@softarc/native-federation-orchestrator 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2022/sdk.mjs CHANGED
@@ -13,6 +13,7 @@ var Optional = class _Optional {
13
13
  constructor(item) {
14
14
  this.item = item;
15
15
  }
16
+ item;
16
17
  static of(item) {
17
18
  return new _Optional(item);
18
19
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/1.domain/externals/external.contract.ts", "../../src/lib/utils/optional.ts", "../../src/lib/utils/path.ts", "../../src/lib/native-federation.error.ts", "../../src/lib/utils/clone-entry.ts"],
4
4
  "sourcesContent": ["import type { SharedVersion, ScopedVersion } from './version.contract';\n\nexport type ExternalName = string;\n\nexport type ScopedExternals = Record<string, ScopedExternal>;\n\nexport const GLOBAL_SCOPE = '__GLOBAL__';\n\nexport const STRICT_SCOPE = 'strict';\n\nexport type SharedExternal = {\n dirty: boolean;\n versions: SharedVersion[];\n};\n\nexport type shareScope = Record<string, SharedExternal>;\n\nexport type SharedExternals = Record<string, shareScope> & { [GLOBAL_SCOPE]: shareScope };\n\nexport type ScopedExternal = Record<string, ScopedVersion>;\n", "export class Optional<T> {\n private constructor(private item?: T) {}\n\n public static of<T>(item?: T): Optional<T> {\n return new Optional(item);\n }\n public static empty<U>(): Optional<U> {\n return Optional.of<U>(undefined);\n }\n\n public isPresent() {\n return typeof this.item !== 'undefined' && this.item !== null;\n }\n public set<U>(other: U) {\n return Optional.of(other);\n }\n\n public ifPresent(callback: (_: T) => void): void {\n if (this.isPresent()) callback(this.item as T);\n }\n\n public map<U>(callback: (_: NonNullable<T>) => U | Optional<U>): Optional<U> {\n if (!this.isPresent()) return Optional.empty();\n\n const result = callback(this.item as NonNullable<T>);\n return result instanceof Optional ? result : Optional.of(result);\n }\n\n public orElse(other: Required<T>): NonNullable<T> {\n return this.isPresent() ? (this.item as NonNullable<T>) : (other as NonNullable<T>);\n }\n\n public orThrow(error: Error | string | (() => Error)): NonNullable<T> {\n if (this.isPresent()) return this.item as NonNullable<T>;\n if (typeof error === 'function') throw error();\n throw typeof error === 'string' ? new Error(error) : error;\n }\n\n public get(): T | undefined {\n return this.item;\n }\n}\n", "function join(pathA: string, pathB: string): string {\n pathA = pathA.endsWith('/') ? pathA.slice(0, -1) : pathA;\n pathB = pathB.startsWith('/') ? pathB.slice(1) : pathB;\n return `${pathA}/${pathB}`;\n}\n\nfunction getScope(path: string) {\n if (!path) return '';\n\n const parts = path.split('/');\n\n if (parts[parts.length - 1] === '' || parts[parts.length - 1]!.includes('.')) {\n parts.pop();\n }\n if (parts.length < 1) return '';\n\n return `${parts.join('/')}/`;\n}\n\nexport { join, getScope };\n", "class NFError extends Error {\n constructor(message: string, cause?: Error) {\n super(message, cause);\n this.name = 'NFError';\n }\n}\n\nexport { NFError };\n", "import type { StorageEntryKey } from 'lib/2.app/config/storage.contract';\nimport { NFError } from 'lib/native-federation.error';\n\ntype CloneEntry = <T>(name: StorageEntryKey, raw: T) => T;\n\nconst cloneEntry: CloneEntry = <T>(name: StorageEntryKey, raw: T) => {\n try {\n if (typeof structuredClone === 'function') {\n return structuredClone(raw);\n }\n } catch {\n /* structured clone is unavailable */\n }\n try {\n return JSON.parse(JSON.stringify(raw));\n } catch {\n /* object is not stringifyable */\n }\n throw new NFError(`Could not parse storage entry '${String(name)}'`);\n};\n\nexport { CloneEntry, cloneEntry };\n"],
5
- "mappings": ";;;;;;;AAMO,IAAM,eAAe;AAErB,IAAM,eAAe;;;ACRrB,IAAM,WAAN,MAAM,UAAY;AAAA,EACf,YAAoB,MAAU;AAAV;AAAA,EAAW;AAAA,EAEvC,OAAc,GAAM,MAAuB;AACzC,WAAO,IAAI,UAAS,IAAI;AAAA,EAC1B;AAAA,EACA,OAAc,QAAwB;AACpC,WAAO,UAAS,GAAM,MAAS;AAAA,EACjC;AAAA,EAEO,YAAY;AACjB,WAAO,OAAO,KAAK,SAAS,eAAe,KAAK,SAAS;AAAA,EAC3D;AAAA,EACO,IAAO,OAAU;AACtB,WAAO,UAAS,GAAG,KAAK;AAAA,EAC1B;AAAA,EAEO,UAAU,UAAgC;AAC/C,QAAI,KAAK,UAAU,EAAG,UAAS,KAAK,IAAS;AAAA,EAC/C;AAAA,EAEO,IAAO,UAA+D;AAC3E,QAAI,CAAC,KAAK,UAAU,EAAG,QAAO,UAAS,MAAM;AAE7C,UAAM,SAAS,SAAS,KAAK,IAAsB;AACnD,WAAO,kBAAkB,YAAW,SAAS,UAAS,GAAG,MAAM;AAAA,EACjE;AAAA,EAEO,OAAO,OAAoC;AAChD,WAAO,KAAK,UAAU,IAAK,KAAK,OAA2B;AAAA,EAC7D;AAAA,EAEO,QAAQ,OAAuD;AACpE,QAAI,KAAK,UAAU,EAAG,QAAO,KAAK;AAClC,QAAI,OAAO,UAAU,WAAY,OAAM,MAAM;AAC7C,UAAM,OAAO,UAAU,WAAW,IAAI,MAAM,KAAK,IAAI;AAAA,EACvD;AAAA,EAEO,MAAqB;AAC1B,WAAO,KAAK;AAAA,EACd;AACF;;;ACzCA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,KAAK,OAAe,OAAuB;AAClD,UAAQ,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI;AACnD,UAAQ,MAAM,WAAW,GAAG,IAAI,MAAM,MAAM,CAAC,IAAI;AACjD,SAAO,GAAG,KAAK,IAAI,KAAK;AAC1B;AAEA,SAAS,SAAS,MAAc;AAC9B,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,QAAQ,KAAK,MAAM,GAAG;AAE5B,MAAI,MAAM,MAAM,SAAS,CAAC,MAAM,MAAM,MAAM,MAAM,SAAS,CAAC,EAAG,SAAS,GAAG,GAAG;AAC5E,UAAM,IAAI;AAAA,EACZ;AACA,MAAI,MAAM,SAAS,EAAG,QAAO;AAE7B,SAAO,GAAG,MAAM,KAAK,GAAG,CAAC;AAC3B;;;ACjBA,IAAM,UAAN,cAAsB,MAAM;AAAA,EAC1B,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;;;ACAA,IAAM,aAAyB,CAAI,MAAuB,QAAW;AACnE,MAAI;AACF,QAAI,OAAO,oBAAoB,YAAY;AACzC,aAAO,gBAAgB,GAAG;AAAA,IAC5B;AAAA,EACF,QAAQ;AAAA,EAER;AACA,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AAAA,EACvC,QAAQ;AAAA,EAER;AACA,QAAM,IAAI,QAAQ,kCAAkC,OAAO,IAAI,CAAC,GAAG;AACrE;",
5
+ "mappings": ";;;;;;;AAMO,IAAM,eAAe;AAErB,IAAM,eAAe;;;ACRrB,IAAM,WAAN,MAAM,UAAY;AAAA,EACf,YAAoB,MAAU;AAAV;AAAA,EAAW;AAAA,EAAX;AAAA,EAE5B,OAAc,GAAM,MAAuB;AACzC,WAAO,IAAI,UAAS,IAAI;AAAA,EAC1B;AAAA,EACA,OAAc,QAAwB;AACpC,WAAO,UAAS,GAAM,MAAS;AAAA,EACjC;AAAA,EAEO,YAAY;AACjB,WAAO,OAAO,KAAK,SAAS,eAAe,KAAK,SAAS;AAAA,EAC3D;AAAA,EACO,IAAO,OAAU;AACtB,WAAO,UAAS,GAAG,KAAK;AAAA,EAC1B;AAAA,EAEO,UAAU,UAAgC;AAC/C,QAAI,KAAK,UAAU,EAAG,UAAS,KAAK,IAAS;AAAA,EAC/C;AAAA,EAEO,IAAO,UAA+D;AAC3E,QAAI,CAAC,KAAK,UAAU,EAAG,QAAO,UAAS,MAAM;AAE7C,UAAM,SAAS,SAAS,KAAK,IAAsB;AACnD,WAAO,kBAAkB,YAAW,SAAS,UAAS,GAAG,MAAM;AAAA,EACjE;AAAA,EAEO,OAAO,OAAoC;AAChD,WAAO,KAAK,UAAU,IAAK,KAAK,OAA2B;AAAA,EAC7D;AAAA,EAEO,QAAQ,OAAuD;AACpE,QAAI,KAAK,UAAU,EAAG,QAAO,KAAK;AAClC,QAAI,OAAO,UAAU,WAAY,OAAM,MAAM;AAC7C,UAAM,OAAO,UAAU,WAAW,IAAI,MAAM,KAAK,IAAI;AAAA,EACvD;AAAA,EAEO,MAAqB;AAC1B,WAAO,KAAK;AAAA,EACd;AACF;;;ACzCA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,KAAK,OAAe,OAAuB;AAClD,UAAQ,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI;AACnD,UAAQ,MAAM,WAAW,GAAG,IAAI,MAAM,MAAM,CAAC,IAAI;AACjD,SAAO,GAAG,KAAK,IAAI,KAAK;AAC1B;AAEA,SAAS,SAAS,MAAc;AAC9B,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,QAAQ,KAAK,MAAM,GAAG;AAE5B,MAAI,MAAM,MAAM,SAAS,CAAC,MAAM,MAAM,MAAM,MAAM,SAAS,CAAC,EAAG,SAAS,GAAG,GAAG;AAC5E,UAAM,IAAI;AAAA,EACZ;AACA,MAAI,MAAM,SAAS,EAAG,QAAO;AAE7B,SAAO,GAAG,MAAM,KAAK,GAAG,CAAC;AAC3B;;;ACjBA,IAAM,UAAN,cAAsB,MAAM;AAAA,EAC1B,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;;;ACAA,IAAM,aAAyB,CAAI,MAAuB,QAAW;AACnE,MAAI;AACF,QAAI,OAAO,oBAAoB,YAAY;AACzC,aAAO,gBAAgB,GAAG;AAAA,IAC5B;AAAA,EACF,QAAQ;AAAA,EAER;AACA,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AAAA,EACvC,QAAQ;AAAA,EAER;AACA,QAAM,IAAI,QAAQ,kCAAkC,OAAO,IAAI,CAAC,GAAG;AACrE;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.0.0",
2
+ "version": "4.0.2",
3
3
  "name": "@softarc/native-federation-orchestrator",
4
4
  "author": "Aukevanoost",
5
5
  "keywords": [
package/quickstart.mjs CHANGED
@@ -9,10 +9,10 @@ var es=Object.create;var Ro=Object.defineProperty;var ts=Object.getOwnPropertyDe
9
9
  //# sourceURL=`,eo=`
10
10
  //# sourceMappingURL=`,Ri=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g,ar=[],to=0,$i=()=>{if(++to>100)return new Promise(n=>ar.push(n))},Si=()=>{to--,ar.length&&ar.shift()()},ro=async(n,f,h)=>{if(ve&&!f.integrity)throw Error(`No integrity for ${n}${st(h)}.`);let g,y=$i();y&&await y;try{g=await oe(n,f)}catch($){throw $.message=`Unable to fetch ${n}${st(h)} - see network log for details.
11
11
  `+$.message,$}finally{Si()}if(!g.ok){let $=new TypeError(`${g.status} ${g.statusText} ${g.url}${st(h)}`);throw $.response=g,$}return g},rt,oo=async()=>{let n=await import(q);rt||(rt=n.transform)};async function no(n,f,h){let g=await ro(n,f,h),y,[,$,I,C]=(y=g.headers.get("content-type")||"").match(/^(?:[^/;]+\/(?:[^/+;]+\+)?(json)|(?:text|application)\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/)||[];if(!(I=$||(C?C[0]+"s":I||/\.m?ts(\?|#|$)/.test(n)&&"ts")))throw Error(`Unsupported Content-Type "${y}" loading ${n}${st(h)}. Modules must be served with a valid MIME type like application/javascript.`);return{url:g.url,source:await(I>"v"?WebAssembly.compileStreaming(g):g.text()),type:I}}let cr="var h=import.meta.hot,",io=async(n,f,h)=>{let g=Fe.integrity[n];f=g&&!f.integrity?{...f,integrity:g}:f;let{url:y=n,source:$,type:I}=await(x||no)(n,f,h,no)||{};if(I==="wasm"){let C=WebAssembly.Module.exports(bi[y]=$),_=WebAssembly.Module.imports($),O=ut(y);$=`import*as $_ns from${O};`;let F=0,E="";for(let{module:o,kind:fe}of _){let ge=ut(o);$+=`import*as impt${F} from${ge};
12
- `,E+=`${ge}:${fe==="global"?`importShim._i.get(impt${F})||impt${F++}`:`impt${F++}`},`}$+=`${cr}i=await WebAssembly.instantiate(importShim._s[${O}],{${E}});importShim._i.set($_ns,i);`,E="";for(let{name:o,kind:fe}of C)$+=`export let ${o}=i.exports['${o}'];`,fe==="global"&&($+=`try{${o}=${o}.value}catch(_){${o}=undefined}`),E+=`${o},`;$+=`if(h)h.accept(m=>({${E}}=m))`}else if(I==="json")$=`${cr}j=JSON.parse(${JSON.stringify($)});export{j as default};if(h)h.accept(m=>j=m.default)`;else if(I==="css")$=`${cr}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify($.replace(Ri,(C,_="",O,F)=>`url(${_}${jr(O||F,y)}${_})`))});if(h){h.data.s=s;h.accept(()=>{})}export default s`;else if(I==="ts"){rt||await oo();let C=rt($,y);$=C===void 0?$:C}return{url:y,source:$,type:I}},lr=(n,f,h,g)=>{if(g&&ft[n]){let $=0;for(;ft[n+"#"+ ++$];);n+="#"+$}let y=ft[n];return y||(ft[n]=y={u:n,r:g?n:void 0,f:void 0,S:g,L:void 0,a:void 0,d:void 0,b:void 0,s:void 0,n:!1,N:!1,t:null,m:null},y.f=(async()=>{y.S===void 0&&({url:y.r,source:y.S,type:y.t}=await(ur[n]||io(n,f,h)),!y.n&&y.t!=="js"&&!P&&(y.t==="css"&&!et||y.t==="json"&&!Qe||y.t==="wasm"&&!It&&!at||y.t==="ts")&&(y.n=!0));try{y.a=di(y.S,y.u)}catch($){it($),y.a=[[],[],!1]}return y})(),y)},vi=n=>Error(`${n} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${n}"] }<\/script>`),so=(n,f)=>{n.L||(n.L=n.f.then(()=>{let h=f;n.d=n.a[0].map(({n:g,d:y,t:$,a:I,se:C})=>{let _=$>=4,O=_&&$<6;if(_){if(!P&&(O?!Ge:!Qt))throw vi(O?"wasm-module-sources":"import-defer");(!O||!at)&&(n.n=!0)}let F;if(I>0&&!P&&Ve){let fe=n.S.slice(I,C-1);fe.includes("json")?Qe?F="":n.n=!0:fe.includes("css")&&(et?F="":n.n=!0)}if(y!==-1||!g)return;let E=lt(g,n.r||n.u);if((E.n||K)&&(n.n=!0),(y>=0||E.N)&&(n.N=!0),y!==-1)return;if(Oe&&Oe(E.r)&&!O)return{l:{b:E.r},s:!1};h.integrity&&(h={...h,integrity:void 0});let o={l:lr(E.r,h,n.r,F),s:O};return F===""&&(o.l.b=o.l.u),o.s||so(o.l,f),o}).filter(g=>g)}))},dt=()=>{for(let n of document.querySelectorAll(P?"link[rel=modulepreload-shim]":"link[rel=modulepreload]"))n.ep||Eo(n);for(let n of document.querySelectorAll("script[type]"))n.type==="importmap"+(P?"-shim":"")?n.ep||ho(n):n.type==="module"+(P?"-shim":"")&&(tt=!1,n.ep||go(n))},Nt=n=>{let f={};return n.integrity&&(f.integrity=n.integrity),n.referrerPolicy&&(f.referrerPolicy=n.referrerPolicy),n.fetchPriority&&(f.priority=n.fetchPriority),n.crossOrigin==="use-credentials"?f.credentials="include":n.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f},fr=Promise.resolve(),ao=!1,At=1,Ft=n=>{if(n===void 0){if(ao)return;ao=!0,At--}--At===0&&!ie&&(P||!Te)&&(document.removeEventListener("DOMContentLoaded",lo),document.dispatchEvent(new Event("DOMContentLoaded")))},pr=1,co=()=>{--pr===0&&!ie&&(P||!Te)&&(window.removeEventListener("load",fo),window.dispatchEvent(new Event("load")))},lo=async()=>{await Ue,Ft()},fo=async()=>{await Ue,Ft(),co()};c&&(document.addEventListener("DOMContentLoaded",lo),window.addEventListener("load",fo));let po=async()=>{await Ue,dt(),document.readyState==="complete"&&mr()},ht=1,mr=()=>{--ht===0&&(Ft(),!ie&&(P||!Te)&&(document.removeEventListener("readystatechange",po),document.dispatchEvent(new Event("readystatechange"))))},mo=n=>n.nextSibling||n.parentNode&&mo(n.parentNode),uo=(n,f)=>n.ep||!f&&(!n.src&&!n.innerHTML||!mo(n))||n.getAttribute("noshim")!==null||!(n.ep=!0),ho=(n,f=ht>0)=>{if(!uo(n,f)){if(n.src){if(!P)return;Kr=!0}mt=mt.then(async()=>{Fe=Dr(n.src?await(await ro(n.src,Nt(n))).json():JSON.parse(n.innerHTML),n.src||we,Fe)}).catch(h=>{h instanceof SyntaxError&&(h=new Error(`Unable to parse import map ${h.message} in: ${n.src||n.innerHTML}`)),it(h)}),!pt&&tt&&mt.then(()=>pt=Fe),!tt&&!nr&&(nr=!0,!P&&Te&&!kt&&(Te=!1,c&&Zr())),tt=!1}},go=(n,f=ht>0)=>{if(uo(n,f))return;let h=n.getAttribute("async")===null&&ht>0,g=At>0,y=pr>0;y&&pr++,h&&ht++,g&&At++;let $,I=n.lang==="ts";I&&!n.src?$=Promise.resolve(rt||oo()).then(()=>{let C=rt(n.innerHTML,we);return C!==void 0&&(Mr(),ir=!1),Tt(n.src||we,we,Nt(n),C===void 0?n.innerHTML:C,!P&&C===void 0,h&&fr,"ts")}).catch(it):$=Tt(n.src||we,we,Nt(n),n.src?void 0:n.innerHTML,!P,h&&fr,I?"ts":void 0).catch(it),ie||$.then(()=>n.dispatchEvent(new Event("load"))),h&&!I&&(fr=$.then(mr)),g&&$.then(Ft),y&&$.then(co)},ur={},Eo=n=>{n.ep=!0,Ue.then(()=>{Te&&!P||ur[n.href]||(ur[n.href]=io(n.href,Nt(n)))})}})();var H=class extends Error{constructor(t,i){super(t,i),this.name="NFError"}};function Y(r,t){return r=r.endsWith("/")?r.slice(0,-1):r,t=t.startsWith("/")?t.slice(1):t,`${r}/${t}`}function Ne(r){if(!r)return"";let t=r.split("/");return(t[t.length-1]===""||t[t.length-1].includes("."))&&t.pop(),t.length<1?"":`${t.join("/")}/`}function $o(r,t){return(u={})=>t.manifestProvider.provide(u).catch(p=>(r.log.error(1,"Could not fetch manifest.",p),Promise.reject(new H("Failed to fetch manifest")))).then(i).then(s).then(b).then(v);function i(u){if(!r.hostRemoteEntry)return u;let{name:p,url:R,cacheTag:S}=r.hostRemoteEntry,D=S?`${R}?cacheTag=${S}`:R;return{...u,[p]:D}}async function s(u){let p=Object.entries(u).map(([R,S])=>c(R,S));return Promise.all(p)}async function c(u,p){let R=!1,S=!1;if(t.remoteInfoRepo.tryGet(u).ifPresent(D=>{r.profile.overrideCachedRemotes!=="never"&&(p!==Y(D.scopeUrl,"remoteEntry.json")||r.profile.overrideCachedRemotesIfURLMatches)?(r.log.debug(1,`Overriding existing remote '${u}' with '${p}'.`),R=!0):(r.log.debug(1,`Found remote '${u}' in storage, omitting fetch.`),S=!0)}),S)return!1;try{let D=await t.remoteEntryProvider.provide(p);return r.log.debug(1,`Fetched '${D.name}' from '${D.url}', exposing: ${JSON.stringify(D.exposes)}`),d(D,u,R)}catch(D){return r.strict.strictRemoteEntry?(r.log.error(1,`Could not fetch remote '${u}'.`,D),Promise.reject(new H(`Could not fetch remote '${u}'`))):(r.log.warn(1,`Could not fetch remote '${u}'. skipping init.`,D),Promise.resolve(!1))}}function d(u,p,R){if(R&&(u.override=R),r.hostRemoteEntry&&p===r.hostRemoteEntry.name&&(u.host=!0,u.name=r.hostRemoteEntry.name),u.name!==p){let S=`Fetched remote '${u.name}' does not match requested '${p}'.`;if(r.strict.strictRemoteEntry)throw new H(S);r.log.warn(1,`${S} Omitting expected name.`)}return u}function b(u){return u.filter(p=>p!==!1)}function v(u){return r.sse&&u.forEach(p=>{if(p.buildNotificationsEndpoint){t.sse.watchRemoteBuilds(Y(Ne(p.url),p.buildNotificationsEndpoint)),r.log.debug(1,`Registered SSE endpoint of remote '${p.name}' `);return}r.log.debug(1,`Remote ${p.name} has no defined 'buildNotificationsEndpoint'`)}),u}}function So(r,t){return u=>{try{return u.forEach(p=>{p?.override&&i(p),s(p),c(p),d(p)}),Promise.resolve(u)}catch(p){return Promise.reject(p)}};function i(u){t.remoteInfoRepo.remove(u.name),t.scopedExternalsRepo.remove(u.name),t.sharedExternalsRepo.removeFromAllScopes(u.name)}function s({name:u,url:p,exposes:R}){t.remoteInfoRepo.addOrUpdate(u,{scopeUrl:Ne(p),exposes:Object.values(R??[]).map(S=>({moduleName:S.key,file:S.outFileName}))})}function c(u){u.shared.forEach(p=>{if(!p.version||!t.versionCheck.isValidSemver(p.version)){let R=`[${u.name}][${p.packageName}] Version '${p.version}' is not a valid version.`;if(r.strict.strictExternalVersion)throw r.log.error(2,R),new H(`Could not process remote '${u.name}'`);r.log.warn(2,R)}p.singleton?b(u.name,p,u):v(u.name,p)})}function d(u){u.chunks&&(r.log.debug(2,`Adding chunks for remote "${u.name}", bundles: [${Object.keys(u.chunks).join(", ")}]`),Object.entries(u.chunks).forEach(([p,R])=>{t.sharedChunksRepo.addOrReplace(u.name,p,R)}))}function b(u,p,R){let S="skip",D=p.version??t.versionCheck.smallestVersion(p.requiredVersion),P={file:p.outFileName,name:u,bundle:p.bundle,strictVersion:p.strictVersion,cached:!1,requiredVersion:p.requiredVersion||D},ue=t.sharedExternalsRepo.scopeType(p.shareScope);ue==="strict"&&(S="share",P.requiredVersion=D);let ne=t.sharedExternalsRepo.tryGet(p.packageName,p.shareScope).orElse({dirty:!1,versions:[]}),oe=ne.versions.find(L=>L.tag===p.version),x=ne.dirty;if(oe){if(P.strictVersion&&oe.remotes[0].requiredVersion!==P.requiredVersion){let L=`[${u}][${p.packageName}@${p.version}] Required version-range '${P.requiredVersion}' does not match cached version-range '${oe.remotes[0].requiredVersion}'`;if(r.strict.strictExternalSameVersionCompatibility)throw r.log.error(2,L),new H(`Could not process remote '${R.name}'`);r.log.warn(2,L)}!oe.host&&R?.host?(oe.host=!0,oe.remotes.unshift(P)):oe.remotes.push(P)}else ue!=="strict"&&(x=!0),ne.versions.push({tag:D,action:S,host:!!R?.host,remotes:[P]});t.sharedExternalsRepo.addOrUpdate(p.packageName,{dirty:x,versions:ne.versions.sort((L,q)=>t.versionCheck.compare(q.tag,L.tag))},p.shareScope)}function v(u,p){t.scopedExternalsRepo.addExternal(u,p.packageName,{tag:p.version??t.versionCheck.smallestVersion(p.requiredVersion),file:p.outFileName,bundle:p.bundle})}}var de="__GLOBAL__",vo="strict";function wo(r,t){return()=>{for(let s of t.sharedExternalsRepo.getScopes()){let c=t.sharedExternalsRepo.getFromScope(s);try{Object.entries(c).filter(([d,b])=>b.dirty).forEach(([d,b])=>t.sharedExternalsRepo.addOrUpdate(d,i(d,b),s))}catch(d){return r.log.error(3,`[${s??de}] failed to determine shared externals.`,{sharedExternals:c,error:d}),Promise.reject(new H(`Could not determine shared externals in scope ${s}.`,d))}}return Promise.resolve()};function i(s,c){if(c.versions.length===1)return c.versions[0].action="share",c.dirty=!1,c;let d=c.versions.find(b=>b.host);if(!d&&r.profile.latestSharedExternal&&(d=c.versions[0]),!d){let b=Number.MAX_VALUE;c.versions.forEach(v=>{let u=c.versions.filter(p=>!p.remotes[0].cached&&p.remotes[0].strictVersion&&!t.versionCheck.isCompatible(v.tag,p.remotes[0].requiredVersion)).length;u<b&&(b=u,d=v)})}if(!d)throw new H(`[${s}] Could not determine shared version!`);return c.versions.forEach(b=>{if(t.versionCheck.isCompatible(d.tag,b.remotes[0].requiredVersion)){b.action="skip";return}if(r.strict.strictExternalCompatibility&&b.remotes[0].strictVersion)throw r.log.error(3,`[${b.remotes[0].name}][${s}@${b.tag}] Is not compatible with requiredRange '${d.remotes[0]?.requiredVersion}' from remote '${d.remotes[0].name}'.`),new H(`External ${s}@${b.tag} could not be shared.`);b.action=b.remotes[0].strictVersion?"scope":"skip"}),d.action="share",c.dirty=!1,c}}var Rt;(function(r){r.COMPLETED="federation-rebuild-complete",r.ERROR="federation-rebuild-error",r.CANCELLED="federation-rebuild-cancelled"})(Rt||(Rt={}));var Co="@nf-internal";function $t(r){r.startsWith("./")&&(r=r.slice(2));let t=r.replace(/.(m|c)?js$/,"");return Co+"/"+t}function Io(r,t){return()=>{let x={imports:{}},L={};try{return i(x,L),c(x,L),u(x,L),D(x,L),ne(x,L),Promise.resolve(x)}catch(q){return Promise.reject(q)}};function i(x,L){let q=t.scopedExternalsRepo.getAll();for(let[U,B]of Object.entries(q)){let K=t.remoteInfoRepo.tryGet(U).orThrow(()=>(r.log.error(4,`[scoped][${U}] Remote name not found in cache.`),new H("Could not create ImportMap.")));R(x,K.scopeUrl,s(B,K.scopeUrl)),Object.values(B).filter(ie=>!!ie.bundle).forEach(ie=>ue(L,U,ie.bundle))}return x}function s(x,L){let q={};for(let[U,B]of Object.entries(x))q[U]=Y(L,B.file);return q}function c(x,L){let q=t.sharedExternalsRepo.getScopes({includeGlobal:!1});for(let U of q)d(x,U,L);return x}function d(x,L,q){let U=t.sharedExternalsRepo.getFromScope(L);for(let[B,K]of Object.entries(U)){let ie,ve;for(let le of K.versions){if(le.action==="scope"){for(let Me of le.remotes){let We=oe(L,Me.name,B);R(x,We,{[B]:Y(We,Me.file)}),ue(q,Me.name,Me.bundle),Me.cached=!0}continue}let Ke=oe(L,le.remotes[0].name,B),Ve=Y(Ke,le.remotes[0].file);le.remotes[0].cached=!0,le.action==="share"&&ue(q,le.remotes[0].name,le.remotes[0].bundle),le.action==="skip"&&(ie||(ie=b(K,L,B)??"NOT_AVAILABLE"),ie!=="NOT_AVAILABLE"&&(ve||(ve=oe(L,ie.remotes[0].name,B)),Ve=Y(ve,ie.remotes[0].file),ie.remotes[0].cached=!0,le.remotes[0].cached=!1)),le.remotes.forEach(Me=>{let We=oe(L,Me.name,B);R(x,We,{[B]:Ve})})}t.sharedExternalsRepo.addOrUpdate(B,K,L)}}function b(x,L,q){let U=x.versions.filter(K=>K.action==="share"),B=`${L}.${q}`;if(U.length>1&&v(B),U.length<1){if(r.strict.strictImportMap)throw r.log.error(4,`[${L}][${q}] shareScope has no override version.`),new H("Could not create ImportMap.");r.log.debug(4,`[${L}][${q}] shareScope has no override version, scoping override versions.`)}return U[0]}function v(x){if(r.strict.strictImportMap)throw r.log.error(4,`[${x}] ShareScope external has multiple shared versions.`),new H("Could not create ImportMap.");r.log.warn(4,`ShareScope external ${x} has multiple shared versions.`)}function u(x,L){let q=t.sharedExternalsRepo.getFromScope();for(let[U,B]of Object.entries(q)){for(let K of B.versions){if(K.action==="skip")continue;if(K.action==="scope"){for(let ve of K.remotes){let le=oe(de,ve.name,U);R(x,le,{[U]:Y(le,ve.file)}),ve.cached=!0,ue(L,ve.name,ve.bundle)}continue}if(x.imports[U]){p(U);continue}let ie=oe(de,K.remotes[0].name,U);S(x,{[U]:Y(ie,K.remotes[0].file)}),ue(L,K.remotes[0].name,K.remotes[0].bundle),K.remotes[0].cached=!0}t.sharedExternalsRepo.addOrUpdate(U,B)}return x}function p(x){if(r.strict.strictImportMap)throw r.log.error(4,`[${x}] Shared external has multiple shared versions.`),new H("Could not create ImportMap.");r.log.warn(4,`Singleton external ${x} has multiple shared versions.`)}function R(x,L,q){x.scopes||(x.scopes={}),x.scopes[L]||(x.scopes[L]={}),x.scopes[L]=Object.assign(x.scopes[L],q)}function S(x,L){x.imports=Object.assign(x.imports,L)}function D(x,L){let q=t.remoteInfoRepo.getAll();for(let[U,B]of Object.entries(q))P(x,U,B),ue(L,U,"mapping-or-exposed")}function P(x,L,q){for(let U of q.exposes){let B=Y(L,U.moduleName),K=Y(q.scopeUrl,U.file);x.imports[B]=K}}function ue(x,L,q){return q&&(x[L]||(x[L]=new Set),x[L].add(q)),x}function ne(x,L){return Object.entries(L).forEach(([q,U])=>{let B=oe("CHUNKS",q),K=Array.from(U).reduce((ie,ve)=>(t.sharedChunksRepo.tryGet(q,ve).ifPresent(le=>{le.forEach(Ke=>{ie[$t(Ke)]=Y(B,Ke)})}),ie),{});Object.keys(K).length>0&&R(x,B,K)}),x}function oe(x,L,q){return t.remoteInfoRepo.tryGet(L).map(U=>U.scopeUrl).orThrow(()=>(q?r.log.error(4,`[${x}][${q}][${L}] Remote name not found in cache.`):r.log.error(4,`[${x}][${L}] Remote name not found in cache.`),new H("Could not create ImportMap.")))}}function Vt(r,t){return c=>Promise.resolve(c).then(i).then(s);function i(c){return t.browser.setImportMapFn(c),r.log.debug(5,"Added import map to browser.",c),c}function s(){t.remoteInfoRepo.commit(),t.scopedExternalsRepo.commit(),t.sharedExternalsRepo.commit(),t.sharedChunksRepo.commit()}}function ko(r,t){let i=(s,c)=>{try{if(!t.remoteInfoRepo.contains(s))throw new H(`Remote '${s}' is not initialized.`);let d=t.remoteInfoRepo.tryGetModule(s,c).orThrow(new H(`Exposed module '${c}' from remote '${s}' not found in storage.`));return r.log.debug(6,`Loading initialized module '${d}'`),t.browser.importModule(d)}catch(d){return r.log.error(6,`Failed to load module ${Y(s,c)}: `,{error:d}),Promise.reject(new H(`Failed to load module ${Y(s,c)}`))}};return()=>Promise.resolve(i)}var ss=({config:r,adapters:t})=>({getRemoteEntries:$o(r,t),processRemoteEntries:So(r,t),determineSharedExternals:wo(r,t),generateImportMap:Io(r,t),commitChanges:Vt(r,t),exposeModuleLoader:ko(r,t)}),Lo=({config:r,adapters:t})=>({flow:ss({config:r,adapters:t}),adapters:t,config:r}),Oo=({flow:r,adapters:t,config:i})=>s=>r.getRemoteEntries(s).then(r.processRemoteEntries).then(r.determineSharedExternals).then(r.generateImportMap).then(r.commitChanges).then(r.exposeModuleLoader).then(c=>({config:i,adapters:t,loadRemoteModule:c}));var To=r=>({setImportMapFn:r.setImportMapFn,importModule:r.loadModuleFn});var Ln=yt(Xo()),On=yt(Sn()),Tn=yt(Xe()),xn=yt(Cn()),Nn=yt(kn()),An=()=>({isValidSemver:function(r){return(0,Ln.default)(r)!==null},isCompatible:function(r,t){return(0,On.default)(r,t)},compare:function(r,t){return(0,Tn.default)(r,t,!0)},smallestVersion:function(r){return(0,Nn.default)(r)?(0,xn.default)(r)?.raw??"0.0.0":"0.0.0"}});var Fn=()=>{let r=i=>i.ok?i.json():Promise.reject(new H(`${i.status} - ${i.statusText}`)),t=i=>s=>{let c=s instanceof Error?s.message:String(s);throw new H(`Fetch of '${i}' returned ${c}`)};return{provide:async function(i){return typeof i!="string"?Promise.resolve(i):fetch(i).then(r).catch(t(i))}}};var Pn=()=>{let r=s=>s.ok?s.json():Promise.reject(new Error(`${s.status} - ${s.statusText}`)),t=s=>c=>(c.exposes||(c.exposes=[]),c.shared||(c.shared=[]),c.url||(c.url=s),c),i=s=>c=>{let d=c instanceof Error?c.message:String(c);throw new H(`Fetch of '${s}' returned ${d}`)};return{provide:async function(s){return fetch(s).then(r).then(t(s)).catch(i(s))}}};var ye=class r{constructor(t){this.item=t}static of(t){return new r(t)}static empty(){return r.of(void 0)}isPresent(){return typeof this.item<"u"&&this.item!==null}set(t){return r.of(t)}ifPresent(t){this.isPresent()&&t(this.item)}map(t){if(!this.isPresent())return r.empty();let i=t(this.item);return i instanceof r?i:r.of(i)}orElse(t){return this.isPresent()?this.item:t}orThrow(t){if(this.isPresent())return this.item;throw typeof t=="function"?t():typeof t=="string"?new Error(t):t}get(){return this.item}};var Mn=r=>{let t=r.storage("remotes",{});r.clearStorage&&t.clear();let i=t.get()??{};return{contains:function(s){return!!i[s]},remove:function(s){return delete i[s],this},addOrUpdate:function(s,c){return i[s]=c,this},tryGet:function(s){return ye.of(i[s])},tryGetModule:function(s,c){return ye.of(i[s]?.exposes.find(d=>d.moduleName===c)).map(d=>Y(i[s].scopeUrl,d.file))},getAll:function(){return i},commit:function(){return t.set(i),this}}};var _n=r=>{let t=r.storage("scoped-externals",{});r.clearStorage&&t.clear();let i=t.get()??{};return{addExternal:function(s,c,d){return i[s]||(i[s]={}),i[s][c]=d,this},remove:function(s){return delete i[s],this},getAll:function(){return i},tryGet:function(s){return ye.of(i[s])},commit:function(){return t.set(i),this}}};var jn=r=>{let t=r.storage("shared-externals",{[de]:{}});r.clearStorage&&t.clear();let i=t.get();return{getFromScope:function(s){return{...i[s??de]}},addOrUpdate:function(s,c,d){return i[d??de]||(i[d??de]={}),i[d??de][s]=c,this},getScopes:function(s={includeGlobal:!0}){return s.includeGlobal?Object.keys(i):Object.keys(i).filter(c=>c!==de)},removeFromAllScopes:function(s){Object.values(i).forEach(c=>{let d=[];Object.entries(c).forEach(([b,v])=>{let u=[];if(v.versions.forEach((p,R)=>{let S=p.remotes.findIndex(D=>D.name===s);~S&&p.remotes.splice(S,1),p.remotes.length===0&&u.push(R)}),u.length>0){for(let p=u.length-1;p>=0;p--)v.versions.splice(u[p],1);v.dirty=!0,v.versions.length===0&&d.push(b)}}),d.forEach(b=>delete c[b])})},scopeType:function(s){switch(s){case de:case null:case void 0:return"global";case vo:return"strict";default:return"shareScope"}},tryGet:function(s,c){return ye.of(i[c??de]?.[s])},commit:function(){return t.set(i),this}}};var Dn=r=>{let t=[];return{watchRemoteBuilds:function(i){let s=new EventSource(i);s.onmessage=function(c){JSON.parse(c.data).type===Rt.COMPLETED&&(t.forEach(b=>b.close()),r.log.debug(0,"[SSE] Rebuild completed, reloading..."),r.reloadBrowserFn())},s.onerror=function(c){r.log.error(0,"[SSE] Connection error:",c)},t.push(s)},closeAll:function(){t.forEach(i=>i.close()),t.length=0}}};var Yt=(r,t)=>{try{if(typeof structuredClone=="function")return structuredClone(t)}catch{}try{return JSON.parse(JSON.stringify(t))}catch{}throw new H(`Could not parse storage entry '${String(r)}'`)};var Vn=r=>{let t=r.storage("shared-chunks",{});r.clearStorage&&t.clear();let i=t.get()??{};return{addOrReplace:function(s,c,d){return i[s]||(i[s]={}),i[s][c]=d,this},tryGet:function(s,c){return ye.of(i[s]?.[c])},commit:function(){return t.set(i),this}}};var Gn=r=>({adapters:{versionCheck:An(),manifestProvider:Fn(),remoteEntryProvider:Pn(),remoteInfoRepo:Mn(r),scopedExternalsRepo:_n(r),sharedExternalsRepo:jn(r),sharedChunksRepo:Vn(r),browser:To(r),sse:Dn(r)},config:r});var Jt=r=>(t,i={})=>(i?.override&&document.head.querySelectorAll(`script[type="${r}"]`).forEach(s=>s.remove()),document.head.appendChild(Object.assign(document.createElement("script"),{type:r,innerHTML:JSON.stringify(t)})),Promise.resolve(t));var qn=()=>({loadModuleFn:r=>import(r),setImportMapFn:Jt("importmap"),reloadBrowserFn:()=>{window.location.reload()}});var Hn=r=>{let t=qn();return{setImportMapFn:r.setImportMapFn??t.setImportMapFn,loadModuleFn:r.loadModuleFn??t.loadModuleFn,reloadBrowserFn:r.reloadBrowserFn??t.reloadBrowserFn}};var Un=r=>r?.hostRemoteEntry?typeof r.hostRemoteEntry=="string"?{hostRemoteEntry:{name:"__NF-HOST__",url:r.hostRemoteEntry}}:{hostRemoteEntry:{name:"__NF-HOST__",...r.hostRemoteEntry}}:{hostRemoteEntry:!1};var Xn={debug:()=>{},error:()=>{},warn:()=>{}};var zt={debug:0,warn:1,error:2};var Wn=(r,t)=>Object.keys(zt).filter(s=>isNaN(Number(s))).reduce((s,c)=>({...s,[c]:(d,b,v)=>{zt[c]>=zt[t]&&r[c](d,b,v)}}),{level:t});var Bn=({logger:r,logLevel:t,sse:i})=>({log:Wn(r??Xn,t??"error"),sse:!!i});var Yn=r=>(t,i)=>{globalThis[r]||(globalThis[r]={});let s=globalThis[r];s[t]||(s[t]=i);let c={get(){return Yt(t,s[t])},set(d){return s[t]=Yt(t,d),c},clear(){return s[t]=Yt(t,i),this}};return c};var Jn=r=>({storage:r.storage?r.storage(r.storageNamespace??"__NATIVE_FEDERATION__"):Yn(r.storageNamespace??"__NATIVE_FEDERATION__"),clearStorage:r.clearStorage??!1});var zn={latestSharedExternal:!1,overrideCachedRemotes:"init-only",overrideCachedRemotesIfURLMatches:!1};var Kn=r=>({strict:typeof r.strict=="boolean"?{strictRemoteEntry:r.strict,strictExternalCompatibility:r.strict,strictExternalSameVersionCompatibility:r.strict,strictExternalVersion:r.strict,strictImportMap:r.strict}:{strictRemoteEntry:r.strict?.strictRemoteEntry??!1,strictExternalCompatibility:r.strict?.strictExternalCompatibility??!1,strictExternalSameVersionCompatibility:r.strict?.strictExternalCompatibility??!1,strictExternalVersion:r.strict?.strictExternalVersion??!1,strictImportMap:r.strict?.strictImportMap??!1},profile:{...zn,...r.profile??{}}});var Zn=r=>({...Hn(r),...Un(r),...Bn(r),...Jn(r),...Kn(r)});function Qn({log:r},t){return({entry:b,actions:v})=>{let u={imports:{}};return i(b,v,u),c(b,u),r.debug(9,`[${b.name}] Processed actions:`,v),Promise.resolve(u)};function i(b,v,u){if(!b.shared)return;let p=Ne(b.url),R=new Set(["mapping-or-exposed"]);b.shared.forEach(S=>{if(!S.singleton){s(p,S.packageName,Y(p,S.outFileName),u),S?.bundle&&R.add(S?.bundle);return}if(!v[S.packageName]){r.warn(9,`[${b.name}] No action defined for shared external '${S.packageName}', skipping.`);return}if(v[S.packageName].action==="skip"){if(!S.shareScope)return;if(v[S.packageName].override){s(p,S.packageName,v[S.packageName].override,u);return}}if(S?.bundle&&R.add(S?.bundle),v[S.packageName].action==="scope"){s(p,S.packageName,Y(p,S.outFileName),u);return}if(S.shareScope){s(p,S.packageName,Y(p,S.outFileName),u);return}u.imports[S.packageName]=Y(p,S.outFileName)}),d(u,b.name,p,R)}function s(b,v,u,p){p.scopes||(p.scopes={}),p.scopes[b]||(p.scopes[b]={}),p.scopes[b][v]=u}function c(b,v){if(!b.exposes)return;let u=Ne(b.url);b.exposes.forEach(p=>{let R=Y(b.name,p.key),S=Y(u,p.outFileName);v.imports[R]=S})}function d(b,v,u,p){return Array.from(p).forEach(R=>{t.sharedChunksRepo.tryGet(v,R).ifPresent(S=>{S.forEach(D=>{s(u,$t(D),Y(u,D),b)})})}),b}}function ei(r,t){return async(c,d)=>{if(d&&i(c,d))return r.log.debug(7,`Found remote '${d}' in storage, omitting fetch.`),ye.empty();try{let b=await t.remoteEntryProvider.provide(c);if(r.log.debug(7,`[${b.name}] Fetched from '${b.url}', exposing: ${JSON.stringify(b.exposes)}`),d&&b.name!==d){let v=`Fetched remote '${b.name}' does not match requested '${d}'.`;if(r.strict.strictRemoteEntry)throw r.log.error(7,v),new H("Could not fetch remote entry");r.log.warn(7,v+" Omitting expected name.")}return t.remoteInfoRepo.contains(b.name)&&(b.override=!0,r.log.debug(7,`Overriding existing remote '${d}' with '${c}'.`)),ye.of(s(b))}catch(b){return r.log.error(7,`[${d??"unknown"}] Could not fetch remoteEntry from ${c}.`,b),Promise.reject(new H(`[${d??c}] Could not fetch remoteEntry.`))}};function i(c,d){return t.remoteInfoRepo.tryGet(d).map(b=>r.profile.overrideCachedRemotes!=="always"||!r.profile.overrideCachedRemotesIfURLMatches&&c===Y(b.scopeUrl,"remoteEntry.json")).orElse(!1)}function s(c){return r.sse&&(c.buildNotificationsEndpoint?(t.sse.watchRemoteBuilds(Y(Ne(c.url),c.buildNotificationsEndpoint)),r.log.debug(7,`Registered SSE endpoint of remote '${c.name}' `)):r.log.debug(7,`Remote ${c.name} has no defined 'buildNotificationsEndpoint'`)),c}}function ti(r,t){return u=>{try{u?.override&&i(u),s(u);let p=c(u);return d(u),Promise.resolve({entry:u,actions:p})}catch(p){return Promise.reject(p)}};function i(u){t.remoteInfoRepo.remove(u.name),t.scopedExternalsRepo.remove(u.name),t.sharedExternalsRepo.removeFromAllScopes(u.name)}function s({name:u,url:p,exposes:R}){t.remoteInfoRepo.addOrUpdate(u,{scopeUrl:Ne(p),exposes:Object.values(R??[]).map(S=>({moduleName:S.key,file:S.outFileName}))})}function c(u){let p={};return u.shared.forEach(R=>{if(!R.version||!t.versionCheck.isValidSemver(R.version)){let S=`[${u.name}][${R.packageName}] Version '${R.version}' is not a valid version.`;if(r.strict.strictExternalVersion)throw r.log.error(8,S),new H(`Could not process remote '${u.name}'`);r.log.warn(8,S)}if(R.singleton){let{action:S,sharedVersion:D}=b(u.name,R);p[R.packageName]={action:S},S==="skip"&&R.shareScope&&D?.remotes[0]?.file&&(p[R.packageName].override=t.remoteInfoRepo.tryGet(D.remotes[0].name).map(P=>Y(P.scopeUrl,D.remotes[0].file)).orThrow(()=>(r.log.error(8,`[${R.shareScope??de}][${u.name}][${R.packageName}@${R.version}][override] Remote name not found in cache.`),new H(`Could not find override url from remote ${D.remotes[0].name}`))))}else v(u.name,R)}),p}function d(u){u.chunks&&(r.log.debug(8,`Adding chunks for remote "${u.name}", bundles: [${Object.keys(u.chunks).join(", ")}]`),Object.entries(u.chunks).forEach(([p,R])=>{t.sharedChunksRepo.addOrReplace(u.name,p,R)}))}function b(u,p){let R=t.sharedExternalsRepo.tryGet(p.packageName,p.shareScope).orElse({dirty:!1,versions:[]}),S="skip",D=p.version??t.versionCheck.smallestVersion(p.requiredVersion),P={file:p.outFileName,strictVersion:p.strictVersion,requiredVersion:p.requiredVersion||D,name:u,bundle:p.bundle,cached:!1};t.sharedExternalsRepo.scopeType(p.shareScope)==="strict"&&(P.requiredVersion=D,S="share");let ne=R.versions.find(L=>L.action==="share"),oe=!ne||t.versionCheck.isCompatible(ne.tag,P.requiredVersion);if(S==="skip"&&!oe&&P.strictVersion){S="scope";let L=`[${p.shareScope??de}][${u}] ${p.packageName}@${p.version} Is not compatible with existing ${p.packageName}@${ne.tag} requiredRange '${ne.remotes[0]?.requiredVersion}'`;if(r.strict.strictExternalCompatibility)throw r.log.error(8,L),new H(`Could not process remote '${u}'`);r.log.warn(8,L)}let x=R.versions.find(L=>L.tag===D);if(x){if(P.strictVersion&&x.remotes[0].requiredVersion!==P.requiredVersion){let L=`[${u}][${p.packageName}@${p.version}] Required version '${P.requiredVersion}' does not match existing '${x.remotes[0].requiredVersion}'`;if(r.strict.strictExternalCompatibility)throw r.log.error(8,L),new H(`Could not process remote '${u}'`);r.log.warn(8,L)}x.remotes.push(P)}else ne||(S="share"),P.cached=S!=="skip",R.versions.push({tag:D,action:S,host:!1,remotes:[P]});return t.sharedExternalsRepo.addOrUpdate(p.packageName,{dirty:R.dirty,versions:R.versions.sort((L,q)=>t.versionCheck.compare(q.tag,L.tag))},p.shareScope),{action:S,sharedVersion:ne}}function v(u,p){t.scopedExternalsRepo.addExternal(u,p.packageName,{tag:p.version??t.versionCheck.smallestVersion(p.requiredVersion),file:p.outFileName,bundle:p.bundle})}}var va=({config:r,adapters:t})=>({getRemoteEntry:ei(r,t),updateCache:ti(r,t),convertToImportMap:Qn(r,t),commitChanges:Vt(r,t)}),ri=({config:r,adapters:t})=>({flow:va({config:r,adapters:t}),adapters:t,config:r}),oi=({flow:r,adapters:t,config:i})=>{let s=async d=>r.updateCache(d).then(r.convertToImportMap).then(r.commitChanges),c=(d,b)=>r.getRemoteEntry(d,b).then(v=>v.map(s).orElse(Promise.resolve())).then(()=>({config:i,adapters:t,initRemoteEntry:c}));return c};var ni=(r,t={})=>{let{adapters:i,config:s}=Gn(Zn(t)),c=v=>s.log.debug(0,v,{remotes:{...i.remoteInfoRepo.getAll()},"shared-externals":i.sharedExternalsRepo.getScopes({includeGlobal:!0}).reduce((u,p)=>({...u,[p]:i.sharedExternalsRepo.getFromScope(p)}),{}),"scoped-externals":i.scopedExternalsRepo.getAll()}),d=Oo(Lo({adapters:i,config:s})),b=oi(ri({config:s,adapters:i}));return d(r).then(({loadRemoteModule:v})=>{let u={config:s,adapters:i,loadRemoteModule:v,as:()=>({loadRemoteModule:v,load:v}),load:v},p=async(R,S)=>b(R,S).catch(D=>(c(`[dynamic-init][${S??R}] STATE DUMP`),s.strict.strictRemoteEntry?Promise.reject(D):(console.warn("Failed to initialize remote entry, continuing anyway."),Promise.resolve()))).then(()=>({...u,initRemoteEntry:p}));return{...u,initRemoteEntry:p}}).catch(v=>(c("[init] STATE DUMP"),Promise.reject(v)))};var ii={debug:(r,t,i)=>i?console.log(`[DEBUG][${r}]: ${t}`,i):console.log(`[DEBUG][${r}]: ${t}`),error:(r,t,i)=>i?console.error(`[NF][${r}]: ${t}`,i):console.error(`[NF][${r}]: ${t}`),warn:(r,t,i)=>i?console.warn(`[NF][${r}]: ${t}`,i):console.warn(`[NF][${r}]: ${t}`)};var si=(r={shimMode:!1})=>({loadModuleFn:t=>importShim(t),setImportMapFn:Jt(r.shimMode?"importmap-shim":"importmap"),reloadBrowserFn:()=>{window.location.reload()}});(async()=>{let r,t=document.querySelector('meta[name="mfe-feed"]')?.getAttribute("content");t&&(r=t);let i=document.getElementById("mfe-manifest");if(!r&&i?.textContent&&(r=JSON.parse(i.textContent)),!r){console.error(`Please provide a manifest in the HTML file:
12
+ `,E+=`${ge}:${fe==="global"?`importShim._i.get(impt${F})||impt${F++}`:`impt${F++}`},`}$+=`${cr}i=await WebAssembly.instantiate(importShim._s[${O}],{${E}});importShim._i.set($_ns,i);`,E="";for(let{name:o,kind:fe}of C)$+=`export let ${o}=i.exports['${o}'];`,fe==="global"&&($+=`try{${o}=${o}.value}catch(_){${o}=undefined}`),E+=`${o},`;$+=`if(h)h.accept(m=>({${E}}=m))`}else if(I==="json")$=`${cr}j=JSON.parse(${JSON.stringify($)});export{j as default};if(h)h.accept(m=>j=m.default)`;else if(I==="css")$=`${cr}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify($.replace(Ri,(C,_="",O,F)=>`url(${_}${jr(O||F,y)}${_})`))});if(h){h.data.s=s;h.accept(()=>{})}export default s`;else if(I==="ts"){rt||await oo();let C=rt($,y);$=C===void 0?$:C}return{url:y,source:$,type:I}},lr=(n,f,h,g)=>{if(g&&ft[n]){let $=0;for(;ft[n+"#"+ ++$];);n+="#"+$}let y=ft[n];return y||(ft[n]=y={u:n,r:g?n:void 0,f:void 0,S:g,L:void 0,a:void 0,d:void 0,b:void 0,s:void 0,n:!1,N:!1,t:null,m:null},y.f=(async()=>{y.S===void 0&&({url:y.r,source:y.S,type:y.t}=await(ur[n]||io(n,f,h)),!y.n&&y.t!=="js"&&!P&&(y.t==="css"&&!et||y.t==="json"&&!Qe||y.t==="wasm"&&!It&&!at||y.t==="ts")&&(y.n=!0));try{y.a=di(y.S,y.u)}catch($){it($),y.a=[[],[],!1]}return y})(),y)},vi=n=>Error(`${n} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${n}"] }<\/script>`),so=(n,f)=>{n.L||(n.L=n.f.then(()=>{let h=f;n.d=n.a[0].map(({n:g,d:y,t:$,a:I,se:C})=>{let _=$>=4,O=_&&$<6;if(_){if(!P&&(O?!Ge:!Qt))throw vi(O?"wasm-module-sources":"import-defer");(!O||!at)&&(n.n=!0)}let F;if(I>0&&!P&&Ve){let fe=n.S.slice(I,C-1);fe.includes("json")?Qe?F="":n.n=!0:fe.includes("css")&&(et?F="":n.n=!0)}if(y!==-1||!g)return;let E=lt(g,n.r||n.u);if((E.n||K)&&(n.n=!0),(y>=0||E.N)&&(n.N=!0),y!==-1)return;if(Oe&&Oe(E.r)&&!O)return{l:{b:E.r},s:!1};h.integrity&&(h={...h,integrity:void 0});let o={l:lr(E.r,h,n.r,F),s:O};return F===""&&(o.l.b=o.l.u),o.s||so(o.l,f),o}).filter(g=>g)}))},dt=()=>{for(let n of document.querySelectorAll(P?"link[rel=modulepreload-shim]":"link[rel=modulepreload]"))n.ep||Eo(n);for(let n of document.querySelectorAll("script[type]"))n.type==="importmap"+(P?"-shim":"")?n.ep||ho(n):n.type==="module"+(P?"-shim":"")&&(tt=!1,n.ep||go(n))},Nt=n=>{let f={};return n.integrity&&(f.integrity=n.integrity),n.referrerPolicy&&(f.referrerPolicy=n.referrerPolicy),n.fetchPriority&&(f.priority=n.fetchPriority),n.crossOrigin==="use-credentials"?f.credentials="include":n.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f},fr=Promise.resolve(),ao=!1,At=1,Ft=n=>{if(n===void 0){if(ao)return;ao=!0,At--}--At===0&&!ie&&(P||!Te)&&(document.removeEventListener("DOMContentLoaded",lo),document.dispatchEvent(new Event("DOMContentLoaded")))},pr=1,co=()=>{--pr===0&&!ie&&(P||!Te)&&(window.removeEventListener("load",fo),window.dispatchEvent(new Event("load")))},lo=async()=>{await Ue,Ft()},fo=async()=>{await Ue,Ft(),co()};c&&(document.addEventListener("DOMContentLoaded",lo),window.addEventListener("load",fo));let po=async()=>{await Ue,dt(),document.readyState==="complete"&&mr()},ht=1,mr=()=>{--ht===0&&(Ft(),!ie&&(P||!Te)&&(document.removeEventListener("readystatechange",po),document.dispatchEvent(new Event("readystatechange"))))},mo=n=>n.nextSibling||n.parentNode&&mo(n.parentNode),uo=(n,f)=>n.ep||!f&&(!n.src&&!n.innerHTML||!mo(n))||n.getAttribute("noshim")!==null||!(n.ep=!0),ho=(n,f=ht>0)=>{if(!uo(n,f)){if(n.src){if(!P)return;Kr=!0}mt=mt.then(async()=>{Fe=Dr(n.src?await(await ro(n.src,Nt(n))).json():JSON.parse(n.innerHTML),n.src||we,Fe)}).catch(h=>{h instanceof SyntaxError&&(h=new Error(`Unable to parse import map ${h.message} in: ${n.src||n.innerHTML}`)),it(h)}),!pt&&tt&&mt.then(()=>pt=Fe),!tt&&!nr&&(nr=!0,!P&&Te&&!kt&&(Te=!1,c&&Zr())),tt=!1}},go=(n,f=ht>0)=>{if(uo(n,f))return;let h=n.getAttribute("async")===null&&ht>0,g=At>0,y=pr>0;y&&pr++,h&&ht++,g&&At++;let $,I=n.lang==="ts";I&&!n.src?$=Promise.resolve(rt||oo()).then(()=>{let C=rt(n.innerHTML,we);return C!==void 0&&(Mr(),ir=!1),Tt(n.src||we,we,Nt(n),C===void 0?n.innerHTML:C,!P&&C===void 0,h&&fr,"ts")}).catch(it):$=Tt(n.src||we,we,Nt(n),n.src?void 0:n.innerHTML,!P,h&&fr,I?"ts":void 0).catch(it),ie||$.then(()=>n.dispatchEvent(new Event("load"))),h&&!I&&(fr=$.then(mr)),g&&$.then(Ft),y&&$.then(co)},ur={},Eo=n=>{n.ep=!0,Ue.then(()=>{Te&&!P||ur[n.href]||(ur[n.href]=io(n.href,Nt(n)))})}})();var H=class extends Error{constructor(t,i){super(t,i),this.name="NFError"}};function Y(r,t){return r=r.endsWith("/")?r.slice(0,-1):r,t=t.startsWith("/")?t.slice(1):t,`${r}/${t}`}function Ne(r){if(!r)return"";let t=r.split("/");return(t[t.length-1]===""||t[t.length-1].includes("."))&&t.pop(),t.length<1?"":`${t.join("/")}/`}function $o(r,t){return(u={})=>t.manifestProvider.provide(u).catch(p=>(r.log.error(1,"Could not fetch manifest.",p),Promise.reject(new H("Failed to fetch manifest")))).then(i).then(s).then(b).then(v);function i(u){if(!r.hostRemoteEntry)return u;let{name:p,url:R,cacheTag:S}=r.hostRemoteEntry,D=S?`${R}?cacheTag=${S}`:R;return{...u,[p]:D}}async function s(u){let p=Object.entries(u).map(([R,S])=>c(R,S));return Promise.all(p)}async function c(u,p){let R=!1,S=!1;if(t.remoteInfoRepo.tryGet(u).ifPresent(D=>{r.profile.overrideCachedRemotes!=="never"&&(p!==Y(D.scopeUrl,"remoteEntry.json")||r.profile.overrideCachedRemotesIfURLMatches)?(r.log.debug(1,`Overriding existing remote '${u}' with '${p}'.`),R=!0):(r.log.debug(1,`Found remote '${u}' in storage, omitting fetch.`),S=!0)}),S)return!1;try{let D=await t.remoteEntryProvider.provide(p);return r.log.debug(1,`Fetched '${D.name}' from '${D.url}', exposing: ${JSON.stringify(D.exposes)}`),d(D,u,R)}catch(D){return r.strict.strictRemoteEntry?(r.log.error(1,`Could not fetch remote '${u}'.`,D),Promise.reject(new H(`Could not fetch remote '${u}'`))):(r.log.warn(1,`Could not fetch remote '${u}'. skipping init.`,D),Promise.resolve(!1))}}function d(u,p,R){if(R&&(u.override=R),r.hostRemoteEntry&&p===r.hostRemoteEntry.name&&(u.host=!0,u.name=r.hostRemoteEntry.name),u.name!==p){let S=`Fetched remote '${u.name}' does not match requested '${p}'.`;if(r.strict.strictRemoteEntry)throw new H(S);r.log.warn(1,`${S} Omitting expected name.`)}return u}function b(u){return u.filter(p=>p!==!1)}function v(u){return r.sse&&u.forEach(p=>{if(p.buildNotificationsEndpoint){t.sse.watchRemoteBuilds(Y(Ne(p.url),p.buildNotificationsEndpoint)),r.log.debug(1,`Registered SSE endpoint of remote '${p.name}' `);return}r.log.debug(1,`Remote ${p.name} has no defined 'buildNotificationsEndpoint'`)}),u}}function So(r,t){return u=>{try{return u.forEach(p=>{p?.override&&i(p),s(p),c(p),d(p)}),Promise.resolve(u)}catch(p){return Promise.reject(p)}};function i(u){t.remoteInfoRepo.remove(u.name),t.scopedExternalsRepo.remove(u.name),t.sharedExternalsRepo.removeFromAllScopes(u.name)}function s({name:u,url:p,exposes:R}){t.remoteInfoRepo.addOrUpdate(u,{scopeUrl:Ne(p),exposes:Object.values(R??[]).map(S=>({moduleName:S.key,file:S.outFileName}))})}function c(u){u.shared.forEach(p=>{if(!p.version||!t.versionCheck.isValidSemver(p.version)){let R=`[${u.name}][${p.packageName}] Version '${p.version}' is not a valid version.`;if(r.strict.strictExternalVersion)throw r.log.error(2,R),new H(`Could not process remote '${u.name}'`);r.log.warn(2,R)}p.singleton?b(u.name,p,u):v(u.name,p)})}function d(u){u.chunks&&(r.log.debug(2,`Adding chunks for remote "${u.name}", bundles: [${Object.keys(u.chunks).join(", ")}]`),Object.entries(u.chunks).forEach(([p,R])=>{t.sharedChunksRepo.addOrReplace(u.name,p,R)}))}function b(u,p,R){let S="skip",D=p.version??t.versionCheck.smallestVersion(p.requiredVersion),P={file:p.outFileName,name:u,bundle:p.bundle,strictVersion:p.strictVersion,cached:!1,requiredVersion:p.requiredVersion||D},ue=t.sharedExternalsRepo.scopeType(p.shareScope);ue==="strict"&&(S="share",P.requiredVersion=D);let ne=t.sharedExternalsRepo.tryGet(p.packageName,p.shareScope).orElse({dirty:!1,versions:[]}),oe=ne.versions.find(L=>L.tag===p.version),x=ne.dirty;if(oe){if(P.strictVersion&&oe.remotes[0].requiredVersion!==P.requiredVersion){let L=`[${u}][${p.packageName}@${p.version}] Required version-range '${P.requiredVersion}' does not match cached version-range '${oe.remotes[0].requiredVersion}'`;if(r.strict.strictExternalSameVersionCompatibility)throw r.log.error(2,L),new H(`Could not process remote '${R.name}'`);r.log.warn(2,L)}!oe.host&&R?.host?(oe.host=!0,oe.remotes.unshift(P)):oe.remotes.push(P)}else ue!=="strict"&&(x=!0),ne.versions.push({tag:D,action:S,host:!!R?.host,remotes:[P]});t.sharedExternalsRepo.addOrUpdate(p.packageName,{dirty:x,versions:ne.versions.sort((L,q)=>t.versionCheck.compare(q.tag,L.tag))},p.shareScope)}function v(u,p){t.scopedExternalsRepo.addExternal(u,p.packageName,{tag:p.version??t.versionCheck.smallestVersion(p.requiredVersion),file:p.outFileName,bundle:p.bundle})}}var de="__GLOBAL__",vo="strict";function wo(r,t){return()=>{for(let s of t.sharedExternalsRepo.getScopes()){let c=t.sharedExternalsRepo.getFromScope(s);try{Object.entries(c).filter(([d,b])=>b.dirty).forEach(([d,b])=>t.sharedExternalsRepo.addOrUpdate(d,i(d,b),s))}catch(d){return r.log.error(3,`[${s??de}] failed to determine shared externals.`,{sharedExternals:c,error:d}),Promise.reject(new H(`Could not determine shared externals in scope ${s}.`,d))}}return Promise.resolve()};function i(s,c){if(c.versions.length===1)return c.versions[0].action="share",c.dirty=!1,c;let d=c.versions.find(b=>b.host);if(!d&&r.profile.latestSharedExternal&&(d=c.versions[0]),!d){let b=Number.MAX_VALUE;c.versions.forEach(v=>{let u=c.versions.filter(p=>!p.remotes[0].cached&&p.remotes[0].strictVersion&&!t.versionCheck.isCompatible(v.tag,p.remotes[0].requiredVersion)).length;u<b&&(b=u,d=v)})}if(!d)throw new H(`[${s}] Could not determine shared version!`);return c.versions.forEach(b=>{if(t.versionCheck.isCompatible(d.tag,b.remotes[0].requiredVersion)){b.action="skip";return}if(r.strict.strictExternalCompatibility&&b.remotes[0].strictVersion)throw r.log.error(3,`[${b.remotes[0].name}][${s}@${b.tag}] Is not compatible with requiredRange '${d.remotes[0]?.requiredVersion}' from remote '${d.remotes[0].name}'.`),new H(`External ${s}@${b.tag} could not be shared.`);b.action=b.remotes[0].strictVersion?"scope":"skip"}),d.action="share",c.dirty=!1,c}}var Rt;(function(r){r.COMPLETED="federation-rebuild-complete",r.ERROR="federation-rebuild-error",r.CANCELLED="federation-rebuild-cancelled"})(Rt||(Rt={}));var Co="@nf-internal";function $t(r){r.startsWith("./")&&(r=r.slice(2));let t=r.replace(/.(m|c)?js$/,"");return Co+"/"+t}function Io(r,t){return()=>{let x={imports:{}},L={};try{return i(x,L),c(x,L),u(x,L),D(x,L),ne(x,L),Promise.resolve(x)}catch(q){return Promise.reject(q)}};function i(x,L){let q=t.scopedExternalsRepo.getAll();for(let[U,B]of Object.entries(q)){let K=t.remoteInfoRepo.tryGet(U).orThrow(()=>(r.log.error(4,`[scoped][${U}] Remote name not found in cache.`),new H("Could not create ImportMap.")));R(x,K.scopeUrl,s(B,K.scopeUrl)),Object.values(B).filter(ie=>!!ie.bundle).forEach(ie=>ue(L,U,ie.bundle))}return x}function s(x,L){let q={};for(let[U,B]of Object.entries(x))q[U]=Y(L,B.file);return q}function c(x,L){let q=t.sharedExternalsRepo.getScopes({includeGlobal:!1});for(let U of q)d(x,U,L);return x}function d(x,L,q){let U=t.sharedExternalsRepo.getFromScope(L);for(let[B,K]of Object.entries(U)){let ie,ve;for(let le of K.versions){if(le.action==="scope"){for(let Me of le.remotes){let We=oe(L,Me.name,B);R(x,We,{[B]:Y(We,Me.file)}),ue(q,Me.name,Me.bundle),Me.cached=!0}continue}let Ke=oe(L,le.remotes[0].name,B),Ve=Y(Ke,le.remotes[0].file);le.remotes[0].cached=!0,le.action==="share"&&ue(q,le.remotes[0].name,le.remotes[0].bundle),le.action==="skip"&&(ie||(ie=b(K,L,B)??"NOT_AVAILABLE"),ie!=="NOT_AVAILABLE"&&(ve||(ve=oe(L,ie.remotes[0].name,B)),Ve=Y(ve,ie.remotes[0].file),ie.remotes[0].cached=!0,le.remotes[0].cached=!1)),le.remotes.forEach(Me=>{let We=oe(L,Me.name,B);R(x,We,{[B]:Ve})})}t.sharedExternalsRepo.addOrUpdate(B,K,L)}}function b(x,L,q){let U=x.versions.filter(K=>K.action==="share"),B=`${L}.${q}`;if(U.length>1&&v(B),U.length<1){if(r.strict.strictImportMap)throw r.log.error(4,`[${L}][${q}] shareScope has no override version.`),new H("Could not create ImportMap.");r.log.debug(4,`[${L}][${q}] shareScope has no override version, scoping override versions.`)}return U[0]}function v(x){if(r.strict.strictImportMap)throw r.log.error(4,`[${x}] ShareScope external has multiple shared versions.`),new H("Could not create ImportMap.");r.log.warn(4,`ShareScope external ${x} has multiple shared versions.`)}function u(x,L){let q=t.sharedExternalsRepo.getFromScope();for(let[U,B]of Object.entries(q)){for(let K of B.versions){if(K.action==="skip")continue;if(K.action==="scope"){for(let ve of K.remotes){let le=oe(de,ve.name,U);R(x,le,{[U]:Y(le,ve.file)}),ve.cached=!0,ue(L,ve.name,ve.bundle)}continue}if(x.imports[U]){p(U);continue}let ie=oe(de,K.remotes[0].name,U);S(x,{[U]:Y(ie,K.remotes[0].file)}),ue(L,K.remotes[0].name,K.remotes[0].bundle),K.remotes[0].cached=!0}t.sharedExternalsRepo.addOrUpdate(U,B)}return x}function p(x){if(r.strict.strictImportMap)throw r.log.error(4,`[${x}] Shared external has multiple shared versions.`),new H("Could not create ImportMap.");r.log.warn(4,`Singleton external ${x} has multiple shared versions.`)}function R(x,L,q){x.scopes||(x.scopes={}),x.scopes[L]||(x.scopes[L]={}),x.scopes[L]=Object.assign(x.scopes[L],q)}function S(x,L){x.imports=Object.assign(x.imports,L)}function D(x,L){let q=t.remoteInfoRepo.getAll();for(let[U,B]of Object.entries(q))P(x,U,B),ue(L,U,"mapping-or-exposed")}function P(x,L,q){for(let U of q.exposes){let B=Y(L,U.moduleName),K=Y(q.scopeUrl,U.file);x.imports[B]=K}}function ue(x,L,q){return q&&(x[L]||(x[L]=new Set),x[L].add(q)),x}function ne(x,L){return Object.entries(L).forEach(([q,U])=>{let B=oe("CHUNKS",q),K=Array.from(U).reduce((ie,ve)=>(t.sharedChunksRepo.tryGet(q,ve).ifPresent(le=>{le.forEach(Ke=>{ie[$t(Ke)]=Y(B,Ke)})}),ie),{});Object.keys(K).length>0&&R(x,B,K)}),x}function oe(x,L,q){return t.remoteInfoRepo.tryGet(L).map(U=>U.scopeUrl).orThrow(()=>(q?r.log.error(4,`[${x}][${q}][${L}] Remote name not found in cache.`):r.log.error(4,`[${x}][${L}] Remote name not found in cache.`),new H("Could not create ImportMap.")))}}function Vt(r,t){return c=>Promise.resolve(c).then(i).then(s);function i(c){return t.browser.setImportMapFn(c),r.log.debug(5,"Added import map to browser.",c),c}function s(){t.remoteInfoRepo.commit(),t.scopedExternalsRepo.commit(),t.sharedExternalsRepo.commit(),t.sharedChunksRepo.commit()}}function ko(r,t){let i=(s,c)=>{try{if(!t.remoteInfoRepo.contains(s))throw new H(`Remote '${s}' is not initialized.`);let d=t.remoteInfoRepo.tryGetModule(s,c).orThrow(new H(`Exposed module '${c}' from remote '${s}' not found in storage.`));return r.log.debug(6,`Loading initialized module '${d}'`),t.browser.importModule(d)}catch(d){return r.log.error(6,`Failed to load module ${Y(s,c)}: `,{error:d}),Promise.reject(new H(`Failed to load module ${Y(s,c)}`))}};return()=>Promise.resolve(i)}var ss=({config:r,adapters:t})=>({getRemoteEntries:$o(r,t),processRemoteEntries:So(r,t),determineSharedExternals:wo(r,t),generateImportMap:Io(r,t),commitChanges:Vt(r,t),exposeModuleLoader:ko(r,t)}),Lo=({config:r,adapters:t})=>({flow:ss({config:r,adapters:t}),adapters:t,config:r}),Oo=({flow:r,adapters:t,config:i})=>s=>r.getRemoteEntries(s).then(r.processRemoteEntries).then(r.determineSharedExternals).then(r.generateImportMap).then(r.commitChanges).then(r.exposeModuleLoader).then(c=>({config:i,adapters:t,loadRemoteModule:c}));var To=r=>({setImportMapFn:r.setImportMapFn,importModule:r.loadModuleFn});var Ln=yt(Xo()),On=yt(Sn()),Tn=yt(Xe()),xn=yt(Cn()),Nn=yt(kn()),An=()=>({isValidSemver:function(r){return(0,Ln.default)(r)!==null},isCompatible:function(r,t){return(0,On.default)(r,t)},compare:function(r,t){return(0,Tn.default)(r,t,!0)},smallestVersion:function(r){return(0,Nn.default)(r)?(0,xn.default)(r)?.raw??"0.0.0":"0.0.0"}});var Fn=()=>{let r=i=>i.ok?i.json():Promise.reject(new H(`${i.status} - ${i.statusText}`)),t=i=>s=>{let c=s instanceof Error?s.message:String(s);throw new H(`Fetch of '${i}' returned ${c}`)};return{provide:async function(i){return typeof i!="string"?Promise.resolve(i):fetch(i).then(r).catch(t(i))}}};var Pn=()=>{let r=s=>s.ok?s.json():Promise.reject(new Error(`${s.status} - ${s.statusText}`)),t=s=>c=>(c.exposes||(c.exposes=[]),c.shared||(c.shared=[]),c.url||(c.url=s),c),i=s=>c=>{let d=c instanceof Error?c.message:String(c);throw new H(`Fetch of '${s}' returned ${d}`)};return{provide:async function(s){return fetch(s).then(r).then(t(s)).catch(i(s))}}};var ye=class r{constructor(t){this.item=t}item;static of(t){return new r(t)}static empty(){return r.of(void 0)}isPresent(){return typeof this.item<"u"&&this.item!==null}set(t){return r.of(t)}ifPresent(t){this.isPresent()&&t(this.item)}map(t){if(!this.isPresent())return r.empty();let i=t(this.item);return i instanceof r?i:r.of(i)}orElse(t){return this.isPresent()?this.item:t}orThrow(t){if(this.isPresent())return this.item;throw typeof t=="function"?t():typeof t=="string"?new Error(t):t}get(){return this.item}};var Mn=r=>{let t=r.storage("remotes",{});r.clearStorage&&t.clear();let i=t.get()??{};return{contains:function(s){return!!i[s]},remove:function(s){return delete i[s],this},addOrUpdate:function(s,c){return i[s]=c,this},tryGet:function(s){return ye.of(i[s])},tryGetModule:function(s,c){return ye.of(i[s]?.exposes.find(d=>d.moduleName===c)).map(d=>Y(i[s].scopeUrl,d.file))},getAll:function(){return i},commit:function(){return t.set(i),this}}};var _n=r=>{let t=r.storage("scoped-externals",{});r.clearStorage&&t.clear();let i=t.get()??{};return{addExternal:function(s,c,d){return i[s]||(i[s]={}),i[s][c]=d,this},remove:function(s){return delete i[s],this},getAll:function(){return i},tryGet:function(s){return ye.of(i[s])},commit:function(){return t.set(i),this}}};var jn=r=>{let t=r.storage("shared-externals",{[de]:{}});r.clearStorage&&t.clear();let i=t.get();return{getFromScope:function(s){return{...i[s??de]}},addOrUpdate:function(s,c,d){return i[d??de]||(i[d??de]={}),i[d??de][s]=c,this},getScopes:function(s={includeGlobal:!0}){return s.includeGlobal?Object.keys(i):Object.keys(i).filter(c=>c!==de)},removeFromAllScopes:function(s){Object.values(i).forEach(c=>{let d=[];Object.entries(c).forEach(([b,v])=>{let u=[];if(v.versions.forEach((p,R)=>{let S=p.remotes.findIndex(D=>D.name===s);~S&&p.remotes.splice(S,1),p.remotes.length===0&&u.push(R)}),u.length>0){for(let p=u.length-1;p>=0;p--)v.versions.splice(u[p],1);v.dirty=!0,v.versions.length===0&&d.push(b)}}),d.forEach(b=>delete c[b])})},scopeType:function(s){switch(s){case de:case null:case void 0:return"global";case vo:return"strict";default:return"shareScope"}},tryGet:function(s,c){return ye.of(i[c??de]?.[s])},commit:function(){return t.set(i),this}}};var Dn=r=>{let t=[];return{watchRemoteBuilds:function(i){let s=new EventSource(i);s.onmessage=function(c){JSON.parse(c.data).type===Rt.COMPLETED&&(t.forEach(b=>b.close()),r.log.debug(0,"[SSE] Rebuild completed, reloading..."),r.reloadBrowserFn())},s.onerror=function(c){r.log.error(0,"[SSE] Connection error:",c)},t.push(s)},closeAll:function(){t.forEach(i=>i.close()),t.length=0}}};var Yt=(r,t)=>{try{if(typeof structuredClone=="function")return structuredClone(t)}catch{}try{return JSON.parse(JSON.stringify(t))}catch{}throw new H(`Could not parse storage entry '${String(r)}'`)};var Vn=r=>{let t=r.storage("shared-chunks",{});r.clearStorage&&t.clear();let i=t.get()??{};return{addOrReplace:function(s,c,d){return i[s]||(i[s]={}),i[s][c]=d,this},tryGet:function(s,c){return ye.of(i[s]?.[c])},commit:function(){return t.set(i),this}}};var Gn=r=>({adapters:{versionCheck:An(),manifestProvider:Fn(),remoteEntryProvider:Pn(),remoteInfoRepo:Mn(r),scopedExternalsRepo:_n(r),sharedExternalsRepo:jn(r),sharedChunksRepo:Vn(r),browser:To(r),sse:Dn(r)},config:r});var Jt=r=>(t,i={})=>(i?.override&&document.head.querySelectorAll(`script[type="${r}"]`).forEach(s=>s.remove()),document.head.appendChild(Object.assign(document.createElement("script"),{type:r,innerHTML:JSON.stringify(t)})),Promise.resolve(t));var qn=()=>({loadModuleFn:r=>import(r),setImportMapFn:Jt("importmap"),reloadBrowserFn:()=>{window.location.reload()}});var Hn=r=>{let t=qn();return{setImportMapFn:r.setImportMapFn??t.setImportMapFn,loadModuleFn:r.loadModuleFn??t.loadModuleFn,reloadBrowserFn:r.reloadBrowserFn??t.reloadBrowserFn}};var Un=r=>r?.hostRemoteEntry?typeof r.hostRemoteEntry=="string"?{hostRemoteEntry:{name:"__NF-HOST__",url:r.hostRemoteEntry}}:{hostRemoteEntry:{name:"__NF-HOST__",...r.hostRemoteEntry}}:{hostRemoteEntry:!1};var Xn={debug:()=>{},error:()=>{},warn:()=>{}};var zt={debug:0,warn:1,error:2};var Wn=(r,t)=>Object.keys(zt).filter(s=>isNaN(Number(s))).reduce((s,c)=>({...s,[c]:(d,b,v)=>{zt[c]>=zt[t]&&r[c](d,b,v)}}),{level:t});var Bn=({logger:r,logLevel:t,sse:i})=>({log:Wn(r??Xn,t??"error"),sse:!!i});var Yn=r=>(t,i)=>{globalThis[r]||(globalThis[r]={});let s=globalThis[r];s[t]||(s[t]=i);let c={get(){return Yt(t,s[t])},set(d){return s[t]=Yt(t,d),c},clear(){return s[t]=Yt(t,i),this}};return c};var Jn=r=>({storage:r.storage?r.storage(r.storageNamespace??"__NATIVE_FEDERATION__"):Yn(r.storageNamespace??"__NATIVE_FEDERATION__"),clearStorage:r.clearStorage??!1});var zn={latestSharedExternal:!1,overrideCachedRemotes:"init-only",overrideCachedRemotesIfURLMatches:!1};var Kn=r=>({strict:typeof r.strict=="boolean"?{strictRemoteEntry:r.strict,strictExternalCompatibility:r.strict,strictExternalSameVersionCompatibility:r.strict,strictExternalVersion:r.strict,strictImportMap:r.strict}:{strictRemoteEntry:r.strict?.strictRemoteEntry??!1,strictExternalCompatibility:r.strict?.strictExternalCompatibility??!1,strictExternalSameVersionCompatibility:r.strict?.strictExternalSameVersionCompatibility??!1,strictExternalVersion:r.strict?.strictExternalVersion??!1,strictImportMap:r.strict?.strictImportMap??!1},profile:{...zn,...r.profile??{}}});var Zn=r=>({...Hn(r),...Un(r),...Bn(r),...Jn(r),...Kn(r)});function Qn({log:r},t){return({entry:b,actions:v})=>{let u={imports:{}};return i(b,v,u),c(b,u),r.debug(9,`[${b.name}] Processed actions:`,v),Promise.resolve(u)};function i(b,v,u){if(!b.shared)return;let p=Ne(b.url),R=new Set(["mapping-or-exposed"]);b.shared.forEach(S=>{if(!S.singleton){s(p,S.packageName,Y(p,S.outFileName),u),S?.bundle&&R.add(S?.bundle);return}if(!v[S.packageName]){r.warn(9,`[${b.name}] No action defined for shared external '${S.packageName}', skipping.`);return}if(v[S.packageName].action==="skip"){if(!S.shareScope)return;if(v[S.packageName].override){s(p,S.packageName,v[S.packageName].override,u);return}}if(S?.bundle&&R.add(S?.bundle),v[S.packageName].action==="scope"){s(p,S.packageName,Y(p,S.outFileName),u);return}if(S.shareScope){s(p,S.packageName,Y(p,S.outFileName),u);return}u.imports[S.packageName]=Y(p,S.outFileName)}),d(u,b.name,p,R)}function s(b,v,u,p){p.scopes||(p.scopes={}),p.scopes[b]||(p.scopes[b]={}),p.scopes[b][v]=u}function c(b,v){if(!b.exposes)return;let u=Ne(b.url);b.exposes.forEach(p=>{let R=Y(b.name,p.key),S=Y(u,p.outFileName);v.imports[R]=S})}function d(b,v,u,p){return Array.from(p).forEach(R=>{t.sharedChunksRepo.tryGet(v,R).ifPresent(S=>{S.forEach(D=>{s(u,$t(D),Y(u,D),b)})})}),b}}function ei(r,t){return async(c,d)=>{if(d&&i(c,d))return r.log.debug(7,`Found remote '${d}' in storage, omitting fetch.`),ye.empty();try{let b=await t.remoteEntryProvider.provide(c);if(r.log.debug(7,`[${b.name}] Fetched from '${b.url}', exposing: ${JSON.stringify(b.exposes)}`),d&&b.name!==d){let v=`Fetched remote '${b.name}' does not match requested '${d}'.`;if(r.strict.strictRemoteEntry)throw r.log.error(7,v),new H("Could not fetch remote entry");r.log.warn(7,v+" Omitting expected name.")}return t.remoteInfoRepo.contains(b.name)&&(b.override=!0,r.log.debug(7,`Overriding existing remote '${d}' with '${c}'.`)),ye.of(s(b))}catch(b){return r.log.error(7,`[${d??"unknown"}] Could not fetch remoteEntry from ${c}.`,b),Promise.reject(new H(`[${d??c}] Could not fetch remoteEntry.`))}};function i(c,d){return t.remoteInfoRepo.tryGet(d).map(b=>r.profile.overrideCachedRemotes!=="always"||!r.profile.overrideCachedRemotesIfURLMatches&&c===Y(b.scopeUrl,"remoteEntry.json")).orElse(!1)}function s(c){return r.sse&&(c.buildNotificationsEndpoint?(t.sse.watchRemoteBuilds(Y(Ne(c.url),c.buildNotificationsEndpoint)),r.log.debug(7,`Registered SSE endpoint of remote '${c.name}' `)):r.log.debug(7,`Remote ${c.name} has no defined 'buildNotificationsEndpoint'`)),c}}function ti(r,t){return u=>{try{u?.override&&i(u),s(u);let p=c(u);return d(u),Promise.resolve({entry:u,actions:p})}catch(p){return Promise.reject(p)}};function i(u){t.remoteInfoRepo.remove(u.name),t.scopedExternalsRepo.remove(u.name),t.sharedExternalsRepo.removeFromAllScopes(u.name)}function s({name:u,url:p,exposes:R}){t.remoteInfoRepo.addOrUpdate(u,{scopeUrl:Ne(p),exposes:Object.values(R??[]).map(S=>({moduleName:S.key,file:S.outFileName}))})}function c(u){let p={};return u.shared.forEach(R=>{if(!R.version||!t.versionCheck.isValidSemver(R.version)){let S=`[${u.name}][${R.packageName}] Version '${R.version}' is not a valid version.`;if(r.strict.strictExternalVersion)throw r.log.error(8,S),new H(`Could not process remote '${u.name}'`);r.log.warn(8,S)}if(R.singleton){let{action:S,sharedVersion:D}=b(u.name,R);p[R.packageName]={action:S},S==="skip"&&R.shareScope&&D?.remotes[0]?.file&&(p[R.packageName].override=t.remoteInfoRepo.tryGet(D.remotes[0].name).map(P=>Y(P.scopeUrl,D.remotes[0].file)).orThrow(()=>(r.log.error(8,`[${R.shareScope??de}][${u.name}][${R.packageName}@${R.version}][override] Remote name not found in cache.`),new H(`Could not find override url from remote ${D.remotes[0].name}`))))}else v(u.name,R)}),p}function d(u){u.chunks&&(r.log.debug(8,`Adding chunks for remote "${u.name}", bundles: [${Object.keys(u.chunks).join(", ")}]`),Object.entries(u.chunks).forEach(([p,R])=>{t.sharedChunksRepo.addOrReplace(u.name,p,R)}))}function b(u,p){let R=t.sharedExternalsRepo.tryGet(p.packageName,p.shareScope).orElse({dirty:!1,versions:[]}),S="skip",D=p.version??t.versionCheck.smallestVersion(p.requiredVersion),P={file:p.outFileName,strictVersion:p.strictVersion,requiredVersion:p.requiredVersion||D,name:u,bundle:p.bundle,cached:!1};t.sharedExternalsRepo.scopeType(p.shareScope)==="strict"&&(P.requiredVersion=D,S="share");let ne=R.versions.find(L=>L.action==="share"),oe=!ne||t.versionCheck.isCompatible(ne.tag,P.requiredVersion);if(S==="skip"&&!oe&&P.strictVersion){S="scope";let L=`[${p.shareScope??de}][${u}] ${p.packageName}@${p.version} Is not compatible with existing ${p.packageName}@${ne.tag} requiredRange '${ne.remotes[0]?.requiredVersion}'`;if(r.strict.strictExternalCompatibility)throw r.log.error(8,L),new H(`Could not process remote '${u}'`);r.log.warn(8,L)}let x=R.versions.find(L=>L.tag===D);if(x){if(P.strictVersion&&x.remotes[0].requiredVersion!==P.requiredVersion){let L=`[${u}][${p.packageName}@${p.version}] Required version '${P.requiredVersion}' does not match existing '${x.remotes[0].requiredVersion}'`;if(r.strict.strictExternalCompatibility)throw r.log.error(8,L),new H(`Could not process remote '${u}'`);r.log.warn(8,L)}x.remotes.push(P)}else ne||(S="share"),P.cached=S!=="skip",R.versions.push({tag:D,action:S,host:!1,remotes:[P]});return t.sharedExternalsRepo.addOrUpdate(p.packageName,{dirty:R.dirty,versions:R.versions.sort((L,q)=>t.versionCheck.compare(q.tag,L.tag))},p.shareScope),{action:S,sharedVersion:ne}}function v(u,p){t.scopedExternalsRepo.addExternal(u,p.packageName,{tag:p.version??t.versionCheck.smallestVersion(p.requiredVersion),file:p.outFileName,bundle:p.bundle})}}var va=({config:r,adapters:t})=>({getRemoteEntry:ei(r,t),updateCache:ti(r,t),convertToImportMap:Qn(r,t),commitChanges:Vt(r,t)}),ri=({config:r,adapters:t})=>({flow:va({config:r,adapters:t}),adapters:t,config:r}),oi=({flow:r,adapters:t,config:i})=>{let s=async d=>r.updateCache(d).then(r.convertToImportMap).then(r.commitChanges),c=(d,b)=>r.getRemoteEntry(d,b).then(v=>v.map(s).orElse(Promise.resolve())).then(()=>({config:i,adapters:t,initRemoteEntry:c}));return c};var ni=(r,t={})=>{let{adapters:i,config:s}=Gn(Zn(t)),c=v=>s.log.debug(0,v,{remotes:{...i.remoteInfoRepo.getAll()},"shared-externals":i.sharedExternalsRepo.getScopes({includeGlobal:!0}).reduce((u,p)=>({...u,[p]:i.sharedExternalsRepo.getFromScope(p)}),{}),"scoped-externals":i.scopedExternalsRepo.getAll()}),d=Oo(Lo({adapters:i,config:s})),b=oi(ri({config:s,adapters:i}));return d(r).then(({loadRemoteModule:v})=>{let u={config:s,adapters:i,loadRemoteModule:v,as:()=>({loadRemoteModule:v,load:v}),load:v},p=async(R,S)=>b(R,S).catch(D=>(c(`[dynamic-init][${S??R}] STATE DUMP`),s.strict.strictRemoteEntry?Promise.reject(D):(console.warn("Failed to initialize remote entry, continuing anyway."),Promise.resolve()))).then(()=>({...u,initRemoteEntry:p}));return{...u,initRemoteEntry:p}}).catch(v=>(c("[init] STATE DUMP"),Promise.reject(v)))};var ii={debug:(r,t,i)=>i?console.log(`[DEBUG][${r}]: ${t}`,i):console.log(`[DEBUG][${r}]: ${t}`),error:(r,t,i)=>i?console.error(`[NF][${r}]: ${t}`,i):console.error(`[NF][${r}]: ${t}`),warn:(r,t,i)=>i?console.warn(`[NF][${r}]: ${t}`,i):console.warn(`[NF][${r}]: ${t}`)};var si=(r={shimMode:!1})=>({loadModuleFn:t=>importShim(t),setImportMapFn:Jt(r.shimMode?"importmap-shim":"importmap"),reloadBrowserFn:()=>{window.location.reload()}});(async()=>{let r,t=document.querySelector('meta[name="mfe-feed"]')?.getAttribute("content");t&&(r=t);let i=document.getElementById("mfe-manifest");if(!r&&i?.textContent&&(r=JSON.parse(i.textContent)),!r){console.error(`Please provide a manifest in the HTML file:
13
13
  <script type="application/json" id="mfe-manifest">
14
14
  {
15
15
  "remote1": "http://localhost:3000/remoteEntry.json",
16
16
  [...]
17
17
  }
18
- <\/script>`);return}await ni(r,{logger:ii,logLevel:"warn",...si({shimMode:!1})}).then(s=>{window.__NF_REGISTRY__!==void 0&&window.__NF_REGISTRY__.register("orch.init-ready",{...s}),window.loadRemoteModule=s.loadRemoteModule,window.dispatchEvent(new CustomEvent("mfe-loader-available",{detail:{...s}}))})})();
18
+ <\/script>`);return}await ni(r,{logger:ii,logLevel:"warn",sse:!0,...si({shimMode:!1})}).then(s=>{window.__NF_REGISTRY__!==void 0&&window.__NF_REGISTRY__.register("orch.init-ready",{...s}),window.loadRemoteModule=s.loadRemoteModule,window.dispatchEvent(new CustomEvent("mfe-loader-available",{detail:{...s}}))})})();