(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,31462,e=>{"use strict";let t,n,i;var r,o,s,a=e.i(43476),l=Object.create,c=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),g={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},v={0:8203,1:8204,2:8205,3:65279},m={0:String.fromCodePoint(v[0]),1:String.fromCodePoint(v[1]),2:String.fromCodePoint(v[2]),3:String.fromCodePoint(v[3])},E=[,,,,].fill(String.fromCodePoint(v[0])).join(""),b=Object.fromEntries(Object.entries(m).map(e=>[e[1],+e[0]])),y=Object.fromEntries(Object.entries(g).map(e=>e.reverse())),_=`${Object.values(g).map(e=>`\\u{${e.toString(16)}}`).join("")}`,O=RegExp(`[${_}]{4,}`,"gu"),T=h((e,t)=>{var n=Object.prototype.hasOwnProperty,i=Object.prototype.toString;t.exports=function(e,t,r){if("[object Function]"!==i.call(t))throw TypeError("iterator must be a function");var o=e.length;if(o===+o)for(var s=0;se.replace(/_([a-z])/g,(e,t)=>t.toUpperCase()));[...C,...w];var I="4.10.5",S=!1,A=e=>(...t)=>{S&&console[e](...t)},D={error:A("error"),warn:A("warn"),log:A("log")},M=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]);function L(e,t,n){let i={...t,method:e,source:"live-preview-sdk",location:window.location.href,version:I};D.log("Send message",i),n.forEach(e=>{window.top?.postMessage(i,e)})}var j=(t=(t,n)=>{var i,r,o,s="__lodash_hash_undefined__",a="[object Arguments]",l="[object Array]",c="[object Boolean]",u="[object Date]",d="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",g="[object Object]",v="[object Promise]",m="[object RegExp]",E="[object Set]",b="[object String]",y="[object WeakMap]",_="[object ArrayBuffer]",O="[object DataView]",T=/^\[object .+?Constructor\]$/,C=/^(?:0|[1-9]\d*)$/,w={};w["[object Float32Array]"]=w["[object Float64Array]"]=w["[object Int8Array]"]=w["[object Int16Array]"]=w["[object Int32Array]"]=w["[object Uint8Array]"]=w["[object Uint8ClampedArray]"]=w["[object Uint16Array]"]=w["[object Uint32Array]"]=!0,w[a]=w[l]=w[_]=w[c]=w[O]=w[u]=w[d]=w[f]=w[p]=w[h]=w[g]=w[m]=w[E]=w[b]=w[y]=!1;var I=e.g&&e.g.Object===Object&&e.g,S="object"==typeof self&&self&&self.Object===Object&&self,A=I||S||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,M=D&&"object"==typeof n&&n&&!n.nodeType&&n,L=M&&M.exports===D,j=L&&I.process,N=function(){try{return j&&j.binding&&j.binding("util")}catch{}}(),R=N&&N.isTypedArray;function P(e){var t=-1,n=Array(e.size);return e.forEach(function(e,i){n[++t]=[i,e]}),n}function U(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var B=Array.prototype,x=Function.prototype,z=Object.prototype,k=A["__core-js_shared__"],F=x.toString,G=z.hasOwnProperty,$=(i=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+i:"",V=z.toString,Y=RegExp("^"+F.call(G).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),H=L?A.Buffer:void 0,K=A.Symbol,Z=A.Uint8Array,q=z.propertyIsEnumerable,J=B.splice,W=K?K.toStringTag:void 0,X=Object.getOwnPropertySymbols,Q=H?H.isBuffer:void 0,ee=(r=Object.keys,o=Object,function(e){return r(o(e))}),et=ew(A,"DataView"),en=ew(A,"Map"),ei=ew(A,"Promise"),er=ew(A,"Set"),eo=ew(A,"WeakMap"),es=ew(Object,"create"),ea=eA(et),el=eA(en),ec=eA(ei),eu=eA(er),ed=eA(eo),ef=K?K.prototype:void 0,ep=ef?ef.valueOf:void 0;function eh(e){var t=-1,n=null==e?0:e.length;for(this.clear();++ta))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var u=-1,d=!0,f=2&n?new em:void 0;for(o.set(e,t),o.set(t,e);++u-1},eg.prototype.set=function(e,t){var n=this.__data__,i=eb(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this},ev.prototype.clear=function(){this.size=0,this.__data__={hash:new eh,map:new(en||eg),string:new eh}},ev.prototype.delete=function(e){var t=eC(this,e).delete(e);return this.size-=!!t,t},ev.prototype.get=function(e){return eC(this,e).get(e)},ev.prototype.has=function(e){return eC(this,e).has(e)},ev.prototype.set=function(e,t){var n=eC(this,e),i=n.size;return n.set(e,t),this.size+=+(n.size!=i),this},em.prototype.add=em.prototype.push=function(e){return this.__data__.set(e,s),this},em.prototype.has=function(e){return this.__data__.has(e)},eE.prototype.clear=function(){this.__data__=new eg,this.size=0},eE.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},eE.prototype.get=function(e){return this.__data__.get(e)},eE.prototype.has=function(e){return this.__data__.has(e)},eE.prototype.set=function(e,t){var n=this.__data__;if(n instanceof eg){var i=n.__data__;if(!en||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new ev(i)}return n.set(e,t),this.size=n.size,this};var eI=X?function(e){return null==e?[]:function(e,t){for(var n=-1,i=null==e?0:e.length,r=0,o=[];++n-1&&e%1==0&&e<=0x1fffffffffffff}function eP(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function eU(e){return"object"==typeof e&&!!e}var eB=R?function(e){return R(e)}:function(e){return eU(e)&&eR(e.length)&&!!w[ey(e)]};function ex(e){return null!=e&&eR(e.length)&&!eN(e)?function(e){var t,n=eL(e),i=!n&&eM(e),r=!n&&!i&&ej(e),o=!n&&!i&&!r&&eB(e),s=n||i||r||o,a=s?function(e,t){for(var n=-1,i=Array(e);++n-1&&c%1==0&&c(n||t((n={exports:{}}).exports,n),n.exports)),N=((e,t,n,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var r,o=d(t),s=0,a=o.length;st[e]).bind(null,r),enumerable:!(i=u(t,r))||i.enumerable});return e})(c(null==(i=j())?{}:l(f(i)),"default",{value:i,enumerable:!0}),i),R=((r={}).FIELD_ID="data-contentful-field-id",r.ENTRY_ID="data-contentful-entry-id",r.ASSET_ID="data-contentful-asset-id",r.LOCALE="data-contentful-locale",r.SPACE="data-contentful-space",r.ENVIRONMENT="data-contentful-environment",r),P=((o={}).MOUSE_MOVE="MOUSE_MOVE",o.SCROLL_START="SCROLL_START",o.SCROLL_END="SCROLL_END",o.RESIZE_START="RESIZE_START",o.RESIZE_END="RESIZE_END",o.TAGGED_ELEMENTS="TAGGED_ELEMENTS",o.INSPECTOR_MODE_CHANGED="INSPECTOR_MODE_CHANGED",o),U={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},B={0:8203,1:8204,2:8205,3:65279},x={0:String.fromCodePoint(B[0]),1:String.fromCodePoint(B[1]),2:String.fromCodePoint(B[2]),3:String.fromCodePoint(B[3])};[,,,,].fill(String.fromCodePoint(B[0])).join(""),Object.fromEntries(Object.entries(x).map(e=>[e[1],+e[0]])),Object.fromEntries(Object.entries(U).map(e=>e.reverse()));var z=`${Object.values(U).map(e=>`\\u{${e.toString(16)}}`).join("")}`,k=RegExp(`[${z}]{4,}`,"gu");function F(e,t){return e.href===t.href}function G({root:e=window.document,options:t}){var n,i;let r,o=[...t.ignoreManuallyTaggedElements?[]:e.querySelectorAll(`[${R.ASSET_ID}][${R.FIELD_ID}], [${R.ENTRY_ID}][${R.FIELD_ID}]`)].map(e=>({element:e,attributes:function(e,t){if(!(e&&e.nodeType===Node.ELEMENT_NODE&&!(!e.hasAttribute(R.FIELD_ID)||!e.hasAttribute(R.ENTRY_ID)&&!e.hasAttribute(R.ASSET_ID))))return null;let n={fieldId:e.getAttribute(R.FIELD_ID),locale:e.getAttribute(R.LOCALE)??t.locale,environment:e.getAttribute(R.ENVIRONMENT)??t.environment,space:e.getAttribute(R.SPACE)??t.space,manuallyTagged:!0};if(!n.fieldId)return D.warn("Element is missing field ID attribute and cannot be tagged",{id:e.getAttribute(R.ENTRY_ID)??e.getAttribute(R.ASSET_ID),sharedProps:n}),null;let i=e.getAttribute(R.ENTRY_ID);if(i)return{...n,entryId:i};let r=e.getAttribute(R.ASSET_ID);return r?{...n,assetId:r}:null}(e,t)})).filter(({attributes:e})=>null!==e),s=[];for(let{node:t,text:i}of(n="body"in e?e.body:e,r=[],"function"==typeof n.matches&&n.matches("*")&&(r=[n]),[...r,...Array.from(n.querySelectorAll("*:not(script,style,meta,title)"))].map(e=>{var t;return{node:e,text:(t=e).matches("input[type=submit], input[type=button], input[type=reset]")?t.value:t.matches("img, video")?t.alt:Array.from(t.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE&&!!e.textContent).map(e=>e.textContent).join("")}}).filter(({text:e})=>!!(e&&e.match(k))))){let e=function(e){let t=e.match(O);return t?function(e,t=!1){let n=Array.from(e),i=1/0,r=-1;for(let e=0;eJSON.parse(e))}catch{}return[]}(t[0],!0)[0]:void 0}(i);if(!e||!e.origin.includes("contentful.com")){D.warn("Element has missing or invalid ContentSourceMap, please check if you have correctly enabled ContentSourceMaps and that the element's data originates from Contentful",{node:t,sourceMap:e});continue}if(!(function(e,t){for(let n of t)if(n.element===e||n.element.contains(e))return!0;return!1}(t,o)||s.some(n=>n.element.contains(t)&&F(n.sourceMap,e)))){if(t.matches("img")){let n=t.closest("figure")||t.closest("picture")||t;s.push({element:n,sourceMap:e});continue}s.push({element:t,sourceMap:e})}}let a=s.filter((e,t)=>s.findIndex(t=>!(!F(e.sourceMap,t.sourceMap)||e.element!==t.element))===t);for(let{element:e,sourceMap:t}of a){let n=null;if(t.href){let i=function(e){try{let t=new URL(e),n=t.searchParams.get("focusedField"),i=t.searchParams.get("focusedLocale"),r=t.pathname.split("/").filter(Boolean),o=r.indexOf("spaces"),s=r.indexOf("environments"),a=-1===o?void 0:r[o+1],l=-1===s?void 0:r[s+1],c,u,d=r.indexOf("entries"),f=r.indexOf("assets");return -1===d?-1!==f&&(c="Asset",u=r[f+1]):(c="Entry",u=r[d+1]),c&&u?n?i?a&&l?{entityId:u,entityType:c,fieldId:n,locale:i,space:a,environment:l}:(console.warn("Missing space or environment in href path",{href:e}),null):(console.warn("Missing focusedLocale query parameter in href",{href:e}),null):(console.warn("Missing focusedField query parameter in href",{href:e}),null):(console.warn("Unable to determine entityType or entityId from href",{href:e}),null)}catch(t){return console.warn("Invalid href URL",{href:e,error:t}),null}}(t.href);if(!i)continue;if("Asset"===i.entityType)n={fieldId:i.fieldId,locale:i.locale,space:i.space,environment:i.environment,assetId:i.entityId};else if("Entry"===i.entityType)n={fieldId:i.fieldId,locale:i.locale,space:i.space,environment:i.environment,entryId:i.entityId};else{D.warn("Unknown entityType",{element:e,sourceMap:t});continue}}else{if(t.contentful&&(i=t.contentful)&&"string"==typeof i.entity&&"string"==typeof i.field&&"string"==typeof i.locale&&"string"==typeof i.space&&"string"==typeof i.environment&&("Asset"===i.entityType||"Entry"===i.entityType)){let i=t.contentful;if(!i.entity||!i.field||!i.locale||!i.space||!i.environment){D.warn("Element has missing information in their ContentSourceMap, please check if you have restricted the platform for the encoding. (Missing parameters in `contentful`)",{element:e,sourceMap:t});continue}let r={fieldId:i.field,locale:i.locale,space:i.space,environment:i.environment};if("Asset"===i.entityType)r.assetId=i.entity,n=r;else if("Entry"===i.entityType)r.entryId=i.entity,n=r;else{D.warn("Unknown entityType in contentful data",{element:e,sourceMap:t});continue}}else{D.warn("Element has neither href nor contentful data in their ContentSourceMap, unable to extract attributes.",{element:e,sourceMap:t});continue}}o.push({element:e,attributes:n})}let l=o.filter(({attributes:e})=>e?.manuallyTagged===!1||!e?.manuallyTagged).length;return{taggedElements:o,manuallyTaggedCount:o.length-l,automaticallyTaggedCount:l,autoTaggedElements:a}}function $({options:e}){return[...new Set(G({options:e}).taggedElements.map(e=>e.attributes&&"entryId"in e.attributes?e.attributes.entryId:null).filter(Boolean))]}var V=class{delay=300;isScrolling=!1;scrollTimeout;isResizing=!1;resizeTimeout;hoveredElement;taggedElements=[];manuallyTaggedCount=0;automaticallyTaggedCount=0;releaseId;intersectionObserver;observersCB=[];cleanupCB=[];constructor(e){this.options=e,this.intersectionObserver=new IntersectionObserver(e=>{let t=this.taggedElements;for(let n of e)if(n.isIntersecting)for(let e of t)e.element===n.target&&(e.coordinates=n.intersectionRect,e.isVisible=n.target.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}));this.taggedElements=t,this.sendTaggedElements()},{threshold:.15})}init=()=>{this.cleanupCB=[this.addScrollListener(),this.addMutationListener(document.body),this.addResizeListener(),this.addHoverListener()],this.updateElements()};cleanup=()=>{this.observersCB.forEach(e=>e()),this.cleanupCB.forEach(e=>e())};receiveMessage=e=>{if(e.method===P.INSPECTOR_MODE_CHANGED){let{isInspectorActive:t,releaseId:n}=e;this.releaseId=n,t?this.init():this.cleanup()}};observe=e=>{this.intersectionObserver.observe(e);let t=this.addMutationListener(e);this.observersCB.push(t,()=>this.intersectionObserver.unobserve(e))};addScrollListener=()=>{let{targetOrigin:e}=this.options,t=()=>{this.isScrolling||(this.isScrolling=!0,L(P.SCROLL_START,{},e)),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.isScrolling=!1,L(P.SCROLL_END,{},e),this.updateElements()},this.delay)},n={capture:!0,passive:!0};return window.addEventListener("scroll",t,n),()=>window.removeEventListener("scroll",t,n)};addMutationListener=e=>{let t=new MutationObserver(()=>{this.updateElements()});return t.observe(e,{characterData:!0,attributes:!0,attributeFilter:[R.ENTRY_ID,R.FIELD_ID,R.LOCALE,R.SPACE,R.ENVIRONMENT,"class","style"],childList:!0,subtree:!0}),()=>t.disconnect()};addResizeListener=()=>{let{targetOrigin:e}=this.options,t=new ResizeObserver(()=>{this.isResizing||(this.isResizing=!0,L(P.RESIZE_START,{},e)),this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.isResizing=!1,L(P.RESIZE_END,{},e),this.updateElements()},this.delay)});return t.observe(document.body),()=>t.disconnect()};addHoverListener=()=>{let e=function(e,t=100){let n;return(...i)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(this,i)},t)}}(e=>{let t;for(let n of e){let e=n;if("BODY"===e.nodeName)break;let i=this.taggedElements.find(t=>t.element===e);if(i){t=i;break}}this.hoveredElement=t?.element,this.updateElements()},this.delay),t=t=>{e(t.composedPath())};return window.addEventListener("mouseover",t,{passive:!0}),()=>window.removeEventListener("mouseover",t)};sendTaggedElements=()=>{L(P.TAGGED_ELEMENTS,{elements:this.taggedElements.map(e=>({coordinates:e.coordinates,isVisible:!!e.isVisible,attributes:e.attributes,isHovered:this.hoveredElement===e.element,isCoveredByOtherElement:!!e.isCoveredByOtherElement,snapshot:M.has(e.element.tagName.toUpperCase())?{[e.element.tagName.toLowerCase()]:Array.from(e.element.attributes).map(e=>`${e.name}="${e.value}"`).join(" ")}:{[e.element.tagName.toLowerCase()]:e.element.innerHTML}})),automaticallyTaggedCount:this.automaticallyTaggedCount,manuallyTaggedCount:this.manuallyTaggedCount,...void 0!==this.releaseId&&{releaseId:this.releaseId}},this.options.targetOrigin)};updateElements=()=>{let{taggedElements:e,manuallyTaggedCount:t,automaticallyTaggedCount:n}=G({options:this.options}),i=((e,t=window.document)=>((e,t=window.document)=>e.map(e=>({...e,isVisible:e.element.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}),isCoveredByOtherElement:((e,t,n=window.document)=>{let{top:i,right:r,bottom:o,left:s}=t,a=n.elementFromPoint(s+1,i+1),l=n.elementFromPoint(r-1,i+1),c=n.elementFromPoint(s+1,o-1),u=n.elementFromPoint(r-1,o-1),d=t=>!!t&&(e===t||e.contains(t));return[d(a),d(l),d(c),d(u)].filter(Boolean).length<2})(e.element,e.coordinates,t)})))(e.map(({element:e,attributes:t})=>({element:e,coordinates:e.getBoundingClientRect(),attributes:t})),t))(e);(0,N.default)(i,this.taggedElements)||(this.observersCB.forEach(e=>e()),this.observersCB=[],this.taggedElements=i,e.forEach(({element:e})=>this.observe(e)),this.manuallyTaggedCount=t,this.automaticallyTaggedCount=n)}},{parse:Y,stringify:H}=JSON,{keys:K}=Object,Z=String,q="object",J=(e,t)=>t,W=(e,t,n)=>{let i=Z(t.push(n)-1);return e.set(n,i),i},X=((s=X||{}).CONNECTED="CONNECTED",s.DISCONNECTED="DISCONNECTED",s.ERROR="ERROR",s.TAGGED_FIELD_CLICKED="TAGGED_FIELD_CLICKED",s.URL_CHANGED="URL_CHANGED",s.SUBSCRIBED="SUBSCRIBED",s.UNSUBSCRIBED="UNSUBSCRIBED",s.ENTRY_UPDATED="ENTRY_UPDATED",s.ENTRY_SAVED="ENTRY_SAVED",s.DEBUG_MODE_ENABLED="DEBUG_MODE_ENABLED",s),Q=class{subscriptions=new Map;defaultLocale;sendMessage;constructor({locale:e,targetOrigin:t}){this.defaultLocale=e,this.sendMessage=(e,n)=>L(e,n,t)}async receiveMessage(e){if(e.method===X.ENTRY_UPDATED){let{data:t,subscriptionId:n}=e,i=this.subscriptions.get(n);i?(i.callback(t),i.data=t,this.subscriptions.set(n,i)):D.error("Received an update for an unknown subscription",{subscriptionId:n,data:t,subscriptions:this.subscriptions})}}subscribe(e){let t=`${performance.now()}-${Math.random().toString(36).slice(2)}`,n=e.locale??this.defaultLocale;this.subscriptions.set(t,{...e});let i={locale:n,event:"edit",id:t,config:((e,t,n)=>{let i=t&&typeof t===q?(e,n)=>""===e||-1{this.sendMessage(X.UNSUBSCRIBED,i),this.subscriptions.delete(t)}}},ee=class{locale;options;inspectorModeEnabled;subscription;constructor({locale:e,options:t,inspectorModeEnabled:n}){this.locale=e,this.options=t,this.inspectorModeEnabled=n}subscribe(e){return this.subscription&&D.log("There is already a subscription for the save event, the existing one will be replaced."),this.subscription=e,()=>{this.subscription=void 0}}receiveMessage(e){if(e.method===X.ENTRY_SAVED&&this.subscription){let{entity:t}=e;this.inspectorModeEnabled?$({options:this.options}).includes(t.sys.id)&&this.subscription(t):this.subscription(t)}}},et=["https://app.contentful.com","https://app.eu.contentful.com","http://localhost:3001"],en=class e{static initialized=!1;static inspectorMode=null;static liveUpdates=null;static saveEvent=null;static inspectorModeEnabled=!0;static liveUpdatesEnabled=!0;static locale;static space;static environment;static sendMessage;static targetOrigin;static init(t){if("object"!=typeof t||!t?.locale)throw Error("Init function has to be called with a locale configuration (for example: `ContentfulLivePreview.init({ locale: 'en-US'})`)");let{debugMode:n,enableInspectorMode:i,enableLiveUpdates:r,locale:o,environment:s,space:a,targetOrigin:l}=t;if("u">typeof window){if(!function(){try{return window.top?.location.href!==window.location.href}catch{return!0}}())return this.liveUpdatesEnabled=!1,Promise.resolve(null);if(n&&(S=n),"boolean"==typeof i&&(this.inspectorModeEnabled=i),"boolean"==typeof r&&(this.liveUpdatesEnabled=r),this.locale=o,this.space=a,this.environment=s,this.initTargetOrigin(l),this.initialized)return D.log("You have already initialized the Live Preview SDK."),Promise.resolve(e.inspectorMode);this.inspectorModeEnabled&&(this.inspectorMode=new V({locale:o,space:a,environment:s,targetOrigin:this.targetOrigin,ignoreManuallyTaggedElements:t.experimental?.ignoreManuallyTaggedElements})),this.liveUpdatesEnabled&&(this.liveUpdates=new Q({locale:o,targetOrigin:this.targetOrigin}),this.saveEvent=new ee({locale:o,options:{locale:this.locale,space:this.space,environment:this.environment,targetOrigin:this.targetOrigin},inspectorModeEnabled:this.inspectorModeEnabled})),window.addEventListener("message",e=>{if("object"==typeof e.data&&e.data&&"source"in e.data&&"live-preview-editor"===e.data.source){if(D.log("Received message",e.data),e.data.method===X.DEBUG_MODE_ENABLED)return void(S=!0);this.inspectorModeEnabled&&this.inspectorMode?.receiveMessage(e.data),this.liveUpdatesEnabled&&(this.liveUpdates?.receiveMessage(e.data),this.saveEvent?.receiveMessage(e.data))}}),function(e,t=500){let n=window.location.href,i=setInterval(()=>{let t=window.location.href;t!==n&&(n=t,e(t))},t)}(()=>{L(X.URL_CHANGED,{action:X.URL_CHANGED,taggedElementCount:document.querySelectorAll(`[${R.ENTRY_ID}]`).length},this.targetOrigin)});let{taggedElements:c,manuallyTaggedCount:u,automaticallyTaggedCount:d}=this.inspectorModeEnabled?G({options:{locale:this.locale,space:this.space,environment:this.environment}}):{taggedElements:[],manuallyTaggedCount:0,automaticallyTaggedCount:0},f=c.length;return L(X.CONNECTED,{action:X.CONNECTED,connected:!0,tags:f,taggedElementCount:f,locale:this.locale,isInspectorEnabled:this.inspectorModeEnabled,isLiveUpdatesEnabled:this.liveUpdatesEnabled,manuallyTaggedElementCount:u,automaticallyTaggedElementCount:d,hideCoveredElementOutlines:t.experimental?.hideCoveredElementOutlines,version:I},this.targetOrigin),this.initialized=!0,Promise.resolve(e.inspectorMode)}}static initTargetOrigin(e){if(e)this.targetOrigin=Array.isArray(e)?e:[e];else{let e=window.location.ancestorOrigins,t=e?et.find(t=>e.contains(t)):et.find(e=>document.referrer.includes(e));if(!t)throw Error("The current origin is not supported. Please provide a targetOrigin in the live preview configuration.");this.targetOrigin=[t]}}static subscribe(e,t){if(!this.liveUpdatesEnabled)return()=>{};let n="string"==typeof e?e:"edit",i="object"==typeof e?e:t;if("save"===n){if(!this.saveEvent)throw Error("Save event is not initialized, please call `ContentfulLivePreview.init()` first.");return this.saveEvent.subscribe(i.callback)}if(!this.liveUpdates)throw Error("Live updates are not initialized, please call `ContentfulLivePreview.init()` first.");return this.liveUpdates.subscribe(i)}static getProps(e){let{fieldId:t,locale:n,environment:i,space:r}=e;if(!this.inspectorModeEnabled)return null;if(t){let o={...n?{[R.LOCALE]:n}:{},...i?{[R.ENVIRONMENT]:i}:{},...r?{[R.SPACE]:r}:{},[R.FIELD_ID]:t};if(n&&(o[R.LOCALE]=n),void 0!==e.assetId)return{...o,[R.ASSET_ID]:e.assetId};if(void 0!==e.entryId)return{...o,[R.ENTRY_ID]:e.entryId}}return D.warn("Missing property for inspector mode",{...e}),null}static toggleInspectorMode(){return this.inspectorModeEnabled=!this.inspectorModeEnabled,this.inspectorModeEnabled}static toggleLiveUpdatesMode(){return this.liveUpdatesEnabled=!this.liveUpdatesEnabled,this.liveUpdatesEnabled}static openEntryInEditor(e){let t={locale:this.locale,environment:this.environment,space:this.space};if(void 0!==e.assetId&&e.fieldId||void 0!==e.entryId&&e.fieldId){var n,i;return void(n={...t,...e},i=this.targetOrigin,L(X.TAGGED_FIELD_CLICKED,{action:X.TAGGED_FIELD_CLICKED,...n},i))}D.error("Please provide field id and entry/asset id to openEntryInEditor.",{...e})}static getEntryList(){return $({options:{locale:this.locale,space:this.space,environment:this.environment}})}},ei=e.i(71645);j();var er=(0,ei.createContext)(null);function eo({children:e,locale:t,space:n,environment:i,debugMode:r=!1,enableInspectorMode:o=!0,enableLiveUpdates:s=!0,targetOrigin:l,experimental:c}){if(!t)throw Error('ContentfulLivePreviewProvider has to be called with a locale property (for example: `{children}`');en.init({locale:t,space:n,environment:i,debugMode:r,enableInspectorMode:o,enableLiveUpdates:s,targetOrigin:l,experimental:c});let u=(0,ei.useMemo)(()=>({locale:t,space:n,environment:i,debugMode:r,enableInspectorMode:o,enableLiveUpdates:s,targetOrigin:l}),[t,n,i,r,o,s,l]);return(0,a.jsx)(er.Provider,{value:u,children:e})}e.s(["ContentfulPreviewProvider",0,({children:e,...t})=>(0,a.jsx)(eo,{...t,children:e})],31462)}]);