@sitecore-feaas/clientside 0.1.55 → 0.1.56

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.
@@ -66,5 +66,5 @@ var be=Object.create;var X=Object.defineProperty;var ve=Object.getOwnPropertyDes
66
66
  </div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};q.observedAttributes=["hidden","opacity"];q.register("feaas-loader");function Xt(e){var t,r,i,n;let s=e.getAttribute("src");if(s)var{cdn:o,library:a,revision:l}=it(s);return{library:e==null?void 0:e.getContextAttribute("library"),revision:(r=(t=e==null?void 0:e.getAttribute("revision"))!==null&&t!==void 0?t:l)!==null&&r!==void 0?r:"published",cdn:(n=(i=e==null?void 0:e.getContextAttribute("cdn"))!==null&&i!==void 0?i:e==null?void 0:e.getContextAttribute("hostname"))!==null&&n!==void 0?n:k}}var st=class extends b{constructor(){super(...arguments),this.onLoad=t=>{this.payload=t,this.advance()}}getProps(){return Xt(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}load(){return ot(this.props,this.onLoad)}};st.register("feaas-stylesheet");var at={};Ot(at,{convertBase64toBlob:()=>Zt,generate:()=>ee,get:()=>De,getVersionForThumbnail:()=>Qt,load:()=>te,responseToImage:()=>wt,upload:()=>re});var Zt=e=>fetch(e).then(t=>t.blob()),wt=e=>e.blob().then(t=>new Promise((r,i)=>{let n=new Image;n.onerror=i,n.onload=()=>{r(n)},n.src=URL.createObjectURL(t)}));async function Qt(e){return e.versions.length||await e.versions.fetch(),e.getVersionForWidth(800)}async function De(e,t,r){try{if(!e.isNew)return await te(e,t,r)}catch(n){e.sdk.log(`FEAAS: Thumbnail ${e.id}, version: ${(t==null?void 0:t.id)||"responsive"}, status: generating ${status}, reason: ${n}`)}let i=await ee(e,t);return r==null||r(i,!1),i&&!e.isNew&&Zt(i.src).then(n=>re(e,t,n)),i}async function te(e,t,r){let i=t?t.getThumbnailURL():e.getThumbnailURL(),n=e.library.stylesheet,s=new Date(Math.max(Number(e.modifiedAt),Number(n.modifiedAt)));e.sdk.log(`FEAAS: Thumbnail ${e.id}/${(t==null?void 0:t.id)||"responsive"}, loading`);var o;return await H(i,{},(a,l)=>{let d=Math.abs(Number(new Date(a.headers.get("x-ms-meta-componentRenderedAt")))-Number(s))<2e3;return l&&!d&&wt(a).then(h=>{o=h,r(h,l)}),d},(a,l,d)=>{e.sdk.log(`FEAAS: Thumbnail ${e.id}/${(t==null?void 0:t.id)||"responsive"}, status: ${l}`),wt(a).then(h=>{o=h,r(h,d)})},null),o}async function ee(e,t){let r=t||(e.isNew?null:await Qt(e));if(!r||r.isViewEmpty())return null;let{stylesheet:i,datasources:n}=e.library;return await Fe(r.classList,i.getBreakpointForWidth(800,r.getBreakpoints()),r.view,n.reduce((o,a)=>Object.assign(o,{[a.id]:a.sample}),{}),i.css,e.sdk)}function Fe(e,t,r,i,n,s){let o=document.createElement("iframe");return o.style.position="absolute",o.style.top="-2000px",o.style.left="-2000px",o.style.width=t.props.minWidth+"px",o.style.height="720px",o.style.zIndex="100011",document.body.appendChild(o),new Promise((a,l)=>{let d=document.createElement("script");d.onerror=l,d.src=s.frontend+"/assets/html2canvas.js",d.onload=()=>{var u;(((u=o.contentWindow.document.fonts)===null||u===void 0?void 0:u.ready)||Promise.resolve()).then(function(){return o.contentWindow.html2canvas(p,{scale:Math.max(1.1,1e3/Math.min(1401,Math.max(320,t.props.minWidth))),width:Math.min(1401,Math.max(320,t.props.minWidth)),height:Math.max(1,Math.min(2e3,p.offsetHeight)),windowWidth:t.props.minWidth+"px",windowHeight:1e3,proxy:s.backend+"/proxy/media",backgroundColor:"#ffffff"}).then(c=>{let m=c.toDataURL("image/jpeg",.6);o.parentElement.removeChild(o);let v=new Image;v.onload=()=>{a(v)},v.onerror=l,v.src=m})})},o.contentWindow.document.head.appendChild(d);let h=o.contentWindow.document.createElement("style");h.textContent=`
67
67
  ${n}
68
68
  body, html { padding: 0; margin: 0; overflow: hidden }
69
- `,o.contentWindow.document.head.appendChild(h);let p=At({template:r,data:i});p.classList.add(...e,"-feaas--preview","-emulate--"+t.details.slug),o.contentWindow.document.body.appendChild(p)})}async function re(e,t,r){let i=t?t.getThumbnailURL():e.getThumbnailURL(),n=new Date(Math.max(Number(e.modifiedAt),Number(e.library.stylesheet.modifiedAt)));try{await e.sdk.uploadBlob("thumbnails",i.split(/\/thumbnails\//)[1],r,{headers:{"x-ms-blob-content-type":"image/jpg","x-ms-blob-cache-control":"public,max-age=31536000,immutable","x-ms-meta-versionId":t?t.id:null,"x-ms-meta-versionRevision":t?t.revision.toString():null,"x-ms-meta-componentId":e.id,"x-ms-meta-componentRenderedAt":n.toUTCString(),"x-ms-meta-componentModifiedAt":e.modifiedAt.toUTCString(),"x-ms-meta-componentCreatedAt":e.createdAt.toUTCString(),"x-ms-meta-modifiedAt":e.modifiedAt.toUTCString()}}),fetch(i,{cache:"no-cache"}).then(()=>{e.sdk.log("FEAAS: Thumbnail uploaded",i)})}catch(s){e.sdk.log("FEAAS: Thumbnail failed to upload",i,s)}return i}var Ct;typeof window!="undefined"&&(window.FEAASElement=O,(Ct=window.FEAASLoading)!==null&&Ct!==void 0||(window.FEAASLoading=Promise.resolve()));function ie(e){let t=[];if(e){let r=e.ownerDocument.defaultView,i,n;for(;r!==window.top;){i=r.parent;for(let s=0;s<i.frames.length;s++)if(i.frames[s]===r){for(let o of i.document.getElementsByTagName("iframe"))if(o.contentWindow===r){n=o.getBoundingClientRect();let a=o.contentWindow.getComputedStyle(o);t.push({left:n.left+parseInt(a.borderLeftWidth),top:n.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 ne(e){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 K=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.defaultProps={hidden:!1},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=ie(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 ne(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(){if(!this.iframe)return;let t=this.iframe.clientWidth,r=this.iframe.clientHeight,i=this.iframe.getBoundingClientRect(),n=this.getPlaceholder(),s=document.body.getBoundingClientRect(),o=this.measurements[this.editedUID];o&&(Object.assign(n.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(n.positionable.style,{position:"absolute",top:o.top+"px",left:o.left+"px",width:o.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(n.loader.style,{position:"absolute",top:o.top+"px",left:o.left+"px",width:o.width+"px",height:o.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:n},{Editor:s,VersionStatusList:o,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:h,EditorUIMode:p,React:{useEffect:u,useMemo:c,useState:m,useContext:v},Chakra:{HStack:_,Box:w,Button:kt,MenuItem:_t},Chrome:ce,ReactDOM:je,useSDK:he,useLibrary:ue,useSlots:pe,useModelObserver:fe,ConfirmationContext:me,VersionContext:He}){if(!this.payload)return;let{React:g}=this.payload,Tt=he(),Nt=ue(),[y,Pt]=m(),{setConfirm:lt}=v(me),U=n||i;y&&(this.component=y),u(()=>{if(this.props.hidden)return;let x=Nt.components.getItem(r).clone();return x.versions.search({ids:[i,n].filter(Boolean),componentIds:[r]}).then(dt=>{x.versions.setItems(dt);let E=x.findVersion(n,["staged","published"]),B=x.findVersion(i,["staged","published"]);if(E)E.deletedAt?(E.getDraft().changeAndNotify(B.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(B)){console.error("FEAAS Editor: Forking");let ct=B.fork(n).id;this.setAttribute("instance",ct)}else console.error("FEAAS Editor: Regular");Pt(x)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),Pt(null)},400)}},[i,this.props.hidden]);let Mt=fe(y==null?void 0:y.versions,[]).filter(x=>x.id==U),I=Mt[0];I&&!this.props.hidden&&(this.version=I),u(()=>(this.unfork=()=>{lt({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let x=y.findVersion(i,["staged","published"]);y.findVersion(n).unstage().unpublish().changeAndNotify(x.toProperties()),y.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(y.findVersion(U).revert(),y.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{lt({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=()=>{lt({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(U).commitData({view:this.editorContext.editor.getData({rootName:U}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",U),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 ge=c(()=>this.target,[y]);return c(()=>y&&pe(t,({picker:x,children:dt})=>g.createElement(w,{ref:E=>{this.chrome=E?{positionable:E,wrapper:E.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},g.createElement(w,{className:"editor-wrapper",position:"absolute",left:0,top:0},g.createElement(s,{datasources:Tt.datasources,sdk:Tt,library:Nt,component:y,versions:Mt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:dt,chrome:({editor:E})=>E&&g.createElement(ce,null),children:({isArchivedDisplayed:E,editor:B,status:ct})=>g.createElement(w,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},g.createElement(w,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),I&&g.createElement(l,{version:I,node:ge,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:g.createElement(_,{justifyContent:"space-between"},g.createElement(h,{size:"sm",editor:ct=="ready"?B:null}),g.createElement(p,{size:"sm"})),middle:(ze,Ve)=>[!1],right:g.createElement(g.Fragment,null,g.createElement(kt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),g.createElement(kt,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),g.createElement(d,{isDisabled:!this.props.forked&&!this.props.changed},g.createElement(_t,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),g.createElement(_t,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[I,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};K.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];K.register("feaas-editor");function oe(e){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 G=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return oe(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}render({placeholder:t,context:r,mode:i,children:n,variant:s},{Picker:o,React:a,useLibrary:l}){let d=l("collections"),h=l("stylesheet.styles");return a.createElement(o,{rules:h,collections:d,themeContext:r,placeholder:t,mode:i||void 0,onModeChange:p=>{p||this.props.onClose(p)},onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:s},n)}};G.observedAttributes=["library","mode","frontend","src","hidden","variant"];G.register("feaas-picker");function se(e){var t,r,i,n;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.sitecoreclud.io/api",cdn:(n=e==null?void 0:e.getAttribute("cdn"))!==null&&n!==void 0?n:"https://feaas.blob.core.windows.net",auth:null,isolate:(e==null?void 0:e.getAttribute("isolate"))==null||(e==null?void 0:e.getAttribute("isolate"))=="true"}}var Y=class extends b{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=(t,r)=>{t=="ready"&&(this.whenSDKReady.resolve(r),this.dispatchEvent(new CustomEvent("feaasReady",{bubbles:!0,composed:!0,detail:r})))},this.whenSDKReady=S(t=>{this.sdk=t})}getProps(){return se(this)}load(){return this.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.getAttribute("isolate")==="false"?this: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:n,Tooltip:s},React:o}){let a={containerRef:{current:this.getRoot()}};return s.defaultProps={hasArrow:!0,placement:"top",portalProps:a},o.createElement(i,{backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),auth:this.props.auth,getTheme:this.getTheme,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},t)}};Y.observedAttributes=["library","component","version","revision","hostname","template"];Y.register("feaas-context");var le=Z(require("react"),1);var St=Z(require("react"),1),ae=Z(require("react-dom"),1);function Et(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return e.replace(t,function(r){return"-"+r.toLowerCase()})}function xt(e){let t=/-[a-z\u00E0-\u00F6\u00F8-\u00FE]/g;return e.replace(t,function(r){return r.slice(1).toUpperCase()})}var Ue=e=>{if(!e)return;let t,r;return e.properties&&(t=Object.keys(e.properties).reduce((i,n)=>(i[Et(n)]=e.properties[n],i),{}),r=e.required.map(i=>Et(i))),{...e,properties:t,required:r}},Ie=(e,t,r)=>{var i;switch((i=r==null?void 0:r[e])===null||i===void 0?void 0:i.type){case"string":return t;case"object":return JSON.parse(t);case"array":return JSON.parse(t);case"number":return+t;case"integer":return+t;case"boolean":return t==="true";default:return t}};function Be(e){var t;let r=e.getAttributeNames(),i=e.getAttribute("data-external-id"),n=(t=A.registered[i])===null||t===void 0?void 0:t.schema;return r.reduce((o,a)=>{if(!a.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(a)){let l=e.getAttribute(a);return{...o,[xt(a)]:Ie(xt(a),l,n==null?void 0:n.properties)}}else return o},{})}var A=class extends b{load(){return Promise.resolve({React:St.default,ReactDOM:ae.default})}render(t,{React:r}){var i;let{dataExternalId:n}=t,s=(i=A.registered[n])===null||i===void 0?void 0:i.component;return s||console.warn("FEAASExternal: The component you requested is not registered"),r.createElement(r.Fragment,null,s&&r.createElement(s,{...t}))}getProps(){return Be(this)}static registerComponent(t,r={}){let i=r.name||t.name,n={...r,title:i,type:"object"};A.registered[i]={component:t,schema:n}}static setRegistrationCallback(){!A.registrationCallback&&typeof window!="undefined"&&(A.registrationCallback=setTimeout(()=>{var t;let r=Object.keys(A.registered).map(i=>({...A.registered[i],name:i,schema:Ue(A.registered[i].schema)}));(t=window==null?void 0:window.parent)===null||t===void 0||t.postMessage(JSON.stringify({action:"register-components",data:r}),"*")},500))}static Preview(t){var r;let i=(t==null?void 0:t.src)||(typeof window!="undefined"?(r=window.location.search.match(/feaasSrc=([^&]+)/))===null||r===void 0?void 0:r[1]:null);return i?St.default.createElement(Rt,{src:i,...t}):null}};A.registered={};A.register("feaas-external");A.setRegistrationCallback();function de({data:e,...t}){if("template"in t&&t.template)var r=gt(t.template,e||{});return"src"in t&&(t={...M(t.src),...t}),le.default.createElement("feaas-component",{...t,template:null,data:typeof e=="string"?e:e?JSON.stringify(e):null,dangerouslySetInnerHTML:{__html:r||""}})}var Rt=de;0&&(module.exports={Base,Component,ComponentProps,DEFAULT_CDN_URL,External,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASContext,FEAASContextProps,FEAASEditor,FEAASEditorProps,FEAASEmbed,FEAASLoader,FEAASLoaderProps,FEAASPicker,FEAASPickerProps,FEAASStylesheet,FEAASStylesheetProps,InvalidResponse,JSONPath,Loader,MyComponent,Stylesheet,Thumbnail,autoloadScripts,cleanCollectionBit,clearFetchCache,createStylesheet,fetchAndRevalidate,fetchAndRevalidateComponent,fetchAndRevalidateStylesheet,fetchBypassingCache,fetchCache,fetchComponent,fetchToValidateCache,fetchWithCacheAwareness,findStylesheet,getComponentSource,getComponentURL,getFetchCache,getFramePosition,getQualifier,getStylesheetSource,getStylesheetURL,loadScript,loadStylesheet,loadStylesheetAllowStale,normalizeCollectionScope,observeDOMElement,parseComponentSource,parseLimit,parseRange,parseStylesheetSource,queryScopes,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderHTMLContent,renderStylesheet,renderStylesheetPromise,serializeCH1RichText,setDOMAttribute});
69
+ `,o.contentWindow.document.head.appendChild(h);let p=At({template:r,data:i});p.classList.add(...e,"-feaas--preview","-emulate--"+t.details.slug),o.contentWindow.document.body.appendChild(p)})}async function re(e,t,r){let i=t?t.getThumbnailURL():e.getThumbnailURL(),n=new Date(Math.max(Number(e.modifiedAt),Number(e.library.stylesheet.modifiedAt)));try{await e.sdk.uploadBlob("thumbnails",i.split(/\/thumbnails\//)[1],r,{headers:{"x-ms-blob-content-type":"image/jpg","x-ms-blob-cache-control":"public,max-age=31536000,immutable","x-ms-meta-versionId":t?t.id:null,"x-ms-meta-versionRevision":t?t.revision.toString():null,"x-ms-meta-componentId":e.id,"x-ms-meta-componentRenderedAt":n.toUTCString(),"x-ms-meta-componentModifiedAt":e.modifiedAt.toUTCString(),"x-ms-meta-componentCreatedAt":e.createdAt.toUTCString(),"x-ms-meta-modifiedAt":e.modifiedAt.toUTCString()}}),fetch(i,{cache:"no-cache"}).then(()=>{e.sdk.log("FEAAS: Thumbnail uploaded",i)})}catch(s){e.sdk.log("FEAAS: Thumbnail failed to upload",i,s)}return i}var Ct;typeof window!="undefined"&&(window.FEAASElement=O,(Ct=window.FEAASLoading)!==null&&Ct!==void 0||(window.FEAASLoading=Promise.resolve()));function ie(e){let t=[];if(e){let r=e.ownerDocument.defaultView,i,n;for(;r!==window.top;){i=r.parent;for(let s=0;s<i.frames.length;s++)if(i.frames[s]===r){for(let o of i.document.getElementsByTagName("iframe"))if(o.contentWindow===r){n=o.getBoundingClientRect();let a=o.contentWindow.getComputedStyle(o);t.push({left:n.left+parseInt(a.borderLeftWidth),top:n.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 ne(e){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 K=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.defaultProps={hidden:!1},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=ie(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 ne(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(){if(!this.iframe)return;let t=this.iframe.clientWidth,r=this.iframe.clientHeight,i=this.iframe.getBoundingClientRect(),n=this.getPlaceholder(),s=document.body.getBoundingClientRect(),o=this.measurements[this.editedUID];o&&(Object.assign(n.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(n.positionable.style,{position:"absolute",top:o.top+"px",left:o.left+"px",width:o.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(n.loader.style,{position:"absolute",top:o.top+"px",left:o.left+"px",width:o.width+"px",height:o.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:n},{Editor:s,VersionStatusList:o,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:h,EditorUIMode:p,React:{useEffect:u,useMemo:c,useState:m,useContext:v},Chakra:{HStack:_,Box:w,Button:kt,MenuItem:_t},Chrome:ce,ReactDOM:je,useSDK:he,useLibrary:ue,useSlots:pe,useModelObserver:fe,ConfirmationContext:me,VersionContext:He}){if(!this.payload)return;let{React:g}=this.payload,Tt=he(),Nt=ue(),[y,Pt]=m(),{setConfirm:lt}=v(me),U=n||i;y&&(this.component=y),u(()=>{if(this.props.hidden)return;let x=Nt.components.getItem(r).clone();return x.versions.search({ids:[i,n].filter(Boolean),componentIds:[r]}).then(dt=>{x.versions.setItems(dt);let E=x.findVersion(n,["staged","published"]),B=x.findVersion(i,["staged","published"]);if(E)E.deletedAt?(E.getDraft().changeAndNotify(B.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(B)){console.error("FEAAS Editor: Forking");let ct=B.fork(n).id;this.setAttribute("instance",ct)}else console.error("FEAAS Editor: Regular");Pt(x)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),Pt(null)},400)}},[i,this.props.hidden]);let Mt=fe(y==null?void 0:y.versions,[]).filter(x=>x.id==U),I=Mt[0];I&&!this.props.hidden&&(this.version=I),u(()=>(this.unfork=()=>{lt({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let x=y.findVersion(i,["staged","published"]);y.findVersion(n).unstage().unpublish().changeAndNotify(x.toProperties()),y.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(y.findVersion(U).revert(),y.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{lt({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=()=>{lt({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(U).commitData({view:this.editorContext.editor.getData({rootName:U}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",U),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 ge=c(()=>this.target,[y]);return c(()=>y&&pe(t,({picker:x,children:dt})=>g.createElement(w,{ref:E=>{this.chrome=E?{positionable:E,wrapper:E.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},g.createElement(w,{className:"editor-wrapper",position:"absolute",left:0,top:0},g.createElement(s,{datasources:Tt.datasources,sdk:Tt,library:Nt,component:y,versions:Mt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:dt,chrome:({editor:E})=>E&&g.createElement(ce,null),children:({isArchivedDisplayed:E,editor:B,status:ct})=>g.createElement(w,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},g.createElement(w,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),I&&g.createElement(l,{version:I,node:ge,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:g.createElement(_,{justifyContent:"space-between"},g.createElement(h,{size:"sm",editor:ct=="ready"?B:null}),g.createElement(p,{size:"sm"})),middle:(ze,Ve)=>[!1],right:g.createElement(g.Fragment,null,g.createElement(kt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),g.createElement(kt,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),g.createElement(d,{isDisabled:!this.props.forked&&!this.props.changed},g.createElement(_t,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),g.createElement(_t,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[I,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};K.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];K.register("feaas-editor");function oe(e){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 G=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return oe(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}render({placeholder:t,context:r,mode:i,children:n,variant:s},{Picker:o,React:a,useLibrary:l}){let d=l("collections"),h=l("stylesheet.styles");return a.createElement(o,{rules:h,collections:d,themeContext:r,placeholder:t,mode:i||void 0,onModeChange:p=>{p||this.props.onClose(p)},onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:s},n)}};G.observedAttributes=["library","mode","frontend","src","hidden","variant"];G.register("feaas-picker");function se(e){var t,r,i,n;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.sitecoreclud.io/api",cdn:(n=e==null?void 0:e.getAttribute("cdn"))!==null&&n!==void 0?n:"https://feaas.blob.core.windows.net",auth:null,isolate:(e==null?void 0:e.getAttribute("isolate"))==null||(e==null?void 0:e.getAttribute("isolate"))=="true"}}var Y=class extends b{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=(t,r)=>{t=="ready"&&(this.whenSDKReady.resolve(r),this.dispatchEvent(new CustomEvent("feaasReady",{bubbles:!0,composed:!0,detail:r})))},this.whenSDKReady=S(t=>{this.sdk=t})}getProps(){return se(this)}load(){return this.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.getAttribute("isolate")==="false"?this: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:n,Tooltip:s},React:o}){let a={containerRef:{current:this.getRoot()}};return s.defaultProps={hasArrow:!0,placement:"top",portalProps:a},o.createElement(i,{backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),auth:this.props.auth,getTheme:this.getTheme,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},t)}};Y.observedAttributes=["library","component","version","revision","hostname","template"];Y.register("feaas-context");var le=Z(require("react"),1);var St=Z(require("react"),1),ae=Z(require("react-dom"),1);function Et(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return e.replace(t,function(r){return"-"+r.toLowerCase()})}function xt(e){let t=/-[a-z\u00E0-\u00F6\u00F8-\u00FE]/g;return e.replace(t,function(r){return r.slice(1).toUpperCase()})}var Ue=e=>{if(!e)return;let t,r;return e.properties&&(t=Object.keys(e.properties).reduce((i,n)=>(i[Et(n)]=e.properties[n],i),{}),r=(e.required||[]).map(i=>Et(i))),{...e,properties:t,required:r}},Ie=(e,t,r)=>{var i;switch((i=r==null?void 0:r[e])===null||i===void 0?void 0:i.type){case"string":return t;case"object":return JSON.parse(t);case"array":return JSON.parse(t);case"number":return+t;case"integer":return+t;case"boolean":return t==="true";default:return t}};function Be(e){var t;let r=e.getAttributeNames(),i=e.getAttribute("data-external-id"),n=(t=A.registered[i])===null||t===void 0?void 0:t.schema;return r.reduce((o,a)=>{if(!a.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(a)){let l=e.getAttribute(a);return{...o,[xt(a)]:Ie(xt(a),l,n==null?void 0:n.properties)}}else return o},{})}var A=class extends b{load(){return Promise.resolve({React:St.default,ReactDOM:ae.default})}render(t,{React:r}){var i;let{dataExternalId:n}=t,s=(i=A.registered[n])===null||i===void 0?void 0:i.component;return s||console.warn("FEAASExternal: The component you requested is not registered"),r.createElement(r.Fragment,null,s&&r.createElement(s,{...t}))}getProps(){return Be(this)}static registerComponent(t,r={}){let i=r.name||t.name,n={...r,title:i,type:"object"};A.registered[i]={component:t,schema:n}}static setRegistrationCallback(){clearTimeout(A.registrationCallback),A.registrationCallback=setTimeout(()=>{var t;if(typeof window!="undefined"){let r=Object.keys(A.registered).map(i=>({...A.registered[i],name:i,schema:Ue(A.registered[i].schema)}));(t=window==null?void 0:window.parent)===null||t===void 0||t.postMessage(JSON.stringify({action:"register-components",data:r}),"*")}},30)}static Preview(t){var r;let i=(t==null?void 0:t.src)||(typeof window!="undefined"?(r=window.location.search.match(/feaasSrc=([^&]+)/))===null||r===void 0?void 0:r[1]:null);return i?St.default.createElement(Rt,{src:i,...t}):null}};A.registered={};A.register("feaas-external");A.setRegistrationCallback();function de({data:e,...t}){if("template"in t&&t.template)var r=gt(t.template,e||{});return"src"in t&&(t={...M(t.src),...t}),le.default.createElement("feaas-component",{...t,template:null,data:typeof e=="string"?e:e?JSON.stringify(e):null,dangerouslySetInnerHTML:{__html:r||""}})}var Rt=de;0&&(module.exports={Base,Component,ComponentProps,DEFAULT_CDN_URL,External,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASContext,FEAASContextProps,FEAASEditor,FEAASEditorProps,FEAASEmbed,FEAASLoader,FEAASLoaderProps,FEAASPicker,FEAASPickerProps,FEAASStylesheet,FEAASStylesheetProps,InvalidResponse,JSONPath,Loader,MyComponent,Stylesheet,Thumbnail,autoloadScripts,cleanCollectionBit,clearFetchCache,createStylesheet,fetchAndRevalidate,fetchAndRevalidateComponent,fetchAndRevalidateStylesheet,fetchBypassingCache,fetchCache,fetchComponent,fetchToValidateCache,fetchWithCacheAwareness,findStylesheet,getComponentSource,getComponentURL,getFetchCache,getFramePosition,getQualifier,getStylesheetSource,getStylesheetURL,loadScript,loadStylesheet,loadStylesheetAllowStale,normalizeCollectionScope,observeDOMElement,parseComponentSource,parseLimit,parseRange,parseStylesheetSource,queryScopes,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderHTMLContent,renderStylesheet,renderStylesheetPromise,serializeCH1RichText,setDOMAttribute});
70
70
  //# sourceMappingURL=react.cjs.map