(function(n,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(n=typeof globalThis<"u"?globalThis:n||self,f(n.CardinoShared={}))})(this,function(n){"use strict";const d=Object.freeze(Object.defineProperty({__proto__:null,calculateGross:({amount:u,vat:t,currency:e})=>({amount:parseFloat((u*(1+t/100)).toFixed(2)),vat:t,currency:e}),format:({currency:u,amount:t},e="de-DE")=>(console.warn("money.format() is deprecated. Use L10n.formatPrice() instead."),new Intl.NumberFormat(e,{style:"currency",currency:u,maximumFractionDigits:0}).format(t))},Symbol.toStringTag,{value:"Module"}));class b{constructor(t,e="en"){this.fallbackLocale="en",this.locales=t,this.locale=e}t(t,e){var o,s;let r=(o=this.locales[this.locale])==null?void 0:o[t];return r===void 0&&this.locale!==this.fallbackLocale&&(r=(s=this.locales[this.fallbackLocale])==null?void 0:s[t]),typeof r!="string"?t:e?this.interpolate(r,e):r}rich(t,e,r){let o=this.t(t,r);if(o===t)return o;for(const[s,a]of Object.entries(e)){const i=new RegExp(`<${s}>([\\s\\S]*?)<\\/${s}>`,"g");o=o.replace(i,(h,l)=>a(l))}return o}has(t){var e;return typeof((e=this.locales[this.locale])==null?void 0:e[t])=="string"}setLocale(t){this.locale=t}getLocale(){return this.locale}getAvailableLocales(){return Object.keys(this.locales)}addTranslations(t,e){this.locales[t]||(this.locales[t]={}),this.locales[t]={...this.locales[t],...e}}interpolate(t,e){return t.replace(/\{\{(\w+)\}\}/g,(r,o)=>{var s;return((s=e[o])==null?void 0:s.toString())??`{{${o}}}`})}}class y{constructor(t="en"){this.locale=t}toDate(t){return typeof t=="string"?new Date(t):t}formatDate(t,e="medium"){return new Intl.DateTimeFormat(this.locale,{dateStyle:e}).format(this.toDate(t))}formatTime(t,e="short"){return new Intl.DateTimeFormat(this.locale,{timeStyle:e}).format(this.toDate(t))}formatDateTime(t,e="medium",r="short"){return new Intl.DateTimeFormat(this.locale,{dateStyle:e,timeStyle:r}).format(this.toDate(t))}formatNumber(t,e){return new Intl.NumberFormat(this.locale,e).format(t)}formatCurrency(t,e){return new Intl.NumberFormat(this.locale,{style:"currency",currency:e}).format(t)}formatPrice({amount:t,currency:e},r){return new Intl.NumberFormat(this.locale,{style:"currency",currency:e,maximumFractionDigits:0,...r}).format(t)}formatPercent(t,e=0){return new Intl.NumberFormat(this.locale,{style:"percent",minimumFractionDigits:e,maximumFractionDigits:e}).format(t)}formatRelative(t,e="long"){const r=Date.now(),s=this.toDate(t).getTime()-r,a=Math.round(s/1e3),i=Math.round(a/60),h=Math.round(i/60),l=Math.round(h/24),m=Math.round(l/7),g=Math.round(l/30),p=Math.round(l/365),c=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto",style:e});return Math.abs(a)<60?c.format(a,"second"):Math.abs(i)<60?c.format(i,"minute"):Math.abs(h)<24?c.format(h,"hour"):Math.abs(l)<7?c.format(l,"day"):Math.abs(m)<4?c.format(m,"week"):Math.abs(g)<12?c.format(g,"month"):c.format(p,"year")}setLocale(t){this.locale=t}getLocale(){return this.locale}}class M{log(t,e){this.debug&&console.debug("[QueryBroker]",t,e)}constructor(t=!1){this.queries=new Map,this.defaults=new Map,this.debug=t}initQuery(t,e={}){this.log("initQuery:start",{queryId:t,defaults:e}),!this.queries.has(t)&&(this.defaults.set(t,{...e}),this.queries.set(t,{...e}),this.log("initQuery:done",{queryId:t,next:this.queries.get(t)??{}}))}setQuery(t,e){const r=this.queries.get(t)??{},o=typeof e=="function"?e({...r}):e,s={...r,...o},a=Object.fromEntries(Object.entries(s).filter(([,i])=>i!=null&&i!==""));this.queries.set(t,a),this.log("setQuery",{queryId:t,inputType:typeof e,existing:r,resolved:o,next:this.queries.get(t)??{}})}resetQuery(t){const e=this.defaults.get(t)??{};this.queries.set(t,{...e}),this.log("resetQuery",{queryId:t,defaults:e,next:this.queries.get(t)??{}})}asCollection(t){const e=this.queries.get(t)??{},r=Object.entries(e).filter(([,o])=>o!=null&&o!=="").map(([o,s])=>({key:o,value:s}));return this.log("asCollection",{queryId:t,params:e,size:r.length}),r}}n.I18n=b,n.L10n=y,n.QueryBroker=M,n.money=d,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});