(function(f,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@bloomreach/spa-sdk")):typeof define=="function"&&define.amd?define(["exports","vue","@bloomreach/spa-sdk"],e):(f=typeof globalThis<"u"?globalThis:f||self,e(f.BrSdk={},f.Vue,f.BloomreachSpaSdk))})(this,function(f,e,m){"use strict";const C=e.defineComponent({__name:"BrMeta",props:{meta:{}},setup(p){const l=p,n=e.ref(l.meta);let c;const r=e.ref(),o=e.ref(),s=()=>{var a,t;!((a=r.value)!=null&&a.nextSibling)||!o.value||(c=(t=n.value)==null?void 0:t.render(r.value.nextSibling,o.value))};return e.watch(n,()=>{var a,t;return(t=(a=e.getCurrentInstance())==null?void 0:a.proxy)==null?void 0:t.$forceUpdate()},{deep:!1}),e.onMounted(()=>s()),e.onUpdated(()=>s()),e.onBeforeUnmount(()=>c==null?void 0:c()),e.onBeforeUpdate(()=>c==null?void 0:c()),(a,t)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[n.value&&n.value.length>0?(e.openBlock(),e.createElementBlock("span",{key:0,style:{display:"none"},ref_key:"head",ref:r},null,512)):e.createCommentVNode("",!0),e.renderSlot(a.$slots,"default"),n.value&&n.value.length>0?(e.openBlock(),e.createElementBlock("span",{key:1,style:{display:"none"},ref_key:"tail",ref:o},null,512)):e.createCommentVNode("",!0)],64))}}),d=Symbol("page$"),g=Symbol("mapping$"),k=Symbol("component$");function y(p,l){const n=e.inject(d),c=e.computed(()=>{var o;return(o=n==null?void 0:n.value)==null?void 0:o.isPreview()}),r=()=>{var i;const a=e.useSlots().default()[0].children,t=(i=a==null?void 0:a[0])==null?void 0:i.children;return t==null?void 0:t.map(_=>e.h(l,{class:{"hst-container-item":c}},[_]))};return()=>e.h(p,{class:{"hst-container":c}},r())}const w=e.defineComponent({setup(){return y("div","div")}}),I=e.defineComponent({setup(){return y("div","span")}}),P=e.defineComponent({__name:"BrContainerNoMarkup",setup(p){const l=e.useAttrs();return(n,c)=>e.renderSlot(n.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(l))))}}),j=e.defineComponent({setup(){return y("ol","li")}}),M=e.defineComponent({setup(){return y("ul","li")}}),R=e.defineComponent({__name:"BrNodeContainer",setup(p){const l=e.inject(d),n=e.inject(k),c=e.inject(g),r=e.computed(()=>{var o;return(o=n==null?void 0:n.value)==null?void 0:o.getType()});return(o,s)=>r.value&&r.value in e.unref(c)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(c)[r.value]),{key:0,component:e.unref(n),page:e.unref(l)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},8,["component","page"])):r.value===e.unref(m.TYPE_CONTAINER_INLINE)?(e.openBlock(),e.createBlock(I,{key:1,component:e.unref(n),page:e.unref(l)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},8,["component","page"])):r.value===e.unref(m.TYPE_CONTAINER_NO_MARKUP)?(e.openBlock(),e.createBlock(P,{key:2,component:e.unref(n),page:e.unref(l)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},8,["component","page"])):r.value===e.unref(m.TYPE_CONTAINER_ORDERED_LIST)?(e.openBlock(),e.createBlock(j,{key:3,component:e.unref(n),page:e.unref(l)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},8,["component","page"])):r.value===e.unref(m.TYPE_CONTAINER_UNORDERED_LIST)?(e.openBlock(),e.createBlock(M,{key:4,component:e.unref(n),page:e.unref(l)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},8,["component","page"])):(e.openBlock(),e.createBlock(w,{key:5,component:e.unref(n),page:e.unref(l)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},8,["component","page"]))}}),b=e.defineComponent({__name:"BrContainerItemUndefined",props:{component:{}},setup(p){const l=p,n=e.computed(()=>l.component.getType());return(c,r)=>(e.openBlock(),e.createElementBlock("div",null,e.toDisplayString(`Component "${n.value}" is not defined.`),1))}}),O=e.defineComponent({__name:"BrNodeContainerItem",setup(p){const l=e.inject(d),n=e.inject(g),c=e.inject(k),r=e.computed(()=>c.value.getType());let o;function s(i){const _=Object.create(Object.getPrototypeOf(i));return Object.assign(_,i)}const a=e.ref(c.value),t=()=>{a.value=s(c.value);const i=e.toRaw(l.value);i==null||i.sync()};return e.onUnmounted(()=>o==null?void 0:o()),e.watch(c,()=>{o==null||o(),o=c.value.on("update",t)},{immediate:!0,deep:!0}),(i,_)=>r.value&&r.value in e.unref(n)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(n)[r.value]),{key:0,component:a.value,page:e.unref(l)},null,8,["component","page"])):e.unref(m.TYPE_CONTAINER_ITEM_UNDEFINED)in e.unref(n)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(n)[e.unref(m.TYPE_CONTAINER_ITEM_UNDEFINED)]),{key:1,component:a.value,page:e.unref(l)},null,8,["component","page"])):a.value?(e.openBlock(),e.createBlock(b,{key:2,component:a.value},null,8,["component"])):e.createCommentVNode("",!0)}}),u=e.defineComponent({__name:"BrNodeComponent",props:{component:{}},setup(p){const l=p,{component:n}=e.toRefs(l),c=e.inject(d),r=e.inject(g),o=e.computed(()=>{var t;return(t=n==null?void 0:n.value)==null?void 0:t.getChildren()}),s=e.computed(()=>{var t;return(t=n==null?void 0:n.value)==null?void 0:t.getMeta()}),a=e.computed(()=>{var t;return(t=n==null?void 0:n.value)==null?void 0:t.getName()});return e.provide(k,n),(t,i)=>{var $;const _=e.resolveComponent("br-node-component",!0);return e.openBlock(),e.createBlock(C,{meta:s.value,key:($=e.unref(n))==null?void 0:$.getId()},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[e.unref(m.isContainerItem)(e.unref(n))?(e.openBlock(),e.createBlock(O,{key:0})):e.unref(m.isContainer)(e.unref(n))?(e.openBlock(),e.createBlock(R,{key:1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,B=>(e.openBlock(),e.createBlock(_,{key:B.getId(),component:B},null,8,["component"]))),128))]),_:1})):a.value&&a.value in e.unref(r)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(r)[a.value]),{key:2,component:e.unref(n),page:e.unref(c)},null,8,["component","page"])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:3},e.renderList(o.value,B=>(e.openBlock(),e.createBlock(_,{key:B.getId(),component:B},null,8,["component"]))),128))])]),_:3},8,["meta"])}}}),h=e.defineComponent({__name:"BrComponent",props:{component:{}},setup(p){const l=p;function n(s,a){if(m.isComponent(a))return[a];if(!s)return[];if(!a)return s.getChildren();const t=s.getComponent(...a.split("/"));return t?[t]:[]}const c=e.inject(d),r=e.inject(k),o=e.computed(()=>n(r==null?void 0:r.value,l.component));return(s,a)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,t=>(e.openBlock(),e.createBlock(u,{component:t},{default:e.withCtx(()=>[e.renderSlot(s.$slots,"default",{component:t,page:e.unref(c)})]),_:2},1032,["component"]))),256))}}),N=e.defineComponent({__name:"BrManageContentButton",props:{content:{},documentTemplateQuery:{},folderTemplateQuery:{},path:{},parameter:{},pickerConfiguration:{},pickerEnableUpload:{type:Boolean},pickerInitialPath:{},pickerRemembersLastVisited:{type:Boolean},pickerRootPath:{},pickerSelectableNodeTypes:{},relative:{type:Boolean},root:{}},setup(p){const l=p,n=e.inject(d),c=e.computed(()=>{var r;return(r=n==null?void 0:n.value)==null?void 0:r.getButton(m.TYPE_MANAGE_CONTENT_BUTTON,l)});return(r,o)=>{var s;return e.unref(n)&&((s=e.unref(n))!=null&&s.isPreview())?(e.openBlock(),e.createBlock(C,{key:0,meta:c.value},null,8,["meta"])):e.createCommentVNode("",!0)}}}),E=e.defineComponent({__name:"BrManageMenuButton",props:{menu:{}},setup(p){const l=p,n=e.inject(d),c=e.computed(()=>{var r;return(r=n==null?void 0:n.value)==null?void 0:r.getButton(m.TYPE_MANAGE_MENU_BUTTON,l.menu)});return(r,o)=>e.unref(n)&&e.unref(n).isPreview()?(e.openBlock(),e.createBlock(C,{key:0,meta:c.value},null,8,["meta"])):e.createCommentVNode("",!0)}}),T=e.defineComponent({__name:"BrPage",props:{page:{},configuration:{},mapping:{}},setup(p){const l=p;function n(){o.value&&m.destroy(o.value)}const{configuration:c,mapping:r}=e.toRefs(l),o=e.ref(),s=e.computed(()=>{var t;return(t=o.value)==null?void 0:t.getComponent()});let a=null;return e.provide(d,o),e.provide(g,r),e.watch(c,async(t,i)=>{if(!i&&l.page){o.value=m.initialize(t,l.page);return}n(),a=m.initialize(t),o.value=await a,a=null},{deep:!0,immediate:!0}),e.onMounted(()=>{const t=e.toRaw(o.value);t==null||t.sync()}),e.onUpdated(()=>{const t=e.toRaw(o.value);t==null||t.sync()}),e.onUnmounted(()=>n()),e.onServerPrefetch(async()=>await a),(t,i)=>o.value||e.unref(c).NBRMode?(e.openBlock(),e.createBlock(u,{key:0,component:s.value},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{component:s.value,page:o.value})]),_:3},8,["component"])):e.createCommentVNode("",!0)}}),S={install(p){p.component("br-component",h),p.component("br-manage-content-button",N),p.component("br-manage-menu-button",E),p.component("br-page",T)}};f.BrComponent=h,f.BrManageContentButton=N,f.BrManageMenuButton=E,f.BrPage=T,f.BrSdk=S,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=index.umd.cjs.map