@sitecore-feaas/clientside 0.1.18 → 0.1.20

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 (84) hide show
  1. package/build/basic.js +5 -1
  2. package/build/basic.js.map +1 -1
  3. package/build/cloud.js +45 -4
  4. package/build/cloud.js.map +1 -1
  5. package/build/components/FEAASBase.js +60 -21
  6. package/build/components/FEAASBase.js.map +1 -1
  7. package/build/components/FEAASComponent.js +35 -1
  8. package/build/components/FEAASComponent.js.map +1 -1
  9. package/build/components/FEAASElement.js +14 -0
  10. package/build/components/FEAASElement.js.map +1 -0
  11. package/build/components/FEAASLoader.js +13 -1
  12. package/build/components/FEAASLoader.js.map +1 -1
  13. package/build/components/FEAASStylesheet.js.map +1 -1
  14. package/build/dom.js +6 -0
  15. package/build/dom.js.map +1 -1
  16. package/build/fetch.js +48 -45
  17. package/build/fetch.js.map +1 -1
  18. package/build/ui/FEAASContext.js +12 -13
  19. package/build/ui/FEAASContext.js.map +1 -1
  20. package/build/ui/FEAASEditor.js +448 -76
  21. package/build/ui/FEAASEditor.js.map +1 -1
  22. package/build/ui/FEAASPicker.js +9 -59
  23. package/build/ui/FEAASPicker.js.map +1 -1
  24. package/dist/browser/basic.esm.js +5 -5
  25. package/dist/browser/basic.esm.js.map +1 -1
  26. package/dist/browser/basic.js +5 -5
  27. package/dist/browser/basic.js.map +1 -1
  28. package/dist/browser/index.esm.js +5 -10
  29. package/dist/browser/index.esm.js.map +1 -1
  30. package/dist/browser/index.js +5 -10
  31. package/dist/browser/index.js.map +1 -1
  32. package/dist/node/basic.esm.js +3 -3
  33. package/dist/node/basic.esm.js.map +1 -1
  34. package/dist/node/basic.js +3 -3
  35. package/dist/node/basic.js.map +1 -1
  36. package/dist/node/index.esm.js +3 -8
  37. package/dist/node/index.esm.js.map +1 -1
  38. package/dist/node/index.js +3 -8
  39. package/dist/node/index.js.map +1 -1
  40. package/examples/index.html +8 -49
  41. package/package.json +2 -7
  42. package/src/basic.ts +8 -1
  43. package/src/cloud.ts +49 -11
  44. package/src/components/FEAASBase.tsx +73 -20
  45. package/src/components/{FEAASComponent.ts → FEAASComponent.tsx} +37 -1
  46. package/src/components/FEAASElement.tsx +21 -0
  47. package/src/components/{FEAASLoader.ts → FEAASLoader.tsx} +14 -1
  48. package/src/components/{FEAASStylesheet.ts → FEAASStylesheet.tsx} +1 -1
  49. package/src/dom.ts +5 -0
  50. package/src/fetch.ts +82 -51
  51. package/src/ui/FEAASContext.tsx +13 -14
  52. package/src/ui/FEAASEditor.tsx +598 -144
  53. package/src/ui/FEAASPicker.tsx +18 -65
  54. package/test/components.ts +19 -0
  55. package/types/basic.d.ts +3 -0
  56. package/types/basic.d.ts.map +1 -1
  57. package/types/cloud.d.ts +8 -1
  58. package/types/cloud.d.ts.map +1 -1
  59. package/types/components/FEAASBase.d.ts +18 -4
  60. package/types/components/FEAASBase.d.ts.map +1 -1
  61. package/types/components/FEAASComponent.d.ts +7 -0
  62. package/types/components/FEAASComponent.d.ts.map +1 -1
  63. package/types/components/FEAASElement.d.ts +12 -0
  64. package/types/components/FEAASElement.d.ts.map +1 -0
  65. package/types/components/FEAASLoader.d.ts +6 -0
  66. package/types/components/FEAASLoader.d.ts.map +1 -1
  67. package/types/components/FEAASStylesheet.d.ts +1 -1
  68. package/types/components/FEAASStylesheet.d.ts.map +1 -1
  69. package/types/dom.d.ts.map +1 -1
  70. package/types/fetch.d.ts +42 -1
  71. package/types/fetch.d.ts.map +1 -1
  72. package/types/tsbuildinfo +1 -1
  73. package/types/tsbuildinfo_ui +1 -1
  74. package/types/ui/FEAASContext.d.ts +4 -4
  75. package/types/ui/FEAASContext.d.ts.map +1 -1
  76. package/types/ui/FEAASEditor.d.ts +71 -5
  77. package/types/ui/FEAASEditor.d.ts.map +1 -1
  78. package/types/ui/FEAASPicker.d.ts +15 -34
  79. package/types/ui/FEAASPicker.d.ts.map +1 -1
  80. package/types/components/FEAASContext.d.ts +0 -43
  81. package/types/components/FEAASEditor.d.ts +0 -136
  82. package/types/components/FEAASPicker.d.ts +0 -65
  83. package/types/components/index.d.ts +0 -7
  84. package/types/index.d.ts +0 -7
@@ -1,5 +1,5 @@
1
- import ot from"vm";var{hasOwnProperty:y}=Object.prototype;function A(t,e){return t=t.slice(),t.push(e),t}function U(t,e){return e=e.slice(),e.unshift(t),e}var H=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function p(t,e,r,i,n){if(!(this instanceof p))try{return new p(t,e,r,i,n)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof t=="string"&&(n=i,i=r,r=e,e=t,t=null);let o=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=y.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||i||null,this.otherTypeCallback=t.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let s={path:o?t.path:e};o?"json"in t&&(s.json=t.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new H(a);return a}}p.prototype.evaluate=function(t,e,r,i){let n=this.parent,o=this.parentProperty,{flatten:s,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!y.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),s=y.call(t,"flatten")?t.flatten:s,this.currResultType=y.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=y.call(t,"sandbox")?t.sandbox:this.currSandbox,a=y.call(t,"wrap")?t.wrap:a,this.currPreventEval=y.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=y.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=y.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,n=y.call(t,"parent")?t.parent:n,o=y.call(t,"parentProperty")?t.parentProperty:o,t=t.path}if(n=n||null,o=o||null,Array.isArray(t)&&(t=p.toPathString(t)),!t&&t!==""||!e)return;let l=p.toPathArray(t);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let c=this._trace(l,e,["$"],n,o,r).filter(function(h){return h&&!h.isParentSelector});return c.length?!a&&c.length===1&&!c[0].hasArrExpr?this._getPreferredOutput(c[0]):c.reduce((h,u)=>{let f=this._getPreferredOutput(u);return s&&Array.isArray(f)?h=h.concat(f):h.push(f),h},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:p.toPathArray(t.path);return t.pointer=p.toPointer(r),t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return p.toPathString(t[e]);case"pointer":return p.toPointer(t.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(t,e,r){if(e){let i=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),e(i,r,t)}};p.prototype._trace=function(t,e,r,i,n,o,s,a){let l;if(!t.length)return l={path:r,value:e,parent:i,parentProperty:n,hasArrExpr:s},this._handleCallback(l,o,"value"),l;let c=t[0],h=t.slice(1),u=[];function f(d){Array.isArray(d)?d.forEach(g=>{u.push(g)}):u.push(d)}if((typeof c!="string"||a)&&e&&y.call(e,c))f(this._trace(h,e[c],A(r,c),e,c,o,s));else if(c==="*")this._walk(e,d=>{f(this._trace(h,e[d],A(r,d),e,d,o,!0,!0))});else if(c==="..")f(this._trace(h,e,r,i,n,o,s)),this._walk(e,d=>{typeof e[d]=="object"&&f(this._trace(t.slice(),e[d],A(r,d),e,d,o,!0))});else{if(c==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(c==="~")return l={path:A(r,c),value:n,parent:i,parentProperty:null},this._handleCallback(l,o,"property"),l;if(c==="$")f(this._trace(h,e,r,null,null,o,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(c))f(this._slice(c,h,e,r,i,n,o));else if(c.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let d=c.replace(/^\?\((.*?)\)$/u,"$1");this._walk(e,g=>{this._eval(d,e[g],g,r,i,n)&&f(this._trace(h,e[g],A(r,g),e,g,o,!0))})}else if(c[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(U(this._eval(c,e,r[r.length-1],r.slice(0,-1),i,n),h),e,r,i,n,o,s))}else if(c[0]==="@"){let d=!1,g=c.slice(1,-2);switch(g){case"scalar":(!e||!["object","function"].includes(typeof e))&&(d=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===g&&(d=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(d=!0);break;case"number":Number.isFinite(e)&&(d=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(d=!0);break;case"object":e&&typeof e===g&&(d=!0);break;case"array":Array.isArray(e)&&(d=!0);break;case"other":d=this.currOtherTypeCallback(e,r,i,n);break;case"null":e===null&&(d=!0);break;default:throw new TypeError("Unknown value type "+g)}if(d)return l={path:r,value:e,parent:i,parentProperty:n},this._handleCallback(l,o,"value"),l}else if(c[0]==="`"&&e&&y.call(e,c.slice(1))){let d=c.slice(1);f(this._trace(h,e[d],A(r,d),e,d,o,s,!0))}else if(c.includes(",")){let d=c.split(",");for(let g of d)f(this._trace(U(g,h),e,r,i,n,o,!0))}else!a&&e&&y.call(e,c)&&f(this._trace(h,e[c],A(r,c),e,c,o,s,!0))}if(this._hasParentSelector)for(let d=0;d<u.length;d++){let g=u[d];if(g&&g.isParentSelector){let m=this._trace(g.expr,e,g.path,i,n,o,s);if(Array.isArray(m)){u[d]=m[0];let F=m.length;for(let R=1;R<F;R++)d++,u.splice(d,0,m[R])}else u[d]=m}}return u};p.prototype._walk=function(t,e){if(Array.isArray(t)){let r=t.length;for(let i=0;i<r;i++)e(i)}else t&&typeof t=="object"&&Object.keys(t).forEach(r=>{e(r)})};p.prototype._slice=function(t,e,r,i,n,o,s){if(!Array.isArray(r))return;let a=r.length,l=t.split(":"),c=l[2]&&Number.parseInt(l[2])||1,h=l[0]&&Number.parseInt(l[0])||0,u=l[1]&&Number.parseInt(l[1])||a;h=h<0?Math.max(0,h+a):Math.min(a,h),u=u<0?Math.max(0,u+a):Math.min(a,u);let f=[];for(let d=h;d<u;d+=c)this._trace(U(d,e),r,i,n,o,s,!0).forEach(m=>{f.push(m)});return f};p.prototype._eval=function(t,e,r,i,n,o){this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;let s=t.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+t;if(!p.cache[a]){let l=t.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");s&&(l=l.replace(/@path/gu,"_$_path")),p.cache[a]=new this.vm.Script(l)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(l){throw new Error("jsonPath: "+l.message+": "+t)}};p.cache={};p.toPathString=function(t){let e=t,r=e.length,i="$";for(let n=1;n<r;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(i+=/^[0-9*]+$/u.test(e[n])?"["+e[n]+"]":"['"+e[n]+"']");return i};p.toPointer=function(t){let e=t,r=e.length,i="";for(let n=1;n<r;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(i+="/"+e[n].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(t){let{cache:e}=p;if(e[t])return e[t].concat();let r=[],n=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(o,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(o,s){return"['"+s.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(o,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(o){let s=o.match(/#(\d+)/u);return!s||!s[1]?o:r[s[1]]});return e[t]=n,e[t].concat()};p.prototype.vm=ot;async function B(t,e,r,i){let n=new Date,o=await fetch(t,e);if(!o.ok)throw new Error("Fetch failed");let s=new Date(o.headers.get("date"));var a=o;if(i(o,"cached"),s<n){let l=await fetch(t+"?"+Math.random(),{...e,method:"HEAD",cache:"no-cache"});if(l.headers.get("last-modified")!=o.headers.get("last-modified")){if(r(l)===!1)throw new Error("Response is stale");a=await fetch(t,{...e,cache:"reload"})}}if(r(a)===!1)throw new Error("Response is not valid");return o!==a&&i(a,"valid"),a}function st({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,component:i,version:n,revision:o="published"}){return`${t||e}/components/${r}/${i}/${n}/${o}.html`}function at({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,revision:i="published"}){return`${t||e}/styles/${r}/${i}.css`}async function P(t,e){return B(st(t),{},r=>r.headers.get("x-ms-meta-versionDeletedAt")==null,r=>{r.text().then(e)})}async function T(t,e){return B(at(t),{},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(e)})}function Tt(t,e){let r=document.createElement("div");r.innerHTML=t;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return w(i,e),r}function lt(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function ct(t){return lt(t)+".*"}function X(t){let e=t.getAttribute("data-path-scope");for(var r=0,i=t;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==e&&r++;return r}function dt(t,e,r){let i=t.getAttribute("data-path-scope");if(i==null)return;var n=X(t);if(n!=0)return;let o=t.parentElement;if(o!=null){e==0?t.setAttribute("hidden","hidden"):t.getAttribute("hidden")!=null&&t.removeAttribute("hidden");for(var s=n+1,a=t,l=t;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==i&&(s++,a=l);for(var c=s;c<e;c++)o.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var c=Math.max(1,e);c<s;c++)a=a.previousElementSibling,o.removeChild(a.nextElementSibling)}}function Y(t,e,r=!1,i=t){var n=e;let o=Object.keys(t).sort((a,l)=>l.length-a.length);for(let a of o)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}n=e.substring(a.length+1),i=t[a];break}var s=p({path:n,json:i});return Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=[n.replace(/^.*?\./,"_."),n.replace(/^.*?\./,""),n.replace(/^([^.]+).*?\.\$\./,"$1."),n.replace(/^.*?\.\$\./,"_."),n.replace(/^.*?\.\$\./,"")].filter((a,l,c)=>c.indexOf(a)===l).reduce((a,l)=>a.length>0?a:p({path:l,json:i}),[])),r&&Array.isArray(s)?s[0]:s}function x(t,e,r,i){var n;if(t){var o=t;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=$(r)),i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(t,e,r));var s=e.replace("data-path-","");if(e=="data-path-src")o=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")o=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")o=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")s="innerHTML";else if(e=="data-embed-src")W(t,r);else if(e=="data-path-attributes"){let u=((n=t.getAttribute("data-attributes-keys"))===null||n===void 0?void 0:n.split(",").filter(Boolean))||[];for(var a in r){var l=r[a];x(t,a,typeof l=="object"&&l?JSON.stringify(l):l,i)}for(var c=0;c<u.length;c++)(r==null||!(u[c]in r))&&x(t,u[c],null,i);x(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!o){var h=String(t.getAttribute("data-path-placeholder")||o[s]);r!=null?s=="innerHTML"?o.innerHTML!=r&&(o.innerHTML=r):o.getAttribute(s)!=r&&o.setAttribute(s,r):s=="innerHTML"?o.innerHTML=h:o.removeAttribute(s)}}}function ut(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let n=i.target,o=n.getAttribute("data-embed-src");o&&W(n,o),i.addedNodes&&i.addedNodes.forEach(s=>{s.nodeType==1&&ht(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function ht(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let n=r[i];W(n,n.getAttribute("data-embed-src"))}if(e)return ut(t)}function W(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let n=r.querySelectorAll("script");for(var i=0;i<n.length;i++)if(n[i].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let o=r.ownerDocument.createElement("script");o.type="module",o.src=e,r.appendChild(o);break}}var Q=["data-attributes-keys","data-path-attributes","data-path-scope"];function w(t,e,r,i){var n,o,s;let a=t;if(i||(e=((n=r==null?void 0:r.processData)===null||n===void 0?void 0:n.call(r,a,e))||e),a.nodeType==1){let c=a.getAttribute("data-path-scope");if(c){let u=X(a),f=Y(e,c,!1)||[];u==0&&dt(a,((o=r==null?void 0:r.shouldRepeat)===null||o===void 0?void 0:o.call(r,a,f))===!1?1:f.length,r),e={...e,[ct(c)]:f[u]}}let h=Array.prototype.slice.call(a.attributes).sort((u,f)=>Q.indexOf(u.name)-Q.indexOf(f.name));for(var l=0;l<h.length;l++){let{name:u,value:f}=h[l];u.startsWith("data-path")&&u!="data-path-scope"&&x(a,u,Y(e,f,!0),r),u=="data-embed-src"&&x(a,u,a.getAttribute(u),r)}}for(var l=0;l<a.children.length;l++)w(a.children[l],e,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,e),a}function O(t,e,r,i){var n;let o=((n=i==null?void 0:i.processTemplate)===null||n===void 0?void 0:n.call(i,t,e,r))||e;return t.innerHTML=o,t.classList.add("-feaas"),w(t,r,i)}function Ot(t,e){return pt(t,e||(e=document.createElement("style"))),e}function pt(t,e){return e||(e=document.createElement("style")),T(t,r=>{e.textContent=r}).then(()=>e)}function $t(t,e){return ft(t,e||(e=document.createElement("div"))),e}async function ft(t,e){return e||(e=document.createElement("div")),e.childNodes.length?w(e,t.data,t):"template"in t?O(e,t.template,t.data,t):P(t,r=>O(e,r,t.data,t)).then(()=>e)}function I(t,e={},r){return r?`<${r}${Object.entries(e).map(([i,n])=>n!=null&&` ${i}="${n}"`).filter(Boolean).join("")}>${$(t)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):$(t)}function $(t){var e;if(Array.isArray(t))return t.map($).join(`
2
- `).trim();if(typeof t=="string")return t;if(t==null)return"";switch(t.type){case"heading":let{level:r,...i}=t.attrs;return I(t.content,i,"h"+r);case"text":return(t.marks||[]).reduce((n,o)=>I(n,o.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[o.type]),(e=t.text)===null||e===void 0?void 0:e.replace(/\s+/," "));default:return I(t.content||t.text,t.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[t.type])}}var gt=typeof HTMLElement=="undefined"?class{}:HTMLElement,b=class extends gt{constructor(){super(...arguments),this.connected=null,this.refs={},this.descendants=[],this.onLoad=e=>{e!=null&&(this.payload=e,this.render())}}getProps(e){return{}}getRoot(){return this}attributeChangedCallback(e,r,i){this.set()}connectedCallback(){console.log("FEAAS: Connected",this),this.connected=new Event("feaasConnected",{bubbles:!0,composed:!0}),this.dispatchEvent(this.connected),this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this),this.set()}disconnectedCallback(){console.log("FEAAS: Disconnected",this),this.removeEventListener("feaasConnected",this),this.removeEventListener("feaasDisconnected",this),this.dispatchEvent(new Event("feaasDisconnected",{bubbles:!0,composed:!0})),this.connected=null}handleEvent(e){switch(e.type){case"feaasConnected":this.nestedCallback(e);break;case"feaasDisconnected":this.unnestedCallback(e);break}}unnestedCallback(e){let r=e.composedPath()[0],i=this.descendants.indexOf(r);i!=-1&&(console.log("FEAAS: Unnest",this,r),this.descendants.splice(i,-1),this.refs[r.getComponentName()]=null,r.refs.parent==this&&(r.refs.parent=null),r.refs.top==this&&(r.refs.top=r.refs.parent))}nestedCallback(e){var r,i;let n=e.composedPath()[0];if(this.descendants.indexOf(n)==-1&&(this.descendants.push(n),console.log("FEAAS: Nest",this,n),this.refs[n.getComponentName()]=n,n.refs.top=this,(r=n.refs).parent||(r.parent=this),n.renderReact))for(var s=n.refs.parent;s;s=s.refs.parent)s.renderReact&&((i=n.refs).parentReact||(i.parentReact=s),n.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.render():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}render(e=!1){var r,i,n;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:o,ReactDOM:s}=this.payload||{};if(!o)throw new Error(`${this.tagName}: React is not present in payload`);if(!s)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?s.render(o.createElement(this.getReactWrapper()),this.getReactRoot()):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(n=(i=this.refs.topReact).forceUpdateReact)===null||n===void 0||n.call(i)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{},i=this.descendants.filter(n=>n.refs.parentReact==this&&n.payload).map((n,o)=>e.createElement(this.getReactWrapper(n),{key:this.tagName+"-"+o,slot:n.getAttribute("slot")}));return this.renderReact({...this.props,children:i},this.payload)}getReactWrapper(e=this,r=e.tagName){let i=e.reactWrapper||(e.reactWrapper=n=>{if(e.renderReact){let{React:o,ReactDOM:s}=e.payload||{},[a,l]=o.useReducer(c=>c+1,0);return e.forceUpdateReact=l,s.createPortal(o.createElement(o.Fragment,null,e.invokeReactRendering()),e.getReactRoot())}else return e.render()});return Object.assign(i,{displayName:r}),i}getUID(){return this.uid||(this.uid=String(Math.random()))}getReactRoot(){return this.getRoot()}set(e){this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof i=="string"||typeof i=="number")&&this.getAttribute(r)!=String(i)&&this.setAttribute(r,String(i))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){var i,n;return(n=(i=r.closest(`[${e}]`))===null||i===void 0?void 0:i.getAttribute(e))!==null&&n!==void 0?n:this.getAttribute(e)}static register(e){typeof window!="undefined"&&!window.customElements.get(e)&&window.customElements.define(e,this)}};function bt(t=this){let e,r=t.getAttribute("data");if(r!=null)try{e=typeof r=="string"?JSON.parse(r):{}}catch(i){}return{data:e!=null?e:{},library:t.getAttribute("library"),component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),hostname:t.getAttribute("hostname"),cdn:t.getContextAttribute("cdn"),template:t.getAttribute("template"),suspended:t.getAttribute("suspended")!=null}}var M=class extends b{setData(e){this.set({data:e})}getProps(){return bt(this)}attributeChangedCallback(e,r,i){this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(e,r,i)}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var i=r;return i}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{P(this.props,this.onLoad)}catch(e){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}render(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)w(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;O(this,this.payload,this.props.data)}}};M.observedAttributes=["library","component","version","revision","hostname","cdn","template","data"];M.register("feaas-component");function Bt(t=this){return{hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var L=class extends b{attributeChangedCallback(e,r,i){e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all"))}connectedCallback(){this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
1
+ var bt=typeof HTMLElement=="undefined"?class{}:HTMLElement,m=class extends bt{constructor(){super(),this.connected=!1,this.refs={},this.descendants=[],this.onLoad=e=>{e!=null&&(this.payload=e,this.render())},this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this)}getProps(e){return{}}getRoot(){return this}attributeChangedCallback(e,r,i){this.set()}connectedCallback(){this.initialize()}initialize(){let e=this.getParent();if(!(e&&!e.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(e=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!e||r.tagName.startsWith("FEAAS-"))return r}getElements(e=this.getRoot(),r=!0){return Array.from(e.querySelectorAll("*")).map(i=>[!r||i.tagName.startsWith("FEAAS-")?i:null,i.shadowRoot?this.getElements(i.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(e){let r=e.composedPath()[0];switch(e.type){case"feaasConnected":r!=this&&this.nestedCallback(r);break;case"feaasDisconnected":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(e){let r=this.descendants.indexOf(e);r!=-1&&(console.log("FEAAS: Unnest",this,e),this.descendants.splice(r,-1),this.refs[e.getComponentName()]=null,e.refs.parent==this&&(e.refs.parent=null),e.refs.top==this&&(e.refs.top=e.refs.parent))}nestedCallback(e){var r,i;if(this.descendants.indexOf(e)==-1&&(this.descendants.push(e),console.log("FEAAS: Nest",this,e),this.refs[e.getComponentName()]=e,e.refs.top=this,(r=e.refs).parent||(r.parent=this),e.renderReact))for(var n=e.refs.parent;n;n=n.refs.parent)n.renderReact&&((i=e.refs).parentReact||(i.parentReact=n),e.refs.topReact=n)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}async reify(){this.payload!==void 0?this.render():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}render(e=!1){var r,i,o;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:n,ReactDOM:s,ReactDOMClient:a}=this.payload||{};if(!n)throw new Error(`${this.tagName}: React is not present in payload`);if(!s)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?(this.reactRoot||(this.reactRoot=a.createRoot(this.getReactRootElement())),this.reactRoot.render(n.createElement(this.getReactWrapper(),{z:"root"}))):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(o=(i=this.refs.topReact).forceUpdateReact)===null||o===void 0||o.call(i)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{},i=this.descendants.filter(o=>o.refs.parentReact==this&&o.payload).map((o,n)=>e.createElement(this.getReactWrapper(o),{key:this.tagName+"-"+n,slot:o.getAttribute("slot")}));return this.renderReact({...this.props,children:i},this.payload)}getReactWrapper(e=this,r=e.tagName){let i=e.reactWrapper||(e.reactWrapper=o=>{if(e.renderReact){let{React:n,ReactDOM:s}=e.payload||{},[a,d]=n.useReducer(l=>l+1,0);return e.forceUpdateReact=d,s.createPortal(n.createElement(n.Fragment,null,e.invokeReactRendering()),e.getReactRootElement())}else return e.render()});return Object.assign(i,{displayName:r}),i}getUID(){return this.uid||(this.uid=String(Math.random()))}getReactRootElement(){return this.getRoot()}set(e){this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof i=="string"||typeof i=="number")&&this.getAttribute(r)!=String(i)&&this.setAttribute(r,String(i))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){for(var i=this;i=i.parentElement||(i.parentNode instanceof ShadowRoot?i.parentNode.host:null);)if(i.getAttribute(e)!=null)return i.getAttribute(e);return this.getAttribute(e)}static register(e){typeof window!="undefined"&&!window.customElements.get(e)&&window.customElements.define(e,this)}};var T=class extends m{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(([e,r])=>({React:e,ReactDOM:r}))}};import yt from"vm";var{hasOwnProperty:v}=Object.prototype;function x(t,e){return t=t.slice(),t.push(e),t}function J(t,e){return e=e.slice(),e.unshift(t),e}var K=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function p(t,e,r,i,o){if(!(this instanceof p))try{return new p(t,e,r,i,o)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof t=="string"&&(o=i,i=r,r=e,e=t,t=null);let n=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=v.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||i||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let s={path:n?t.path:e};n?"json"in t&&(s.json=t.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new K(a);return a}}p.prototype.evaluate=function(t,e,r,i){let o=this.parent,n=this.parentProperty,{flatten:s,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!v.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),s=v.call(t,"flatten")?t.flatten:s,this.currResultType=v.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=v.call(t,"sandbox")?t.sandbox:this.currSandbox,a=v.call(t,"wrap")?t.wrap:a,this.currPreventEval=v.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=v.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=v.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=v.call(t,"parent")?t.parent:o,n=v.call(t,"parentProperty")?t.parentProperty:n,t=t.path}if(o=o||null,n=n||null,Array.isArray(t)&&(t=p.toPathString(t)),!t&&t!==""||!e)return;let d=p.toPathArray(t);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;let l=this._trace(d,e,["$"],o,n,r).filter(function(u){return u&&!u.isParentSelector});return l.length?!a&&l.length===1&&!l[0].hasArrExpr?this._getPreferredOutput(l[0]):l.reduce((u,h)=>{let f=this._getPreferredOutput(h);return s&&Array.isArray(f)?u=u.concat(f):u.push(f),u},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:p.toPathArray(t.path);return t.pointer=p.toPointer(r),t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return p.toPathString(t[e]);case"pointer":return p.toPointer(t.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(t,e,r){if(e){let i=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),e(i,r,t)}};p.prototype._trace=function(t,e,r,i,o,n,s,a){let d;if(!t.length)return d={path:r,value:e,parent:i,parentProperty:o,hasArrExpr:s},this._handleCallback(d,n,"value"),d;let l=t[0],u=t.slice(1),h=[];function f(c){Array.isArray(c)?c.forEach(g=>{h.push(g)}):h.push(c)}if((typeof l!="string"||a)&&e&&v.call(e,l))f(this._trace(u,e[l],x(r,l),e,l,n,s));else if(l==="*")this._walk(e,c=>{f(this._trace(u,e[c],x(r,c),e,c,n,!0,!0))});else if(l==="..")f(this._trace(u,e,r,i,o,n,s)),this._walk(e,c=>{typeof e[c]=="object"&&f(this._trace(t.slice(),e[c],x(r,c),e,c,n,!0))});else{if(l==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if(l==="~")return d={path:x(r,l),value:o,parent:i,parentProperty:null},this._handleCallback(d,n,"property"),d;if(l==="$")f(this._trace(u,e,r,null,null,n,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))f(this._slice(l,u,e,r,i,o,n));else if(l.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=l.replace(/^\?\((.*?)\)$/u,"$1");this._walk(e,g=>{this._eval(c,e[g],g,r,i,o)&&f(this._trace(u,e[g],x(r,g),e,g,n,!0))})}else if(l[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(J(this._eval(l,e,r[r.length-1],r.slice(0,-1),i,o),u),e,r,i,o,n,s))}else if(l[0]==="@"){let c=!1,g=l.slice(1,-2);switch(g){case"scalar":(!e||!["object","function"].includes(typeof e))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===g&&(c=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(c=!0);break;case"number":Number.isFinite(e)&&(c=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(c=!0);break;case"object":e&&typeof e===g&&(c=!0);break;case"array":Array.isArray(e)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(e,r,i,o);break;case"null":e===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+g)}if(c)return d={path:r,value:e,parent:i,parentProperty:o},this._handleCallback(d,n,"value"),d}else if(l[0]==="`"&&e&&v.call(e,l.slice(1))){let c=l.slice(1);f(this._trace(u,e[c],x(r,c),e,c,n,s,!0))}else if(l.includes(",")){let c=l.split(",");for(let g of c)f(this._trace(J(g,u),e,r,i,o,n,!0))}else!a&&e&&v.call(e,l)&&f(this._trace(u,e[l],x(r,l),e,l,n,s,!0))}if(this._hasParentSelector)for(let c=0;c<h.length;c++){let g=h[c];if(g&&g.isParentSelector){let w=this._trace(g.expr,e,g.path,i,o,n,s);if(Array.isArray(w)){h[c]=w[0];let V=w.length;for(let A=1;A<V;A++)c++,h.splice(c,0,w[A])}else h[c]=w}}return h};p.prototype._walk=function(t,e){if(Array.isArray(t)){let r=t.length;for(let i=0;i<r;i++)e(i)}else t&&typeof t=="object"&&Object.keys(t).forEach(r=>{e(r)})};p.prototype._slice=function(t,e,r,i,o,n,s){if(!Array.isArray(r))return;let a=r.length,d=t.split(":"),l=d[2]&&Number.parseInt(d[2])||1,u=d[0]&&Number.parseInt(d[0])||0,h=d[1]&&Number.parseInt(d[1])||a;u=u<0?Math.max(0,u+a):Math.min(a,u),h=h<0?Math.max(0,h+a):Math.min(a,h);let f=[];for(let c=u;c<h;c+=l)this._trace(J(c,e),r,i,o,n,s,!0).forEach(w=>{f.push(w)});return f};p.prototype._eval=function(t,e,r,i,o,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;let s=t.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+t;if(!p.cache[a]){let d=t.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");s&&(d=d.replace(/@path/gu,"_$_path")),p.cache[a]=new this.vm.Script(d)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(d){throw new Error("jsonPath: "+d.message+": "+t)}};p.cache={};p.toPathString=function(t){let e=t,r=e.length,i="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+=/^[0-9*]+$/u.test(e[o])?"["+e[o]+"]":"['"+e[o]+"']");return i};p.toPointer=function(t){let e=t,r=e.length,i="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+="/"+e[o].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(t){let{cache:e}=p;if(e[t])return e[t].concat();let r=[],o=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(n,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(n,s){return"['"+s.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(n,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(n){let s=n.match(/#(\d+)/u);return!s||!s[1]?n:r[s[1]]});return e[t]=o,e[t].concat()};p.prototype.vm=yt;async function ot(t,e,r,i){return R({url:t,options:e,validator:r,callback:i}).then(L).then(o=>o.response)}async function R({url:t,options:e,validator:r,callback:i},o="initial"){let n=new Date;console.log("fetch",o,t);let s=await fetch(t,e);if(!s.ok)throw new Error("Fetch failed");if((r==null?void 0:r(s))===!1)throw new Error("Response is not valid");let a=new Date(s.headers.get("date"))<n;return i==null||i(s,o),{url:t,options:e,isCached:a,response:s,validator:r}}async function L(t){let{url:e,isCached:r,options:i,validator:o,response:n,callback:s}=t;if(r){let{response:a}=await R({url:e+"?"+Math.random(),options:{...i,method:"HEAD",cache:"no-cache"},validator:o},"check");if(a.headers.get("last-modified")!=n.headers.get("last-modified"))return G(t)}return t}async function G(t){let{url:e,options:r,validator:i,callback:o}=t;return R({url:e,options:{...r,cache:"reload"},validator:i,callback:o},"updated")}function nt({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,component:i,version:o,revision:n="published"}){return`${t||e}/components/${r}/${i}/${o}/${n}.html`}function mt({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,revision:i="published"}){return`${t||e}/styles/${r}/${i}.css`}async function N(t,e){let r=s=>s.headers.get("x-ms-meta-versionDeletedAt")==null,i=s=>{s.text().then(e)},o=await Promise.all([t.instance&&R({options:{headers:{Accept:"text/html"}},url:nt({...t,version:t.instance}),validator:r}).catch(s=>s),R({url:nt(t),validator:r}).catch(s=>s)]),n=o.find(s=>s&&"isCached"in s&&s);if(!n||n instanceof Error)throw o.find(a=>a&&a instanceof Error)||new Error("Can not fetch component");return o[0]==n&&console.log("Using fork!",o),i(n.response),L({...n,callback:i}).catch(s=>{if(o[0]==n&&(G({...n,callback:null,validator:null}),console.log("Fork was deleted"),!(o[1]instanceof Error)))return i(o[1].response),L({...o[1],callback:i});throw s})}async function D(t,e){return ot(mt(t),{headers:{Accept:"text/css"}},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(e)})}function Kt(t,e){let r=document.createElement("div");r.innerHTML=t;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return k(i,e),r}function vt(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function At(t){return vt(t)+".*"}function lt(t){let e=t.getAttribute("data-path-scope");for(var r=0,i=t;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==e&&r++;return r}function Et(t,e,r){let i=t.getAttribute("data-path-scope");if(i==null)return;var o=lt(t);if(o!=0)return;let n=t.parentElement;if(n!=null){e==0?t.setAttribute("hidden","hidden"):t.getAttribute("hidden")!=null&&t.removeAttribute("hidden");for(var s=o+1,a=t,d=t;d=d.nextElementSibling;)d.getAttribute("data-path-scope")==i&&(s++,a=d);for(var l=s;l<e;l++)n.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var l=Math.max(1,e);l<s;l++)a=a.previousElementSibling,n.removeChild(a.nextElementSibling)}}function st(t,e,r=!1,i=t){var o=e;let n=Object.keys(t).sort((a,d)=>d.length-a.length);for(let a of n)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}o=e.substring(a.length+1),i=t[a];break}var s=p({path:o,json:i});return Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=[o.replace(/^.*?\./,"_."),o.replace(/^.*?\./,""),o.replace(/^([^.]+).*?\.\$\./,"$1."),o.replace(/^.*?\.\$\./,"_."),o.replace(/^.*?\.\$\./,"")].filter((a,d,l)=>l.indexOf(a)===d).reduce((a,d)=>a.length>0?a:p({path:d,json:i}),[])),r&&Array.isArray(s)?s[0]:s}function O(t,e,r,i){var o;if(t){var n=t;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=F(r)),i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(t,e,r));var s=e.replace("data-path-","");if(e=="data-path-src")n=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")n=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")n=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")s="innerHTML";else if(e=="data-embed-src")Q(t,r);else if(e=="data-path-attributes"){let h=((o=t.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];for(var a in r){var d=r[a];O(t,a,typeof d=="object"&&d?JSON.stringify(d):d,i)}for(var l=0;l<h.length;l++)(r==null||!(h[l]in r))&&O(t,h[l],null,i);O(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!n){var u=String(t.getAttribute("data-path-placeholder")||n[s]);r!=null?s=="innerHTML"?n.innerHTML!=r&&(n.innerHTML=r):n.getAttribute(s)!=r&&n.setAttribute(s,r):s=="innerHTML"?n.innerHTML=u:n.removeAttribute(s)}}}function Ct(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let o=i.target,n=o.getAttribute("data-embed-src");n&&Q(o,n),i.addedNodes&&i.addedNodes.forEach(s=>{s.nodeType==1&&wt(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function wt(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let o=r[i];Q(o,o.getAttribute("data-embed-src"))}if(e)return Ct(t)}function Q(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let o=r.querySelectorAll("script");for(var i=0;i<o.length;i++)if(o[i].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let n=r.ownerDocument.createElement("script");n.type="module",n.src=e,r.appendChild(n);break}}var at=["data-attributes-keys","data-path-attributes","data-path-scope"];function k(t,e,r,i){var o,n,s;let a=t;if(i||(e=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,a,e))||e),a.nodeType==1){let l=a.getAttribute("data-path-scope");if(l){let h=lt(a),f=st(e,l,!1)||[];h==0&&Et(a,((n=r==null?void 0:r.shouldRepeat)===null||n===void 0?void 0:n.call(r,a,f))===!1?1:f.length,r),e={...e,[At(l)]:f[h]}}let u=Array.prototype.slice.call(a.attributes).sort((h,f)=>at.indexOf(h.name)-at.indexOf(f.name));for(var d=0;d<u.length;d++){let{name:h,value:f}=u[d];h.startsWith("data-path")&&h!="data-path-scope"&&O(a,h,st(e,f,!0),r),h=="data-embed-src"&&O(a,h,a.getAttribute(h),r)}}for(var d=0;d<a.children.length;d++)k(a.children[d],e,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,e),a}function $(t,e,r,i){var o;let n=((o=i==null?void 0:i.processTemplate)===null||o===void 0?void 0:o.call(i,t,e,r))||e;if(t.innerHTML=n,t.classList.add("-feaas"),(t.closest(".component.feaas")||t).className.includes("-theme--"))for(let a of t.children)a.className=a.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1");return k(t,r,i)}function Gt(t,e){return xt(t,e||(e=document.createElement("style"))),e}function xt(t,e){return e||(e=document.createElement("style")),D(t,r=>{e.textContent=r}).then(()=>e)}function Yt(t,e){return Rt(t,e||(e=document.createElement("div"))),e}async function Rt(t,e){return e||(e=document.createElement("div")),e.childNodes.length?k(e,t.data,t):"template"in t?$(e,t.template,t.data,t):N(t,r=>$(e,r,t.data,t)).then(()=>e)}function Y(t,e={},r){return r?`<${r}${Object.entries(e).map(([i,o])=>o!=null&&` ${i}="${o}"`).filter(Boolean).join("")}>${F(t)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):F(t)}function F(t){var e;if(Array.isArray(t))return t.map(F).join(`
2
+ `).trim();if(typeof t=="string")return t;if(t==null)return"";switch(t.type){case"heading":let{level:r,...i}=t.attrs;return Y(t.content,i,"h"+r);case"text":return(t.marks||[]).reduce((o,n)=>Y(o,n.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[n.type]),(e=t.text)===null||e===void 0?void 0:e.replace(/\s+/," "));default:return Y(t.content||t.text,t.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[t.type])}}function kt(t=this){let e,r=t.getAttribute("data");if(r!=null)try{e=typeof r=="string"?JSON.parse(r):{}}catch(i){}return{data:e!=null?e:{},library:t.getAttribute("library"),component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),hostname:t.getAttribute("hostname"),cdn:t.getContextAttribute("cdn"),template:t.getAttribute("template"),instance:t.getAttribute("instance"),editable:t.getAttribute("editable")!=null,suspended:t.getAttribute("suspended")!=null}}var I=class extends m{constructor(){super(),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}setData(e){this.set({data:e})}getProps(){return kt(this)}attributeChangedCallback(e,r,i){r!==i&&(this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(e,r,i))}getEditor(){var e;return(e=document.querySelector("feaas-context"))===null||e===void 0?void 0:e.refs.editor}edit(){let e=this.getEditor();if(e!=null&&e.setTarget(this))return e.open(),!0}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var i=r;return i}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{N(this.props,this.onLoad)}catch(e){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}render(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)k(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;$(this,this.payload,this.props.data)}}};I.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable"];I.register("feaas-component");function St(t=this){return{opacity:t!=null&&t.getAttribute("opacity")?parseFloat(t==null?void 0:t.getAttribute("opacity")):1,hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var U=class extends m{getProps(){return St(this)}attributeChangedCallback(e,r,i){if(r!==i)return e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,i)}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,10 +63,5 @@ import ot from"vm";var{hasOwnProperty:y}=Object.prototype;function A(t,e){return
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)}};L.observedAttributes=["hidden"];L.register("feaas-loader");function yt(t=this){var e;return{library:t==null?void 0:t.getContextAttribute("library"),revision:(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:"published",cdn:(t==null?void 0:t.getContextAttribute("cdn"))||(t==null?void 0:t.getContextAttribute("hostname"))}}var q=class extends b{getProps(){return yt(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){T(this.props,this.onLoad)}render(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};q.register("feaas-stylesheet");var z;typeof window!="undefined"&&((z=window.FEAASLoading)!==null&&z!==void 0||(window.FEAASLoading=Promise.resolve()));function vt(t){let e=[];if(t){let r=t.ownerDocument.defaultView,i,n;for(;r!==window.top;){i=r.parent;for(let o=0;o<i.frames.length;o++)if(i.frames[o]===r){for(let s of i.document.getElementsByTagName("iframe"))if(s.contentWindow===r){n=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:n.left+parseInt(a.borderLeftWidth),top:n.top+parseInt(a.borderTopWidth)})}r=i;break}}}return e.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function mt(t=this){var e;return{context:HTMLElement,frontend:t==null?void 0:t.getContextAttribute("frontend"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/assets/editor.js",library:t==null?void 0:t.getAttribute("library"),component:t==null?void 0:t.getAttribute("component"),version:t==null?void 0:t.getAttribute("version"),revision:(t==null?void 0:t.getAttribute("revision"))||"saved",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,for:t==null?void 0:t.getAttribute("for")}}var J=class extends b{constructor(){super(...arguments),this.framePoint={top:0,left:0},this.wrapperRect={top:0,left:0,width:0,height:0},this.bodyRect={top:0,left:0,width:0,height:0},this.getTarget=()=>document.querySelector("iframe").contentWindow.document.getElementById(this.props.for),this.onChromeMeasureElement=(e,r)=>(r==null&&(r=e.getBoundingClientRect()),e.ownerDocument==document?{left:r.left-this.bodyRect.left,top:r.top-this.bodyRect.top,width:r.width,height:r.height}:{left:r.left+this.framePoint.left-this.bodyRect.left,top:r.top+this.framePoint.top-this.bodyRect.top,width:r.width,height:r.height}),this.onBeforeMeasure=e=>{e.memoized.focusable&&(this.framePoint=vt(e.memoized.focusable)),this.wrapperRect=this.wrapper.getBoundingClientRect(),this.bodyRect=this.wrapper.ownerDocument.body.parentElement.getBoundingClientRect()},this.onMeasure=()=>{},this.onPosition=({focusable:e,root:r})=>{let i=this.wrapper.querySelector(".editor-chrome"),n=this.wrapper.querySelector(".ui.overlays");e?(i.style.width=e.width+16*2+"px",i.style.height=e.height+16*1+64+"px",i.style.left=e.left-16+"px",i.style.top=e.top-64+"px",n&&(n.style.left=r.left+"px",n.style.top=r.top+"px")):(i.style.left="-1000px",i.style.top="-1000px")}}getProps(){return mt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({children:e,component:r,version:i},{Editor:n,VersionStatusList:o,Version:s,EditorUIUndo:a,EditorUIMode:l,React:{useEffect:c,useMemo:h,useState:u},Chakra:{HStack:f,Box:d},Chrome:g,ReactDOM:m,useSDK:F,useSlots:R,useModelObserver:Z}){if(!this.payload)return;let{sdk:C}=F(),[v,tt]=u(),K=C.library;c(()=>tt(K.components.getItem(r)),[r,K]),c(()=>{v==null||v.versions.fetch()},[v]);let et=h(this.getTarget,[this.props.for]),_=Z(v==null?void 0:v.versions),G=h(()=>(_==null?void 0:_.filter(j=>j.id==i||!i))||[],[_]);if(v)return R(e,({picker:j,children:rt})=>React.createElement(d,{ref:k=>this.wrapper=k},React.createElement(d,{className:"editor-wrapper",position:"absolute",left:0,top:0},React.createElement(n,{datasources:C.datasources,sdk:C,library:C.library,component:v,versions:G,context:{onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition}},({editor:k,status:it,isArchivedDisplayed:nt})=>({after:rt,picker:j,chrome:k&&React.createElement(g,null),children:v.reduceVersionRevisions(G).filter(E=>{var S;return nt||!(!((S=E.saved||E.draft)===null||S===void 0)&&S.deletedAt)}).map((E,S)=>React.createElement(d,{key:E.head.id,position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none"},React.createElement(d,{className:"borders",pointerEvents:"none",left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(d,{className:"borders",pointerEvents:"none",right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(d,{className:"borders",pointerEvents:"none",top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(d,{className:"borders",pointerEvents:"none",bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(s,{version:E.head,node:et},{left:React.createElement(f,{justifyContent:"space-between"},React.createElement(a,{size:"sm",editor:it=="ready"?k:null}),React.createElement(l,{size:"sm"})),middle:React.createElement(o,null)})))})))))}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null}};J.register("feaas-editor");function At(t=this){var e,r;return{part:(t==null?void 0:t.getAttribute("part"))||"picker",slot:(t==null?void 0:t.getAttribute("part"))||"slot",mode:t==null?void 0:t.getAttribute("mode"),frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/assets/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,context:void 0,onClose:void 0}}var V=class extends b{getProps(){return At(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({context:e,mode:r,children:i},{Picker:n,React:o,ReactDOM:s}){return o.createElement(n,{mode:r||void 0,onClose:this.props.onClose,context:e},i)}};V.register("feaas-picker");function wt(t=this){var e,r;return{library:(t==null?void 0:t.getAttribute("library"))||"library",mode:t==null?void 0:t.getAttribute("mode"),frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/assets/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,context:null,getToken:null}}var D=class extends b{constructor(){super(...arguments),this.payload=null,this.onClose=()=>{this.removeAttribute("mode")}}getProps(){return wt(this)}render(){let{frontend:e,library:r,getToken:i,src:n,mode:o,context:s}=this.props;this.getAttribute("mode")==null?this.setAttribute("hidden","hidden"):this.removeAttribute("hidden"),this.children.length==0&&(this.innerHTML=`
67
- <feaas-context library='${r}'>
68
- <feaas-picker mode='${o}'>
69
- <feaas-loader />
70
- </feaas-context>
71
- `),this.refs.context.set({frontend:e,library:r,getToken:i}),this.refs.picker.set({frontend:e,context:s,src:n,mode:o,onClose:this.onClose})}};D.observedAttributes=["library","mode","frontend","src","context"];D.register("feaas-picker-lazy");function Rt(t=this){var e,r,i,n;return{library:t==null?void 0:t.getAttribute("library"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/assets/context.js",frontend:(r=t==null?void 0:t.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(n=t==null?void 0:t.getAttribute("cdn"))!==null&&n!==void 0?n:"https://feaascompontsapiprod.blob.core.windows.net",getToken:null}}var N=class extends b{getProps(){return Rt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}getTheme(e){return e}getRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}getReactRoot(){return this.reactRoot||(this.reactRoot=document.createElement("div"),this.getRoot().appendChild(this.reactRoot)),this.reactRoot}nestedCallback(e){super.nestedCallback(e);let r=e.composedPath()[0];r.parentNode!=this.getRoot()&&this.getRoot().appendChild(r)}renderReact({children:e,library:r},{AppContext:i,Chakra:{Button:n,Tooltip:o},React:s}){let a={containerRef:{current:this.getRoot()}};return o.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(i,{libraryId:this.props.library,container:this.getRoot(),getToken:this.props.getToken,getTheme:this.getTheme,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};N.observedAttributes=["library","component","version","revision","hostname","template"];N.register("feaas-context");export{b as Base,M as Component,b as FEAASBase,M as FEAASComponent,bt as FEAASComponentsProps,N as FEAASContext,Rt as FEAASContextProps,J as FEAASEditor,mt as FEAASEditorProps,L as FEAASLoader,Bt as FEAASLoaderProps,V as FEAASPicker,D as FEAASPickerLazy,wt as FEAASPickerLazyProps,At as FEAASPickerProps,q as FEAASStylesheet,yt as FEAASStylesheetProps,p as JSONPath,L as Loader,q as Stylesheet,ht as autoloadScripts,lt as cleanCollectionBit,B as fetchAndRevalidate,vt as getFramePosition,W as loadScript,ct as normalizeCollectionScope,ut as observeDOMElement,Y as queryScopes,$t as renderComponent,Tt as renderComponentElement,ft as renderComponentPromise,O as renderDOMContent,w as renderDOMElement,Ot as renderStylesheet,pt as renderStylesheetPromise,$ as serializeCH1RichText,x as setDOMAttribute};
66
+ </div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}render(){this.loader.style.opacity=String(this.props.opacity)}};U.observedAttributes=["hidden","opacity"];U.register("feaas-loader");function _t(t=this){var e;return{library:t==null?void 0:t.getContextAttribute("library"),revision:(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:"published",cdn:(t==null?void 0:t.getContextAttribute("cdn"))||(t==null?void 0:t.getContextAttribute("hostname"))}}var X=class extends m{getProps(){return _t(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){D(this.props,this.onLoad)}render(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};X.register("feaas-stylesheet");var Z;typeof window!="undefined"&&(window.FEAASElement=T,(Z=window.FEAASLoading)!==null&&Z!==void 0||(window.FEAASLoading=Promise.resolve()));function Pt(t){let e=[];if(t){let r=t.ownerDocument.defaultView,i,o;for(;r!==window.top;){i=r.parent;for(let n=0;n<i.frames.length;n++)if(i.frames[n]===r){for(let s of i.document.getElementsByTagName("iframe"))if(s.contentWindow===r){o=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:o.left+parseInt(a.borderLeftWidth),top:o.top+parseInt(a.borderTopWidth)})}r=i;break}}}return e.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function Tt(t=this){var e;return{context:HTMLElement,frontend:t==null?void 0:t.getContextAttribute("frontend"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/editor.js",library:t==null?void 0:t.getAttribute("library"),component:t==null?void 0:t.getAttribute("component"),version:t==null?void 0:t.getAttribute("version"),instance:t==null?void 0:t.getAttribute("instance"),forked:t==null?void 0:t.getAttribute("forked"),revision:(t==null?void 0:t.getAttribute("revision"))||"saved",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,for:t==null?void 0:t.getAttribute("for"),state:(t==null?void 0:t.getAttribute("state"))||"idle",changed:(t==null?void 0:t.getAttribute("changed"))!=null}}var W=class extends m{constructor(){super(...arguments),this.framePoint={top:0,left:0},this.wrapperRect={top:0,left:0,width:0,height:0},this.bodyRect={top:0,left:0,width:0,height:0},this.setTarget=(e,r={component:e.getAttribute("component"),version:e.getAttribute("version"),revision:e.getAttribute("revision"),instance:e.getAttribute("instance")})=>{if(!this.closing&&(!this.target||e==null))return this.set(r),this.target=e,!0},this.onChromeMeasureElement=(e,r=e.getBoundingClientRect())=>e.ownerDocument==document?{left:r.left-this.bodyRect.left,top:r.top-this.bodyRect.top,width:r.width,height:r.height}:{left:r.left+this.framePoint.left-this.bodyRect.left,top:r.top+this.framePoint.top-this.bodyRect.top,width:r.width,height:r.height},this.onBeforeMeasure=e=>{e.memoized.focusable&&(this.framePoint=Pt(e.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:e,root:r})=>{!this.chrome||this.props.hidden||(e?(this.chrome.wrapper.style.width=e.width+16*2+"px",this.chrome.wrapper.style.height=e.height+16*1+64+"px",this.chrome.wrapper.style.left=e.left-16+"px",this.chrome.wrapper.style.top=e.top-64+"px",this.chrome.wrapper.style.opacity="1",this.chrome.absolute=this.querySelector(".ui.overlays"),this.chrome.absolute&&(this.chrome.absolute.style.left=r.left+"px",this.chrome.absolute.style.top=r.top+"px")):(this.chrome.wrapper.style.opacity="0",this.chrome.wrapper.style.left="-1000px",this.chrome.wrapper.style.top="-1000px"))},this.onWindowMessage=e=>{var r;switch((r=e.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let i=this.getPlaceholder();this.setTarget(i.editable,e.data)&&(this.loader=i.loader,document.body.appendChild(i.clipper),this.editedUID=e.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=e.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var e;this.setAttribute("hidden","hidden"),this.placeholder&&(this.placeholder.positionable.style.opacity="0",this.placeholder.positionable.style.pointerEvents="none"),this.chrome&&(this.chrome.wrapper.style.opacity="0"),!((e=this.target)===null||e===void 0)&&e.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(e,r)=>{this.versionContext=e,this.setVersionContext=r},this.onEditorStateChange=(e,r)=>{this.editorContext=e,this.setEditorContext=r,e.editor&&this.props.state=="loading"&&!this.props.hidden&&(this.setAttribute("state","ready"),this.ownerDocument.fonts.ready.then(()=>setTimeout(()=>{this.setReadyState(),this.setIframeComponentContent()},100)))}}getProps(){return Tt(this)}getReactRootElement(){return this.reactRootElement||(this.reactRootElement=document.createElement("div"),this.getRoot().appendChild(this.reactRootElement)),this.reactRootElement}showLoader(){this.loader||(this.loader=document.createElement("feaas-loader"),this.loader.setAttribute("opacity","0.6"),this.loader.style.zIndex="1000",this.target.appendChild(this.loader),this.target.tagName=="FEAAS-COMPONENT"&&(this.target.style.position="relative"))}hideLoader(){this.loader&&(this.loader.setAttribute("hidden","hidden"),this.target.tagName=="FEAAS-COMPONENT"&&(this.target.style.position="relative",this.target.style.position=""))}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this.onWindowMessage)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.onWindowMessage)}setIframe(e){this.iframe=e}setIframeComponentContent(){this.placeholder&&this.iframe&&this.placeholder.editable.innerHTML&&this.iframe.contentWindow.postMessage({type:"feaasUpdate",id:this.editedUID,content:this.placeholder.editable.innerHTML})}setPlaceholder(){let e=this.iframe.clientWidth,r=this.iframe.clientHeight,i=this.iframe.getBoundingClientRect(),o=this.getPlaceholder(),n=document.body.getBoundingClientRect(),s=this.measurements[this.editedUID];s&&(Object.assign(o.clipper.style,{position:"absolute",top:i.top+this.iframe.clientTop-n.top+"px",left:i.left+this.iframe.clientLeft-n.left+"px",width:e+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(o.positionable.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(o.loader.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",height:s.height+"px",filter:"opacity(0.6)",zIndex:3,pointerEvents:"none"}),document.dispatchEvent(new Event("feaasRefresh",{bubbles:!0})))}getPlaceholder(){return this.placeholder?this.placeholder:(this.placeholder={clipper:document.createElement("div"),positionable:document.createElement("div"),editable:Object.assign(document.createElement("div"),{className:"-feaas"}),loader:document.createElement("feaas-loader")},this.placeholder.clipper.appendChild(this.placeholder.positionable),this.placeholder.positionable.appendChild(this.placeholder.editable),this.placeholder.clipper.appendChild(this.placeholder.loader),this.placeholder)}attributeChangedCallback(e,r,i){r!==i&&(e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,i))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(e){return e.forkOriginId==null&&this.props.instance!=null}cleanup(){var e;this.placeholder&&((e=this.placeholder.clipper)===null||e===void 0||e.remove(),this.placeholder=null)}close(){console.log("Editor is not ready")}unfork(){console.log("Editor is not ready")}discard(){console.log("Editor is not ready")}save(){console.log("Editor is not ready")}setVersionContext(e){console.log("Editor is not ready")}setEditorContext(e){console.log("Editor is not ready")}setLoadingState(){this.showLoader(),this.setAttribute("state","loading")}setReadyState(){this.hideLoader(),this.setEditorContext({activeVersionId:this.component.versions[0].id}),this.setAttribute("state","ready")}renderReact({children:e,component:r,version:i,instance:o},{Editor:n,VersionStatusList:s,VersionStatusButton:a,Version:d,VersionMenu:l,EditorUIUndo:u,EditorUIMode:h,React:{useEffect:f,useMemo:c,useState:g,useContext:w},Chakra:{HStack:V,Box:A,Button:tt,MenuItem:et},Chrome:dt,ReactDOM:Lt,useSDK:ct,useSlots:ht,useModelObserver:ut,ConfirmationContext:pt,VersionContext:Nt}){if(!this.payload)return;let{React:b}=this.payload,{sdk:M}=ct(),[y,rt]=g(),{setConfirm:z}=w(pt),S=o||i,ft=M.library;y&&(this.component=y),f(()=>{if(this.props.hidden)return;let C=ft.components.getItem(r).clone();return C.versions.search({ids:[i,o].filter(Boolean),componentIds:[r]}).then(H=>{C.versions.setItems(H);let E=C.findVersion(o,["staged","published"]),P=C.findVersion(i,["staged","published"]);if(E)E.deletedAt?(E.getDraft().changeAndNotify(P.toProperties()).restore(),console.error("FEAAS Editor: Restoring fork")):(console.error("FEAAS Editor: Pre-forked"),this.setAttribute("forked",E.id));else if(this.removeAttribute("forked"),this.shouldFork(P)){console.error("FEAAS Editor: Forking");let q=P.fork(o).id;this.setAttribute("instance",q)}else console.error("FEAAS Editor: Regular");rt(C)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),rt(null)},400)}},[i,this.props.hidden]);let it=ut(y==null?void 0:y.versions,[]).filter(C=>C.id==S),_=it[0];_&&!this.props.hidden&&(this.version=_),f(()=>(this.unfork=()=>{z({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let C=y.findVersion(i,["staged","published"]);y.findVersion(o).unstage().unpublish().changeAndNotify(C.toProperties()),y.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(y.findVersion(S).revert(),y.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{z({title:"Component has unsaved changes",button:"Discard",body:"Are you sure to close editor and discard changes?",bypass:!this.props.changed,action:()=>{this.discard(),requestAnimationFrame(this.onClose)}})},this.save=()=>{z({bypass:!!this.props.forked,title:"Customizing component",button:"Save",body:"Changes to the component will only be visible on that page. Changes to component done in Component Builder will not be reflected here. It will be possible to revert the customization.",action:()=>{y.findVersion(S).commitData({view:this.editorContext.editor.getData({rootName:S}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",S),y.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[y]);let gt=c(()=>this.target,[y]);return c(()=>y&&ht(e,({picker:C,children:H})=>b.createElement(A,{ref:E=>{this.chrome=E?{positionable:E,wrapper:E.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},b.createElement(A,{className:"editor-wrapper",position:"absolute",left:0,top:0},b.createElement(n,{datasources:M.datasources,sdk:M,library:M.library,component:y,versions:it,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:H,chrome:({editor:E})=>E&&b.createElement(dt,null),children:({isArchivedDisplayed:E,editor:P,status:q})=>b.createElement(A,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},b.createElement(A,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),b.createElement(A,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),b.createElement(A,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),b.createElement(A,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),_&&b.createElement(d,{version:_,node:gt,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:b.createElement(V,{justifyContent:"space-between"},b.createElement(u,{size:"sm",editor:q=="ready"?P:null}),b.createElement(h,{size:"sm"})),middle:(Dt,$t)=>[!1],right:b.createElement(b.Fragment,null,b.createElement(tt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),b.createElement(tt,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),b.createElement(l,{isDisabled:!this.props.forked&&!this.props.changed},b.createElement(et,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),b.createElement(et,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[_,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};W.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];W.register("feaas-editor");function Ot(t=this){var e,r;return{part:(t==null?void 0:t.getAttribute("part"))||"picker",slot:(t==null?void 0:t.getAttribute("part"))||"picker",mode:t==null?void 0:t.getAttribute("mode"),placeholder:(t==null?void 0:t.getAttribute("placeholder"))||"No theme",frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,variant:t==null?void 0:t.getAttribute("variant"),context:void 0,onClose:void 0,onContextAttributeSet:void 0}}var j=class extends m{getProps(){return Ot(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({placeholder:e,context:r,mode:i,children:o,variant:n},{Picker:s,React:a,ReactDOM:d}){return a.createElement(s,{placeholder:e,mode:i||void 0,onClose:this.props.onClose,onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:n},o)}};j.observedAttributes=["library","mode","frontend","src","hidden","variant"];j.register("feaas-picker");function Mt(t=this){var e,r,i,o;return{library:t==null?void 0:t.getAttribute("library"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/context.js",frontend:(r=t==null?void 0:t.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(o=t==null?void 0:t.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaascompontsapiprod.blob.core.windows.net",getToken:null}}var B=class extends m{getProps(){return Mt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}getTheme(e){return e}getRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}getReactRootElement(){return this.reactRootElement||(this.reactRootElement=document.createElement("div"),this.getRoot().appendChild(this.reactRootElement)),this.reactRootElement}connectedCallback(){Array.from(this.children).forEach(e=>{this.getRoot().appendChild(e)}),super.connectedCallback()}renderReact({children:e,library:r},{AppContext:i,Chakra:{Button:o,Tooltip:n},React:s}){let a={containerRef:{current:this.getRoot()}};return n.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(i,{backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),getToken:this.props.getToken,getTheme:this.getTheme,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};B.observedAttributes=["library","component","version","revision","hostname","template"];B.register("feaas-context");export{m as Base,I as Component,m as FEAASBase,I as FEAASComponent,kt as FEAASComponentsProps,B as FEAASContext,Mt as FEAASContextProps,W as FEAASEditor,Tt as FEAASEditorProps,U as FEAASLoader,St as FEAASLoaderProps,j as FEAASPicker,Ot as FEAASPickerProps,X as FEAASStylesheet,_t as FEAASStylesheetProps,p as JSONPath,U as Loader,X as Stylesheet,wt as autoloadScripts,vt as cleanCollectionBit,ot as fetchAndRevalidate,R as fetchAndValidate,Pt as getFramePosition,G as invalidateRequest,Q as loadScript,At as normalizeCollectionScope,Ct as observeDOMElement,st as queryScopes,L as refetchAndValidate,Yt as renderComponent,Kt as renderComponentElement,Rt as renderComponentPromise,$ as renderDOMContent,k as renderDOMElement,Gt as renderStylesheet,xt as renderStylesheetPromise,F as serializeCH1RichText,O as setDOMAttribute};
72
67
  //# sourceMappingURL=index.esm.js.map