@datawheel/bespoke 0.9.11 → 0.9.12-rc.2

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.
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-7K6SKRXP.js';import {b as b$1,d,c}from'./chunk-4XIZPGIL.js';import {O,Oa,Pa,Va,J}from'./chunk-AA4WMKFB.js';import {a}from'./chunk-P6ORTCRN.js';import {b}from'./chunk-QZ5NBDGE.js';import {memo,useMemo}from'react';import {Center,Badge}from'@mantine/core';import*as Z from'd3plus-react';import {useRouter}from'next/router';import {jsx}from'react/jsx-runtime';var q=()=>({}),G={},m={[c]:d,...Z,...G};function K({block:o,active:e,locale:a$2,variables:s,configOverride:L={}}){let N=q(),c=O(o),u=Oa(a$2),I={variables:s},A=Pa(),g=a(),J$1=useRouter(),{sectionVariables:d,setSectionVariables:M,resetSectionVariables:R}=Va(o?.section_id),p=b(),t=useMemo(()=>{if(!e)return {error:"Activate to View"};if(!c?.logic)return {error:"Add a Configuration"};let f=J({logic:c.logic},u,I).logic,n={router:J$1,section:{variables:d,setVariables:M,resetVariables:R},events:{fire:(l,x={})=>p("viz_interaction",{name:l,...x},{component:"Viz",blockId:o.id,sectionId:o.section_id})}};return b$1(f,u,s,a$2,o.id,{},n,A,g)},[c?.logic,e,s,d,g.status,p]),{type:i}=t.config||{},_=i&&m[i]?i:"Treemap";i||(t.config={error:'Visualization missing "type"'}),m[i]||(t.config={error:`"${i}" is not a valid Visualization Type`});let h=m[_],y=t.error||t.config?.error||false;if(y)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:y},"type")});let{_data:Q,...w}=t.config,V={locale:a$2,variables:s,...w,...L};return N.print&&(V.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(a$1,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(h,{style:{flex:1},dataFormat:f=>{let n;try{n=t.dataFormat(f);}catch(l){console.error("Error in dataFormat: ",l),n=[];}return n},linksFormat:t.linksFormat,nodesFormat:t.nodesFormat,topojsonFormat:t.topojsonFormat,config:{...V}},"viz-key")})})}var mo=memo(K,(o,e)=>o.block.contentByLocale.logic.content===e.block.contentByLocale.logic.content&&o.active===e.active&&o.locale===e.locale&&JSON.stringify(o.variables)===JSON.stringify(e.variables)&&JSON.stringify(o.configOverride)===JSON.stringify(e.configOverride));export{mo as default};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-7K6SKRXP.js';import {K}from'./chunk-NKCSPYUO.js';import {b as b$1,d as d$1,c}from'./chunk-4XIZPGIL.js';import'./chunk-KUPNLLLT.js';import {O,Oa,Va,Pa,J as J$1}from'./chunk-AA4WMKFB.js';import {a}from'./chunk-P6ORTCRN.js';import {b}from'./chunk-QZ5NBDGE.js';import*as J from'd3plus-react';import {useMemo}from'react';import {useRouter}from'next/router';import {jsx}from'react/jsx-runtime';var d={...J,[c]:d$1},Z=(c,n)=>{let o={...c};return n&&(o.detectResize=false,o.detectResizeDelay=0,o.detectVisible=false,o.detectVisibleInterval=0,o.duration=0,o.shapeConfig={...o.shapeConfig,duration:0}),o};function $(c$1){let{print:n}=K(),{block:o,active:h,locale:l,variables:s,configOverride:x={}}=c$1,m=O(o),u=Oa(l),L={variables:s},N=useRouter(),{sectionVariables:g,setSectionVariables:O$1,resetSectionVariables:H}=Va(o?.section_id),M=Pa(),v=a(),y=b(),b$2=JSON.stringify(g),e=useMemo(()=>{if(!m?.logic)return {error:"Add a Configuration"};let a=J$1({logic:m.logic},u,L).logic,t={router:N,section:{variables:g,setVariables:O$1,resetVariables:H},events:{fire:(p,w={})=>y("viz_interaction",{name:p,...w},{component:"Viz",blockId:o.id,sectionId:o.section_id})}};return b$1(a,u,s,l,o.id,{},t,M,v)},[o,h,s,b$2,v.status,y]),{type:r}=e.config||{},A=r&&d[r]?r:"Treemap";d[r]||(e.config={error:`"${r}" is not a valid Visualization Type`});let D=d[A],j=useMemo(()=>{let{_data:a,...t}=e.config;return Z(t,n)},[e,n]),V={locale:l,variables:s,...j,...x};return jsx("div",{className:"bespoke-Viz","data-ignore-print":V._printIgnore?"true":void 0,children:jsx("div",{style:{display:"flex",flex:"1 1 100%",minHeight:r===c?void 0:400},children:jsx(a$1,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(D,{style:{flex:1},dataFormat:a=>{let t;try{t=e.dataFormat(a);}catch(p){console.error("Error in dataFormat: ",p),t=[];}return t},linksFormat:e.linksFormat,nodesFormat:e.nodesFormat,topojsonFormat:e.topojsonFormat,config:{...V,sectionVariables:b$2}},"viz-key")})})})}export{$ as default};
@@ -1,3 +1,3 @@
1
- import {i,X,j}from'./chunk-EYRXKCMJ.js';import {dataConcat}from'd3plus-viz';import {jsx}from'react/jsx-runtime';var x=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",L="Error Rendering Visualization",d={data:[],dataFormat:r=>r,type:"Treemap",noDataHTML:`<p style="font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
1
+ import {i,X,j}from'./chunk-AA4WMKFB.js';import {dataConcat}from'd3plus-viz';import {jsx}from'react/jsx-runtime';var x=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",L="Error Rendering Visualization",d={data:[],dataFormat:r=>r,type:"Treemap",noDataHTML:`<p style="font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
2
2
  <strong>${L}</strong>
3
3
  </p>`},y=(r,n,o)=>{let t=n.find(a=>{let s=a.content?.pattern;if(!s)return false;try{return new RegExp(s,"gm").test(r)}catch{return false}});if(t){if(t.content?.useProxy)return `${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(r)}&wrapper=false`;try{let s={envs:{...X()},...o?{session:o}:{}},i=j({vars:["url","libs","session"],logic:t.content.logic},s)(r);if(i instanceof Promise)console.warn(`[DataSource] Logic for "${t.name}" is async, which is not supported in this context. Use useProxy=true for async logic.`);else if(i?.axiosConfig?.url!=null){let{url:c,headers:e}=i.axiosConfig;return e&&Object.keys(e).length>0?{url:c,headers:e}:c}}catch(a){console.error(`[DataSource] Failed to apply logic for URL "${r}":`,a.message);}}return r},g=(r,n,o)=>typeof r=="string"?y(r,n,o):Array.isArray(r)?r.map(t=>typeof t=="string"?y(t,n,o):t):r,T=(r,n,o={},t=x,a=null,s={},u={},i$1=[],c)=>{let e;try{e=i({vars:["variables"],logic:r},n,t,s,u)(o),e.data=g(e.data,i$1,c),e._downloadUrl&&(e.__downloadUrl=g(e.__downloadUrl,i$1,c));}catch(l){return console.error(`Parsing Error in propify (ID: ${a})`),console.error(`Error message: ${l.message}`),{error:`${l}`,config:d}}if(typeof e!="object")return {error:"Visualization JS code must return an object",config:d};let F=e.dataFormat?e.dataFormat:l=>{let U=Array.isArray(e.data)&&e.data.length>1&&e.data.some(E=>typeof E=="string")?l:[l];return dataConcat(U,"data")};delete e.dataFormat;let h=e.linksFormat||void 0;delete e.linksFormat;let D=e.nodesFormat||void 0;delete e.nodesFormat;let S=e.topojsonFormat||void 0;return delete e.topojsonFormat,{config:e,dataFormat:F,linksFormat:h,nodesFormat:D,topojsonFormat:S}},P=T;var B="HTML",H=({config:r})=>!r||!r.html?null:jsx("div",{className:"bespoke-html",dangerouslySetInnerHTML:{__html:r.html}});export{g as a,P as b,B as c,H as d};
@@ -0,0 +1,35 @@
1
+ import {a as a$1}from'./chunk-P6ORTCRN.js';import {a,b}from'./chunk-QZ5NBDGE.js';import*as Mo from'd3-array';import*as Do from'd3-collection';import*as Uo from'd3-format';import*as Fo from'd3-time-format';import {formatAbbreviate}from'd3plus-format';import {date}from'd3plus-axis';import {merge,closest,assign,isObject}from'd3plus-common';import {titleCase,strip}from'd3plus-text';import lt from'axios';import wr from'axios-retry';import cn from'yn';import {format}from'pretty-format';import bn from'toposort';import {csvParse}from'd3-dsv';import gn from'jsonwebtoken';import En from'next/config';import {schema,normalize}from'normalizr';import {createSlice,configureStore}from'@reduxjs/toolkit';import {HYDRATE,createWrapper}from'next-redux-wrapper';import {notifications}from'@mantine/notifications';import {createContext,useMemo,useContext,useRef,useCallback,useEffect}from'react';import {useDispatch,useSelector}from'react-redux';import {Skeleton}from'@mantine/core';import {jsx}from'react/jsx-runtime';var fr="report",da="Report",fa=null;var mr="section",ya="Section",Ra=fr;var _o=()=>{let e=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",t=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[e];return t.includes(e)||t.push(e),{localeDefault:e,locales:t}},se=_o;var {localeDefault:Oo}=se(),Ta="block",ba="Block",Aa=mr;function ee(e){return {variables:e.variables||{},query:e.query||{},locale:e.locale||Oo}}function Ct(e){return e.reduce((t,r,o)=>(o?o===e.length-1&&o===1?t+=` and ${r}`:o===e.length-1?t+=`, and ${r}`:t+=`, ${r}`:t+=r,t),"")}function xt(e){let t=1+76.18009173/e-86.50532033/(e+1)+24.01409822/(e+2)-1.231739516/(e+3)+.00120858003/(e+4)-536382e-11/(e+5);return (e-.5)*Math.log(e+4.5)-(e+4.5)+Math.log(t*2.50662827465)}function yr(e,t,r){let o=0,n=1,s=1,i=1,a=0,c=0,u;for(;Math.abs((s-c)/s)>1e-5;)c=s,u=-(t+a)*(t+r+a)*e/(t+2*a)/(t+2*a+1),o=s+u*o,n=i+u*n,a+=1,u=a*(r-a)*e/(t+2*a-1)/(t+2*a),s=o+u*s,i=n+u*i,o/=i,n/=i,s/=i,i=1;return s/t}function Io(e,t,r){let o,n;if(e<0)n=0;else if(e>=t)n=1;else {e=Math.floor(e);let s=r,i=e+1,a=t-e,c=i+a,u=Math.exp(xt(c)-xt(a)-xt(i)+i*Math.log(s)+a*Math.log(1-s));s<(i+1)/(c+2)?o=u*yr(s,i,a):o=1-u*yr(1-s,a,i),n=1-o;}return Math.round(n*1e5)/1e5}function Bo(e){return {.99999:15.137,.99:6.635,.95:3.841,.9:2.706}[e]}function ze(e,t,r,o){let n=t/(1-t),s=0,i=1,a=0,c=0;for(;s<=e;)c+=i,s>=r&s<=o&&(a+=i),c>1e30&&(a/=1e30,c/=1e30,i/=1e30),s+=1,i=i*n*(e+1-s)/s;return a/c}function wo(e,t,r){let o=e/t,s=(100-r*100)/2,i,a;if(e===0)i=0;else {let c=o/2,u=0,d=o,p=s/100;for(;d-u>1e-5;)ze(t,c,e,e)*.5+ze(t,c,e+1,t)>p?(d=c,c=(u+c)/2):(u=c,c=(d+c)/2);i=c;}if(e===t)a=0;else {let c=(1+o)/2,u=o,d=1,p=s/100;for(;d-u>1e-5;)ze(t,c,e,e)*.5+ze(t,c,0,e-1)<p?(d=c,c=(u+c)/2):(u=c,c=(d+c)/2);a=c;}return {lci:i,uci:a}}function No(e,t){let r=e,o=t,n=r,s=o,i=95,a=.5,c=.5,d=(100-i)/2/100,p=n;for(;c>1e-5;)c/=2,ot((1+p)*a/(1-a),p+1,1e10)+.5*ot((1+p)*a/(1-a),p,p)>d?a-=c:a+=c;let f=(1+p)*a/(1-a)/s;for(a=.5,c=.5,d=(100-i)/2/100;c>1e-5;)c/=2,ot((1+p)*a/(1-a),0,p-1)+.5*ot((1+p)*a/(1-a),p,p)<d?a-=c:a+=c;let m=(1+p)*a/(1-a)/s;return {lci:f,uci:m}}function ot(e,t,r){let o=1,n=0,s=0,i=0;for(;i<e||o>n*1e-10;)n+=o,i>=t&i<=r&&(s+=o),n>1e30&&(s/=1e30,n/=1e30,o/=1e30),i+=1,o=o*e/i;return s/n}var Rr={binomialCdf:Io,binP:ze,computeMidP:wo,criticalValue:Bo,smr:No};var de={d3:{...Mo,...Do,...Uo,...Fo},d3plus:{assign:assign,closest:closest,date:date,formatAbbreviate:formatAbbreviate,merge:merge,strip:strip,titleCase:titleCase},stats:Rr},Ko={};function Na(e){let t=e.logicFactory(de);return Ko[e.name]={description:e.description,inputType:e.inputType,logic:Yo(t),testValue:e.testValue,type:e.type||"formatter"},t}function Yo(e){let t=e.toString().trim();if(t.startsWith("function"))return t.replace(/^function(?:\s\w+)?\([^)]\)/,"").trim().replace(/^{([\s\S]+)\}$/,"$1");let r=t.replace(/^.+?=>/,"").trim();return r.startsWith("{")?r.replace(/^{([\s\S]+)\}$/,"$1"):`return ${r}`}var fe=Wo;function Wo(e,t,r,o=false){let{variables:n}=ee(r);if(!e)return e;let s=/([A-z0-9]*)\{\{([^\}]+)\}\}/g;return e.replace(s,(a,c,u)=>{let d=f=>f;if(c){let f=c.replace(/^\w/g,T=>T.toLowerCase());f in t?d=t[f]:d=T=>`${c}${T}`;}let p=Array.isArray(n[u])?Ct(n[u]):n[u];if(p===void 0)return o?a:"N/A";try{return d(p,de,t)}catch(f){return console.error(`Error using formatter ${d.name}
2
+ `,`Error message: ${f.message}`),"N/A"}})}var kt=(e,t,r)=>{let{variables:o}=r,n=i=>i.allowed==="never"?false:!i.allowed||i.allowed==="always"||o[i.allowed],s={...e};return Object.keys(s).forEach(i=>{typeof s[i]=="string"?s[i]=fe(s[i],t,r):Array.isArray(s[i])?s[i]=s[i].filter(n).map(a=>typeof a=="object"?kt(a,t,r):typeof a=="string"?fe(a,t,r):a):typeof s[i]=="object"&&s[i]!==null&&!(s[i]instanceof Date)&&(s[i]=kt(s[i],t,r));}),s},nt=kt;var Ee={REPORT:"report",SECTION:"section",BLOCK:"block",INPUT:"block_input",FORMATTER:"formatter",DATASOURCE:"datasource",DIMENSION:"report_dimension",VARIANT:"report_dimension_variant",SEARCH:"search"};[Ee.BLOCK,Ee.SEARCH];var Wa={report:"Report",section:"Section",block:"Block",block_input:"Input",formatter:"Formatter",datasource:"Data Source",dimension:"Dimension",variant:"Variant",search:"Search"};({[Ee.SECTION]:"report_id",[Ee.DIMENSION]:"report_id",[Ee.VARIANT]:"dimension_id",[Ee.BLOCK]:"section_id",[Ee.INPUT]:"block_id"});var Xa={UNILATERAL:"uni",MULTILATERAL:"multi"},Se={SINGLE:"single",MULTI:"multi"},Za={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},Pt={ALLOWED:"allowed",ALLOWED_LOGIC:"allowedLogic",IGNORE_CASCADE:"ignoreCascade"},Qo={ACCESS:"access",ACCESS_LOGIC:"accessLogic"},Xo={DISABLED:"disabled"},Zo={FALLBACK:"fallback"},Jo={CLIENT_SIDE:"clientSideSection"};var en={IMAGE:"image",PARAGRAPH:"paragraph",SELECTOR:"selector",STAT:"stat",SUBTITLE:"subtitle",TITLE:"title",NAV:"nav",RESET_BUTTON:"reset_button",COMPARISON_BUTTON:"comparison_button",TABLE:"table",BUTTON:"button",MULTIHIERARCHY_SELECTOR:"multihierarchy_selector",FALLBACK:"fallback",SKELETON:"skeleton"},Lt={GENERATOR:"generator",RELATED:"related",VIZ:"visualization",SECTION_FLAG:"section_flag"},_t="logic",h={...en,...Lt};[h.GENERATOR,h.SECTION_FLAG,h.SELECTOR,h.VIZ,h.IMAGE,h.TABLE,h.MULTIHIERARCHY_SELECTOR];var w={ALT:"alt",AUTHOR:"author",DESC:"desc",FOOTNOTE:"footnote",BIO:"bio",IMAGE:"image",LABEL:"label",LOGIC:"logic",MULTIHIERARCHY_SELECTOR:"multihierarchySelector",MULTIHIERARCHY_SELECTOR_ALL_LABEL:"multihierarchySelectorAllLabel",MULTIHIERARCHY_SELECTOR_NAME:"multihierarchySelectorName",MULTIHIERARCHY_SELECTOR_PLACEHOLDER:"multihierarchySelectorPlaceholder",SIMPLE:"simple",SIMPLE_ENABLED:"simpleEnabled",PARAGRAPH:"paragraph",SELECTOR_DEFAULT:"selectorDefault",SELECTOR_DYNAMIC:"selectorDynamic",SELECTOR_NAME:"selectorName",SELECTOR_TYPE:"selectorType",SRC:"src",SLUG:"slug",SUBTITLE:"subtitle",TABLE:"table",TITLE:"title",SHORT_TITLE:"shortTitle",TOOLTIP:"tooltip",TWITTER:"twitter",URL:"url",VALUE:"value"};[w.LOGIC,w.SIMPLE,w.SIMPLE_ENABLED];var $={ENABLE_ALL:{bubbleMenu:true,toolbarOptions:{history:true,alignment:false,format:true}},DISABLE_ALL:{bubbleMenu:false,toolbarOptions:{history:false,alignment:false,format:false}},ENABLE_FORMAT:{bubbleMenu:true,toolbarOptions:{history:true,alignment:false,format:true}}},oi={[h.IMAGE]:[{field:w.TITLE,editorConfig:$.ENABLE_ALL},{field:w.SRC,editorConfig:$.DISABLE_ALL},{field:w.ALT,editorConfig:$.DISABLE_ALL},{field:w.DESC,editorConfig:$.ENABLE_ALL}],[h.PARAGRAPH]:[{field:h.PARAGRAPH,editorConfig:$.ENABLE_ALL},{field:w.TOOLTIP,editorConfig:$.ENABLE_FORMAT}],[h.SELECTOR]:[{field:w.SELECTOR_DEFAULT},{field:w.SELECTOR_DYNAMIC},{field:w.SELECTOR_NAME,editorConfig:$.ENABLE_FORMAT},{field:w.SELECTOR_TYPE}],[h.STAT]:[{field:w.TITLE,editorConfig:$.ENABLE_FORMAT},{field:w.SUBTITLE,editorConfig:$.ENABLE_FORMAT},{field:w.VALUE,editorConfig:$.ENABLE_FORMAT},{field:w.TOOLTIP,editorConfig:$.ENABLE_FORMAT}],[h.SUBTITLE]:[{field:w.SUBTITLE,editorConfig:$.ENABLE_FORMAT},{field:w.TOOLTIP,editorConfig:$.ENABLE_FORMAT}],[h.TITLE]:[{field:w.TITLE,editorConfig:$.ENABLE_FORMAT},{field:w.SLUG,editorConfig:$.DISABLE_ALL},{field:w.TOOLTIP,editorConfig:$.ENABLE_FORMAT}],[h.BUTTON]:[{field:w.LABEL,editorConfig:$.ENABLE_FORMAT},{field:w.URL,editorConfig:$.ENABLE_FORMAT}],[h.GENERATOR]:[],[h.SECTION_FLAG]:[],[h.VIZ]:[],[h.TABLE]:[],[h.MULTIHIERARCHY_SELECTOR]:[{field:w.MULTIHIERARCHY_SELECTOR_NAME,editorConfig:$.ENABLE_FORMAT},{field:w.MULTIHIERARCHY_SELECTOR_PLACEHOLDER,editorConfig:$.DISABLE_ALL},{field:w.MULTIHIERARCHY_SELECTOR_ALL_LABEL,editorConfig:$.DISABLE_ALL}],[h.NAV]:[{field:w.TITLE,editorConfig:$.ENABLE_FORMAT},{field:w.SHORT_TITLE,editorConfig:$.ENABLE_FORMAT}]},at={NAME:"name",DESCRIPTION:"description",...Pt,...Qo,...Zo,...Xo,...Jo};var Sr={FORMATTER:"formatter",FUNCTION:"function"},ni={[Sr.FORMATTER]:"Formatter",[Sr.FUNCTION]:"Function"},st={STRING:"string",NUMBER:"number",OBJECT:"object",DATE:"date"},si={[st.STRING]:"String",[st.NUMBER]:"Number",[st.OBJECT]:"Object/Array",[st.DATE]:"Date"};var {localeDefault:hr,locales:rn}=se(),on=Object.values(Lt),nn=(e,t=hr)=>e&&on.includes(e.type)?{locale:_t,locales:[_t]}:{locale:t,locales:rn},Tr=(e,t=hr)=>{if(!e)return {};let{locale:r}=nn(e,t);return e.contentByLocale?.[r]?.content};var sr={};a(sr,{addBlockToState:()=>Is,addRunConsumersRunning:()=>or,cloneEntity:()=>yo,createEntity:()=>po,deleteEntity:()=>mo,deleteQueryParam:()=>bs,readClientSideBlocks:()=>ws,readEntity:()=>Xe,readEnvSecrets:()=>Ds,readMember:()=>ho,readMetadata:()=>vs,readPrivateBlocks:()=>Bs,readUser:()=>Ps,recalculateVariables:()=>bt,removeBlocksFromState:()=>Os,removeDataSourceLogic:()=>Us,removeRunConsumersRunning:()=>nr,reportSearch:()=>Ss,resetSectionState:()=>et,revalidateReport:()=>Ms,revalidateUrl:()=>Ns,searchMember:()=>Ts,searchRegenerate:()=>hs,searchRole:()=>xs,searchUser:()=>ks,setCurrentLocale:()=>Rs,setPreferredLocale:()=>gs,setPreviews:()=>ys,setQueryParam:()=>As,setSectionState:()=>Je,setStatus:()=>So,updateEntity:()=>fo,updateMyData:()=>_s,updateUser:()=>Ls,urlProxy:()=>Cs,variantValidateSlug:()=>Es});function te(e,t){return e.request(t).then(r=>{let{status:o,data:n}=r;return "error"in n?{ok:false,status:o,error:n.error}:{ok:true,status:o,wrapper:n.wrapper,data:n.data}},r=>{if("isAxiosError"in r){let{status:o,data:n}=r.response||{status:500};return {ok:false,status:o,error:n?.error??r.message}}return {ok:false,status:500,error:r.message}})}function G(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>te(e,{...o,method:"GET",params:r?r(n):n})}function j(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>te(e,{...o,method:"POST",data:n})}function me(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>te(e,{...o,method:"DELETE",params:r?r(n):n})}function he(e,t){return r=>te(e,{method:"POST",url:`images/save/${t}`,params:{prompt:r.prompt,provider:t}})}function De(e,t){return r=>te(e,{method:"GET",url:`images/search/${t}`,params:{prompt:r.prompt,page:r.page,provider:t}})}function br(e,t){return ()=>te(e,{method:"GET",url:`list/icons/${t}`,params:{provider:t}})}function Ar(e,t){return r=>te(e,{method:"GET",url:`read/icons/${t}/icon.svg`,params:{name:r.name}})}var Te=e=>({id:e}),an=e=>{if(e.mode==="slugs"){let t=e.slugs.map(r=>[r.variantSlug,r.memberSlug].join("/")).join(",");return {...e,slugs:t}}return ["related","whole"].includes(e.mode)?{...e}:{...e,[e.mode]:e[e.mode].join(",")}};function je(e){let t=lt.create({baseURL:e});return {createBulkBlock:j(t,"create/bulk/block"),createBlock:j(t,"create/block"),createDimension:j(t,"create/dimension"),createFormatter:j(t,"create/formatter"),createReport:j(t,"create/report"),createSection:j(t,"create/section"),createVariant:j(t,"create/variant"),createDatasource:j(t,"create/datasource"),deleteBlock:me(t,"delete/block",Te),deleteDimension:me(t,"delete/dimension",Te),deleteFormatter:me(t,"delete/formatter",Te),deleteReport:me(t,"delete/report",Te),deleteSection:me(t,"delete/section",Te),deleteVariant:me(t,"delete/variant",Te),deleteDatasource:me(t,"delete/datasource",Te),readBlock:G(t,"read/block"),readDimension:G(t,"read/dimension"),readFormatter:G(t,"read/formatter"),readReport:G(t,"read/report"),readSection:G(t,"read/section"),readVariant:G(t,"read/variant"),readDatasource:G(t,"read/datasource"),updateBulkBlock:j(t,"update/bulk/block"),updateBlock:j(t,"update/block"),updateDimension:j(t,"update/dimension"),updateFormatter:j(t,"update/formatter"),updateReport:j(t,"update/report"),updateSection:j(t,"update/section"),updateVariant:j(t,"update/variant"),updateDatasource:j(t,"update/datasource"),searchReport:G(t,"search/reports"),validateVariantSlug:G(t,"validate/variant"),readMember:G(t,"read/members",an),readMemberImage:G(t,{url:"member/image",responseType:"blob"}),searchMember:G(t,"search/members"),updateMember:G(t,"update/members"),imageLocalSearch:De(t,"local"),imageLocalSave:he(t,"local"),imageFlickrSearch:De(t,"flickr"),imageFlickrSave:he(t,"flickr"),imageUnsplashSearch:De(t,"unsplash"),imageUnsplashSave:he(t,"unsplash"),imageUploadSave:he(t,"upload"),imageAdobeSearch:De(t,"adobe"),imageAdobeSave:he(t,"adobe"),imagePixabaySearch:De(t,"pixabay"),imagePixabaySave:he(t,"pixabay"),readMetadata:G(t,"read/metadata"),regenerateSearch:j(t,"search/regenerate"),urlProxy:G(t,"url/proxy"),searchRole:G(t,"auth/search/roles"),searchUser:G(t,"auth/search/users"),readUser:G(t,"auth/read/user"),updateUser:j(t,"auth/update/user"),updateMyData:j(t,"auth/update/me"),revalidateReport:G(t,"revalidate/report"),revalidateUrl:G(t,"revalidate/url"),readPrivateBlocks:j(t,"read/blocks/private"),readClientSideBlocks:G(t,"read/section/client"),listTablerIcons:br(t,"tabler"),readTablerIcon:Ar(t,"tabler"),readEnvSecrets:G(t,"read/secrets")}}var ln=cn(process.env.REPORTS_LOGGING),be=pn;function pn(e,t,r,o,n=void 0,s){let i={},a=[],{locale:c}=ee(s);try{if(t){let u=new Proxy(console,{get(p,f){return dn(f,"log","debug","info","warn","error")?(...T)=>{a.push(`${f} ${Date.now()} - ${T.map(m=>format(m)).join(" ")}`),ln&&p[f](...T);}:p[f]}}),d;return n?d=new Function(e,"console","libs","formatters","locale","variables",r)(t,u,de,o,c,n):d=new Function(e,"console","libs","formatters","locale",r)(t,u,de,o,c),typeof d=="object"&&Object.keys(d).length>0&&Object.assign(i,d),{vars:i,error:null,log:a,output:d}}return {vars:i,error:"Invalid API Link",log:a}}catch(u){return {vars:i,error:u.message,log:a}}}function dn(e,...t){return t.includes(e)}var vr=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];var fn=(e,t,r)=>{if(!r)return false;if(e===Se.SINGLE)return r.find(n=>n.id===t);let o=Array.isArray(t)?t:t.split(",");return Array.isArray(o)&&o.every(n=>r.map(s=>s.id).includes(n))},Ot=fn;function It(e,t,r,o,n=false){let{variables:s}=ee(o),i=nt({logic:t},r,o).logic,a=be("variables",s,i,r,void 0,o),{vars:c,log:u,error:d}=a,p=c.type||Se.SINGLE,f=c.component||"Selector",T=c.hideLabel||"false",m=c.resetSectionVars||"false",R=c.name||"Unlabeled Selector",y=vr(c.options||[]),v=P=>p===Se.MULTI&&!Array.isArray(P)?[P]:P,k=c.defaultValue,A;if(k&&(k=v(k),Ot(p,k,y)&&(A=k)),!A){let P=y&&y[0]&&y[0].id||y[0]||"";A=v(P);}if(n&&typeof window<"u"){let P=`selector${e}id`,H=new URLSearchParams(window.location.search),I=Object.fromEntries(H)[P];I&&!Ot(p,I,y)&&I!==void 0&&(H.delete(P),window.history.replaceState(null,null,`?${H.toString()}`));}return {config:{name:R,type:p,options:y,defaultValue:A,component:f,hideLabel:T,resetSectionVars:m},log:u,error:d}}function Bt(e,t,r){if(!e)return false;let o=Array.isArray(r)?r:r.split(",");return Array.isArray(o)&&o.every(n=>e.map(s=>`${s[`${t} ID`]}`).includes(n))}function wt(e,t,r,o,n=false){let{variables:s}=ee(o),i=nt({logic:t},r,o).logic,a=be("variables",s,i,r,void 0,o),{vars:c,log:u,error:d}=a;if(n&&typeof window<"u"){let f=`multihierarchySelector${e}-value`,T=`multihierarchySelector${e}-type`,m=new URLSearchParams(window.location.search),R=Object.fromEntries(m),y=R[f],v=R[T];y&&y!==void 0&&v&&v!==void 0&&!Bt(c.data,v,y)&&(m.delete(f),m.delete(T),window.history.replaceState(null,null,`?${m.toString()}`));}return {config:c,log:u,error:d}}var mn=(e,t,r)=>{let o=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),s=new URLSearchParams(t).get(o),i=n||s;if(r.type===Se.MULTI){let u=i?i.split(","):r.defaultValue,d=r.options.filter(p=>u.includes(p.id));return {[`selector${e}id`]:u,[`selector${e}label`]:(d||[]).map(p=>p.label)}}let a=i&&r.options.find(u=>u.id===i)?i:r.defaultValue,c=r.options.find(u=>u.id===a);return {[`selector${e}id`]:a,[`selector${e}label`]:c&&c.label||void 0}},Cr=mn;var yn=(e,t,r)=>{let o=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,s=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),i=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),a=new URLSearchParams(t).get(o),c=new URLSearchParams(t).get(n),u=s||a,d=i||c,p=u?u.split(","):r.defaultValue||[],f=d||r.defaultValueType||"",T=r.data?.filter(m=>p.includes(`${m[`${f} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:p,[`multihierarchySelector${e}label`]:[...new Set((T||[]).map(m=>m[f]))],[`multihierarchySelector${e}type`]:f}},xr=yn;function Rn(e,t){let r=Object.values(t),o=r.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(r.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(s=>o.includes(s)))).map(n=>[n.id,n]))}var kr=Rn;var Ec=e=>{let t=[];if(Array.isArray(e))return [];let r=(o,n="")=>{!o||typeof o!="object"||Object.keys(o).forEach(s=>{if(Array.isArray(o[s]))t.push(`${n?`${n}.`:""}${s}`);else if(typeof o[s]=="object")r(o[s],`${n?`${n}.`:""}${s}`);else return});};return r(e),t},Pr=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((r,o)=>r[o],e):e;function Sc(e,t){return e.some(r=>t.includes(r))}function hc(e){return e.filter((t,r,o)=>o.indexOf(t)===r)}var Lr="SECTION_ALLOWED",Ac=`// const {anotherVariable} = variables; (From context and inputs)
3
+ // const {toUpper} = formatters; (Ad-hoc formatters)
4
+ // const currentLocale = locale;
5
+ // const {d3} = libs; (Preset libraries)
6
+ // const {data} = resp; (Response from API)
7
+ return {
8
+ // propery1: true,
9
+ // propery2: [1,2,3],
10
+ // propery3: {innerProperty1: 1, innerProperty2: "text" }
11
+ }`,vc=`// const {anotherVariable} = variables; (From context and inputs)
12
+ // const {toUpper} = formatters; (Ad-hoc formatters)
13
+ // const currentLocale = locale;
14
+ // const {d3} = libs; (Preset libraries)
15
+ // const {setVariables, resetVariables} = section;
16
+ // const {myCustomSectionVariable} = section.variables;
17
+ return {
18
+ type: "LinePlot",
19
+ title: "New d3plus chart",
20
+ data: [
21
+ {id: "alpha", x: 4, y: 7},
22
+ {id: "alpha", x: 5, y: 25},
23
+ {id: "alpha", x: 6, y: 13},
24
+ {id: "beta", x: 4, y: 17},
25
+ {id: "beta", x: 5, y: 8},
26
+ {id: "beta", x: 6, y: 16}
27
+ ],
28
+ groupBy: "id",
29
+ x: "x",
30
+ y: "y"
31
+ }`;function Nt(e){return e.type===h.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var _r={jwt:gn};var Or=(e,t={},r="en",o={},n={})=>{let s={setVariables:o.onSetVariables?o.onSetVariables:c=>c,openModal:o.onOpenModal?o.onOpenModal:c=>c,formatters:t,libs:de,locale:r,...n};function i(c){return Function("globals",...c.vars,`with (globals) { ${c.logic} }`).bind(s,s)}function a(c){if(c.vars&&c.logic)return i(c);for(let u in c)Array.isArray(c[u])?c[u]=c[u].map(d=>isObject(d)?a(d):d):isObject(c[u])&&(c[u]=a(c[u]));return c}return a(e)},Ir=(e,t={})=>{let r={libs:_r,...t};function o(s){return Function("globals",...s.vars,`with (globals) { ${s.logic} }`).bind(r,r)}function n(s){if(s.vars&&s.logic)return o(s);for(let i in s)Array.isArray(s[i])?s[i]=s[i].map(a=>isObject(a)?n(a):a):isObject(s[i])&&(s[i]=n(s[i]));return s}return n(e)};function Sn(){let{publicRuntimeConfig:e}=En(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((r,o)=>(r[`ENV_${o}`]=t[o]||"N/A",r),{})}}var Ue=Sn;function hn(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,r])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:r}),{})}var Br=hn;var ue=cn(process.env.NEXT_PUBLIC_REPORTS_DEBUG),Cn=process.env.REPORTS_ORIGIN||"",xn=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,Dr=5;try{Dr=parseInt(`${xn||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}wr(lt,{retries:Dr,retryDelay:wr.exponentialDelay,onRetry:(e,t,r)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",r.url),console.error(t.message);}});lt.interceptors.request.use(e=>({...e,requestStart:Date.now()}));lt.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));var kn=(e,t,r)=>{let o=fe(e,t,r);return o.startsWith("http")||(o=`${Cn}${o.startsWith("/")?"":"/"}${o}`),o},{urlProxy:Pn}=je("/api/cms");function ut(e){return e.ok!==void 0}function ct(e){this.message=e,this.name="ApiFetchException";}var Nr=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;async function Ln(e,t,r="en",o,n,s){let i=Date.now(),a=e,c,u=Ue(),d=Br(),p={envs:{...u,...d}},f=new URL(e),T=new URLSearchParams(f.searchParams.toString());T.has("bespoke_slugs")&&(f.searchParams.delete("bespoke_slugs"),a=f.toString());let m={datasource:void 0};o.find(A=>{if(!A.content?.pattern)return false;try{let N=new RegExp(A.content.pattern,"gm");return N.test(a)?(m.datasource=A,!0):N.test(a)}catch{return false}});let R=n?n.settings:{},y=!!(R&&R.useProxy&&R.useProxy==="true"),v=m.datasource&&typeof m.datasource.content.useProxy=="boolean"?m.datasource.content.useProxy:false,k=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(y||v)){let A=await Pn({url:a,timeout:Nr});if(A.ok===true)c=A.data;else throw new ct(A?.error)}else try{let N={url:a,timeout:Nr};if(m.datasource){let H=p;s&&(H={...p,session:s});let I=typeof window>"u"&&m.datasource.content.logic_ssr?m.datasource.content.logic_ssr:m.datasource.content.logic,L=await Ir({vars:["url","libs","session"],logic:I},H)(a);if(L.axiosConfig)N=L.axiosConfig;else throw new ct(`AxiosConfig is missing in Data Source ${m.datasource.name} (ID: ${m.datasource.id}).`)}let P=await lt(N);if(P.status===200)P.headers["content-type"]==="text/csv"?c=csvParse(P.data):c=P.data;else throw new ct("No response for: "+a)}catch(A){throw new ct(A.message)}if(T.has("bespoke_slugs")){let A=T.get("bespoke_slugs");if(A){let N=A.split(",");if(N.length===3){let[P,H,z]=N,I=Pr(c,z);if(I&&Array.isArray(I)){let M=Array.from(new Set(I.map(L=>`${L[H]}`).filter(L=>!["","undefined"].includes(L))));if(M.length>0){let L=M.join("").length>2e3,_=await t({mode:L?"whole":"ids",ids:L?void 0:M,all:false,locale:r,variant:[parseInt(P,10)],output:"lite",limit:M.length+1,allowNulls:true}).then(D=>{let O=[];return ut(D)?D.ok&&(O=D.data.results):O=D.results,O&&Array.isArray(O)?O:[]}).catch(D=>(console.error(`Error hydrating slugs for Variant: ${P}, Key: ${H}, Accessor: ${z}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(D),[]));if(_){let D=Object.fromEntries(_.map(O=>[O.id,`/${O.variant_slug}/${O.slug}`]));I.map(O=>(O.bespoke_slug=D[O[H]]?D[O[H]]:null,O));}}}}}}return {data:c,requestDuration:Date.now()-i,finalUrl:v||y?k:a,apiDataSource:m.datasource?m.datasource:false}}function _n(e){this.name="BlockException",this.message=e;}async function Mr(e,t,r,o,n,s){let{locale:i,variables:a,query:c}=ee(r),u=In(e,r,a,t),d=null,p=e.contentByLocale?.logic?.content?.api,f=null,T=null,m=null,R=null,y=null;if(!u)return {outputVariables:{},renderVariables:{},status:{allowed:false,hiddenByCascade:e.id}};if(e.type===h.FALLBACK||e.type===h.SKELETON)return {outputVariables:{},renderVariables:{},status:{allowed:u,hiddenByCascade:e.id}};if(p){if(m=kn(p,t,r),e._clientSideGenerator&&!n.some(D=>{if(!D.content?.pattern)return false;try{return new RegExp(D.content.pattern,"gm").test(m||"")}catch{return false}})&&!e._requiredByConsumers)return {outputVariables:{},renderVariables:{},status:{allowed:u,client:true}};let I=m.split("|||").filter(_=>_!==""),M=[];for(let _=0;_<I.length;_++){let D=I[_];new RegExp("^(?:[a-z+]+:)?//","i").test(m)||(D=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${D}`.replace(/([^:]\/)\/+/g,"$1")),M.push(Ln(D,o,i,n,e,s).catch(Ne=>{throw new _n(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
32
+ Error fetching ${D}.
33
+ Message: ${Ne.message}.
34
+ `)}));}let L=await Promise.all(M).catch(_=>_.message);if(typeof L=="string"&&L)return {outputVariables:{},renderVariables:{},status:{error:L}};d=L.length===1?L[0].data:L.map(_=>_.data),T=L.reduce((_,D)=>_+JSON.stringify(D.data).length/1024,0),f=Math.max(...L.map(_=>_.requestDuration)),R=L.map(_=>_.apiDataSource?`${_.apiDataSource.name} (${_.apiDataSource.id})`:null),y=L.map(_=>_.finalUrl);}if(e.type===h.SELECTOR){let{config:I,log:M,error:L}=It(e.id,e.contentByLocale[i].content.logic,t,r,true);return {outputVariables:Cr(e.id,c,I),renderVariables:I,status:{log:M,error:L,allowed:u}}}if(e.type===h.MULTIHIERARCHY_SELECTOR){let{config:I,log:M,error:L}=wt(e.id,e.contentByLocale[i].content.logic,t,r,true);return {outputVariables:xr(e.id,c,I),renderVariables:I,status:{log:M,error:L,allowed:u}}}if(e.type===h.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:u}};if(e.type===h.RELATED){let I=e.contentByLocale?.logic?.content?.simple?.compare||"variant",M=e.contentByLocale?.logic?.content?.simple?.limit||4,L=Object.keys(a).filter(l=>l.startsWith("report_id")).map(l=>a[l]),_=Object.keys(a).filter(l=>l.startsWith("dimension_id")).map(l=>a[l]),D=Object.keys(a).filter(l=>l.startsWith("variant_id")).map(l=>a[l]),O=Object.keys(a).filter(l=>l.startsWith("id")).map(l=>a[l]);if(!O.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:false}};let Ne=await Promise.all(O.map((l,B)=>o({mode:"ids",locale:i,ids:[l],output:"lite",variant:[D[B]]}))).then(l=>l.flatMap(B=>{let S=[];return ut(B)?B.ok&&(S=B.data.results):S=B.results,S&&Array.isArray(S)?S:[]})).catch(l=>(console.error("Error getting related members",l),[]));if(_.length>1){let l=Object.keys(a).filter(U=>U.startsWith("variant_slug")).map(U=>a[U]),B=Ne.map((U,K)=>{let q={mode:"related",locale:i,related:M??4,current_ids:[U.content_id],output:"full",variant_ids:[U.variant_id]};return K===0&&(q.include_ids=[U.content_id]),q}),S=await Promise.all(B.map(U=>o(U))).then(U=>U.flatMap(K=>{let q=[];return ut(K)?K.ok&&(q=K.data.results):q=K.results,q&&Array.isArray(q)?q:[]})).catch(U=>(console.error("Error getting related members",U),[])),x=S.reduce((U,K)=>{let q=K.variant_slug;return U[q]||(U[q]=[]),U[q].push(K),U},{}),vt=[],rt=Object.keys(x),W=[{combination:[],index:0}];for(;W.length>0;){let U=W.pop();if(!U)continue;let{combination:K,index:q}=U;if(q===rt.length){vt.push(K);continue}let $e=rt[q],lr=x[$e];for(let Ge of lr)W.push({combination:[...K,Ge],index:q+1});}return {outputVariables:{related_reports:vt.map(U=>{let K=U.sort((q,$e)=>l.indexOf(q.variant_slug)-l.indexOf($e.variant_slug));return {entities:K,link:"/"+K.map(q=>`${q.variant_slug}/${q.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:S.length>0}}}let tt=Ne.map(l=>l.content_id),b={mode:"related",locale:i,related:M??4,current_ids:tt,output:"full"};I&&(I==="report"?b.report_ids=L:I==="dimension"?b.dimension_ids=_:b.variant_ids=D);let C=await o(b).then(l=>{let B=[];return ut(l)?l.ok&&(B=l.data.results):B=l.results,B&&Array.isArray(B)?B:[]}).catch(l=>(console.error("Error getting related members",l),[]));return {outputVariables:{related_reports:C.map(l=>({entities:[l],link:`/${l.variant_slug}/${l.slug}`}))},renderVariables:{},status:{log:[],allowed:C.length>0}}}let{logic:v}=Tr(e,i),k=fe(v,t,r),A=be("resp",d||{},k,t,a,r),{vars:N,error:P,log:H}=A;if(typeof N!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:H,duration:f,responseSize:T,resp:d,api:m,allowed:u,apiFinalUrls:y,apiDataSources:R}};let z=Object.keys(N).reduce((I,M)=>({...I,[`${e.type}${e.id}${M}`]:N[M]}),{});return {renderVariables:N,outputVariables:[h.GENERATOR,h.SECTION_FLAG].includes(e.type)?N:z,status:{log:H,error:P,duration:f,responseSize:T,resp:d,api:m,allowed:u,apiFinalUrls:y,apiDataSources:R}}}function On(e,t,r,o,n,s,i){return e.consumers.forEach(a=>{if(t[a]){let c=`${r}-${a}`;!o.includes(c)&&(t[a].section_id===t[r].section_id||!n)&&o.push(c),e.consumers.filter(u=>t[u]&&t[u].section_id===t[r].section_id||!n).forEach(u=>Mt(u,t,o,false,s,n,i));}})}var Mt=(e,t,r=[],o=true,n=true,s=true,i=[])=>{if(i.includes(e))return [];i.push(e);let a=t[e];return a&&a.inputs.length&&o&&a.inputs.forEach(c=>{let u=`${c}-${e}`;r.includes(u)||r.push(u),a.inputs.forEach(d=>Mt(d,t,r,o,false,s,i));}),a&&a.consumers.length&&n&&On(a,t,e,r,s,n,i),r},In=(e,t,r,o)=>{let n=true;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=false;else {let s=ee(t),{error:i,output:a}=be("variables",r,e.settings.allowedLogic||"return false;",o,void 0,s);i||(n=!!a);}return n},Ur=async(e,t,r,o,n,s={},i,a="section",c,u)=>{let d=a==="section",p=s?.isCMS||false,f=ee(n),T=f.variables,m={...s.variables??{}},R={...s.status??{}},y=new Set,v=[],k={};r?k={...k,[r]:e[r]}:t?k=(t??[]).reduce((b,C)=>{let{id:V}=C;if(!p&&C.settings?.[at.CLIENT_SIDE]&&d){let B=Object.values(e).filter(S=>S.section_id===V&&S.type!==h.SECTION_FLAG&&(S.type===h.GENERATOR&&S._clientSideGenerator||!S.shared||S.shared&&S.consumers?.length===0));return {...b,...B.reduce((S,x)=>({...S,[x.id]:x}),{})}}return {...b,...kr(V,e)}},{}):k=Object.values(e).filter(b=>Nt(b)).reduce((b,C)=>({...b,[C.id]:C}),{});let A=Object.values(k).filter(b=>Nt(b));if(A.length>0){ue&&console.info("%crunConsumers: calculating section flags","color:purple",A.map(l=>l.id).join(", "));let b=Object.fromEntries(await Promise.all(A.map(async l=>[l.id,await Mr(l,o,{...f,variables:T,locale:T.locale},i,c,u).then(B=>{let{outputVariables:S,status:x}=B;if(x.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${l.id}, Section ${l.section_id}) failed with message: ${x.error}. `);R[l.id]={allowed:false,error:x.error},m[l.id]={};}return (l.consumers.length>0||[h.GENERATOR,h.SECTION_FLAG,h.RELATED].includes(l.type))&&x.allowed&&Object.keys(S).length>0?m[l.id]=S:m[l.id]={},a==="report"?(R[l.id]={allowed:x.allowed,client:x.client||null},[h.GENERATOR,h.SECTION_FLAG].includes(l.type)&&x.api&&(R[l.id].api=x.api)):R[l.id]=x,B})]))),V=Object.entries(b).filter(([,l])=>!l.outputVariables[Lr]).map(([l])=>Number(l));y=new Set(V.map(l=>e[l].section_id)),Object.values(k).filter(l=>y.has(l.section_id)).forEach(l=>{v.push(l.id),delete k[l.id];}),ue&&console.info("%crunConsumers: removing sections","color:purple",y.keys());}let N=y.size>0?Object.fromEntries(Object.entries(e).filter(([,b])=>y?.has(b.section_id)?(v.includes(b.id)||v.push(b.id),false):true)):e;if(v.length>0&&(N=Object.fromEntries(Object.entries(N).map(([b,C])=>{let V={...C,inputs:C.inputs.filter(l=>!v.includes(l)),consumers:C.consumers.filter(l=>!v.includes(l))};return [b,V]}))),!r&&!t)return {variables:{...s.variables??{},...m},status:{...s.status??{},...R}};a==="report"&&v.length>0&&v.forEach(b=>{delete m[b],delete R[b],delete e[b];}),ue&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(k));let P=Object.keys(k).reduce((b,C)=>{let V=new Date,l=Mt(Number(C),N,[],!r,true,d).map(x=>x.split("-")),S=(new Date().getTime()-V.getTime())/1e3;return ue&&console.info(`%cResolved dependencies for ${C} (${S.toFixed(2)}s)`,"color:blue"),[...b,...l]},[]),H=new Date,z=Object.keys(k).reduce((b,C)=>b.includes(C)?[...b]:[C,...b],bn(P)),M=(new Date().getTime()-H.getTime())/1e3;ue&&console.info(`%cResolved DAG (${M.toFixed(2)}s): `,"color:green",z);let L=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,_=parseInt(`${L||0}`,10);async function D(b,C){let V=new Map,l=[],B=async()=>l.length;for(let S of b){if(_!==0){let W=await B();for(;W>=_;)ue&&console.info("Too many pending promises, waiting...",W,l),await new Promise(Me=>setTimeout(Me,500)),W=await B();}let x=C[S],rt=Promise.all(x.inputs.filter(W=>b.includes(String(W))).map(W=>V.get(Number(W)))).then(async()=>{let W=x.inputs.reduce((Q,J)=>({...Q,...m[J]}),T),Me=x.inputs.find(Q=>(x.settings?.ignoreCascade?x.settings?.ignoreCascade:[]).includes(Q)||!R[Q]?false:!R[Q].allowed||R[Q].hiddenByCascade);if(Me){R[S]={allowed:false,hiddenByCascade:R[Me].hiddenByCascade||Me},m[S]={},l.splice(l.indexOf(Number(S)),1);return}let U=new Date,K,q=!p&&t&&t.find(Q=>Q.id===x.section_id)?.settings?.[at.CLIENT_SIDE];typeof window<"u"&&[h.SELECTOR,h.MULTIHIERARCHY_SELECTOR].includes(x.type)&&x.settings[at.DISABLED]&&!q?K=new Promise(Q=>{Q({outputVariables:m[S],status:R[S]});}):K=Mr(x,o,{...f,variables:W,locale:W.locale},i,c,u);let $e=await K.then(({outputVariables:Q,status:J})=>{if(J.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${S}, Section ${x.section_id}) failed with message: ${J.error}.`);R[S]={allowed:false,error:J.error},m[S]={};}(x.consumers.length>0||[h.GENERATOR,h.SECTION_FLAG,h.RELATED].includes(x.type))&&J.allowed&&Object.keys(Q).length>0?m[S]=Q:m[S]={},a==="report"?(R[S]={allowed:J.allowed,client:J.client||null},[h.GENERATOR,h.SECTION_FLAG].includes(x.type)&&J.api&&(R[S].api=J.api)):R[S]=J;}),Ge=(new Date().getTime()-U.getTime())/1e3;return ue&&console.info(`%cBlock ${x.id} resolved in ${Ge.toFixed(3)}s`,Ge>500?"color:red":"color:green"),R[S].duration=R[S].duration?R[S].duration:Ge,l.splice(l.indexOf(Number(S)),1),$e}).catch(W=>{throw l.splice(l.indexOf(Number(S)),1),W});l.push(Number(S)),V.set(Number(S),rt);}await Promise.all(Array.from(V.values()));}let O=new Date;!p&&a==="section"&&t&&(z=z.filter(b=>!R[b]||R[b].client),ue&&console.info("%cFiltering DAG to exclude blocks already solved by SSR. Remaining blocks: ","color:yellow",z)),await D(z,N);let tt=(new Date().getTime()-O.getTime())/1e3;return ue&&console.info(`%cResolved Variables (${tt.toFixed(2)}s), ${z.length} blocks`,"color:green"),{variables:{...s.variables??{},...m},status:{...s.status??{},...R}}},Ru=e=>e<250?"green":e<1e3?"yellow":"red",gu=e=>e<10?"green":e<100?"yellow":"red";function Bn(e=[]){return e.reduce((t,r,o)=>{if(r){let n=o+1;t[`id${n}`]=r.id,t[`name${n}`]=r.name,t[`slug${n}`]=r.slug,"attributes"in r&&Object.keys(r.attributes).forEach(s=>{t[`attr_${s}${n}`]=r.attributes[s];}),t[`variant_id${n}`]=r.variant_id,t[`variant_name${n}`]=r.variant_name,t[`variant_slug${n}`]=r.variant_slug,t[`dimension_id${n}`]=r.dimension_id,t[`dimension_name${n}`]=r.dimension_name,t.report_id=r.report_id,t.report_name=r.report_name;}return t},{})}var Fr=Bn;function ae(e){if(!e)throw Error("Assertion Error")}function Gr(e,t){return +(e<t)-+(e>t)}function pt(e,t,r="ordering"){return Gr(t[r],e[r])}function He(e){if(e===""||e.charCodeAt(e.length-1)==32)return false;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<32||r>126)return false}return true}function Vr(e){ae(e.length!==0);for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r);if(o>33){let n=e.substr(0,r)+String.fromCharCode(o-1);return ae(He(n)),n}}let t=e.substr(0,e.length-1)+" ~";return ae(He(t)),t}function Dt(e){ae(e.length!==0);for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r);if(o<126){let n=e.substr(0,r)+String.fromCharCode(o+1);return ae(He(n)),n}}let t=e+"!";return ae(He(t)),t}function qr(e,t){return Math.trunc((e+t)/2)}function $r(e,t){ae(e<t);let r=false,o="",n=Math.max(e.length,t.length);for(let s=0;s<n;s++){let i=s<e.length?e.charCodeAt(s):32,a=s<t.length&&!r?t.charCodeAt(s):126;if(i===a)o+=String.fromCharCode(i);else if(a-i>1){o+=String.fromCharCode(qr(i,a)),r=false;break}else o+=String.fromCharCode(i),r=true;}return r&&(o+=String.fromCharCode(qr(32,126))),ae(e<o),ae(o<t),ae(He(o)),o}function bu(e,t,r,o=false,n=true,s="ordering"){if(o)return r===0?e[t[0]]?Vr(e[t[0]][s]):"!":r===t.length?Dt(e[t[r-1]][s]):$r(e[t[r-1]][s],e[t[r]][s]);if(r===0)return Vr(e[t[r]][s]);if(r===t.length-1)return Dt(e[t[r]][s]);let i=n?r:r-1,a=n?r+1:r;return $r(e[t[i]][s],e[t[a]][s])}function Au(e,t=false){let r=e.reduce((o,n)=>Gr(n,o)<0?n:o,"!");return t?Dt(r):r}var{localeDefault:Nn}=se();var Ke=new schema.Entity("block",{},{mergeStrategy(e,t){return t.block_input?e||{}:{...e,...t}}});Ke.define({consumers:[Ke],inputs:[Ke]});var zr=new schema.Entity("variant"),jr=new schema.Entity("dimension",{variants:[zr]},{processStrategy(e){return {...e,variants:"variants"in e?e.variants:[]}}}),Hr=new schema.Entity("section",{blocks:[Ke]}),Mn=new schema.Entity("report",{dimensions:[jr],sections:[Hr]},{processStrategy(e){return {...e,sections:"sections"in e?e.sections.sort(pt):[]}}}),Dn=new schema.Entity("formatter"),Un=new schema.Entity("datasource"),Fn={report:Mn,section:Hr,block:Ke,dimension:jr,variant:zr,formatter:Dn,datasource:Un};function dt(e,t){let r=Fn[e];if(!r)throw new Error(`Invalid entity type: ${e}`);let{entities:o}=normalize(t,[r]);return {report:Ae(o,"report"),dimension:Ae(o,"dimension"),section:Ae(o,"section"),block:Ae(o,"block"),variant:Ae(o,"variant"),formatter:Ae(o,"formatter"),datasource:Ae(o,"datasource")}}function Ae(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}var Kr=(e,t=void 0)=>{let{sid:r,bid:o,previews:n=[],query:s={}}=t||{},i,a,c={};return r?(i=r,c.activeSection=i):i=e.activeSection,n.length>0?(a=n,c.previews=a.filter(Boolean)):a=e.previews,{parsedParams:{sid:i,bid:o,previews:a,query:s},statusPayload:c}},Yr=(e=[],t=Nn)=>e.reduce((r,o)=>{let n=Or({vars:["n"],logic:o.content.logic},{},t,{});return r[o.name]=n,r},{});var Ce=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",ft=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[Ce];ft.includes(Ce)||ft.push(Ce);var $n={localeDefault:Ce,locales:ft,currentLocale:Ce,preferredLocale:Ce,showToolbar:false,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:true,settings:false,reportEditor:false},isCMS:false,isRunConsumersRunning:[]},mt=createSlice({name:"status",initialState:$n,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:true};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:false};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(r=>!t.payload.includes(r));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),re=mt.actions;var jn={attributes:{},variables:{},status:{}},yt=createSlice({name:"variables",initialState:jn,reducers:{setVariableChange:(e,t)=>{e.attributes={...e.attributes,...t.payload.attributes},e.variables={...e.variables,...t.payload.variables},e.status={...e.status,...t.payload.status};}},extraReducers:{[HYDRATE]:(e,t)=>({attributes:{...e.attributes,...t.payload.variables.attributes},status:{...e.status,...t.payload.variables.status},variables:{...e.variables,...t.payload.variables.variables}})}}),Wr=yt.actions;var Yn={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},le=createSlice({name:"records",initialState:Yn,reducers:{set:(e,t)=>{let r=t.payload;return {entities:Ye(e.entities,r.entities||{}),requests:Ye(e.requests,r.requests||{}),reports:r.reports||e.reports,tree:r.tree||e.tree}},setRequest:(e,t)=>{let r=t.payload;e.requests[r.type][r.key]=r;},setCreateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=dt(r.type,o),s=Ye(e.entities,n);if(e.entities=s,r.type==="report"){let i=r.data;e.reports?e.reports.indexOf(i.id)===-1&&(e.reports=[...e.reports,i.id]):e.reports=[i.id];}else if(r.type==="dimension"){let i=r.data;e.entities.report[i.report_id].dimensions.push(i.id),e.entities.report[i.report_id].dimensions=Rt(s.report[i.report_id].dimensions,s.dimension);}else if(r.type==="variant"){let i=r.data;e.entities.dimension[i.dimension_id].variants.push(i.id);}else if(r.type==="section"&&!Array.isArray(r.data)){let i=r.data;e.entities.report[i.report_id].sections.push(i.id),e.entities.report[i.report_id].sections=Rt(s.report[i.report_id].sections,s.section);}else if(r.type==="block")if(Array.isArray(r.data)){let i=r.data,a=i[0],c=i.map(u=>u.id);e.entities.section[a.section_id].blocks.concat(c);}else {let i=r.data;e.entities.section[i.section_id].blocks.push(i.id);}}},setReadRequest(e,t){let r=t.payload;if(r.type!=="report"&&(e.requests[r.type][r.key]=r),r.status==="SUCCESS"){let o=dt(r.type,r.data),n=Ye(e.entities,o);e.entities=n;}},setUpdateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=dt(r.type,o),s,i,a;if(r.type==="block"&&!Array.isArray(r.data)){let u=e.entities.block[r.data.id].inputs,d=n.block[r.data.id].inputs;s=u.length!==d.length,s&&(a=u.length>d.length,i=a?u.filter(p=>!d.includes(p))[0]:d.filter(p=>!u.includes(p))[0]),Object.values(n.block).forEach(p=>{p.block_input&&delete n.block[p.id];});}let c=Ye(e.entities,n);if(e.entities=c,r.type==="dimension"){let u=r.data;e.entities.report[u.report_id].dimensions=Rt(c.report[u.report_id].dimensions,c.dimension);}else if(r.type==="section"&&!Array.isArray(r.data)){let u=r.data;e.entities.report[u.report_id].sections=Rt(c.report[u.report_id].sections,c.section);}else if(r.type==="block"&&!Array.isArray(r.data)){let u=r.data;s&&(a?e.entities.block[i].consumers=e.entities.block[i].consumers.filter(d=>d!==u.id):e.entities.block[i].consumers.push(u.id));}}},setDeleteRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let{id:o,parentId:n,parentType:s}=r.data;if(delete e.entities[r.type][o],s&&n!=null){let i=`${r.type}s`;Wn(e.entities[s][n][i],o);}}},removeBlocks:(e,t)=>{let r=t.payload,o={...e.entities.block};return r.forEach(n=>{delete o[n];}),{...e,entities:{...e.entities,block:o}}},addBlocks:(e,t)=>{let r=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...r}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(r=>{e.entities.datasource[r].content.useProxy&&(delete e.entities.datasource[r].content.logic,delete e.entities.datasource[r].content.logic_ssr,delete e.entities.datasource[r].content.testUrl,delete e.entities.datasource[r].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let r=t.payload.records,o=r.entities;return {entities:o,reports:Object.values(o.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:r.tree}}}});function Ye(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,{...e[r],...t[r]}]))}function Rt(e,t){return e.map(n=>t[n]).sort((n,s)=>typeof n.ordering=="string"&&typeof s.ordering=="string"?pt(n,s):typeof n.ordering=="number"&&typeof s.ordering=="number"?n.ordering-s.ordering:String(n.ordering).localeCompare(String(s.ordering))).map(n=>n.id)}function Wn(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1);}var Ut=class extends Error{constructor(t,r){super(r),this.code=t;}toJSON(){return Xr(this)}static is(t){return Object.prototype.hasOwnProperty.call(t,"code")&&typeof t.code=="number"}};function Qn(e){return {ok:true,status:200,wrapper:true,data:e}}function Xr(e){return {ok:false,status:Ut.is(e)?e.code:500,error:e.message}}function Zu(e){return t=>e(t).then(Qn,Xr)}function xe(e,t,r){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${Qr(r)}`;return e[n]}let o=`${t}${Qr(r)}`;return e[o]}function Qr(e){return e[0].toUpperCase()+e.slice(1)}function Y(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];if(process.env.NODE_ENV!=="production"){var n=ns[e],s=n?typeof n=="function"?n.apply(null,r):n:"unknown error nr: "+e;throw Error("[Immer] "+s)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map((function(i){return "'"+i+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Fe(e){return !!e&&!!e[X]}function Pe(e){var t;return !!e&&((function(r){if(!r||typeof r!="object")return false;var o=Object.getPrototypeOf(r);if(o===null)return true;var n=Object.hasOwnProperty.call(o,"constructor")&&o.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===ss})(e)||Array.isArray(e)||!!e[so]||!!(!((t=e.constructor)===null||t===void 0)&&t[so])||Yt(e)||Wt(e))}function Qe(e,t,r){r===void 0&&(r=false),qe(e)===0?(r?Object.keys:er)(e).forEach((function(o){r&&typeof o=="symbol"||t(o,e[o],e);})):e.forEach((function(o,n){return t(n,o,e)}));}function qe(e){var t=e[X];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:Yt(e)?2:Wt(e)?3:0}function Gt(e,t){return qe(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Xn(e,t){return qe(e)===2?e.get(t):e[t]}function ao(e,t,r){var o=qe(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r;}function Zn(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function Yt(e){return rs&&e instanceof Map}function Wt(e){return os&&e instanceof Set}function ke(e){return e.o||e.t}function Qt(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=as(e);delete t[X];for(var r=er(t),o=0;o<r.length;o++){var n=r[o],s=t[n];s.writable===false&&(s.writable=true,s.configurable=true),(s.get||s.set)&&(t[n]={configurable:true,writable:true,enumerable:s.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Xt(e,t){return t===void 0&&(t=false),Zt(e)||Fe(e)||!Pe(e)||(qe(e)>1&&(e.set=e.add=e.clear=e.delete=Jn),Object.freeze(e),t&&Qe(e,(function(r,o){return Xt(o,true)}),true)),e}function Jn(){Y(2);}function Zt(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function ie(e){var t=is[e];return t||Y(18,e),t}function Zr(){return process.env.NODE_ENV==="production"||Ve||Y(0),Ve}function Ft(e,t){t&&(ie("Patches"),e.u=[],e.s=[],e.v=t);}function gt(e){zt(e),e.p.forEach(es),e.p=null;}function zt(e){e===Ve&&(Ve=e.l);}function Jr(e){return Ve={p:[],l:Ve,h:e,m:true,_:0}}function es(e){var t=e[X];t.i===0||t.i===1?t.j():t.g=true;}function Vt(e,t){t._=t.p.length;var r=t.p[0],o=e!==void 0&&e!==r;return t.h.O||ie("ES5").S(t,e,o),o?(r[X].P&&(gt(t),Y(4)),Pe(e)&&(e=Et(t,e),t.l||St(t,e)),t.u&&ie("Patches").M(r[X].t,e,t.u,t.s)):e=Et(t,r,[]),gt(t),t.u&&t.v(t.u,t.s),e!==io?e:void 0}function Et(e,t,r){if(Zt(t))return t;var o=t[X];if(!o)return Qe(t,(function(a,c){return eo(e,o,t,a,c,r)}),true),t;if(o.A!==e)return t;if(!o.P)return St(e,o.t,true),o.t;if(!o.I){o.I=true,o.A._--;var n=o.i===4||o.i===5?o.o=Qt(o.k):o.o,s=n,i=false;o.i===3&&(s=new Set(n),n.clear(),i=true),Qe(s,(function(a,c){return eo(e,o,n,a,c,r,i)})),St(e,n,false),r&&e.u&&ie("Patches").N(o,r,e.u,e.s);}return o.o}function eo(e,t,r,o,n,s,i){if(process.env.NODE_ENV!=="production"&&n===r&&Y(5),Fe(n)){var a=Et(e,n,s&&t&&t.i!==3&&!Gt(t.R,o)?s.concat(o):void 0);if(ao(r,o,a),!Fe(a))return;e.m=false;}else i&&r.add(n);if(Pe(n)&&!Zt(n)){if(!e.h.D&&e._<1)return;Et(e,n),t&&t.A.l||St(e,n);}}function St(e,t,r){r===void 0&&(r=false),!e.l&&e.h.D&&e.m&&Xt(t,r);}function qt(e,t){var r=e[X];return (r?ke(r):e)[t]}function to(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Object.getPrototypeOf(r);}}function jt(e){e.P||(e.P=true,e.l&&jt(e.l));}function $t(e){e.o||(e.o=Qt(e.t));}function Ht(e,t,r){var o=Yt(t)?ie("MapSet").F(t,r):Wt(t)?ie("MapSet").T(t,r):e.O?(function(n,s){var i=Array.isArray(n),a={i:i?1:0,A:s?s.A:Zr(),P:false,I:false,R:{},l:s,t:n,k:null,o:null,j:null,C:false},c=a,u=Kt;i&&(c=[a],u=We);var d=Proxy.revocable(c,u),p=d.revoke,f=d.proxy;return a.k=f,a.j=p,f})(t,r):ie("ES5").J(t,r);return (r?r.A:Zr()).p.push(o),o}function ts(e){return Fe(e)||Y(22,e),(function t(r){if(!Pe(r))return r;var o,n=r[X],s=qe(r);if(n){if(!n.P&&(n.i<4||!ie("ES5").K(n)))return n.t;n.I=true,o=ro(r,s),n.I=false;}else o=ro(r,s);return Qe(o,(function(i,a){n&&Xn(n.t,i)===a||ao(o,i,t(a));})),s===3?new Set(o):o})(e)}function ro(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Qt(e)}var oo,Ve,Jt=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",rs=typeof Map<"u",os=typeof Set<"u",no=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",io=Jt?Symbol.for("immer-nothing"):((oo={})["immer-nothing"]=true,oo),so=Jt?Symbol.for("immer-draftable"):"__$immer_draftable",X=Jt?Symbol.for("immer-state"):"__$immer_state";var ns={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return "Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return "Unsupported patch operation: "+e},18:function(e){return "The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return "'current' expects a draft, got: "+e},23:function(e){return "'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},ss=""+Object.prototype.constructor,er=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,as=Object.getOwnPropertyDescriptors||function(e){var t={};return er(e).forEach((function(r){t[r]=Object.getOwnPropertyDescriptor(e,r);})),t},is={},Kt={get:function(e,t){if(t===X)return e;var r=ke(e);if(!Gt(r,t))return (function(n,s,i){var a,c=to(s,i);return c?"value"in c?c.value:(a=c.get)===null||a===void 0?void 0:a.call(n.k):void 0})(e,r,t);var o=r[t];return e.I||!Pe(o)?o:o===qt(e.t,t)?($t(e),e.o[t]=Ht(e.A.h,o,e)):o},has:function(e,t){return t in ke(e)},ownKeys:function(e){return Reflect.ownKeys(ke(e))},set:function(e,t,r){var o=to(ke(e),t);if(o?.set)return o.set.call(e.k,r),true;if(!e.P){var n=qt(ke(e),t),s=n?.[X];if(s&&s.t===r)return e.o[t]=r,e.R[t]=false,true;if(Zn(r,n)&&(r!==void 0||Gt(e.t,t)))return true;$t(e),jt(e);}return e.o[t]===r&&(r!==void 0||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=true),true},deleteProperty:function(e,t){return qt(e.t,t)!==void 0||t in e.t?(e.R[t]=false,$t(e),jt(e)):delete e.R[t],e.o&&delete e.o[t],true},getOwnPropertyDescriptor:function(e,t){var r=ke(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:true,configurable:e.i!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty:function(){Y(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Y(12);}},We={};Qe(Kt,(function(e,t){We[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};})),We.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Y(13),We.set.call(this,e,t,void 0)},We.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Y(14),Kt.set.call(this,e[0],t,r,e[0])};var cs=(function(){function e(r){var o=this;this.O=no,this.D=true,this.produce=function(n,s,i){if(typeof n=="function"&&typeof s!="function"){var a=s;s=n;var c=o;return function(R){var y=this;R===void 0&&(R=a);for(var v=arguments.length,k=Array(v>1?v-1:0),A=1;A<v;A++)k[A-1]=arguments[A];return c.produce(R,(function(N){var P;return (P=s).call.apply(P,[y,N].concat(k))}))}}var u;if(typeof s!="function"&&Y(6),i!==void 0&&typeof i!="function"&&Y(7),Pe(n)){var d=Jr(o),p=Ht(o,n,void 0),f=true;try{u=s(p),f=!1;}finally{f?gt(d):zt(d);}return typeof Promise<"u"&&u instanceof Promise?u.then((function(R){return Ft(d,i),Vt(R,d)}),(function(R){throw gt(d),R})):(Ft(d,i),Vt(u,d))}if(!n||typeof n!="object"){if((u=s(n))===void 0&&(u=n),u===io&&(u=void 0),o.D&&Xt(u,true),i){var T=[],m=[];ie("Patches").M(n,u,T,m),i(T,m);}return u}Y(21,n);},this.produceWithPatches=function(n,s){if(typeof n=="function")return function(u){for(var d=arguments.length,p=Array(d>1?d-1:0),f=1;f<d;f++)p[f-1]=arguments[f];return o.produceWithPatches(u,(function(T){return n.apply(void 0,[T].concat(p))}))};var i,a,c=o.produce(n,s,(function(u,d){i=u,a=d;}));return typeof Promise<"u"&&c instanceof Promise?c.then((function(u){return [u,i,a]})):[c,i,a]},typeof r?.useProxies=="boolean"&&this.setUseProxies(r.useProxies),typeof r?.autoFreeze=="boolean"&&this.setAutoFreeze(r.autoFreeze);}var t=e.prototype;return t.createDraft=function(r){Pe(r)||Y(8),Fe(r)&&(r=ts(r));var o=Jr(this),n=Ht(this,r,void 0);return n[X].C=true,zt(o),n},t.finishDraft=function(r,o){var n=r&&r[X];process.env.NODE_ENV!=="production"&&(n&&n.C||Y(9),n.I&&Y(10));var s=n.A;return Ft(s,o),Vt(void 0,s)},t.setAutoFreeze=function(r){this.D=r;},t.setUseProxies=function(r){r&&!no&&Y(20),this.O=r;},t.applyPatches=function(r,o){var n;for(n=o.length-1;n>=0;n--){var s=o[n];if(s.path.length===0&&s.op==="replace"){r=s.value;break}}n>-1&&(o=o.slice(n+1));var i=ie("Patches").$;return Fe(r)?i(r,o):this.produce(r,(function(a){return i(a,o)}))},e})(),Z=new cs,us=Z.produce;Z.produceWithPatches.bind(Z);Z.setAutoFreeze.bind(Z);Z.setUseProxies.bind(Z);Z.applyPatches.bind(Z);Z.createDraft.bind(Z);Z.finishDraft.bind(Z);var ht=us;var oe=le.actions,Tt={create:tr,read:Ro,update:rr,delete:go,clone:Eo},po=Ze({block:ye("block"),dimension:ye("dimension"),formatter:ye("formatter"),report:ye("report"),section:ye("section"),variant:ye("variant"),datasource:ye("datasource")}),Xe=Ze({block:Re("block"),dimension:Re("dimension"),formatter:Re("formatter"),report:Re("report"),section:Re("section"),variant:Re("variant"),datasource:Re("datasource")}),fo=Ze({block:ce("block"),dimension:ce("dimension"),formatter:ce("formatter"),report:ce("report"),section:ce("section"),variant:ce("variant"),datasource:ce("datasource")}),mo=Ze({block:Le("block"),dimension:Le("dimension"),formatter:Le("formatter"),report:Le("report"),section:Le("section"),variant:Le("variant"),datasource:Le("datasource")}),yo=Ze({block:uo("block"),section:uo("section")});function Ze(e){return (t,r)=>{let o=e[t];if(!o)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return o(r)}}function Oe(e,t){return (r,o)=>{let s=o().records.requests[e][t],i=!s||s.status==="UNINITIALIZED"?"LOADING":"FETCHING";r(oe.setRequest({key:t,type:e,status:i}));}}function _e(e,t,r,o){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:o,title:"Error"}),n(oe.setRequest({key:t,type:e,status:"FAILURE",error:{code:r,message:o}}));}}function ye(e){return t=>{let r=tr(e,t);return (o,n,s)=>(o(Oe(e,r)),xe(s,"create",e)(t).then(a=>(a.ok===true?o(oe.setCreateRequest({key:r,operation:"create",status:"SUCCESS",type:e,data:a.data})):o(_e(e,r,a.status,a.error)),a)))}}function ds(e){return t=>{let r=tr(e,t[0]);return (o,n,s)=>(o(Oe(e,r)),xe(s,"createBulk",e)(t).then(a=>(a.ok===true?o(oe.setCreateRequest({key:r,operation:"createBulk",status:"SUCCESS",type:e,data:a.data})):o(_e(e,r,a.status,a.error)),a)))}}function co(e,t,r){return r.replace(new RegExp(e,"g"),t)}function fs(e){return e.section_id!==void 0}function ms(e){return e.report_id!==void 0}function uo(e){return t=>{let{create:r}=t;return (o,n,s)=>ye(e)(r)(o,n,s).then(async a=>{if(a.ok){let{data:c}=a,{id:u}=c,{update:d}=t,p=Eo(e,{id:u});if(o(Oe(e,`${p}`)),e==="block"&&fs(r)){let f=ht(d,y=>{y.id=u;}),{contentByLocale:T}=f;T&&(f=ht(f,y=>{y.id=u,y.contentByLocale=Object.keys(T).reduce((v,k)=>{let A=T?T[k]:{};return v[k]={...A,id:u},v},{});}));let R=f.inputs?.map(y=>({type:y.type,id:y.id,inputAction:{operation:"create",input:{input_id:y.id,block_id:f.id}}}));return R&&R.length>0&&lo(e)([f,...R])(o,n,s).then(()=>Re("section")({id:f.section_id,include:true})(o,n,s).then(y=>(y.ok&&o(oe.setRequest({key:p,type:e,status:"SUCCESS",data:y.data})),y))),ce(e)(f)(o,n,s).then(y=>(y.ok&&o(oe.setRequest({key:p,type:e,status:"SUCCESS",data:y.data})),y))}if(e==="section"&&ms(r)){let{id:f}=c,T=ht(d,y=>{y.id=f;}),{blocks:m}=T,R=m?.map(y=>({type:y.type,blockcol:y.blockcol,blockrow:y.blockrow,section_id:f,locales:Object.keys(y.contentByLocale).map(v=>v)}));return R&&m&&await ds("block")(R)(o,n,s).then(y=>{if(y.ok){let v=y.data,k=[],A=v.map((N,P)=>{let z={...N},I=z.id,M=m[P];M.contentByLocale&&(z.contentByLocale=Object.keys(M.contentByLocale).reduce((C,V)=>{let l=M.contentByLocale[V];return C[V]={...l,content:{...l.content},id:z.id},C},{}));let{settings:L}=M,{contentByLocale:_,id:D}=z;z.settings=L;let O={id:D,contentByLocale:_,settings:L};return M.inputs.map(C=>C.id).reduce((C,V)=>{let l=m.findIndex(B=>B.id===V);return [...C,l]},[]).map(C=>({...v[C],originalBlock:m[C]})).forEach(C=>{let{id:V,type:l,originalBlock:B}=C;if([h.SELECTOR,h.VIZ].includes(l)){if(O.contentByLocale?.logic?.content?.api){let S=O.contentByLocale?.logic.content.api;O.contentByLocale.logic.content.api=co(`(selector${B.id}id)`,`selector${V}id`,S);}if(O.contentByLocale?.logic?.content?.logic){let S=O.contentByLocale.logic.content.logic;O.contentByLocale.logic.content.logic=co(`(selector${B.id}id)`,`selector${V}id`,S);}}k.push({id:V,inputAction:{operation:"create",input:{input_id:V,block_id:I}}});}),O});return lo("block")([...A,...k])(o,n,s)}}),ce(e)(T)(o,n,s).then(y=>(y.ok&&o(oe.setRequest({key:p,type:e,status:"SUCCESS",data:y.data})),y))}return ce(e)({...d,id:c.id})(o,n,s)}})}}function Re(e){return t=>{let r=Ro(e,t);return (o,n,s)=>{o(Oe(e,r));let i=xe(s,"read",e);if(typeof i!="function"){let a=`Failed to get valid RPC method for entity "${e}"`;return o(_e(e,r,500,a)),Promise.reject(new Error(a))}return i(t).then(a=>(a.ok===true?o(oe.setReadRequest({key:r,operation:"read",status:"SUCCESS",type:e,data:a.data})):o(_e(e,r,a.status,a.error)),a))}}}function ce(e){return t=>{let r=rr(e,t);return (o,n,s)=>(o(Oe(e,r)),xe(s,"update",e)(t).then(a=>(a.ok===true?o(oe.setUpdateRequest({key:r,operation:"update",status:"SUCCESS",type:e,data:a.data})):o(_e(e,r,a.status,a.error)),a)))}}function lo(e){return t=>{let r=rr(e,t[0]);return (o,n,s)=>(o(Oe(e,r)),xe(s,"updateBulk",e)(t).then(a=>(a.ok===true?o(oe.setUpdateRequest({key:r,operation:"updateBulk",status:"SUCCESS",type:e,data:a.data})):o(_e(e,r,a.status,a.error)),a)))}}function Le(e){return t=>{let r=go(e,t);return (o,n,s)=>(o(Oe(e,r)),xe(s,"delete",e)(t).then(a=>{a.ok===true?o(oe.setDeleteRequest({key:r,operation:"delete",status:"SUCCESS",type:e,data:a.data})):o(_e(e,r,a.status,a.error));}))}}function tr(e,t){if(e==="variant"){let r=t;return `create(variant, [${r.dimension_id}, ${r.name}])`}return `create(${e}, [${Object.keys(t)}])`}function Ro(e,t={}){let r=t.id==null?null:`'${t.id}'`;return `read(${e}, ${r}, ${!!t.include})`}function rr(e,t){let{id:r,...o}=t;return `update(${e}, ${r}, [${Object.keys(o)}])`}function go(e,t){return `delete(${e}, ${t})`}function Eo(e,t){let r=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${r})`}var{setStatus:So,setPreviews:ys,setSectionState:Je,resetSectionState:et,setCurrentLocale:Rs,setPreferredLocale:gs,addRunConsumersRunning:or,removeRunConsumersRunning:nr}=re;function Es(e,t){return async(r,o,n)=>{let s=await n.validateVariantSlug({dimension:e,slug:t});if("error"in s)throw new Error(s.error);return s.data}}function Ss(e){return async(t,r,o)=>{let n=await o.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function hs(){return async(e,t,r)=>{let o=await r.regenerateSearch(void 0);if("error"in o)throw new Error(o.error);return o.data}}function ho(e){return async(t,r,o)=>{let n=await o.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function Ts(e){return async(t,r,o)=>{let n=await o.searchMember(e);if(n.ok===true)return n.data;throw new Error(n.error)}}async function To(e,t,r,o,n){let s=r().status,i={...s,...o},a={...s.query,...o.query};Object.keys(a).forEach(u=>a[u]===void 0&&delete a[u]);let c={...i,query:a};t(So(c)),s.activeSection&&t(bt(e,{query:a},n));}function bs(e,t,r){return async(o,n)=>To(e,o,n,{query:{[t]:void 0}},r)}function As(e,t,r,o){return async(n,s)=>To(e,n,s,{query:{[t]:r}},o)}function bt(e,t,r){return async(o,n)=>{let s=n(),{currentLocale:i,isCMS:a}=s.status,c=s.records.entities.block,u=e.formatterFunctions[i],d=e.datasourceFunctions,{parsedParams:p,statusPayload:f}=Kr(s.status,t),{sid:T,bid:m,previews:R,query:y}=p;Object.keys(f).length&&o(re.setStatus(f));let v={...Fr(R),locale:i,...Ue()},k={variables:v,query:y,locale:i};o(re.addRunConsumersRunning([T]));let A=s.records.entities.section[T],N=async P=>o(ho(P));try{let P=await Ur(c,A&&[A],m,u,k,{isCMS:a},N,"section",d,r),{variables:H,status:z}=P;o(Wr.setVariableChange({attributes:v,variables:H,status:z})),o(re.removeRunConsumersRunning([T]));}catch(P){console.error("Error in runConsumers client side: recalculateVariables",P);}}}function vs(e){return async(t,r,o)=>{let n=await o.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function Cs(e){return async(t,r,o)=>{let n=await o.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function xs(){return async(e,t,r)=>{let o=await r.searchRole("");if("error"in o)throw new Error(o.error);return o.data}}function ks(e){return async(t,r,o)=>{let n=await o.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function Ps(e){return async(t,r,o)=>{let n=await o.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function Ls({user:e}){return async(t,r,o)=>{let n=await o.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function _s(e){return async(t,r,o)=>{let n=await o.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function Os(e){let{removeBlocks:t}=le.actions;return async r=>{await r(t(e));}}function Is(e){let{addBlocks:t}=le.actions;return async r=>{await r(t(e));}}function Bs(e){return async(t,r,o)=>{let n=await o.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function ws(e){return async(t,r,o)=>{let n=await o.readClientSideBlocks(e);if("error"in n)throw new Error(n.error);return n.data}}function Ns(e){return async(t,r,o)=>{let n=await o.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function Ms(e){return async(t,r,o)=>{let n=await o.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function Ds(){return async(e,t,r)=>{let o=await r.readEnvSecrets({});if("error"in o)throw new Error(o.error);return o.data}}function Us(){let{removeDataSourceLogic:e}=le.actions;return async t=>{await t(e());}}var bo=()=>configureStore({reducer:{[le.name]:le.reducer,[mt.name]:mt.reducer,[yt.name]:yt.reducer},middleware(e){return e({thunk:{extraArgument:je("/api/cms/")}})}}),qs=createWrapper(bo);function Gs(e,t){let r=o=>{let{id:n,skelHeight:s,skelWidth:i,...a}=o,c=t(n);return c.isUninitialized||c.isFetching?jsx(Skeleton,{width:i,height:s}):c.isError?null:jsx(e,{...a,for:c.data})};return r.displayName=`withFetcher(${e.displayName||e.name||"Component"})`,r}var {locales:vo}=se(),sa={pathSegment:"path",formatterFunctions:vo.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",previewPrefix:null,siteProps:{}},Ie=createContext(sa);function op(e){let {pathSegment:t,profilePrefix:r,previewPrefix:o,siteProps:n}=e,s=ar();F(p=>p.status.isCMS);let a=ir(),u={...Ue()},d=useMemo(()=>({profilePrefix:r,previewPrefix:o,pathSegment:t,siteProps:n,formatterFunctions:vo.reduce((p,f)=>({...p,[f]:s.data?Yr(s.data,f):{}}),{}),datasourceFunctions:(a?.data||[]).sort((p,f)=>p.content.order>f.content.order?1:-1).map(p=>({...p,content:{...p.content,pattern:fe(p.content.pattern,{},{variables:u})}}))}),[s,t,r,o,n,a]);return jsx(Ie.Provider,{value:d,children:e.children})}function np(){let e=useContext(Ie);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var {localeDefault:la}=se(),pe=useDispatch,F=useSelector,zs=Be("report"),js=Be("dimension"),Hs=Be("variant"),Ks=Be("section"),Ys=Be("block"),ar=Be("formatter"),ir=Be("datasource"),Ws=we("report"),Qs=we("section"),cr=we("block"),Xs=we("dimension"),Zs=we("variant"),Js=we("formatter"),ea=we("datasource");function bp(){let e=F(n=>n.status.activeEntity),t=pe();return {activeEntity:e,selectEntity:n=>t(re.setActiveEntity(n)),unselectEntity:()=>t(re.setActiveEntity({type:null,id:null}))}}var pa=(e,t=void 0,r=void 0)=>{if(!e)return {};let o=cr(e).data,n=F(a=>t||a.variables.variables),s=F(a=>r||a.variables.attributes);return useMemo(()=>o?o.inputs.reduce((a,c)=>({...a,...n[c]}),s):{},[o,s,n])},Ap=e=>{let t=cr(e).data,r=F(s=>s.variables.variables),o=F(s=>s.variables.attributes);return t?useMemo(()=>t?Object.keys(r).reduce((s,i)=>({...s,...t.inputs.includes(parseInt(i,10))?{[i]:r[i]}:{}}),{attributes:o}):{attributes:o},[t,r,o]):{}};var vp=e=>F(t=>t.variables.status[e]),Cp=(e=la)=>useContext(Ie).formatterFunctions[e],xp=()=>useContext(Ie).datasourceFunctions,kp=()=>useContext(Ie).profilePrefix,Pp=()=>useContext(Ie).previewPrefix,Lp=(e=void 0,t=void 0)=>{let r=F(s=>s.status.localeDefault),o=F(s=>s.status.query);return {variables:pa(e),locale:t||r,query:o}},xo=(e,t)=>Object.values(t).filter(o=>Object.keys(o.contentByLocale).some(n=>{let{logic:s}=o.contentByLocale[n].content;return s&&(`${s}`.includes(`formatters.${e}(`)||`${s}`.includes(`${e}{{`))})).length,_p=e=>{if(!e)return 0;let t=F(o=>o.records.entities.formatter),r=F(o=>o.records.entities.block);return useMemo(()=>xo(e,r),[e,t,r])},Op=()=>{let e=F(r=>r.records.entities.formatter),t=F(r=>r.records.entities.block);return useMemo(()=>Object.values(e).reduce((r,o)=>(r[o.name]=xo(o.name,t),r),{}),[e,t])};function Ip(e){let t=pe(),r=F(a=>a.status.sectionState)[e]||{},o=b(),n=useRef(r);n.current=r;let s=useCallback(a=>{let c=n.current,u={},d=Array.from(new Set([...Object.keys(c),...Object.keys(a)]));for(let p of d)c[p]!==a[p]&&(u[p]={from:c[p],to:a[p]});o("section_variables_change",{sectionId:e,prev:{...c},next:{...a},changes:u}),t(Je({[e]:a}));},[e,o]),i=useCallback(()=>{t(et(e));},[e]);return {sectionVariables:r,setSectionVariables:s,resetSectionVariables:i}}function Bp(e){let t=pe(),r=F(c=>c.status.sectionState),o=useMemo(()=>e.reduce((c,u)=>(c[u]=r[u]||{},c),{}),[e,r]),n=useCallback(c=>{t(Je(c));},[]),s=useCallback(()=>{e.map(u=>et(u)).forEach(u=>t(u));},[e]),i=useCallback(c=>u=>{t(Je({[c]:u}));},[]),a=useCallback(c=>()=>{t(et(c));},[]);return {sectionsVariables:o,setSectionsVariables:n,resetSectionsVariables:s,setSectionVariables:i,resetSectionVariables:a}}function wp(){let e=pe(),t=F(n=>n.status.isRunConsumersRunning),r=useCallback(n=>{e(or(n));},[]),o=useCallback(n=>{e(nr(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:r,removeRunConsumersRunning:o}}function Np(e){let t=pe(),r=a$1();return useCallback(o=>t(bt(e,o,r)),[t,e,r.status])}function Mp(e){let t=pe();return {opened:F(a=>a.status.sidebarStatus[e]),handlers:{open:()=>t(re.openSidebar(e)),close:()=>t(re.closeSidebar(e)),toggle:()=>t(re.toggleSidebar(e))}}}function Dp(){return F(t=>t.status.currentLocale)}function Up(){return F(t=>t.status.preferredLocale)}function Be(e){return t=>{let r=pe(),o=useMemo(()=>Tt.read(e,{include:true}),[]),n=useCallback(i=>{let a=Object.values(i.records.entities[e]),c=i.records.requests[e][o]||{status:a==null?"UNINITIALIZED":"SUCCESS"},u=t?a.filter(d=>t.includes(d.id)):a;return ur(u,c)},[o]),s=F(n);return useEffect(()=>{s.isUninitialized&&r(Xe(e,{id:t,include:true}));},[s.status]),s}}function ta(e,t){let r=useMemo(()=>Tt.clone(e,{id:t}),[t,e]);return F(n=>{let s=n.records.entities[e][t],i=n.records.requests[e][r]||{status:s==null?"UNINITIALIZED":"SUCCESS"};return ur(s,i)})}function we(e){return t=>{let r=pe(),o=useMemo(()=>Tt.read(e,{id:t,include:true}),[t]),n=useCallback(i=>{let a=i.records.entities[e][t],c=i.records.requests[e][o]||{status:a==null?"UNINITIALIZED":"SUCCESS"};return ur(a,c)},[o]),s=F(n);return useEffect(()=>(s.isUninitialized&&t!==null&&r(Xe(e,{id:t,include:true})),()=>{}),[o,s.isUninitialized,r,t]),s}}function ur(e,t){let r={data:void 0,error:void 0,status:t.status,isUninitialized:t.status==="UNINITIALIZED",isLoading:t.status==="LOADING",isFetching:t.status==="LOADING"||t.status==="FETCHING",isSuccess:t.status==="SUCCESS",isError:t.status==="FAILURE"};return t.status==="UNINITIALIZED"?r:t.status==="LOADING"?{...r,data:e}:t.status==="FETCHING"?{...r,data:e}:t.status==="FAILURE"?{...r,error:t.error}:{...r,data:e}}
35
+ export{On as $,Up as $a,w as A,Ys as Aa,oi as B,ar as Ba,at as C,ir as Ca,Sr as D,Ws as Da,ni as E,Qs as Ea,st as F,cr as Fa,si as G,Xs as Ga,be as H,Zs as Ha,fe as I,Js as Ia,nt as J,ea as Ja,Ot as K,bp as Ka,It as L,pa as La,wt as M,Ap as Ma,nn as N,vp as Na,Tr as O,Cp as Oa,Ec as P,xp as Pa,Pr as Q,kp as Qa,Sc as R,Pp as Ra,hc as S,Lp as Sa,Lr as T,_p as Ta,Ac as U,Op as Ua,vc as V,Ip as Va,Nt as W,Bp as Wa,Ue as X,wp as Xa,Br as Y,Np as Ya,Ln as Z,Mp as Za,Mr as _,Dp as _a,se as a,Ur as aa,ta as ab,Gr as b,Ru as ba,qs as bb,pt as c,gu as ca,Gs as cb,Dt as d,Fr as da,Ie as db,bu as e,Ce as ea,op as eb,Au as f,re as fa,np as fb,Ko as g,Wr as ga,Na as h,Ut as ha,Or as i,Zu as ia,Ir as j,xe as ja,Yr as k,Qr as ka,fr as l,Xe as la,da as m,ho as ma,fa as n,bs as na,mr as o,As as oa,ya as p,vs as pa,Ra as q,Os as qa,Ta as r,Is as ra,ba as s,Us as sa,Aa as t,sr as ta,Ee as u,pe as ua,Wa as v,F as va,Xa as w,zs as wa,Se as x,js as xa,Za as y,Hs as ya,h as z,Ks as za};
@@ -0,0 +1 @@
1
+ import {X,I as I$1}from'./chunk-AA4WMKFB.js';import b from'slugify';var v=t=>t.records.entities.section,E=t=>t.records.entities.block;function s(t){return e=>Object.values(e.records.entities[t])}var T=s("section"),k=s("block"),D=s("formatter");var S=X();function I(t){return Object.values(t.records.entities.datasource||[]).sort((e,r)=>e.content.order>r.content.order?1:-1).map(e=>{let r={...S};return {...e,content:{...e.content,pattern:I$1(e.content.pattern,{},{variables:r})}}})}function g(t,e){let r=[],c=o=>Object.values(e).reduce((i,p)=>("inputs"in p&&p.inputs.includes(o)&&(i.push(p.id),i=i.concat(c(p.id))),i),[]);t.forEach(o=>{r=r.concat(c(o));});let n=[];return r.forEach(o=>{n.includes(o)||n.push(o);}),n}function l(t){let e={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},r=`(?:${Object.keys(e).join("|")})`,c=RegExp(r),n=RegExp(r,"g"),o=String(t).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return c.test(o)?o.replace(n,m=>e[m]):o}function d(t){return typeof t=="string"?String(t).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):t}function y(t){return t?b(d(l(t)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var $=y;export{v as a,E as b,T as c,k as d,D as e,I as f,l as g,d as h,$ as i,g as j};