import{ag as E,P as T,am as b,aj as C}from"./index.ad1b71d6.js";import{w as x}from"./paths.ea576c73.js";const f={};function m(t){return t==="local"?localStorage:sessionStorage}function N(t,c,e){const r=(e==null?void 0:e.serializer)??JSON,a=(e==null?void 0:e.storage)??"local",s=typeof window<"u"&&typeof document<"u";function S(i,u){s&&m(a).setItem(i,r.stringify(u))}if(!f[t]){const i=x(c,n=>{const o=s?m(a).getItem(t):null;if(o&&n(r.parse(o)),s){const w=g=>{g.key===t&&n(g.newValue?r.parse(g.newValue):null)};return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)}}),{subscribe:u,set:l}=i;f[t]={set(n){S(t,n),l(n)},update(n){const o=n(E(i));S(t,o),l(o)},subscribe:u}}return f[t]}const d="SETTINGS_CONTEXT",O="settingsStore";function I(){const t={},{subscribe:c,set:e,update:r}=N(O,t,{storage:"session"});return{subscribe:c,set:e,update:r,reset(){e(JSON.parse(JSON.stringify(t)))},setEmbedding(a){r(s=>(s.embedding=a,s))}}}function h(t){T(d,t)}function J(){if(!b(d))throw new Error("SettingsContext not found");return C(d)}export{I as c,J as g,h as s};
