(function() { LWR.define("force/luvioRuntime",["exports"],function(e){const{create:t,freeze:r,keys:i}=Object,{hasOwnProperty:s}=Object.prototype,{isArray:n}=Array,{push:o,indexOf:a,slice:c}=Array.prototype,{stringify:u}=JSON;function h(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0===e)return;if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return u(e);let t,r;if(n(e)){for(r="[",t=0;t<e.length;t++)t&&(r+=","),r+=h(e[t])||"null";return r+"]"}if(null===e)return"null";const s=i(e).sort();for(r="",t=0;t<s.length;t++){const i=s[t],n=h(e[i]);n&&(r&&(r+=","),r+=u(i)+":"+n)}return"{"+r+"}"}function d(e){return y(e)?e.then(e=>e):{then:(t,r)=>{if(t)try{return d(t(e))}catch(e){return l(e)}return d(e)}}}function l(e){return y(e)?e.then(e=>e):{then:(t,r)=>{if(r)try{return d(r(e))}catch(e){return l(e)}return l(e)}}}function y(e){return e instanceof Promise||"object"==typeof e&&null!==e&&s.call(e,"then")&&"function"==typeof e.then}function m(e){return e instanceof Error?e:new Error(`${e}`)}class p extends Error{}class b{read(e){const{l1Cache:t,readFromL1:r}=e;return d(r(t))}write(e){const{l1Cache:t,writeToL1:r}=e;return r(t),d(void 0)}}class f{constructor(){this.data={}}clear(){this.data={}}delete(e,t){delete this.data[e]}get(e,t){return this.data[e]}set(e,t,r){this.data[e]=t}length(){return this.keys().length}keys(){return new g(Object.keys(this.data))}}class w{constructor(){this.data={}}clear(){this.data={}}delete(e,t){delete this.data[e]}get(e,t){return this.data[e]}set(e,t,r){this.data[e]=t}setPartial(e,t,r){const i=this.get(e);if(void 0===i)throw new Error(`Metadata for key "${e}" not found`);this.data[e]={...i,...t}}expire(e,t){const{expirationTime:r=Date.now()}=t||{};this.setPartial(e,{expirationTime:r})}}class g{constructor(e){this.data={},this.lengthInternal=0,e&&e.forEach(e=>{this.add(e)})}add(e){this.data[e]=!0,this.lengthInternal++}contains(e){return!0===this.data[e]}elements(){return Object.keys(this.data)}get length(){return this.lengthInternal}overlaps(e){const t=e.elements();for(let e=0;e<t.length;++e)if(this.contains(t[e]))return!0;return!1}difference(e){const t=new g;return this.elements().forEach(r=>{e.contains(r)||t.add(r)}),t}isSubsetOf(e){return 0===this.difference(e).length}equals(e){return this.length===e.length&&this.elements().every(t=>e.contains(t))}}class R{constructor(e){this.baseStore=e,this.keysRead=new g,this.missingKeysRead=new g,this.keysUpdated=new g}delete(e,t){this.keysUpdated.add(e),this.baseStore.delete(e,t)}get(e,t){this.keysRead.add(e);const r=this.baseStore.get(e,t);return void 0===r&&this.missingKeysRead.add(e),r}set(e,t,r){this.keysUpdated.add(e),this.baseStore.set(e,t,r)}length(){return this.baseStore.length()}keys(){return this.baseStore.keys()}}class k{constructor(e,t,r=Date.now()){this.baseStore=e,this.metadataRepository=t,this.now=r}delete(e,t){this.baseStore.delete(e,t)}get(e,t){const r=this.metadataRepository.get(e);if(!(r&&r.expirationTime<=this.now))return this.baseStore.get(e,t)}set(e,t,r){this.baseStore.set(e,t,r)}length(){return this.keys().length}keys(){return new g(this.baseStore.keys().elements().filter(e=>void 0!==this.get(e)))}}function v(e){const{data:t,errors:r}=e,i=void 0!==t&&0===r.length,s=r.length>0&&!(r[0]instanceof p);return i||s}class C{constructor(e){this.runtime=e,this.policyName="cache-then-network"}run(e){const{readFromCache:t,readFromNetwork:r,writeToCache:i,buildResult:s}=e,n=Date.now();let o=new k(this.runtime.store,this.runtime.metadataRepository,n);const{readFromCache:a,readFromNetwork:c,writeToCache:u}=this.runtime.requestDeduplicationService.applyDedupe({readFromCache:e=>this.readWithValidation(()=>t(e)),readFromNetwork:r,writeToCache:(e,t)=>this.writeWithValidation(()=>i(t,e,this.runtime.metadataRepository,this.runtime.keySubscriptionService))});return a(o).then(e=>v(e)?e:c().then(e=>u(this.runtime.store,e).then(()=>e)).then(e=>{const t=s(e,this.runtime.store);return this.runtime.cachePolicyValidator.validateBuildResult(t),t}))}readWithValidation(e){const t=e();return this.runtime.cachePolicyValidator.validateReadResult(t),t}writeWithValidation(e){const t=e();return this.runtime.cachePolicyValidator.validateWriteResult(t),t}}class S{constructor(e){this.runtime=e,this.policyName="no-cache"}run(e){const{readFromNetwork:t,writeToCache:r,buildResult:i}=e;return t().then(e=>{const t=r(e,this.runtime.store,this.runtime.metadataRepository,this.runtime.keySubscriptionService);return this.runtime.cachePolicyValidator.validateWriteResult(t),t.then(t=>({writeResult:t,networkResult:e}))}).then(e=>{const t=i(e.networkResult,this.runtime.store);return this.runtime.cachePolicyValidator.validateBuildResult(t),t})}}class T{constructor(){this.nextId=1,this.subscriptions=[]}subscribe(e){const t=this.nextId++,{subscription:r,callback:i}=e;return this.subscriptions.push({subscriptionId:t,keys:r,callback:i}),()=>{this.subscriptions=this.subscriptions.filter(e=>e.subscriptionId!==t)}}publish(e,t){const r=this.subscriptions.slice();for(let t=0;t<r.length;++t){const{keys:i,callback:s}=r[t];e.overlaps(i)&&s()}return d(void 0)}}const P=Symbol("EventIdentifierWildcard");class x{constructor(){this.subscriptions={}}subscribe(e){const{subscription:t,callback:r}=e;let i=this.subscriptions[t.type];void 0===i&&(i=[],this.subscriptions[t.type]=i);const s={callback:r,subscription:t};return i.push(s),()=>{this.subscriptions[t.type]=i.filter(e=>e!==s)}}publish(e,t){const r=this.subscriptions[e.type];if(void 0===r)return d(void 0);const s=r.filter(t=>{const r=Object.keys(e.identifiers),s=t.subscription.identifiers;if(i(s).length!==r.length)return!1;for(let t=0;t<r.length;t++){const i=r[t],n=s[i],o=e.identifiers[i];if(n!==P&&n!==o)return!1}return!0}),n=[];return s.forEach(t=>{const r=t.callback(e);r instanceof Promise&&n.push(r)}),n.length>0?Promise.all(n).then(()=>{}):d(void 0)}}class N extends Error{}class F{constructor(){this.registry={}}register(e,t){this.registry[e.namespace]||(this.registry[e.namespace]={}),this.registry[e.namespace][e.typeName]=e}get(e,t,r){const i=this.registry[e];if(!i)throw new N(`namespace ${e} not found`);const s=i[t];if(!s)throw new N(`type ${t} not found in namespace ${e}`);return s}}class I{constructor(){this.outstandingNetworkRequests=new Map,this.outstandingReads=new Map}applyDedupe({readFromCache:e,readFromNetwork:t,writeToCache:r}){const i={expectedNetworkKeys:void 0};return{readFromCache:this.buildDedupedReadFromCache(e,i),readFromNetwork:this.buildDedupedReadFromNetwork(t,i),writeToCache:this.buildDedupedWriteToCache(r)}}buildDedupedReadFromCache(e,t){const r=i=>{const s=new R(i);return e(s).then(e=>{const n=s.missingKeysRead;if(v(e)||0===n.length)return e;t.expectedNetworkKeys||(t.expectedNetworkKeys=n);let o=new g(n.elements());const a=Array.from(this.outstandingNetworkRequests.entries()).reduce((e,[t,r])=>(t.overlaps(n)&&(e.push(r),o=o.difference(t)),e),[]);if(o.length>0)return e;const c=new Promise(e=>{this.outstandingReads.set(t.expectedNetworkKeys,e)});return Promise.any([c,...a]).then(()=>(this.outstandingReads.delete(t.expectedNetworkKeys),r(i))).catch(()=>(this.outstandingReads.delete(t.expectedNetworkKeys),r(i)))})};return r}buildDedupedReadFromNetwork(e,t){return()=>{if(void 0===t.expectedNetworkKeys||0===t.expectedNetworkKeys.length)return e();const r=()=>this.outstandingNetworkRequests.delete(t.expectedNetworkKeys),i=e().then(e=>(r(),e),e=>(r(),new Promise((t,r)=>{r(e)})));return this.outstandingNetworkRequests.set(t.expectedNetworkKeys,i),i}}buildDedupedWriteToCache(e){return(t,r)=>{const i=new R(t);return e(i,r).then(()=>{const e=i.keysUpdated;Array.from(this.outstandingReads.entries()).forEach(([t,r])=>{t.isSubsetOf(e)&&r()})})}}}class E{constructor(e,t){this.config=e,this.commandContext=t}}class O extends E{}function K(e,t,r,i,s,n){const o=new R(t);return r.write({l1Cache:o,writeToL1:t=>{n(e,t,i)}}).then(()=>s.publish(o.keysUpdated))}function L(e,t,r,i,s,n){if(void 0!==e.data){const o=r(e.data),a=t.buildKey(o);t.write(a,e.data,i,s,n)}}class D extends O{constructor(e,t,r){super(e,t),this.commandContext=t,this.internalRuntime=r,this.runtime=r,this.initialize()}initialize(){}selectCachePolicy(){const e=this.commandContext.cachePolicy||this.runtime.defaultCachePolicyName,t=this.runtime.cachePolicies.find(t=>t.policyName===e);if(void 0===t)throw new Error(`Could not find cache policy "${e}". Did you configure it in your Runtime?`);return t}execute(){return this.selectCachePolicy().run({readFromCache:e=>this.readFromCacheInclusionPolicy(e),readFromNetwork:()=>this.fetch(),writeToCache:(e,t,r,i)=>this.writeToCacheInclusionPolicy(e,t,r,i),buildResult:(e,t)=>this.buildResult(e,t)})}readFromCacheInclusionPolicy(e){return this.runtime.cacheInclusionPolicy.read({l1Cache:e,readFromL1:e=>this.readFromL1(e)}).then(e=>({...e,subscribe:this.buildSubscribe(e)}))}writeToCacheInclusionPolicy(e,t,r,i){return K(e,t,this.runtime.cacheInclusionPolicy,r,i,(e,t,r)=>this.writeToL1(e,t,r))}buildResult(e,t){return e.errors.length>0?d({...e,subscribe:e=>()=>{}}):this.readFromCacheInclusionPolicy(t)}buildSubscribe(e){return function(e,t,r,i,s,n){return o=>{let a=e,c=()=>{};const u=()=>{const e=new R(t);return r.read({l1Cache:e,readFromL1:s}).then(t=>{const{data:r}=t,{data:s}=a;void 0!==r&&(void 0!==a&&void 0!==s&&n(s,r)||(o(t),a=t),c(),c=i.subscribe({subscription:e.keysRead,callback:u}))})};return u(),()=>{c()}}}(e,this.internalRuntime.store,this.runtime.cacheInclusionPolicy,this.runtime.keySubscriptionService,e=>this.readFromL1(e),(e,t)=>this.areResultsEqual(e,t))}}const j=e=>{const t=new F;return e.forEach(e=>t.register(e)),t};e.ArrayIsArray=n,e.ArrayPrototypeIndexOf=a,e.ArrayPrototypePush=o,e.ArrayPrototypeSlice=c,e.BaseCommand=E,e.BaseSubscribableCommand=O,e.CachePolicyCommand=D,e.CacheThenNetworkPolicy=C,e.CachingCommand=class extends O{constructor(e,t,r){super(e,t),this.commandContext=t,this.runtime=r}execute(){const e=new R(this.runtime.store);return d({...this.read(e),subscribe:this.buildSubscribe()})}buildSubscribe(){return e=>{let t,r=()=>{};const i=()=>{const s=new R(this.runtime.store),n=this.read(s);void 0!==n.data&&(void 0!==t&&void 0!==t.data&&this.equals(t.data,n.data)||(e(n),t=n),r(),r=this.runtime.keySubscriptionService.subscribe({subscription:s.keysRead,callback:()=>i()}))};return i(),()=>{r()}}}},e.DataNotFoundError=p,e.DefaultEventSubscriptionService=x,e.DefaultKeySubscriptionService=T,e.DefaultTypeRegistry=F,e.DurableCacheInclusionPolicy=class{read(e){const{l1Cache:t,readFromL1:r}=e,i=new R(t),s=r(i),{data:n,errors:o}=s,a=void 0!==n&&0===o.length,c=o.length>0&&!(o[0]instanceof p);return a||c?d(s):this.revive(i.keysRead,t).then(e=>i.keysRead.difference(e).length>0?d(s):this.read({l1Cache:t,readFromL1:r}))}write(e){const{l1Cache:t,writeToL1:r}=e,i=new R(new f);r(i);const s=new R(t);i.keysUpdated.elements().forEach(e=>s.get(e));const n=s.missingKeysRead;return(n.length>0?this.revive(n,t).then(()=>{}):d(void 0)).then(()=>{const e=new R(t);return r(e),this.syncToL2Cache(e.keysUpdated,t)})}},e.EventIdentifierWildcard=P,e.InMemoryCacheInclusionPolicy=b,e.InMemoryMetadataRepository=w,e.InMemoryStore=f,e.JSONStringify=u,e.KeySet=g,e.MutationTypeRegistryCommand=class extends E{constructor(e,t,r){super(e,t),this.commandContext=t,this.internalRuntime=r,this.runtime=r}readFromL1(e,t){try{const r=this.returnType,i=this.buildKeyConfigFromInstance(t),s=r.buildKey(i),n=r.read(s,e,this.runtime.typeRegistry),o=[];return void 0===n&&o.push(new p),{data:n,errors:o}}catch(e){return{data:void 0,errors:[m(e)]}}}writeToL1(e,t,r){L(e,this.returnType,e=>this.buildKeyConfigFromInstance(e),t,this.runtime.typeRegistry,r)}readFromCacheInclusionPolicy(e,t){return this.runtime.cacheInclusionPolicy.read({l1Cache:e,readFromL1:e=>this.readFromL1(e,t)})}writeToCacheInclusionPolicy(e,t,r,i){return K(e,t,this.runtime.cacheInclusionPolicy,r,i,(e,t,r)=>this.writeToL1(e,t,r))}get returnType(){return this.runtime.typeRegistry.get(this.returnTypeNamespace,this.returnTypeName)}areResultsEqual(e,t){return this.returnType.equals(e,t,this.runtime.typeRegistry)}execute(){return this.fetch().then(e=>(this.writeToCacheInclusionPolicy(e,this.internalRuntime.store,this.runtime.metadataRepository,this.runtime.keySubscriptionService),e)).then(e=>this.buildResult(e,this.internalRuntime.store))}buildResult(e,t){return e.errors.length>0?d(e):this.readFromCacheInclusionPolicy(t,e.data)}},e.NetworkCommand=class extends E{constructor(e,t,r){super(e,t),this.commandContext=t,this.runtime=r}execute(){return this.fetch()}},e.NoCachePolicy=S,e.ObjectCreate=t,e.ObjectFreeze=r,e.ObjectKeys=i,e.ObjectPrototypeHasOwnProperty=s,e.OpaqueRepresentationType=class{constructor(e,t,r,i){this.namespace=e,this.typeName=t,this.ttl=r,this.buildKey=i}equals(e,t,r){return h(e)===h(t)}read(e,t,r){return t.get(e)}write(e,t,r,i,s){r.set(e,t);const n=Date.now();s.set(e,{namespace:this.namespace,typeName:this.typeName,ingestionTime:n,expirationTime:n+this.ttl})}},e.RecordableStore=R,e.RequestDeduplicationService=I,e.TTLFilteredStore=k,e.TypeNotFoundError=N,e.TypeRegistryCachePolicyCommand=class extends D{readFromL1(e){try{const t=this.returnType,r=t.buildKey(this.buildKeyConfig()),i=t.read(r,e,this.runtime.typeRegistry),s=[];return void 0===i&&s.push(new p),{data:i,errors:s}}catch(e){return{data:void 0,errors:[m(e)]}}}writeToL1(e,t,r){return L(e,this.returnType,e=>this.buildKeyConfigFromInstance(e),t,this.runtime.typeRegistry,r)}get returnType(){return this.runtime.typeRegistry.get(this.returnTypeNamespace,this.returnTypeName)}areResultsEqual(e,t){return this.returnType.equals(e,t,this.runtime.typeRegistry)}},e.buildDefaultRuntime=e=>{const t={metadataRepository:new w,store:new f,keySubscriptionService:new T,cachePolicyValidator:{validateReadResult(){},validateWriteResult(){},validateBuildResult(){}},requestDeduplicationService:new I};return{...t,cachePolicies:[new C(t),new S(t)],typeRegistry:j(e.types),cacheInclusionPolicy:new b,defaultCachePolicyName:"cache-then-network",eventSubscriptionService:new x}},e.buildLocalStateCommands=function(){let e=[];const t={data:void 0,errors:[]},r=r=>(e.push(r),r(t),()=>{e=e.filter(e=>e!==r)});return[{execute:()=>d({...t,subscribe:r})},{execute:r=>(t.data=r.newValue,e.forEach(e=>e(t)),d({...t}))}]},e.buildStoreBasedLocalStateCommands=function(e,t){let r=[];const i=i=>(r.push(i),i({data:e.get(t),errors:[]}),()=>{r=r.filter(e=>e!==i)});return[{execute:()=>d({data:e.get(t),errors:[],subscribe:i})},{execute(i){e.set(t,i.newValue);const s={data:i.newValue,errors:[]};return r.forEach(e=>e(s)),d(s)}}]},e.buildStoreSubscriptionBasedLocalStateCommands=function(e,t,r){const i=i=>(i({data:e.get(t),errors:[]}),r.subscribe({subscription:new g([t]),callback:()=>i({data:e.get(t),errors:[]})}));return[{execute:()=>d({data:e.get(t),errors:[],subscribe:i})},{execute:i=>(e.set(t,i.newValue),r.publish(new g([t])),d({data:i.newValue,errors:[]}))}]},e.convertFetchResponseToData=function(e){return e.then(e=>e.ok?e.json().then(e=>({data:e,errors:[]}),e=>({data:void 0,errors:[m(e)]})):{data:void 0,errors:[m(e.statusText)]}).catch(e=>({data:void 0,errors:[m(e)]}))},e.deepEquals=function e(t,r){if(void 0===t)return void 0===r;if(null===t)return null===r;if(Array.isArray(t)){if(!Array.isArray(r)||t.length!==r.length)return!1;for(let i=0;i<t.length;++i)if(!e(t[i],r[i]))return!1;return!0}if("object"==typeof t){if("object"!=typeof r)return!1;const i=Object.keys(t),s=Object.keys(r);if(i.length!==s.length)return!1;for(let s=0;s<i.length;++s){const n=i[s];if(!e(t[n],r[n]))return!1}return!0}return t===r},e.deserializeToInMemoryServices=function(e,t={}){if("1"!==e.version)throw new Error("unrecognized serialization version");const r={store:new f,"metadata-repository":new w},{ingestionTime:i}=t;return Object.entries(e.data).forEach(([e,t])=>r.store.set(e,t)),Object.entries(e.metadata).forEach(([e,t])=>{const s="number"==typeof i?{...t,ingestionTime:i,expirationTime:i+t.expirationTime-t.ingestionTime}:{...t};r["metadata-repository"].set(e,s)}),r},e.isSubscribable=function(e){return"subscribe"in e},e.rejectedPromiseLike=l,e.resolvedPromiseLike=d,e.serialize=function(e){return e.store.keys().elements().reduce((t,r)=>{t.data[r]=e.store.get(r);const i=e["metadata-repository"].get(r);return i&&(t.metadata[r]=i),t},{version:"1",data:{},metadata:{}})},e.stableJSONStringify=h,e.toError=m,Object.defineProperty(e,"__esModule",{value:!0})});
})();(function() { LWR.define("force/luvioRegistry",["exports"],function(i){const t=[],e=[];function n(i){t.push(i),e.forEach(t=>i(t))}i.findRegistrations=function(i){return e.filter(t=>t.id===i)},i.forEachRegistration=n,i.register=function(i){e.push(i),t.forEach(t=>t(i))},i.withRegistration=function(i,t){n(e=>{e.id===i&&t(e)})},Object.defineProperty(i,"__esModule",{value:!0})});
})();(function() { LWR.define("force/luvioRuntimeWebruntime",["exports","lwc","force/luvioRegistry","force/luvioRuntime"],function(e,t,i,o){function r(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var a=r(o);const n="metadata-repository";const c=function(){const e=globalThis.CLWR?.serverData||globalThis.LWR?.serverData||{},t=e.initialData?.luvio||Object.values(e)[0]?.initialData?.luvio;return null!==t&&"object"==typeof t&&t.version&&t.data&&t.metadata?(delete globalThis.CLWR?.serverData?.initialData?.luvio,o.deserializeToInMemoryServices(t,{ingestionTime:Date.now()})):{[n]:new o.InMemoryMetadataRepository,store:new o.InMemoryStore}}(),l=c[n],u=c.store,s={metadataRepository:l,store:u,keySubscriptionService:new o.DefaultKeySubscriptionService,cachePolicyValidator:{validateReadResult(){},validateWriteResult(){},validateBuildResult(){}},requestDeduplicationService:new o.RequestDeduplicationService},d=[new o.CacheThenNetworkPolicy(s)],y={...s,cacheInclusionPolicy:new o.InMemoryCacheInclusionPolicy,cachePolicies:d,typeRegistry:new o.DefaultTypeRegistry,defaultCachePolicyName:"cache-then-network"};i.withRegistration("commandModule",e=>{Object.keys(e.runtimeDependencies).every(e=>e in y)&&e.setCommandRuntime(y)});const f=t.registerComponent(a,{tmpl:void 0,sel:"force-luvio-runtime-webruntime",apiVersion:62});e.default=f,e.serializeDataStore=function(){return o.serialize({[n]:l,store:u})},Object.defineProperty(e,"__esModule",{value:!0})});
})();