sliccy 5.32.4 → 5.32.5

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 (87) hide show
  1. package/dist/ui/assets/{account-store-BokqeKBj.js → account-store-JJwGg0EI.js} +1 -1
  2. package/dist/ui/assets/{account-store-BfOHnqUX.js → account-store-px0p2sZ-.js} +2 -2
  3. package/dist/ui/assets/{adobe-DCTZeeCG.js → adobe-Cx3Nh5ZF.js} +1 -1
  4. package/dist/ui/assets/{adobe-B6BLrKyZ.js → adobe-D-yBTaR3.js} +1 -1
  5. package/dist/ui/assets/{adobe-oauth-state-DyWfCpd9.js → adobe-oauth-state-BErYOXlx.js} +1 -1
  6. package/dist/ui/assets/{agent-message-to-chat-BGOt7zdt.js → agent-message-to-chat-BuKgOtbz.js} +1 -1
  7. package/dist/ui/assets/{apps-So20aUVP.js → apps-CoWRJTR8.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-Dg7P7-zc.js → azure-openai-BvBJjrQj.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-DkXl6rL7.js → azure-openai-DzX7pbt4.js} +1 -1
  10. package/dist/ui/assets/{cdp-wAooorxs.js → cdp-IDGN5yWS.js} +1 -1
  11. package/dist/ui/assets/{cerebras-BHEfKUqA.js → cerebras-Bq4c0Szc.js} +1 -1
  12. package/dist/ui/assets/{cerebras-CqjkCBXf.js → cerebras-x4lXGs4G.js} +1 -1
  13. package/dist/ui/assets/{connect-surface-BKaKXs1I.js → connect-surface-BrHTfkaa.js} +1 -1
  14. package/dist/ui/assets/dip-gWThmqPW.js +1 -0
  15. package/dist/ui/assets/{dist-D_z6cCg2.js → dist-C2TOilKZ.js} +1 -1
  16. package/dist/ui/assets/{dist-CQDi-98s.js → dist-DCNNrkGt.js} +1 -1
  17. package/dist/ui/assets/{ensure-speech-assets-CQm9qv40.js → ensure-speech-assets-BnFHG3HC.js} +1 -1
  18. package/dist/ui/assets/esp8266-CcY_BsyU.js +1 -0
  19. package/dist/ui/assets/{esptool-operations-DX2M1lrH.js → esptool-operations-B7a1-ZSq.js} +2 -2
  20. package/dist/ui/assets/extension-bridge-transport-D4zvQFUJ.js +1 -0
  21. package/dist/ui/assets/{fs-Y501gVp6.js → fs-CAaM6n0v.js} +2 -2
  22. package/dist/ui/assets/{fs-8G6exssT.js → fs-CRn5w89x.js} +1 -1
  23. package/dist/ui/assets/{github-Bb4Uk3zm.js → github-Dgy-88Y4.js} +1 -1
  24. package/dist/ui/assets/{github-CmzugZyZ.js → github-VA-oQqld.js} +2 -2
  25. package/dist/ui/assets/{github-copilot-CEMcvKxO.js → github-copilot-BIUwVuM-.js} +1 -1
  26. package/dist/ui/assets/{github-copilot-BC3lA6pG.js → github-copilot-DH1VPc8n.js} +1 -1
  27. package/dist/ui/assets/{hear-BgLO8_ZV.js → hear-DLkGuMuj.js} +1 -1
  28. package/dist/ui/assets/{kernel-worker-cOMb9dW0.js → kernel-worker-Bg-Mr4P5.js} +18 -18
  29. package/dist/ui/assets/{kokoro-engine-8SK1XhNo.js → kokoro-engine-bQwGz2iy.js} +1 -1
  30. package/dist/ui/assets/{lick-ws-bridge-DUpfw5Cw.js → lick-ws-bridge-DqHNs_TC.js} +1 -1
  31. package/dist/ui/assets/{lick-ws-bridge-ZICrYFIq.js → lick-ws-bridge-a94L_MAh.js} +1 -1
  32. package/dist/ui/assets/{local-llm-DjSsoqBK.js → local-llm-DEibX24u.js} +1 -1
  33. package/dist/ui/assets/{main-BwjqRukt.js → main-ByXMTyEz.js} +4 -4
  34. package/dist/ui/assets/main-cherry-Dl4yLnHl.js +1 -0
  35. package/dist/ui/assets/{mount-DqnZMKpT.js → mount-DrU4sQt2.js} +1 -1
  36. package/dist/ui/assets/{mount-SC46VzJl.js → mount-Dx2SvuKq.js} +2 -2
  37. package/dist/ui/assets/{new-session-B6B6YSVJ.js → new-session-Cq-3aUd5.js} +2 -2
  38. package/dist/ui/assets/{oauth-bootstrap-8oaNo14A.js → oauth-bootstrap-CuCZ3K1C.js} +2 -2
  39. package/dist/ui/assets/{openai-codex-C5L90K9s.js → openai-codex-Bcg7XsxJ.js} +1 -1
  40. package/dist/ui/assets/{openai-codex-BIjw8lvz.js → openai-codex-DdjEKrbs.js} +1 -1
  41. package/dist/ui/assets/page-follower-tray-DD7SJUIA.js +5 -0
  42. package/dist/ui/assets/{panel-rpc-handlers-DWnPCtqS.js → panel-rpc-handlers-b0g-5ls8.js} +2 -2
  43. package/dist/ui/assets/{provider-DtBT8r4B.js → provider-CWjCflQr.js} +2 -2
  44. package/dist/ui/assets/{provider-DCEZLF1W.js → provider-CwLKNsJy.js} +1 -1
  45. package/dist/ui/assets/provider-store-access-B74W83Ux.js +1 -0
  46. package/dist/ui/assets/provider-store-access-C_Wn_w-d.js +1 -0
  47. package/dist/ui/assets/{providers-CvYMDqCL.js → providers-D6-KVJr9.js} +1 -1
  48. package/dist/ui/assets/{providers-DhaH6zef.js → providers-Jt_t5qTc.js} +2 -2
  49. package/dist/ui/assets/{quick-llm-Dq21hPK2.js → quick-llm-C-KEAJdQ.js} +1 -1
  50. package/dist/ui/assets/remote-cdp-transport-ZG2v9Vg-.js +1 -0
  51. package/dist/ui/assets/session-freezer-fPJ0hYDB.js +1 -0
  52. package/dist/ui/assets/{speak-CClITCPK.js → speak-CmcNSPHD.js} +1 -1
  53. package/dist/ui/assets/{sprinkle-manager-gfD7_n13.js → sprinkle-manager-BQu--HzK.js} +1 -1
  54. package/dist/ui/assets/{store-DrCJeBNd.js → store-D9oZpBbh.js} +1 -1
  55. package/dist/ui/assets/{sudo-DgiMHb5o.js → sudo-Ck_pTIzk.js} +1 -1
  56. package/dist/ui/assets/{transformers-env-DKNE7GpB.js → transformers-env-LV0A5mj1.js} +1 -1
  57. package/dist/ui/assets/{tray-leader-Lqisrfbv.js → tray-leader-356dBYZu.js} +1 -1
  58. package/dist/ui/assets/{tray-leave-runtime-C2MoDf-1.js → tray-leave-runtime-t2Mz_UYX.js} +1 -1
  59. package/dist/ui/assets/{upgrade-detection-CbBla6hH.js → upgrade-detection-F3DIg19T.js} +1 -1
  60. package/dist/ui/assets/{voice-reply-CJuWFQPX.js → voice-reply-DepY9B9R.js} +1 -1
  61. package/dist/ui/assets/{wc-attach-jZdZHKD1.js → wc-attach-BHdxhw2P.js} +2 -2
  62. package/dist/ui/assets/{wc-extension-Cs88BUjq.js → wc-extension-CFkvLT92.js} +2 -2
  63. package/dist/ui/assets/{wc-follower-C3__8PFa.js → wc-follower-D-v4jW5A.js} +3 -3
  64. package/dist/ui/assets/{wc-live-DR6tvItT.js → wc-live-DeaUqF1Y.js} +5 -5
  65. package/dist/ui/assets/{wc-nav-DtsNnJ6v.js → wc-nav-DW1Byys4.js} +2 -2
  66. package/dist/ui/assets/{wc-onboarding-D0yx-jSj.js → wc-onboarding-C1UgUky4.js} +2 -2
  67. package/dist/ui/assets/{wc-placeholder-BbSTS-RA.js → wc-placeholder-_Ho5xhzb.js} +3 -3
  68. package/dist/ui/assets/{wc-settings-CPEfugAj.js → wc-settings-CWYXzAaT.js} +2 -2
  69. package/dist/ui/assets/{wc-shell-Dk6AF6cB.js → wc-shell-DLQupMvX.js} +3 -3
  70. package/dist/ui/assets/{wc-sprinkles-BIGx9RF3.js → wc-sprinkles-CcwVs3HA.js} +2 -2
  71. package/dist/ui/assets/wc-tray-C1hvo8mk.js +2 -0
  72. package/dist/ui/assets/{whisper-engine-CRsuayPy.js → whisper-engine-CZBm31yy.js} +1 -1
  73. package/dist/ui/assets/{xai-grok-Bb_OnCv9.js → xai-grok-B6d4phUC.js} +1 -1
  74. package/dist/ui/assets/{xai-grok-B-MyCxjN.js → xai-grok-DTNCrUmU.js} +1 -1
  75. package/dist/ui/index.html +3 -3
  76. package/dist/ui/packages/webapp/index.html +3 -3
  77. package/package.json +1 -1
  78. package/dist/ui/assets/dip-DDOAr0-_.js +0 -1
  79. package/dist/ui/assets/esp8266-XUxBx9Cp.js +0 -1
  80. package/dist/ui/assets/extension-bridge-transport-WLbnai-d.js +0 -1
  81. package/dist/ui/assets/main-cherry-D01ARITG.js +0 -1
  82. package/dist/ui/assets/page-follower-tray-BJ1UHMvQ.js +0 -5
  83. package/dist/ui/assets/provider-store-access-0MbnfMwG.js +0 -1
  84. package/dist/ui/assets/provider-store-access-Bwpbtc8J.js +0 -1
  85. package/dist/ui/assets/remote-cdp-transport-DDt3F4ID.js +0 -1
  86. package/dist/ui/assets/session-freezer-B59WuEaJ.js +0 -1
  87. package/dist/ui/assets/wc-tray-CkhSEgan.js +0 -2
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{b as t,n,r,t as i,y as a}from"./kernel-worker-cOMb9dW0.js";const o=e(`lick-ws-bridge`);function s(e){if(e.stopped)return;let t;try{t=e.wsFactory(e.wsUrl)}catch(t){o.error(`Failed to construct lick WebSocket`,{url:e.wsUrl,error:t instanceof Error?t.message:String(t)}),c(e,`construct-threw`);return}e.socket=t,t.onopen=()=>{e.consecutiveFailures>0?o.info(`Lick WebSocket recovered`,{attempts:e.consecutiveFailures}):o.info(`Lick WebSocket connected`),e.consecutiveFailures=0,e.unrecoverableSignalled=!1},t.onmessage=n=>{u(e,t,n.data).catch(e=>{let t=typeof n.data==`string`?n.data.slice(0,200):`[non-string payload]`;o.error(`Failed to process lick message`,{error:e instanceof Error?e.message:String(e),preview:t})})},t.onclose=n=>{if(e.socket===t&&(e.socket=null),e.stopped)return;let r=n.reason?` reason=${JSON.stringify(n.reason)}`:``;c(e,`disconnected code=${n.code}${r}`)},t.onerror=t=>{let n=t.target;o.error(`Lick WebSocket error`,{url:e.wsUrl,readyState:n?.readyState,eventType:t.type})}}function c(e,t){if(e.reconnectHandle!=null){o.debug(`Lick WS failure during pending reconnect — keeping existing timer`,{cause:t});return}e.consecutiveFailures++;let n=Math.min(e.baseDelay*2**(e.consecutiveFailures-1),6e4),r={url:e.wsUrl,attempt:e.consecutiveFailures,cause:t,retryInMs:n};if(e.consecutiveFailures>=3?o.error(`Lick WebSocket still down`,r):o.warn(`Lick WebSocket down`,r),e.consecutiveFailures===20&&!e.unrecoverableSignalled){e.unrecoverableSignalled=!0;try{e.lickManager.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`lick-ws-bridge-down`,url:e.wsUrl,attempts:e.consecutiveFailures}})}catch(e){o.error(`Failed to emit lick-ws-bridge-down signal`,{error:e instanceof Error?e.message:String(e)})}}l(e,n)}function l(e,t){e.stopped||e.reconnectHandle!=null||(e.reconnectHandle=e.setTimer(()=>{e.reconnectHandle=null,s(e)},t))}async function u(e,t,n){let r=JSON.parse(typeof n==`string`?n:String(n));if(r.requestId){let n=r.requestId,i=await m(e,r,n);if(e.stopped||e.socket!==t||t.readyState!==1){o.warn(`Lick reply dropped — socket changed/closed mid-request`,{type:r.type,requestId:n});return}try{t.send(JSON.stringify(i))}catch(e){o.error(`ws.send() failed delivering lick reply`,{type:r.type,requestId:n,error:e instanceof Error?e.message:String(e)})}return}if(r.type===`webhook_event`){d(e.lickManager,r);return}r.type===`navigate_event`&&p(e.lickManager,r)}function d(e,t){let n=typeof t.webhookId==`string`?t.webhookId:null;if(!n){o.error(`Malformed webhook_event from lick-ws`,{receivedKeys:Object.keys(t)});return}let r=t.headers&&typeof t.headers==`object`?t.headers:{};try{e.handleWebhookEvent(n,r,t.body)}catch(e){o.error(`Webhook event dispatch failed`,{webhookId:n,error:e instanceof Error?e.message:String(e)})}}function f(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function p(e,t){let n=f(t);if(!n){o.debug(`navigate_event dropped — invalid payload`,{hasVerb:typeof t.verb==`string`,hasTarget:typeof t.target==`string`,hasUrl:typeof t.url==`string`&&t.url.length>0});return}e.emitEvent(n)}async function m(e,t,n){let{lickManager:r}=e;try{switch(t.type){case`list_webhooks`:return{type:`response`,requestId:n,data:r.listWebhooks().map(t=>({...t,url:h(e,t.id)}))};case`create_webhook`:{let i=await r.createWebhook(t.name||`default`,t.scoop,t.filter);return{type:`response`,requestId:n,data:{...i,url:h(e,i.id)}}}case`delete_webhook`:return await r.deleteWebhook(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Webhook not found`}};case`list_crontasks`:return{type:`response`,requestId:n,data:r.listCronTasks()};case`create_crontask`:if(!t.name)throw Error(`name is required`);if(!t.cron)throw Error(`cron is required`);return{type:`response`,requestId:n,data:await r.createCronTask(t.name,t.cron,t.scoop,t.filter)};case`delete_crontask`:return await r.deleteCronTask(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Cron task not found`}};case`tray_status`:{let e=a();return{type:`response`,requestId:n,data:{state:e.state,joinUrl:e.session?.joinUrl??null,workerBaseUrl:e.session?.workerBaseUrl??null,trayId:e.session?.trayId??null}}}default:return{type:`response`,requestId:n,error:`Unknown request type: ${t.type}`}}}catch(e){return{type:`response`,requestId:n,error:e instanceof Error?e.message:String(e)}}}function h(e,i){let a=t().session;return a?.webhookUrl?n(a.webhookUrl,i):e.webhookOriginOverride?`${e.webhookOriginOverride}/webhooks/${i}`:r(e.options.locationHref,i)}function g(e){if(e.stopped)return;e.stopped=!0,e.reconnectHandle!=null&&(e.clearTimer(e.reconnectHandle),e.reconnectHandle=null);let t=e.socket;if(e.socket=null,t)try{t.close()}catch(e){t.readyState!==3&&t.readyState!==2&&o.warn(`Lick socket close() threw before terminal state`,{readyState:t.readyState,error:e instanceof Error?e.message:String(e)})}}function _(e,t){try{new URL(t.locationHref)}catch(e){throw Error(`startLickWsBridge: invalid locationHref ${JSON.stringify(t.locationHref)}: ${e instanceof Error?e.message:String(e)}`)}let n=typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0?t.lickWsUrl:i(t.locationHref),r=null;if(typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0)try{let e=new URL(t.lickWsUrl);r=`${e.protocol===`wss:`?`https:`:`http:`}//${e.host}`}catch{r=null}let a={lickManager:e,options:t,wsUrl:n,webhookOriginOverride:r,baseDelay:t.reconnectDelayMs??3e3,wsFactory:t.webSocketFactory??(e=>new WebSocket(e)),setTimer:t.setTimeoutFn??setTimeout.bind(globalThis),clearTimer:t.clearTimeoutFn??clearTimeout.bind(globalThis),stopped:!1,socket:null,reconnectHandle:null,consecutiveFailures:0,unrecoverableSignalled:!1};return s(a),{stop(){g(a)}}}export{_ as startLickWsBridge};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{b as t,n,r,t as i,y as a}from"./kernel-worker-Bg-Mr4P5.js";const o=e(`lick-ws-bridge`);function s(e){if(e.stopped)return;let t;try{t=e.wsFactory(e.wsUrl)}catch(t){o.error(`Failed to construct lick WebSocket`,{url:e.wsUrl,error:t instanceof Error?t.message:String(t)}),c(e,`construct-threw`);return}e.socket=t,t.onopen=()=>{e.consecutiveFailures>0?o.info(`Lick WebSocket recovered`,{attempts:e.consecutiveFailures}):o.info(`Lick WebSocket connected`),e.consecutiveFailures=0,e.unrecoverableSignalled=!1},t.onmessage=n=>{u(e,t,n.data).catch(e=>{let t=typeof n.data==`string`?n.data.slice(0,200):`[non-string payload]`;o.error(`Failed to process lick message`,{error:e instanceof Error?e.message:String(e),preview:t})})},t.onclose=n=>{if(e.socket===t&&(e.socket=null),e.stopped)return;let r=n.reason?` reason=${JSON.stringify(n.reason)}`:``;c(e,`disconnected code=${n.code}${r}`)},t.onerror=t=>{let n=t.target;o.error(`Lick WebSocket error`,{url:e.wsUrl,readyState:n?.readyState,eventType:t.type})}}function c(e,t){if(e.reconnectHandle!=null){o.debug(`Lick WS failure during pending reconnect — keeping existing timer`,{cause:t});return}e.consecutiveFailures++;let n=Math.min(e.baseDelay*2**(e.consecutiveFailures-1),6e4),r={url:e.wsUrl,attempt:e.consecutiveFailures,cause:t,retryInMs:n};if(e.consecutiveFailures>=3?o.error(`Lick WebSocket still down`,r):o.warn(`Lick WebSocket down`,r),e.consecutiveFailures===20&&!e.unrecoverableSignalled){e.unrecoverableSignalled=!0;try{e.lickManager.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`lick-ws-bridge-down`,url:e.wsUrl,attempts:e.consecutiveFailures}})}catch(e){o.error(`Failed to emit lick-ws-bridge-down signal`,{error:e instanceof Error?e.message:String(e)})}}l(e,n)}function l(e,t){e.stopped||e.reconnectHandle!=null||(e.reconnectHandle=e.setTimer(()=>{e.reconnectHandle=null,s(e)},t))}async function u(e,t,n){let r=JSON.parse(typeof n==`string`?n:String(n));if(r.requestId){let n=r.requestId,i=await m(e,r,n);if(e.stopped||e.socket!==t||t.readyState!==1){o.warn(`Lick reply dropped — socket changed/closed mid-request`,{type:r.type,requestId:n});return}try{t.send(JSON.stringify(i))}catch(e){o.error(`ws.send() failed delivering lick reply`,{type:r.type,requestId:n,error:e instanceof Error?e.message:String(e)})}return}if(r.type===`webhook_event`){d(e.lickManager,r);return}r.type===`navigate_event`&&p(e.lickManager,r)}function d(e,t){let n=typeof t.webhookId==`string`?t.webhookId:null;if(!n){o.error(`Malformed webhook_event from lick-ws`,{receivedKeys:Object.keys(t)});return}let r=t.headers&&typeof t.headers==`object`?t.headers:{};try{e.handleWebhookEvent(n,r,t.body)}catch(e){o.error(`Webhook event dispatch failed`,{webhookId:n,error:e instanceof Error?e.message:String(e)})}}function f(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function p(e,t){let n=f(t);if(!n){o.debug(`navigate_event dropped — invalid payload`,{hasVerb:typeof t.verb==`string`,hasTarget:typeof t.target==`string`,hasUrl:typeof t.url==`string`&&t.url.length>0});return}e.emitEvent(n)}async function m(e,t,n){let{lickManager:r}=e;try{switch(t.type){case`list_webhooks`:return{type:`response`,requestId:n,data:r.listWebhooks().map(t=>({...t,url:h(e,t.id)}))};case`create_webhook`:{let i=await r.createWebhook(t.name||`default`,t.scoop,t.filter);return{type:`response`,requestId:n,data:{...i,url:h(e,i.id)}}}case`delete_webhook`:return await r.deleteWebhook(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Webhook not found`}};case`list_crontasks`:return{type:`response`,requestId:n,data:r.listCronTasks()};case`create_crontask`:if(!t.name)throw Error(`name is required`);if(!t.cron)throw Error(`cron is required`);return{type:`response`,requestId:n,data:await r.createCronTask(t.name,t.cron,t.scoop,t.filter)};case`delete_crontask`:return await r.deleteCronTask(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Cron task not found`}};case`tray_status`:{let e=a();return{type:`response`,requestId:n,data:{state:e.state,joinUrl:e.session?.joinUrl??null,workerBaseUrl:e.session?.workerBaseUrl??null,trayId:e.session?.trayId??null}}}default:return{type:`response`,requestId:n,error:`Unknown request type: ${t.type}`}}}catch(e){return{type:`response`,requestId:n,error:e instanceof Error?e.message:String(e)}}}function h(e,i){let a=t().session;return a?.webhookUrl?n(a.webhookUrl,i):e.webhookOriginOverride?`${e.webhookOriginOverride}/webhooks/${i}`:r(e.options.locationHref,i)}function g(e){if(e.stopped)return;e.stopped=!0,e.reconnectHandle!=null&&(e.clearTimer(e.reconnectHandle),e.reconnectHandle=null);let t=e.socket;if(e.socket=null,t)try{t.close()}catch(e){t.readyState!==3&&t.readyState!==2&&o.warn(`Lick socket close() threw before terminal state`,{readyState:t.readyState,error:e instanceof Error?e.message:String(e)})}}function _(e,t){try{new URL(t.locationHref)}catch(e){throw Error(`startLickWsBridge: invalid locationHref ${JSON.stringify(t.locationHref)}: ${e instanceof Error?e.message:String(e)}`)}let n=typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0?t.lickWsUrl:i(t.locationHref),r=null;if(typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0)try{let e=new URL(t.lickWsUrl);r=`${e.protocol===`wss:`?`https:`:`http:`}//${e.host}`}catch{r=null}let a={lickManager:e,options:t,wsUrl:n,webhookOriginOverride:r,baseDelay:t.reconnectDelayMs??3e3,wsFactory:t.webSocketFactory??(e=>new WebSocket(e)),setTimer:t.setTimeoutFn??setTimeout.bind(globalThis),clearTimer:t.clearTimeoutFn??clearTimeout.bind(globalThis),stopped:!1,socket:null,reconnectHandle:null,consecutiveFailures:0,unrecoverableSignalled:!1};return s(a),{stop(){g(a)}}}export{_ as startLickWsBridge};
@@ -1,2 +1,2 @@
1
- import{s as e}from"./models-ByRUWfA-.js";import{a as t,c as n,f as r}from"./compat-DADQxxLV.js";import{b as i}from"./account-store-BokqeKBj.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"./models-ByRUWfA-.js";import{a as t,c as n,f as r}from"./compat-DADQxxLV.js";import{b as i}from"./account-store-JJwGg0EI.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 e=d(i(s));return e.length===0?[{id:l,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 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,r={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?n(m(e),t,h(r)):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?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(t,n){let r=e(),i={role:`assistant`,content:[],api:t.api,provider:t.provider,model:t.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(){t({api:p,stream:g,streamSimple:_})}function b(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function x(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function S(e,t,n){let r=`${x(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 C(e,t){let n=b(e),r=await T(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};let i=await T(`${n}/api/v0/models`,t);if(i&&i.object===`list`)return{kind:`lmstudio`};let a=await T(`${n}/props`,t);if(a&&`build_info`in a)return{kind:`llamacpp`,version:a.build_info?.version};let o=w(e);return o===`11434`?{kind:`ollama`}:o===`1234`?{kind:`lmstudio`}:o===`8000`?{kind:`vllm`}:o===`1337`?{kind:`jan`}:{kind:`unknown`}}function w(e){try{return new URL(e).port||null}catch{return null}}async function T(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function E(e,t,n){let r={kind:`unknown`};try{r=await C(e,n)}catch{}try{let i=await S(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=D(n,r.kind);return o.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function D(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,C as detectRuntime,S as discoverModels,b as originOf,y as register,E as verifyConnection};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sudo-DgiMHb5o.js","assets/preload-helper-CZgWQFsJ.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CaWoNw-n.js","assets/rolldown-runtime-aKtaBQYM.js","assets/src-YN73WJ67.js","assets/fetch-body-D2PwksUW.js","assets/quick-llm-Dq21hPK2.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-BokqeKBj.js","assets/context-compaction-DaxQExZG.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DhaH6zef.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js","assets/panel-responder-BKgfV-nl.js","assets/extension-bridge-transport-WLbnai-d.js","assets/cdp-bridge-CUqQUcaF.js","assets/lick-ws-bridge-DUpfw5Cw.js","assets/tray-leader-Lqisrfbv.js","assets/cdp-wAooorxs.js","assets/navigation-watcher-C2s0i0h4.js","assets/handoff-link-w8LYa3Ua.js","assets/remote-cdp-transport-DDt3F4ID.js","assets/main-cherry-D01ARITG.js","assets/synthetic-cdp-transport-DLIt5SkY.js","assets/oauth-service-DdejFjWa.js","assets/wc-permissions-registry-Blyunq37.js","assets/wc-shell-Dk6AF6cB.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-C3__8PFa.js","assets/theme-engine-BEk-Upnk.js","assets/wc-attach-jZdZHKD1.js","assets/wc-live-DR6tvItT.js","assets/hid-device-registry-6w-g8ZpF.js","assets/serial-port-registry-DsPZvGpT.js","assets/usb-operations-D-YdmmuG.js","assets/usb-device-registry-k6vTKonT.js","assets/shared-BtKwD6I9.js","assets/mime-types-ugOWOUZ9.js","assets/sprinkle-renderer-DryXybiX.js","assets/theme-BWT6ZRD3.js","assets/sprinkle-bridge-CZr9Wcf7.js","assets/page-follower-tray-BJ1UHMvQ.js","assets/wc-sprinkles-BIGx9RF3.js","assets/oauth-bootstrap-8oaNo14A.js","assets/legacy-styles-CuB1P3LZ.js","assets/connect-surface-BKaKXs1I.js","assets/wc-extension-Cs88BUjq.js","assets/wc-detached-B3WCbbZT.js","assets/messages-BD4p8GuF.js"])))=>i.map(i=>d[i]);
2
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o.js";import{t}from"./preload-helper-CZgWQFsJ.js";import{A as n,B as r,C as i,D as a,E as o,F as s,H as c,I as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,_ as x,a as S,b as C,c as ee,d as w,f as te,g as ne,h as re,i as T,j as ie,k as ae,l as oe,m as se,n as ce,o as le,p as ue,s as de,t as fe,u as pe,v as me,w as he,x as ge,y as E,z as _e}from"./account-store-BokqeKBj.js";import{t as D}from"./logger-DDBAeTLF.js";import{a as ve,o as ye,r as be,s as xe}from"./src-YN73WJ67.js";import{a as Se,c as Ce,o as we,s as Te,t as Ee}from"./proxied-fetch-CaWoNw-n.js";import{a as De}from"./providers-DhaH6zef.js";import"./messages-BD4p8GuF.js";import{n as Oe}from"./clipboard-DuHpK59o.js";function ke(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function Ae(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function je(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(xe),r=t.get(ye);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(be),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${ve}${r}`,token:r,apiBaseUrl:ke(n),lickWsUrl:Ae(n),role:a}}var Me=`slicc:bridge-config`,Ne=`slicc:extension-delegate-config`;function Pe(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 Fe=D(`boot/ext-fetch-delegate`);function Ie(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function Le(e,t,n){let r=Ie();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 Re(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Pe(t.data))return;let n=t.ports?.[0];if(!n){Fe.warn(`delegated fetch envelope arrived without a response port`);return}Le(t.data,n,e)})}function ze(){if(typeof chrome<`u`&&chrome?.runtime?.id)return;let e=new Blob([`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sudo-Ck_pTIzk.js","assets/preload-helper-CZgWQFsJ.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CaWoNw-n.js","assets/rolldown-runtime-aKtaBQYM.js","assets/src-YN73WJ67.js","assets/fetch-body-D2PwksUW.js","assets/quick-llm-C-KEAJdQ.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-JJwGg0EI.js","assets/context-compaction-DaxQExZG.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Jt_t5qTc.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js","assets/panel-responder-BKgfV-nl.js","assets/extension-bridge-transport-D4zvQFUJ.js","assets/cdp-bridge-CUqQUcaF.js","assets/lick-ws-bridge-DqHNs_TC.js","assets/tray-leader-356dBYZu.js","assets/cdp-IDGN5yWS.js","assets/navigation-watcher-C2s0i0h4.js","assets/handoff-link-w8LYa3Ua.js","assets/remote-cdp-transport-ZG2v9Vg-.js","assets/main-cherry-Dl4yLnHl.js","assets/synthetic-cdp-transport-DLIt5SkY.js","assets/oauth-service-DdejFjWa.js","assets/wc-permissions-registry-Blyunq37.js","assets/wc-shell-DLQupMvX.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-D-v4jW5A.js","assets/theme-engine-BEk-Upnk.js","assets/wc-attach-BHdxhw2P.js","assets/wc-live-DeaUqF1Y.js","assets/hid-device-registry-6w-g8ZpF.js","assets/serial-port-registry-DsPZvGpT.js","assets/usb-operations-D-YdmmuG.js","assets/usb-device-registry-k6vTKonT.js","assets/shared-BtKwD6I9.js","assets/mime-types-ugOWOUZ9.js","assets/sprinkle-renderer-DryXybiX.js","assets/theme-BWT6ZRD3.js","assets/sprinkle-bridge-CZr9Wcf7.js","assets/page-follower-tray-DD7SJUIA.js","assets/wc-sprinkles-CcwVs3HA.js","assets/oauth-bootstrap-CuCZ3K1C.js","assets/legacy-styles-CuB1P3LZ.js","assets/connect-surface-BrHTfkaa.js","assets/wc-extension-CFkvLT92.js","assets/wc-detached-B3WCbbZT.js","assets/messages-BD4p8GuF.js"])))=>i.map(i=>d[i]);
2
+ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o.js";import{t}from"./preload-helper-CZgWQFsJ.js";import{A as n,B as r,C as i,D as a,E as o,F as s,H as c,I as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,_ as x,a as S,b as C,c as ee,d as w,f as te,g as ne,h as re,i as T,j as ie,k as ae,l as oe,m as se,n as ce,o as le,p as ue,s as de,t as fe,u as pe,v as me,w as he,x as ge,y as E,z as _e}from"./account-store-JJwGg0EI.js";import{t as D}from"./logger-DDBAeTLF.js";import{a as ve,o as ye,r as be,s as xe}from"./src-YN73WJ67.js";import{a as Se,c as Ce,o as we,s as Te,t as Ee}from"./proxied-fetch-CaWoNw-n.js";import{a as De}from"./providers-Jt_t5qTc.js";import"./messages-BD4p8GuF.js";import{n as Oe}from"./clipboard-DuHpK59o.js";function ke(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function Ae(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function je(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(xe),r=t.get(ye);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(be),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${ve}${r}`,token:r,apiBaseUrl:ke(n),lickWsUrl:Ae(n),role:a}}var Me=`slicc:bridge-config`,Ne=`slicc:extension-delegate-config`;function Pe(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 Fe=D(`boot/ext-fetch-delegate`);function Ie(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function Le(e,t,n){let r=Ie();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 Re(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Pe(t.data))return;let n=t.ports?.[0];if(!n){Fe.warn(`delegated fetch envelope arrived without a response port`);return}Le(t.data,n,e)})}function ze(){if(typeof chrome<`u`&&chrome?.runtime?.id)return;let e=new Blob([`
3
3
  let lastPong = Date.now();
4
4
  let frozen = false;
5
5
  setInterval(() => {
@@ -19,6 +19,6 @@ import{n as e}from"./rolldown-runtime-aKtaBQYM.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 Be=`slicc-nuke-control`;function Ve(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(Be),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 O=null;function He(){return O||(O=Ve(),O)}var k=`tray`,Ue=`trayWorkerUrl`,We=`lead`;function A(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``,t.pathname!==`/`&&(t.pathname=t.pathname.replace(/\/+$/,``)||`/`);let n=t.toString();return n.endsWith(`/`)?n.slice(0,-1):n}catch{return null}}function Ge(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.toString(),r=t.pathname.split(`/`).filter(Boolean);if(r.length<2||r.at(-2)!==`join`)return null;let[i,a,...o]=decodeURIComponent(r.at(-1)).split(`.`);if(!i||!a||o.length>0)return null;r.splice(-2,2),t.pathname=r.length>0?`/${r.join(`/`)}`:`/`;let s=A(t.toString());return s?{workerBaseUrl:s,trayId:i,joinUrl:n}:null}catch{return null}}function Ke(e,t){let n=new URL(e);return n.searchParams.delete(Ue),n.searchParams.delete(We),n.searchParams.set(k,t),n.toString()}var j=`slicc.trayWorkerBaseUrl`,M=`slicc.trayJoinUrl`,qe=`https://www.sliccy.ai`;function Je(e,t){let n=A(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t.replace(/^\/+/,``);return new URL(r,`${n}/`).toString()}function N(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=null;if(n.length>=2&&n.at(-2)===`tray`)r=decodeURIComponent(n.at(-1)),n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`;else if(n.length>=2&&n.at(-2)===`join`)return Ge(t.toString());let i=A(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function P(e){let t=N(e);return t?.joinUrl?t:null}function F(e,t){let n=P(t);return n?(e.setItem(M,n.joinUrl),e.setItem(j,n.workerBaseUrl),n):null}function Ye(e){return!!P(e?.getItem(`slicc.trayJoinUrl`)??null)}function Xe(e,t){let n=!1;try{let t=new URL(e),r=t.searchParams.get(k);if(r!==null){n=!0;let e=N(r);if(e?.joinUrl)return e.joinUrl}t.searchParams.get(`slicc`)===`leader`&&(n=!0)}catch{}let r=N(e);return r?.joinUrl?r.joinUrl:(r?.trayId&&(n=!0),n?null:P(t?.getItem(`slicc.trayJoinUrl`)??null)?.joinUrl??null)}function Ze(e){try{let t=new URL(e);t.searchParams.delete(k);let n=t.pathname.split(`/`).filter(Boolean);return n.length>=2&&n.at(-2)===`join`&&(n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`),t.toString()}catch{return e}}function Qe(e,t){let n=A(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t?.trim();return r?new URL(`tray/${encodeURIComponent(r)}`,`${n}/`).toString():n}function $e(e,t,n){return Ke(e,Qe(t,n))}async function et(e){let t=rt(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(M,t.joinUrl),e.storage.setItem(j,t.workerBaseUrl)),t;let n=P(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(j,n.workerBaseUrl),n;let r=e.runtimeConfigFetcher?await it(e.runtimeConfigFetcher):null;if(r?.joinConfig)return e.storage&&(e.storage.setItem(M,r.joinConfig.joinUrl),e.storage.setItem(j,r.joinConfig.workerBaseUrl)),r.joinConfig;let i=r?.workerBaseUrl??null,a=A(e.storage?.getItem(`slicc.trayWorkerBaseUrl`)??null),o=A(e.envBaseUrl??null),s=A(e.defaultWorkerBaseUrl??null),c=i??a??o??s;return c?(e.storage&&e.storage.setItem(j,c),{workerBaseUrl:c,trayId:null,joinUrl:null}):null}async function tt(e){return(await et(e))?.workerBaseUrl??null}async function nt(e=fetch){try{let t=await e(Se(`/api/runtime-config`),{cache:`no-store`,headers:Ee()});return t.ok?await t.json():null}catch{return null}}function rt(e){try{let t=new URL(e),n=N(t.searchParams.get(k));if(n)return n;let r=N(t.searchParams.get(We));if(r)return r;let i=A(t.searchParams.get(Ue));return i?{workerBaseUrl:i,trayId:null,joinUrl:null}:Ge(e)||null}catch{return null}}async function it(e){let t=await e();if(!t)return null;let n=P(t.trayJoinUrl??null);return{workerBaseUrl:A(t.trayWorkerBaseUrl??null),joinConfig:n}}var at=`slicc-cdp-superseded-banner`;function ot(e){if(e.getElementById(at))return;let t=e.createElement(`div`);t.id=at,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)}function st(e,t,n){if(t){try{if(new URL(e).searchParams.get(`detached`)===`1`)return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);return t.searchParams.get(`connect`)===`1`?`connect`:t.searchParams.get(`runtime`)===`hosted-leader`?`hosted-leader`:t.searchParams.get(`cherry`)===`1`?`cherry`:Xe(e,n===void 0?typeof window<`u`?window.localStorage:null:n)?`follower`:lt(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ct(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function lt(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}var ut=e({setupSudoExtension:()=>ft,setupSudoStandalone:()=>dt});async function dt(e){let{installSudoTestHook:n}=await t(async()=>{let{installSudoTestHook:e}=await import(`./sudo-DgiMHb5o.js`);return{installSudoTestHook: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,24]));n()}async function ft(e){let{installPanelSudoResponder:n}=await t(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-DgiMHb5o.js`);return{installPanelSudoResponder: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,24]));n()}function pt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function mt(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}function I(){return typeof globalThis.chrome?.runtime?.connect==`function`}var ht=[100,200,400,800,1600];async function gt(e,t,n,r=ht,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 _t(e,n,r){let{ExtensionBridgeTransport:i}=await t(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-WLbnai-d.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([25,2,26])),{mapNavigatePayloadToLickEvent:a}=await t(async()=>{let{mapNavigatePayloadToLickEvent:e}=await import(`./lick-ws-bridge-DUpfw5Cw.js`);return{mapNavigatePayloadToLickEvent:e}},__vite__mapDeps([27,2,28,4,3,1,5,6])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=new e(new i({extensionId:n,onLick:e=>{let t=a(e);if(t){if(o){o.sendForwardedLick(t);return}s.length>=50&&(s.shift(),c||(c=!0,r.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(t)}}}));return await gt(u,void 0,r),{browser:u,attachLickForwardingClient:l}}async function vt(e){let{runtimeMode:n,envBaseUrl:r,window:i,log:a}=e,o=n===`electron-overlay`;a.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:n});let{BrowserAPI:s}=await t(async()=>{let{BrowserAPI:e}=await import(`./cdp-wAooorxs.js`);return{BrowserAPI:e}},__vite__mapDeps([29,2,30,31,32,4]));await dt({log:a});let c,l,u,d=null,f=null,p=null,m=null,h,g=n===`cherry`?null:mt(i.location.search),_=!!g&&I(),v=n===`cherry`||_?null:je(i.location.search);v?.apiBaseUrl&&(d=v.apiBaseUrl,Ce(v.apiBaseUrl),f=v.token,we(v.token)),v?.lickWsUrl&&(p=v.lickWsUrl);let y=await nt(),b=ct(n,y!==null)?qe:null;if(await et({locationHref:i.location.href,storage:i.localStorage,envBaseUrl:r,defaultWorkerBaseUrl:b,runtimeConfigFetcher:async()=>y}),n===`cherry`){let{setupCherryFollower:e}=await t(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-D01ARITG.js`);return{setupCherryFollower:e}},__vite__mapDeps([33,2,29,30,31,32,4,34])),n=await e();c=n.browser,l=n.joinUrl,u=n.transport}else if(g&&I()){a.info(`Routing CDP through the extension bridge (leader tab)`);let e=await _t(s,g.extensionId,a);c=e.browser,h=e.attachLickForwardingClient,m=g.extensionId,Te(g.extensionId)}else{c=new s,v&&a.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`?(a.info(`Skipping CDP connect for follower overlay tab`),c.primeConnectOptions(e)):(await gt(c,e,a),c.setCdpSupersededHandler(()=>ot(i.document)))}let x=c.getTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:x,cherryJoinUrl:l,cherryTransport:u,instanceId:pt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m,attachLickForwardingClient:h}}var L=D(`boot/sw-registration`);async function yt(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 St())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),L.info(`Preview SW registered`),!(typeof chrome<`u`&&chrome?.runtime?.id))try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),L.info(`LLM-proxy SW registered`)}catch(e){L.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`),L.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(bt(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{bt(e)})),t&&(xt(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{xt(t)}))}catch(e){L.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function bt(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Me,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){L.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function xt(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ne,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){L.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function St(){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`),L.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){L.error(`connect-mode SW cleanup failed`,e)}return!1}var R={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function z(){return{...R}}var Ct=`slicc.followerTrayStatus`,B=new Set;function wt(e){return B.add(e),()=>{B.delete(e)}}function Tt(){if(B.size!==0)for(let e of[...B])try{e({...R})}catch{}}function Et(e){R={...e},Tt()}function Dt(e){R={...R,lastPingTime:e},Tt()}function Ot(e){return typeof e==`string`&&e.startsWith(`No API key configured`)}function kt(e){if(!e)return!1;let t=e.toLowerCase();return t.includes(`the provided model identifier is invalid`)||t.includes(`model not allowed`)}function V(e){return e?e.toLowerCase().includes(`please log in again`):!1}function At(e){return Ot(e)||kt(e)||V(e)}var H=null,jt=!1;function Mt(){return typeof window>`u`||typeof document>`u`||document?.documentElement===void 0||typeof localStorage?.getItem!=`function`}function Nt(){return Mt()?`standalone-worker`:typeof chrome<`u`&&chrome?.runtime?.id?`extension`:typeof document<`u`&&document.documentElement?.dataset?.electronOverlay?`electron`:`cli`}async function Pt(){if(!jt&&!(typeof localStorage<`u`&&typeof localStorage?.getItem==`function`&&localStorage.getItem(`telemetry-disabled`)===`true`))try{let e=Nt();e!==`standalone-worker`&&typeof window<`u`?window.RUM_GENERATION=`slicc-${e}`:globalThis.RUM_GENERATION=`slicc-${e}`,e===`standalone-worker`?(H=(await t(()=>import(`./rum-worker-CwmNSpjO.js`),[])).default,self.addEventListener(`error`,e=>{let t=e;U(`js`,t.error?.message??t.message??``)}),self.addEventListener(`unhandledrejection`,e=>{let t=e.reason;U(`js`,t instanceof Error?t.message:String(t))})):e===`extension`?(H=(await t(()=>import(`./rum-DW84CvBs.js`),[])).default,typeof window<`u`&&(window.addEventListener(`error`,e=>{let t=e;U(`js`,t.error?.message??t.message??``)}),window.addEventListener(`unhandledrejection`,e=>{let t=e.reason;U(`js`,t instanceof Error?t.message:String(t))}))):(typeof window<`u`&&(window.SAMPLE_PAGEVIEWS_AT_RATE=`high`),Wt(),H=(await t(()=>import(`./src-C9oNvq2b.js`),[])).sampleRUM),jt=!0,H&&H(`navigate`,{source:typeof document<`u`?document.referrer:``,target:e})}catch{}}function Ft(e,t){H?.(`formsubmit`,{source:e,target:t})}function It(e){H?.(`viewblock`,{source:e})}function Lt(e){H?.(`viewmedia`,{source:e})}function U(e,t){let n=t;if(typeof n==`string`){if(At(n))return;let e=Bt(n);if(e===null)return;n=e}H?.(`error`,{source:e,target:n})}function Rt(e){H?.(`signup`,{source:e})}function zt(e){return e.includes(`@vite/client`)||e.includes(`@vite/env`)||e.includes(`[vite]`)||/https?:\/\/localhost:\d+\/@vite\//.test(e)||/\/__vite_ping/.test(e)}function Bt(e){let t=e??``;if(t.includes(`@vite/`)||t.includes(`[vite]`)||t.includes(`__vite_ping`)){let e=t.split(`
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 Be=`slicc-nuke-control`;function Ve(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(Be),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 O=null;function He(){return O||(O=Ve(),O)}var k=`tray`,Ue=`trayWorkerUrl`,We=`lead`;function A(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``,t.pathname!==`/`&&(t.pathname=t.pathname.replace(/\/+$/,``)||`/`);let n=t.toString();return n.endsWith(`/`)?n.slice(0,-1):n}catch{return null}}function Ge(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.toString(),r=t.pathname.split(`/`).filter(Boolean);if(r.length<2||r.at(-2)!==`join`)return null;let[i,a,...o]=decodeURIComponent(r.at(-1)).split(`.`);if(!i||!a||o.length>0)return null;r.splice(-2,2),t.pathname=r.length>0?`/${r.join(`/`)}`:`/`;let s=A(t.toString());return s?{workerBaseUrl:s,trayId:i,joinUrl:n}:null}catch{return null}}function Ke(e,t){let n=new URL(e);return n.searchParams.delete(Ue),n.searchParams.delete(We),n.searchParams.set(k,t),n.toString()}var j=`slicc.trayWorkerBaseUrl`,M=`slicc.trayJoinUrl`,qe=`https://www.sliccy.ai`;function Je(e,t){let n=A(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t.replace(/^\/+/,``);return new URL(r,`${n}/`).toString()}function N(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=null;if(n.length>=2&&n.at(-2)===`tray`)r=decodeURIComponent(n.at(-1)),n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`;else if(n.length>=2&&n.at(-2)===`join`)return Ge(t.toString());let i=A(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function P(e){let t=N(e);return t?.joinUrl?t:null}function F(e,t){let n=P(t);return n?(e.setItem(M,n.joinUrl),e.setItem(j,n.workerBaseUrl),n):null}function Ye(e){return!!P(e?.getItem(`slicc.trayJoinUrl`)??null)}function Xe(e,t){let n=!1;try{let t=new URL(e),r=t.searchParams.get(k);if(r!==null){n=!0;let e=N(r);if(e?.joinUrl)return e.joinUrl}t.searchParams.get(`slicc`)===`leader`&&(n=!0)}catch{}let r=N(e);return r?.joinUrl?r.joinUrl:(r?.trayId&&(n=!0),n?null:P(t?.getItem(`slicc.trayJoinUrl`)??null)?.joinUrl??null)}function Ze(e){try{let t=new URL(e);t.searchParams.delete(k);let n=t.pathname.split(`/`).filter(Boolean);return n.length>=2&&n.at(-2)===`join`&&(n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`),t.toString()}catch{return e}}function Qe(e,t){let n=A(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t?.trim();return r?new URL(`tray/${encodeURIComponent(r)}`,`${n}/`).toString():n}function $e(e,t,n){return Ke(e,Qe(t,n))}async function et(e){let t=rt(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(M,t.joinUrl),e.storage.setItem(j,t.workerBaseUrl)),t;let n=P(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(j,n.workerBaseUrl),n;let r=e.runtimeConfigFetcher?await it(e.runtimeConfigFetcher):null;if(r?.joinConfig)return e.storage&&(e.storage.setItem(M,r.joinConfig.joinUrl),e.storage.setItem(j,r.joinConfig.workerBaseUrl)),r.joinConfig;let i=r?.workerBaseUrl??null,a=A(e.storage?.getItem(`slicc.trayWorkerBaseUrl`)??null),o=A(e.envBaseUrl??null),s=A(e.defaultWorkerBaseUrl??null),c=i??a??o??s;return c?(e.storage&&e.storage.setItem(j,c),{workerBaseUrl:c,trayId:null,joinUrl:null}):null}async function tt(e){return(await et(e))?.workerBaseUrl??null}async function nt(e=fetch){try{let t=await e(Se(`/api/runtime-config`),{cache:`no-store`,headers:Ee()});return t.ok?await t.json():null}catch{return null}}function rt(e){try{let t=new URL(e),n=N(t.searchParams.get(k));if(n)return n;let r=N(t.searchParams.get(We));if(r)return r;let i=A(t.searchParams.get(Ue));return i?{workerBaseUrl:i,trayId:null,joinUrl:null}:Ge(e)||null}catch{return null}}async function it(e){let t=await e();if(!t)return null;let n=P(t.trayJoinUrl??null);return{workerBaseUrl:A(t.trayWorkerBaseUrl??null),joinConfig:n}}var at=`slicc-cdp-superseded-banner`;function ot(e){if(e.getElementById(at))return;let t=e.createElement(`div`);t.id=at,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)}function st(e,t,n){if(t){try{if(new URL(e).searchParams.get(`detached`)===`1`)return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);return t.searchParams.get(`connect`)===`1`?`connect`:t.searchParams.get(`runtime`)===`hosted-leader`?`hosted-leader`:t.searchParams.get(`cherry`)===`1`?`cherry`:Xe(e,n===void 0?typeof window<`u`?window.localStorage:null:n)?`follower`:lt(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ct(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function lt(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}var ut=e({setupSudoExtension:()=>ft,setupSudoStandalone:()=>dt});async function dt(e){let{installSudoTestHook:n}=await t(async()=>{let{installSudoTestHook:e}=await import(`./sudo-Ck_pTIzk.js`);return{installSudoTestHook: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,24]));n()}async function ft(e){let{installPanelSudoResponder:n}=await t(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-Ck_pTIzk.js`);return{installPanelSudoResponder: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,24]));n()}function pt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function mt(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}function I(){return typeof globalThis.chrome?.runtime?.connect==`function`}var ht=[100,200,400,800,1600];async function gt(e,t,n,r=ht,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 _t(e,n,r){let{ExtensionBridgeTransport:i}=await t(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-D4zvQFUJ.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([25,2,26])),{mapNavigatePayloadToLickEvent:a}=await t(async()=>{let{mapNavigatePayloadToLickEvent:e}=await import(`./lick-ws-bridge-DqHNs_TC.js`);return{mapNavigatePayloadToLickEvent:e}},__vite__mapDeps([27,2,28,4,3,1,5,6])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=new e(new i({extensionId:n,onLick:e=>{let t=a(e);if(t){if(o){o.sendForwardedLick(t);return}s.length>=50&&(s.shift(),c||(c=!0,r.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(t)}}}));return await gt(u,void 0,r),{browser:u,attachLickForwardingClient:l}}async function vt(e){let{runtimeMode:n,envBaseUrl:r,window:i,log:a}=e,o=n===`electron-overlay`;a.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:n});let{BrowserAPI:s}=await t(async()=>{let{BrowserAPI:e}=await import(`./cdp-IDGN5yWS.js`);return{BrowserAPI:e}},__vite__mapDeps([29,2,30,31,32,4]));await dt({log:a});let c,l,u,d=null,f=null,p=null,m=null,h,g=n===`cherry`?null:mt(i.location.search),_=!!g&&I(),v=n===`cherry`||_?null:je(i.location.search);v?.apiBaseUrl&&(d=v.apiBaseUrl,Ce(v.apiBaseUrl),f=v.token,we(v.token)),v?.lickWsUrl&&(p=v.lickWsUrl);let y=await nt(),b=ct(n,y!==null)?qe:null;if(await et({locationHref:i.location.href,storage:i.localStorage,envBaseUrl:r,defaultWorkerBaseUrl:b,runtimeConfigFetcher:async()=>y}),n===`cherry`){let{setupCherryFollower:e}=await t(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-Dl4yLnHl.js`);return{setupCherryFollower:e}},__vite__mapDeps([33,2,29,30,31,32,4,34])),n=await e();c=n.browser,l=n.joinUrl,u=n.transport}else if(g&&I()){a.info(`Routing CDP through the extension bridge (leader tab)`);let e=await _t(s,g.extensionId,a);c=e.browser,h=e.attachLickForwardingClient,m=g.extensionId,Te(g.extensionId)}else{c=new s,v&&a.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`?(a.info(`Skipping CDP connect for follower overlay tab`),c.primeConnectOptions(e)):(await gt(c,e,a),c.setCdpSupersededHandler(()=>ot(i.document)))}let x=c.getTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:x,cherryJoinUrl:l,cherryTransport:u,instanceId:pt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m,attachLickForwardingClient:h}}var L=D(`boot/sw-registration`);async function yt(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 St())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),L.info(`Preview SW registered`),!(typeof chrome<`u`&&chrome?.runtime?.id))try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),L.info(`LLM-proxy SW registered`)}catch(e){L.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`),L.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(bt(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{bt(e)})),t&&(xt(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{xt(t)}))}catch(e){L.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function bt(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Me,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){L.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function xt(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ne,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){L.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function St(){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`),L.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){L.error(`connect-mode SW cleanup failed`,e)}return!1}var R={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function z(){return{...R}}var Ct=`slicc.followerTrayStatus`,B=new Set;function wt(e){return B.add(e),()=>{B.delete(e)}}function Tt(){if(B.size!==0)for(let e of[...B])try{e({...R})}catch{}}function Et(e){R={...e},Tt()}function Dt(e){R={...R,lastPingTime:e},Tt()}function Ot(e){return typeof e==`string`&&e.startsWith(`No API key configured`)}function kt(e){if(!e)return!1;let t=e.toLowerCase();return t.includes(`the provided model identifier is invalid`)||t.includes(`model not allowed`)}function V(e){return e?e.toLowerCase().includes(`please log in again`):!1}function At(e){return Ot(e)||kt(e)||V(e)}var H=null,jt=!1;function Mt(){return typeof window>`u`||typeof document>`u`||document?.documentElement===void 0||typeof localStorage?.getItem!=`function`}function Nt(){return Mt()?`standalone-worker`:typeof chrome<`u`&&chrome?.runtime?.id?`extension`:typeof document<`u`&&document.documentElement?.dataset?.electronOverlay?`electron`:`cli`}async function Pt(){if(!jt&&!(typeof localStorage<`u`&&typeof localStorage?.getItem==`function`&&localStorage.getItem(`telemetry-disabled`)===`true`))try{let e=Nt();e!==`standalone-worker`&&typeof window<`u`?window.RUM_GENERATION=`slicc-${e}`:globalThis.RUM_GENERATION=`slicc-${e}`,e===`standalone-worker`?(H=(await t(()=>import(`./rum-worker-CwmNSpjO.js`),[])).default,self.addEventListener(`error`,e=>{let t=e;U(`js`,t.error?.message??t.message??``)}),self.addEventListener(`unhandledrejection`,e=>{let t=e.reason;U(`js`,t instanceof Error?t.message:String(t))})):e===`extension`?(H=(await t(()=>import(`./rum-DW84CvBs.js`),[])).default,typeof window<`u`&&(window.addEventListener(`error`,e=>{let t=e;U(`js`,t.error?.message??t.message??``)}),window.addEventListener(`unhandledrejection`,e=>{let t=e.reason;U(`js`,t instanceof Error?t.message:String(t))}))):(typeof window<`u`&&(window.SAMPLE_PAGEVIEWS_AT_RATE=`high`),Wt(),H=(await t(()=>import(`./src-C9oNvq2b.js`),[])).sampleRUM),jt=!0,H&&H(`navigate`,{source:typeof document<`u`?document.referrer:``,target:e})}catch{}}function Ft(e,t){H?.(`formsubmit`,{source:e,target:t})}function It(e){H?.(`viewblock`,{source:e})}function Lt(e){H?.(`viewmedia`,{source:e})}function U(e,t){let n=t;if(typeof n==`string`){if(At(n))return;let e=Bt(n);if(e===null)return;n=e}H?.(`error`,{source:e,target:n})}function Rt(e){H?.(`signup`,{source:e})}function zt(e){return e.includes(`@vite/client`)||e.includes(`@vite/env`)||e.includes(`[vite]`)||/https?:\/\/localhost:\d+\/@vite\//.test(e)||/\/__vite_ping/.test(e)}function Bt(e){let t=e??``;if(t.includes(`@vite/`)||t.includes(`[vite]`)||t.includes(`__vite_ping`)){let e=t.split(`
23
23
  `).filter(e=>!zt(e)).join(`
24
- `).trim();return e?e.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`):null}return t.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`)}var Vt=Symbol.for(`slicc.telemetry.sendBeacon.wrapped`);function Ht(e){if(typeof e!=`string`)return{kind:`absent`};let t=Bt(e);return t===null?{kind:`noise`}:{kind:`kept`,value:t,mutated:t!==e}}function Ut(e){let t=Ht(e.source),n=Ht(e.target),r=t.kind!==`kept`,i=n.kind!==`kept`;if((t.kind!==`absent`||n.kind!==`absent`)&&r&&i)return!0;let a=!1;return t.kind===`kept`?t.mutated&&(e.source=t.value,a=!0):t.kind===`noise`&&(e.source=``,a=!0),n.kind===`kept`?n.mutated&&(e.target=n.value,a=!0):n.kind===`noise`&&(e.target=``,a=!0),a?JSON.stringify(e):null}function Wt(){if(typeof navigator>`u`||typeof navigator.sendBeacon!=`function`)return;let e=navigator.sendBeacon;if(e[Vt])return;let t=e.bind(navigator),n=((e,n)=>{try{let r=typeof n==`string`?n:n instanceof ArrayBuffer?new TextDecoder().decode(n):null;if(r&&r.length>0&&r.charCodeAt(0)===123){let n=JSON.parse(r);if(n?.checkpoint===`error`){let r=Ut(n);if(r===!0)return!0;if(r!==null)return t(e,r)}}}catch{}return t(e,n)});n[Vt]=!0,navigator.sendBeacon=n}function Gt(e,t){if(e.state===`inactive`&&t.state===`inactive`)return{kind:`leader-offer`,label:`Enable multi-browser sync`,caption:`Connect another browser to this session.`};if(e.state===`leader`&&e.session?.joinUrl)return{kind:`leader-copy`,joinUrl:e.session.joinUrl,label:`Enable multi-browser sync`,caption:`Share this URL to connect more browsers.`};if(e.state!==`inactive`){let t=e.state===`connecting`?`Setting up multi-browser sync…`:e.state===`reconnecting`?`Reconnecting…`:`Sync service unreachable.`;return{kind:`leader-pending`,label:`Multi-browser sync`,caption:e.error??t}}return{kind:`follower`,label:`Multi-browser sync`,caption:t.error??t.lastError??Kt(t.state)??`Mirroring another browser.`}}function Kt(e){switch(e){case`connected`:return`Connected — mirroring another browser.`;case`connecting`:return`Connecting to the other browser…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Disconnected from the other browser.`;default:return null}}function qt(e){let t=e.trim();if(!t)return`Paste a sync URL to continue.`;let n=null;try{n=new URL(t)}catch{return`That doesn’t look like a URL. Paste the full https://… link from the other browser.`}return n.protocol!==`https:`&&n.protocol!==`http:`?`Sync URLs must start with https://.`:n.pathname.includes(`/join/`)?`That sync URL is malformed. Re-copy it from the other browser and try again.`:`This URL is missing the /join/… capability. Use “Enable multi-browser sync” on the other browser.`}var Jt=e({ACCOUNTS_KEY:()=>fe,__test__:()=>ce,_testOnly_dispatchTrayJoinWithFailureFeedback:()=>Zt,addAccount:()=>T,applyProviderDefaults:()=>S,clearAllSettings:()=>le,clearApiKey:()=>de,clearBaseUrl:()=>ee,clearSelectedProvider:()=>oe,describeInvalidJoinUrl:()=>qt,downloadProviders:()=>$t,exportProviders:()=>pe,getAccounts:()=>w,getAllAvailableModels:()=>te,getAllExtraOAuthDomains:()=>ue,getApiKey:()=>se,getApiKeyForProvider:()=>re,getApiVersionForProvider:()=>ne,getAvailableProviders:()=>x,getBaseUrl:()=>me,getBaseUrlForProvider:()=>E,getDeploymentForProvider:()=>C,getExtraOAuthDomains:()=>ge,getOAuthAccountInfo:()=>g,getProviderConfig:()=>i,getProviderModels:()=>he,getRawApiKeyForProvider:()=>_,getSelectedModelId:()=>o,getSelectedProvider:()=>a,isModelHiddenFromPicker:()=>p,logoutOAuthAccount:()=>ae,maskOAuthTokenWithRetry:()=>n,migrateLegacyAuthOnlySelection:()=>ie,persistOAuthMaskViaServiceWorker:()=>d,providerOffersLlmModels:()=>f,reloginOAuthAccount:()=>nn,removeAccount:()=>m,resolveCurrentModel:()=>s,resolveModelById:()=>l,resolveModelByShorthand:()=>u,saveOAuthAccount:()=>h,setApiKey:()=>_e,setBaseUrl:()=>r,setExtraOAuthDomains:()=>y,setExtraOAuthDomainsAsync:()=>c,setSelectedModelId:()=>v,setSelectedProvider:()=>b,showProviderSettings:()=>Cn}),Yt=D(`provider-settings`);function Xt(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function Zt(e,t){return Qt(e,t)}function Qt(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){Yt.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 $t(){let e=JSON.stringify(pe(),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 en(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function W(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 G={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`]},K=`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 q(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 J(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function Y(e){e.options?.startInAddAccount?J(e):X(e)}function tn(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)`):e.userName?t.textContent=e.userName:e.accessToken?t.textContent=`Logged in`:t.textContent=en(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function nn(e,n){let{createOAuthLauncher:r,createInterceptingOAuthLauncherForCurrentRuntime:i}=await t(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-DdejFjWa.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([35,1,3,4,5,6,19,36])),a={forceReauth:!0};if(e.onOAuthLoginIntercepted){let t=await i();t&&await e.onOAuthLoginIntercepted(t,n,a)}else if(e.onOAuthLogin){let t=r();await e.onOAuthLogin(t,n,a)}}function rn(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(W(G.pen)),q(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function an(e,t,n){let r=document.createElement(`button`);return r.style.cssText=K,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(W(G.login)),q(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{nn(n,()=>X(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(W(G.logout)),q(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await ae(t.providerId),X(e)})()})),r}function on(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(W(G.trash)),q(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await m(t.providerId),X(e)})()}),n}function sn(e,t){let n=i(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 a=document.createElement(`div`);a.style.cssText=`flex: 1; min-width: 0;`;let o=document.createElement(`div`);o.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,o.textContent=n.name,a.appendChild(o),a.appendChild(tn(t)),r.appendChild(a);let s=document.createElement(`div`);return s.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,s.appendChild(rn(e,t)),n.isOAuth&&s.appendChild(an(e,t,n)),s.appendChild(on(e,t)),r.appendChild(s),r}function cn(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=z(),a=i.state!==`inactive`,o=Ye(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 X(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(sn(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`,()=>$t()),i.appendChild(o),t.appendChild(i),t.appendChild(cn(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`,()=>J(e)),t.appendChild(c)}function ln(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=i(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 a=new Set(w().map(e=>e.providerId)),o=[...x()].sort((e,t)=>i(e).name.localeCompare(i(t).name));for(let t of o){if(a.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!f(t))continue;let r=document.createElement(`option`);r.value=t,r.textContent=i(t).name,n.appendChild(r)}return n}function un(e,t){let n=ln(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 dn(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 fn(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}=dn(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 Oe(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 pn(e,n){let r=n.providerSelect.value;if(!r)return;let a=i(r);if(!a.onOAuthLogin&&!a.onOAuthLoginIntercepted)return;let{status:o}=n.oauth,s=w().some(e=>e.providerId===r),c=E(r);if(a.requiresBaseUrl&&!n.baseUrlInput.value.trim()&&!c){o.textContent=`Base URL is required.`,o.style.color=`var(--slicc-cone)`,n.baseUrlInput.focus();return}a.requiresBaseUrl&&n.baseUrlInput.value.trim()&&T(r,``,n.baseUrlInput.value.trim()),o.textContent=`Opening login window...`;try{if(a.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:r}=await t(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-DdejFjWa.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),i=await r();if(!i)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await a.onOAuthLoginIntercepted(i,()=>Y(e),{presentDeviceCode:fn(n.oauth)})}else if(a.onOAuthLogin){let{createOAuthLauncher:n}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-DdejFjWa.js`);return{createOAuthLauncher:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),r=n();await a.onOAuthLogin(r,()=>Y(e))}}catch(e){if(!s)try{await m(r)}catch{}Yt.error(`OAuth login failed`,{providerId:r,error:e instanceof Error?e.message:String(e)}),o.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function mn(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 hn(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 gn(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 _n(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=i(t);e.providerDesc.textContent=n.description,mn(e,n),hn(e,n),gn(e,n)}function vn(e,t){let n=t.providerSelect.value;if(!n)return;let r=i(n),a=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(r.requiresApiKey&&t.apiKeyInput.value.trim().length<5){a(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()){a(`Base URL is required for this provider.`,t.baseUrlInput);return}if(r.requiresDeployment&&!t.deploymentInput.value.trim()){a(`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),Y(e)}function yn(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`,()=>J(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`,()=>X(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 a=document.createElement(`div`);a.className=`dialog__desc`,a.textContent=`Provider:`,n.appendChild(a);let o=un(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{pn(e,o)}),t?.userName&&(o.oauth.status.textContent=`Logged in as ${t.userName}`,o.oauth.loginBtn.textContent=`Re-login`),n.appendChild(o.oauth.section),n.appendChild(o.apiKeySection),n.appendChild(o.baseUrlSection),n.appendChild(o.deploymentSection),n.appendChild(o.apiVersionSection),n.appendChild(o.errorEl),o.providerSelect.addEventListener(`change`,()=>{o.errorEl.style.display=`none`,_n(o)}),_n(o),o.saveBtn.addEventListener(`click`,()=>vn(e,o));let s=t=>{t.key===`Enter`&&vn(e,o)};o.apiKeyInput.addEventListener(`keydown`,s),o.baseUrlInput.addEventListener(`keydown`,s),o.deploymentInput.addEventListener(`keydown`,s),o.apiVersionInput.addEventListener(`keydown`,s),n.appendChild(o.saveBtn),yn(e,!!t),requestAnimationFrame(()=>{let e=o.providerSelect.value;if(!e)return;let t=i(e);t.requiresApiKey?o.apiKeyInput.focus():t.requiresBaseUrl&&o.baseUrlInput.focus()})}function bn(e,t,n,r){if(Xt()){let e={type:`refresh-tray-runtime`,joinUrl:t,workerBaseUrl:n};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else Qt(t,r);r.textContent=`Connecting…`,r.style.display=``,r.style.color=`var(--s2-content-secondary)`;let i=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);r.dataset.dismissTimer=String(i)}function xn(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=F(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}bn(e,n.joinUrl,n.workerBaseUrl,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 Sn(){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(Sn());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=`https://www.sliccy.ai/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=F(window.localStorage,t);if(!n){o.textContent=qt(t),o.style.display=``,a.focus();return}bn(e,n.joinUrl,n.workerBaseUrl,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 Cn(e){return Rt(`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?X(i):e?.autoJoinUrl?xn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=D(`main`);function wn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function Tn(){let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let n=typeof chrome<`u`&&!!chrome?.runtime?.id,r=st(window.location.href,n);if(wn(window.location.href)){let{mountWcUiPreview:n}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-Dk6AF6cB.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([37,4,1,23,38,39,40]));n(e);return}ze(),He(),r!==`connect`&&Pt().catch(()=>{});let i=je(window.location.search),a=r===`cherry`?null:mt(window.location.search),o=!!a&&I();if(await yt(i?{apiBaseUrl:i.apiBaseUrl,token:i.token}:null,o&&a?{extensionId:a.extensionId}:null)===`reload-pending`)return;if(!n&&(r===`follower`||r===`cherry`)){let{mountWcUiFollower:n}=await t(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-C3__8PFa.js`);return{mountWcUiFollower:e}},__vite__mapDeps([41,1,2,32,4,37,23,38,39,40,42,43,5,36,44,8,9,10,11,12,13,3,6,14,15,16,17,18,19,20,21,45,46,47,48,28,49,50,51,52,53,54,55]));return n(e,$,r)}await De(),S();let{bootstrapOAuthReplicas:s}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-8oaNo14A.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([56,1,12,4,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));if(await Promise.race([s().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),r===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:n}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-CuB1P3LZ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([57,1]));await n();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-BKaKXs1I.js`);return{mountConnectSurface:e}},__vite__mapDeps([58,12,4,1,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));await r(e);return}if(n){let{mountWcUiExtension:n}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-Cs88BUjq.js`);return{mountWcUiExtension:e}},__vite__mapDeps([59,1,60,61,44,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,45,46,47,48,23,28,49,50,37,38,39,40,51,52,42,53]));return n(e,$,r===`extension-detached`)}o&&a&&Re(a.extensionId);let{mountWcUiLive:c}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-DR6tvItT.js`);return{mountWcUiLive:e}},__vite__mapDeps([44,1,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,45,46,47,48,23,28,49,50,37,38,39,40,51,52,42,53]));return c(e,$,r)}Tn().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);if(t){let n=document.createElement(`div`);n.style.cssText=`padding: 2rem; text-align: center;`;let r=document.createElement(`h1`);r.style.color=`var(--s2-negative, #e34850)`,r.textContent=`Failed to start`;let i=document.createElement(`p`);for(i.style.color=`var(--s2-content-tertiary, #717171)`,i.textContent=e.message,n.appendChild(r),n.appendChild(i);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n)}});export{Ye as C,Ze as D,F as E,Je as S,tt as T,ut as _,U as a,j as b,V as c,Ct as d,z as f,vt as g,wt as h,Ft as i,kt as l,Et as m,Cn as n,Lt as o,Dt as p,Gt as r,It as s,Jt as t,Ot as u,qe as v,Xe as w,$e as x,M as y};
24
+ `).trim();return e?e.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`):null}return t.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`)}var Vt=Symbol.for(`slicc.telemetry.sendBeacon.wrapped`);function Ht(e){if(typeof e!=`string`)return{kind:`absent`};let t=Bt(e);return t===null?{kind:`noise`}:{kind:`kept`,value:t,mutated:t!==e}}function Ut(e){let t=Ht(e.source),n=Ht(e.target),r=t.kind!==`kept`,i=n.kind!==`kept`;if((t.kind!==`absent`||n.kind!==`absent`)&&r&&i)return!0;let a=!1;return t.kind===`kept`?t.mutated&&(e.source=t.value,a=!0):t.kind===`noise`&&(e.source=``,a=!0),n.kind===`kept`?n.mutated&&(e.target=n.value,a=!0):n.kind===`noise`&&(e.target=``,a=!0),a?JSON.stringify(e):null}function Wt(){if(typeof navigator>`u`||typeof navigator.sendBeacon!=`function`)return;let e=navigator.sendBeacon;if(e[Vt])return;let t=e.bind(navigator),n=((e,n)=>{try{let r=typeof n==`string`?n:n instanceof ArrayBuffer?new TextDecoder().decode(n):null;if(r&&r.length>0&&r.charCodeAt(0)===123){let n=JSON.parse(r);if(n?.checkpoint===`error`){let r=Ut(n);if(r===!0)return!0;if(r!==null)return t(e,r)}}}catch{}return t(e,n)});n[Vt]=!0,navigator.sendBeacon=n}function Gt(e,t){if(e.state===`inactive`&&t.state===`inactive`)return{kind:`leader-offer`,label:`Enable multi-browser sync`,caption:`Connect another browser to this session.`};if(e.state===`leader`&&e.session?.joinUrl)return{kind:`leader-copy`,joinUrl:e.session.joinUrl,label:`Enable multi-browser sync`,caption:`Share this URL to connect more browsers.`};if(e.state!==`inactive`){let t=e.state===`connecting`?`Setting up multi-browser sync…`:e.state===`reconnecting`?`Reconnecting…`:`Sync service unreachable.`;return{kind:`leader-pending`,label:`Multi-browser sync`,caption:e.error??t}}return{kind:`follower`,label:`Multi-browser sync`,caption:t.error??t.lastError??Kt(t.state)??`Mirroring another browser.`}}function Kt(e){switch(e){case`connected`:return`Connected — mirroring another browser.`;case`connecting`:return`Connecting to the other browser…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Disconnected from the other browser.`;default:return null}}function qt(e){let t=e.trim();if(!t)return`Paste a sync URL to continue.`;let n=null;try{n=new URL(t)}catch{return`That doesn’t look like a URL. Paste the full https://… link from the other browser.`}return n.protocol!==`https:`&&n.protocol!==`http:`?`Sync URLs must start with https://.`:n.pathname.includes(`/join/`)?`That sync URL is malformed. Re-copy it from the other browser and try again.`:`This URL is missing the /join/… capability. Use “Enable multi-browser sync” on the other browser.`}var Jt=e({ACCOUNTS_KEY:()=>fe,__test__:()=>ce,_testOnly_dispatchTrayJoinWithFailureFeedback:()=>Zt,addAccount:()=>T,applyProviderDefaults:()=>S,clearAllSettings:()=>le,clearApiKey:()=>de,clearBaseUrl:()=>ee,clearSelectedProvider:()=>oe,describeInvalidJoinUrl:()=>qt,downloadProviders:()=>$t,exportProviders:()=>pe,getAccounts:()=>w,getAllAvailableModels:()=>te,getAllExtraOAuthDomains:()=>ue,getApiKey:()=>se,getApiKeyForProvider:()=>re,getApiVersionForProvider:()=>ne,getAvailableProviders:()=>x,getBaseUrl:()=>me,getBaseUrlForProvider:()=>E,getDeploymentForProvider:()=>C,getExtraOAuthDomains:()=>ge,getOAuthAccountInfo:()=>g,getProviderConfig:()=>i,getProviderModels:()=>he,getRawApiKeyForProvider:()=>_,getSelectedModelId:()=>o,getSelectedProvider:()=>a,isModelHiddenFromPicker:()=>p,logoutOAuthAccount:()=>ae,maskOAuthTokenWithRetry:()=>n,migrateLegacyAuthOnlySelection:()=>ie,persistOAuthMaskViaServiceWorker:()=>d,providerOffersLlmModels:()=>f,reloginOAuthAccount:()=>nn,removeAccount:()=>m,resolveCurrentModel:()=>s,resolveModelById:()=>l,resolveModelByShorthand:()=>u,saveOAuthAccount:()=>h,setApiKey:()=>_e,setBaseUrl:()=>r,setExtraOAuthDomains:()=>y,setExtraOAuthDomainsAsync:()=>c,setSelectedModelId:()=>v,setSelectedProvider:()=>b,showProviderSettings:()=>Cn}),Yt=D(`provider-settings`);function Xt(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function Zt(e,t){return Qt(e,t)}function Qt(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){Yt.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 $t(){let e=JSON.stringify(pe(),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 en(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function W(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 G={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`]},K=`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 q(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 J(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function Y(e){e.options?.startInAddAccount?J(e):X(e)}function tn(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)`):e.userName?t.textContent=e.userName:e.accessToken?t.textContent=`Logged in`:t.textContent=en(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function nn(e,n){let{createOAuthLauncher:r,createInterceptingOAuthLauncherForCurrentRuntime:i}=await t(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-DdejFjWa.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([35,1,3,4,5,6,19,36])),a={forceReauth:!0};if(e.onOAuthLoginIntercepted){let t=await i();t&&await e.onOAuthLoginIntercepted(t,n,a)}else if(e.onOAuthLogin){let t=r();await e.onOAuthLogin(t,n,a)}}function rn(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(W(G.pen)),q(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function an(e,t,n){let r=document.createElement(`button`);return r.style.cssText=K,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(W(G.login)),q(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{nn(n,()=>X(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(W(G.logout)),q(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await ae(t.providerId),X(e)})()})),r}function on(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(W(G.trash)),q(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await m(t.providerId),X(e)})()}),n}function sn(e,t){let n=i(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 a=document.createElement(`div`);a.style.cssText=`flex: 1; min-width: 0;`;let o=document.createElement(`div`);o.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,o.textContent=n.name,a.appendChild(o),a.appendChild(tn(t)),r.appendChild(a);let s=document.createElement(`div`);return s.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,s.appendChild(rn(e,t)),n.isOAuth&&s.appendChild(an(e,t,n)),s.appendChild(on(e,t)),r.appendChild(s),r}function cn(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=z(),a=i.state!==`inactive`,o=Ye(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 X(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(sn(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`,()=>$t()),i.appendChild(o),t.appendChild(i),t.appendChild(cn(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`,()=>J(e)),t.appendChild(c)}function ln(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=i(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 a=new Set(w().map(e=>e.providerId)),o=[...x()].sort((e,t)=>i(e).name.localeCompare(i(t).name));for(let t of o){if(a.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!f(t))continue;let r=document.createElement(`option`);r.value=t,r.textContent=i(t).name,n.appendChild(r)}return n}function un(e,t){let n=ln(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 dn(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 fn(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}=dn(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 Oe(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 pn(e,n){let r=n.providerSelect.value;if(!r)return;let a=i(r);if(!a.onOAuthLogin&&!a.onOAuthLoginIntercepted)return;let{status:o}=n.oauth,s=w().some(e=>e.providerId===r),c=E(r);if(a.requiresBaseUrl&&!n.baseUrlInput.value.trim()&&!c){o.textContent=`Base URL is required.`,o.style.color=`var(--slicc-cone)`,n.baseUrlInput.focus();return}a.requiresBaseUrl&&n.baseUrlInput.value.trim()&&T(r,``,n.baseUrlInput.value.trim()),o.textContent=`Opening login window...`;try{if(a.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:r}=await t(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-DdejFjWa.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),i=await r();if(!i)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await a.onOAuthLoginIntercepted(i,()=>Y(e),{presentDeviceCode:fn(n.oauth)})}else if(a.onOAuthLogin){let{createOAuthLauncher:n}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-DdejFjWa.js`);return{createOAuthLauncher:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),r=n();await a.onOAuthLogin(r,()=>Y(e))}}catch(e){if(!s)try{await m(r)}catch{}Yt.error(`OAuth login failed`,{providerId:r,error:e instanceof Error?e.message:String(e)}),o.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function mn(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 hn(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 gn(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 _n(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=i(t);e.providerDesc.textContent=n.description,mn(e,n),hn(e,n),gn(e,n)}function vn(e,t){let n=t.providerSelect.value;if(!n)return;let r=i(n),a=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(r.requiresApiKey&&t.apiKeyInput.value.trim().length<5){a(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()){a(`Base URL is required for this provider.`,t.baseUrlInput);return}if(r.requiresDeployment&&!t.deploymentInput.value.trim()){a(`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),Y(e)}function yn(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`,()=>J(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`,()=>X(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 a=document.createElement(`div`);a.className=`dialog__desc`,a.textContent=`Provider:`,n.appendChild(a);let o=un(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{pn(e,o)}),t?.userName&&(o.oauth.status.textContent=`Logged in as ${t.userName}`,o.oauth.loginBtn.textContent=`Re-login`),n.appendChild(o.oauth.section),n.appendChild(o.apiKeySection),n.appendChild(o.baseUrlSection),n.appendChild(o.deploymentSection),n.appendChild(o.apiVersionSection),n.appendChild(o.errorEl),o.providerSelect.addEventListener(`change`,()=>{o.errorEl.style.display=`none`,_n(o)}),_n(o),o.saveBtn.addEventListener(`click`,()=>vn(e,o));let s=t=>{t.key===`Enter`&&vn(e,o)};o.apiKeyInput.addEventListener(`keydown`,s),o.baseUrlInput.addEventListener(`keydown`,s),o.deploymentInput.addEventListener(`keydown`,s),o.apiVersionInput.addEventListener(`keydown`,s),n.appendChild(o.saveBtn),yn(e,!!t),requestAnimationFrame(()=>{let e=o.providerSelect.value;if(!e)return;let t=i(e);t.requiresApiKey?o.apiKeyInput.focus():t.requiresBaseUrl&&o.baseUrlInput.focus()})}function bn(e,t,n,r){if(Xt()){let e={type:`refresh-tray-runtime`,joinUrl:t,workerBaseUrl:n};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else Qt(t,r);r.textContent=`Connecting…`,r.style.display=``,r.style.color=`var(--s2-content-secondary)`;let i=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);r.dataset.dismissTimer=String(i)}function xn(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=F(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}bn(e,n.joinUrl,n.workerBaseUrl,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 Sn(){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(Sn());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=`https://www.sliccy.ai/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=F(window.localStorage,t);if(!n){o.textContent=qt(t),o.style.display=``,a.focus();return}bn(e,n.joinUrl,n.workerBaseUrl,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 Cn(e){return Rt(`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?X(i):e?.autoJoinUrl?xn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=D(`main`);function wn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function Tn(){let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let n=typeof chrome<`u`&&!!chrome?.runtime?.id,r=st(window.location.href,n);if(wn(window.location.href)){let{mountWcUiPreview:n}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-DLQupMvX.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([37,4,1,23,38,39,40]));n(e);return}ze(),He(),r!==`connect`&&Pt().catch(()=>{});let i=je(window.location.search),a=r===`cherry`?null:mt(window.location.search),o=!!a&&I();if(await yt(i?{apiBaseUrl:i.apiBaseUrl,token:i.token}:null,o&&a?{extensionId:a.extensionId}:null)===`reload-pending`)return;if(!n&&(r===`follower`||r===`cherry`)){let{mountWcUiFollower:n}=await t(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-D-v4jW5A.js`);return{mountWcUiFollower:e}},__vite__mapDeps([41,1,2,32,4,37,23,38,39,40,42,43,5,36,44,8,9,10,11,12,13,3,6,14,15,16,17,18,19,20,21,45,46,47,48,28,49,50,51,52,53,54,55]));return n(e,$,r)}await De(),S();let{bootstrapOAuthReplicas:s}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-CuCZ3K1C.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([56,1,12,4,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));if(await Promise.race([s().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),r===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:n}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-CuB1P3LZ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([57,1]));await n();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-BrHTfkaa.js`);return{mountConnectSurface:e}},__vite__mapDeps([58,12,4,1,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));await r(e);return}if(n){let{mountWcUiExtension:n}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-CFkvLT92.js`);return{mountWcUiExtension:e}},__vite__mapDeps([59,1,60,61,44,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,45,46,47,48,23,28,49,50,37,38,39,40,51,52,42,53]));return n(e,$,r===`extension-detached`)}o&&a&&Re(a.extensionId);let{mountWcUiLive:c}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-DeaUqF1Y.js`);return{mountWcUiLive:e}},__vite__mapDeps([44,1,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,45,46,47,48,23,28,49,50,37,38,39,40,51,52,42,53]));return c(e,$,r)}Tn().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);if(t){let n=document.createElement(`div`);n.style.cssText=`padding: 2rem; text-align: center;`;let r=document.createElement(`h1`);r.style.color=`var(--s2-negative, #e34850)`,r.textContent=`Failed to start`;let i=document.createElement(`p`);for(i.style.color=`var(--s2-content-tertiary, #717171)`,i.textContent=e.message,n.appendChild(r),n.appendChild(i);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n)}});export{Ye as C,Ze as D,F as E,Je as S,tt as T,ut as _,U as a,j as b,V as c,Ct as d,z as f,vt as g,wt as h,Ft as i,kt as l,Et as m,Cn as n,Lt as o,Dt as p,Gt as r,It as s,Jt as t,Ot as u,qe as v,Xe as w,$e as x,M as y};
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{BrowserAPI as t}from"./cdp-IDGN5yWS.js";import{t as n}from"./synthetic-cdp-transport-DLIt5SkY.js";var r=new Set([`handshake.hello`,`handshake.welcome`,`cdp.request`,`cdp.response`,`cdp.event`,`permission.request`,`permission.response`,`host.event`,`slicc.event`]);function i(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.cherry===1&&typeof t.channelId==`string`&&typeof t.kind==`string`&&r.has(t.kind)}function a(e,t){return!(!t.allowOrigins.includes(e.origin)||t.expectedSource!==null&&e.source!==t.expectedSource||!i(e.data)||t.channelId!==null&&e.data.channelId!==t.channelId)}function o(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.cherry==`number`&&t.cherry!==1&&typeof t.channelId==`string`&&typeof t.kind==`string`}var s=e(`cherry-transport`),c=3e4,l=class extends n{opts;channelId=null;nextId=1;pending=new Map;connectResolve=null;connectReject=null;connectTimer=null;_joinUrl=null;_features={terminal:!0,files:!0,memory:!0,browser:!0,modelPicker:!0,history:!0,nav:!0,newSprinkle:!0,monitor:!0};_theme=null;boundHandler=e=>this.handleMessage(e);onHostEvent=null;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}getCurrentUrl(){return typeof location<`u`?location.href:super.getCurrentUrl()}get joinUrl(){return this._joinUrl}get features(){return this._features}get theme(){return this._theme}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);this._state=`connecting`,this.channelId=`cherry-${crypto.randomUUID()}`,typeof window<`u`&&window.addEventListener(`message`,this.boundHandler);let t=e?.timeout??c;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`))},t),this.post({cherry:1,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);for(let[,e]of this.pending)e.reject(Error(`Cherry transport disconnected`));this.pending.clear(),this._state=`disconnected`,this.channelId=null}async forward(e,t,n,r=c){let i=this.nextId++;return new Promise((n,a)=>{let o=setTimeout(()=>{this.pending.delete(i),a(Error(`Cherry CDP timed out after ${r}ms: ${e}`))},r);this.pending.set(i,{resolve:e=>{clearTimeout(o),n(e)},reject:e=>{clearTimeout(o),a(e)}}),this.post({cherry:1,channelId:this.channelId,kind:`cdp.request`,id:i,method:e,params:t})})}__test_receive(e){this.handleMessage(e)}emitSliccEventToHost(e,t){if(!this.channelId){s.warn(`Dropping slicc.event before handshake (no channelId yet)`,{name:e});return}this.post({cherry:1,channelId:this.channelId,kind:`slicc.event`,name:e,detail:t})}post(e){this.opts.counterpart.postMessage(e,this.opts.targetOrigin)}handleMessage(e){if(!a(e,{allowOrigins:this.opts.allowOrigins,expectedSource:this.opts.counterpart,channelId:this.channelId})){o(e.data)?(s.warn(`Cherry protocol version mismatch — update the older side`,{peerVersion:e.data.cherry,ourVersion:1,origin:e.origin}),this.opts.allowOrigins.includes(e.origin)&&e.source===this.opts.counterpart&&this.failPendingConnect(Error(`Cherry protocol version mismatch (peer v${e.data.cherry}, ours v1) — update the older side`))):i(e.data)&&s.warn(`Rejected a cherry envelope (origin/source/channel mismatch)`,{origin:e.origin,allowOrigins:this.opts.allowOrigins});return}let t=e.data;switch(t.kind){case`handshake.welcome`:this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),this._state=`connected`,this._joinUrl=t.joinUrl??null,this._theme=t.theme??null,this._features=t.features??{terminal:!0,files:!0,memory:!0,browser:!0,modelPicker:!0,history:!0,nav:!0,newSprinkle:!0,monitor:!0},s.info(`Cherry handshake complete`,{channelId:this.channelId}),this.connectResolve?.(),this.connectResolve=null,this.connectReject=null;return;case`cdp.response`:{let e=this.pending.get(t.id);if(!e)return;this.pending.delete(t.id),t.error?e.reject(Error(`Cherry CDP error: ${t.error.message} (${t.error.code})`)):e.resolve(t.result??{});return}case`cdp.event`:this.emit(t.method,{...t.params??{},sessionId:t.sessionId??this.syntheticIds.session});return;case`host.event`:this.onHostEvent?.(t.name,t.detail);return;default:return}}},u=e(`cherry-boot`);function d(){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 f(){let e=d(),n=[e],r=e,i=new l({counterpart:window.parent,allowOrigins:n,targetOrigin:r});await i.connect(),u.info(`Cherry transport connected`);let a=i.joinUrl;if(!a)throw Error(`cherry boot: no joinUrl from handshake`);return{transport:i,browser:new t(i),joinUrl:a}}export{f as setupCherryFollower};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{_ as t,o as n,r,t as i,v as a}from"./proxied-fetch-BG3drLHR.js";import"./backend-local-mrUgrni5.js";import{t as o}from"./types-idfTVsM8.js";import{t as s}from"./mime-types-BqLkKWa7.js";import{t as c}from"./remote-cache-D59F5FOx.js";import{t as l}from"./port-bridge-client-HYsuFrMw.js";function u(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function d(e){return e.split(`/`).pop()||`data`}function f(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 p=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=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`da access denied`,e);if(i.status>=400)throw new o(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 o(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=u(d(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),l,f=1;try{l=await c()}catch{f=2,l=await c()}if(l.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new o(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new o(`EACCES`,`da write denied`,e);if(l.status>=400)throw new o(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,p);let m=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 o(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new o(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),s=await this.cache.getListing(a);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);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 o(`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===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new o(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new o(`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 m(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 h=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new o(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 o(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),s,c=1;try{s=await a()}catch{c=2,s=await a()}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 o(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new o(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new o(`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 o(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),s=await this.cache.getListing(a);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);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 o(`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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`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 o(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new o(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new o(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},g=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function _(){let{getAccounts:e}=await import(`./account-store-BfOHnqUX.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new g(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const v=l({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new o(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function y(e,t){return v({type:e,envelope:t})}function b(){return typeof chrome<`u`&&!!chrome?.runtime?.id}const x=t,S=a,C=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),w=new Set([101,103,204,205,304]);function T(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new o(`EACCES`,e.error):e.errorCode===`invalid_request`?new o(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||C.has(String(e.errorCode))?new o(`EIO`,e.error):new o(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=x(e.bodyBase64)}catch(e){throw new o(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=w.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function E(e,t){let r;try{r=await fetch(n(e),{method:`POST`,headers:i({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new o(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function D(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function O(e,t,n){return b()?D(e,n):r()?y(e,n):E(t,n)}function k(e){return async t=>T(await O(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?S(t.body):void 0}))}function A(e){let t=e?.getImsToken??(async()=>(await _()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new o(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return T(await O(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?S(e.body):void 0}))}}var j=e({DaMountBackend:()=>p,RemoteMountCache:()=>c,S3MountBackend:()=>h,makeSignedFetchDa:()=>A,makeSignedFetchS3:()=>k});export{p as a,h as i,A as n,k as r,j as t};
1
+ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{_ as t,o as n,r,t as i,v as a}from"./proxied-fetch-BG3drLHR.js";import"./backend-local-mrUgrni5.js";import{t as o}from"./types-idfTVsM8.js";import{t as s}from"./mime-types-BqLkKWa7.js";import{t as c}from"./remote-cache-D59F5FOx.js";import{t as l}from"./port-bridge-client-HYsuFrMw.js";function u(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function d(e){return e.split(`/`).pop()||`data`}function f(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 p=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=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`da access denied`,e);if(i.status>=400)throw new o(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 o(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=u(d(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),l,f=1;try{l=await c()}catch{f=2,l=await c()}if(l.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new o(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new o(`EACCES`,`da write denied`,e);if(l.status>=400)throw new o(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,p);let m=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 o(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new o(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),s=await this.cache.getListing(a);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);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 o(`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===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new o(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new o(`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 m(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 h=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new o(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 o(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),s,c=1;try{s=await a()}catch{c=2,s=await a()}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 o(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new o(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new o(`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 o(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),s=await this.cache.getListing(a);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);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 o(`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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`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 o(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new o(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new o(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},g=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function _(){let{getAccounts:e}=await import(`./account-store-px0p2sZ-.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new g(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const v=l({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new o(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function y(e,t){return v({type:e,envelope:t})}function b(){return typeof chrome<`u`&&!!chrome?.runtime?.id}const x=t,S=a,C=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),w=new Set([101,103,204,205,304]);function T(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new o(`EACCES`,e.error):e.errorCode===`invalid_request`?new o(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||C.has(String(e.errorCode))?new o(`EIO`,e.error):new o(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=x(e.bodyBase64)}catch(e){throw new o(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=w.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function E(e,t){let r;try{r=await fetch(n(e),{method:`POST`,headers:i({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new o(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function D(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function O(e,t,n){return b()?D(e,n):r()?y(e,n):E(t,n)}function k(e){return async t=>T(await O(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?S(t.body):void 0}))}function A(e){let t=e?.getImsToken??(async()=>(await _()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new o(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return T(await O(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?S(e.body):void 0}))}}var j=e({DaMountBackend:()=>p,RemoteMountCache:()=>c,S3MountBackend:()=>h,makeSignedFetchDa:()=>A,makeSignedFetchS3:()=>k});export{p as a,h as i,A as n,k as r,j as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-BokqeKBj.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-CZgWQFsJ.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-YN73WJ67.js","assets/proxied-fetch-CaWoNw-n.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DhaH6zef.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-CZgWQFsJ.js";import{t}from"./mime-types-ugOWOUZ9.js";import{c as n,l as r}from"./src-YN73WJ67.js";import{a as i,n as a,t as o}from"./proxied-fetch-CaWoNw-n.js";import{t as s}from"./types-idfTVsM8.js";import"./backend-local-BgTSBOxM.js";import"./mount-table-store-CfQUN_2R.js";import{t as c}from"./mount-bridge-client-VA_GLWNL.js";function l(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function u(e){return e.split(`/`).pop()||`data`}function d(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 f=5*1024*1024,p=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=d(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=l(u(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),d,f=1;try{d=await c()}catch{f=2,d=await c()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new s(`EACCES`,`da write denied`,e);if(d.status>=400)throw new s(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`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 m(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 h=25*1024*1024,g=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??h,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.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 s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.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 s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`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 s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-BokqeKBj.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var y=`slicc-mount-cache`,b=`listings`,x=`bodies`,S=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??y}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(b)||e.createObjectStore(b),e.objectStoreNames.contains(x)||e.createObjectStore(x)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(b,`readonly`).objectStore(b).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(b,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(b).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(b,`readwrite`);i.objectStore(b).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readonly`).objectStore(x).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,x,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,x,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readwrite`);i.objectStore(x).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(b),n(x)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(x,`readonly`).objectStore(x),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(x,`readwrite`),i=r.objectStore(x);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function C(){return typeof chrome<`u`&&!!chrome?.runtime?.id}var w=n,T=r,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return C()?A(e,n):a()?c(e,n):k(t,n)}function M(e){return async t=>O(await j(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?T(e.body):void 0}))}}export{p as DaMountBackend,S as RemoteMountCache,g as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-JJwGg0EI.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-CZgWQFsJ.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-YN73WJ67.js","assets/proxied-fetch-CaWoNw-n.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Jt_t5qTc.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-CZgWQFsJ.js";import{t}from"./mime-types-ugOWOUZ9.js";import{c as n,l as r}from"./src-YN73WJ67.js";import{a as i,n as a,t as o}from"./proxied-fetch-CaWoNw-n.js";import{t as s}from"./types-idfTVsM8.js";import"./backend-local-BgTSBOxM.js";import"./mount-table-store-CfQUN_2R.js";import{t as c}from"./mount-bridge-client-VA_GLWNL.js";function l(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function u(e){return e.split(`/`).pop()||`data`}function d(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 f=5*1024*1024,p=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=d(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=l(u(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),d,f=1;try{d=await c()}catch{f=2,d=await c()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new s(`EACCES`,`da write denied`,e);if(d.status>=400)throw new s(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`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 m(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 h=25*1024*1024,g=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??h,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.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 s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.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 s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`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 s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-JJwGg0EI.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var y=`slicc-mount-cache`,b=`listings`,x=`bodies`,S=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??y}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(b)||e.createObjectStore(b),e.objectStoreNames.contains(x)||e.createObjectStore(x)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(b,`readonly`).objectStore(b).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(b,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(b).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(b,`readwrite`);i.objectStore(b).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readonly`).objectStore(x).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,x,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,x,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readwrite`);i.objectStore(x).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(b),n(x)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(x,`readonly`).objectStore(x),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(x,`readwrite`),i=r.objectStore(x);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function C(){return typeof chrome<`u`&&!!chrome?.runtime?.id}var w=n,T=r,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return C()?A(e,n):a()?c(e,n):k(t,n)}function M(e){return async t=>O(await j(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?T(e.body):void 0}))}}export{p as DaMountBackend,S as RemoteMountCache,g as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-Dq21hPK2.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/preload-helper-CZgWQFsJ.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-BokqeKBj.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-YN73WJ67.js","assets/proxied-fetch-CaWoNw-n.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DhaH6zef.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-CZgWQFsJ.js";import{F as t,m as n}from"./account-store-BokqeKBj.js";import{t as r}from"./logger-DDBAeTLF.js";import"./main-BwjqRukt.js";import{t as i}from"./llm-session-id-bZQs6gBN.js";import{SessionStore as a}from"./session-store-DAM8GRJ0.js";import{a as o,i as s}from"./wc-live-DR6tvItT.js";var c=r(`new-session`),l=`ui-new-session`,u=2e4,d=250;async function f(r){let d=r.enrichmentRaceMs??u,f=n()??void 0,m;try{m=t()}catch(e){c.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=m?.provider===`adobe`?{"X-Session-Id":i(l)}:void 0,g=new a;try{await g.init()}catch(e){return c.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=await o({sessionStore:g,vfs:r.vfs,mode:`quick`});if(!_)return null;if(!f||!m)return c.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:_.filename}),_;let v=m,y=s(r.vfs,_,{model:v,apiKey:f,headers:h,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-Dq21hPK2.js`).then(e=>e.n);return{pickLucideIcon: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])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(c.warn(`Single-click enrichment threw (entry stays pending)`,{filename:_.filename,error:e instanceof Error?e.message:String(e)}),null)),b=await p(y,d,r.onProgress);return b.kind===`llm`?b.updated?{...b.updated,archive:_.archive}:_:(y.then(e=>{c.info(`Background enrichment resolved after race window`,{filename:_.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),_)}async function p(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},d));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function m(e){let t=new a;try{await t.init()}catch(e){return c.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}return o({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{f as runNewSessionFreeze,m as runNewSessionFreezeQuick};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-C-KEAJdQ.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/preload-helper-CZgWQFsJ.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-JJwGg0EI.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-YN73WJ67.js","assets/proxied-fetch-CaWoNw-n.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Jt_t5qTc.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-CZgWQFsJ.js";import{F as t,m as n}from"./account-store-JJwGg0EI.js";import{t as r}from"./logger-DDBAeTLF.js";import"./main-ByXMTyEz.js";import{t as i}from"./llm-session-id-bZQs6gBN.js";import{SessionStore as a}from"./session-store-DAM8GRJ0.js";import{a as o,i as s}from"./wc-live-DeaUqF1Y.js";var c=r(`new-session`),l=`ui-new-session`,u=2e4,d=250;async function f(r){let d=r.enrichmentRaceMs??u,f=n()??void 0,m;try{m=t()}catch(e){c.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=m?.provider===`adobe`?{"X-Session-Id":i(l)}:void 0,g=new a;try{await g.init()}catch(e){return c.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=await o({sessionStore:g,vfs:r.vfs,mode:`quick`});if(!_)return null;if(!f||!m)return c.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:_.filename}),_;let v=m,y=s(r.vfs,_,{model:v,apiKey:f,headers:h,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-C-KEAJdQ.js`).then(e=>e.n);return{pickLucideIcon: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])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(c.warn(`Single-click enrichment threw (entry stays pending)`,{filename:_.filename,error:e instanceof Error?e.message:String(e)}),null)),b=await p(y,d,r.onProgress);return b.kind===`llm`?b.updated?{...b.updated,archive:_.archive}:_:(y.then(e=>{c.info(`Background enrichment resolved after race window`,{filename:_.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),_)}async function p(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},d));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function m(e){let t=new a;try{await t.init()}catch(e){return c.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}return o({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{f as runNewSessionFreeze,m as runNewSessionFreezeQuick};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-DtBT8r4B.js","assets/preload-helper-CZgWQFsJ.js","assets/account-store-BokqeKBj.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-YN73WJ67.js","assets/proxied-fetch-CaWoNw-n.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DhaH6zef.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-CZgWQFsJ.js";import{R as t,d as n}from"./account-store-BokqeKBj.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-DhaH6zef.js";import"./main-BwjqRukt.js";var a=r(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-DtBT8r4B.js`);return{ensureAllMcpProvidersRegistered: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])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let r=n();a.info(`Bootstrap OAuth replicas`,{count:r.length});for(let e of r){if(!e.accessToken){a.debug(`Skipping account without token`,{providerId:e.providerId});continue}if((e.tokenExpiresAt??1/0)-Date.now()<=o){let t=i(e.providerId);if(t?.onSilentRenew)try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId});continue}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});continue}try{await t({providerId:e.providerId,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)})}}}export{s as bootstrapOAuthReplicas};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-CWjCflQr.js","assets/preload-helper-CZgWQFsJ.js","assets/account-store-JJwGg0EI.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-YN73WJ67.js","assets/proxied-fetch-CaWoNw-n.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-k6-rjoyS.js","assets/secrets-bridge-client-2HszvKw8.js","assets/port-bridge-client-CbHZI-MK.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Jt_t5qTc.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-CZgWQFsJ.js";import{R as t,d as n}from"./account-store-JJwGg0EI.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-Jt_t5qTc.js";import"./main-ByXMTyEz.js";var a=r(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-CWjCflQr.js`);return{ensureAllMcpProvidersRegistered: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])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let r=n();a.info(`Bootstrap OAuth replicas`,{count:r.length});for(let e of r){if(!e.accessToken){a.debug(`Skipping account without token`,{providerId:e.providerId});continue}if((e.tokenExpiresAt??1/0)-Date.now()<=o){let t=i(e.providerId);if(t?.onSilentRenew)try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId});continue}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});continue}try{await t({providerId:e.providerId,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)})}}}export{s as bootstrapOAuthReplicas};