1import{a as w,b,h as S}from"./chunk-7BXBZ5JU.js";function y(e,t,...r){if(typeof console>"u")return;let o=console[e];o&&o(t,...r)}var L=(e,...t)=>{y("log",e,...t)},V=(e,...t)=>{y("info",e,...t)},P=(e,...t)=>{y("warn",e,...t)},N=(e,...t)=>{y("error",e,...t)},G=Object.freeze(Object.defineProperty({__proto__:null,error:N,info:V,log:L,warn:P},Symbol.toStringTag,{value:"Module"}));function R(e){var t;return((t=e?.["@path"])==null?void 0:t.replace(/\//g,"_"))||e?.["@name"]||""}function A(e,t={},r,o){if(!e||typeof e!="object")return{};let n=b(w({},t),{metadata:{"@index":r},key:R(e)}),l;return o?(n.data={},l=n.data):l=n,Object.keys(e).forEach(i=>{i.match(/^(@|mgnl:|jcr:)/)?n.metadata[i]=e[i]:l[i.replace("-","_")]=e[i]}),n}var x=(e,t,r)=>(P("This getComponentProperties method is deprecated. Use buildComponentProperties instead."),A(e,void 0,t,r)),K=Object.freeze(Object.defineProperty({__proto__:null,buildComponentProperties:A,buildKey:R,getComponentProperties:x},Symbol.toStringTag,{value:"Module"}));function D(e){try{let t=/^http(s?):\/\//i.test(e)?e:"http://valid-url.com"+(e.startsWith("/")?e:"/"+e);return new URL(t)}catch(t){return console.warn("requestUrl is not a valid URL"),!1}}function M(e){return new RegExp(`/${e}($|/)`)}var z=(e,t,r)=>{let o=D(e),n={isMagnolia:!1,isMagnoliaEdit:!1,isMagnoliaPreview:!1,version:void 0,nodePath:void 0,currentLanguage:void 0,searchParams:void 0,search:void 0};if(o){let l=o.pathname,i=new URLSearchParams(o.search),d=i.get("mgnlPreview"),u=i.get("mgnlPreviewAsVisitor"),s=i.get("mgnlVersion"),p=d??u;p&&(n.isMagnolia=!0,p==="false"&&(n.isMagnoliaEdit=!0),p==="true"&&(n.isMagnoliaPreview=!0)),n.isMagnolia&&!u&&i.set("variants","all"),s?(n.version=s,i.set("version",s)):delete n.version;let c=l,m=!1;if(r&&r.length>0&&(n.currentLanguage=r[0],m=r.some(g=>M(g).test(c)?(n.currentLanguage=g,!0):!1),i.set("lang",n.currentLanguage)),t){m&&(c=c.replace(M(n.currentLanguage),"/"));let g=new RegExp("(.html|/$)"),E=new RegExp(`^${t}($|/)`);c=c.replace(E,"/").replace(g,""),n.nodePath=t+c}n.searchParams=Object.fromEntries(i),n.search="?"+i.toString()}return n};function k(){var e;let t=()=>{try{let{href:a}=window.parent.location;return a!=null}catch(a){return!1}};function r(){if(!(typeof window>"u"))return t()?window.parent:window}let o={serverUrl:t()&&typeof window<"u"?(e=r())==null?void 0:e.location.href:""},n=a=>new Promise(f=>{setTimeout(f,a)}),l=(a,f,v=5e3)=>S(null,null,function*(){for(;!a();)if(yield n(200),v>0&&f&&Date.now()-f.getTime()>v){P("Wait timeout");break}return a()}),i=()=>typeof window<"u"?window!==window.parent:!1,d=()=>{let a=r();return new URLSearchParams(a?.location.search).get("mgnlPreviewAsVisitor")==="true"},u=()=>{var a;return!!((a=o.serverUrl)!=null&&a.endsWith(":edit"))},s=a=>S(null,null,function*(){var f;return yield l(()=>{var v;return((v=o.serverUrl)==null?void 0:v.length)||!1},new Date,a),!!((f=o.serverUrl)!=null&&f.endsWith(":edit"))}),p=()=>{var a;return!!((a=o.serverUrl)!=null&&a.endsWith(":view"))},c=()=>u()||!o.serverUrl,m=null,g=a=>{m&&clearTimeout(m),m=setTimeout(E,a)},E=()=>{let a=r();a!=null&&a.mgnlRefresh&&(document.documentElement.innerHTML.indexOf("cms:page content=")>-1?a.mgnlRefresh():g(200))};return{isSameOrigin:t,inIframe:i,inEditorAsync:s,inEditorPreview:p,inPreviewAsVisitor:d,isRenderingAnnotation:c,isPageEditorReady:()=>{let a=r();return a?.mgnlFrameReady!==void 0},onFrameReady:()=>{let a=r();a!=null&&a.mgnlFrameReady&&a.mgnlFrameReady()},setServerUrl:a=>{o.serverUrl=a},inEditor:u,refresh:g,getMagnoliaContext:z}}var h=k(),T="selectedComponentVariants",O=(e,t,r)=>{if(!t||typeof r!="function")return;let o=t.toLowerCase();e[o]=e[o]||[],e[o].push(r)};function j(e){let t=new URL(e);return`${t.protocol}//${t.hostname}${t.port?`:${t.port}`:""}${t.pathname.substring(0,t.pathname.indexOf(".magnolia"))}`}function B(e,t){return t?e[t.toLowerCase()]||[]:[]}function I(e,t){var r;let o="mgnlPageEditorBridge",n=document.getElementById(o);if(n||!t){typeof e=="function"&&e();return}let l=j(t),i=document.getElementsByTagName("script")[0];n=document.createElement("script"),n.id=o,n.src=`${l}VAADIN/widgetsets/info.magnolia.PageEditor/info.magnolia.PageEditor.nocache.js`,(r=i.parentNode)==null||r.insertBefore(n,i),n.onload=()=>{setTimeout(function u(){h.isPageEditorReady()?(h.onFrameReady(),h.refresh(),typeof e=="function"&&e()):setTimeout(u,100)},50)};let d=document.createElement("link");d.href=`${l}VAADIN/themes/pages-app/page-editor.css`,d.type="text/css",d.rel="stylesheet",document.head.insertBefore(d,document.head.firstChild)}var C=()=>{let e={element:{dialog:"",path:"/",workspace:"website"},action:"initialize",elementType:"page"};window.parent.postMessage(JSON.stringify(e),"*")},W=(e,t)=>{typeof window>"u"||h.isSameOrigin()||(window.addEventListener("message",r=>
1{if(!r.data||!(typeof r.data=="string"&&r.data.startsWith("{")))return;let o=JSON.parse(r.data);B(e,o.action).forEach(n=>{try{n(o)}catch(l){console.error(l)}})}),O(e,"updateState",r=>{let o=r.serverUrl;h.setServerUrl(o),I(t,o)}),C())},F=(e,t)=>typeof e=="object"&&Object.keys(e).length>0?JSON.stringify(e)!==t.get(T):!1,J=(e,t)=>{O(e,"updateState",r=>{let o=r,n=new URL(window.location.href);F(o.selectedComponentVariants,n.searchParams)&&(n.searchParams.set(T,JSON.stringify(o.selectedComponentVariants)),t?(window.history.pushState({},"",n.toString()),window.dispatchEvent(new Event("popstate"))):window.location.href=n.toString())})},Q=Object.freeze(Object.defineProperty({__proto__:null,getBaseServerUrl:j,init:W,initialVariantsHandler:J,onMessage:O,requestServerUrl:C},Symbol.toStringTag,{value:"Module"}));function U(e,t){if(!e||!t)return e;let r=JSON.parse(JSON.stringify(e));return Object.keys(t).forEach(o=>{if(o.includes(e?.["@path"])&&t[o].startsWith("cms:area")){let n=o.split("/").pop();n&&!(n in e)&&(r[n]={"@path":`${e?.["@path"]}/${n}`,"@nodes":[],"@id":`${e?.["@path"]}/${n}`})}}),r}var X=Object.freeze(Object.defineProperty({__proto__:null,generateMissingAreas:U},Symbol.toStringTag,{value:"Module"})),_=(e,t)=>
1{if(!e||!t)return e;let r=t[e?.["@path"]],o=r?r.match(/selectedVariant="(.+)"/):null;if(!o)return e;let n=o[1];return n===e["@name"]?e:e[n]?e[n]:null},q=(e,t)=>!h.inIframe()||h.inPreviewAsVisitor()?e:_(e,t),$=(e,t)=>{if(!e||!t)return e;let r={},o=/selectedVariant="(.+?)"/,n=/content="(.+?)"/,l=/((variants|variantTitles)=".+?")/g;return Object.entries(e).forEach(i=>{var d,u;let[s,p]=i;if(o.test(p)&&s in t){let c=t[s];if(c==="original")c=s.split("/").pop(),r[s]=p.replace(o,`selectedVariant="${c}"`);else{let m=s+"/variants/"+c,g=e[m];g!=null?(r[s]=g.replace(n,((d=p.match(n))==null?void 0:d[0])||""),r[s]=r[s].concat(" ",((u=p.match(l))==null?void 0:u.join(" "))||""),r[s]=r[s].concat(" ",`selectedVariant="${c}"`)):P("Cannot find the variant with path '%s'. Please review the document https://docs.magnolia-cms.com/headless/spa-development/personalization-of-headless-SPA-projects.html#_notes.",m)}}}),w(w({},e),r)},H=(e,t,r)=>{let o;!t||!r?o=t||{}:o=$(t,r);let n=U(e,o);return n=_(n,o),{content:n,templateAnnotations:o}},Y=Object.freeze(Object.defineProperty({__proto__:null,getRenderContent:H,getSelectedVariant:_,getVariant:q,wrap:$},Symbol.toStringTag,{value:"Module"})),Z={TEMPLATE_ID_PROP:"mgnl:template",END_AREA_COMMENT:"/cms:area",END_COMPONENT_COMMENT:"/cms:component"};export{G as a,K as b,h as c,Q as d,X as e,Y as f,Z as g};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.