@sitecore-feaas/clientside 0.1.27 → 0.1.28

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.
@@ -1,5 +1,5 @@
1
- var Dt=Object.create;var B=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,Ut=Object.prototype.hasOwnProperty;var Wt=(e,t)=>{for(var r in t)B(e,r,{get:t[r],enumerable:!0})},dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Ut.call(e,o)&&o!==r&&B(e,o,{get:()=>t[o],enumerable:!(i=$t(t,o))||i.enumerable});return e};var Ht=(e,t,r)=>(r=e!=null?Dt(It(e)):{},dt(t||!e||!e.__esModule?B(r,"default",{value:e,enumerable:!0}):r,e)),jt=e=>dt(B({},"__esModule",{value:!0}),e);var Yt={};Wt(Yt,{Base:()=>y,Component:()=>F,FEAASBase:()=>y,FEAASComponent:()=>F,FEAASComponentsProps:()=>Et,FEAASContext:()=>H,FEAASContextProps:()=>St,FEAASEditor:()=>U,FEAASEditorProps:()=>Rt,FEAASLoader:()=>I,FEAASLoaderProps:()=>Ct,FEAASPicker:()=>W,FEAASPickerProps:()=>kt,FEAASStylesheet:()=>J,FEAASStylesheetProps:()=>wt,JSONPath:()=>p,Loader:()=>I,MyComponent:()=>V,Stylesheet:()=>J,autoloadScripts:()=>yt,cleanCollectionBit:()=>pt,fetchAndRevalidate:()=>tt,fetchAndRevalidateComponent:()=>_,fetchAndValidate:()=>k,fetchComponentHTML:()=>Vt,fetchStylesheet:()=>N,getComponentURL:()=>et,getFramePosition:()=>xt,getStylesheetURL:()=>ht,invalidateRequest:()=>z,loadScript:()=>q,normalizeCollectionScope:()=>ft,observeDOMElement:()=>bt,queryScopes:()=>it,refetchAndValidate:()=>L,renderComponent:()=>Gt,renderComponentElement:()=>zt,renderComponentPromise:()=>At,renderDOMContent:()=>D,renderDOMElement:()=>x,renderHTMLContent:()=>Jt,renderStylesheet:()=>Kt,renderStylesheetPromise:()=>vt,serializeCH1RichText:()=>$,setDOMAttribute:()=>P});module.exports=jt(Yt);var Bt=typeof HTMLElement=="undefined"?class{}:HTMLElement,y=class extends Bt{getProps(t){return{}}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)}getRoot(){return this}attributeChangedCallback(t,r,i){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 i;return(i=r.initialize)===null||i===void 0?void 0:i.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(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(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,i;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 n=t.refs.parent;n;n=n.refs.parent)n.render&&((i=t.refs).parentReact||(i.parentReact=n),t.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.update():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}update(t=!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?a?(this.reactRoot||(this.reactRoot=a.createRoot(this.getReactRootElement())),this.reactRoot.render(n.createElement(this.getReactWrapper()))):s.render(n.createElement(this.getReactWrapper()),this.getReactRootElement()):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:t,ReactDOM:r}=this.payload||{},i=this.descendants.filter(o=>o.refs.parentReact==this&&o.payload).map((o,n)=>t.createElement(this.getReactWrapper(o),{key:o.tagName+"-"+o.getUID(),slot:o.getAttribute("slot")}));return this.render({...this.props,children:i},this.payload)}getReactWrapper(t=this,r=t.tagName){let i=t.reactWrapper||(t.reactWrapper=o=>{if(t.render){let{React:n,ReactDOM:s}=t.payload||{},[a,l]=n.useReducer(d=>d+1,0);return t.forceUpdateReact=l,s.createPortal(n.createElement(n.Fragment,null,t.invokeReactRendering()),t.getReactRootElement())}else return t.update()});return Object.assign(i,{key:this.tagName+"-"+this.getUID(),displayName:r}),i}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 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(t,r){return typeof t=="string"&&t.match(/^\/[^\/]/)?r+t:t}getContextAttribute(t,r=this){for(var i=this;i=i.parentElement||(i.parentNode instanceof ShadowRoot?i.parentNode.host:null);)if(i.getAttribute(t)!=null)return i.getAttribute(t);return this.getAttribute(t)}static register(t){typeof window!="undefined"&&!window.customElements.get(t)&&window.customElements.define(t,this)}};var S=class extends y{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)}},V=class extends S{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:t},{React:r}){let[i,o]=r.useState(0);return r.useEffect(()=>{o(n=>n+1)},[t]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",t),r.createElement("p",null,"Triggered updates: ",i))}};V.observedAttributes=["counter"];var ct=Ht(require("vm"),1),{hasOwnProperty:v}=Object.prototype;function R(e,t){return e=e.slice(),e.push(t),e}function X(e,t){return t=t.slice(),t.unshift(e),t}var Z=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 p(e,t,r,i,o){if(!(this instanceof p))try{return new p(e,t,r,i,o)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof e=="string"&&(o=i,i=r,r=t,t=e,e=null);let n=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=v.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||i||null,this.otherTypeCallback=e.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){let s={path:n?e.path:t};n?"json"in e&&(s.json=e.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new Z(a);return a}}p.prototype.evaluate=function(e,t,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,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(!v.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),s=v.call(e,"flatten")?e.flatten:s,this.currResultType=v.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=v.call(e,"sandbox")?e.sandbox:this.currSandbox,a=v.call(e,"wrap")?e.wrap:a,this.currPreventEval=v.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=v.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=v.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=v.call(e,"parent")?e.parent:o,n=v.call(e,"parentProperty")?e.parentProperty:n,e=e.path}if(o=o||null,n=n||null,Array.isArray(e)&&(e=p.toPathString(e)),!e&&e!==""||!t)return;let l=p.toPathArray(e);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let d=this._trace(l,t,["$"],o,n,r).filter(function(h){return h&&!h.isParentSelector});return d.length?!a&&d.length===1&&!d[0].hasArrExpr?this._getPreferredOutput(d[0]):d.reduce((h,f)=>{let u=this._getPreferredOutput(f);return s&&Array.isArray(u)?h=h.concat(u):h.push(u),h},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(e){let t=this.currResultType;switch(t){case"all":{let r=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(r),e.path=typeof e.path=="string"?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(e,t,r){if(t){let i=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:p.toPathString(e.path),t(i,r,e)}};p.prototype._trace=function(e,t,r,i,o,n,s,a){let l;if(!e.length)return l={path:r,value:t,parent:i,parentProperty:o,hasArrExpr:s},this._handleCallback(l,n,"value"),l;let d=e[0],h=e.slice(1),f=[];function u(c){Array.isArray(c)?c.forEach(g=>{f.push(g)}):f.push(c)}if((typeof d!="string"||a)&&t&&v.call(t,d))u(this._trace(h,t[d],R(r,d),t,d,n,s));else if(d==="*")this._walk(t,c=>{u(this._trace(h,t[c],R(r,c),t,c,n,!0,!0))});else if(d==="..")u(this._trace(h,t,r,i,o,n,s)),this._walk(t,c=>{typeof t[c]=="object"&&u(this._trace(e.slice(),t[c],R(r,c),t,c,n,!0))});else{if(d==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(d==="~")return l={path:R(r,d),value:o,parent:i,parentProperty:null},this._handleCallback(l,n,"property"),l;if(d==="$")u(this._trace(h,t,r,null,null,n,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(d))u(this._slice(d,h,t,r,i,o,n));else if(d.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=d.replace(/^\?\((.*?)\)$/u,"$1");this._walk(t,g=>{this._eval(c,t[g],g,r,i,o)&&u(this._trace(h,t[g],R(r,g),t,g,n,!0))})}else if(d[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");u(this._trace(X(this._eval(d,t,r[r.length-1],r.slice(0,-1),i,o),h),t,r,i,o,n,s))}else if(d[0]==="@"){let c=!1,g=d.slice(1,-2);switch(g){case"scalar":(!t||!["object","function"].includes(typeof t))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===g&&(c=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(c=!0);break;case"number":Number.isFinite(t)&&(c=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(c=!0);break;case"object":t&&typeof t===g&&(c=!0);break;case"array":Array.isArray(t)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(t,r,i,o);break;case"null":t===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+g)}if(c)return l={path:r,value:t,parent:i,parentProperty:o},this._handleCallback(l,n,"value"),l}else if(d[0]==="`"&&t&&v.call(t,d.slice(1))){let c=d.slice(1);u(this._trace(h,t[c],R(r,c),t,c,n,s,!0))}else if(d.includes(",")){let c=d.split(",");for(let g of c)u(this._trace(X(g,h),t,r,i,o,n,!0))}else!a&&t&&v.call(t,d)&&u(this._trace(h,t[d],R(r,d),t,d,n,s,!0))}if(this._hasParentSelector)for(let c=0;c<f.length;c++){let g=f[c];if(g&&g.isParentSelector){let w=this._trace(g.expr,t,g.path,i,o,n,s);if(Array.isArray(w)){f[c]=w[0];let K=w.length;for(let A=1;A<K;A++)c++,f.splice(c,0,w[A])}else f[c]=w}}return f};p.prototype._walk=function(e,t){if(Array.isArray(e)){let r=e.length;for(let i=0;i<r;i++)t(i)}else e&&typeof e=="object"&&Object.keys(e).forEach(r=>{t(r)})};p.prototype._slice=function(e,t,r,i,o,n,s){if(!Array.isArray(r))return;let a=r.length,l=e.split(":"),d=l[2]&&Number.parseInt(l[2])||1,h=l[0]&&Number.parseInt(l[0])||0,f=l[1]&&Number.parseInt(l[1])||a;h=h<0?Math.max(0,h+a):Math.min(a,h),f=f<0?Math.max(0,f+a):Math.min(a,f);let u=[];for(let c=h;c<f;c+=d)this._trace(X(c,t),r,i,o,n,s,!0).forEach(w=>{u.push(w)});return u};p.prototype._eval=function(e,t,r,i,o,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;let s=e.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+e;if(!p.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");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+": "+e)}};p.cache={};p.toPathString=function(e){let t=e,r=t.length,i="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(t[o])||(i+=/^[0-9*]+$/u.test(t[o])?"["+t[o]+"]":"['"+t[o]+"']");return i};p.toPointer=function(e){let t=e,r=t.length,i="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(t[o])||(i+="/"+t[o].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(e){let{cache:t}=p;if(t[e])return t[e].concat();let r=[],o=e.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 t[e]=o,t[e].concat()};p.prototype.vm=ct.default;async function tt(e,t,r,i){return k({url:e,options:t,validator:r,callback:i}).then(L).then(o=>o.response)}async function k({url:e,options:t,validator:r,callback:i},o="initial"){let n=new Date,s=await fetch(e,t);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:e,options:t,isCached:a,response:s,validator:r}}async function L(e){let{url:t,isCached:r,options:i,validator:o,response:n,callback:s}=e;if(r){let{response:a}=await k({url:t+"?"+Math.random(),options:{...i,method:"HEAD",cache:"no-cache"},validator:o},"check");if(a.headers.get("last-modified")!=n.headers.get("last-modified"))return z(e)}return e}async function z(e){let{url:t,options:r,validator:i,callback:o}=e;return k({url:t,options:{...r,cache:"reload"},validator:i,callback:o},"updated")}function et({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,component:i,version:o,revision:n="published"}){return`${e||t}/components/${r}/${i}/${o}/${n}.html`}function ht({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,revision:i="published"}){return`${e||t}/styles/${r}/${i}.css`}async function _(e,t,r=!1){let i=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,o=a=>{a.text().then(t)},n=await Promise.all([e.instance&&k({options:{headers:{Accept:"text/html"}},url:et({...e,version:e.instance}),validator:i}).catch(a=>a),k({url:et(e),validator:i}).catch(a=>a)]),s=n.find(a=>a&&"isCached"in a&&a);if(!s||s instanceof Error)throw n.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return n[0]==s&&console.log("Using fork!",n),o(s.response),L({...s,callback:o}).catch(a=>{if(n[0]==s&&(z({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(n[1]instanceof Error)))return o(n[1].response),L({...n[1],callback:o});throw a})}async function Vt(e){var t;return await _(e,r=>{t=r},!1),t}async function N(e,t){return tt(ht(e),{headers:{Accept:"text/css"}},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(t)})}function zt(e,t){let r=document.createElement("div");r.innerHTML=e;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return x(i,t),r}function pt(e){return e.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function ft(e){return pt(e)+".*"}function gt(e){let t=e.getAttribute("data-path-scope");for(var r=0,i=e;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==t&&r++;return r}function qt(e,t,r){let i=e.getAttribute("data-path-scope");if(i==null)return;var o=gt(e);if(o!=0)return;let n=e.parentElement;if(n!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var s=o+1,a=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==i&&(s++,a=l);for(var d=s;d<t;d++)n.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var d=Math.max(1,t);d<s;d++)a=a.previousElementSibling,n.removeChild(a.nextElementSibling)}}function it(e,t,r=!1,i=e){var o=t;let n=Object.keys(e).sort((a,l)=>l.length-a.length);for(let a of n)if(t.startsWith(a)){if(a==t){if(r)return e[a];continue}o=t.substring(a.length+1),i=e[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(/^.*?\.\$\./,""),o.replace(/^[^.]+$/,"_")].filter((a,l,d)=>d.indexOf(a)===l).reduce((a,l)=>a.length>0?a:p({path:l,json:i}),[])),r&&Array.isArray(s)?s[0]:s}function P(e,t,r,i){var o;if(e){var n=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=$(r)),i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(e,t,r));var s=t.replace("data-path-","");if(t=="data-path-src")n=e.tagName=="IMG"?e:e.querySelector("img, video");else if(t=="data-path-href")n=e.querySelector("a")||e.closest("a");else if(t=="data-path-alt")n=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")s="innerHTML";else if(t=="data-embed-src")q(e,r);else if(t=="data-path-attributes"){let f=((o=e.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var a in r){var l=r[a];P(e,a,typeof l=="object"&&l?JSON.stringify(l):l,i)}for(var d=0;d<f.length;d++)(r==null||!(f[d]in r))&&P(e,f[d],null,i);P(e,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!n){var h=String(e.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=h:n.removeAttribute(s)}}}function bt(e){let t=new e.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&&yt(s,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function yt(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let o=r[i];q(o,o.getAttribute("data-embed-src"))}if(t)return bt(e)}function q(e,t){for(var r=e;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")==t)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let n=r.ownerDocument.createElement("script");n.type="module",n.src=t,r.appendChild(n);break}}var ut=["data-attributes-keys","data-path-attributes","data-path-scope"];function x(e,t,r,i){var o,n,s;let a=e;if(i||(t=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,a,t))||t),a.nodeType==1){let h=a.getAttribute("data-path-scope");if(h){let u=gt(a),c=it(t,h,!1)||[];u==0&&qt(a,((n=r==null?void 0:r.shouldRepeat)===null||n===void 0?void 0:n.call(r,a,c))===!1?1:c.length,r),t={...t,[ft(h)]:c[u]}}let f=Array.prototype.slice.call(a.attributes).sort((u,c)=>ut.indexOf(u.name)-ut.indexOf(c.name));for(var l=0;l<f.length;l++){let{name:u,value:c}=f[l];u.startsWith("data-path")&&u!="data-path-scope"&&P(a,u,it(t,c,!0),r),u=="data-embed-src"&&P(a,u,a.getAttribute(u),r)}}for(var l=0,d;d=a.childNodes[l++];)mt(d)&&x(d,t,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,t),a}function mt(e){return e.nodeType==1}function D(e,t,r,i){var o;let n=((o=i==null?void 0:i.processTemplate)===null||o===void 0?void 0:o.call(i,e,t,r))||t;if(e.innerHTML=n,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(var a=0,l;l=e.childNodes[a++];)mt(l)&&(l.className=l.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return x(e,r,i)}function Jt(e,t,r,i=!1){var o;let n=((o=r==null?void 0:r.processTemplate)===null||o===void 0?void 0:o.call(r,null,e,t))||e;if(typeof document=="undefined"||i){let{parseHTML:s}=require("linkedom"),{document:a}=s(n);return x(a,t,r).toString()}else{let s=document.createElement("div");return s.innerHTML=n,x(s,t,r),s.innerHTML}}function Kt(e,t){return vt(e,t||(t=document.createElement("style"))),t}function vt(e,t){return t||(t=document.createElement("style")),N(e,r=>{t.textContent=r}).then(()=>t)}function Gt(e,t){return At(e,t||(t=document.createElement("div"))),t}async function At(e,t){return t||(t=document.createElement("div")),t.childNodes.length?x(t,e.data,e):"template"in e?D(t,e.template,e.data,e):_(e,r=>D(t,r,e.data,e)).then(()=>t)}function rt(e,t={},r){return r?`<${r}${Object.entries(t).map(([i,o])=>o!=null&&` ${i}="${o}"`).filter(Boolean).join("")}>${$(e)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):$(e)}function $(e){var t;if(Array.isArray(e))return e.map($).join(`
2
- `).trim();if(typeof e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...i}=e.attrs;return rt(e.content,i,"h"+r);case"text":return(e.marks||[]).reduce((o,n)=>rt(o,n.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[n.type]),(t=e.text)===null||t===void 0?void 0:t.replace(/\s+/," "));default:return rt(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}function Et(e=this){let t,r=e.getAttribute("data");if(r!=null)try{t=typeof r=="string"?JSON.parse(r):{}}catch(i){}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 F=class extends y{setData(t){this.set({data:t})}getProps(){return Et(this)}attributeChangedCallback(t,r,i){r!==i&&(this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(t,r,i))}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}constructor(){super(),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}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 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{_(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)x(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;D(this,this.payload,this.props.data)}}};F.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable"];F.register("feaas-component");function Ct(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 I=class extends y{getProps(){return Ct(this)}attributeChangedCallback(t,r,i){if(r!==i)return t=="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(t,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=`
1
+ var Dt=Object.create;var H=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,Ut=Object.prototype.hasOwnProperty;var Wt=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Ut.call(e,o)&&o!==r&&H(e,o,{get:()=>t[o],enumerable:!(i=$t(t,o))||i.enumerable});return e};var jt=(e,t,r)=>(r=e!=null?Dt(It(e)):{},dt(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),Bt=e=>dt(H({},"__esModule",{value:!0}),e);var Yt={};Wt(Yt,{Base:()=>y,Component:()=>F,FEAASBase:()=>y,FEAASComponent:()=>F,FEAASComponentsProps:()=>Et,FEAASContext:()=>j,FEAASContextProps:()=>St,FEAASEditor:()=>U,FEAASEditorProps:()=>Rt,FEAASLoader:()=>I,FEAASLoaderProps:()=>Ct,FEAASPicker:()=>W,FEAASPickerProps:()=>kt,FEAASStylesheet:()=>J,FEAASStylesheetProps:()=>wt,JSONPath:()=>p,Loader:()=>I,MyComponent:()=>V,Stylesheet:()=>J,autoloadScripts:()=>yt,cleanCollectionBit:()=>pt,fetchAndRevalidate:()=>tt,fetchAndRevalidateComponent:()=>_,fetchAndValidate:()=>k,fetchComponent:()=>Vt,fetchStylesheet:()=>N,getComponentURL:()=>et,getFramePosition:()=>xt,getStylesheetURL:()=>ht,invalidateRequest:()=>z,loadScript:()=>q,normalizeCollectionScope:()=>ft,observeDOMElement:()=>bt,queryScopes:()=>it,refetchAndValidate:()=>L,renderComponent:()=>Gt,renderComponentElement:()=>zt,renderComponentPromise:()=>At,renderDOMContent:()=>D,renderDOMElement:()=>x,renderHTMLContent:()=>Jt,renderStylesheet:()=>Kt,renderStylesheetPromise:()=>vt,serializeCH1RichText:()=>$,setDOMAttribute:()=>P});module.exports=Bt(Yt);var Ht=typeof HTMLElement=="undefined"?class{}:HTMLElement,y=class extends Ht{getProps(t){return{}}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)}getRoot(){return this}attributeChangedCallback(t,r,i){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 i;return(i=r.initialize)===null||i===void 0?void 0:i.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(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(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,i;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&&((i=t.refs).parentReact||(i.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,i,o;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:s,ReactDOM:n,ReactDOMClient:a}=this.payload||{};if(!s)throw new Error(`${this.tagName}: React is not present in payload`);if(!n)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()))):n.render(s.createElement(this.getReactWrapper()),this.getReactRootElement()):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:t,ReactDOM:r}=this.payload||{},i=this.descendants.filter(o=>o.refs.parentReact==this&&o.payload).map((o,s)=>t.createElement(this.getReactWrapper(o),{key:o.tagName+"-"+o.getUID(),slot:o.getAttribute("slot")}));return this.render({...this.props,children:i},this.payload)}getReactWrapper(t=this,r=t.tagName){let i=t.reactWrapper||(t.reactWrapper=o=>{if(t.render){let{React:s,ReactDOM:n}=t.payload||{},[a,l]=s.useReducer(d=>d+1,0);return t.forceUpdateReact=l,n.createPortal(s.createElement(s.Fragment,null,t.invokeReactRendering()),t.getReactRootElement())}else return t.update()});return Object.assign(i,{key:this.tagName+"-"+this.getUID(),displayName:r}),i}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 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(t,r){return typeof t=="string"&&t.match(/^\/[^\/]/)?r+t:t}getContextAttribute(t,r=this){for(var i=this;i=i.parentElement||(i.parentNode instanceof ShadowRoot?i.parentNode.host:null);)if(i.getAttribute(t)!=null)return i.getAttribute(t);return this.getAttribute(t)}static register(t){typeof window!="undefined"&&!window.customElements.get(t)&&window.customElements.define(t,this)}};var S=class extends y{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)}},V=class extends S{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:t},{React:r}){let[i,o]=r.useState(0);return r.useEffect(()=>{o(s=>s+1)},[t]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",t),r.createElement("p",null,"Triggered updates: ",i))}};V.observedAttributes=["counter"];var ct=jt(require("vm"),1),{hasOwnProperty:v}=Object.prototype;function R(e,t){return e=e.slice(),e.push(t),e}function X(e,t){return t=t.slice(),t.unshift(e),t}var Z=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 p(e,t,r,i,o){if(!(this instanceof p))try{return new p(e,t,r,i,o)}catch(n){if(!n.avoidNew)throw n;return n.value}typeof e=="string"&&(o=i,i=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=v.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||i||null,this.otherTypeCallback=e.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){let n={path:s?e.path:t};s?"json"in e&&(n.json=e.json):n.json=r;let a=this.evaluate(n);if(!a||typeof a!="object")throw new Z(a);return a}}p.prototype.evaluate=function(e,t,r,i){let o=this.parent,s=this.parentProperty,{flatten:n,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,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(!v.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),n=v.call(e,"flatten")?e.flatten:n,this.currResultType=v.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=v.call(e,"sandbox")?e.sandbox:this.currSandbox,a=v.call(e,"wrap")?e.wrap:a,this.currPreventEval=v.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=v.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=v.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=v.call(e,"parent")?e.parent:o,s=v.call(e,"parentProperty")?e.parentProperty:s,e=e.path}if(o=o||null,s=s||null,Array.isArray(e)&&(e=p.toPathString(e)),!e&&e!==""||!t)return;let l=p.toPathArray(e);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let d=this._trace(l,t,["$"],o,s,r).filter(function(h){return h&&!h.isParentSelector});return d.length?!a&&d.length===1&&!d[0].hasArrExpr?this._getPreferredOutput(d[0]):d.reduce((h,f)=>{let u=this._getPreferredOutput(f);return n&&Array.isArray(u)?h=h.concat(u):h.push(u),h},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(e){let t=this.currResultType;switch(t){case"all":{let r=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(r),e.path=typeof e.path=="string"?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(e,t,r){if(t){let i=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:p.toPathString(e.path),t(i,r,e)}};p.prototype._trace=function(e,t,r,i,o,s,n,a){let l;if(!e.length)return l={path:r,value:t,parent:i,parentProperty:o,hasArrExpr:n},this._handleCallback(l,s,"value"),l;let d=e[0],h=e.slice(1),f=[];function u(c){Array.isArray(c)?c.forEach(g=>{f.push(g)}):f.push(c)}if((typeof d!="string"||a)&&t&&v.call(t,d))u(this._trace(h,t[d],R(r,d),t,d,s,n));else if(d==="*")this._walk(t,c=>{u(this._trace(h,t[c],R(r,c),t,c,s,!0,!0))});else if(d==="..")u(this._trace(h,t,r,i,o,s,n)),this._walk(t,c=>{typeof t[c]=="object"&&u(this._trace(e.slice(),t[c],R(r,c),t,c,s,!0))});else{if(d==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(d==="~")return l={path:R(r,d),value:o,parent:i,parentProperty:null},this._handleCallback(l,s,"property"),l;if(d==="$")u(this._trace(h,t,r,null,null,s,n));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(d))u(this._slice(d,h,t,r,i,o,s));else if(d.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=d.replace(/^\?\((.*?)\)$/u,"$1");this._walk(t,g=>{this._eval(c,t[g],g,r,i,o)&&u(this._trace(h,t[g],R(r,g),t,g,s,!0))})}else if(d[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");u(this._trace(X(this._eval(d,t,r[r.length-1],r.slice(0,-1),i,o),h),t,r,i,o,s,n))}else if(d[0]==="@"){let c=!1,g=d.slice(1,-2);switch(g){case"scalar":(!t||!["object","function"].includes(typeof t))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===g&&(c=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(c=!0);break;case"number":Number.isFinite(t)&&(c=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(c=!0);break;case"object":t&&typeof t===g&&(c=!0);break;case"array":Array.isArray(t)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(t,r,i,o);break;case"null":t===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+g)}if(c)return l={path:r,value:t,parent:i,parentProperty:o},this._handleCallback(l,s,"value"),l}else if(d[0]==="`"&&t&&v.call(t,d.slice(1))){let c=d.slice(1);u(this._trace(h,t[c],R(r,c),t,c,s,n,!0))}else if(d.includes(",")){let c=d.split(",");for(let g of c)u(this._trace(X(g,h),t,r,i,o,s,!0))}else!a&&t&&v.call(t,d)&&u(this._trace(h,t[d],R(r,d),t,d,s,n,!0))}if(this._hasParentSelector)for(let c=0;c<f.length;c++){let g=f[c];if(g&&g.isParentSelector){let w=this._trace(g.expr,t,g.path,i,o,s,n);if(Array.isArray(w)){f[c]=w[0];let K=w.length;for(let A=1;A<K;A++)c++,f.splice(c,0,w[A])}else f[c]=w}}return f};p.prototype._walk=function(e,t){if(Array.isArray(e)){let r=e.length;for(let i=0;i<r;i++)t(i)}else e&&typeof e=="object"&&Object.keys(e).forEach(r=>{t(r)})};p.prototype._slice=function(e,t,r,i,o,s,n){if(!Array.isArray(r))return;let a=r.length,l=e.split(":"),d=l[2]&&Number.parseInt(l[2])||1,h=l[0]&&Number.parseInt(l[0])||0,f=l[1]&&Number.parseInt(l[1])||a;h=h<0?Math.max(0,h+a):Math.min(a,h),f=f<0?Math.max(0,f+a):Math.min(a,f);let u=[];for(let c=h;c<f;c+=d)this._trace(X(c,t),r,i,o,s,n,!0).forEach(w=>{u.push(w)});return u};p.prototype._eval=function(e,t,r,i,o,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;let n=e.includes("@path");n&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+e;if(!p.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");n&&(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+": "+e)}};p.cache={};p.toPathString=function(e){let t=e,r=t.length,i="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(t[o])||(i+=/^[0-9*]+$/u.test(t[o])?"["+t[o]+"]":"['"+t[o]+"']");return i};p.toPointer=function(e){let t=e,r=t.length,i="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(t[o])||(i+="/"+t[o].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(e){let{cache:t}=p;if(t[e])return t[e].concat();let r=[],o=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(s,n){return"[#"+(r.push(n)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(s,n){return"['"+n.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(s,n){return";"+n.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(s){let n=s.match(/#(\d+)/u);return!n||!n[1]?s:r[n[1]]});return t[e]=o,t[e].concat()};p.prototype.vm=ct.default;async function tt(e,t,r,i){return k({url:e,options:t,validator:r,callback:i}).then(L).then(o=>o.response)}async function k({url:e,options:t,validator:r,callback:i},o="initial"){let s=new Date,n=await fetch(e,t);if(!n.ok)throw new Error("Fetch failed");if((r==null?void 0:r(n))===!1)throw new Error("Response is not valid");let a=new Date(n.headers.get("date"))<s;return i==null||i(n,o),{url:e,options:t,isCached:a,response:n,validator:r}}async function L(e){let{url:t,isCached:r,options:i,validator:o,response:s,callback:n}=e;if(r){let{response:a}=await k({url:t+"?"+Math.random(),options:{...i,method:"HEAD",cache:"no-cache"},validator:o},"check");if(a.headers.get("last-modified")!=s.headers.get("last-modified"))return z(e)}return e}async function z(e){let{url:t,options:r,validator:i,callback:o}=e;return k({url:t,options:{...r,cache:"reload"},validator:i,callback:o},"updated")}function et({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,component:i,version:o,revision:s="published"}){return`${e||t}/components/${r}/${i}/${o}/${s}.html`}function ht({cdn:e="https://feaascomponentsapidev.blob.core.windows.net",hostname:t,library:r,revision:i="published"}){return`${e||t}/styles/${r}/${i}.css`}async function _(e,t,r=!1){let i=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,o=a=>{a.text().then(t)},s=await Promise.all([e.instance&&k({options:{headers:{Accept:"text/html"}},url:et({...e,version:e.instance}),validator:i}).catch(a=>a),k({url:et(e),validator:i}).catch(a=>a)]),n=s.find(a=>a&&"isCached"in a&&a);if(!n||n instanceof Error)throw s.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return s[0]==n&&console.log("Using fork!",s),o(n.response),L({...n,callback:o}).catch(a=>{if(s[0]==n&&(z({...n,callback:null,validator:null}),console.log("Fork was deleted"),!(s[1]instanceof Error)))return o(s[1].response),L({...s[1],callback:o});throw a})}async function Vt(e){var t;let{response:r}=await _(e,i=>{t=i},!1);return{...e,template:t,lastModified:r.headers.get("last-modified")}}async function N(e,t){return tt(ht(e),{headers:{Accept:"text/css"}},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(t)})}function zt(e,t){let r=document.createElement("div");r.innerHTML=e;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return x(i,t),r}function pt(e){return e.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function ft(e){return pt(e)+".*"}function gt(e){let t=e.getAttribute("data-path-scope");for(var r=0,i=e;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==t&&r++;return r}function qt(e,t,r){let i=e.getAttribute("data-path-scope");if(i==null)return;var o=gt(e);if(o!=0)return;let s=e.parentElement;if(s!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var n=o+1,a=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==i&&(n++,a=l);for(var d=n;d<t;d++)s.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var d=Math.max(1,t);d<n;d++)a=a.previousElementSibling,s.removeChild(a.nextElementSibling)}}function it(e,t,r=!1,i=e){var o=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}o=t.substring(a.length+1),i=e[a];break}var n=p({path:o,json:i});return Array.isArray(n)&&(n==null?void 0:n.length)==0&&(n=[o.replace(/^.*?\./,"_."),o.replace(/^.*?\./,""),o.replace(/^([^.]+).*?\.\$\./,"$1."),o.replace(/^.*?\.\$\./,"_."),o.replace(/^.*?\.\$\./,""),o.replace(/^[^.]+$/,"_")].filter((a,l,d)=>d.indexOf(a)===l).reduce((a,l)=>a.length>0?a:p({path:l,json:i}),[])),r&&Array.isArray(n)?n[0]:n}function P(e,t,r,i){var o;if(e){var s=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=$(r)),i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(e,t,r));var n=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")n="innerHTML";else if(t=="data-embed-src")q(e,r);else if(t=="data-path-attributes"){let f=((o=e.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var a in r){var l=r[a];P(e,a,typeof l=="object"&&l?JSON.stringify(l):l,i)}for(var d=0;d<f.length;d++)(r==null||!(f[d]in r))&&P(e,f[d],null,i);P(e,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!s){var h=String(e.getAttribute("data-path-placeholder")||s[n]);r!=null?n=="innerHTML"?s.innerHTML!=r&&(s.innerHTML=r):s.getAttribute(n)!=r&&s.setAttribute(n,r):n=="innerHTML"?s.innerHTML=h:s.removeAttribute(n)}}}function bt(e){let t=new e.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let o=i.target,s=o.getAttribute("data-embed-src");s&&q(o,s),i.addedNodes&&i.addedNodes.forEach(n=>{n.nodeType==1&&yt(n,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function yt(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let o=r[i];q(o,o.getAttribute("data-embed-src"))}if(t)return bt(e)}function q(e,t){for(var r=e;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")==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 ut=["data-attributes-keys","data-path-attributes","data-path-scope"];function x(e,t,r,i){var o,s,n;let a=e;if(i||(t=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,a,t))||t),a.nodeType==1){let h=a.getAttribute("data-path-scope");if(h){let u=gt(a),c=it(t,h,!1)||[];u==0&&qt(a,((s=r==null?void 0:r.shouldRepeat)===null||s===void 0?void 0:s.call(r,a,c))===!1?1:c.length,r),t={...t,[ft(h)]:c[u]}}let f=Array.prototype.slice.call(a.attributes).sort((u,c)=>ut.indexOf(u.name)-ut.indexOf(c.name));for(var l=0;l<f.length;l++){let{name:u,value:c}=f[l];u.startsWith("data-path")&&u!="data-path-scope"&&P(a,u,it(t,c,!0),r),u=="data-embed-src"&&P(a,u,a.getAttribute(u),r)}}for(var l=0,d;d=a.childNodes[l++];)mt(d)&&x(d,t,r,!0);return i||(n=r==null?void 0:r.onRender)===null||n===void 0||n.call(r,a,t),a}function mt(e){return e.nodeType==1}function D(e,t,r,i){var o;let s=((o=i==null?void 0:i.processTemplate)===null||o===void 0?void 0:o.call(i,e,t,r))||t;if(e.innerHTML=s,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(var a=0,l;l=e.childNodes[a++];)mt(l)&&(l.className=l.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return x(e,r,i)}function Jt(e,t,r,i=!1){var o;let s=((o=r==null?void 0:r.processTemplate)===null||o===void 0?void 0:o.call(r,null,e,t))||e;if(typeof document=="undefined"||i){let{parseHTML:n}=require("linkedom"),{document:a}=n(s);return x(a,t,r).toString()}else{let n=document.createElement("div");return n.innerHTML=s,x(n,t,r),n.innerHTML}}function Kt(e,t){return vt(e,t||(t=document.createElement("style"))),t}function vt(e,t){return t||(t=document.createElement("style")),N(e,r=>{t.textContent=r}).then(()=>t)}function Gt(e,t){return At(e,t||(t=document.createElement("div"))),t}async function At(e,t){return t||(t=document.createElement("div")),t.childNodes.length?x(t,e.data,e):"template"in e?D(t,e.template,e.data,e):_(e,r=>D(t,r,e.data,e)).then(()=>t)}function rt(e,t={},r){return r?`<${r}${Object.entries(t).map(([i,o])=>o!=null&&` ${i}="${o}"`).filter(Boolean).join("")}>${$(e)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):$(e)}function $(e){var t;if(Array.isArray(e))return e.map($).join(`
2
+ `).trim();if(typeof e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...i}=e.attrs;return rt(e.content,i,"h"+r);case"text":return(e.marks||[]).reduce((o,s)=>rt(o,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 rt(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}function Et(e=this){let t,r=e.getAttribute("data");if(r!=null)try{t=typeof r=="string"?JSON.parse(r):{}}catch(i){}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,lastModified:e.getAttribute("last-modified")}}var F=class extends y{setData(t){this.set({data:t})}getProps(){return Et(this)}attributeChangedCallback(t,r,i){r!==i&&(this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(t,r,i))}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}constructor(){super(),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}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 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{_(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)x(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;D(this,this.payload,this.props.data)}}};F.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable"];F.register("feaas-component");function Ct(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 I=class extends y{getProps(){return Ct(this)}attributeChangedCallback(t,r,i){if(r!==i)return t=="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(t,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,5 +63,5 @@ var Dt=Object.create;var B=Object.defineProperty;var $t=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)}};I.observedAttributes=["hidden","opacity"];I.register("feaas-loader");function wt(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 J=class extends y{getProps(){return wt(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){N(this.props,this.onLoad)}update(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};J.register("feaas-stylesheet");var ot;typeof window!="undefined"&&(window.FEAASElement=S,(ot=window.FEAASLoading)!==null&&ot!==void 0||(window.FEAASLoading=Promise.resolve()));function xt(e){let t=[];if(e){let r=e.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);t.push({left:o.left+parseInt(a.borderLeftWidth),top:o.top+parseInt(a.borderTopWidth)})}r=i;break}}}return t.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function Rt(e=this){var t;return{context:HTMLElement,frontend:e==null?void 0:e.getContextAttribute("frontend"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/editor.js",library:e==null?void 0:e.getAttribute("library"),component:e==null?void 0:e.getAttribute("component"),version:e==null?void 0:e.getAttribute("version"),instance:e==null?void 0:e.getAttribute("instance"),forked:e==null?void 0:e.getAttribute("forked"),revision:(e==null?void 0:e.getAttribute("revision"))||"saved",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,for:e==null?void 0:e.getAttribute("for"),state:(e==null?void 0:e.getAttribute("state"))||"idle",changed:(e==null?void 0:e.getAttribute("changed"))!=null}}var U=class extends y{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=(t,r={component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),instance:t.getAttribute("instance")})=>{if(!this.closing&&(!this.target||t==null))return this.set(r),this.target=t,!0},this.onChromeMeasureElement=(t,r=t.getBoundingClientRect())=>t.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=t=>{t.memoized.focusable&&(this.framePoint=xt(t.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:t,root:r})=>{!this.chrome||this.props.hidden||(t?(this.chrome.wrapper.style.width=t.width+16*2+"px",this.chrome.wrapper.style.height=t.height+16*1+64+"px",this.chrome.wrapper.style.left=t.left-16+"px",this.chrome.wrapper.style.top=t.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=t=>{var r;switch((r=t.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let i=this.getPlaceholder();this.setTarget(i.editable,t.data)&&(this.loader=i.loader,document.body.appendChild(i.clipper),this.editedUID=t.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=t.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var t;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"),!((t=this.target)===null||t===void 0)&&t.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(t,r)=>{this.versionContext=t,this.setVersionContext=r},this.onEditorStateChange=(t,r)=>{this.editorContext=t,this.setEditorContext=r,t.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 Rt(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(t){this.iframe=t}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 t=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:t+"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(t,r,i){r!==i&&(t=="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(t,r,i))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(t){return t.forkOriginId==null&&this.props.instance!=null}cleanup(){var t;this.placeholder&&((t=this.placeholder.clipper)===null||t===void 0||t.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(t){console.log("Editor is not ready")}setEditorContext(t){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")}render({children:t,component:r,version:i,instance:o},{Editor:n,VersionStatusList:s,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:h,EditorUIMode:f,React:{useEffect:u,useMemo:c,useState:g,useContext:w},Chakra:{HStack:K,Box:A,Button:nt,MenuItem:st},Chrome:_t,ReactDOM:Qt,useSDK:Pt,useSlots:Tt,useModelObserver:Ot,ConfirmationContext:Mt,VersionContext:Xt}){if(!this.payload)return;let{React:b}=this.payload,{sdk:j}=Pt(),[m,at]=g(),{setConfirm:G}=w(Mt),T=o||i,Lt=j.library;m&&(this.component=m),u(()=>{if(this.props.hidden)return;let C=Lt.components.getItem(r).clone();return C.versions.search({ids:[i,o].filter(Boolean),componentIds:[r]}).then(Y=>{C.versions.setItems(Y);let E=C.findVersion(o,["staged","published"]),M=C.findVersion(i,["staged","published"]);if(E)E.deletedAt?(E.getDraft().changeAndNotify(M.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(M)){console.error("FEAAS Editor: Forking");let Q=M.fork(o).id;this.setAttribute("instance",Q)}else console.error("FEAAS Editor: Regular");at(C)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),at(null)},400)}},[i,this.props.hidden]);let lt=Ot(m==null?void 0:m.versions,[]).filter(C=>C.id==T),O=lt[0];O&&!this.props.hidden&&(this.version=O),u(()=>(this.unfork=()=>{G({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=m.findVersion(i,["staged","published"]);m.findVersion(o).unstage().unpublish().changeAndNotify(C.toProperties()),m.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(m.findVersion(T).revert(),m.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{G({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=()=>{G({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:()=>{m.findVersion(T).commitData({view:this.editorContext.editor.getData({rootName:T}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",T),m.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[m]);let Nt=c(()=>this.target,[m]);return c(()=>m&&Tt(t,({picker:C,children:Y})=>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:j.datasources,sdk:j,library:j.library,component:m,versions:lt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:Y,chrome:({editor:E})=>E&&b.createElement(_t,null),children:({isArchivedDisplayed:E,editor:M,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"}),O&&b.createElement(l,{version:O,node:Nt,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:b.createElement(K,{justifyContent:"space-between"},b.createElement(h,{size:"sm",editor:Q=="ready"?M:null}),b.createElement(f,{size:"sm"})),middle:(Zt,te)=>[!1],right:b.createElement(b.Fragment,null,b.createElement(nt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),b.createElement(nt,{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(d,{isDisabled:!this.props.forked&&!this.props.changed},b.createElement(st,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),b.createElement(st,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[O,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};U.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];U.register("feaas-editor");function kt(e=this){var t,r;return{part:(e==null?void 0:e.getAttribute("part"))||"picker",slot:(e==null?void 0:e.getAttribute("part"))||"picker",mode:e==null?void 0:e.getAttribute("mode"),placeholder:(e==null?void 0:e.getAttribute("placeholder"))||"No theme",frontend:(t=e==null?void 0:e.getContextAttribute("frontend"))!==null&&t!==void 0?t:"https://components.sitecorecloud.io",src:(r=e==null?void 0:e.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,variant:e==null?void 0:e.getAttribute("variant"),context:void 0,onClose:void 0,onContextAttributeSet:void 0}}var W=class extends y{getProps(){return kt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}render({placeholder:t,context:r,mode:i,children:o,variant:n},{Picker:s,React:a,ReactDOM:l}){return a.createElement(s,{placeholder:t,mode:i||void 0,onClose:this.props.onClose,onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:n},o)}};W.observedAttributes=["library","mode","frontend","src","hidden","variant"];W.register("feaas-picker");function St(e=this){var t,r,i,o;return{library:e==null?void 0:e.getAttribute("library"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/context.js",frontend:(r=e==null?void 0:e.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=e==null?void 0:e.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(o=e==null?void 0:e.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaascompontsapiprod.blob.core.windows.net",getToken:null}}var H=class extends y{constructor(){super(...arguments),this.onStatusChange=t=>{t=="ready"&&this.dispatchEvent(new Event("feaasReady",{bubbles:!0,composed:!0}))}}getProps(){return St(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return console.log("Is ready?",this.props,super.isReadyToLoad()&&this.props.library!=null),super.isReadyToLoad()&&this.props.library!=null}getTheme(t){return t}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(t=>{this.getRoot().appendChild(t)}),super.connectedCallback()}render({children:t,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,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},t)}};H.observedAttributes=["library","component","version","revision","hostname","template"];H.register("feaas-context");0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASContext,FEAASContextProps,FEAASEditor,FEAASEditorProps,FEAASLoader,FEAASLoaderProps,FEAASPicker,FEAASPickerProps,FEAASStylesheet,FEAASStylesheetProps,JSONPath,Loader,MyComponent,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,fetchAndRevalidateComponent,fetchAndValidate,fetchComponentHTML,fetchStylesheet,getComponentURL,getFramePosition,getStylesheetURL,invalidateRequest,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,refetchAndValidate,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderHTMLContent,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)}};I.observedAttributes=["hidden","opacity"];I.register("feaas-loader");function wt(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 J=class extends y{getProps(){return wt(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){N(this.props,this.onLoad)}update(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};J.register("feaas-stylesheet");var ot;typeof window!="undefined"&&(window.FEAASElement=S,(ot=window.FEAASLoading)!==null&&ot!==void 0||(window.FEAASLoading=Promise.resolve()));function xt(e){let t=[];if(e){let r=e.ownerDocument.defaultView,i,o;for(;r!==window.top;){i=r.parent;for(let s=0;s<i.frames.length;s++)if(i.frames[s]===r){for(let n of i.document.getElementsByTagName("iframe"))if(n.contentWindow===r){o=n.getBoundingClientRect();let a=n.contentWindow.getComputedStyle(n);t.push({left:o.left+parseInt(a.borderLeftWidth),top:o.top+parseInt(a.borderTopWidth)})}r=i;break}}}return t.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function Rt(e=this){var t;return{context:HTMLElement,frontend:e==null?void 0:e.getContextAttribute("frontend"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/editor.js",library:e==null?void 0:e.getAttribute("library"),component:e==null?void 0:e.getAttribute("component"),version:e==null?void 0:e.getAttribute("version"),instance:e==null?void 0:e.getAttribute("instance"),forked:e==null?void 0:e.getAttribute("forked"),revision:(e==null?void 0:e.getAttribute("revision"))||"saved",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,for:e==null?void 0:e.getAttribute("for"),state:(e==null?void 0:e.getAttribute("state"))||"idle",changed:(e==null?void 0:e.getAttribute("changed"))!=null}}var U=class extends y{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=(t,r={component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),instance:t.getAttribute("instance")})=>{if(!this.closing&&(!this.target||t==null))return this.set(r),this.target=t,!0},this.onChromeMeasureElement=(t,r=t.getBoundingClientRect())=>t.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=t=>{t.memoized.focusable&&(this.framePoint=xt(t.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:t,root:r})=>{!this.chrome||this.props.hidden||(t?(this.chrome.wrapper.style.width=t.width+16*2+"px",this.chrome.wrapper.style.height=t.height+16*1+64+"px",this.chrome.wrapper.style.left=t.left-16+"px",this.chrome.wrapper.style.top=t.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=t=>{var r;switch((r=t.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let i=this.getPlaceholder();this.setTarget(i.editable,t.data)&&(this.loader=i.loader,document.body.appendChild(i.clipper),this.editedUID=t.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=t.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var t;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"),!((t=this.target)===null||t===void 0)&&t.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(t,r)=>{this.versionContext=t,this.setVersionContext=r},this.onEditorStateChange=(t,r)=>{this.editorContext=t,this.setEditorContext=r,t.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 Rt(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(t){this.iframe=t}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 t=this.iframe.clientWidth,r=this.iframe.clientHeight,i=this.iframe.getBoundingClientRect(),o=this.getPlaceholder(),s=document.body.getBoundingClientRect(),n=this.measurements[this.editedUID];n&&(Object.assign(o.clipper.style,{position:"absolute",top:i.top+this.iframe.clientTop-s.top+"px",left:i.left+this.iframe.clientLeft-s.left+"px",width:t+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(o.positionable.style,{position:"absolute",top:n.top+"px",left:n.left+"px",width:n.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(o.loader.style,{position:"absolute",top:n.top+"px",left:n.left+"px",width:n.width+"px",height:n.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(t,r,i){r!==i&&(t=="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(t,r,i))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(t){return t.forkOriginId==null&&this.props.instance!=null}cleanup(){var t;this.placeholder&&((t=this.placeholder.clipper)===null||t===void 0||t.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(t){console.log("Editor is not ready")}setEditorContext(t){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")}render({children:t,component:r,version:i,instance:o},{Editor:s,VersionStatusList:n,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:h,EditorUIMode:f,React:{useEffect:u,useMemo:c,useState:g,useContext:w},Chakra:{HStack:K,Box:A,Button:st,MenuItem:nt},Chrome:_t,ReactDOM:Qt,useSDK:Pt,useSlots:Tt,useModelObserver:Mt,ConfirmationContext:Ot,VersionContext:Xt}){if(!this.payload)return;let{React:b}=this.payload,{sdk:B}=Pt(),[m,at]=g(),{setConfirm:G}=w(Ot),T=o||i,Lt=B.library;m&&(this.component=m),u(()=>{if(this.props.hidden)return;let C=Lt.components.getItem(r).clone();return C.versions.search({ids:[i,o].filter(Boolean),componentIds:[r]}).then(Y=>{C.versions.setItems(Y);let E=C.findVersion(o,["staged","published"]),O=C.findVersion(i,["staged","published"]);if(E)E.deletedAt?(E.getDraft().changeAndNotify(O.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(O)){console.error("FEAAS Editor: Forking");let Q=O.fork(o).id;this.setAttribute("instance",Q)}else console.error("FEAAS Editor: Regular");at(C)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),at(null)},400)}},[i,this.props.hidden]);let lt=Mt(m==null?void 0:m.versions,[]).filter(C=>C.id==T),M=lt[0];M&&!this.props.hidden&&(this.version=M),u(()=>(this.unfork=()=>{G({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=m.findVersion(i,["staged","published"]);m.findVersion(o).unstage().unpublish().changeAndNotify(C.toProperties()),m.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(m.findVersion(T).revert(),m.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{G({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=()=>{G({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:()=>{m.findVersion(T).commitData({view:this.editorContext.editor.getData({rootName:T}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",T),m.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[m]);let Nt=c(()=>this.target,[m]);return c(()=>m&&Tt(t,({picker:C,children:Y})=>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(s,{datasources:B.datasources,sdk:B,library:B.library,component:m,versions:lt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:Y,chrome:({editor:E})=>E&&b.createElement(_t,null),children:({isArchivedDisplayed:E,editor:O,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"}),M&&b.createElement(l,{version:M,node:Nt,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:b.createElement(K,{justifyContent:"space-between"},b.createElement(h,{size:"sm",editor:Q=="ready"?O:null}),b.createElement(f,{size:"sm"})),middle:(Zt,te)=>[!1],right:b.createElement(b.Fragment,null,b.createElement(st,{variant:"secondary",size:"sm",onClick:this.close},"Close"),b.createElement(st,{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(d,{isDisabled:!this.props.forked&&!this.props.changed},b.createElement(nt,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),b.createElement(nt,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[M,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};U.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];U.register("feaas-editor");function kt(e=this){var t,r;return{part:(e==null?void 0:e.getAttribute("part"))||"picker",slot:(e==null?void 0:e.getAttribute("part"))||"picker",mode:e==null?void 0:e.getAttribute("mode"),placeholder:(e==null?void 0:e.getAttribute("placeholder"))||"No theme",frontend:(t=e==null?void 0:e.getContextAttribute("frontend"))!==null&&t!==void 0?t:"https://components.sitecorecloud.io",src:(r=e==null?void 0:e.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,variant:e==null?void 0:e.getAttribute("variant"),context:void 0,onClose:void 0,onContextAttributeSet:void 0}}var W=class extends y{getProps(){return kt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}render({placeholder:t,context:r,mode:i,children:o,variant:s},{Picker:n,React:a,ReactDOM:l}){return a.createElement(n,{placeholder:t,mode:i||void 0,onClose:this.props.onClose,onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:s},o)}};W.observedAttributes=["library","mode","frontend","src","hidden","variant"];W.register("feaas-picker");function St(e=this){var t,r,i,o;return{library:e==null?void 0:e.getAttribute("library"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/context.js",frontend:(r=e==null?void 0:e.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=e==null?void 0:e.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(o=e==null?void 0:e.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaascompontsapiprod.blob.core.windows.net",getToken:null}}var j=class extends y{constructor(){super(...arguments),this.onStatusChange=t=>{t=="ready"&&this.dispatchEvent(new Event("feaasReady",{bubbles:!0,composed:!0}))}}getProps(){return St(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return console.log("Is ready?",this.props,super.isReadyToLoad()&&this.props.library!=null),super.isReadyToLoad()&&this.props.library!=null}getTheme(t){return t}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(t=>{this.getRoot().appendChild(t)}),super.connectedCallback()}render({children:t,library:r},{AppContext:i,Chakra:{Button:o,Tooltip:s},React:n}){let a={containerRef:{current:this.getRoot()}};return s.defaultProps={hasArrow:!0,placement:"top",portalProps:a},n.createElement(i,{backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),getToken:this.props.getToken,getTheme:this.getTheme,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},t)}};j.observedAttributes=["library","component","version","revision","hostname","template"];j.register("feaas-context");0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASContext,FEAASContextProps,FEAASEditor,FEAASEditorProps,FEAASLoader,FEAASLoaderProps,FEAASPicker,FEAASPickerProps,FEAASStylesheet,FEAASStylesheetProps,JSONPath,Loader,MyComponent,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,fetchAndRevalidateComponent,fetchAndValidate,fetchComponent,fetchStylesheet,getComponentURL,getFramePosition,getStylesheetURL,invalidateRequest,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,refetchAndValidate,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderHTMLContent,renderStylesheet,renderStylesheetPromise,serializeCH1RichText,setDOMAttribute});
67
67
  //# sourceMappingURL=index.js.map