@bluealba/pae-ui-react-core 4.3.0-develop-102 → 4.3.0-develop-112
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/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +207 -207
- package/dist/index.systemjs.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.systemjs.js
CHANGED
|
@@ -20,7 +20,7 @@ Check the top-level render call using <`+I+">.")}return A}}function fd(b,A){{if(
|
|
|
20
20
|
<%s {...props} />
|
|
21
21
|
React keys must be passed directly to JSX without using spread:
|
|
22
22
|
let props = %s;
|
|
23
|
-
<%s key={someKey} {...props} />`,ls,gn,v0,gn),hd[gn+ls]=!0}}return b===r?f0(ve):d0(ve),ve}}function p0(b,A,I){return md(b,A,I,!0)}function h0(b,A,I){return md(b,A,I,!1)}var m0=h0,g0=p0;Kn.Fragment=r,Kn.jsx=m0,Kn.jsxs=g0}(),Kn}Es.exports=Ed();var c=Es.exports;const Rs=hr(null),Ps=({module:e,children:t})=>c.jsx(Rs.Provider,{value:e,children:t});Ps.displayName="PAEModule";const br=E("useModuleMetadata",()=>{const e=mr(Rs);if(!e)throw new Error("Module metadata was not setup yet !!");return e});function Lo(){if(!window[qn])throw new Error("PAE Global state not found.");return window[qn]}const As=E("getApplications",()=>{const{authUser:{applications:e}}=Lo();return e||[]}),Td=E("getOperations",e=>As().filter(t=>t.
|
|
23
|
+
<%s key={someKey} {...props} />`,ls,gn,v0,gn),hd[gn+ls]=!0}}return b===r?f0(ve):d0(ve),ve}}function p0(b,A,I){return md(b,A,I,!0)}function h0(b,A,I){return md(b,A,I,!1)}var m0=h0,g0=p0;Kn.Fragment=r,Kn.jsx=m0,Kn.jsxs=g0}(),Kn}Es.exports=Ed();var c=Es.exports;const Rs=hr(null),Ps=({module:e,children:t})=>c.jsx(Rs.Provider,{value:e,children:t});Ps.displayName="PAEModule";const br=E("useModuleMetadata",()=>{const e=mr(Rs);if(!e)throw new Error("Module metadata was not setup yet !!");return e});function Lo(){if(!window[qn])throw new Error("PAE Global state not found.");return window[qn]}const As=E("getApplications",()=>{const{authUser:{applications:e}}=Lo();return e||[]}),Td=E("getOperations",e=>As().filter(t=>t.name===e).flatMap(t=>t.operations)),Rd=E("useOperations",()=>{const{application:e}=br();return De(()=>Td(e),[e])}),Pd=E("hasAccess",e=>(...t)=>t.every(n=>e.some(r=>r.name===n))),wr=E("useAuth",()=>{const[{authUser:e}]=vr(),t=Rd();return{authUser:e,hasAccess:De(()=>Pd(t),[t])}}),_0=E("useHasNoSession",()=>{const{authUser:e}=wr();return!e||e.id==="anon"}),Os=E("useModuleConfig",()=>{var e;return((e=br().ui)==null?void 0:e.customProps)??{}}),Is=E("useModule",e=>{const t=yr();return De(()=>{const n=t.find(r=>r.name===e);if(!n)throw new Error(`Could not find the module [${e}] in the local catalog !`);return n},[t,e])}),Ad=E("useModuleConfigByName",e=>{var t,n;return((n=(t=Is(e))==null?void 0:t.ui)==null?void 0:n.customProps)??{}}),Od=e=>e.replace(/\/+/g,"/"),x0=E("useModuleCommonPaths",(e,t="only-base-path")=>{const{apiDocs:n,health:r,version:o,changelog:i}=(e==null?void 0:e.commonPaths)||{},s=(a,l="")=>{if(a===void 0&&!l)return;const u=a??l;if(t==="only-base-path")return u;const f=Od(`${e.baseUrl}/${u}`);return t==="with-module-base"?f:`${document.location.origin}${f}`};return{apiDocsPath:s(n,"/api-docs-json"),healthPath:s(r,"/health"),versionPath:s(o,"/version"),changelogPath:s(i,"/changelog")}});function Id(){window.open(yd,"_self")}const C0=E("navigateTo",e=>ws(e)),jd=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/,S0=E("isValidEmail",e=>jd.test(e)),E0=E("getInitials",(e,t=2)=>{if(!e)return"";const n=e.split(" ");return n.length===1?n.join("").slice(0,t):n.map(r=>r[0]).join("").slice(0,t)}),js=e=>e.type==="app"||e.type==="tool",kd=e=>e.modules.some(js)&&e.route&&e.route!=="/",ks=e=>{const{catalog:t}=Lo();return _r(t.filter(n=>n.application===e))},_r=(e=[])=>e.find(t=>{var n;return js(t)&&((n=t.ui)==null?void 0:n.route)!=="/"}),Ld=E("useApplications",()=>{const e=yr();return De(()=>As().map(n=>{var i,s,a;const r=Nd(e,n.name),o=_r(r);return{name:n.name,displayName:((s=(i=o==null?void 0:o.ui)==null?void 0:i.customProps)==null?void 0:s.overrideApplicationDisplayName)??n.displayName,modules:r,route:(a=o==null?void 0:o.ui)==null?void 0:a.route,roles:[],operations:n.operations}}),[e])}),Nd=(e,t)=>e.filter(n=>n.application===t)||[],Dd=E("useUIApplications",()=>{const e=Ld();return De(()=>e.filter(kd),[e])}),Md=E("useApplicationUIModule",e=>De(()=>e?ks(e.name):void 0,[e])),Ct=new Map,$d=e=>{try{const{catalog:t}=Lo(),n=t.find(r=>r.name===e);return n!=null&&n.version?`${e}@${n.version}`:e}catch{return e}},No=E("useApplicationJSModule",e=>{const[t,n]=W(null);return te(()=>{(async()=>{if(!e){n(null);return}try{const o=$d(e);if(Ct.has(o)){const s=Ct.get(o);n(s);return}const i=await System.import(e);Ct.set(o,i),n(i)}catch(o){console.error(`Error importing module ${e}: ${o.message}`),n(null)}})()},[e,n]),t}),Fd=e=>{e?(Array.from(Ct.keys()).filter(n=>n.startsWith(e)).forEach(n=>Ct.delete(n)),console.log(`[useApplicationJSModule] Cleared cache for module: ${e}`)):(Ct.clear(),console.log("[useApplicationJSModule] Cleared all module cache"))};typeof window<"u"&&(window.PAE={...window.PAE,clearModuleCache:Fd,getModuleCacheSize:()=>Ct.size,getModuleCacheKeys:()=>Array.from(Ct.keys())});const Bd=E("useApplicationIcon",e=>{const t=typeof e=="string"?ks(e):_r(e==null?void 0:e.modules),n=No(t==null?void 0:t.name);return n==null?void 0:n.icon}),Ud=E("useModuleMenu",e=>{const t=_r(e==null?void 0:e.modules),n=No(t==null?void 0:t.name),[r,o]=W(!1),[i,s]=W({}),a=async()=>(typeof(n==null?void 0:n.menu)=="function"?await n.menu():n==null?void 0:n.menu)||[],l=async()=>{if(!(n!=null&&n.menu))return[];o(!0);const h=Wd((e==null?void 0:e.operations)||[]),m=(await a()).map(g=>{const{operations:x,items:p,path:v}=g;if(x!=null&&x.length&&!h(x))return null;const y=(p||[]).filter(w=>{var C;return!((C=w==null?void 0:w.operations)!=null&&C.length)||h(w.operations)});return!y.length&&!v?null:{...g,items:y}}).filter(Boolean);return o(!1),m},u=async()=>{const h=await l();e&&s(m=>({...m,[e.name]:h}))};te(()=>{u()},[n==null?void 0:n.menu]);const f=De(()=>e?i[e.name]||[]:[],[i,e]);return{loading:r,menu:f}}),Wd=e=>t=>t.every(n=>e.some(r=>r.name===n)),T0=E("useApplicationMenu",e=>Ud(e));function ue(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Kt(e){return function t(n){return arguments.length===0||ue(n)?t:e.apply(this,arguments)}}function St(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return ue(n)?t:Kt(function(o){return e(n,o)});default:return ue(n)&&ue(r)?t:ue(n)?Kt(function(o){return e(o,r)}):ue(r)?Kt(function(o){return e(n,o)}):e(n,r)}}}function Do(e){return function t(n,r,o){switch(arguments.length){case 0:return t;case 1:return ue(n)?t:St(function(i,s){return e(n,i,s)});case 2:return ue(n)&&ue(r)?t:ue(n)?St(function(i,s){return e(i,r,s)}):ue(r)?St(function(i,s){return e(n,i,s)}):Kt(function(i){return e(n,r,i)});default:return ue(n)&&ue(r)&&ue(o)?t:ue(n)&&ue(r)?St(function(i,s){return e(i,s,o)}):ue(n)&&ue(o)?St(function(i,s){return e(i,r,s)}):ue(r)&&ue(o)?St(function(i,s){return e(n,i,s)}):ue(n)?Kt(function(i){return e(i,r,o)}):ue(r)?Kt(function(i){return e(n,i,o)}):ue(o)?Kt(function(i){return e(n,r,i)}):e(n,r,o)}}}function xr(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Ls(e){return Object.prototype.toString.call(e)==="[object Object]"}var Hd=Do(function(t,n,r){var o=t(n),i=t(r);return o>i?-1:o<i?1:0}),Vd=Do(function(t,n,r){var o={},i;n=n||{},r=r||{};for(i in n)xr(i,n)&&(o[i]=xr(i,r)?t(i,n[i],r[i]):n[i]);for(i in r)xr(i,r)&&!xr(i,o)&&(o[i]=r[i]);return o}),zd=Do(function e(t,n,r){return Vd(function(o,i,s){return Ls(i)&&Ls(s)?e(t,i,s):t(o,i,s)},n,r)}),Gd=St(function(t,n){return zd(function(r,o,i){return i},t,n)}),qd=St(function(t,n){return Array.prototype.slice.call(n,0).sort(function(r,o){for(var i=0,s=0;i===0&&s<t.length;)i=t[s](r,o),s+=1;return i})});const Ns=E("useCurrentApplication",()=>{const e=xd(),t=Dd();return De(()=>Kd(e,t),[e,t])}),Kd=(e,t)=>qd([Hd(Qd)],t).find(n=>n.route&&e.startsWith(n.route)),Qd=e=>{var t;return((t=e==null?void 0:e.route)==null?void 0:t.length)||-1},Yd=E("useCurrentApplicationName",()=>{var e;return(e=Ns())==null?void 0:e.name}),R0=E("useCurrentJSModule",()=>{const e=Ns(),t=Md(e);return No(t==null?void 0:t.name)}),Ds=E("useServiceBaseURL",(e,t)=>{const r=yr().find(o=>o.name===e);if(!r){if(t)return null;throw new Error(`Service with name [${e}] not available in the catalog`)}return r.baseUrl}),Ms=E("useServiceInvoker",(e,t)=>{const n=Ds(e,!!t)??t;return fe((r,o)=>{const s={Accept:"application/json",...(o==null?void 0:o.body)instanceof FormData?{}:{"Content-Type":"application/json"},...o==null?void 0:o.headers};return fetch(Zd(`${n}${r}`),{...o,headers:s})},[n])}),Zd=e=>e.replace(/\/+/g,"/"),Xd=["impersonate","impersonate-display-name","tenant"],Jd=E("useServiceWebSocketURL",(e,t)=>{const n=Ds(e,t);return De(()=>{if(!n)return null;try{const r=new URL(window.location.href),o=new URL(n,window.location.origin);return Xd.forEach(i=>{const s=r.searchParams.get(i);s&&o.searchParams.set(i,s)}),o.toString()}catch(r){return console.error("Error building WebSocket URL:",r),n}},[n])}),ef=(e,t)=>n=>({timestamp:new Date(new Date().toUTCString()).toISOString(),module:t.name,moduleVersion:t.version,application:t.application,user:e.username,...n}),tf=(e,t,n)=>async r=>{if(r.length===0)throw new Error("Invalid call to trackEvents with an empty array of events!");const o=await e("/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r.map(ef(t,n)))});if(!o.ok)throw new Error(`Error publishing habits event ${o.statusText}`)},nf="@bluealba/pae-habits-service",rf=E("useTrackEvents",()=>{const{authUser:e}=wr(),t=br(),n=Ms(nf);return fe(tf(n,e,t),[n,e,t])}),P0=E("useTrackEvent",()=>{const e=rf();return fe((t,n)=>e([{name:t,data:n}]),[e])}),of=E("useExtensionPoint",e=>{const t=br(),n=window[Cs],[r,o]=W(null);return te(()=>n.defineExtensionPoint(t,e,i=>{o(()=>i)}),[o]),r}),sf=E("useExtendExtensionPoint",(e,t,n)=>{te(()=>window[Cs].setExtensionPoint(e,t,n),[])}),af=E("usePlatformEventListener",(e,t)=>{te(()=>(window.addEventListener(e,t),()=>window.removeEventListener(e,t)),[e,t])}),lf=E("useDynamicStyleSheet",e=>{const{cssCustomizationLoadingDelay:t=1e3}=Os();te(()=>{if(!e)return;const n=document.createElement("style");return setTimeout(()=>{n.innerHTML=e,document.head.append(n)},t),()=>n&&n.remove()},[e])}),cf=e=>{var t;return(t=e.split(/[#?]/)[0].split(".").pop())==null?void 0:t.trim()},uf={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg"},df=e=>{const t=cf(e);return t?uf[t]:void 0},ff=(e,t)=>{const n=t??df(e);return n?`format(${n})`:""};function $s(e){const[t,n]=W(!1);return te(()=>{if(!(e!=null&&e.length))return;const r=document.createElement("style");r.setAttribute("data-generated-fonts","true");const o=e.flatMap(({fontFamily:s,variants:a})=>a.map(({path:l,fontWeight:u,format:f})=>`
|
|
24
24
|
@font-face {
|
|
25
25
|
font-family: "${s}";
|
|
26
26
|
src: url("${l}") ${ff(l,f)};
|
package/dist/index.umd.js
CHANGED
|
@@ -20,7 +20,7 @@ Check the top-level render call using <`+j+">.")}return O}}function Bd(b,O){{if(
|
|
|
20
20
|
<%s {...props} />
|
|
21
21
|
React keys must be passed directly to JSX without using spread:
|
|
22
22
|
let props = %s;
|
|
23
|
-
<%s key={someKey} {...props} />`,wi,dn,F0,dn),Wd[dn+wi]=!0}}return b===r?L0(pe):k0(pe),pe}}function N0(b,O,j){return Hd(b,O,j,!0)}function D0(b,O,j){return Hd(b,O,j,!1)}var M0=D0,$0=N0;Vn.Fragment=r,Vn.jsx=M0,Vn.jsxs=$0}(),Vn}Ni.exports=ef();var c=Ni.exports;const Mi=S.createContext(null),$i=({module:e,children:t})=>c.jsx(Mi.Provider,{value:e,children:t});$i.displayName="PAEModule";const zn=()=>{const e=S.useContext(Mi);if(!e)throw new Error("Module metadata was not setup yet !!");return e};function Io(){if(!window[Un])throw new Error("PAE Global state not found.");return window[Un]}const jo=()=>{const{authUser:{applications:e}}=Io();return e||[]},Fi=e=>jo().filter(t=>t.
|
|
23
|
+
<%s key={someKey} {...props} />`,wi,dn,F0,dn),Wd[dn+wi]=!0}}return b===r?L0(pe):k0(pe),pe}}function N0(b,O,j){return Hd(b,O,j,!0)}function D0(b,O,j){return Hd(b,O,j,!1)}var M0=D0,$0=N0;Vn.Fragment=r,Vn.jsx=M0,Vn.jsxs=$0}(),Vn}Ni.exports=ef();var c=Ni.exports;const Mi=S.createContext(null),$i=({module:e,children:t})=>c.jsx(Mi.Provider,{value:e,children:t});$i.displayName="PAEModule";const zn=()=>{const e=S.useContext(Mi);if(!e)throw new Error("Module metadata was not setup yet !!");return e};function Io(){if(!window[Un])throw new Error("PAE Global state not found.");return window[Un]}const jo=()=>{const{authUser:{applications:e}}=Io();return e||[]},Fi=e=>jo().filter(t=>t.name===e).flatMap(t=>t.operations),Bi=()=>{const{application:e}=zn();return S.useMemo(()=>Fi(e),[e])},Ui=e=>(...t)=>t.every(n=>e.some(r=>r.name===n)),Gn=()=>{const[{authUser:e}]=Wn(),t=Bi();return{authUser:e,hasAccess:S.useMemo(()=>Ui(t),[t])}},tf=()=>{const{authUser:e}=Gn();return!e||e.id==="anon"},ko=()=>{var e;return((e=zn().ui)==null?void 0:e.customProps)??{}},Lo=e=>{const t=Hn();return S.useMemo(()=>{const n=t.find(r=>r.name===e);if(!n)throw new Error(`Could not find the module [${e}] in the local catalog !`);return n},[t,e])},Wi=e=>{var t,n;return((n=(t=Lo(e))==null?void 0:t.ui)==null?void 0:n.customProps)??{}},nf=e=>e.replace(/\/+/g,"/"),rf=(e,t="only-base-path")=>{const{apiDocs:n,health:r,version:o,changelog:s}=(e==null?void 0:e.commonPaths)||{},i=(a,l="")=>{if(a===void 0&&!l)return;const u=a??l;if(t==="only-base-path")return u;const f=nf(`${e.baseUrl}/${u}`);return t==="with-module-base"?f:`${document.location.origin}${f}`};return{apiDocsPath:i(n,"/api-docs-json"),healthPath:i(r,"/health"),versionPath:i(o,"/version"),changelogPath:i(s,"/changelog")}};function of(){window.open(qd,"_self")}const sf=e=>he.navigateToUrl(e),af=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/,lf=e=>af.test(e),cf=(e,t=2)=>{if(!e)return"";const n=e.split(" ");return n.length===1?n.join("").slice(0,t):n.map(r=>r[0]).join("").slice(0,t)},Hi=e=>e.type==="app"||e.type==="tool",uf=e=>e.modules.some(Hi)&&e.route&&e.route!=="/",Vi=e=>{const{catalog:t}=Io();return mr(t.filter(n=>n.application===e))},mr=(e=[])=>e.find(t=>{var n;return Hi(t)&&((n=t.ui)==null?void 0:n.route)!=="/"}),zi=()=>{const e=Hn();return S.useMemo(()=>jo().map(n=>{var s,i,a;const r=df(e,n.name),o=mr(r);return{name:n.name,displayName:((i=(s=o==null?void 0:o.ui)==null?void 0:s.customProps)==null?void 0:i.overrideApplicationDisplayName)??n.displayName,modules:r,route:(a=o==null?void 0:o.ui)==null?void 0:a.route,roles:[],operations:n.operations}}),[e])},df=(e,t)=>e.filter(n=>n.application===t)||[],Gi=()=>{const e=zi();return S.useMemo(()=>e.filter(uf),[e])},qi=e=>S.useMemo(()=>e?Vi(e.name):void 0,[e]),gt=new Map,ff=e=>{try{const{catalog:t}=Io(),n=t.find(r=>r.name===e);return n!=null&&n.version?`${e}@${n.version}`:e}catch{return e}},gr=e=>{const[t,n]=S.useState(null);return S.useEffect(()=>{(async()=>{if(!e){n(null);return}try{const o=ff(e);if(gt.has(o)){const i=gt.get(o);n(i);return}const s=await System.import(e);gt.set(o,s),n(s)}catch(o){console.error(`Error importing module ${e}: ${o.message}`),n(null)}})()},[e,n]),t},pf=e=>{e?(Array.from(gt.keys()).filter(n=>n.startsWith(e)).forEach(n=>gt.delete(n)),console.log(`[useApplicationJSModule] Cleared cache for module: ${e}`)):(gt.clear(),console.log("[useApplicationJSModule] Cleared all module cache"))};typeof window<"u"&&(window.PAE={...window.PAE,clearModuleCache:pf,getModuleCacheSize:()=>gt.size,getModuleCacheKeys:()=>Array.from(gt.keys())});const Ki=e=>{const t=typeof e=="string"?Vi(e):mr(e==null?void 0:e.modules),n=gr(t==null?void 0:t.name);return n==null?void 0:n.icon},Qi=e=>{const t=mr(e==null?void 0:e.modules),n=gr(t==null?void 0:t.name),[r,o]=S.useState(!1),[s,i]=S.useState({}),a=async()=>(typeof(n==null?void 0:n.menu)=="function"?await n.menu():n==null?void 0:n.menu)||[],l=async()=>{if(!(n!=null&&n.menu))return[];o(!0);const h=hf((e==null?void 0:e.operations)||[]),m=(await a()).map(g=>{const{operations:x,items:p,path:v}=g;if(x!=null&&x.length&&!h(x))return null;const y=(p||[]).filter(w=>{var C;return!((C=w==null?void 0:w.operations)!=null&&C.length)||h(w.operations)});return!y.length&&!v?null:{...g,items:y}}).filter(Boolean);return o(!1),m},u=async()=>{const h=await l();e&&i(m=>({...m,[e.name]:h}))};S.useEffect(()=>{u()},[n==null?void 0:n.menu]);const f=S.useMemo(()=>e?s[e.name]||[]:[],[s,e]);return{loading:r,menu:f}},hf=e=>t=>t.every(n=>e.some(r=>r.name===n)),mf=e=>Qi(e);function le(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Ht(e){return function t(n){return arguments.length===0||le(n)?t:e.apply(this,arguments)}}function vt(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return le(n)?t:Ht(function(o){return e(n,o)});default:return le(n)&&le(r)?t:le(n)?Ht(function(o){return e(o,r)}):le(r)?Ht(function(o){return e(n,o)}):e(n,r)}}}function No(e){return function t(n,r,o){switch(arguments.length){case 0:return t;case 1:return le(n)?t:vt(function(s,i){return e(n,s,i)});case 2:return le(n)&&le(r)?t:le(n)?vt(function(s,i){return e(s,r,i)}):le(r)?vt(function(s,i){return e(n,s,i)}):Ht(function(s){return e(n,r,s)});default:return le(n)&&le(r)&&le(o)?t:le(n)&&le(r)?vt(function(s,i){return e(s,i,o)}):le(n)&&le(o)?vt(function(s,i){return e(s,r,i)}):le(r)&&le(o)?vt(function(s,i){return e(n,s,i)}):le(n)?Ht(function(s){return e(s,r,o)}):le(r)?Ht(function(s){return e(n,s,o)}):le(o)?Ht(function(s){return e(n,r,s)}):e(n,r,o)}}}function vr(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Yi(e){return Object.prototype.toString.call(e)==="[object Object]"}var gf=No(function(t,n,r){var o=t(n),s=t(r);return o>s?-1:o<s?1:0}),vf=No(function(t,n,r){var o={},s;n=n||{},r=r||{};for(s in n)vr(s,n)&&(o[s]=vr(s,r)?t(s,n[s],r[s]):n[s]);for(s in r)vr(s,r)&&!vr(s,o)&&(o[s]=r[s]);return o}),yf=No(function e(t,n,r){return vf(function(o,s,i){return Yi(s)&&Yi(i)?e(t,s,i):t(o,s,i)},n,r)}),bf=vt(function(t,n){return yf(function(r,o,s){return s},t,n)}),wf=vt(function(t,n){return Array.prototype.slice.call(n,0).sort(function(r,o){for(var s=0,i=0;s===0&&i<t.length;)s=t[i](r,o),i+=1;return s})});const Do=()=>{const e=Li(),t=Gi();return S.useMemo(()=>_f(e,t),[e,t])},_f=(e,t)=>wf([gf(xf)],t).find(n=>n.route&&e.startsWith(n.route)),xf=e=>{var t;return((t=e==null?void 0:e.route)==null?void 0:t.length)||-1},Zi=()=>{var e;return(e=Do())==null?void 0:e.name},Cf=()=>{const e=Do(),t=qi(e);return gr(t==null?void 0:t.name)},Mo=(e,t)=>{const r=Hn().find(o=>o.name===e);if(!r){if(t)return null;throw new Error(`Service with name [${e}] not available in the catalog`)}return r.baseUrl},$o=(e,t)=>{const n=Mo(e,!!t)??t;return S.useCallback((r,o)=>{const i={Accept:"application/json",...(o==null?void 0:o.body)instanceof FormData?{}:{"Content-Type":"application/json"},...o==null?void 0:o.headers};return fetch(Sf(`${n}${r}`),{...o,headers:i})},[n])},Sf=e=>e.replace(/\/+/g,"/"),Ef=["impersonate","impersonate-display-name","tenant"],Xi=(e,t)=>{const n=Mo(e,t);return S.useMemo(()=>{if(!n)return null;try{const r=new URL(window.location.href),o=new URL(n,window.location.origin);return Ef.forEach(s=>{const i=r.searchParams.get(s);i&&o.searchParams.set(s,i)}),o.toString()}catch(r){return console.error("Error building WebSocket URL:",r),n}},[n])},Tf=(e,t)=>n=>({timestamp:new Date(new Date().toUTCString()).toISOString(),module:t.name,moduleVersion:t.version,application:t.application,user:e.username,...n}),Pf=(e,t,n)=>async r=>{if(r.length===0)throw new Error("Invalid call to trackEvents with an empty array of events!");const o=await e("/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r.map(Tf(t,n)))});if(!o.ok)throw new Error(`Error publishing habits event ${o.statusText}`)},Af="@bluealba/pae-habits-service",Ji=()=>{const{authUser:e}=Gn(),t=zn(),n=$o(Af);return S.useCallback(Pf(n,e,t),[n,e,t])},Rf=()=>{const e=Ji();return S.useCallback((t,n)=>e([{name:t,data:n}]),[e])},ea=e=>{const t=zn(),n=window[ji],[r,o]=S.useState(null);return S.useEffect(()=>n.defineExtensionPoint(t,e,s=>{o(()=>s)}),[o]),r},ta=(e,t,n)=>{S.useEffect(()=>window[ji].setExtensionPoint(e,t,n),[])},na=(e,t)=>{S.useEffect(()=>(window.addEventListener(e,t),()=>window.removeEventListener(e,t)),[e,t])},ra=e=>{const{cssCustomizationLoadingDelay:t=1e3}=ko();S.useEffect(()=>{if(!e)return;const n=document.createElement("style");return setTimeout(()=>{n.innerHTML=e,document.head.append(n)},t),()=>n&&n.remove()},[e])},Of=e=>{var t;return(t=e.split(/[#?]/)[0].split(".").pop())==null?void 0:t.trim()},If={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg"},jf=e=>{const t=Of(e);return t?If[t]:void 0},kf=(e,t)=>{const n=t??jf(e);return n?`format(${n})`:""};function oa(e){const[t,n]=S.useState(!1);return S.useEffect(()=>{if(!(e!=null&&e.length))return;const r=document.createElement("style");r.setAttribute("data-generated-fonts","true");const o=e.flatMap(({fontFamily:i,variants:a})=>a.map(({path:l,fontWeight:u,format:f})=>`
|
|
24
24
|
@font-face {
|
|
25
25
|
font-family: "${i}";
|
|
26
26
|
src: url("${l}") ${kf(l,f)};
|