@sitecore-feaas/clientside 0.1.23 → 0.1.24

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.
Files changed (40) hide show
  1. package/build/components/FEAASBase.js +8 -2
  2. package/build/components/FEAASBase.js.map +1 -1
  3. package/build/components/FEAASElement.js +29 -0
  4. package/build/components/FEAASElement.js.map +1 -1
  5. package/build/dom.js +8 -5
  6. package/build/dom.js.map +1 -1
  7. package/build/ui/FEAASContext.js +9 -1
  8. package/build/ui/FEAASContext.js.map +1 -1
  9. package/dist/browser/basic.esm.js +5 -5
  10. package/dist/browser/basic.esm.js.map +1 -1
  11. package/dist/browser/basic.js +5 -5
  12. package/dist/browser/basic.js.map +1 -1
  13. package/dist/browser/index.esm.js +5 -5
  14. package/dist/browser/index.esm.js.map +1 -1
  15. package/dist/browser/index.js +5 -5
  16. package/dist/browser/index.js.map +1 -1
  17. package/dist/node/basic.esm.js +3 -3
  18. package/dist/node/basic.esm.js.map +1 -1
  19. package/dist/node/basic.js +3 -3
  20. package/dist/node/basic.js.map +1 -1
  21. package/dist/node/index.esm.js +3 -3
  22. package/dist/node/index.esm.js.map +1 -1
  23. package/dist/node/index.js +3 -3
  24. package/dist/node/index.js.map +1 -1
  25. package/examples/index.html +0 -8
  26. package/package.json +1 -1
  27. package/src/components/FEAASBase.tsx +9 -2
  28. package/src/components/FEAASElement.tsx +33 -0
  29. package/src/dom.ts +13 -10
  30. package/src/ui/FEAASContext.tsx +7 -0
  31. package/types/components/FEAASBase.d.ts +2 -0
  32. package/types/components/FEAASBase.d.ts.map +1 -1
  33. package/types/components/FEAASElement.d.ts +12 -0
  34. package/types/components/FEAASElement.d.ts.map +1 -1
  35. package/types/components/FEAASStylesheet.d.ts +2 -2
  36. package/types/dom.d.ts.map +1 -1
  37. package/types/tsbuildinfo +1 -1
  38. package/types/tsbuildinfo_ui +1 -1
  39. package/types/ui/FEAASContext.d.ts +1 -0
  40. package/types/ui/FEAASContext.d.ts.map +1 -1
@@ -1,5 +1,5 @@
1
- var nt=Object.create;var P=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var ct=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},B=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of st(t))!at.call(e,i)&&i!==r&&P(e,i,{get:()=>t[i],enumerable:!(n=it(t,i))||n.enumerable});return e};var lt=(e,t,r)=>(r=e!=null?nt(ot(e)):{},B(t||!e||!e.__esModule?P(r,"default",{value:e,enumerable:!0}):r,e)),ut=e=>B(P({},"__esModule",{value:!0}),e);var bt={};ct(bt,{Base:()=>b,Component:()=>x,FEAASBase:()=>b,FEAASComponent:()=>x,FEAASComponentsProps:()=>Z,FEAASLoader:()=>k,FEAASLoaderProps:()=>tt,FEAASStylesheet:()=>L,FEAASStylesheetProps:()=>et,JSONPath:()=>d,Loader:()=>k,Stylesheet:()=>L,autoloadScripts:()=>Y,cleanCollectionBit:()=>J,fetchAndRevalidate:()=>j,fetchAndValidate:()=>A,invalidateRequest:()=>O,loadScript:()=>M,normalizeCollectionScope:()=>K,observeDOMElement:()=>G,queryScopes:()=>H,refetchAndValidate:()=>S,renderComponent:()=>gt,renderComponentElement:()=>pt,renderComponentPromise:()=>X,renderDOMContent:()=>C,renderDOMElement:()=>E,renderStylesheet:()=>yt,renderStylesheetPromise:()=>Q,serializeCH1RichText:()=>R,setDOMAttribute:()=>w});module.exports=ut(bt);var ht=typeof HTMLElement=="undefined"?class{}:HTMLElement,b=class extends ht{constructor(){super(),this.connected=!1,this.refs={},this.descendants=[],this.onLoad=t=>{t!=null&&(this.payload=t,this.update())},this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this)}getProps(t){return{}}getRoot(){return this}attributeChangedCallback(t,r,n){this.set()}connectedCallback(){this.initialize()}initialize(){let t=this.getParent();if(!(t&&!t.connected)&&!this.connected)return this.connected=!0,console.log("FEAAS: Connected",this.tagName,this),this.dispatchEvent(new Event("feaasConnected",{bubbles:!0,composed:!0})),this.getElements().map(r=>r.initialize()),this.set(),!0}getParent(t=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!t||r.tagName.startsWith("FEAAS-"))return r}getElements(t=this.getRoot(),r=!0){return Array.from(t.querySelectorAll("*")).map(n=>[!r||n.tagName.startsWith("FEAAS-")?n:null,n.shadowRoot?this.getElements(n.shadowRoot,r):null]).flat().filter(Boolean)}disconnectedCallback(){this.connected&&(console.log("FEAAS: Disconnected",this),this.dispatchEvent(new Event("feaasDisconnected",{bubbles:!0,composed:!0})),this.connected=null)}handleEvent(t){let r=t.composedPath()[0];switch(t.type){case"feaasConnected":r!=this&&this.nestedCallback(r);break;case"feaasDisconnected":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(t){let r=this.descendants.indexOf(t);r!=-1&&(console.log("FEAAS: Unnest",this,t),this.descendants.splice(r,-1),this.refs[t.getComponentName()]=null,t.refs.parent==this&&(t.refs.parent=null),t.refs.top==this&&(t.refs.top=t.refs.parent))}nestedCallback(t){var r,n;if(this.descendants.indexOf(t)==-1&&(this.descendants.push(t),console.log("FEAAS: Nest",this,t),this.refs[t.getComponentName()]=t,t.refs.top=this,(r=t.refs).parent||(r.parent=this),t.render))for(var s=t.refs.parent;s;s=s.refs.parent)s.render&&((n=t.refs).parentReact||(n.parentReact=s),t.refs.topReact=s)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}async reify(){this.payload!==void 0?this.update():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}update(t=!1){var r,n,i;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:s,ReactDOM:o,ReactDOMClient:a}=this.payload||{};if(!s)throw new Error(`${this.tagName}: React is not present in payload`);if(!o)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?a?(this.reactRoot||(this.reactRoot=a.createRoot(this.getReactRootElement())),this.reactRoot.render(s.createElement(this.getReactWrapper()))):o.render(s.createElement(this.getReactWrapper()),this.getReactRootElement()):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(i=(n=this.refs.topReact).forceUpdateReact)===null||i===void 0||i.call(n)}invokeReactRendering(){let{React:t,ReactDOM:r}=this.payload||{},n=this.descendants.filter(i=>i.refs.parentReact==this&&i.payload).map((i,s)=>t.createElement(this.getReactWrapper(i),{key:this.tagName+"-"+s,slot:i.getAttribute("slot")}));return this.render({...this.props,children:n},this.payload)}getReactWrapper(t=this,r=t.tagName){let n=t.reactWrapper||(t.reactWrapper=i=>{if(t.render){let{React:s,ReactDOM:o}=t.payload||{},[a,l]=s.useReducer(c=>c+1,0);return t.forceUpdateReact=l,o.createPortal(s.createElement(s.Fragment,null,t.invokeReactRendering()),t.getReactRootElement())}else return t.update()});return Object.assign(n,{displayName:r}),n}getUID(){return this.uid||(this.uid=String(Math.random()))}getReactRootElement(){return this.getRoot()}set(t){this.overrides={...this.overrides,...t},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let n=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof n=="string"||typeof n=="number")&&this.getAttribute(r)!=String(n)&&this.setAttribute(r,String(n))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(t,r){return typeof t=="string"&&t.match(/^\/[^\/]/)?r+t:t}getContextAttribute(t,r=this){for(var n=this;n=n.parentElement||(n.parentNode instanceof ShadowRoot?n.parentNode.host:null);)if(n.getAttribute(t)!=null)return n.getAttribute(t);return this.getAttribute(t)}static register(t){typeof window!="undefined"&&!window.customElements.get(t)&&window.customElements.define(t,this)}};var _=class extends b{load(){return Promise.all([import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react"),import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react-dom")]).then(([t,r])=>({React:t,ReactDOM:r}))}render({},{React:t}){return t.createElement(t.Fragment,null)}};var W=lt(require("vm"),1),{hasOwnProperty:g}=Object.prototype;function v(e,t){return e=e.slice(),e.push(t),e}function D(e,t){return t=t.slice(),t.unshift(e),t}var F=class extends Error{constructor(t){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=t,this.name="NewError"}};function d(e,t,r,n,i){if(!(this instanceof d))try{return new d(e,t,r,n,i)}catch(o){if(!o.avoidNew)throw o;return o.value}typeof e=="string"&&(i=n,n=r,r=t,t=e,e=null);let s=e&&typeof e=="object";if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=g.call(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.preventEval=e.preventEval||!1,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){let o={path:s?e.path:t};s?"json"in e&&(o.json=e.json):o.json=r;let a=this.evaluate(o);if(!a||typeof a!="object")throw new F(a);return a}}d.prototype.evaluate=function(e,t,r,n){let i=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&typeof e=="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!g.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=g.call(e,"flatten")?e.flatten:o,this.currResultType=g.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=g.call(e,"sandbox")?e.sandbox:this.currSandbox,a=g.call(e,"wrap")?e.wrap:a,this.currPreventEval=g.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=g.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=g.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=g.call(e,"parent")?e.parent:i,s=g.call(e,"parentProperty")?e.parentProperty:s,e=e.path}if(i=i||null,s=s||null,Array.isArray(e)&&(e=d.toPathString(e)),!e&&e!==""||!t)return;let l=d.toPathArray(e);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let c=this._trace(l,t,["$"],i,s,r).filter(function(p){return p&&!p.isParentSelector});return c.length?!a&&c.length===1&&!c[0].hasArrExpr?this._getPreferredOutput(c[0]):c.reduce((p,h)=>{let f=this._getPreferredOutput(h);return o&&Array.isArray(f)?p=p.concat(f):p.push(f),p},[]):a?[]:void 0};d.prototype._getPreferredOutput=function(e){let t=this.currResultType;switch(t){case"all":{let r=Array.isArray(e.path)?e.path:d.toPathArray(e.path);return e.pointer=d.toPointer(r),e.path=typeof e.path=="string"?e.path:d.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return d.toPathString(e[t]);case"pointer":return d.toPointer(e.path);default:throw new TypeError("Unknown result type")}};d.prototype._handleCallback=function(e,t,r){if(t){let n=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:d.toPathString(e.path),t(n,r,e)}};d.prototype._trace=function(e,t,r,n,i,s,o,a){let l;if(!e.length)return l={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:o},this._handleCallback(l,s,"value"),l;let c=e[0],p=e.slice(1),h=[];function f(u){Array.isArray(u)?u.forEach(y=>{h.push(y)}):h.push(u)}if((typeof c!="string"||a)&&t&&g.call(t,c))f(this._trace(p,t[c],v(r,c),t,c,s,o));else if(c==="*")this._walk(t,u=>{f(this._trace(p,t[u],v(r,u),t,u,s,!0,!0))});else if(c==="..")f(this._trace(p,t,r,n,i,s,o)),this._walk(t,u=>{typeof t[u]=="object"&&f(this._trace(e.slice(),t[u],v(r,u),t,u,s,!0))});else{if(c==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:p,isParentSelector:!0};if(c==="~")return l={path:v(r,c),value:i,parent:n,parentProperty:null},this._handleCallback(l,s,"property"),l;if(c==="$")f(this._trace(p,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(c))f(this._slice(c,p,t,r,n,i,s));else if(c.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let u=c.replace(/^\?\((.*?)\)$/u,"$1");this._walk(t,y=>{this._eval(u,t[y],y,r,n,i)&&f(this._trace(p,t[y],v(r,y),t,y,s,!0))})}else if(c[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(D(this._eval(c,t,r[r.length-1],r.slice(0,-1),n,i),p),t,r,n,i,s,o))}else if(c[0]==="@"){let u=!1,y=c.slice(1,-2);switch(y){case"scalar":(!t||!["object","function"].includes(typeof t))&&(u=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===y&&(u=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(u=!0);break;case"number":Number.isFinite(t)&&(u=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(u=!0);break;case"object":t&&typeof t===y&&(u=!0);break;case"array":Array.isArray(t)&&(u=!0);break;case"other":u=this.currOtherTypeCallback(t,r,n,i);break;case"null":t===null&&(u=!0);break;default:throw new TypeError("Unknown value type "+y)}if(u)return l={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(l,s,"value"),l}else if(c[0]==="`"&&t&&g.call(t,c.slice(1))){let u=c.slice(1);f(this._trace(p,t[u],v(r,u),t,u,s,o,!0))}else if(c.includes(",")){let u=c.split(",");for(let y of u)f(this._trace(D(y,p),t,r,n,i,s,!0))}else!a&&t&&g.call(t,c)&&f(this._trace(p,t[c],v(r,c),t,c,s,o,!0))}if(this._hasParentSelector)for(let u=0;u<h.length;u++){let y=h[u];if(y&&y.isParentSelector){let m=this._trace(y.expr,t,y.path,n,i,s,o);if(Array.isArray(m)){h[u]=m[0];let rt=m.length;for(let N=1;N<rt;N++)u++,h.splice(u,0,m[N])}else h[u]=m}}return h};d.prototype._walk=function(e,t){if(Array.isArray(e)){let r=e.length;for(let n=0;n<r;n++)t(n)}else e&&typeof e=="object"&&Object.keys(e).forEach(r=>{t(r)})};d.prototype._slice=function(e,t,r,n,i,s,o){if(!Array.isArray(r))return;let a=r.length,l=e.split(":"),c=l[2]&&Number.parseInt(l[2])||1,p=l[0]&&Number.parseInt(l[0])||0,h=l[1]&&Number.parseInt(l[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),h=h<0?Math.max(0,h+a):Math.min(a,h);let f=[];for(let u=p;u<h;u+=c)this._trace(D(u,t),r,n,i,s,o,!0).forEach(m=>{f.push(m)});return f};d.prototype._eval=function(e,t,r,n,i,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;let o=e.includes("@path");o&&(this.currSandbox._$_path=d.toPathString(n.concat([r])));let a="script:"+e;if(!d.cache[a]){let l=e.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");o&&(l=l.replace(/@path/gu,"_$_path")),d.cache[a]=new this.vm.Script(l)}try{return d.cache[a].runInNewContext(this.currSandbox)}catch(l){throw new Error("jsonPath: "+l.message+": "+e)}};d.cache={};d.toPathString=function(e){let t=e,r=t.length,n="$";for(let i=1;i<r;i++)/^(~|\^|@.*?\(\))$/u.test(t[i])||(n+=/^[0-9*]+$/u.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n};d.toPointer=function(e){let t=e,r=t.length,n="";for(let i=1;i<r;i++)/^(~|\^|@.*?\(\))$/u.test(t[i])||(n+="/"+t[i].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return n};d.toPathArray=function(e){let{cache:t}=d;if(t[e])return t[e].concat();let r=[],i=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(s,o){return"[#"+(r.push(o)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(s,o){return"['"+o.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(s,o){return";"+o.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(s){let o=s.match(/#(\d+)/u);return!o||!o[1]?s:r[o[1]]});return t[e]=i,t[e].concat()};d.prototype.vm=W.default;async function j(e,t,r,n){return A({url:e,options:t,validator:r,callback:n}).then(S).then(i=>i.response)}async function A({url:e,options:t,validator:r,callback:n},i="initial"){let s=new Date;console.log("fetch",i,e);let o=await fetch(e,t);if(!o.ok)throw new Error("Fetch failed");if((r==null?void 0:r(o))===!1)throw new Error("Response is not valid");let a=new Date(o.headers.get("date"))<s;return n==null||n(o,i),{url:e,options:t,isCached:a,response:o,validator:r}}async function S(e){let{url:t,isCached:r,options:n,validator:i,response:s,callback:o}=e;if(r){let{response:a}=await A({url:t+"?"+Math.random(),options:{...n,method:"HEAD",cache:"no-cache"},validator:i},"check");if(a.headers.get("last-modified")!=s.headers.get("last-modified"))return O(e)}return e}async function O(e){let{url:t,options:r,validator:n,callback:i}=e;return A({url:t,options:{...r,cache:"reload"},validator:n,callback:i},"updated")}function q({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,component:n,version:i,revision:s="published"}){return`${e||t}/components/${r}/${n}/${i}/${s}.html`}function dt({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,revision:n="published"}){return`${e||t}/styles/${r}/${n}.css`}async function $(e,t){let r=o=>o.headers.get("x-ms-meta-versionDeletedAt")==null,n=o=>{o.text().then(t)},i=await Promise.all([e.instance&&A({options:{headers:{Accept:"text/html"}},url:q({...e,version:e.instance}),validator:r}).catch(o=>o),A({url:q(e),validator:r}).catch(o=>o)]),s=i.find(o=>o&&"isCached"in o&&o);if(!s||s instanceof Error)throw i.find(a=>a&&a instanceof Error)||new Error("Can not fetch component");return i[0]==s&&console.log("Using fork!",i),n(s.response),S({...s,callback:n}).catch(o=>{if(i[0]==s&&(O({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(i[1]instanceof Error)))return n(i[1].response),S({...i[1],callback:n});throw o})}async function T(e,t){return j(dt(e),{headers:{Accept:"text/css"}},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(t)})}function pt(e,t){let r=document.createElement("div");r.innerHTML=e;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return E(n,t),r}function J(e){return e.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function K(e){return J(e)+".*"}function V(e){let t=e.getAttribute("data-path-scope");for(var r=0,n=e;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==t&&r++;return r}function ft(e,t,r){let n=e.getAttribute("data-path-scope");if(n==null)return;var i=V(e);if(i!=0)return;let s=e.parentElement;if(s!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var o=i+1,a=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==n&&(o++,a=l);for(var c=o;c<t;c++)s.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var c=Math.max(1,t);c<o;c++)a=a.previousElementSibling,s.removeChild(a.nextElementSibling)}}function H(e,t,r=!1,n=e){var i=t;let s=Object.keys(e).sort((a,l)=>l.length-a.length);for(let a of s)if(t.startsWith(a)){if(a==t){if(r)return e[a];continue}i=t.substring(a.length+1),n=e[a];break}var o=d({path:i,json:n});return Array.isArray(o)&&(o==null?void 0:o.length)==0&&(o=[i.replace(/^.*?\./,"_."),i.replace(/^.*?\./,""),i.replace(/^([^.]+).*?\.\$\./,"$1."),i.replace(/^.*?\.\$\./,"_."),i.replace(/^.*?\.\$\./,"")].filter((a,l,c)=>c.indexOf(a)===l).reduce((a,l)=>a.length>0?a:d({path:l,json:n}),[])),r&&Array.isArray(o)?o[0]:o}function w(e,t,r,n){var i;if(e){var s=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=R(r)),n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(e,t,r));var o=t.replace("data-path-","");if(t=="data-path-src")s=e.tagName=="IMG"?e:e.querySelector("img, video");else if(t=="data-path-href")s=e.querySelector("a")||e.closest("a");else if(t=="data-path-alt")s=e.querySelector("img, picture");else if(t=="data-path-hidden")r=r?null:!0;else if(t=="data-path"||t=="data-embed-html"||t=="html")o="innerHTML";else if(t=="data-embed-src")M(e,r);else if(t=="data-path-attributes"){let h=((i=e.getAttribute("data-attributes-keys"))===null||i===void 0?void 0:i.split(",").filter(Boolean))||[];for(var a in r){var l=r[a];w(e,a,typeof l=="object"&&l?JSON.stringify(l):l,n)}for(var c=0;c<h.length;c++)(r==null||!(h[c]in r))&&w(e,h[c],null,n);w(e,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!s){var p=String(e.getAttribute("data-path-placeholder")||s[o]);r!=null?o=="innerHTML"?s.innerHTML!=r&&(s.innerHTML=r):s.getAttribute(o)!=r&&s.setAttribute(o,r):o=="innerHTML"?s.innerHTML=p:s.removeAttribute(o)}}}function G(e){let t=new e.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,s=i.getAttribute("data-embed-src");s&&M(i,s),n.addedNodes&&n.addedNodes.forEach(o=>{o.nodeType==1&&Y(o,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function Y(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];M(i,i.getAttribute("data-embed-src"))}if(t)return G(e)}function M(e,t){for(var r=e;r;r=r.parentElement)if(!r.parentElement){let i=r.querySelectorAll("script");for(var n=0;n<i.length;n++)if(i[n].getAttribute("src")==t)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let s=r.ownerDocument.createElement("script");s.type="module",s.src=t,r.appendChild(s);break}}var z=["data-attributes-keys","data-path-attributes","data-path-scope"];function E(e,t,r,n){var i,s,o;let a=e;if(n||(t=((i=r==null?void 0:r.processData)===null||i===void 0?void 0:i.call(r,a,t))||t),a.nodeType==1){let c=a.getAttribute("data-path-scope");if(c){let h=V(a),f=H(t,c,!1)||[];h==0&&ft(a,((s=r==null?void 0:r.shouldRepeat)===null||s===void 0?void 0:s.call(r,a,f))===!1?1:f.length,r),t={...t,[K(c)]:f[h]}}let p=Array.prototype.slice.call(a.attributes).sort((h,f)=>z.indexOf(h.name)-z.indexOf(f.name));for(var l=0;l<p.length;l++){let{name:h,value:f}=p[l];h.startsWith("data-path")&&h!="data-path-scope"&&w(a,h,H(t,f,!0),r),h=="data-embed-src"&&w(a,h,a.getAttribute(h),r)}}for(var l=0;l<a.children.length;l++)E(a.children[l],t,r,!0);return n||(o=r==null?void 0:r.onRender)===null||o===void 0||o.call(r,a,t),a}function C(e,t,r,n){var i;let s=((i=n==null?void 0:n.processTemplate)===null||i===void 0?void 0:i.call(n,e,t,r))||t;if(e.innerHTML=s,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(let a of e.children)a.className=a.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1");return E(e,r,n)}function yt(e,t){return Q(e,t||(t=document.createElement("style"))),t}function Q(e,t){return t||(t=document.createElement("style")),T(e,r=>{t.textContent=r}).then(()=>t)}function gt(e,t){return X(e,t||(t=document.createElement("div"))),t}async function X(e,t){return t||(t=document.createElement("div")),t.childNodes.length?E(t,e.data,e):"template"in e?C(t,e.template,e.data,e):$(e,r=>C(t,r,e.data,e)).then(()=>t)}function U(e,t={},r){return r?`<${r}${Object.entries(t).map(([n,i])=>i!=null&&` ${n}="${i}"`).filter(Boolean).join("")}>${R(e)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):R(e)}function R(e){var t;if(Array.isArray(e))return e.map(R).join(`
2
- `).trim();if(typeof e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...n}=e.attrs;return U(e.content,n,"h"+r);case"text":return(e.marks||[]).reduce((i,s)=>U(i,s.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[s.type]),(t=e.text)===null||t===void 0?void 0:t.replace(/\s+/," "));default:return U(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}function Z(e=this){let t,r=e.getAttribute("data");if(r!=null)try{t=typeof r=="string"?JSON.parse(r):{}}catch(n){}return{data:t!=null?t:{},library:e.getAttribute("library"),component:e.getAttribute("component"),version:e.getAttribute("version"),revision:e.getAttribute("revision"),hostname:e.getAttribute("hostname"),cdn:e.getContextAttribute("cdn"),template:e.getAttribute("template"),instance:e.getAttribute("instance"),editable:e.getAttribute("editable")!=null,suspended:e.getAttribute("suspended")!=null}}var x=class extends b{constructor(){super(),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}setData(t){this.set({data:t})}getProps(){return Z(this)}attributeChangedCallback(t,r,n){r!==n&&(this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(t,r,n))}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}edit(){let t=this.getEditor();if(t!=null&&t.setTarget(this))return t.open(),!0}getOriginal(){let t=this.getAttribute("data-path-scope");if(t){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==t;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{$(this.props,this.onLoad)}catch(t){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}update(){if(Array.from(this.children).filter(t=>t.tagName!="BR").length>0&&!this.needsRefresh)E(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;C(this,this.payload,this.props.data)}}};x.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable"];x.register("feaas-component");function tt(e=this){return{opacity:e!=null&&e.getAttribute("opacity")?parseFloat(e==null?void 0:e.getAttribute("opacity")):1,hidden:(e==null?void 0:e.getAttribute("hidden"))!=null}}var k=class extends b{getProps(){return tt(this)}attributeChangedCallback(t,r,n){if(r!==n)return t=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(t,r,n)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
1
+ var it=Object.create;var P=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ot(t))!ct.call(e,i)&&i!==r&&P(e,i,{get:()=>t[i],enumerable:!(n=st(t,i))||n.enumerable});return e};var ut=(e,t,r)=>(r=e!=null?it(at(e)):{},W(t||!e||!e.__esModule?P(r,"default",{value:e,enumerable:!0}):r,e)),ht=e=>W(P({},"__esModule",{value:!0}),e);var mt={};lt(mt,{Base:()=>b,Component:()=>x,FEAASBase:()=>b,FEAASComponent:()=>x,FEAASComponentsProps:()=>tt,FEAASLoader:()=>k,FEAASLoaderProps:()=>et,FEAASStylesheet:()=>N,FEAASStylesheetProps:()=>rt,JSONPath:()=>d,Loader:()=>k,MyComponent:()=>$,Stylesheet:()=>N,autoloadScripts:()=>Q,cleanCollectionBit:()=>K,fetchAndRevalidate:()=>U,fetchAndValidate:()=>A,invalidateRequest:()=>O,loadScript:()=>L,normalizeCollectionScope:()=>V,observeDOMElement:()=>Y,queryScopes:()=>I,refetchAndValidate:()=>_,renderComponent:()=>bt,renderComponentElement:()=>ft,renderComponentPromise:()=>Z,renderDOMContent:()=>R,renderDOMElement:()=>w,renderStylesheet:()=>gt,renderStylesheetPromise:()=>X,serializeCH1RichText:()=>C,setDOMAttribute:()=>S});module.exports=ht(mt);var dt=typeof HTMLElement=="undefined"?class{}:HTMLElement,b=class extends dt{constructor(){super(),this.connected=!1,this.refs={},this.descendants=[],this.onLoad=t=>{t!=null&&(this.payload=t,this.update())},this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this)}getProps(t){return{}}getRoot(){return this}attributeChangedCallback(t,r,n){this.set()}connectedCallback(){this.initialize()}initialize(){let t=this.getParent();if(!(t&&!t.connected)&&!this.connected)return this.connected=!0,console.log("FEAAS: Connected",this.tagName,this),this.dispatchEvent(new Event("feaasConnected",{bubbles:!0,composed:!0})),this.getElements().map(r=>{var n;return(n=r.initialize)===null||n===void 0?void 0:n.call(r)}),this.set(),!0}getParent(t=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!t||r.tagName.startsWith("FEAAS-"))return r}getElements(t=this.getRoot(),r=!0){return Array.from(t.querySelectorAll("*")).map(n=>[!r||n.tagName.startsWith("FEAAS-")?n:null,n.shadowRoot?this.getElements(n.shadowRoot,r):null]).flat().filter(Boolean)}disconnectedCallback(){this.connected&&(console.log("FEAAS: Disconnected",this),this.dispatchEvent(new Event("feaasDisconnected",{bubbles:!0,composed:!0})),this.connected=null)}handleEvent(t){let r=t.composedPath()[0];switch(t.type){case"feaasConnected":r!=this&&this.nestedCallback(r);break;case"feaasDisconnected":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(t){let r=this.descendants.indexOf(t);r!=-1&&(console.log("FEAAS: Unnest",this,t),this.descendants.splice(r,-1),this.refs[t.getComponentName()]=null,t.refs.parent==this&&(t.refs.parent=null),t.refs.top==this&&(t.refs.top=t.refs.parent))}nestedCallback(t){var r,n;if(this.descendants.indexOf(t)==-1&&(this.descendants.push(t),console.log("FEAAS: Nest",this,t),this.refs[t.getComponentName()]=t,t.refs.top=this,(r=t.refs).parent||(r.parent=this),t.render))for(var s=t.refs.parent;s;s=s.refs.parent)s.render&&((n=t.refs).parentReact||(n.parentReact=s),t.refs.topReact=s)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}async reify(){this.payload!==void 0?this.update():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}update(t=!1){var r,n,i;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:s,ReactDOM:o,ReactDOMClient:a}=this.payload||{};if(!s)throw new Error(`${this.tagName}: React is not present in payload`);if(!o)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?a?(this.reactRoot||(this.reactRoot=a.createRoot(this.getReactRootElement())),this.reactRoot.render(s.createElement(this.getReactWrapper()))):o.render(s.createElement(this.getReactWrapper()),this.getReactRootElement()):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(i=(n=this.refs.topReact).forceUpdateReact)===null||i===void 0||i.call(n)}invokeReactRendering(){let{React:t,ReactDOM:r}=this.payload||{},n=this.descendants.filter(i=>i.refs.parentReact==this&&i.payload).map((i,s)=>t.createElement(this.getReactWrapper(i),{key:this.tagName+"-"+s,slot:i.getAttribute("slot")}));return this.render({...this.props,children:n},this.payload)}getReactWrapper(t=this,r=t.tagName){let n=t.reactWrapper||(t.reactWrapper=i=>{if(t.render){let{React:s,ReactDOM:o}=t.payload||{},[a,l]=s.useReducer(c=>c+1,0);return t.forceUpdateReact=l,o.createPortal(s.createElement(s.Fragment,null,t.invokeReactRendering()),t.getReactRootElement())}else return t.update()});return Object.assign(n,{displayName:r}),n}getUID(){return this.uid||(this.uid=String(Math.random()))}getShadowRoot(){return this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot}getReactRootElement(){return this.useShadowRoot?this.getShadowRoot():this.getRoot()}set(t){this.overrides={...this.overrides,...t},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let n=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof n=="string"||typeof n=="number")&&this.getAttribute(r)!=String(n)&&this.setAttribute(r,String(n))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(t,r){return typeof t=="string"&&t.match(/^\/[^\/]/)?r+t:t}getContextAttribute(t,r=this){for(var n=this;n=n.parentElement||(n.parentNode instanceof ShadowRoot?n.parentNode.host:null);)if(n.getAttribute(t)!=null)return n.getAttribute(t);return this.getAttribute(t)}static register(t){typeof window!="undefined"&&!window.customElements.get(t)&&window.customElements.define(t,this)}};var E=class extends b{load(){return Promise.all([import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react"),import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react-dom")]).then(([t,r])=>({React:t,ReactDOM:r}))}render({},{React:t}){return t.createElement(t.Fragment,null)}},$=class extends E{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:t},{React:r}){let[n,i]=r.useState(0);return r.useEffect(()=>{i(s=>s+1)},[t]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",t),r.createElement("p",null,"Triggered updates: ",n))}};$.observedAttributes=["counter"];var q=ut(require("vm"),1),{hasOwnProperty:g}=Object.prototype;function v(e,t){return e=e.slice(),e.push(t),e}function F(e,t){return t=t.slice(),t.unshift(e),t}var j=class extends Error{constructor(t){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=t,this.name="NewError"}};function d(e,t,r,n,i){if(!(this instanceof d))try{return new d(e,t,r,n,i)}catch(o){if(!o.avoidNew)throw o;return o.value}typeof e=="string"&&(i=n,n=r,r=t,t=e,e=null);let s=e&&typeof e=="object";if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=g.call(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.preventEval=e.preventEval||!1,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){let o={path:s?e.path:t};s?"json"in e&&(o.json=e.json):o.json=r;let a=this.evaluate(o);if(!a||typeof a!="object")throw new j(a);return a}}d.prototype.evaluate=function(e,t,r,n){let i=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&typeof e=="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!g.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=g.call(e,"flatten")?e.flatten:o,this.currResultType=g.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=g.call(e,"sandbox")?e.sandbox:this.currSandbox,a=g.call(e,"wrap")?e.wrap:a,this.currPreventEval=g.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=g.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=g.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=g.call(e,"parent")?e.parent:i,s=g.call(e,"parentProperty")?e.parentProperty:s,e=e.path}if(i=i||null,s=s||null,Array.isArray(e)&&(e=d.toPathString(e)),!e&&e!==""||!t)return;let l=d.toPathArray(e);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let c=this._trace(l,t,["$"],i,s,r).filter(function(p){return p&&!p.isParentSelector});return c.length?!a&&c.length===1&&!c[0].hasArrExpr?this._getPreferredOutput(c[0]):c.reduce((p,h)=>{let f=this._getPreferredOutput(h);return o&&Array.isArray(f)?p=p.concat(f):p.push(f),p},[]):a?[]:void 0};d.prototype._getPreferredOutput=function(e){let t=this.currResultType;switch(t){case"all":{let r=Array.isArray(e.path)?e.path:d.toPathArray(e.path);return e.pointer=d.toPointer(r),e.path=typeof e.path=="string"?e.path:d.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return d.toPathString(e[t]);case"pointer":return d.toPointer(e.path);default:throw new TypeError("Unknown result type")}};d.prototype._handleCallback=function(e,t,r){if(t){let n=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:d.toPathString(e.path),t(n,r,e)}};d.prototype._trace=function(e,t,r,n,i,s,o,a){let l;if(!e.length)return l={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:o},this._handleCallback(l,s,"value"),l;let c=e[0],p=e.slice(1),h=[];function f(u){Array.isArray(u)?u.forEach(y=>{h.push(y)}):h.push(u)}if((typeof c!="string"||a)&&t&&g.call(t,c))f(this._trace(p,t[c],v(r,c),t,c,s,o));else if(c==="*")this._walk(t,u=>{f(this._trace(p,t[u],v(r,u),t,u,s,!0,!0))});else if(c==="..")f(this._trace(p,t,r,n,i,s,o)),this._walk(t,u=>{typeof t[u]=="object"&&f(this._trace(e.slice(),t[u],v(r,u),t,u,s,!0))});else{if(c==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:p,isParentSelector:!0};if(c==="~")return l={path:v(r,c),value:i,parent:n,parentProperty:null},this._handleCallback(l,s,"property"),l;if(c==="$")f(this._trace(p,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(c))f(this._slice(c,p,t,r,n,i,s));else if(c.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let u=c.replace(/^\?\((.*?)\)$/u,"$1");this._walk(t,y=>{this._eval(u,t[y],y,r,n,i)&&f(this._trace(p,t[y],v(r,y),t,y,s,!0))})}else if(c[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(F(this._eval(c,t,r[r.length-1],r.slice(0,-1),n,i),p),t,r,n,i,s,o))}else if(c[0]==="@"){let u=!1,y=c.slice(1,-2);switch(y){case"scalar":(!t||!["object","function"].includes(typeof t))&&(u=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===y&&(u=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(u=!0);break;case"number":Number.isFinite(t)&&(u=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(u=!0);break;case"object":t&&typeof t===y&&(u=!0);break;case"array":Array.isArray(t)&&(u=!0);break;case"other":u=this.currOtherTypeCallback(t,r,n,i);break;case"null":t===null&&(u=!0);break;default:throw new TypeError("Unknown value type "+y)}if(u)return l={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(l,s,"value"),l}else if(c[0]==="`"&&t&&g.call(t,c.slice(1))){let u=c.slice(1);f(this._trace(p,t[u],v(r,u),t,u,s,o,!0))}else if(c.includes(",")){let u=c.split(",");for(let y of u)f(this._trace(F(y,p),t,r,n,i,s,!0))}else!a&&t&&g.call(t,c)&&f(this._trace(p,t[c],v(r,c),t,c,s,o,!0))}if(this._hasParentSelector)for(let u=0;u<h.length;u++){let y=h[u];if(y&&y.isParentSelector){let m=this._trace(y.expr,t,y.path,n,i,s,o);if(Array.isArray(m)){h[u]=m[0];let nt=m.length;for(let D=1;D<nt;D++)u++,h.splice(u,0,m[D])}else h[u]=m}}return h};d.prototype._walk=function(e,t){if(Array.isArray(e)){let r=e.length;for(let n=0;n<r;n++)t(n)}else e&&typeof e=="object"&&Object.keys(e).forEach(r=>{t(r)})};d.prototype._slice=function(e,t,r,n,i,s,o){if(!Array.isArray(r))return;let a=r.length,l=e.split(":"),c=l[2]&&Number.parseInt(l[2])||1,p=l[0]&&Number.parseInt(l[0])||0,h=l[1]&&Number.parseInt(l[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),h=h<0?Math.max(0,h+a):Math.min(a,h);let f=[];for(let u=p;u<h;u+=c)this._trace(F(u,t),r,n,i,s,o,!0).forEach(m=>{f.push(m)});return f};d.prototype._eval=function(e,t,r,n,i,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;let o=e.includes("@path");o&&(this.currSandbox._$_path=d.toPathString(n.concat([r])));let a="script:"+e;if(!d.cache[a]){let l=e.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");o&&(l=l.replace(/@path/gu,"_$_path")),d.cache[a]=new this.vm.Script(l)}try{return d.cache[a].runInNewContext(this.currSandbox)}catch(l){throw new Error("jsonPath: "+l.message+": "+e)}};d.cache={};d.toPathString=function(e){let t=e,r=t.length,n="$";for(let i=1;i<r;i++)/^(~|\^|@.*?\(\))$/u.test(t[i])||(n+=/^[0-9*]+$/u.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n};d.toPointer=function(e){let t=e,r=t.length,n="";for(let i=1;i<r;i++)/^(~|\^|@.*?\(\))$/u.test(t[i])||(n+="/"+t[i].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return n};d.toPathArray=function(e){let{cache:t}=d;if(t[e])return t[e].concat();let r=[],i=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(s,o){return"[#"+(r.push(o)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(s,o){return"['"+o.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(s,o){return";"+o.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(s){let o=s.match(/#(\d+)/u);return!o||!o[1]?s:r[o[1]]});return t[e]=i,t[e].concat()};d.prototype.vm=q.default;async function U(e,t,r,n){return A({url:e,options:t,validator:r,callback:n}).then(_).then(i=>i.response)}async function A({url:e,options:t,validator:r,callback:n},i="initial"){let s=new Date;console.log("fetch",i,e);let o=await fetch(e,t);if(!o.ok)throw new Error("Fetch failed");if((r==null?void 0:r(o))===!1)throw new Error("Response is not valid");let a=new Date(o.headers.get("date"))<s;return n==null||n(o,i),{url:e,options:t,isCached:a,response:o,validator:r}}async function _(e){let{url:t,isCached:r,options:n,validator:i,response:s,callback:o}=e;if(r){let{response:a}=await A({url:t+"?"+Math.random(),options:{...n,method:"HEAD",cache:"no-cache"},validator:i},"check");if(a.headers.get("last-modified")!=s.headers.get("last-modified"))return O(e)}return e}async function O(e){let{url:t,options:r,validator:n,callback:i}=e;return A({url:t,options:{...r,cache:"reload"},validator:n,callback:i},"updated")}function z({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,component:n,version:i,revision:s="published"}){return`${e||t}/components/${r}/${n}/${i}/${s}.html`}function pt({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,revision:n="published"}){return`${e||t}/styles/${r}/${n}.css`}async function T(e,t){let r=o=>o.headers.get("x-ms-meta-versionDeletedAt")==null,n=o=>{o.text().then(t)},i=await Promise.all([e.instance&&A({options:{headers:{Accept:"text/html"}},url:z({...e,version:e.instance}),validator:r}).catch(o=>o),A({url:z(e),validator:r}).catch(o=>o)]),s=i.find(o=>o&&"isCached"in o&&o);if(!s||s instanceof Error)throw i.find(a=>a&&a instanceof Error)||new Error("Can not fetch component");return i[0]==s&&console.log("Using fork!",i),n(s.response),_({...s,callback:n}).catch(o=>{if(i[0]==s&&(O({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(i[1]instanceof Error)))return n(i[1].response),_({...i[1],callback:n});throw o})}async function M(e,t){return U(pt(e),{headers:{Accept:"text/css"}},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(t)})}function ft(e,t){let r=document.createElement("div");r.innerHTML=e;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return w(n,t),r}function K(e){return e.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function V(e){return K(e)+".*"}function G(e){let t=e.getAttribute("data-path-scope");for(var r=0,n=e;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==t&&r++;return r}function yt(e,t,r){let n=e.getAttribute("data-path-scope");if(n==null)return;var i=G(e);if(i!=0)return;let s=e.parentElement;if(s!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var o=i+1,a=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==n&&(o++,a=l);for(var c=o;c<t;c++)s.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var c=Math.max(1,t);c<o;c++)a=a.previousElementSibling,s.removeChild(a.nextElementSibling)}}function I(e,t,r=!1,n=e){var i=t;let s=Object.keys(e).sort((a,l)=>l.length-a.length);for(let a of s)if(t.startsWith(a)){if(a==t){if(r)return e[a];continue}i=t.substring(a.length+1),n=e[a];break}var o=d({path:i,json:n});return Array.isArray(o)&&(o==null?void 0:o.length)==0&&(o=[i.replace(/^.*?\./,"_."),i.replace(/^.*?\./,""),i.replace(/^([^.]+).*?\.\$\./,"$1."),i.replace(/^.*?\.\$\./,"_."),i.replace(/^.*?\.\$\./,""),i.replace(/^[^.]+$/,"_")].filter((a,l,c)=>c.indexOf(a)===l).reduce((a,l)=>a.length>0?a:d({path:l,json:n}),[])),r&&Array.isArray(o)?o[0]:o}function S(e,t,r,n){var i;if(e){var s=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=C(r)),n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(e,t,r));var o=t.replace("data-path-","");if(t=="data-path-src")s=e.tagName=="IMG"?e:e.querySelector("img, video");else if(t=="data-path-href")s=e.querySelector("a")||e.closest("a");else if(t=="data-path-alt")s=e.querySelector("img, picture");else if(t=="data-path-hidden")r=r?null:!0;else if(t=="data-path"||t=="data-embed-html"||t=="html")o="innerHTML";else if(t=="data-embed-src")L(e,r);else if(t=="data-path-attributes"){let h=((i=e.getAttribute("data-attributes-keys"))===null||i===void 0?void 0:i.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var a in r){var l=r[a];S(e,a,typeof l=="object"&&l?JSON.stringify(l):l,n)}for(var c=0;c<h.length;c++)(r==null||!(h[c]in r))&&S(e,h[c],null,n);S(e,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!s){var p=String(e.getAttribute("data-path-placeholder")||s[o]);r!=null?o=="innerHTML"?s.innerHTML!=r&&(s.innerHTML=r):s.getAttribute(o)!=r&&s.setAttribute(o,r):o=="innerHTML"?s.innerHTML=p:s.removeAttribute(o)}}}function Y(e){let t=new e.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,s=i.getAttribute("data-embed-src");s&&L(i,s),n.addedNodes&&n.addedNodes.forEach(o=>{o.nodeType==1&&Q(o,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function Q(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];L(i,i.getAttribute("data-embed-src"))}if(t)return Y(e)}function L(e,t){for(var r=e;r;r=r.parentElement)if(!r.parentElement){let i=r.querySelectorAll("script");for(var n=0;n<i.length;n++)if(i[n].getAttribute("src")==t)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let s=r.ownerDocument.createElement("script");s.type="module",s.src=t,r.appendChild(s);break}}var J=["data-attributes-keys","data-path-attributes","data-path-scope"];function w(e,t,r,n){var i,s,o;let a=e;if(n||(t=((i=r==null?void 0:r.processData)===null||i===void 0?void 0:i.call(r,a,t))||t),a.nodeType==1){let c=a.getAttribute("data-path-scope");if(c){let h=G(a),f=I(t,c,!1)||[];h==0&&yt(a,((s=r==null?void 0:r.shouldRepeat)===null||s===void 0?void 0:s.call(r,a,f))===!1?1:f.length,r),t={...t,[V(c)]:f[h]}}let p=Array.prototype.slice.call(a.attributes).sort((h,f)=>J.indexOf(h.name)-J.indexOf(f.name));for(var l=0;l<p.length;l++){let{name:h,value:f}=p[l];h.startsWith("data-path")&&h!="data-path-scope"&&S(a,h,I(t,f,!0),r),h=="data-embed-src"&&S(a,h,a.getAttribute(h),r)}}for(var l=0;l<a.children.length;l++)w(a.children[l],t,r,!0);return n||(o=r==null?void 0:r.onRender)===null||o===void 0||o.call(r,a,t),a}function R(e,t,r,n){var i;let s=((i=n==null?void 0:n.processTemplate)===null||i===void 0?void 0:i.call(n,e,t,r))||t;if(e.innerHTML=s,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(let a of e.children)a.className=a.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1");return w(e,r,n)}function gt(e,t){return X(e,t||(t=document.createElement("style"))),t}function X(e,t){return t||(t=document.createElement("style")),M(e,r=>{t.textContent=r}).then(()=>t)}function bt(e,t){return Z(e,t||(t=document.createElement("div"))),t}async function Z(e,t){return t||(t=document.createElement("div")),t.childNodes.length?w(t,e.data,e):"template"in e?R(t,e.template,e.data,e):T(e,r=>R(t,r,e.data,e)).then(()=>t)}function H(e,t={},r){return r?`<${r}${Object.entries(t).map(([n,i])=>i!=null&&` ${n}="${i}"`).filter(Boolean).join("")}>${C(e)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):C(e)}function C(e){var t;if(Array.isArray(e))return e.map(C).join(`
2
+ `).trim();if(typeof e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...n}=e.attrs;return H(e.content,n,"h"+r);case"text":return(e.marks||[]).reduce((i,s)=>H(i,s.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[s.type]),(t=e.text)===null||t===void 0?void 0:t.replace(/\s+/," "));default:return H(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}function tt(e=this){let t,r=e.getAttribute("data");if(r!=null)try{t=typeof r=="string"?JSON.parse(r):{}}catch(n){}return{data:t!=null?t:{},library:e.getAttribute("library"),component:e.getAttribute("component"),version:e.getAttribute("version"),revision:e.getAttribute("revision"),hostname:e.getAttribute("hostname"),cdn:e.getContextAttribute("cdn"),template:e.getAttribute("template"),instance:e.getAttribute("instance"),editable:e.getAttribute("editable")!=null,suspended:e.getAttribute("suspended")!=null}}var x=class extends b{constructor(){super(),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}setData(t){this.set({data:t})}getProps(){return tt(this)}attributeChangedCallback(t,r,n){r!==n&&(this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(t,r,n))}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}edit(){let t=this.getEditor();if(t!=null&&t.setTarget(this))return t.open(),!0}getOriginal(){let t=this.getAttribute("data-path-scope");if(t){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==t;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{T(this.props,this.onLoad)}catch(t){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}update(){if(Array.from(this.children).filter(t=>t.tagName!="BR").length>0&&!this.needsRefresh)w(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;R(this,this.payload,this.props.data)}}};x.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable"];x.register("feaas-component");function et(e=this){return{opacity:e!=null&&e.getAttribute("opacity")?parseFloat(e==null?void 0:e.getAttribute("opacity")):1,hidden:(e==null?void 0:e.getAttribute("hidden"))!=null}}var k=class extends b{getProps(){return et(this)}attributeChangedCallback(t,r,n){if(r!==n)return t=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(t,r,n)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
3
3
  #loader {
4
4
  position: absolute;
5
5
  top: 0;
@@ -63,5 +63,5 @@ var nt=Object.create;var P=Object.defineProperty;var it=Object.getOwnPropertyDes
63
63
  style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
64
64
  ></circle>
65
65
  </svg>
66
- </div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};k.observedAttributes=["hidden","opacity"];k.register("feaas-loader");function et(e=this){var t;return{library:e==null?void 0:e.getContextAttribute("library"),revision:(t=e==null?void 0:e.getAttribute("revision"))!==null&&t!==void 0?t:"published",cdn:(e==null?void 0:e.getContextAttribute("cdn"))||(e==null?void 0:e.getContextAttribute("hostname"))}}var L=class extends b{getProps(){return et(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){T(this.props,this.onLoad)}update(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};L.register("feaas-stylesheet");var I;typeof window!="undefined"&&(window.FEAASElement=_,(I=window.FEAASLoading)!==null&&I!==void 0||(window.FEAASLoading=Promise.resolve()));0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASLoader,FEAASLoaderProps,FEAASStylesheet,FEAASStylesheetProps,JSONPath,Loader,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,fetchAndValidate,invalidateRequest,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,refetchAndValidate,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderStylesheet,renderStylesheetPromise,serializeCH1RichText,setDOMAttribute});
66
+ </div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};k.observedAttributes=["hidden","opacity"];k.register("feaas-loader");function rt(e=this){var t;return{library:e==null?void 0:e.getContextAttribute("library"),revision:(t=e==null?void 0:e.getAttribute("revision"))!==null&&t!==void 0?t:"published",cdn:(e==null?void 0:e.getContextAttribute("cdn"))||(e==null?void 0:e.getContextAttribute("hostname"))}}var N=class extends b{getProps(){return rt(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){M(this.props,this.onLoad)}update(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};N.register("feaas-stylesheet");var B;typeof window!="undefined"&&(window.FEAASElement=E,(B=window.FEAASLoading)!==null&&B!==void 0||(window.FEAASLoading=Promise.resolve()));0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASLoader,FEAASLoaderProps,FEAASStylesheet,FEAASStylesheetProps,JSONPath,Loader,MyComponent,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,fetchAndValidate,invalidateRequest,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,refetchAndValidate,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderStylesheet,renderStylesheetPromise,serializeCH1RichText,setDOMAttribute});
67
67
  //# sourceMappingURL=basic.js.map