@rimori/playwright-testing 0.3.21-next.2 → 0.3.22-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const n="__mf_init____mf__virtual/__mfe_internal__rimori_mf_2_scenario_mf_2_host__mf_v__runtimeInit__mf_v__.js__";let i=globalThis[n];if(!i){let e,t;const o=new Promise((r,f)=>{e=r,t=f});i=globalThis[n]={initPromise:o,initResolve:e,initReject:t},typeof window>"u"&&e({loadRemote:function(){return Promise.resolve(void 0)},loadShare:function(){return Promise.resolve(void 0)}})}const s=i.initPromise,m=s.then(e=>e.loadShare("@rimori/client",{customShareInfo:{shareConfig:{singleton:!0,strictVersion:!1,requiredVersion:"^2.5.34-next.0"}}})),_=await m.then(e=>typeof e=="function"?e():e);_.__esModule?_.default:_.default;const{setupWorker:l,AudioController:a,Translator:u,TIER_ORDER:d,ROLE_ORDER:c,StorageModule:g,EventBusHandler:v,EventBus:R,RimoriClient:h,StandaloneClient:P,MessageSender:S,getDifficultyLevel:b,getDifficultyLabel:p,getNeighborDifficultyLevel:E,compareLanguageLevels:L,RimoriCommunicationHandler:C}=_;export{P as _,h as a,v as b,R as c,a as d,S as e};
1
+ const n="__mf_init____mf__virtual/__mfe_internal__rimori_mf_2_scenario_mf_2_host__mf_v__runtimeInit__mf_v__.js__";let i=globalThis[n];if(!i){let e,t;const o=new Promise((r,f)=>{e=r,t=f});i=globalThis[n]={initPromise:o,initResolve:e,initReject:t},typeof window>"u"&&e({loadRemote:function(){return Promise.resolve(void 0)},loadShare:function(){return Promise.resolve(void 0)}})}const s=i.initPromise,m=s.then(e=>e.loadShare("@rimori/client",{customShareInfo:{shareConfig:{singleton:!0,strictVersion:!1,requiredVersion:"^2.5.35"}}})),_=await m.then(e=>typeof e=="function"?e():e);_.__esModule?_.default:_.default;const{setupWorker:l,AudioController:a,Translator:u,TIER_ORDER:d,ROLE_ORDER:c,StorageModule:g,EventBusHandler:v,EventBus:R,RimoriClient:h,StandaloneClient:P,MessageSender:S,getDifficultyLevel:b,getDifficultyLabel:p,getNeighborDifficultyLevel:E,compareLanguageLevels:L,RimoriCommunicationHandler:C}=_;export{P as _,h as a,v as b,R as c,a as d,S as e};
@@ -2,7 +2,7 @@ import{_ as Fe}from"./preload-helper.js";class L{listeners=new Map;responseResol
2
2
 
3
3
  Caused by: ${(f=h?.name)!==null&&f!==void 0?f:"Error"}: ${w}`,b&&(a+=` (${b})`),h?.stack&&(a+=`
4
4
  ${h.stack}`)}else{var y;a=(y=n?.stack)!==null&&y!==void 0?y:""}const m=this.url.toString().length;return n?.name==="AbortError"||n?.code==="ABORT_ERR"?(c="",l="Request was aborted (timeout or manual cancellation)",m>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${m} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(h?.name==="HeadersOverflowError"||h?.code==="UND_ERR_HEADERS_OVERFLOW")&&(c="",l="HTTP headers exceeded server limits (typically 16KB)",m>this.urlLengthLimit&&(l+=`. Your request URL is ${m} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(o=n?.name)!==null&&o!==void 0?o:"FetchError"}: ${n?.message}`,details:a,hint:l,code:c},data:null,count:null,status:0,statusText:""}})),i.then(r,e)}returns(){return this}overrideTypes(){return this}},Ke=class extends qe{select(r){let e=!1;const t=(r??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",t),this.headers.append("Prefer","return=representation"),this}order(r,{ascending:e=!0,nullsFirst:t,foreignTable:s,referencedTable:i=s}={}){const n=i?`${i}.order`:"order",o=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${o?`${o},`:""}${r}.${e?"asc":"desc"}${t===void 0?"":t?".nullsfirst":".nullslast"}`),this}limit(r,{foreignTable:e,referencedTable:t=e}={}){const s=typeof t>"u"?"limit":`${t}.limit`;return this.url.searchParams.set(s,`${r}`),this}range(r,e,{foreignTable:t,referencedTable:s=t}={}){const i=typeof s>"u"?"offset":`${s}.offset`,n=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${r}`),this.url.searchParams.set(n,`${e-r+1}`),this}abortSignal(r){return this.signal=r,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:r=!1,verbose:e=!1,settings:t=!1,buffers:s=!1,wal:i=!1,format:n="text"}={}){var o;const a=[r?"analyze":null,e?"verbose":null,t?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${n}; for="${l}"; options=${a};`),n==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(r){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${r}`),this}};const ge=new RegExp("[,()]");var B=class extends Ke{eq(r,e){return this.url.searchParams.append(r,`eq.${e}`),this}neq(r,e){return this.url.searchParams.append(r,`neq.${e}`),this}gt(r,e){return this.url.searchParams.append(r,`gt.${e}`),this}gte(r,e){return this.url.searchParams.append(r,`gte.${e}`),this}lt(r,e){return this.url.searchParams.append(r,`lt.${e}`),this}lte(r,e){return this.url.searchParams.append(r,`lte.${e}`),this}like(r,e){return this.url.searchParams.append(r,`like.${e}`),this}likeAllOf(r,e){return this.url.searchParams.append(r,`like(all).{${e.join(",")}}`),this}likeAnyOf(r,e){return this.url.searchParams.append(r,`like(any).{${e.join(",")}}`),this}ilike(r,e){return this.url.searchParams.append(r,`ilike.${e}`),this}ilikeAllOf(r,e){return this.url.searchParams.append(r,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(r,e){return this.url.searchParams.append(r,`ilike(any).{${e.join(",")}}`),this}regexMatch(r,e){return this.url.searchParams.append(r,`match.${e}`),this}regexIMatch(r,e){return this.url.searchParams.append(r,`imatch.${e}`),this}is(r,e){return this.url.searchParams.append(r,`is.${e}`),this}isDistinct(r,e){return this.url.searchParams.append(r,`isdistinct.${e}`),this}in(r,e){const t=Array.from(new Set(e)).map(s=>typeof s=="string"&&ge.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`in.(${t})`),this}notIn(r,e){const t=Array.from(new Set(e)).map(s=>typeof s=="string"&&ge.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`not.in.(${t})`),this}contains(r,e){return typeof e=="string"?this.url.searchParams.append(r,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(r,`cs.{${e.join(",")}}`):this.url.searchParams.append(r,`cs.${JSON.stringify(e)}`),this}containedBy(r,e){return typeof e=="string"?this.url.searchParams.append(r,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(r,`cd.{${e.join(",")}}`):this.url.searchParams.append(r,`cd.${JSON.stringify(e)}`),this}rangeGt(r,e){return this.url.searchParams.append(r,`sr.${e}`),this}rangeGte(r,e){return this.url.searchParams.append(r,`nxl.${e}`),this}rangeLt(r,e){return this.url.searchParams.append(r,`sl.${e}`),this}rangeLte(r,e){return this.url.searchParams.append(r,`nxr.${e}`),this}rangeAdjacent(r,e){return this.url.searchParams.append(r,`adj.${e}`),this}overlaps(r,e){return typeof e=="string"?this.url.searchParams.append(r,`ov.${e}`):this.url.searchParams.append(r,`ov.{${e.join(",")}}`),this}textSearch(r,e,{config:t,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const n=t===void 0?"":`(${t})`;return this.url.searchParams.append(r,`${i}fts${n}.${e}`),this}match(r){return Object.entries(r).filter(([e,t])=>t!==void 0).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(r,e,t){return this.url.searchParams.append(r,`not.${e}.${t}`),this}or(r,{foreignTable:e,referencedTable:t=e}={}){const s=t?`${t}.or`:"or";return this.url.searchParams.append(s,`(${r})`),this}filter(r,e,t){return this.url.searchParams.append(r,`${e}.${t}`),this}},ze=class{constructor(r,{headers:e={},schema:t,fetch:s,urlLengthLimit:i=8e3}){this.url=r,this.headers=new Headers(e),this.schema=t,this.fetch=s,this.urlLengthLimit=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(r,e){const{head:t=!1,count:s}=e??{},i=t?"HEAD":"GET";let n=!1;const o=(r??"*").split("").map(c=>/\s/.test(c)&&!n?"":(c==='"'&&(n=!n),c)).join(""),{url:a,headers:l}=this.cloneRequestState();return a.searchParams.set("select",o),s&&l.append("Prefer",`count=${s}`),new B({method:i,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(r,{count:e,defaultToNull:t=!0}={}){var s;const i="POST",{url:n,headers:o}=this.cloneRequestState();if(e&&o.append("Prefer",`count=${e}`),t||o.append("Prefer","missing=default"),Array.isArray(r)){const a=r.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);n.searchParams.set("columns",l.join(","))}}return new B({method:i,url:n,headers:o,schema:this.schema,body:r,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(r,{onConflict:e,ignoreDuplicates:t=!1,count:s,defaultToNull:i=!0}={}){var n;const o="POST",{url:a,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${t?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),s&&l.append("Prefer",`count=${s}`),i||l.append("Prefer","missing=default"),Array.isArray(r)){const c=r.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(c.length>0){const h=[...new Set(c)].map(u=>`"${u}"`);a.searchParams.set("columns",h.join(","))}}return new B({method:o,url:a,headers:l,schema:this.schema,body:r,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit})}update(r,{count:e}={}){var t;const s="PATCH",{url:i,headers:n}=this.cloneRequestState();return e&&n.append("Prefer",`count=${e}`),new B({method:s,url:i,headers:n,schema:this.schema,body:r,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:r}={}){var e;const t="DELETE",{url:s,headers:i}=this.cloneRequestState();return r&&i.append("Prefer",`count=${r}`),new B({method:t,url:s,headers:i,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function Q(r){"@babel/helpers - typeof";return Q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(r)}function He(r,e){if(Q(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var s=t.call(r,e);if(Q(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Ve(r){var e=He(r,"string");return Q(e)=="symbol"?e:e+""}function Je(r,e,t){return(e=Ve(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function pe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,s)}return t}function X(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pe(Object(t),!0).forEach(function(s){Je(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):pe(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}var Te=class Ne{constructor(e,{headers:t={},schema:s,fetch:i,timeout:n,urlLengthLimit:o=8e3}={}){this.url=e,this.headers=new Headers(t),this.schemaName=s,this.urlLengthLimit=o;const a=i??globalThis.fetch;n!==void 0&&n>0?this.fetch=(l,c)=>{const h=new AbortController,u=setTimeout(()=>h.abort(),n),g=c?.signal;if(g){if(g.aborted)return clearTimeout(u),a(l,c);const d=()=>{clearTimeout(u),h.abort()};return g.addEventListener("abort",d,{once:!0}),a(l,X(X({},c),{},{signal:h.signal})).finally(()=>{clearTimeout(u),g.removeEventListener("abort",d)})}return a(l,X(X({},c),{},{signal:h.signal})).finally(()=>clearTimeout(u))}:this.fetch=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new ze(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new Ne(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,t={},{head:s=!1,get:i=!1,count:n}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const h=d=>d!==null&&typeof d=="object"&&(!Array.isArray(d)||d.some(h)),u=s&&Object.values(t).some(h);u?(a="POST",c=t):s||i?(a=s?"HEAD":"GET",Object.entries(t).filter(([d,f])=>f!==void 0).map(([d,f])=>[d,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([d,f])=>{l.searchParams.append(d,f)})):(a="POST",c=t);const g=new Headers(this.headers);return u?g.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&g.set("Prefer",`count=${n}`),new B({method:a,url:l,headers:g,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit})}};class me{pluginId;port=null;queryParams={};supabase=null;rimoriInfo=null;isMessageChannelReady=!1;pendingRequests=[];updateCallbacks=new Set;constructor(e,t){this.pluginId=e,this.getClient=this.getClient.bind(this),!t&&this.initMessageChannel(typeof WorkerGlobalScope<"u")}initMessageChannel(e=!1){const t=s=>{const{type:i,pluginId:n,queryParams:o,rimoriInfo:a}=s.data||{},[l]=s.ports||[];i!=="rimori:init"||!l||n!==this.pluginId||(this.queryParams=o||{},this.port=l,a&&(this.rimoriInfo=a,this.supabase=this.getSupabase(a.url,a.key,a.token)),this.port.onmessage=({data:c})=>{const{event:h,type:u,eventId:g,response:d,error:f}=c||{};if(u==="response"&&g)P.emit(this.pluginId,d.topic,d.data,g);else if(u==="error"&&g)P.emit(this.pluginId,"error",{error:f},g);else if(h){const{topic:y,sender:m,data:w,eventId:b,ai_session_token:T}=h;m!==this.pluginId&&P.emit(m,y,w,b,T)}},P.on("*",c=>{c.sender===this.pluginId&&!c.topic.startsWith("self.")&&this.port?.postMessage({event:c})}),P.on(`${this.pluginId}.supabase.triggerUpdate`,c=>{this.handleRimoriInfoUpdate(c.data)}),this.isMessageChannelReady=!0,this.pendingRequests.forEach(c=>c()),this.pendingRequests=[])};e?self.onmessage=t:window.addEventListener("message",t),this.sendHello(e),P.on("self.rimori.triggerInitFinished",()=>{this.sendFinishedInit(e)})}sendHello(e=!1){try{const t={type:"rimori:hello",pluginId:this.pluginId};e?self.postMessage(t):window.parent.postMessage(t,"*")}catch(t){console.error("[PluginController] Error sending hello:",t)}}sendFinishedInit(e=!1){try{const t={type:"rimori:acknowledged",pluginId:this.pluginId};e?self.postMessage(t):window.parent.postMessage(t,"*")}catch(t){console.error("[PluginController] Error sending finished init:",t)}}getQueryParam(e){return this.queryParams[e]||null}getSupabase(e,t,s){return new Te(`${e}/rest/v1`,{schema:this.rimoriInfo?.dbSchema,headers:{apikey:t,Authorization:`Bearer ${s}`,"plugin-id":this.pluginId}})}async getClient(){if(this.supabase&&this.rimoriInfo&&this.rimoriInfo.expiration>new Date)return{supabase:this.supabase,info:this.rimoriInfo};if(!this.isMessageChannelReady)return new Promise(e=>{this.pendingRequests.push(async()=>{const t=await this.getClient();e(t)})});if(this.rimoriInfo&&this.supabase)return{supabase:this.supabase,info:this.rimoriInfo};if(!this.rimoriInfo)if(typeof WorkerGlobalScope<"u"){const e=Math.floor(Math.random()*1e9),t={event:{timestamp:new Date().toISOString(),eventId:e,sender:this.pluginId,topic:"global.supabase.requestAccess",data:{},debug:!1}};return new Promise(s=>{const i=self.onmessage;self.onmessage=n=>{n.data?.topic==="global.supabase.requestAccess"&&n.data?.eventId===e?(this.rimoriInfo=n.data.data,this.supabase=this.getSupabase(this.rimoriInfo.url,this.rimoriInfo.key,this.rimoriInfo.token),self.onmessage=i,s({supabase:this.supabase,info:this.rimoriInfo})):i&&i.call(self,n)},self.postMessage(t)})}else{const{data:e}=await P.request(this.pluginId,"global.supabase.requestAccess");this.rimoriInfo=e,this.supabase=this.getSupabase(this.rimoriInfo.url,this.rimoriInfo.key,this.rimoriInfo.token)}return{supabase:this.supabase,info:this.rimoriInfo}}handleRimoriInfoUpdate(e){JSON.stringify(this.rimoriInfo)!==JSON.stringify(e)&&(this.rimoriInfo=e,this.supabase=this.getSupabase(e.url,e.key,e.token),this.updateCallbacks.forEach(t=>{try{t(e)}catch(s){console.error("[RimoriCommunicationHandler] Error in update callback:",s)}}))}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}fetchBackend(e,t={}){if(!this.rimoriInfo)throw new Error(`[CommunicationHandler:${this.pluginId}] fetchBackend called before rimoriInfo was initialized`);const{token:s,backendUrl:i}=this.rimoriInfo,n={};typeof t.body=="string"&&(n["Content-Type"]="application/json");const o={...n,...t.headers,Authorization:`Bearer ${s}`,"plugin-id":this.pluginId};return fetch(i+e,{...t,headers:o})}}let We=class J{static instance;isProduction;logs=[];logIdCounter=0;originalConsole;mousePosition=null;constructor(e,t){this.isProduction=this.validateIsProduction(t),this.originalConsole={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug},this.overrideConsoleMethods(),this.trackMousePosition(),this.exposeToDevTools(),this.setupNavigationClearing(),e.event.respond("logging.requestPluginLogs",async()=>{this.addLogEntry(await this.createLogEntry("info","Screenshot capture",void 0,!0));const s={logs:this.logs,pluginId:e.plugin.pluginId,timestamp:new Date().toISOString()};return this.logs=[],this.logIdCounter=0,s})}static getInstance(e,t){return J.instance||(J.instance=new J(e,t)),J.instance}validateIsProduction(e){return e!==void 0?e:typeof window<"u"&&window.location.href?!window.location.href.includes("localhost"):!0}exposeToDevTools(){typeof window<"u"&&(window.getRimoriLogs=()=>this.logs)}setupNavigationClearing(){if(typeof window>"u"||typeof history>"u")return;window.addEventListener("popstate",()=>this.logs=[]);const e=history.pushState,t=history.replaceState;history.pushState=(...n)=>{e.apply(history,n),this.logs=[]},history.replaceState=(...n)=>{t.apply(history,n),this.logs=[]};let s=window.location.href;setInterval(()=>{window.location.href!==s&&(s=window.location.href,this.logs=[])},100),window.addEventListener("hashchange",()=>this.logs=[])}overrideConsoleMethods(){console.log=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.log(t,s,...e),this.handleConsoleCall("info",e)},console.info=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.info(t,s,...e),this.handleConsoleCall("info",e)},console.warn=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.warn(t,s,...e),this.handleConsoleCall("warn",e)},console.error=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.error(t,s,...e),this.handleConsoleCall("error",e)},console.debug=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.debug(t,s,...e),this.handleConsoleCall("debug",e)}}getCallerLocation(){const e={location:"",style:""},t="color: #0063A2; font-weight: bold;";if(this.isProduction)return e;try{const s=new Error().stack;if(!s)return e;const n=s.split(`
5
- `)[3];if(!n)return e;const o=n.match(/(?:at\s+.*?\s+\()?([^/\\(]+\.(?:ts|tsx|js|jsx)):(\d+):(\d+)\)?/);if(o){const[,l,c]=o;return{style:t,location:`%c[${l}:${c}]`}}const a=n.match(/([^/\\]+\.(?:ts|tsx|js|jsx))/);return a?{style:t,location:`%c[${a[1]}]`}:e}catch{return e}}trackMousePosition(){if(typeof window<"u"){const e=t=>{this.mousePosition={x:t.clientX,y:t.clientY,timestamp:new Date().toISOString()}};window.addEventListener("mousemove",e),window.addEventListener("click",e)}}async handleConsoleCall(e,t){if(this.isProduction&&(e==="debug"||e==="info"))return;const s=t.map(o=>{if(typeof o!="object")return o;try{return JSON.stringify(o)}catch(a){return"Error adding object to log: "+a.message+" "+String(o)}}).join(" "),i=t.length>1?t.slice(1):void 0,n=await this.createLogEntry(e,s,i);this.addLogEntry(n)}getBrowserInfo(){return{userAgent:navigator.userAgent,language:navigator.language,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine,screenResolution:`${screen.width}x${screen.height}`,windowSize:`${window.innerWidth}x${window.innerHeight}`,timestamp:new Date().toISOString()}}async captureScreenshot(){if(typeof window>"u"||typeof document>"u")return null;try{const e=(await Fe(async()=>{const{default:i}=await import("./html2canvas.esm.js");return{default:i}},[])).default;return(await e(document.body)).toDataURL("image/png")}catch{return null}}async createLogEntry(e,t,s,i){const n={};return typeof window>"u"||typeof document>"u"?{id:`log_${++this.logIdCounter}_${Date.now()}`,timestamp:new Date().toISOString(),level:e,message:t,data:s}:(n.url=window.location.href,n.browserInfo=this.getBrowserInfo(),n.userAgent=n.browserInfo.userAgent,(e==="error"||e==="warn"||i)&&(n.screenshot=await this.captureScreenshot()||void 0,n.mousePosition=this.mousePosition||void 0),{id:`log_${++this.logIdCounter}_${Date.now()}`,timestamp:new Date().toISOString(),level:e,message:t,data:s,context:n})}addLogEntry(e){this.logs.push(e),this.logs.length>1e3&&(this.logs=this.logs.slice(-1e3))}};var re={};const p=r=>typeof r=="string",V=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},ye=r=>r==null?"":""+r,Ge=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},Qe=/###/g,be=r=>r&&r.indexOf("###")>-1?r.replace(Qe,"."):r,we=r=>!r||p(r),W=(r,e,t)=>{const s=p(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(we(r))return{};const n=be(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return we(r)?{}:{obj:r,k:be(s[i])}},ve=(r,e,t)=>{const{obj:s,k:i}=W(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],o=e.slice(0,e.length-1),a=W(r,o,Object);for(;a.obj===void 0&&o.length;)n=`${o[o.length-1]}.${n}`,o=o.slice(0,o.length-1),a=W(r,o,Object),a?.obj&&typeof a.obj[`${a.k}.${n}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Ye=(r,e,t,s)=>{const{obj:i,k:n}=W(r,e,Object);i[n]=i[n]||[],i[n].push(t)},te=(r,e)=>{const{obj:t,k:s}=W(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},Ze=(r,e,t)=>{const s=te(r,t);return s!==void 0?s:te(e,t)},Re=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?p(r[s])||r[s]instanceof String||p(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):Re(r[s],e[s],t):r[s]=e[s]);return r},F=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Xe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const et=r=>p(r)?r.replace(/[&<>"'\/]/g,e=>Xe[e]):r;class tt{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const st=[" ",",","?","!",";"],it=new tt(20),nt=(r,e,t)=>{e=e||"",t=t||"";const s=st.filter(o=>e.indexOf(o)<0&&t.indexOf(o)<0);if(s.length===0)return!0;const i=it.getRegExp(`(${s.map(o=>o==="?"?"\\?":o).join("|")})`);let n=!i.test(r);if(!n){const o=r.indexOf(t);o>0&&!i.test(r.substring(0,o))&&(n=!0)}return n},ce=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let o,a="";for(let l=n;l<s.length;++l)if(l!==n&&(a+=t),a+=s[l],o=i[a],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=o}return i},Y=r=>r?.replace(/_/g,"-"),rt={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){console?.[r]?.apply?.(console,e)}};class se{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||rt,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,s,i){return i&&!this.debug?null:(p(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new se(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new se(this.logger,e)}}var A=new se;class ie{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let o=0;o<n;o++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let o=0;o<n;o++)i.apply(i,[e,...t])})}}class Se extends ie{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,s,i={}){const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],s&&(Array.isArray(s)?a.push(...s):p(s)&&n?a.push(...s.split(n)):a.push(s)));const l=te(this.data,a);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=a[0],t=a[1],s=a.slice(2).join(".")),l||!o||!p(s)?l:ce(this.data?.[e]?.[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(o?s.split(o):s)),e.indexOf(".")>-1&&(a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),ve(this.data,a,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(p(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,o={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let l=te(this.data,a)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?Re(l,s,n):l={...l,...s},ve(this.data,a,l),o.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var Ae={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{e=this.processors[n]?.process(e,t,s,i)??e}),e}};const je=Symbol("i18next/PATH_KEY");function ot(){const r=[],e=Object.create(null);let t;return e.get=(s,i)=>(t?.revoke?.(),i===je?r:(r.push(i),t=Proxy.revocable(s,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}function K(r,e){const{[je]:t}=r(ot()),s=e?.keySeparator??".",i=e?.nsSeparator??":";if(t.length>1&&i){const n=e?.ns,o=Array.isArray(n)?n:null;if(o&&o.length>1&&o.slice(1).includes(t[0]))return`${t[0]}${i}${t.slice(1).join(s)}`}return t.join(s)}const xe={},oe=r=>!p(r)&&typeof r!="boolean"&&typeof r!="number";let Pe=class Me extends ie{constructor(e,t={}){super(),Ge(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=A.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(e==null)return!1;const i=this.resolve(e,s);if(i?.res===void 0)return!1;const n=oe(i.res);return!(s.returnObjects===!1&&n)}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const o=s&&e.indexOf(s)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!nt(e,s,i);if(o&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:p(n)?[n]:n};const c=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(c[0])>-1)&&(n=c.shift()),e=c.join(i)}return{key:e,namespaces:p(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?{...t}:t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=K(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]),e=e.map(x=>typeof x=="function"?K(x,{...this.options,...i}):String(x));const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let h=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const u=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return g?n?{res:`${c}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:a;const d=this.resolve(e,i);let f=d?.res;const y=d?.usedKey||a,m=d?.exactUsedKey||a,w=["[object Number]","[object Function]","[object RegExp]"],b=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,T=!this.i18nFormat||this.i18nFormat.handleAsObject,O=i.count!==void 0&&!p(i.count),N=Me.hasDefaultValue(i),v=O?this.pluralResolver.getSuffix(u,i.count,i):"",E=i.ordinal&&O?this.pluralResolver.getSuffix(u,i.count,{ordinal:!1}):"",M=O&&!i.ordinal&&i.count===0,S=M&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${v}`]||i[`defaultValue${E}`]||i.defaultValue;let I=f;T&&!f&&N&&(I=S);const ne=oe(I),D=Object.prototype.toString.apply(I);if(T&&I&&ne&&w.indexOf(D)<0&&!(p(b)&&Array.isArray(I))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const x=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,I,{...i,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=x,d.usedParams=this.getUsedParamsDetails(i),d):x}if(o){const x=Array.isArray(I),$=x?[]:{},ue=x?m:y;for(const R in I)if(Object.prototype.hasOwnProperty.call(I,R)){const j=`${ue}${o}${R}`;N&&!f?$[R]=this.translate(j,{...i,defaultValue:oe(S)?S[R]:void 0,joinArrays:!1,ns:l}):$[R]=this.translate(j,{...i,joinArrays:!1,ns:l}),$[R]===j&&($[R]=I[R])}f=$}}else if(T&&p(b)&&Array.isArray(f))f=f.join(b),f&&(f=this.extendTranslation(f,e,i,s));else{let x=!1,$=!1;!this.isValidLookup(f)&&N&&(x=!0,f=S),this.isValidLookup(f)||($=!0,f=a);const R=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&$?void 0:f,j=N&&S!==f&&this.options.updateMissing;if($||x||j){if(this.logger.log(j?"updateKey":"missingKey",u,c,a,j?S:f),o){const C=this.resolve(a,{...i,keySeparator:!1});C&&C.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let z=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let C=0;C<Z.length;C++)z.push(Z[C]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(i.lng||this.language):z.push(i.lng||this.language);const de=(C,_,H)=>{const fe=N&&H!==f?H:R;this.options.missingKeyHandler?this.options.missingKeyHandler(C,c,_,fe,j,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(C,c,_,fe,j,i),this.emit("missingKey",C,c,_,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?z.forEach(C=>{const _=this.pluralResolver.getSuffixes(C,i);M&&i[`defaultValue${this.options.pluralSeparator}zero`]&&_.indexOf(`${this.options.pluralSeparator}zero`)<0&&_.push(`${this.options.pluralSeparator}zero`),_.forEach(H=>{de([C],a+H,i[`defaultValue${H}`]||S)})}):de(z,a,S))}f=this.extendTranslation(f,e,i,d,s),$&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${c}${h}${a}`),($||x)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${a}`:a,x?f:void 0,i))}return n?(d.res=f,d.usedParams=this.getUsedParamsDetails(i),d):f}extendTranslation(e,t,s,i,n){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const l=p(e)&&(s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const u=e.match(this.interpolator.nestingRegexp);c=u&&u.length}let h=s.replace&&!p(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,s.lng||this.language||i.usedLng,s),l){const u=e.match(this.interpolator.nestingRegexp),g=u&&u.length;c<g&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...u)=>n?.[0]===u[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${t[0]}`),null):this.translate(...u,t),s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,a=p(o)?[o]:o;return e!=null&&a?.length&&s.applyPostProcessor!==!1&&(e=Ae.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,t={}){let s,i,n,o,a;return p(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?K(l,{...this.options,...t}):l)),e.forEach(l=>{if(this.isValidLookup(s))return;const c=this.extractFromKey(l,t),h=c.key;i=h;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const g=t.count!==void 0&&!p(t.count),d=g&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(p(t.context)||typeof t.context=="number")&&t.context!=="",y=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(m=>{this.isValidLookup(s)||(a=m,!xe[`${y[0]}-${m}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(xe[`${y[0]}-${m}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(w=>{if(this.isValidLookup(s))return;o=w;const b=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,h,w,m,t);else{let O;g&&(O=this.pluralResolver.getSuffix(w,t.count,t));const N=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(t.ordinal&&O.indexOf(v)===0&&b.push(h+O.replace(v,this.options.pluralSeparator)),b.push(h+O),d&&b.push(h+N)),f){const E=`${h}${this.options.contextSeparator||"_"}${t.context}`;b.push(E),g&&(t.ordinal&&O.indexOf(v)===0&&b.push(E+O.replace(v,this.options.pluralSeparator)),b.push(E+O),d&&b.push(E+N))}}let T;for(;T=b.pop();)this.isValidLookup(s)||(n=T,s=this.getResource(w,m,T,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!p(e.replace);let i=s?e.replace:e;if(s&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}};class Oe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=A.create("languageUtils")}getScriptPartFromCode(e){if(e=Y(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=Y(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(p(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(o=>{if(o===n)return o;if(!(o.indexOf("-")<0&&n.indexOf("-")<0)&&(o.indexOf("-")>0&&n.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===n||o.indexOf(n)===0&&n.length>1))return o})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),p(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return p(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):p(e)&&n(this.formatLanguageCode(e)),s.forEach(o=>{i.indexOf(o)<0&&n(this.formatLanguageCode(o))}),i}}const Ie={zero:0,one:1,two:2,few:3,many:4,other:5},Le={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class at{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=A.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=Y(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let o;try{o=new Intl.PluralRules(s,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Le;if(!e.match(/-|_/))return Le;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,t)}return this.pluralRulesCache[n]=o,o}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>Ie[i]-Ie[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const ke=(r,e,t,s=".",i=!0)=>{let n=Ze(r,e,t);return!n&&i&&p(t)&&(n=ce(r,t,s),n===void 0&&(n=ce(e,t,s))),n},ae=r=>r.replace(/\$/g,"$$$$");class Ce{constructor(e={}){this.logger=A.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(t=>t),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:o,suffix:a,suffixEscaped:l,formatSeparator:c,unescapeSuffix:h,unescapePrefix:u,nestingPrefix:g,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:y,nestingOptionsSeparator:m,maxReplaces:w,alwaysFormat:b}=e.interpolation;this.escape=t!==void 0?t:et,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?F(n):o||"{{",this.suffix=a?F(a):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=h?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=g?F(g):d||F("$t("),this.nestingSuffix=f?F(f):y||F(")"),this.nestingOptionsSeparator=m||",",this.maxReplaces=w||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>t?.source===s?(t.lastIndex=0,t):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,s,i){let n,o,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=d=>{if(d.indexOf(this.formatSeparator)<0){const w=ke(t,l,d,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(w,void 0,s,{...i,...t,interpolationkey:d}):w}const f=d.split(this.formatSeparator),y=f.shift().trim(),m=f.join(this.formatSeparator).trim();return this.format(ke(t,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),m,s,{...i,...t,interpolationkey:y})};this.resetRegExp();const h=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:d=>ae(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?ae(this.escape(d)):ae(d)}].forEach(d=>{for(a=0;n=d.regex.exec(e);){const f=n[1].trim();if(o=c(f),o===void 0)if(typeof h=="function"){const m=h(e,n,i);o=p(m)?m:""}else if(i&&Object.prototype.hasOwnProperty.call(i,f))o="";else if(u){o=n[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${e}`),o="";else!p(o)&&!this.useRawValueToEscape&&(o=ye(o));const y=d.safeValue(o);if(e=e.replace(n[0],y),u?(d.regex.lastIndex+=o.length,d.regex.lastIndex-=n[0].length):d.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,o;const a=(l,c)=>{const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const u=l.split(new RegExp(`${F(h)}[ ]*{`));let g=`{${u[1]}`;l=u[0],g=this.interpolate(g,o);const d=g.match(/'/g),f=g.match(/"/g);((d?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(g=g.replace(/'/g,'"'));try{o=JSON.parse(g),c&&(o={...c,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${h}${g}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...s},o=o.replace&&!p(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(l=i[1].slice(c).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),n=t(a.call(this,i[1].trim(),o),o),n&&i[0]===e&&!p(n))return n;p(n)||(n=ye(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,u)=>this.format(h,u,s.lng,{...s,interpolationkey:i[1].trim()}),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const lt=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(o=>{if(o){const[a,...l]=o.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=c),c==="false"&&(t[h]=!1),c==="true"&&(t[h]=!0),isNaN(c)||(t[h]=parseInt(c,10))}})}return{formatName:e,formatOptions:t}},Ee=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n={...n,[i.interpolationkey]:void 0});const o=s+JSON.stringify(n);let a=e[o];return a||(a=r(Y(s),i),e[o]=a),a(t)}},ct=r=>(e,t,s)=>r(Y(t),s)(e);class ht{constructor(e={}){this.logger=A.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?Ee:ct;this.formats={number:s((i,n)=>{const o=new Intl.NumberFormat(i,{...n});return a=>o.format(a)}),currency:s((i,n)=>{const o=new Intl.NumberFormat(i,{...n,style:"currency"});return a=>o.format(a)}),datetime:s((i,n)=>{const o=new Intl.DateTimeFormat(i,{...n});return a=>o.format(a)}),relativetime:s((i,n)=>{const o=new Intl.RelativeTimeFormat(i,{...n});return a=>o.format(a,n.range||"day")}),list:s((i,n)=>{const o=new Intl.ListFormat(i,{...n});return a=>o.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ee(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{const{formatName:c,formatOptions:h}=lt(l);if(this.formats[c]){let u=a;try{const g=i?.formatParams?.[i.interpolationkey]||{},d=g.locale||g.lng||i.locale||i.lng||s;u=this.formats[c](a,d,{...h,...i,...g})}catch(g){this.logger.warn(g)}return u}else this.logger.warn(`there was no format function for ${c}`);return a},e)}}const ut=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class dt extends ie{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=A.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i)}queueLoad(e,t,s,i){const n={},o={},a={},l={};return e.forEach(c=>{let h=!0;t.forEach(u=>{const g=`${c}|${u}`;!s.reload&&this.store.hasResourceBundle(c,u)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?o[g]===void 0&&(o[g]=!0):(this.state[g]=1,h=!1,o[g]===void 0&&(o[g]=!0),n[g]===void 0&&(n[g]=!0),l[u]===void 0&&(l[u]=!0)))}),h||(a[c]=!0)}),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],o=i[1];t&&this.emit("failedLoading",n,o,t),!t&&s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Ye(l.loaded,[n],o),ut(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{a[c]||(a[c]={});const h=l.loaded[c];h.length&&h.forEach(u=>{a[c][u]===void 0&&(a[c][u]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:o});return}this.readingCalls++;const a=(c,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(c&&h&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,o)},n);return}o(c,h)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const c=l(e,t);c&&typeof c.then=="function"?c.then(h=>a(null,h)).catch(a):a(null,c)}catch(c){a(c)}return}return l(e,t,a)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();p(e)&&(e=this.languageUtils.toResolveHierarchy(e)),p(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(o=>{this.loadOne(o)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}loadOne(e,t=""){const s=e.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,o),!o&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,t,s,i,n,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend?.create){const l={...o,isUpdate:n},c=this.backend.create.bind(this.backend);if(c.length<6)try{let h;c.length===5?h=c(e,t,s,i,l):h=c(e,t,s,i),h&&typeof h.then=="function"?h.then(u=>a(null,u)).catch(a):a(null,h)}catch(h){a(h)}else c(e,t,s,i,a,l)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const le=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),p(r[1])&&(e.defaultValue=r[1]),p(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),$e=r=>(p(r.ns)&&(r.ns=[r.ns]),p(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),p(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),r.supportedLngs?.indexOf?.("cimode")<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r),ee=()=>{},ft=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})},De="__i18next_supportNoticeShown",gt=()=>!!(typeof globalThis<"u"&&globalThis[De]||typeof process<"u"&&re&&re.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&re),pt=()=>{typeof globalThis<"u"&&(globalThis[De]=!0)},mt=r=>!!(r?.modules?.backend?.name?.indexOf("Locize")>0||r?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||r?.options?.backend?.backends&&r.options.backend.backends.some(e=>e?.name?.indexOf("Locize")>0||e?.constructor?.name?.indexOf("Locize")>0)||r?.options?.backend?.projectId||r?.options?.backend?.backendOptions&&r.options.backend.backendOptions.some(e=>e?.projectId));class G extends ie{constructor(e={},t){if(super(),this.options=$e(e),this.services={},this.logger=A,this.modules={external:[]},ft(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(p(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=le();this.options={...s,...this.options,...$e(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!mt(this)&&!gt()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),pt());const i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?A.init(i(this.modules.logger),this.options):A.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=ht;const h=new Oe(this.options);this.store=new Se(this.options.resources,this.options);const u=this.services;u.logger=A,u.resourceStore=this.store,u.languageUtils=h,u.pluralResolver=new at(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(u.formatter=i(c),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new Ce(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new dt(i(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(d,...f)=>{this.emit(d,...f)}),this.modules.languageDetector&&(u.languageDetector=i(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=i(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new Pe(this.services,this.options),this.translator.on("*",(d,...f)=>{this.emit(d,...f)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=ee),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...h)=>this.store[c](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...h)=>(this.store[c](...h),this)});const a=V(),l=()=>{const c=(h,u)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(u),t(h,u)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=ee){let s=t;const i=p(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const n=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(c=>{c!=="cimode"&&n.indexOf(c)<0&&n.push(c)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>o(l)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(n,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(a)})}else s(null)}reloadResources(e,t,s){const i=V();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=ee),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Ae.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const s=V();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...c)=>this.t(...c)),t&&t(a,(...c)=>this.t(...c))},o=a=>{!e&&!a&&this.services.languageDetector&&(a=[]);const l=p(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(p(a)?[a]:a);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,h=>{n(h,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),s}getFixedT(e,t,s){const i=(n,o,...a)=>{let l;typeof o!="object"?l=this.options.overloadTranslationOptionHandler([n,o].concat(a)):l={...o},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const c={...this.options,...l};typeof l.keyPrefix=="function"&&(l.keyPrefix=K(l.keyPrefix,c));const h=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(n)?u=n.map(g=>(typeof g=="function"&&(g=K(g,c)),`${l.keyPrefix}${h}${g}`)):(typeof n=="function"&&(n=K(n,c)),u=l.keyPrefix?`${l.keyPrefix}${h}${n}`:n),this.t(u,l)};return p(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const o=(a,l)=>{const c=this.services.backendConnector.state[`${a}|${l}`];return c===-1||c===0||c===2};if(t.precheck){const a=t.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(s,e)&&(!i||o(n,e)))}loadNamespaces(e,t){const s=V();return this.options.ns?(p(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=V();p(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return n.length?(this.options.preload=i.concat(n),this.loadResources(o=>{s.resolve(),t&&t(o)}),s):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const n=i.getTextInfo();if(n&&n.direction)return n.direction}}catch{}const t=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services?.languageUtils||new Oe(le());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new G(e,t);return s.createInstance=G.createInstance,s}cloneInstance(e={},t=ee){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},n=new G(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const a=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((h,u)=>(h[u]={...l[c][u]},h),l[c]),l),{});n.store=new Se(a,i),n.services.resourceStore=n.store}if(e.interpolation){const l={...le().interpolation,...this.options.interpolation,...e.interpolation},c={...i,interpolation:l};n.services.interpolator=new Ce(c)}return n.translator=new Pe(n.services,i),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const k=G.createInstance(),yt=k.createInstance;k.dir;k.init;k.loadResources;k.reloadResources;k.use;k.changeLanguage;k.getFixedT;k.t;k.exists;k.setDefaultNamespace;k.hasLoadedNamespace;k.loadNamespaces;k.loadLanguages;class bt{currentLanguage;initializationState;initializationPromise;i18n;translationUrl;ai;aiTranslationCache=new Map;aiTranslationPending=new Map;constructor(e,t,s){this.currentLanguage=e,this.initializationState="not-inited",this.initializationPromise=null,this.translationUrl=t,this.ai=s}async initialize(){if(this.initializationState!=="finished")return this.initializationState==="initing"&&this.initializationPromise?this.initializationPromise:(this.initializationState="initing",this.initializationPromise=(async()=>{try{const e=await this.fetchTranslations(this.currentLanguage),t=yt({lng:this.currentLanguage,resources:{[this.currentLanguage]:{translation:e}},debug:!1,showSupportNotice:!1,parseMissingKeyHandler:(s,i)=>s.trim()?this.isTranslationKey(s)?(console.warn(`Translation key not found: ${s}`),i??""):(this.fetchTranslation(s).then(n=>{this.i18n?.addResource(this.currentLanguage,"translation",s,n),this.i18n?.emit("languageChanged")}),s):""});await t.init(),this.i18n=t,this.initializationState="finished"}catch(e){throw this.initializationState="not-inited",this.initializationPromise=null,e}})(),this.initializationPromise)}getTranslationUrl(e){return`${(this.translationUrl||window.location.origin).replace(/\/+$/,"")}locales/${e}.json`}usePlugin(e){if(!this.i18n)throw new Error("Translator is not initialized");this.i18n.use(e)}onLanguageChanged(e){if(!this.i18n)throw new Error("Translator is not initialized");this.i18n.on("languageChanged",e)}async fetchTranslations(e,t=0){try{const s=await fetch(this.getTranslationUrl(e));if(!s.ok)throw new Error(`Failed to fetch translations for ${e}: ${s.status}`);const i=await s.json();return Object.keys(i).length===0&&t===0?(await new Promise(n=>setTimeout(n,300)),this.fetchTranslations(e,1)):i}catch(s){return t===0?(await new Promise(i=>setTimeout(i,300)),this.fetchTranslations(e,1)):(console.warn(`Failed to fetch translations for ${e}:`,s),e==="en"?{}:this.fetchTranslations("en").catch(i=>(console.error("Failed to fetch fallback translations:",i),{})))}}t(e,t){if(!this.i18n)throw new Error("Translator is not initialized");return this.i18n.t(e,t)}getCurrentLanguage(){return this.currentLanguage}isReady(){return this.initializationState==="finished"}isTranslationKey(e){return/^[^\s.]+(\.[^\s.]+)+$/.test(e)}async fetchTranslation(e,t){const s=this.aiTranslationCache.get(e);if(s)return s;const i=this.aiTranslationPending.get(e);if(i)return i;if(!this.ai||this.currentLanguage==="en")return e;const n=(async()=>{try{const a=(await this.ai.getObject({prompt:"global.translator.translate",variables:{additionalInstructions:t??"",language:this.currentLanguage,text:e},cache:!0}))?.translation;if(a)return this.aiTranslationCache.set(e,a),a}catch(o){console.warn("Failed to translate freeform text:",{text:e,error:o})}finally{this.aiTranslationPending.delete(e)}return e})();return this.aiTranslationPending.set(e,n),n}}class wt{pluginId;rimoriInfo;translator;supabase;communicationHandler;releaseChannel;applicationMode;theme;ttsEnabled=!0;constructor(e,t,s,i){this.rimoriInfo=s,this.supabase=e,this.pluginId=s.pluginId,this.releaseChannel=s.releaseChannel,this.communicationHandler=t;const n=s.installedPlugins.find(o=>o.id===s.pluginId);this.translator=new bt(s.interfaceLanguage,n?.endpoint||"",i),this.ttsEnabled=s.ttsEnabled??!0,this.communicationHandler.onUpdate(o=>{this.rimoriInfo=o,this.ttsEnabled=o.ttsEnabled??!0}),this.applicationMode=this.communicationHandler.getQueryParam("applicationMode"),this.theme=this.communicationHandler.getQueryParam("rm_theme")||"light"}async fetchSettings(){const e=!this.rimoriInfo.guild.allowUserPluginSettings,{data:t}=await this.supabase.schema("public").from("plugin_settings").select("*").eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",e).maybeSingle();return t?.settings??null}async setSettings(e){const t=!this.rimoriInfo.guild.allowUserPluginSettings,s={plugin_id:this.pluginId,settings:e,guild_id:this.rimoriInfo.guild.id,is_guild_setting:t};t&&(s.user_id=null);const i=this.supabase.schema("public").from("plugin_settings").update({settings:e}).eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",t),{data:n,error:o}=await(t?i.is("user_id",null).select():i.select());if(o&&(o.code==="42501"||o.message?.includes("policy")))throw new Error(`Cannot set ${t?"guild":"user"} settings: Permission denied.`);if(n&&n.length>0)return;const{error:a}=await this.supabase.schema("public").from("plugin_settings").insert(s);if(a){if(a.code==="23505"){const l=this.supabase.schema("public").from("plugin_settings").update({settings:e}).eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",t),{error:c}=await(t?l.is("user_id",null):l);if(!c)return}throw a}}async getSettings(e){const t=await this.fetchSettings();if(!t)return await this.setSettings(e),e;const s=Object.keys(t),i=Object.keys(e);if(s.length!==i.length){const n=Object.fromEntries(Object.entries(t).filter(([a])=>i.includes(a))),o={...e,...n};return await this.setSettings(o),o}return t}getUserInfo(){return this.rimoriInfo.profile}getGuildInfo(){return{id:this.rimoriInfo.guild.id,name:this.rimoriInfo.guild.name,description:this.rimoriInfo.guild.description,isShadowGuild:this.rimoriInfo.guild.isShadowGuild}}onRimoriInfoUpdate(e){return this.communicationHandler.onUpdate(e)}getPluginInfo(){return{installedPlugins:this.rimoriInfo.installedPlugins,mainPanelPlugin:this.rimoriInfo.mainPanelPlugin,sidePanelPlugin:this.rimoriInfo.sidePanelPlugin}}async getTranslator(){return await this.translator.initialize(),this.translator}}const Nt=["anonymous","free","standard","premium","early_access"],Rt=["user","plugin_moderator","lang_moderator","admin"];class vt{supabase;communicationHandler;tablePrefix;schema;constructor(e,t,s){this.supabase=e,this.communicationHandler=t,this.tablePrefix=s.tablePrefix,this.schema=s.dbSchema,t.onUpdate(i=>{this.tablePrefix=i.tablePrefix,this.schema=i.dbSchema})}from(e){const t=this.getTableName(e);return e.startsWith("global_")?this.supabase.schema("public").from(t):this.supabase.schema(this.schema).from(t)}getTableName(e){if(/[A-Z]/.test(e))throw new Error("Table name cannot include uppercase letters. Please use snake_case for table names.");return e.startsWith("global_")?e.replace("global_",""):this.tablePrefix+"_"+e}async setPublicity(e,t,s){const i=this.getTableName(e);await this.communicationHandler.fetchBackend("/db-entry/publicity",{method:"POST",body:JSON.stringify({table_name:i,schema:this.schema,entry_id:t,publicity:s})})}async vectorSearch(e){const t=await this.communicationHandler.fetchBackend("/plugin-search/vector-search",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw new Error(`Vector search failed: ${t.statusText}`);return await t.json()}}const St=["reading","listening","speaking","writing","learning","community"];class xt{pluginId;eventBus;constructor(e,t){this.pluginId=e,this.eventBus=t??P}emitAccomplishment(e){const t={...e,type:"durationMinutes"in e?"macro":"micro"};if(!this.validateAccomplishment(t))return;const s=this.sanitizeAccomplishment(t),i="global.accomplishment.trigger"+(t.type==="macro"?"Macro":"Micro");this.eventBus.emit(this.pluginId,i,s)}validateAccomplishment(e){if(!St.includes(e.skillCategory))throw new Error(`Invalid skill category: ${e.skillCategory}`);if(!/^[0-9a-z_.-]+$/.test(e.accomplishmentKeyword))throw new Error(`The accomplishment keyword: ${e.accomplishmentKeyword} is invalid. Only lowercase letters, minuses, underscores and periods are allowed`);if(e.description.length<10)throw new Error("Description is too short");if(!["micro","macro"].includes(e.type))throw new Error("Invalid accomplishment type "+e.type);if(e.type==="macro"&&(e.errorRatio<0||e.errorRatio>1))throw new Error("The error ratio must be between 0 and 1");return!0}sanitizeAccomplishment(e){return e.description=e.description.replace(/[^\x20-\x7E]/g,""),e.meta?.forEach(t=>{t.description=t.description.replace(/[^\x20-\x7E]/g,"")}),e.meta?.forEach(t=>{t.key=t.key.replace(/([A-Z])/g,"_$1").toLowerCase()}),e}getDecoupledTopic(e){const[t,s,i]=e.split(".");return{plugin:t||"*",skillCategory:s||"*",accomplishmentKeyword:i||"*"}}subscribe(e="*",t){typeof e=="string"&&(e=[e]),e.forEach(s=>{const i=s.split(".").length;if(i===1)s+=".*.*";else if(i===2)s+=".*";else if(i!==3)throw new Error("Invalid accomplishment topic pattern. The pattern must be plugin.skillCategory.accomplishmentKeyword or an * as wildcard for any plugin, skill category or accomplishment keyword");this.eventBus.on(["global.accomplishment.triggerMicro","global.accomplishment.triggerMacro"],n=>{const{plugin:o,skillCategory:a,accomplishmentKeyword:l}=this.getDecoupledTopic(s);o!=="*"&&n.sender!==o||a!=="*"&&n.data.skillCategory!==a||l!=="*"&&n.data.accomplishmentKeyword!==l||t(n)},[this.pluginId])})}}class Pt{pluginId;accomplishmentController;aiModule;eventBus;constructor(e,t,s){this.pluginId=e,this.aiModule=t,this.eventBus=s??P,this.accomplishmentController=new xt(e,this.eventBus),this.eventBus.on(["global.session.triggerUpdate"],i=>{i.data.session_token?this.aiModule.session.set(i.data.session_token):this.aiModule.session.clear()})}getGlobalEventTopic(e){if(e.startsWith("global.")||e.startsWith("self."))return e;const t=e.split(".");if(t.length===3){if(!t[0].startsWith("pl")&&t[0]!=="global")throw new Error(`Invalid event topic '${e}'. The topic must start with the plugin id, 'self' or 'global'.`);return e}else if(t.length>3)throw new Error(`The event topic must consist of 3 parts. <pluginId>.<topic area>.<action>. Received: ${e}`);return`${this.pluginId??"global"}.${e}`}emit(e,t,s){const i=this.getGlobalEventTopic(e);this.eventBus.emit(this.pluginId,i,t,s)}async request(e,t){const s=this.getGlobalEventTopic(e),i=this.aiModule.session.get()??void 0;return this.eventBus.request(this.pluginId,s,t,i)}on(e,t){const s=Array.isArray(e)?e:[e];return this.eventBus.on(s.map(i=>this.getGlobalEventTopic(i)),i=>{i.ai_session_token&&!this.aiModule.session.get()&&this.aiModule.session.set(i.ai_session_token),t(i)})}once(e,t){this.eventBus.once(this.getGlobalEventTopic(e),t)}respond(e,t){const s=Array.isArray(e)?e:[e];let i=t;typeof t=="function"&&(i=async n=>{const o=this.aiModule.session.get();n.ai_session_token&&this.aiModule.session.set(n.ai_session_token);try{return await t(n)}finally{n.ai_session_token&&(o?this.aiModule.session.set(o):this.aiModule.session.clear())}}),this.eventBus.respond(this.pluginId,s.map(n=>this.getGlobalEventTopic(n)),i)}async emitAccomplishment(e){this.accomplishmentController.emitAccomplishment(e)}onAccomplishment(e,t){this.accomplishmentController.subscribe(e,t)}emitSidebarAction(e,t,s,i){this.emit("global.sidebar.triggerAction",{plugin_id:e,action_key:t,text:s,args:i})}emitMainPanelAction(e,t,s){this.emit("global.mainPanel.triggerAction",{plugin_id:e,action_key:t,...s})}onMainPanelAction(e,t=[]){const s=Array.isArray(t)?t:[t],i=this.on("action.requestMain",({data:n})=>{(s.length===0||s.includes(n.action_key))&&e(n)});return this.emit("action.requestMain"),i}onSidePanelAction(e,t=[]){const s=Array.isArray(t)?t:[t],i=this.on("action.requestSidebar",({data:n})=>{(s.length===0||s.includes(n.action))&&e(n)});return this.emit("action.requestSidebar"),this.eventBus.emit(this.pluginId,"global.session.requestCurrent",{}),i}}class Ot{controller;sessionTokenId=null;onRateLimitedCb;constructor(e){this.controller=e}resolvePromptName(e){return e.startsWith("global.")?e:e.split(".").length===2&&this.controller.pluginId?`${this.controller.pluginId}.${e}`:e}session={get:()=>this.sessionTokenId,set:e=>{this.sessionTokenId=e},clear:()=>{this.sessionTokenId=null}};setOnRateLimited(e){this.onRateLimitedCb=e}async getText(e){const{messages:t,tools:s,cache:i=!1,prompt:n,variables:o}=e,{result:a}=await this.streamObject({cache:i,tools:s,messages:t,prompt:n,variables:o});return a}async getStreamedText(e){const{messages:t,onMessage:s,tools:i,cache:n=!1,prompt:o,variables:a}=e,l=Math.random().toString(36).substring(3),{result:c}=await this.streamObject({cache:n,tools:i,messages:t,prompt:o,variables:a,onResult:({result:h})=>s(l,h,!1)});return s(l,c,!0),c}async getVoice(e,t="alloy",s=1,i,n=!1,o){return e.trim().length?await this.controller.fetchBackend("/voice/tts",{method:"POST",body:JSON.stringify({input:e,voice:t,speed:s,language:i,cache:n,instructions:o,session_token_id:this.sessionTokenId??void 0})}).then(a=>a.blob()):(console.warn("[rimori-client] getVoice called with empty text — skipping TTS request and returning empty Blob."),new Blob([],{type:"audio/mpeg"}))}async getTextFromVoice(e,t){const s=new FormData;return s.append("file",e),t&&s.append("language",t.code),this.sessionTokenId&&s.append("session_token_id",this.sessionTokenId),await this.controller.fetchBackend("/voice/stt",{method:"POST",body:s}).then(i=>i.json()).then(i=>i.text)}async getObject(e){const{cache:t=!1,tools:s=[],prompt:i,variables:n}=e;return await this.streamObject({messages:[],cache:t,tools:s,prompt:i,variables:n})}async getStreamedObject(e){const{onResult:t,cache:s=!1,tools:i=[],prompt:n,variables:o}=e;return await this.streamObject({messages:[],onResult:t,cache:s,tools:i,prompt:n,variables:o})}async streamObject(e){const{messages:t,onResult:s=()=>null,cache:i=!1,tools:n=[],prompt:o,variables:a}=e,l=t.map((m,w)=>({...m,id:`${w+1}`})),c={cache:i,tools:n,stream:!0,messages:l,session_token_id:this.sessionTokenId??void 0};o&&(c.prompt={name:this.resolvePromptName(o),variables:a??{}});const h=await this.controller.fetchBackend("/ai/llm",{method:"POST",body:JSON.stringify(c)});if(!h.ok){if(h.status===429){const m=await h.json().catch(()=>({})),w=m.exercises_remaining??0;throw this.onRateLimitedCb?.(w),new Error(`Rate limit exceeded: ${m.error??"Daily exercise limit reached"}. exercises_remaining: ${w}`)}throw new Error(`Failed to stream object: ${h.status} ${h.statusText}`)}if(!h.body)throw new Error("No response body.");const u=h.body.getReader(),g=new TextDecoder("utf-8");let d={},f="",y=!0;for(;y;){await new Promise(v=>setTimeout(v,30));const{value:m,done:w}=await u.read();if(w)return y=!1,s(d,!1),d;if(!m)continue;const b=g.decode(m,{stream:!0}),O=(f+b).split(`
5
+ `)[3];if(!n)return e;const o=n.match(/(?:at\s+.*?\s+\()?([^/\\(]+\.(?:ts|tsx|js|jsx)):(\d+):(\d+)\)?/);if(o){const[,l,c]=o;return{style:t,location:`%c[${l}:${c}]`}}const a=n.match(/([^/\\]+\.(?:ts|tsx|js|jsx))/);return a?{style:t,location:`%c[${a[1]}]`}:e}catch{return e}}trackMousePosition(){if(typeof window<"u"){const e=t=>{this.mousePosition={x:t.clientX,y:t.clientY,timestamp:new Date().toISOString()}};window.addEventListener("mousemove",e),window.addEventListener("click",e)}}async handleConsoleCall(e,t){if(this.isProduction&&(e==="debug"||e==="info"))return;const s=t.map(o=>{if(typeof o!="object")return o;try{return JSON.stringify(o)}catch(a){return"Error adding object to log: "+a.message+" "+String(o)}}).join(" "),i=t.length>1?t.slice(1):void 0,n=await this.createLogEntry(e,s,i);this.addLogEntry(n)}getBrowserInfo(){return{userAgent:navigator.userAgent,language:navigator.language,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine,screenResolution:`${screen.width}x${screen.height}`,windowSize:`${window.innerWidth}x${window.innerHeight}`,timestamp:new Date().toISOString()}}async captureScreenshot(){if(typeof window>"u"||typeof document>"u")return null;try{const e=(await Fe(async()=>{const{default:i}=await import("./html2canvas.esm.js");return{default:i}},[])).default;return(await e(document.body)).toDataURL("image/png")}catch{return null}}async createLogEntry(e,t,s,i){const n={};return typeof window>"u"||typeof document>"u"?{id:`log_${++this.logIdCounter}_${Date.now()}`,timestamp:new Date().toISOString(),level:e,message:t,data:s}:(n.url=window.location.href,n.browserInfo=this.getBrowserInfo(),n.userAgent=n.browserInfo.userAgent,(e==="error"||e==="warn"||i)&&(n.screenshot=await this.captureScreenshot()||void 0,n.mousePosition=this.mousePosition||void 0),{id:`log_${++this.logIdCounter}_${Date.now()}`,timestamp:new Date().toISOString(),level:e,message:t,data:s,context:n})}addLogEntry(e){this.logs.push(e),this.logs.length>1e3&&(this.logs=this.logs.slice(-1e3))}};var re={};const p=r=>typeof r=="string",V=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},ye=r=>r==null?"":""+r,Ge=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},Qe=/###/g,be=r=>r&&r.indexOf("###")>-1?r.replace(Qe,"."):r,we=r=>!r||p(r),W=(r,e,t)=>{const s=p(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(we(r))return{};const n=be(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return we(r)?{}:{obj:r,k:be(s[i])}},ve=(r,e,t)=>{const{obj:s,k:i}=W(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],o=e.slice(0,e.length-1),a=W(r,o,Object);for(;a.obj===void 0&&o.length;)n=`${o[o.length-1]}.${n}`,o=o.slice(0,o.length-1),a=W(r,o,Object),a?.obj&&typeof a.obj[`${a.k}.${n}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Ye=(r,e,t,s)=>{const{obj:i,k:n}=W(r,e,Object);i[n]=i[n]||[],i[n].push(t)},te=(r,e)=>{const{obj:t,k:s}=W(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},Ze=(r,e,t)=>{const s=te(r,t);return s!==void 0?s:te(e,t)},Re=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?p(r[s])||r[s]instanceof String||p(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):Re(r[s],e[s],t):r[s]=e[s]);return r},F=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Xe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const et=r=>p(r)?r.replace(/[&<>"'\/]/g,e=>Xe[e]):r;class tt{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const st=[" ",",","?","!",";"],it=new tt(20),nt=(r,e,t)=>{e=e||"",t=t||"";const s=st.filter(o=>e.indexOf(o)<0&&t.indexOf(o)<0);if(s.length===0)return!0;const i=it.getRegExp(`(${s.map(o=>o==="?"?"\\?":o).join("|")})`);let n=!i.test(r);if(!n){const o=r.indexOf(t);o>0&&!i.test(r.substring(0,o))&&(n=!0)}return n},ce=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let o,a="";for(let l=n;l<s.length;++l)if(l!==n&&(a+=t),a+=s[l],o=i[a],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=o}return i},Y=r=>r?.replace(/_/g,"-"),rt={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){console?.[r]?.apply?.(console,e)}};class se{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||rt,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,s,i){return i&&!this.debug?null:(p(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new se(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new se(this.logger,e)}}var A=new se;class ie{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let o=0;o<n;o++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let o=0;o<n;o++)i.apply(i,[e,...t])})}}class Se extends ie{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,s,i={}){const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],s&&(Array.isArray(s)?a.push(...s):p(s)&&n?a.push(...s.split(n)):a.push(s)));const l=te(this.data,a);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=a[0],t=a[1],s=a.slice(2).join(".")),l||!o||!p(s)?l:ce(this.data?.[e]?.[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(o?s.split(o):s)),e.indexOf(".")>-1&&(a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),ve(this.data,a,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(p(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,o={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let l=te(this.data,a)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?Re(l,s,n):l={...l,...s},ve(this.data,a,l),o.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var Ae={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{e=this.processors[n]?.process(e,t,s,i)??e}),e}};const je=Symbol("i18next/PATH_KEY");function ot(){const r=[],e=Object.create(null);let t;return e.get=(s,i)=>(t?.revoke?.(),i===je?r:(r.push(i),t=Proxy.revocable(s,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}function K(r,e){const{[je]:t}=r(ot()),s=e?.keySeparator??".",i=e?.nsSeparator??":";if(t.length>1&&i){const n=e?.ns,o=Array.isArray(n)?n:null;if(o&&o.length>1&&o.slice(1).includes(t[0]))return`${t[0]}${i}${t.slice(1).join(s)}`}return t.join(s)}const xe={},oe=r=>!p(r)&&typeof r!="boolean"&&typeof r!="number";let Pe=class Me extends ie{constructor(e,t={}){super(),Ge(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=A.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(e==null)return!1;const i=this.resolve(e,s);if(i?.res===void 0)return!1;const n=oe(i.res);return!(s.returnObjects===!1&&n)}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const o=s&&e.indexOf(s)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!nt(e,s,i);if(o&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:p(n)?[n]:n};const c=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(c[0])>-1)&&(n=c.shift()),e=c.join(i)}return{key:e,namespaces:p(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?{...t}:t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=K(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]),e=e.map(x=>typeof x=="function"?K(x,{...this.options,...i}):String(x));const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let h=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const u=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return g?n?{res:`${c}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:a;const d=this.resolve(e,i);let f=d?.res;const y=d?.usedKey||a,m=d?.exactUsedKey||a,w=["[object Number]","[object Function]","[object RegExp]"],b=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,T=!this.i18nFormat||this.i18nFormat.handleAsObject,O=i.count!==void 0&&!p(i.count),N=Me.hasDefaultValue(i),v=O?this.pluralResolver.getSuffix(u,i.count,i):"",E=i.ordinal&&O?this.pluralResolver.getSuffix(u,i.count,{ordinal:!1}):"",M=O&&!i.ordinal&&i.count===0,S=M&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${v}`]||i[`defaultValue${E}`]||i.defaultValue;let I=f;T&&!f&&N&&(I=S);const ne=oe(I),D=Object.prototype.toString.apply(I);if(T&&I&&ne&&w.indexOf(D)<0&&!(p(b)&&Array.isArray(I))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const x=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,I,{...i,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=x,d.usedParams=this.getUsedParamsDetails(i),d):x}if(o){const x=Array.isArray(I),$=x?[]:{},ue=x?m:y;for(const R in I)if(Object.prototype.hasOwnProperty.call(I,R)){const j=`${ue}${o}${R}`;N&&!f?$[R]=this.translate(j,{...i,defaultValue:oe(S)?S[R]:void 0,joinArrays:!1,ns:l}):$[R]=this.translate(j,{...i,joinArrays:!1,ns:l}),$[R]===j&&($[R]=I[R])}f=$}}else if(T&&p(b)&&Array.isArray(f))f=f.join(b),f&&(f=this.extendTranslation(f,e,i,s));else{let x=!1,$=!1;!this.isValidLookup(f)&&N&&(x=!0,f=S),this.isValidLookup(f)||($=!0,f=a);const R=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&$?void 0:f,j=N&&S!==f&&this.options.updateMissing;if($||x||j){if(this.logger.log(j?"updateKey":"missingKey",u,c,a,j?S:f),o){const C=this.resolve(a,{...i,keySeparator:!1});C&&C.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let z=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let C=0;C<Z.length;C++)z.push(Z[C]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(i.lng||this.language):z.push(i.lng||this.language);const de=(C,_,H)=>{const fe=N&&H!==f?H:R;this.options.missingKeyHandler?this.options.missingKeyHandler(C,c,_,fe,j,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(C,c,_,fe,j,i),this.emit("missingKey",C,c,_,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?z.forEach(C=>{const _=this.pluralResolver.getSuffixes(C,i);M&&i[`defaultValue${this.options.pluralSeparator}zero`]&&_.indexOf(`${this.options.pluralSeparator}zero`)<0&&_.push(`${this.options.pluralSeparator}zero`),_.forEach(H=>{de([C],a+H,i[`defaultValue${H}`]||S)})}):de(z,a,S))}f=this.extendTranslation(f,e,i,d,s),$&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${c}${h}${a}`),($||x)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${a}`:a,x?f:void 0,i))}return n?(d.res=f,d.usedParams=this.getUsedParamsDetails(i),d):f}extendTranslation(e,t,s,i,n){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const l=p(e)&&(s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const u=e.match(this.interpolator.nestingRegexp);c=u&&u.length}let h=s.replace&&!p(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,s.lng||this.language||i.usedLng,s),l){const u=e.match(this.interpolator.nestingRegexp),g=u&&u.length;c<g&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...u)=>n?.[0]===u[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${t[0]}`),null):this.translate(...u,t),s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,a=p(o)?[o]:o;return e!=null&&a?.length&&s.applyPostProcessor!==!1&&(e=Ae.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,t={}){let s,i,n,o,a;return p(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?K(l,{...this.options,...t}):l)),e.forEach(l=>{if(this.isValidLookup(s))return;const c=this.extractFromKey(l,t),h=c.key;i=h;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const g=t.count!==void 0&&!p(t.count),d=g&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(p(t.context)||typeof t.context=="number")&&t.context!=="",y=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(m=>{this.isValidLookup(s)||(a=m,!xe[`${y[0]}-${m}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(xe[`${y[0]}-${m}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(w=>{if(this.isValidLookup(s))return;o=w;const b=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,h,w,m,t);else{let O;g&&(O=this.pluralResolver.getSuffix(w,t.count,t));const N=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(t.ordinal&&O.indexOf(v)===0&&b.push(h+O.replace(v,this.options.pluralSeparator)),b.push(h+O),d&&b.push(h+N)),f){const E=`${h}${this.options.contextSeparator||"_"}${t.context}`;b.push(E),g&&(t.ordinal&&O.indexOf(v)===0&&b.push(E+O.replace(v,this.options.pluralSeparator)),b.push(E+O),d&&b.push(E+N))}}let T;for(;T=b.pop();)this.isValidLookup(s)||(n=T,s=this.getResource(w,m,T,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!p(e.replace);let i=s?e.replace:e;if(s&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}};class Oe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=A.create("languageUtils")}getScriptPartFromCode(e){if(e=Y(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=Y(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(p(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(o=>{if(o===n)return o;if(!(o.indexOf("-")<0&&n.indexOf("-")<0)&&(o.indexOf("-")>0&&n.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===n||o.indexOf(n)===0&&n.length>1))return o})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),p(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return p(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):p(e)&&n(this.formatLanguageCode(e)),s.forEach(o=>{i.indexOf(o)<0&&n(this.formatLanguageCode(o))}),i}}const Ie={zero:0,one:1,two:2,few:3,many:4,other:5},Le={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class at{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=A.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=Y(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let o;try{o=new Intl.PluralRules(s,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Le;if(!e.match(/-|_/))return Le;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,t)}return this.pluralRulesCache[n]=o,o}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>Ie[i]-Ie[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const ke=(r,e,t,s=".",i=!0)=>{let n=Ze(r,e,t);return!n&&i&&p(t)&&(n=ce(r,t,s),n===void 0&&(n=ce(e,t,s))),n},ae=r=>r.replace(/\$/g,"$$$$");class Ce{constructor(e={}){this.logger=A.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(t=>t),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:o,suffix:a,suffixEscaped:l,formatSeparator:c,unescapeSuffix:h,unescapePrefix:u,nestingPrefix:g,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:y,nestingOptionsSeparator:m,maxReplaces:w,alwaysFormat:b}=e.interpolation;this.escape=t!==void 0?t:et,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?F(n):o||"{{",this.suffix=a?F(a):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=h?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=g?F(g):d||F("$t("),this.nestingSuffix=f?F(f):y||F(")"),this.nestingOptionsSeparator=m||",",this.maxReplaces=w||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>t?.source===s?(t.lastIndex=0,t):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,s,i){let n,o,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=d=>{if(d.indexOf(this.formatSeparator)<0){const w=ke(t,l,d,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(w,void 0,s,{...i,...t,interpolationkey:d}):w}const f=d.split(this.formatSeparator),y=f.shift().trim(),m=f.join(this.formatSeparator).trim();return this.format(ke(t,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),m,s,{...i,...t,interpolationkey:y})};this.resetRegExp();const h=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:d=>ae(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?ae(this.escape(d)):ae(d)}].forEach(d=>{for(a=0;n=d.regex.exec(e);){const f=n[1].trim();if(o=c(f),o===void 0)if(typeof h=="function"){const m=h(e,n,i);o=p(m)?m:""}else if(i&&Object.prototype.hasOwnProperty.call(i,f))o="";else if(u){o=n[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${e}`),o="";else!p(o)&&!this.useRawValueToEscape&&(o=ye(o));const y=d.safeValue(o);if(e=e.replace(n[0],y),u?(d.regex.lastIndex+=o.length,d.regex.lastIndex-=n[0].length):d.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,o;const a=(l,c)=>{const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const u=l.split(new RegExp(`${F(h)}[ ]*{`));let g=`{${u[1]}`;l=u[0],g=this.interpolate(g,o);const d=g.match(/'/g),f=g.match(/"/g);((d?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(g=g.replace(/'/g,'"'));try{o=JSON.parse(g),c&&(o={...c,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${h}${g}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...s},o=o.replace&&!p(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(l=i[1].slice(c).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),n=t(a.call(this,i[1].trim(),o),o),n&&i[0]===e&&!p(n))return n;p(n)||(n=ye(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,u)=>this.format(h,u,s.lng,{...s,interpolationkey:i[1].trim()}),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const lt=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(o=>{if(o){const[a,...l]=o.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=c),c==="false"&&(t[h]=!1),c==="true"&&(t[h]=!0),isNaN(c)||(t[h]=parseInt(c,10))}})}return{formatName:e,formatOptions:t}},Ee=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n={...n,[i.interpolationkey]:void 0});const o=s+JSON.stringify(n);let a=e[o];return a||(a=r(Y(s),i),e[o]=a),a(t)}},ct=r=>(e,t,s)=>r(Y(t),s)(e);class ht{constructor(e={}){this.logger=A.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?Ee:ct;this.formats={number:s((i,n)=>{const o=new Intl.NumberFormat(i,{...n});return a=>o.format(a)}),currency:s((i,n)=>{const o=new Intl.NumberFormat(i,{...n,style:"currency"});return a=>o.format(a)}),datetime:s((i,n)=>{const o=new Intl.DateTimeFormat(i,{...n});return a=>o.format(a)}),relativetime:s((i,n)=>{const o=new Intl.RelativeTimeFormat(i,{...n});return a=>o.format(a,n.range||"day")}),list:s((i,n)=>{const o=new Intl.ListFormat(i,{...n});return a=>o.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ee(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{const{formatName:c,formatOptions:h}=lt(l);if(this.formats[c]){let u=a;try{const g=i?.formatParams?.[i.interpolationkey]||{},d=g.locale||g.lng||i.locale||i.lng||s;u=this.formats[c](a,d,{...h,...i,...g})}catch(g){this.logger.warn(g)}return u}else this.logger.warn(`there was no format function for ${c}`);return a},e)}}const ut=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class dt extends ie{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=A.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i)}queueLoad(e,t,s,i){const n={},o={},a={},l={};return e.forEach(c=>{let h=!0;t.forEach(u=>{const g=`${c}|${u}`;!s.reload&&this.store.hasResourceBundle(c,u)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?o[g]===void 0&&(o[g]=!0):(this.state[g]=1,h=!1,o[g]===void 0&&(o[g]=!0),n[g]===void 0&&(n[g]=!0),l[u]===void 0&&(l[u]=!0)))}),h||(a[c]=!0)}),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],o=i[1];t&&this.emit("failedLoading",n,o,t),!t&&s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Ye(l.loaded,[n],o),ut(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{a[c]||(a[c]={});const h=l.loaded[c];h.length&&h.forEach(u=>{a[c][u]===void 0&&(a[c][u]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:o});return}this.readingCalls++;const a=(c,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(c&&h&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,o)},n);return}o(c,h)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const c=l(e,t);c&&typeof c.then=="function"?c.then(h=>a(null,h)).catch(a):a(null,c)}catch(c){a(c)}return}return l(e,t,a)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();p(e)&&(e=this.languageUtils.toResolveHierarchy(e)),p(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(o=>{this.loadOne(o)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}loadOne(e,t=""){const s=e.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,o),!o&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,t,s,i,n,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend?.create){const l={...o,isUpdate:n},c=this.backend.create.bind(this.backend);if(c.length<6)try{let h;c.length===5?h=c(e,t,s,i,l):h=c(e,t,s,i),h&&typeof h.then=="function"?h.then(u=>a(null,u)).catch(a):a(null,h)}catch(h){a(h)}else c(e,t,s,i,a,l)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const le=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),p(r[1])&&(e.defaultValue=r[1]),p(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),$e=r=>(p(r.ns)&&(r.ns=[r.ns]),p(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),p(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),r.supportedLngs?.indexOf?.("cimode")<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r),ee=()=>{},ft=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})},De="__i18next_supportNoticeShown",gt=()=>!!(typeof globalThis<"u"&&globalThis[De]||typeof process<"u"&&re&&re.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&re),pt=()=>{typeof globalThis<"u"&&(globalThis[De]=!0)},mt=r=>!!(r?.modules?.backend?.name?.indexOf("Locize")>0||r?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||r?.options?.backend?.backends&&r.options.backend.backends.some(e=>e?.name?.indexOf("Locize")>0||e?.constructor?.name?.indexOf("Locize")>0)||r?.options?.backend?.projectId||r?.options?.backend?.backendOptions&&r.options.backend.backendOptions.some(e=>e?.projectId));class G extends ie{constructor(e={},t){if(super(),this.options=$e(e),this.services={},this.logger=A,this.modules={external:[]},ft(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(p(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=le();this.options={...s,...this.options,...$e(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!mt(this)&&!gt()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),pt());const i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?A.init(i(this.modules.logger),this.options):A.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=ht;const h=new Oe(this.options);this.store=new Se(this.options.resources,this.options);const u=this.services;u.logger=A,u.resourceStore=this.store,u.languageUtils=h,u.pluralResolver=new at(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(u.formatter=i(c),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new Ce(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new dt(i(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(d,...f)=>{this.emit(d,...f)}),this.modules.languageDetector&&(u.languageDetector=i(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=i(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new Pe(this.services,this.options),this.translator.on("*",(d,...f)=>{this.emit(d,...f)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=ee),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...h)=>this.store[c](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...h)=>(this.store[c](...h),this)});const a=V(),l=()=>{const c=(h,u)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(u),t(h,u)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=ee){let s=t;const i=p(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const n=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(c=>{c!=="cimode"&&n.indexOf(c)<0&&n.push(c)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>o(l)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(n,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(a)})}else s(null)}reloadResources(e,t,s){const i=V();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=ee),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Ae.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const s=V();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...c)=>this.t(...c)),t&&t(a,(...c)=>this.t(...c))},o=a=>{!e&&!a&&this.services.languageDetector&&(a=[]);const l=p(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(p(a)?[a]:a);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,h=>{n(h,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),s}getFixedT(e,t,s){const i=(n,o,...a)=>{let l;typeof o!="object"?l=this.options.overloadTranslationOptionHandler([n,o].concat(a)):l={...o},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const c={...this.options,...l};typeof l.keyPrefix=="function"&&(l.keyPrefix=K(l.keyPrefix,c));const h=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(n)?u=n.map(g=>(typeof g=="function"&&(g=K(g,c)),`${l.keyPrefix}${h}${g}`)):(typeof n=="function"&&(n=K(n,c)),u=l.keyPrefix?`${l.keyPrefix}${h}${n}`:n),this.t(u,l)};return p(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const o=(a,l)=>{const c=this.services.backendConnector.state[`${a}|${l}`];return c===-1||c===0||c===2};if(t.precheck){const a=t.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(s,e)&&(!i||o(n,e)))}loadNamespaces(e,t){const s=V();return this.options.ns?(p(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=V();p(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return n.length?(this.options.preload=i.concat(n),this.loadResources(o=>{s.resolve(),t&&t(o)}),s):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const n=i.getTextInfo();if(n&&n.direction)return n.direction}}catch{}const t=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services?.languageUtils||new Oe(le());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new G(e,t);return s.createInstance=G.createInstance,s}cloneInstance(e={},t=ee){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},n=new G(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const a=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((h,u)=>(h[u]={...l[c][u]},h),l[c]),l),{});n.store=new Se(a,i),n.services.resourceStore=n.store}if(e.interpolation){const l={...le().interpolation,...this.options.interpolation,...e.interpolation},c={...i,interpolation:l};n.services.interpolator=new Ce(c)}return n.translator=new Pe(n.services,i),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const k=G.createInstance(),yt=k.createInstance;k.dir;k.init;k.loadResources;k.reloadResources;k.use;k.changeLanguage;k.getFixedT;k.t;k.exists;k.setDefaultNamespace;k.hasLoadedNamespace;k.loadNamespaces;k.loadLanguages;class bt{currentLanguage;initializationState;initializationPromise;i18n;translationUrl;ai;aiTranslationCache=new Map;aiTranslationPending=new Map;constructor(e,t,s){this.currentLanguage=e,this.initializationState="not-inited",this.initializationPromise=null,this.translationUrl=t,this.ai=s}async initialize(){if(this.initializationState!=="finished")return this.initializationState==="initing"&&this.initializationPromise?this.initializationPromise:(this.initializationState="initing",this.initializationPromise=(async()=>{try{const e=await this.fetchTranslations(this.currentLanguage),t=yt({lng:this.currentLanguage,resources:{[this.currentLanguage]:{translation:e}},debug:!1,showSupportNotice:!1,parseMissingKeyHandler:(s,i)=>s.trim()?this.isTranslationKey(s)?(console.warn(`Translation key not found: ${s}`),i??""):(this.fetchTranslation(s).then(n=>{this.i18n?.addResource(this.currentLanguage,"translation",s,n),this.i18n?.emit("languageChanged")}),s):""});await t.init(),this.i18n=t,this.initializationState="finished"}catch(e){throw this.initializationState="not-inited",this.initializationPromise=null,e}})(),this.initializationPromise)}getTranslationUrl(e){return`${(this.translationUrl||window.location.origin).replace(/\/+$/,"")}/locales/${e}.json`}usePlugin(e){if(!this.i18n)throw new Error("Translator is not initialized");this.i18n.use(e)}onLanguageChanged(e){if(!this.i18n)throw new Error("Translator is not initialized");this.i18n.on("languageChanged",e)}async fetchTranslations(e,t=0){try{const s=await fetch(this.getTranslationUrl(e));if(!s.ok)throw new Error(`Failed to fetch translations for ${e}: ${s.status}`);const i=await s.json();return Object.keys(i).length===0&&t===0?(await new Promise(n=>setTimeout(n,300)),this.fetchTranslations(e,1)):i}catch(s){return t===0?(await new Promise(i=>setTimeout(i,300)),this.fetchTranslations(e,1)):(console.warn(`Fetching of ${e} translation not possible. Falling back to english. Error details: `+s.message),e==="en"?{}:this.fetchTranslations("en").catch(i=>(console.error("Failed to fetch fallback translations:",i),{})))}}t(e,t){if(!this.i18n)throw new Error("Translator is not initialized");return this.i18n.t(e,t)}getCurrentLanguage(){return this.currentLanguage}isReady(){return this.initializationState==="finished"}isTranslationKey(e){return/^[^\s.]+(\.[^\s.]+)+$/.test(e)}async fetchTranslation(e,t){const s=this.aiTranslationCache.get(e);if(s)return s;const i=this.aiTranslationPending.get(e);if(i)return i;if(!this.ai||this.currentLanguage==="en")return e;const n=(async()=>{try{const a=(await this.ai.getObject({prompt:"global.translator.translate",variables:{additionalInstructions:t??"",language:this.currentLanguage,text:e},cache:!0}))?.translation;if(a)return this.aiTranslationCache.set(e,a),a}catch(o){console.warn("Failed to translate freeform text:",{text:e,error:o})}finally{this.aiTranslationPending.delete(e)}return e})();return this.aiTranslationPending.set(e,n),n}}class wt{pluginId;rimoriInfo;translator;supabase;communicationHandler;releaseChannel;applicationMode;theme;ttsEnabled=!0;constructor(e,t,s,i){this.rimoriInfo=s,this.supabase=e,this.pluginId=s.pluginId,this.releaseChannel=s.releaseChannel,this.communicationHandler=t;const n=s.installedPlugins.find(o=>o.id===s.pluginId);this.translator=new bt(s.interfaceLanguage,n?.endpoint||"",i),this.ttsEnabled=s.ttsEnabled??!0,this.communicationHandler.onUpdate(o=>{this.rimoriInfo=o,this.ttsEnabled=o.ttsEnabled??!0}),this.applicationMode=this.communicationHandler.getQueryParam("applicationMode"),this.theme=this.communicationHandler.getQueryParam("rm_theme")||"light"}async fetchSettings(){const e=!this.rimoriInfo.guild.allowUserPluginSettings,{data:t}=await this.supabase.schema("public").from("plugin_settings").select("*").eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",e).maybeSingle();return t?.settings??null}async setSettings(e){const t=!this.rimoriInfo.guild.allowUserPluginSettings,s={plugin_id:this.pluginId,settings:e,guild_id:this.rimoriInfo.guild.id,is_guild_setting:t};t&&(s.user_id=null);const i=this.supabase.schema("public").from("plugin_settings").update({settings:e}).eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",t),{data:n,error:o}=await(t?i.is("user_id",null).select():i.select());if(o&&(o.code==="42501"||o.message?.includes("policy")))throw new Error(`Cannot set ${t?"guild":"user"} settings: Permission denied.`);if(n&&n.length>0)return;const{error:a}=await this.supabase.schema("public").from("plugin_settings").insert(s);if(a){if(a.code==="23505"){const l=this.supabase.schema("public").from("plugin_settings").update({settings:e}).eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",t),{error:c}=await(t?l.is("user_id",null):l);if(!c)return}throw a}}async getSettings(e){const t=await this.fetchSettings();if(!t)return await this.setSettings(e),e;const s=Object.keys(t),i=Object.keys(e);if(s.length!==i.length){const n=Object.fromEntries(Object.entries(t).filter(([a])=>i.includes(a))),o={...e,...n};return await this.setSettings(o),o}return t}getUserInfo(){return this.rimoriInfo.profile}getGuildInfo(){return{id:this.rimoriInfo.guild.id,name:this.rimoriInfo.guild.name,description:this.rimoriInfo.guild.description,isShadowGuild:this.rimoriInfo.guild.isShadowGuild}}onRimoriInfoUpdate(e){return this.communicationHandler.onUpdate(e)}getPluginInfo(){return{installedPlugins:this.rimoriInfo.installedPlugins,mainPanelPlugin:this.rimoriInfo.mainPanelPlugin,sidePanelPlugin:this.rimoriInfo.sidePanelPlugin}}async getTranslator(){return await this.translator.initialize(),this.translator}}const Nt=["anonymous","free","standard","premium","early_access"],Rt=["user","plugin_moderator","lang_moderator","admin"];class vt{supabase;communicationHandler;tablePrefix;schema;constructor(e,t,s){this.supabase=e,this.communicationHandler=t,this.tablePrefix=s.tablePrefix,this.schema=s.dbSchema,t.onUpdate(i=>{this.tablePrefix=i.tablePrefix,this.schema=i.dbSchema})}from(e){const t=this.getTableName(e);return e.startsWith("global_")?this.supabase.schema("public").from(t):this.supabase.schema(this.schema).from(t)}getTableName(e){if(/[A-Z]/.test(e))throw new Error("Table name cannot include uppercase letters. Please use snake_case for table names.");return e.startsWith("global_")?e.replace("global_",""):this.tablePrefix+"_"+e}async setPublicity(e,t,s){const i=this.getTableName(e);await this.communicationHandler.fetchBackend("/db-entry/publicity",{method:"POST",body:JSON.stringify({table_name:i,schema:this.schema,entry_id:t,publicity:s})})}async vectorSearch(e){const t=await this.communicationHandler.fetchBackend("/plugin-search/vector-search",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw new Error(`Vector search failed: ${t.statusText}`);return await t.json()}}const St=["reading","listening","speaking","writing","learning","community"];class xt{pluginId;eventBus;constructor(e,t){this.pluginId=e,this.eventBus=t??P}emitAccomplishment(e){const t={...e,type:"durationMinutes"in e?"macro":"micro"};if(!this.validateAccomplishment(t))return;const s=this.sanitizeAccomplishment(t),i="global.accomplishment.trigger"+(t.type==="macro"?"Macro":"Micro");this.eventBus.emit(this.pluginId,i,s)}validateAccomplishment(e){if(!St.includes(e.skillCategory))throw new Error(`Invalid skill category: ${e.skillCategory}`);if(!/^[0-9a-z_.-]+$/.test(e.accomplishmentKeyword))throw new Error(`The accomplishment keyword: ${e.accomplishmentKeyword} is invalid. Only lowercase letters, minuses, underscores and periods are allowed`);if(e.description.length<10)throw new Error("Description is too short");if(!["micro","macro"].includes(e.type))throw new Error("Invalid accomplishment type "+e.type);if(e.type==="macro"&&(e.errorRatio<0||e.errorRatio>1))throw new Error("The error ratio must be between 0 and 1");return!0}sanitizeAccomplishment(e){return e.description=e.description.replace(/[^\x20-\x7E]/g,""),e.meta?.forEach(t=>{t.description=t.description.replace(/[^\x20-\x7E]/g,"")}),e.meta?.forEach(t=>{t.key=t.key.replace(/([A-Z])/g,"_$1").toLowerCase()}),e}getDecoupledTopic(e){const[t,s,i]=e.split(".");return{plugin:t||"*",skillCategory:s||"*",accomplishmentKeyword:i||"*"}}subscribe(e="*",t){typeof e=="string"&&(e=[e]),e.forEach(s=>{const i=s.split(".").length;if(i===1)s+=".*.*";else if(i===2)s+=".*";else if(i!==3)throw new Error("Invalid accomplishment topic pattern. The pattern must be plugin.skillCategory.accomplishmentKeyword or an * as wildcard for any plugin, skill category or accomplishment keyword");this.eventBus.on(["global.accomplishment.triggerMicro","global.accomplishment.triggerMacro"],n=>{const{plugin:o,skillCategory:a,accomplishmentKeyword:l}=this.getDecoupledTopic(s);o!=="*"&&n.sender!==o||a!=="*"&&n.data.skillCategory!==a||l!=="*"&&n.data.accomplishmentKeyword!==l||t(n)},[this.pluginId])})}}class Pt{pluginId;accomplishmentController;aiModule;eventBus;constructor(e,t,s){this.pluginId=e,this.aiModule=t,this.eventBus=s??P,this.accomplishmentController=new xt(e,this.eventBus),this.eventBus.on(["global.session.triggerUpdate"],i=>{i.data.session_token?this.aiModule.session.set(i.data.session_token):this.aiModule.session.clear()})}getGlobalEventTopic(e){if(e.startsWith("global.")||e.startsWith("self."))return e;const t=e.split(".");if(t.length===3){if(!t[0].startsWith("pl")&&t[0]!=="global")throw new Error(`Invalid event topic '${e}'. The topic must start with the plugin id, 'self' or 'global'.`);return e}else if(t.length>3)throw new Error(`The event topic must consist of 3 parts. <pluginId>.<topic area>.<action>. Received: ${e}`);return`${this.pluginId??"global"}.${e}`}emit(e,t,s){const i=this.getGlobalEventTopic(e);this.eventBus.emit(this.pluginId,i,t,s)}async request(e,t){const s=this.getGlobalEventTopic(e),i=this.aiModule.session.get()??void 0;return this.eventBus.request(this.pluginId,s,t,i)}on(e,t){const s=Array.isArray(e)?e:[e];return this.eventBus.on(s.map(i=>this.getGlobalEventTopic(i)),i=>{i.ai_session_token&&!this.aiModule.session.get()&&this.aiModule.session.set(i.ai_session_token),t(i)})}once(e,t){this.eventBus.once(this.getGlobalEventTopic(e),t)}respond(e,t){const s=Array.isArray(e)?e:[e];let i=t;typeof t=="function"&&(i=async n=>{const o=this.aiModule.session.get();n.ai_session_token&&this.aiModule.session.set(n.ai_session_token);try{return await t(n)}finally{n.ai_session_token&&(o?this.aiModule.session.set(o):this.aiModule.session.clear())}}),this.eventBus.respond(this.pluginId,s.map(n=>this.getGlobalEventTopic(n)),i)}async emitAccomplishment(e){this.accomplishmentController.emitAccomplishment(e)}onAccomplishment(e,t){this.accomplishmentController.subscribe(e,t)}emitSidebarAction(e,t,s,i){this.emit("global.sidebar.triggerAction",{plugin_id:e,action_key:t,text:s,args:i})}emitMainPanelAction(e,t,s){this.emit("global.mainPanel.triggerAction",{plugin_id:e,action_key:t,...s})}onMainPanelAction(e,t=[]){const s=Array.isArray(t)?t:[t],i=this.on("action.requestMain",({data:n})=>{(s.length===0||s.includes(n.action_key))&&e(n)});return this.emit("action.requestMain"),i}onSidePanelAction(e,t=[]){const s=Array.isArray(t)?t:[t],i=this.on("action.requestSidebar",({data:n})=>{(s.length===0||s.includes(n.action))&&e(n)});return this.emit("action.requestSidebar"),this.eventBus.emit(this.pluginId,"global.session.requestCurrent",{}),i}}class Ot{controller;sessionTokenId=null;onRateLimitedCb;constructor(e){this.controller=e}resolvePromptName(e){return e.startsWith("global.")?e:e.split(".").length===2&&this.controller.pluginId?`${this.controller.pluginId}.${e}`:e}session={get:()=>this.sessionTokenId,set:e=>{this.sessionTokenId=e},clear:()=>{this.sessionTokenId=null}};setOnRateLimited(e){this.onRateLimitedCb=e}async getText(e){const{messages:t,tools:s,cache:i=!1,prompt:n,variables:o}=e,{result:a}=await this.streamObject({cache:i,tools:s,messages:t,prompt:n,variables:o});return a}async getStreamedText(e){const{messages:t,onMessage:s,tools:i,cache:n=!1,prompt:o,variables:a}=e,l=Math.random().toString(36).substring(3),{result:c}=await this.streamObject({cache:n,tools:i,messages:t,prompt:o,variables:a,onResult:({result:h})=>s(l,h,!1)});return s(l,c,!0),c}async getVoice(e,t="alloy",s=1,i,n=!1,o){return e.trim().length?await this.controller.fetchBackend("/voice/tts",{method:"POST",body:JSON.stringify({input:e,voice:t,speed:s,language:i,cache:n,instructions:o,session_token_id:this.sessionTokenId??void 0})}).then(a=>a.blob()):(console.warn("[rimori-client] getVoice called with empty text — skipping TTS request and returning empty Blob."),new Blob([],{type:"audio/mpeg"}))}async getTextFromVoice(e,t){const s=new FormData;return s.append("file",e),t&&s.append("language",t.code),this.sessionTokenId&&s.append("session_token_id",this.sessionTokenId),await this.controller.fetchBackend("/voice/stt",{method:"POST",body:s}).then(i=>i.json()).then(i=>i.text)}async getObject(e){const{cache:t=!1,tools:s=[],prompt:i,variables:n}=e;return await this.streamObject({messages:[],cache:t,tools:s,prompt:i,variables:n})}async getStreamedObject(e){const{onResult:t,cache:s=!1,tools:i=[],prompt:n,variables:o}=e;return await this.streamObject({messages:[],onResult:t,cache:s,tools:i,prompt:n,variables:o})}async streamObject(e){const{messages:t,onResult:s=()=>null,cache:i=!1,tools:n=[],prompt:o,variables:a}=e,l=t.map((m,w)=>({...m,id:`${w+1}`})),c={cache:i,tools:n,stream:!0,messages:l,session_token_id:this.sessionTokenId??void 0};o&&(c.prompt={name:this.resolvePromptName(o),variables:a??{}});const h=await this.controller.fetchBackend("/ai/llm",{method:"POST",body:JSON.stringify(c)});if(!h.ok){if(h.status===429){const m=await h.json().catch(()=>({})),w=m.exercises_remaining??0;throw this.onRateLimitedCb?.(w),new Error(`Rate limit exceeded: ${m.error??"Daily exercise limit reached"}. exercises_remaining: ${w}`)}throw new Error(`Failed to stream object: ${h.status} ${h.statusText}`)}if(!h.body)throw new Error("No response body.");const u=h.body.getReader(),g=new TextDecoder("utf-8");let d={},f="",y=!0;for(;y;){await new Promise(v=>setTimeout(v,30));const{value:m,done:w}=await u.read();if(w)return y=!1,s(d,!1),d;if(!m)continue;const b=g.decode(m,{stream:!0}),O=(f+b).split(`
6
6
  `);f=O.pop()??"";const N=O.filter(v=>v.trim());for(const v of N){if(v.startsWith("token:")){try{const S=JSON.parse(v.slice(6).trim());S.token_id&&(this.sessionTokenId=S.token_id)}catch{console.error("Failed to parse token: line",v)}continue}if(v.startsWith("debug:")){try{const S=JSON.parse(v.slice(6).trim());console.group(`[Rimori Prompt] ${S.promptName}`),console.log(`System prompt:
7
7
  `,S.system),console.log(`User prompt:
8
8
  `,S.user),console.log("Variables:",S.variables),console.groupEnd()}catch{}continue}const E=v.substring(0,5),M=v.substring(5).trim();if(M==="[DONE]")return y=!1,s(d,!1),d;if(E==="data:")d=JSON.parse(M),s(d,!0);else if(E==="tool:"){const{toolCallId:S,toolName:I,args:ne}=JSON.parse(M),D=n.find(x=>x.name===I);if(D&&D.execute){const x=await D.execute(ne);await this.sendToolResult(S,x)}else D&&!D.execute?console.error("Tool found but has no execute function:",I):console.error("Tool not found:",I)}else E==="error"?console.error("Error:",M.substring(1)):E==="info:"||console.error("Unknown stream data:",v)}}return d}async sendToolResult(e,t){await this.controller.fetchBackend("/ai/llm/tool_result",{method:"POST",body:JSON.stringify({toolCallId:e,result:t??"[DONE]"})})}}class It{supabase;communicationHandler;eventModule;constructor(e,t,s,i){this.supabase=e,this.communicationHandler=t,this.eventModule=i}async view(){const{data:e,error:t}=await this.supabase.schema("public").from("weekly_exercises").select("*");if(t)throw new Error(`Failed to fetch weekly exercises: ${t.message}`);return e||[]}async add(e){const t=Array.isArray(e)?e:[e],s=await this.communicationHandler.fetchBackend("/exercises",{method:"POST",body:JSON.stringify({exercises:t})});if(!s.ok){const n=await s.text();throw new Error(`Failed to create exercises: ${n}`)}const i=await s.json();return this.eventModule.emit("global.exercises.triggerChange"),i}async start(e){return new Promise((t,s)=>{const i=setTimeout(()=>{n.off(),s(new Error("Exercise start timed out: rimori-main did not respond within 5s"))},5e3),n=this.eventModule.on("global.session.triggerUpdate",({data:o})=>{o.session_token&&(clearTimeout(i),n.off(),t())});this.eventModule.emit("global.exercise.triggerStart",e)})}async delete(e){const t=await this.communicationHandler.fetchBackend(`/exercises/${e}`,{method:"DELETE"});if(!t.ok){const s=await t.text();throw new Error(`Failed to delete exercise: ${s}`)}return this.eventModule.emit("global.exercises.triggerChange"),await t.json()}}class Lt{controller;constructor(e){this.controller=e}async uploadImage(e){const t=new FormData;t.append("file",e,"image.png");try{const s=await this.controller.fetchBackend("/plugin-images/upload",{method:"POST",body:t});if(!s.ok){const n=await s.json().catch(()=>({}));return{error:new Error(n.message??`Upload failed (${s.status})`)}}return{data:await s.json()}}catch(s){return{error:s instanceof Error?s:new Error(String(s))}}}}class U{static instance;controller;sharedContent;db;event;plugin;ai;exercise;storage;eventBus;constructor(e,t,s,i){this.controller=e,this.eventBus=i??P,this.sharedContent=new Ue(t,this),this.ai=new Ot(e),this.ai.setOnRateLimited(n=>{this.eventBus.emit(s.pluginId,"global.quota.triggerExceeded",{exercises_remaining:n})}),this.event=new Pt(s.pluginId,this.ai,this.eventBus),this.db=new vt(t,e,s),this.plugin=new wt(t,e,s,this.ai),this.exercise=new It(t,e,s,this.event),this.storage=new Lt(e),this.plugin.applicationMode!=="sidebar"&&We.getInstance(this)}static createWithInfo(e){const t=L.create("Plugin EventBus "+e.pluginId),s=new me(e.pluginId,!0);s.handleRimoriInfoUpdate(e);const i=new Te(`${e.url}/rest/v1`,{schema:e.dbSchema,headers:{apikey:e.key,Authorization:`Bearer ${e.token}`,"plugin-id":e.pluginId}}),n=new U(s,i,e,t);return t.on(`${e.pluginId}.supabase.triggerUpdate`,o=>{console.log("[RimoriClient] Federated triggerUpdate received for",e.pluginId,"| ttsEnabled:",o.data?.ttsEnabled),s.handleRimoriInfoUpdate(o.data)}),n}static async getInstance(e){if(!U.instance){if(!e)throw new Error("Plugin ID is required");const t=new me(e,!1),s=await t.getClient();U.instance=new U(t,s.supabase,s.info)}return U.instance}navigation={toDashboard:()=>{this.event.emit("global.navigation.triggerToDashboard")}};runtime={fetchBackend:(e,t={})=>this.controller.fetchBackend(e,t)}}const kt="https://pheptqdoqsdnadgoihvr.supabase.co",Ct="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoZXB0cWRvcXNkbmFkZ29paHZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE2OTY2ODcsImV4cCI6MjA0NzI3MjY4N30.4GPFAXTF8685FaXISdAPNCIM-H3RGLo8GbyhQpu1mP0";class q{static instance;config;supabase;constructor(e){throw new Error("Authentication is disabled until new developer platform is released.")}static async getInstance(){if(!q.instance){const e=await fetch("https://app.rimori.se/config.json").then(t=>t.json()).catch(t=>{console.warn("Error fetching config.json, using default values",t)});q.instance=new q({url:e?.SUPABASE_URL||kt,key:e?.SUPABASE_ANON_KEY||Ct,backendUrl:e?.BACKEND_URL||"https://api.rimori.se"})}return q.instance}async getClient(){return this.supabase}async needsLogin(){const{error:e}=await this.supabase.auth.getUser();return e!==null}async login(e,t){const{error:s}=await this.supabase.auth.signInWithPassword({email:e,password:t});return s?(console.error("Login failed:",s),!1):(console.log("Successfully logged in"),!0)}static async initListeners(e){console.warn("The plugin seams to not be running inside the Rimori platform. Switching to development standalone mode.");const{supabase:t,config:s}=await q.getInstance();P.respond("standalone","global.supabase.requestAccess",async()=>{const i=await t.auth.getSession();console.log("session",i);let n=null;try{const{data:{user:l}}=await t.auth.getUser();if(l){const{data:c}=await t.from("profiles").select("current_guild_id").eq("user_id",l.id).maybeSingle();n=c?.current_guild_id||null}}catch{n=null}const o=await fetch(`${s.backendUrl}/plugin/token`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i.data.session?.access_token}`},body:JSON.stringify({pluginId:e,guildId:n})});if(!o.ok){const l=await o.text();throw new Error(`Failed to get plugin token. ${o.status}: ${l}`)}return{token:(await o.json()).token,pluginId:e,url:s.url,key:s.key,backendUrl:s.backendUrl,tablePrefix:e,expiration:new Date(Date.now()+1e3*60*60*1.5)}}),P.on("*",async i=>{console.log("[standalone] would send event to parent",i)},["standalone"])}}class Et{audioContext;chunkQueue=[];isPlaying=!1;analyser;dataArray;shouldMonitorLoudness=!0;isMonitoring=!1;handle=0;volume=1;loudnessCallback=()=>{};currentIndex=0;startedPlaying=!1;onEndOfSpeech=()=>{};backgroundNoiseLevel=30;currentSource=null;stopped=!1;constructor(){this.init()}init(){this.audioContext=new AudioContext,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=256;const e=this.analyser.frequencyBinCount;this.dataArray=new Uint8Array(e)}setOnLoudnessChange(e){this.loudnessCallback=e}setVolume(e){this.volume=e}async addChunk(e,t){this.stopped||(console.log("Adding chunk",t,e),this.chunkQueue[t]=e,t===0&&!this.startedPlaying&&(this.startedPlaying=!0,this.playChunks()))}playChunks(){if(!(this.isPlaying||this.stopped)){if(!this.chunkQueue[this.currentIndex]){setTimeout(()=>this.playChunks(),10);return}this.isPlaying=!0,this.playChunk(this.chunkQueue[this.currentIndex]).then(()=>{this.isPlaying=!1,!this.stopped&&(this.currentIndex++,this.chunkQueue[this.currentIndex]?(this.shouldMonitorLoudness=!0,this.playChunks()):setTimeout(()=>{this.stopped||(this.chunkQueue.length>this.currentIndex?this.playChunks():(this.startedPlaying=!1,this.shouldMonitorLoudness=!1))},1e3))})}}stopPlayback(){if(this.stopped=!0,this.currentSource){try{this.currentSource.stop()}catch{}this.currentSource=null}this.isPlaying=!1,this.chunkQueue=[],this.startedPlaying=!1,this.shouldMonitorLoudness=!1,cancelAnimationFrame(this.handle),this.loudnessCallback(0)}cleanup(){this.stopPlayback(),this.audioContext&&this.audioContext.state!=="closed"&&this.audioContext.close().catch(e=>{console.warn("Error closing AudioContext:",e)})}playChunk(e){return!e||this.stopped?Promise.resolve():new Promise(t=>{const s=this.audioContext.createBufferSource();this.currentSource=s,this.audioContext.decodeAudioData(e.slice(0)).then(i=>{if(this.stopped){t();return}s.buffer=i;const n=this.audioContext.createGain();n.gain.value=this.volume,s.connect(n),n.connect(this.analyser),this.analyser.connect(this.audioContext.destination),s.start(0),n.gain.value=this.volume,s.onended=()=>{this.currentSource===s&&(this.currentSource=null),t()},this.isMonitoring||(this.isMonitoring=!0,this.shouldMonitorLoudness=!0,this.monitorLoudness())})})}async playAgain(){console.log("Playing again"),this.chunkQueue.length>0&&!this.isPlaying&&this.playChunks()}monitorLoudness(){if(!this.shouldMonitorLoudness){cancelAnimationFrame(this.handle),this.loudnessCallback(0),this.onEndOfSpeech();return}this.analyser.getByteTimeDomainData(this.dataArray);let e=0;for(let s=0;s<this.dataArray.length;s++){const i=this.dataArray[s]/128-1;e+=i*i}const t=Math.sqrt(e/this.dataArray.length);if(t!==0){let s=20*Math.log10(t);const i=-57,n=-15;s<i&&(s=i),s>n&&(s=n);let o=(s-i)/(n-i)*100;o<this.backgroundNoiseLevel?o=0:o=(o-this.backgroundNoiseLevel)/(100-this.backgroundNoiseLevel)*100,this.loudnessCallback(Math.round(o))}this.handle=requestAnimationFrame(()=>this.monitorLoudness())}reset(){this.stopPlayback(),this.stopped=!1,this.currentIndex=0,this.shouldMonitorLoudness=!0,this.isMonitoring=!1,this.isPlaying=!1,this.init()}setOnEndOfSpeech(e){this.onEndOfSpeech=e}}class At{player=new Et;fetchedSentences=new Set;lastLoading=!1;voice;voiceBackend;cache;voiceSpeed=1;instructions;constructor(e,t,s=!1){if(t?.split("_").length!==2)throw new Error("Invalid voice id format '"+t+"'. Voice id needs to look like <provider>_<voice_id>");this.voiceBackend=e,this.voice=t,this.cache=s}getCompletedSentences(e,t){const s=/(.+?[.?!]|.+?:\s+|.+?\n+)/g,i=[];let n;for(;(n=s.exec(e))!==null;){const o=n[0].trim();o.length>0&&i.push(o)}if(!t){const o=i[i.length-1],a=e.lastIndexOf(o)+o.length;a<e.length&&i.push(e.slice(a).trim())}return i}async handleNewText(e,t){if(!this.lastLoading&&t&&this.reset(),this.lastLoading=t,!e)return;const s=this.getCompletedSentences(e,t);for(let i=0;i<s.length;i++){const n=s[i];if(!this.fetchedSentences.has(n)){this.fetchedSentences.add(n);const o=await this.generateSpeech(n);await this.player.addChunk(o,i)}}}setInstructions(e){this.instructions=e}async generateSpeech(e){return await(await this.voiceBackend(e,this.voice,this.voiceSpeed,void 0,this.cache,this.instructions)).arrayBuffer()}play(){this.player.playAgain()}stop(){this.player.stopPlayback()}cleanup(){this.player.cleanup()}reset(){this.stop(),this.fetchedSentences.clear(),this.player.reset()}setVolume(e){this.player.setVolume(e)}setOnLoudnessChange(e){this.player.setOnLoudnessChange(t=>{e(t)})}setOnEndOfSpeech(e){this.player.setOnEndOfSpeech(e)}setVoiceSpeed(e){this.voiceSpeed=e}}const _e=["Pre-A1","A1","A2","B1","B2","C1","C2","Post-C2"];function he(r){return _e.indexOf(r)+1}function $t(r){return _e[r]}function jt(r,e){return $t(he(r)+e-1)}function Mt(r,e){return he(r)-he(e)}async function Dt(r,e){Object.assign(globalThis,{window:{isWorker:!0,location:{},parent:{postMessage:()=>{}},addEventListener:()=>{}}}),L.getInstance("Worker "+r+" EventBus");const s=await U.getInstance(r);console.debug("[Worker] RimoriClient initialized.");const i=new Error("[Worker "+r+"] Worker setup must complete within 5s. Use init event (e.g. onboarding.triggerInitPlugin) or run work async."),n=Promise.resolve(e(s)),o=new Promise((a,l)=>setTimeout(()=>l(i),5e3));await Promise.race([n,o]),console.debug("[Worker] Worker initialized."),s.event.emit("self.rimori.triggerInitFinished")}class _t{pluginId;constructor(e){this.pluginId=e}async startRecording(){P.emit(this.pluginId,"global.microphone.triggerStartRecording")}async stopRecording(){return(await P.request(this.pluginId,"global.microphone.triggerStopRecording")).data}async pauseRecording(){return(await P.request(this.pluginId,"global.microphone.triggerPauseRecording")).data}async resumeRecording(){return(await P.request(this.pluginId,"global.microphone.triggerResumeRecording")).data}async getCurrentStatus(){return(await P.request(this.pluginId,"global.microphone.triggerGetCurrentStatus")).data}}export{_t as AudioController,P as EventBus,L as EventBusHandler,At as MessageSender,Rt as ROLE_ORDER,U as RimoriClient,me as RimoriCommunicationHandler,q as StandaloneClient,Lt as StorageModule,Nt as TIER_ORDER,bt as Translator,Mt as compareLanguageLevels,$t as getDifficultyLabel,he as getDifficultyLevel,jt as getNeighborDifficultyLevel,Dt as setupWorker};
@@ -1 +1 @@
1
- import{_ as n}from"./preload-helper.js";import"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__rimori-scenario-host__remoteEntry-_hash_.js";const o={"@rimori/client":async()=>await n(()=>import("./index2.js"),[]),"@rimori/react-client":async()=>await n(()=>import("./index3.js"),[]),"@tanstack/react-query":async()=>await n(()=>import("./index4.js"),[]),react:async()=>await n(()=>import("./index5.js").then(t=>t.i),[]),"react-dom":async()=>await n(()=>import("./index6.js").then(t=>t.i),[]),"react/jsx-dev-runtime":async()=>await n(()=>import("./jsx-dev-runtime.js").then(t=>t.j),[]),"react/jsx-runtime":async()=>await n(()=>import("./jsx-runtime.js").then(t=>t.j),[]),zod:async()=>await n(()=>import("./index7.js"),[])},a={"@rimori/client":{name:"@rimori/client",version:"2.5.34-next.0",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["@rimori/client"].loaded=!0;const{"@rimori/client":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^2.5.34-next.0"}},"@rimori/react-client":{name:"@rimori/react-client",version:"0.4.21",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["@rimori/react-client"].loaded=!0;const{"@rimori/react-client":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^0.4.21"}},"@tanstack/react-query":{name:"@tanstack/react-query",version:"5.100.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["@tanstack/react-query"].loaded=!0;const{"@tanstack/react-query":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^5.100.5"}},react:{name:"react",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a.react.loaded=!0;const{react:e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},"react-dom":{name:"react-dom",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["react-dom"].loaded=!0;const{"react-dom":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},"react/jsx-dev-runtime":{name:"react/jsx-dev-runtime",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["react/jsx-dev-runtime"].loaded=!0;const{"react/jsx-dev-runtime":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},"react/jsx-runtime":{name:"react/jsx-runtime",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["react/jsx-runtime"].loaded=!0;const{"react/jsx-runtime":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},zod:{name:"zod",version:"3.25.76",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a.zod.loaded=!0;const{zod:e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^3.25.76"}}},u=[];export{u as usedRemotes,a as usedShared};
1
+ import{_ as n}from"./preload-helper.js";import"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__rimori-scenario-host__remoteEntry-_hash_.js";const o={"@rimori/client":async()=>await n(()=>import("./index2.js"),[]),"@rimori/react-client":async()=>await n(()=>import("./index3.js"),[]),"@tanstack/react-query":async()=>await n(()=>import("./index4.js"),[]),react:async()=>await n(()=>import("./index5.js").then(t=>t.i),[]),"react-dom":async()=>await n(()=>import("./index6.js").then(t=>t.i),[]),"react/jsx-dev-runtime":async()=>await n(()=>import("./jsx-dev-runtime.js").then(t=>t.j),[]),"react/jsx-runtime":async()=>await n(()=>import("./jsx-runtime.js").then(t=>t.j),[]),zod:async()=>await n(()=>import("./index7.js"),[])},a={"@rimori/client":{name:"@rimori/client",version:"2.5.35",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["@rimori/client"].loaded=!0;const{"@rimori/client":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^2.5.35"}},"@rimori/react-client":{name:"@rimori/react-client",version:"0.4.21",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["@rimori/react-client"].loaded=!0;const{"@rimori/react-client":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^0.4.21"}},"@tanstack/react-query":{name:"@tanstack/react-query",version:"5.100.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["@tanstack/react-query"].loaded=!0;const{"@tanstack/react-query":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^5.100.5"}},react:{name:"react",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a.react.loaded=!0;const{react:e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},"react-dom":{name:"react-dom",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["react-dom"].loaded=!0;const{"react-dom":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},"react/jsx-dev-runtime":{name:"react/jsx-dev-runtime",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["react/jsx-dev-runtime"].loaded=!0;const{"react/jsx-dev-runtime":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},"react/jsx-runtime":{name:"react/jsx-runtime",version:"19.2.5",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a["react/jsx-runtime"].loaded=!0;const{"react/jsx-runtime":e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^19.2.5"}},zod:{name:"zod",version:"3.25.76",scope:["default"],loaded:!1,from:"__mfe_internal__rimori-scenario-host",async get(){a.zod.loaded=!0;const{zod:e}=o,r={...await e()};return Object.defineProperty(r,"__esModule",{value:!0,enumerable:!1}),function(){return r}},shareConfig:{singleton:!0,requiredVersion:"^3.25.76"}}},u=[];export{u as usedRemotes,a as usedShared};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/playwright-testing",
3
- "version": "0.3.21-next.2",
3
+ "version": "0.3.22-next.0",
4
4
  "description": "Playwright testing utilities for Rimori plugins and workers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@playwright/test": "^1.40.0",
30
- "@rimori/client": "2.5.34-next.0"
30
+ "@rimori/client": "^2.5.35"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@module-federation/enhanced": "^2.3.3",
34
34
  "@module-federation/vite": "^1.14.5",
35
35
  "@playwright/test": "^1.40.0",
36
- "@rimori/client": "2.5.34-next.0",
36
+ "@rimori/client": "^2.5.35",
37
37
  "@rimori/react-client": "^0.4.19",
38
38
  "@tanstack/react-query": "^5.56.2",
39
39
  "@types/node": "^20.12.7",