@datawheel/bespoke 1.0.0-rc.3 → 1.0.0-rc.5

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.
package/dist/report.js CHANGED
@@ -12,7 +12,7 @@ import'path';import'url';import*as sg from'd3-array';import*as ag from'd3-collec
12
12
  dignissim interdum eros. Curabitur non tincidunt libero.
13
13
  Suspendisse quis nibh in massa tincidunt feugiat sit amet vitae nisl.
14
14
  In pulvinar sapien ut tincidunt volutpat. Donec auctor tellus eu augue feugiat,
15
- a viverra sapien pulvinar.`,style:o,append:t?jsx($e,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:true})}var id=b(()=>{c();Qt();Ie();});function gi({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:a,_iconVariant:s,_icon:i,_iconRadius:l,_iconSize:p,_iconPadding:u}){let d=t||"<span class='cr-block-placeholder'>Title</span>",m=o||"<span class='cr-block-placeholder'>Big Stat</span>",g=e||"<span class='cr-block-placeholder'>Subtitle</span>",f=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:We(f),children:[a!=="none"&&a&&jsx(be,{blockType:"stat",iconType:a,iconVariant:s,iconRadius:l,iconSize:p,icon:i,iconPadding:u}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(se,{component:"div",size:"md",html:d,style:n,isPreview:true}),jsx(se,{component:"div",size:"xl",html:m,style:n,isPreview:true}),jsx(se,{component:"div",size:"sm",html:g,style:n,isPreview:true})]},"stat"),r&&jsx($e,{content:r})]})})}var cd=b(()=>{c();Qt();Jt();Ie();je();});function hi({subtitle:e,tooltip:t,settings:o}){let r=ve(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{gap:"sm",position:We(n),children:[jsx(se,{size:"sm",html:r,isPreview:true}),t&&jsx($e,{content:t,style:{display:"inline-flex"}})]})}var ud=b(()=>{c();Qt();Yt();Ie();je();});function yi({title:e,tooltip:t,_iconType:o,_iconVariant:r,_icon:n,settings:a,_iconRadius:s,_iconSize:i,_iconPadding:l}){let p=ve(e)||"Title",u=a&&a.order?parseInt(a.order,10):1,d=u<=6?u:1,m=!!(a&&a.search&&a.search!=="off"),g=a&&a.search?a.search:"",f=a&&a.align?a.align:"left";return jsxs(Group,{gap:"sm",justify:We(f),children:[o!=="none"&&o&&jsx(be,{blockType:"title",iconType:o,iconVariant:r,iconRadius:s,iconSize:i,icon:n,iconPadding:l}),jsx(se,{component:"h",order:d,style:a,html:p,isPreview:true}),m&&jsx(Tooltip,{label:`Click will open '${g}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx($e,{content:t})]})}var dd=b(()=>{c();Qt();Yt();Jt();Ie();je();});function Ti(e){let{id:t,type:o,defaultValue:r,options:n,name:a,settings:s,hideLabel:i,component:l,resetSectionVars:p,section:u}=e,d=Te(),m=useContext(Mt),g=K(v=>v.status.query),{sectionVariables:f,resetSectionVariables:x}=De(u),y=Rx(t),E=useMemo(()=>g[y]||r,[g[y],o,r]),L=useMemo(()=>Ex(g[y],r),[g[y],o,r]),[k,O]=useState(n?.map(v=>({value:v.id,label:v.label,imageUrl:v.imageUrl}))||[]),[F,W]=useState((n||[]).map(v=>v.id).join("-"));useEffect(()=>{let v=(n||[]).map(N=>`${N.label}|${N.id}`).join("-");if(F===v)return;W(v);let P=(n||[]).map(N=>({value:N.id,label:N.label}));O(P);let D=o===Be.SINGLE?E:L;Vo(o,D,n||[])||d(sa(m,y));},[JSON.stringify(n),t]);let A=()=>{p==="true"&&f&&x();},B=v=>{d(Wo(m,y,v)),A();},w=v=>{d(Wo(m,y,v.join())),A();},C=i==="true"?jsx(Fragment,{}):jsx(se,{component:"div",html:a,size:"sm",style:s,isPreview:true});return k.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):k.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(k)]}):{[Be.SINGLE]:l===Ln.SEGMENTED_CONTROL?jsxs("div",{children:[C,jsx(SegmentedControl,{data:k,value:k.map(v=>v.value).includes(E)?E:"",onChange:B,fullWidth:true})]}):jsx(Select,{label:C,data:k,value:E,onChange:B,renderOption:v=>jsx(kx,{...v}),styles:{label:{display:i==="true"?"none":"block"}}}),[Be.MULTI]:jsx(MultiSelect,{label:C,data:k,value:L,onChange:w,styles:{label:{display:i==="true"?"none":"block"}}})}[o]}var Rx,Ex,kx,gd=b(()=>{c();Jr();_n();ge();he();Kt();Ie();Pe();Rx=e=>`selector${e}id`,Ex=(e,t)=>e&&typeof e=="string"?e.split(","):t,kx=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{wrap:"nowrap",children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});var hd=b(()=>{});function Ei({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:a=0}){let s=useMantineTheme(),[i,l]=useState(false);if(a===Ri)return null;let p=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),u=vi(r),d=r,m=JSON.stringify(d),g=100,f=1e3,x=!!(m&&m.length>g),y=10,E={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(u==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,c:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:a+1<Ri?Object.keys(r).sort((L,k)=>{let O=vi(r[L]),F=vi(r[k]);return O!==F?bd.indexOf(O)-bd.indexOf(F):L.localeCompare(k)}).map(L=>jsx(Ei,{root:false,label:L,value:r[L],level:a+1},L)):p})]})});if(u==="array"){let L=r.length>y,k=L?r.slice(0,y):r,O=L?r.length-y:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,p:0,color:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[a+1<Ri?k.map((F,W)=>jsx(Ei,{root:false,label:W,value:F,level:a+1,parentIsArray:true},W)):p,L&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",O," other elements]"]})]})]})})}return u==="string"?d=x?`"${d.substring(0,g)} ... "`:`"${d}"`:u==="error"?d=`Error: ${d.message}`:u==="undefined"?d=u:d.toString&&(d=d.toString()),jsxs(Group,{wrap:"nowrap",gap:0,justify:"space-between",children:[jsx(Tooltip,{label:"Copied!",opened:i,closeDelay:1e3,children:jsx(Text,{c:e?"dimmed":s.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap",cursor:"pointer"},onClick:()=>{let L=o?`{{${t}}}`:n?`[${t}]`:t;navigator.clipboard.writeText(L),l(true),setTimeout(()=>l(false),1e3);},fw:700,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Tooltip,{label:d,children:jsx(CodeHighlight,{className:"cr-variable",code:d,language:"jsx",withCopyButton:false,styles:L=>({codeHighlight:{textAlign:"right",overflow:"hidden",width:"fit-content",flex:"0 1 auto"},code:{padding:"5px 0 5px 5px",fontSize:L.fontSizes.xs},pre:{marginLeft:"5px"}})})}),x&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,children:[jsx(HoverCard.Target,{children:jsx(ActionIcon,{children:jsx(IconCodePlus,{})})}),jsx(HoverCard.Dropdown,{w:500,children:jsx(Text,{size:"sm",maw:"100%",style:{wordBreak:"break-all",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:m.substring(0,f)})})]})]})}var vi,bd,Ri,Sd,Td=b(()=>{c();hd();vi=e=>{let t=typeof e;if(t==="object"){if(e===null)return "undefined";Array.isArray(e)?t="array":["Error","EvalError","ReferenceError","SyntaxError"].includes(e.constructor.name)&&(t="error");}return t},bd=["object","array","string","number"],Ri=5;Sd=Ei;});var xd,vd=b(()=>{c();xd=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function Mx({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let a=Tt(t==="attributes"?null:t).data,s=a?a.type:"block",i=a?.type&&a?.id?`${a.type}${a.id}`:"",l=Object.keys(o).filter(r?()=>true:p=>!xd(i)(p));return jsx(Stack,{gap:0,children:l.length?l.map(p=>jsx(Sd,{dimmed:e.includes(p),label:p,value:o[p]},p)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${s}`})})})}var Rd,Ed=b(()=>{c();Td();he();vd();Rd=Mx;});function Hx({outputVariables:e,status:t,hasAPI:o=false,debug:r,type:n}){let[a,s]=useState(false),i=o&&!Object.keys(e).length&&!t.error,l=Object.keys(e).some(u=>u.startsWith("_"));return r?i?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),l&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:a,onChange:u=>s(u.currentTarget.checked)}),jsx(Rd,{variables:e,showInternal:a})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var Ci,kd=b(()=>{c();Ed();Ci=Hx;});function wi(e){let{alt:t,src:o,desc:r,title:n,settings:a,...s}=e,i=ve(t),l=ve(o),p=ve(r),u=jsx("img",{src:l,alt:i,style:s}),d=a&&a.align?String(a.align):"left";return (p&&p.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:ot(d),gap:"sm",children:[n&&jsx(se,{component:"p",html:n,style:a,isPreview:true}),u,r&&jsx(se,{component:"p",size:"sm",html:r,style:a,isPreview:true})]})),l&&i?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Cd=b(()=>{c();Yt();Ie();je();});function Ii({headings:e,settings:t,title:o,shortTitle:r,_iconType:n,_iconVariant:a,_icon:s,_iconRadius:i,_iconSize:l,_iconPadding:p}){let{min:u="1",max:d="6",icons:m="yes"}=t||{},g=ve(o)||"",f=ve(r||o)||"",x=g&&g.length>0,y=n&&n!=="none",E=f===g?`${g}`:`${g} (${f})`,L=Pr(parseInt(u,10),parseInt(d,10),e),k=m==="yes",O=t&&t.align?String(t.align):"left",F=Rr(O),W=We(O),A=ot(O),B=t&&t.titlePosition?String(t.titlePosition):"left",w=useMemo(()=>{let v={right:"left",left:"right"},P=x&&["left","right"].includes(B),D={};if(P){let N=B==="right";D={gap:"xs",justify:N&&v[W]?v[W]:W,style:{flexDirection:N?"row-reverse":"row"},wrap:"nowrap"};}else D={gap:"xs",align:A,justify:"center",style:{flexDirection:B==="bottom"?"column-reverse":"column"}};return {element:P?Group:Stack,props:D}},[x,W,A,B]),C=v=>!v||!v?.length?null:jsx(Fragment,{children:v.map(P=>jsxs(Fragment$1,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${P.id}`,children:jsxs(Group,{gap:"sm",children:[k&&jsx(be,{...P.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:P.label}})]})})},P.id),jsx(Box,{pl:"xs",children:C(P.children)})]},P.id))});return jsxs(w.element,{pos:"relative",...w.props,children:[x&&jsxs(Group,{gap:"xs",position:W,wrap:"nowrap",children:[y&&jsx(be,{blockType:"title",iconType:n,iconVariant:a,iconRadius:i,iconSize:l,icon:s,iconPadding:p}),jsx(se,{style:t,html:E,isPreview:true,lineClamp:1})]}),jsxs(List,{sx:v=>({display:"flex",gap:v.spacing.md,justifyContent:F,alignItems:"center",listStyleType:"none"}),children:[L?.map(v=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${v.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[k&&jsx(be,{blockType:"nav",...v.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:v.label}})]})})}),v?.children?.length?jsx(Menu.Dropdown,{children:C(v.children)}):null]})},v.id)),!L||L.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})]})}var Ad=b(()=>{c();Qa();Jt();je();Ie();Jt();Yt();});function _i(e){let{related_reports:t,settings:o}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let r=Rr(o&&o.align?String(o.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:r,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(a=>a.name).join(" & ")},n.link))})}var Id=b(()=>{c();je();});function Oi({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:a}){let s=Tt(e).data,{sectionVariables:i,resetSectionVariables:l}=De(s?.section_id),p=!!Object.keys(i).length,u=ot(o&&o.align?o.align:"left");return jsxs(Stack,{align:u,children:[!p&&!a&&jsx(Text,{size:"xs",ta:o?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>l(),disabled:!p,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})]})}var _d=b(()=>{c();Pe();Pe();je();});function Mi({settings:e,label:t,showIcon:o,position:r="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:r,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",o&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var Md=b(()=>{c();});function Fi({columns:e=[],id:t,data:o=[],tableProps:r={}}){let[n,a]=useState({}),{initialState:s}=r,i=s?.pagination?.pageIndex,l=s?.pagination?.pageSize,p=`table-${[t,i,l].filter(f=>f).join("-")}`,u=useMemo(()=>e.map(f=>f.accessorKey),[e]),d=useMemo(()=>o.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(x=>u.includes(x))),[u,o]),m=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:x})=>jsx(se,{html:`${x}`,isPreview:true}),filterFn:"contains"})),[e]),g=kc();return useEffect(()=>{(async()=>{try{let y=`${(g||"en").toUpperCase()}`;a({});}catch(x){console.error("Error loading translations:",x);}})();},[g]),createElement(MantineReactTable,{...r,autoResetPageIndex:false,columns:m,data:d,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",key:p,layoutMode:"grid",localization:n,state:{...r.state,isFullScreen:false}})}var Nd=b(()=>{c();Ie();Pe();});function Di({label:e,url:t,settings:o}){let{align:r}=o;return jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var Dd=b(()=>{c();});function zi(e){let t=Te(),o=useContext(Mt),r=K($=>$.status.query),n=Ov(e.id),a=useMantineTheme(),{colorScheme:s}=useMantineColorScheme(),{allLabel:i,colorKey:l,data:p,defaultValue:u,defaultValueType:d,iconKey:m,levels:g,limit:f,placeholder:x,searchIndexKey:y,searchIndexSeparator:E,resetSectionVars:L,section:k}=e,[O,F]=useState(false),[W,A]=useState(true),[B,w]=useState(""),[C,v]=useState(false),[P,D]=useState([""].slice(1)),{sectionVariables:N,resetSectionVariables:H}=De(k),X=useMemo(()=>Mv(r[`${n}-value`],u),[r,u,n]),M=useMemo(()=>r[`${n}-type`]||d,[r,d,n]),U=useCallback(()=>{L==="true"&&N&&H();},[L,N,H]),_=useCallback($=>{U(),t(Wo(o,`${n}-value`,$.join()));},[t,o,n,U]),j=useCallback($=>{U(),t(Wo(o,`${n}-type`,$));},[t,o,n,U]),ie=useRef(null),le=useRef(false),q=useRef(!!f&&f<X.length),oe=P.length,ee=g[oe],Q=P.filter(Boolean);P.length>0&&Q.length===0&&Q.push(`${i} ${ee?.label}`),useEffect(()=>{let $=()=>{A(true);};return window.addEventListener("touchmove",$),()=>{window.removeEventListener("touchmove",$);}},[]);let I=useMemo(()=>Lv(p,g,l,m,y,E),[l,p,m,g,y,E]),R=useMemo(()=>{let $=_v(B),ce=Array.from(Bv(I,$)).reverse();return C?ce:P.reduce((ye,V)=>ye.filter(te=>!V||te.searchindex.indexOf(V)>-1),ce.filter(ye=>ye.type===ee?.value))},[ee,I,B,C,P]),z=useRef(null),G=es({count:O?R.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>z.current,[]),overscan:10,rangeExtractor:useCallback($=>ln($),[])}),[J,re]=useState(-1),ne=Math.min(J,R.length-1),we=useCallback($=>{let ce=P.concat($);C&&v(false),D(ce);},[C,P]),Re=useCallback(()=>{let $=P.slice(0,oe-1);C&&v(false),D($);},[C,P,oe]),_e=useCallback($=>{w($.currentTarget.value),!q.current&&p.length>0&&F(true);},[p,w,q,F]),Ae=useCallback(()=>{w(""),_([]),ie.current?.focus(),f&&(q.current=false);},[w,_,ie,f,q]),Ye=useCallback($=>{let ce=X.filter(ye=>ye!==$);_(ce),f&&ce.length<f&&(q.current=false);},[X,_,f,q]),Ne=useCallback($=>{M||j($.type),M!==$.type?(j($.type),_([$.value])):X.includes($.value)?Ye($.value):f?(X.length<f&&_([...X,$.value]),X.length===f&&_([...X.slice(1),$.value])):_([...X,$.value]),w("");},[M,j,_,X,Ye,f]),qt=useCallback(()=>{X.length>0&&B.length===0&&(_(X.slice(0,-1)),F(true),f&&(q.current=false)),B.length>0&&w(B.slice(0,-1));},[X,B,_,w,F,f,q]),Lo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$+1>=R.length?$:$+1);},[re,R]),_o=useCallback(()=>{let $=R[ne];$&&Ne($);},[R,ne,Ne]),wt=useCallback(()=>{F(false);},[F]),At=useCallback(()=>{Re(),re(0);},[re,Re]),no=useCallback(()=>{let $=R[ne];!C&&$&&$.type!==g[g.length-1]?.value&&(we($.name),re(0));},[R,ne,C,g,re,we]),Bo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$-1<0?0:$-1);},[re]),ar=({label:$,onRemove:ce,...ye})=>jsxs("div",{style:{alignItems:"center",backgroundColor:s==="dark"?"var(--mantine-color-dark-7)":"var(--mantine-color-gray-1)",borderRadius:a.radius.sm,cursor:"default",color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${a.spacing.xs} / 2 - ${rem(2)}) calc(${a.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${a.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...ye,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:ce,radius:2,size:"sm",sx:{color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",marginLeft:`calc(${a.spacing.sm} / 6)`},tabIndex:-1})]}),ze=useMemo(()=>X.map($=>I.find(ce=>ce.value===$)).filter($=>!!$).map(($,ce)=>createElement(ar,{...$,index:ce,key:$.value,onRemove:ye=>{ye.preventDefault(),ye.stopPropagation(),Ye($.value);}})),[X]),ir=forwardRef(function({color:ce,icon:ye,label:V,value:te,...ue},lt){return jsx("div",{ref:lt,style:{cursor:"pointer",width:"100%"},...ue,children:jsxs(Group,{align:"center",wrap:"nowrap",gap:"xs",w:"100%",children:[ye&&jsx(Box,{bg:ce??"transparent",component:"img",w:20,h:20,src:ye}),jsx(Text,{lineClamp:1,size:"sm",children:V||te})]})})}),{settings:lr}=e,so=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(se,{component:"div",html:e.label,size:"sm",style:lr,isPreview:true});return jsx(Input.Wrapper,{label:so,children:jsxs(Popover,{closeOnClickOutside:true,keepMounted:true,opened:O,onChange:F,onClose:()=>{re(0),w("");},onOpen:()=>{G.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>re(0),sx:{position:"relative","& .defaultValue":{backgroundColor:s==="dark"?"var(--mantine-color-dark-5)":"var(--mantine-color-gray-3)",color:s==="dark"?"var(--mantine-color-dark-1)":"var(--mantine-color-gray-7)"}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:X.join(",")}),jsx(Input,{component:"div",multiline:true,onMouseDown:$=>{$.preventDefault(),!q.current&&p.length>0&&F(!O),ie.current?.focus();},rightSection:X.length>0?jsx(CloseButton,{onClick:Ae,onMouseDown:$=>$.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:a.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${a.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:s==="dark"?"var(--mantine-color-dark-3)":"var(--mantine-color-gray-5)",opacity:1}},children:[ze,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":O,onChange:_e,onKeyDown:getHotkeyHandler([["ArrowDown",Lo],["ArrowLeft",At],["ArrowRight",no],["ArrowUp",Bo],["Backspace",qt],["Enter",_o],["Escape",wt]]),placeholder:X.length===0?x:void 0,ref:ie,readOnly:q.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:a.fontSizes.sm,marginLeft:`calc(${a.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:B})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:$=>$.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:$=>$.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",gap:"xs",w:"100%",children:[g.length>1&&jsxs(Stack,{gap:"xs",children:[jsxs(Group,{onClick:$=>{$.stopPropagation();},px:"xs",justify:"center",gap:"xs",children:[jsx(Button,{onClick:()=>{re(0),v(true),D([]),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:C?"filled":"outline",children:i}),g.map(($,ce)=>jsx(Button,{onClick:()=>{C&&v(false);let ye=[""].slice(1),V=ce;for(;V--;)ye[V]=P[V]||"";re(0),D(ye),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:!C&&P.length===g.findIndex(ye=>ye.value===$?.value)?"filled":"outline",children:$?.label},$?.value))]}),jsx(Divider,{})]}),oe>0&&jsxs(Group,{align:"center",wrap:"nowrap",px:"xs",children:[jsx(ActionIcon,{onClick:Re,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:Q.map($=>jsx(Text,{lineClamp:1,size:"xs",children:$},`${$}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>A(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:z,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${G.getTotalSize()}px`,position:"relative",width:"100%"},children:G.getVirtualItems().map($=>{let ce=R[$.index],ye=ne===$.index,V=X.includes(ce.value);return R.length>0&&ye&&!W&&G.scrollToIndex(ne),jsxs(Group,{"aria-selected":ye,align:"center","data-hovered":ye||void 0,"data-index":$.index,"data-selected":V,id:ce.vale,wrap:"nowrap",onMouseEnter:te=>{te.preventDefault(),te.stopPropagation(),W&&(re($.index),A(false));},onMouseMove:te=>{te.preventDefault(),te.stopPropagation(),A(true);},onMouseDown:te=>{te.preventDefault(),Ne(ce);},justify:"space-between",ref:G.measureElement,role:"option",gap:"xs",sx:te=>({borderRadius:te.radius.xs,padding:"15px 5px 15px",paddingLeft:C&&10*g.findIndex(ue=>ue?.value===ce.type)||5,position:"absolute",top:0,left:0,height:`${$.size}px`,transform:`translateY(${$.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"},"&:hover":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"}}),tabIndex:-1,children:[jsx(ir,{index:$.index,...ce}),!C&&ce.type!==g[g.length-1]?.value&&jsx(ActionIcon,{onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),we(ce.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},ce.value)})})})]})})})})]})})}var Lv,_v,Bv,Ov,Mv,qd=b(()=>{c();Va();Ie();Kt();he();Pe();Jr();Lv=(e=[],t=[],o="",r="",n="",a="|")=>{let s=t.map(x=>x.value).slice(),i=`${s.pop()}`,l=x=>x[o],p=x=>x[r],u=x=>{if(x[n])return typeof x[n]=="string"?x[n].split(a):x[n]},d=new Set,m=[],g=[],f=nest().rollup(x=>{let y=x[0],E=w=>w&&w.value&&!d.has(w.value),L=s.map(w=>y[`${w} ID`]),k=s.map(w=>y[w]),O=s.map((w,C)=>{if(g[C]!==k[C]){g[C]=k[C];let v=l[C]||l[l.length-1]||l,P=p[C]||p[p.length-1]||p,D=u[C]||u[u.length-1]||u;return {color:v(y,w)||void 0,icon:P(y,w)||void 0,value:`${L[C]}`,label:k[C],name:k[C],type:w,searchindex:k.slice(0,C+1).concat(D(y,w)).join("|")}}return {}}).filter(E);O.forEach(w=>d.add(w.value));let F=l[l.length-1]||l,W=p[p.length-1]||p,A=u[u.length-1]||u,B=x.map(w=>({color:F(w,i)||void 0,icon:W(w,i)||void 0,value:`${w[`${i} ID`]}`,label:w[i],name:w[i],type:i,searchindex:k.concat(w[i]).concat(A(w,i)).join("|")}));m.push(...O.concat(B));});return s.forEach(x=>{f.key(y=>`${y[`${x} ID`]}|${y[x]}`);}),f.entries(e),m},_v=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},Bv=(e,t)=>{let o=e.length,r,n=i=>r&&r.searchindex.includes(i.searchindex),s={next:()=>{for(let i=o-1;i>-1;i--){let l=e[i];if(t.test(`${l.value} ${l.label} ${l.searchindex}`)||n(l))return r=l,o=i,{done:false,value:l}}return {done:true,value:void 0}},[Symbol.iterator]:()=>s};return s},Ov=e=>`multihierarchySelector${e}`,Mv=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var Wd={};Ms(Wd,{default:()=>jv});function Wv({block:e,active:t,locale:o,variables:r,configOverride:n={}}){let a=Hv(),s=qe(e),i=Ot(o),l={variables:r},p=yo(),u=useRouter(),{sectionVariables:d,setSectionVariables:m,resetSectionVariables:g}=De(e.section_id),f=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!s?.logic)return {error:"Add a Configuration"};let W=pt({logic:s.logic},i,l).logic,A={router:u,section:{variables:d,setVariables:m,resetVariables:g}};return ko(W,i,r,o,e.id,{},A,p)},[s?.logic,t,r,d]),{type:x}=f.config||{},y=x&&$i[x]?x:"Treemap";x||(f.config={error:'Visualization missing "type"'}),$i[x]||(f.config={error:`"${x}" is not a valid Visualization Type`});let E=$i[y],L=f.error||f.config?.error||false;if(L)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:L},"type")});let{_data:k,...O}=f.config,F={locale:o,variables:r,...O,...n};return a.print&&(F.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(or,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(E,{style:{flex:1},dataFormat:W=>{let A;try{A=f.dataFormat(W);}catch(B){console.error("Error in dataFormat: ",B),A=[];}return A},linksFormat:f.linksFormat,nodesFormat:f.nodesFormat,topojsonFormat:f.topojsonFormat,config:{...F}},"viz-key")})})}var Hv,qv,$i,jv,jd=b(()=>{c();Do();ui();mn();zo();Pe();pi();Hv=()=>({}),qv={},$i={HTML:fn,...XT,...qv};jv=memo(Wv,(e,t)=>e.block.contentByLocale.logic.content===t.block.contentByLocale.logic.content&&e.active===t.active&&e.locale===t.locale&&JSON.stringify(e.variables)===JSON.stringify(t.variables)&&JSON.stringify(e.configOverride)===JSON.stringify(t.configOverride));});var Yv,Ue,Kd=b(()=>{c();ge();id();cd();ud();dd();gd();kd();Cd();Ad();Id();_d();Md();Nd();Dd();qd();Yv=JT(()=>Promise.resolve().then(()=>(jd(),Wd)),{ssr:false}),Ue={[h.PARAGRAPH]:fi,[h.STAT]:gi,[h.SUBTITLE]:hi,[h.TITLE]:yi,[h.SELECTOR]:Ti,[h.VIZ]:Yv,[h.GENERATOR]:Ci,[h.SECTION_FLAG]:Ci,[h.IMAGE]:wi,[h.NAV]:Ii,[h.RELATED]:_i,[h.RESET_BUTTON]:Oi,[h.COMPARISON_BUTTON]:Mi,[h.TABLE]:Fi,[h.BUTTON]:Di,[h.MULTIHIERARCHY_SELECTOR]:zi};});var Yd=b(()=>{c();ge();({[h.TITLE]:IconHeading,[h.GENERATOR]:IconApi,[h.SECTION_FLAG]:IconFlag,[h.STAT]:IconPercentage,[h.VIZ]:IconChartBar,[h.PARAGRAPH]:IconAlignLeft,[h.SELECTOR]:IconSelector,[h.IMAGE]:IconPhoto,[h.TABLE]:IconTable,[h.MULTIHIERARCHY_SELECTOR]:IconListTree});});var Xd=b(()=>{c();ge();({[h.TITLE]:"Title",[h.GENERATOR]:"Data",[h.STAT]:"Stat",[h.VIZ]:"Visualization",[h.PARAGRAPH]:"Paragraph",[h.SELECTOR]:"Selector",[h.SUBTITLE]:"Subtitle",[h.RESET_BUTTON]:"Reset Button",[h.COMPARISON_BUTTON]:"Comparison Button",[h.RELATED]:"Related Reports",[h.NAV]:"Navigation",[h.IMAGE]:"Image",[h.TABLE]:"Table",[h.BUTTON]:"Button",[h.FALLBACK]:"Fallback",[h.SECTION_FLAG]:"Section Flag",[h.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"});});var aR,Ui,Qd=b(()=>{c();ge();ad();Kd();Yd();Xd();aR={[h.GENERATOR]:{type:h.GENERATOR,renderer:Ue[h.GENERATOR],renderPreviewOnEdit:false},[h.SECTION_FLAG]:{type:h.SECTION_FLAG,renderer:Ue[h.SECTION_FLAG],renderPreviewOnEdit:false},[h.IMAGE]:{type:h.IMAGE,renderer:Ue[h.IMAGE],renderPreviewOnEdit:false},[h.PARAGRAPH]:{type:h.PARAGRAPH,renderer:Ue[h.PARAGRAPH],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RELATED]:{type:h.RELATED,renderer:Ue[h.RELATED],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.SELECTOR]:{type:h.SELECTOR,renderer:Ue[h.SELECTOR],adapter:hn[h.SELECTOR],nonActiveAdapter:()=>hn[h.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:false},[h.STAT]:{type:h.STAT,renderer:Ue[h.STAT],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.SUBTITLE]:{type:h.SUBTITLE,renderer:Ue[h.SUBTITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TITLE]:{type:h.TITLE,renderer:Ue[h.TITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.VIZ]:{type:h.VIZ,renderer:Ue[h.VIZ],renderPreviewOnEdit:false},[h.NAV]:{type:h.NAV,renderer:Ue[h.NAV],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RESET_BUTTON]:{type:h.RESET_BUTTON,renderer:Ue[h.RESET_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.COMPARISON_BUTTON]:{type:h.COMPARISON_BUTTON,renderer:Ue[h.COMPARISON_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TABLE]:{type:h.TABLE,renderer:Ue[h.TABLE],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.BUTTON]:{type:h.BUTTON,renderer:Ue[h.BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.MULTIHIERARCHY_SELECTOR]:{type:h.MULTIHIERARCHY_SELECTOR,renderer:Ue[h.MULTIHIERARCHY_SELECTOR],adapter:hn[h.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>hn[h.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:false}},Ui=aR;});function Rs({blockId:e,active:t=true,asComparison:o=false}){let{query:r,locale:n=bt}=useRouter(),a=nt(),s=Tt(e).data,i=Tr(e,o&&a.active?a?.variables.variables:void 0,o&&a.active?a?.variables.attributes:void 0),l=qe(s,n),p=Ot(n),u={variables:i,query:r,locale:n},d=K(E=>E.variables.variables[s.id]||{}),m=K(E=>E.variables.status[s.id]||{}),[g,f]=useState(()=>{if(![h.GENERATOR,h.VIZ,h.NAV].includes(s.type)){if(s?.type===h.SELECTOR){let k=qe(s,n),{config:O}=fr(s.id,k?.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.MULTIHIERARCHY_SELECTOR){let k=qe(s,n),{config:O}=gr(s.id,k.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.RESET_BUTTON)return {...l.simple,id:s.id,section:s.section_id};if(s?.type===h.COMPARISON_BUTTON)return {...l.simple,id:s.id,section:s.section_id};let E=st(l?.logic,p,u),{vars:L}=Lt("variables",i,E,p,void 0,u);return L}return null});useEffect(()=>{(async()=>{if(!s||s.type===h.GENERATOR)return;if(s.type===h.VIZ){f({block:s,locale:n,variables:i,active:t});return}if(!t&&!Ui[s.type].evalWhenNonActive){let{nonActiveAdapter:O}=Ui[s.type],F=O&&typeof O=="function"?O():{};f(F);return}if(s.type===h.GENERATOR){f({outputVariables:d});return}if(h.SELECTOR===s.type){let O=qe(s,n),{config:F}=fr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(h.MULTIHIERARCHY_SELECTOR===s.type){let O=qe(s,n),{config:F}=gr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(s.type===h.RELATED){let{related_reports:O}=d;f({related_reports:O});return}if(s.type===h.RESET_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.COMPARISON_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.FALLBACK){f({id:s.id,type:s.original_type,roles:s.settings.access});return}let L=st(l?.logic,p,u),{vars:k}=Lt("variables",i,L,p,void 0,u);if(s.type===h.TABLE){f({sectionId:s.section_id,...k});return}if(s.type===h.NAV){f({id:s.id,headings:s.inputs,section:s.section_id,settings:s.settings,...k});return}f(k);})();},[l,i]);let x=m.allowed||s?.type===h.NAV;if(!s||!g||!x)return null;let y=Ju[s.type];return jsx("div",{id:`bespoke-${s.type}-${s.id}`,className:`cms-block-wrapper bespoke-block-area cms-block-${e}`,children:jsx(y,{...g,settings:s.settings,asComparison:o})})}var Jd=b(()=>{c();ge();ed();Qd();zo();Pe();mr();qr();Dn();Hs();Ws();eo();});var em,pR,tm,Es,ks=b(()=>{c();em={margin:{label:"Content Margin",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},columnGutter:{label:"Column Gutter",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},width:{label:"Width",defaultValue:"full",options:[{label:"Full Width",value:"full"},{label:"Center",value:"center"}]},position:{label:"Position",defaultValue:"normal",options:[{label:"Normal",value:"normal"},{label:"Sticky",value:"sticky"}]},style:{label:"Style",defaultValue:"none",options:[{label:"None",value:"none"},{label:"Card",value:"card"}]}},pR=Object.keys(em).reduce((e,t)=>(e[t]=em[t].defaultValue,e),{}),tm={memberImageBg:false,optionsMenu:false,optionData:true,optionImage:true,optionShare:true,showAnchor:false,...pR},Es=e=>({data:typeof e.optionData=="boolean"?e.optionData:true,image:typeof e.optionImage=="boolean"?e.optionImage:true,share:typeof e.optionShare=="boolean"?e.optionShare:true});});function om({previews:e}){let t=e.map((o,r)=>({key:o?`bg-${o.content_id}`:`bg-${r}`,src:o?`/api/cms/member/image?member=${o.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:true,gap:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(o=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${o.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},o.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var rm=b(()=>{c();});function nm({direction:e,onClick:t,visible:o}){return o?jsx(ActionIcon,{className:`bespoke-sortable-table-arrow bespoke-sortable-table-arrow-${e}`,variant:"filled",size:"md",sx:{position:"absolute",top:"50%",[e==="left"?"left":"right"]:"16px",zIndex:10,opacity:.55,"&:hover":{opacity:1}},onClick:t,children:e==="left"?jsx(IconArrowLeft,{size:16}):jsx(IconArrowRight,{size:16})}):null}function sm({data:e}){let t=useRef(null),[o,r]=useState(false),[n,a]=useState(false),[s,i]=useState(false),l=useMemo(()=>(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(d=>!d.startsWith("_")).map(d=>({accessorKey:d,header:d,enableSorting:true})),[e]);return useEffect(()=>{let p=()=>{if(t.current){let{scrollWidth:u,clientWidth:d,scrollLeft:m}=t.current;r(u>d),a(m>0),i(m+d<u-1);}};return p(),window.addEventListener("resize",p),t.current?.addEventListener("scroll",p),()=>{window.removeEventListener("resize",p),t.current?.removeEventListener("scroll",p);}},[e]),jsxs("div",{className:"bespoke-sortable-table",style:{position:"relative"},children:[jsx(MantineReactTable,{columns:l,data:e,enableBottomToolbar:false,enableColumnActions:false,enablePagination:false,enableSorting:true,enableTopToolbar:false,layoutMode:"grid",enableStickyHeader:true,initialState:{density:"xs"},mantineTableProps:{sx:{tableLayout:"fixed"}},mantineTableContainerProps:{ref:t,sx:{minHeight:100,maxHeight:350,overflowX:"auto"}},mantineTableBodyCellProps:{p:"5px !important",sx:{textWrap:"wrap"}},defaultColumn:{minSize:50,maxSize:150}}),jsx(nm,{direction:"left",visible:o&&n,onClick:()=>{t.current&&t.current.scrollBy({left:-150,behavior:"smooth"});}}),jsx(nm,{direction:"right",visible:o&&s,onClick:()=>{t.current&&t.current.scrollBy({left:150,behavior:"smooth"});}})]})}var am=b(()=>{c();});function Vr(e){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(a)?a.replace(n,s=>t[s]):a}var qi=b(()=>{c();});function Wi(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var im=b(()=>{c();});function RR(e){return e?vR(Wi(Vr(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var oo,Tn=b(()=>{c();qi();im();oo=RR;});function mm(e){let{section:t}=e,o=zt(),r=useRouter(),n=K(I=>I.status.isCMS),a=K(I=>I.status.currentLocale),s=r.locale,i=n?a:s,l=50,p=Ot(i),u=yo(),d=Le("options"),m={...Zi,...d.data_tab},[g,f]=useState([]),[x,y]=useState([]),[E,L]=useState(),[k,O]=useState(),[F,W]=useState(false),[A,B]=useState({}),[w,C]=useState(true),[v,P]=useState(true),{sectionVariables:D,setSectionVariables:N,resetSectionVariables:H}=De(t.id),X=t.blocks||[],M=K(I=>({records:I.records,variables:I.variables})),U=useMemo(()=>X.reduce((I,R)=>{let z=M.records.entities.block[R],G=M.variables.variables[R],J=M.variables.status[R];return (h.GENERATOR===z.type&&G._downloadEnabled===true&&J.allowed||h.VIZ===z.type&&J.allowed)&&(I[R]={entity:z,variables:M.variables.variables[R],status:M.variables.status[R],inputVariablesFlat:z.inputs.reduce((re,ne)=>({...re,...M.variables.variables[ne]}),M.variables.attributes)}),I},{}),[X]),_=I=>{y(R=>R.includes(I)?R:[...R,I]);},j=I=>{f(R=>(R.find(G=>G.ix===I.ix)?R:[...R,I]).sort((G,J)=>G.ix>J.ix?1:-1));};function ie(I){!E&&I[0]&&le(I[0]);}function le(I){L(I),O("0");}useEffect(()=>{let I=async(R,z,G)=>{let J=dataLoad.bind({});return new Promise((re,ne)=>{J(z,null,null,(we,Re)=>{if(we)ne(we);else {let _e=G instanceof Function?G(Re):Re;R.data.unshift(_e),j(R),re(Re);}});})};if(g.length===0&&x.length===0){let R=0;for(let z of Object.values(U)){let G=z.entity;if([h.GENERATOR,h.SECTION_FLAG].includes(G.type)){let J=z.variables._downloadData||z.variables._downloadUrl||z.status.api;if(J){let re=[];typeof J=="string"?re=J.split("|||"):re=[J],re=hs(re,u);let ne=z.variables._downloadTitle||`${m.data_source} ${R+1}`,we=z.variables._downloadFileName||ne;j({ix:R,id:G.id,title:Vr(ne),fileName:we,data:Array.isArray(re)?re:[re],loading:false,type:h.GENERATOR}),_(R),R++;}}else if(G.type===h.VIZ){let J=qe(G),re=z.inputVariablesFlat,ne={variables:re},we=pt({logic:J.logic},p,ne).logic,Re={router:r,section:{variables:D,setVariables:N,resetVariables:H}},_e=ko(we,p,re,i,G.id,{},Re,u),Ae=_e.config._downloadTitle||_e.config.title||`${m.viz_source} ${R+1}`,Ye=_e.config._downloadFileName||Ae;if(_e.config._downloadEnabled!==false)try{let Ne=_e.config._downloadUrl||_e.config.data,qt=typeof Ne=="string"?[Ne]:Ne,Lo=_e.dataFormat instanceof Function?_e.dataFormat:!1,_o=_e.config._downloadDataFormat instanceof Function?_e.config._downloadDataFormat:!1;I({ix:R,id:G.id,title:Vr(Ae),fileName:Ye,data:qt,loading:!1,type:h.VIZ},Ne,_o||Lo),_(R),R++;}catch(Ne){console.error("DataLoad catch",Ne);}}}P(false);}},[U]),useEffect(()=>{g.length===x.length&&ie(g);},[g]),useEffect(()=>{if(E&&k){let I=parseInt(k,10);if(E.data[I]&&(!A[E.ix]||!A[E.ix][k])){C(true);let R=E.data[k];typeof R=="string"?Xs(R,o,i,[],void 0).then(z=>{let G=UR(z);B({...A,[E.ix]:{...A[E.ix],[I]:G}});}).catch(z=>{console.error(z);}).finally(()=>{C(false);}):(B({...A,[E.ix]:{...A[E.ix],[I]:R}}),C(false));}}},[k,E]);let q=(I,R)=>{let z=I===R?"":`-${I}`.toLowerCase();if(E){let G=E.data.length>1&&k?`-${parseInt(k,10)+1}`:"";return `${oo(E.fileName)}${z}${G}.${R.toLowerCase()}`}return `${z}.${R}`},oe=async I=>{if(E){W(true);let R=new AR,z=q(I,I);try{switch(I){case Cs.json.extension:R.file(z,JSON.stringify(ee));break;case Cs.csv.extension:R.file(z,csvFormat(ee));break;case Cs.xlsx.extension:{let{utils:G,write:J}=await import('xlsx'),re=G.book_new();G.book_append_sheet(re,G.json_to_sheet(ee),z.substring(0,30));let ne=J(re,{bookType:"xlsx",bookSST:!0,type:"binary"});R.file(z,ne,{binary:!0});break}default:break}R.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(G=>{W(!1),saveAs(G,q(I,"zip"));});}catch(G){console.error(m.error_generating,G),W(false);}}},ee=useMemo(()=>E&&A[E.ix]&&A[E.ix][k]?A[E.ix][k]:[],[A,E,k]),Q=useMemo(()=>{if(g&&g.length>0&&g.length===x.length){let I=g.map(R=>({value:`${R.ix}`,label:R.title}));return jsx(Select,{disabled:!E,style:{flex:"1"},value:`${E?.ix}`,onChange:R=>{let z=g.find(G=>`${G.ix}`===R);le(z);},data:I,icon:jsx(IconDatabase,{size:16})})}else return ""},[g,E,x]);return jsxs(Stack,{className:"cms-section-options-data",gap:"xs",py:"xs",children:[jsx(LoadingOverlay,{visible:v,overlayProps:{blur:2}}),g.length===0&&!v&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:m.no_data_src}),g.length>1&&g.length===x.length&&!v&&jsx(Input.Wrapper,{label:`${m.choose_data_src}:`,children:jsx(Group,{gap:"xs",children:Q})}),E&&k&&jsx(Stack,{gap:"xs",children:jsx(Input.Wrapper,{label:`${m.preview}
15
+ a viverra sapien pulvinar.`,style:o,append:t?jsx($e,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:true})}var id=b(()=>{c();Qt();Ie();});function gi({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:a,_iconVariant:s,_icon:i,_iconRadius:l,_iconSize:p,_iconPadding:u}){let d=t||"<span class='cr-block-placeholder'>Title</span>",m=o||"<span class='cr-block-placeholder'>Big Stat</span>",g=e||"<span class='cr-block-placeholder'>Subtitle</span>",f=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:We(f),children:[a!=="none"&&a&&jsx(be,{blockType:"stat",iconType:a,iconVariant:s,iconRadius:l,iconSize:p,icon:i,iconPadding:u}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(se,{component:"div",size:"md",html:d,style:n,isPreview:true}),jsx(se,{component:"div",size:"xl",html:m,style:n,isPreview:true}),jsx(se,{component:"div",size:"sm",html:g,style:n,isPreview:true})]},"stat"),r&&jsx($e,{content:r})]})})}var cd=b(()=>{c();Qt();Jt();Ie();je();});function hi({subtitle:e,tooltip:t,settings:o}){let r=ve(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{gap:"sm",position:We(n),children:[jsx(se,{size:"sm",html:r,isPreview:true}),t&&jsx($e,{content:t,style:{display:"inline-flex"}})]})}var ud=b(()=>{c();Qt();Yt();Ie();je();});function yi({title:e,tooltip:t,_iconType:o,_iconVariant:r,_icon:n,settings:a,_iconRadius:s,_iconSize:i,_iconPadding:l}){let p=ve(e)||"Title",u=a&&a.order?parseInt(a.order,10):1,d=u<=6?u:1,m=!!(a&&a.search&&a.search!=="off"),g=a&&a.search?a.search:"",f=a&&a.align?a.align:"left";return jsxs(Group,{gap:"sm",justify:We(f),children:[o!=="none"&&o&&jsx(be,{blockType:"title",iconType:o,iconVariant:r,iconRadius:s,iconSize:i,icon:n,iconPadding:l}),jsx(se,{component:"h",order:d,style:a,html:p,isPreview:true}),m&&jsx(Tooltip,{label:`Click will open '${g}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx($e,{content:t})]})}var dd=b(()=>{c();Qt();Yt();Jt();Ie();je();});function Ti(e){let{id:t,type:o,defaultValue:r,options:n,name:a,settings:s,hideLabel:i,component:l,resetSectionVars:p,section:u}=e,d=Te(),m=useContext(Mt),g=K(v=>v.status.query),{sectionVariables:f,resetSectionVariables:x}=De(u),y=Rx(t),E=useMemo(()=>g[y]||r,[g[y],o,r]),L=useMemo(()=>Ex(g[y],r),[g[y],o,r]),[k,O]=useState(n?.map(v=>({value:v.id,label:v.label,imageUrl:v.imageUrl}))||[]),[F,W]=useState((n||[]).map(v=>v.id).join("-"));useEffect(()=>{let v=(n||[]).map(N=>`${N.label}|${N.id}`).join("-");if(F===v)return;W(v);let P=(n||[]).map(N=>({value:N.id,label:N.label}));O(P);let D=o===Be.SINGLE?E:L;Vo(o,D,n||[])||d(sa(m,y));},[JSON.stringify(n),t]);let A=()=>{p==="true"&&f&&x();},B=v=>{d(Wo(m,y,v)),A();},w=v=>{d(Wo(m,y,v.join())),A();},C=i==="true"?jsx(Fragment,{}):jsx(se,{component:"div",html:a,size:"sm",style:s,isPreview:true});return k.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):k.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(k)]}):{[Be.SINGLE]:l===Ln.SEGMENTED_CONTROL?jsxs("div",{children:[C,jsx(SegmentedControl,{data:k,value:k.map(v=>v.value).includes(E)?E:"",onChange:B,fullWidth:true})]}):jsx(Select,{label:C,data:k,value:E,onChange:B,renderOption:v=>jsx(kx,{...v}),styles:{label:{display:i==="true"?"none":"block"}}}),[Be.MULTI]:jsx(MultiSelect,{label:C,data:k,value:L,onChange:w,styles:{label:{display:i==="true"?"none":"block"}}})}[o]}var Rx,Ex,kx,gd=b(()=>{c();Jr();_n();ge();he();Kt();Ie();Pe();Rx=e=>`selector${e}id`,Ex=(e,t)=>e&&typeof e=="string"?e.split(","):t,kx=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{wrap:"nowrap",children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});var hd=b(()=>{});function Ei({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:a=0}){let s=useMantineTheme(),[i,l]=useState(false);if(a===Ri)return null;let p=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),u=vi(r),d=r,m=JSON.stringify(d),g=100,f=1e3,x=!!(m&&m.length>g),y=10,E={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(u==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,c:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:a+1<Ri?Object.keys(r).sort((L,k)=>{let O=vi(r[L]),F=vi(r[k]);return O!==F?bd.indexOf(O)-bd.indexOf(F):L.localeCompare(k)}).map(L=>jsx(Ei,{root:false,label:L,value:r[L],level:a+1},L)):p})]})});if(u==="array"){let L=r.length>y,k=L?r.slice(0,y):r,O=L?r.length-y:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,p:0,color:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[a+1<Ri?k.map((F,W)=>jsx(Ei,{root:false,label:W,value:F,level:a+1,parentIsArray:true},W)):p,L&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",O," other elements]"]})]})]})})}return u==="string"?d=x?`"${d.substring(0,g)} ... "`:`"${d}"`:u==="error"?d=`Error: ${d.message}`:u==="undefined"?d=u:d.toString&&(d=d.toString()),jsxs(Group,{wrap:"nowrap",gap:0,justify:"space-between",children:[jsx(Tooltip,{label:"Copied!",opened:i,closeDelay:1e3,children:jsx(Text,{c:e?"dimmed":s.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap",cursor:"pointer"},onClick:()=>{let L=o?`{{${t}}}`:n?`[${t}]`:t;navigator.clipboard.writeText(L),l(true),setTimeout(()=>l(false),1e3);},fw:700,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Tooltip,{label:d,children:jsx(CodeHighlight,{className:"cr-variable",code:d,language:"jsx",withCopyButton:false,styles:L=>({codeHighlight:{textAlign:"right",overflow:"hidden",width:"fit-content",flex:"0 1 auto"},code:{padding:"5px 0 5px 5px",fontSize:L.fontSizes.xs},pre:{marginLeft:"5px",marginTop:"0px",marginBottom:"0px"},showCodeButton:{display:"none"}})})}),x&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,children:[jsx(HoverCard.Target,{children:jsx(ActionIcon,{children:jsx(IconCodePlus,{})})}),jsx(HoverCard.Dropdown,{w:500,children:jsx(Text,{size:"sm",maw:"100%",style:{wordBreak:"break-all",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:m.substring(0,f)})})]})]})}var vi,bd,Ri,Sd,Td=b(()=>{c();hd();vi=e=>{let t=typeof e;if(t==="object"){if(e===null)return "undefined";Array.isArray(e)?t="array":["Error","EvalError","ReferenceError","SyntaxError"].includes(e.constructor.name)&&(t="error");}return t},bd=["object","array","string","number"],Ri=5;Sd=Ei;});var xd,vd=b(()=>{c();xd=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function Mx({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let a=Tt(t==="attributes"?null:t).data,s=a?a.type:"block",i=a?.type&&a?.id?`${a.type}${a.id}`:"",l=Object.keys(o).filter(r?()=>true:p=>!xd(i)(p));return jsx(Stack,{gap:0,children:l.length?l.map(p=>jsx(Sd,{dimmed:e.includes(p),label:p,value:o[p]},p)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${s}`})})})}var Rd,Ed=b(()=>{c();Td();he();vd();Rd=Mx;});function Hx({outputVariables:e,status:t,hasAPI:o=false,debug:r,type:n}){let[a,s]=useState(false),i=o&&!Object.keys(e).length&&!t.error,l=Object.keys(e).some(u=>u.startsWith("_"));return r?i?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),l&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:a,onChange:u=>s(u.currentTarget.checked)}),jsx(Rd,{variables:e,showInternal:a})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var Ci,kd=b(()=>{c();Ed();Ci=Hx;});function wi(e){let{alt:t,src:o,desc:r,title:n,settings:a,...s}=e,i=ve(t),l=ve(o),p=ve(r),u=jsx("img",{src:l,alt:i,style:s}),d=a&&a.align?String(a.align):"left";return (p&&p.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:ot(d),gap:"sm",children:[n&&jsx(se,{component:"p",html:n,style:a,isPreview:true}),u,r&&jsx(se,{component:"p",size:"sm",html:r,style:a,isPreview:true})]})),l&&i?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Cd=b(()=>{c();Yt();Ie();je();});function Ii({headings:e,settings:t,title:o,shortTitle:r,_iconType:n,_iconVariant:a,_icon:s,_iconRadius:i,_iconSize:l,_iconPadding:p}){let{min:u="1",max:d="6",icons:m="yes"}=t||{},g=ve(o)||"",f=ve(r||o)||"",x=g&&g.length>0,y=n&&n!=="none",E=f===g?`${g}`:`${g} (${f})`,L=Pr(parseInt(u,10),parseInt(d,10),e),k=m==="yes",O=t&&t.align?String(t.align):"left",F=Rr(O),W=We(O),A=ot(O),B=t&&t.titlePosition?String(t.titlePosition):"left",w=useMemo(()=>{let v={right:"left",left:"right"},P=x&&["left","right"].includes(B),D={};if(P){let N=B==="right";D={gap:"xs",justify:N&&v[W]?v[W]:W,style:{flexDirection:N?"row-reverse":"row"},wrap:"nowrap"};}else D={gap:"xs",align:A,justify:"center",style:{flexDirection:B==="bottom"?"column-reverse":"column"}};return {element:P?Group:Stack,props:D}},[x,W,A,B]),C=v=>!v||!v?.length?null:jsx(Fragment,{children:v.map(P=>jsxs(Fragment$1,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${P.id}`,children:jsxs(Group,{gap:"sm",children:[k&&jsx(be,{...P.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:P.label}})]})})},P.id),jsx(Box,{pl:"xs",children:C(P.children)})]},P.id))});return jsxs(w.element,{pos:"relative",...w.props,children:[x&&jsxs(Group,{gap:"xs",position:W,wrap:"nowrap",children:[y&&jsx(be,{blockType:"title",iconType:n,iconVariant:a,iconRadius:i,iconSize:l,icon:s,iconPadding:p}),jsx(se,{style:t,html:E,isPreview:true,lineClamp:1})]}),jsxs(List,{sx:v=>({display:"flex",gap:v.spacing.md,justifyContent:F,alignItems:"center",listStyleType:"none"}),children:[L?.map(v=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${v.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[k&&jsx(be,{blockType:"nav",...v.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:v.label}})]})})}),v?.children?.length?jsx(Menu.Dropdown,{children:C(v.children)}):null]})},v.id)),!L||L.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})]})}var Ad=b(()=>{c();Qa();Jt();je();Ie();Jt();Yt();});function _i(e){let{related_reports:t,settings:o}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let r=Rr(o&&o.align?String(o.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:r,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(a=>a.name).join(" & ")},n.link))})}var Id=b(()=>{c();je();});function Oi({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:a}){let s=Tt(e).data,{sectionVariables:i,resetSectionVariables:l}=De(s?.section_id),p=!!Object.keys(i).length,u=ot(o&&o.align?o.align:"left");return jsxs(Stack,{align:u,children:[!p&&!a&&jsx(Text,{size:"xs",ta:o?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>l(),disabled:!p,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})]})}var _d=b(()=>{c();Pe();Pe();je();});function Mi({settings:e,label:t,showIcon:o,position:r="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:r,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",o&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var Md=b(()=>{c();});function Fi({columns:e=[],id:t,data:o=[],tableProps:r={}}){let[n,a]=useState({}),{initialState:s}=r,i=s?.pagination?.pageIndex,l=s?.pagination?.pageSize,p=`table-${[t,i,l].filter(f=>f).join("-")}`,u=useMemo(()=>e.map(f=>f.accessorKey),[e]),d=useMemo(()=>o.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(x=>u.includes(x))),[u,o]),m=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:x})=>jsx(se,{html:`${x}`,isPreview:true}),filterFn:"contains"})),[e]),g=kc();return useEffect(()=>{(async()=>{try{let y=`${(g||"en").toUpperCase()}`;a({});}catch(x){console.error("Error loading translations:",x);}})();},[g]),createElement(MantineReactTable,{...r,autoResetPageIndex:false,columns:m,data:d,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",key:p,layoutMode:"grid",localization:n,state:{...r.state,isFullScreen:false}})}var Nd=b(()=>{c();Ie();Pe();});function Di({label:e,url:t,settings:o}){let{align:r}=o;return jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var Dd=b(()=>{c();});function zi(e){let t=Te(),o=useContext(Mt),r=K($=>$.status.query),n=Ov(e.id),a=useMantineTheme(),{colorScheme:s}=useMantineColorScheme(),{allLabel:i,colorKey:l,data:p,defaultValue:u,defaultValueType:d,iconKey:m,levels:g,limit:f,placeholder:x,searchIndexKey:y,searchIndexSeparator:E,resetSectionVars:L,section:k}=e,[O,F]=useState(false),[W,A]=useState(true),[B,w]=useState(""),[C,v]=useState(false),[P,D]=useState([""].slice(1)),{sectionVariables:N,resetSectionVariables:H}=De(k),X=useMemo(()=>Mv(r[`${n}-value`],u),[r,u,n]),M=useMemo(()=>r[`${n}-type`]||d,[r,d,n]),U=useCallback(()=>{L==="true"&&N&&H();},[L,N,H]),_=useCallback($=>{U(),t(Wo(o,`${n}-value`,$.join()));},[t,o,n,U]),j=useCallback($=>{U(),t(Wo(o,`${n}-type`,$));},[t,o,n,U]),ie=useRef(null),le=useRef(false),q=useRef(!!f&&f<X.length),oe=P.length,ee=g[oe],Q=P.filter(Boolean);P.length>0&&Q.length===0&&Q.push(`${i} ${ee?.label}`),useEffect(()=>{let $=()=>{A(true);};return window.addEventListener("touchmove",$),()=>{window.removeEventListener("touchmove",$);}},[]);let I=useMemo(()=>Lv(p,g,l,m,y,E),[l,p,m,g,y,E]),R=useMemo(()=>{let $=_v(B),ce=Array.from(Bv(I,$)).reverse();return C?ce:P.reduce((ye,V)=>ye.filter(te=>!V||te.searchindex.indexOf(V)>-1),ce.filter(ye=>ye.type===ee?.value))},[ee,I,B,C,P]),z=useRef(null),G=es({count:O?R.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>z.current,[]),overscan:10,rangeExtractor:useCallback($=>ln($),[])}),[J,re]=useState(-1),ne=Math.min(J,R.length-1),we=useCallback($=>{let ce=P.concat($);C&&v(false),D(ce);},[C,P]),Re=useCallback(()=>{let $=P.slice(0,oe-1);C&&v(false),D($);},[C,P,oe]),_e=useCallback($=>{w($.currentTarget.value),!q.current&&p.length>0&&F(true);},[p,w,q,F]),Ae=useCallback(()=>{w(""),_([]),ie.current?.focus(),f&&(q.current=false);},[w,_,ie,f,q]),Ye=useCallback($=>{let ce=X.filter(ye=>ye!==$);_(ce),f&&ce.length<f&&(q.current=false);},[X,_,f,q]),Ne=useCallback($=>{M||j($.type),M!==$.type?(j($.type),_([$.value])):X.includes($.value)?Ye($.value):f?(X.length<f&&_([...X,$.value]),X.length===f&&_([...X.slice(1),$.value])):_([...X,$.value]),w("");},[M,j,_,X,Ye,f]),qt=useCallback(()=>{X.length>0&&B.length===0&&(_(X.slice(0,-1)),F(true),f&&(q.current=false)),B.length>0&&w(B.slice(0,-1));},[X,B,_,w,F,f,q]),Lo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$+1>=R.length?$:$+1);},[re,R]),_o=useCallback(()=>{let $=R[ne];$&&Ne($);},[R,ne,Ne]),wt=useCallback(()=>{F(false);},[F]),At=useCallback(()=>{Re(),re(0);},[re,Re]),no=useCallback(()=>{let $=R[ne];!C&&$&&$.type!==g[g.length-1]?.value&&(we($.name),re(0));},[R,ne,C,g,re,we]),Bo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$-1<0?0:$-1);},[re]),ar=({label:$,onRemove:ce,...ye})=>jsxs("div",{style:{alignItems:"center",backgroundColor:s==="dark"?"var(--mantine-color-dark-7)":"var(--mantine-color-gray-1)",borderRadius:a.radius.sm,cursor:"default",color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${a.spacing.xs} / 2 - ${rem(2)}) calc(${a.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${a.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...ye,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:ce,radius:2,size:"sm",sx:{color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",marginLeft:`calc(${a.spacing.sm} / 6)`},tabIndex:-1})]}),ze=useMemo(()=>X.map($=>I.find(ce=>ce.value===$)).filter($=>!!$).map(($,ce)=>createElement(ar,{...$,index:ce,key:$.value,onRemove:ye=>{ye.preventDefault(),ye.stopPropagation(),Ye($.value);}})),[X]),ir=forwardRef(function({color:ce,icon:ye,label:V,value:te,...ue},lt){return jsx("div",{ref:lt,style:{cursor:"pointer",width:"100%"},...ue,children:jsxs(Group,{align:"center",wrap:"nowrap",gap:"xs",w:"100%",children:[ye&&jsx(Box,{bg:ce??"transparent",component:"img",w:20,h:20,src:ye}),jsx(Text,{lineClamp:1,size:"sm",children:V||te})]})})}),{settings:lr}=e,so=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(se,{component:"div",html:e.label,size:"sm",style:lr,isPreview:true});return jsx(Input.Wrapper,{label:so,children:jsxs(Popover,{closeOnClickOutside:true,keepMounted:true,opened:O,onChange:F,onClose:()=>{re(0),w("");},onOpen:()=>{G.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>re(0),sx:{position:"relative","& .defaultValue":{backgroundColor:s==="dark"?"var(--mantine-color-dark-5)":"var(--mantine-color-gray-3)",color:s==="dark"?"var(--mantine-color-dark-1)":"var(--mantine-color-gray-7)"}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:X.join(",")}),jsx(Input,{component:"div",multiline:true,onMouseDown:$=>{$.preventDefault(),!q.current&&p.length>0&&F(!O),ie.current?.focus();},rightSection:X.length>0?jsx(CloseButton,{onClick:Ae,onMouseDown:$=>$.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:a.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${a.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:s==="dark"?"var(--mantine-color-dark-3)":"var(--mantine-color-gray-5)",opacity:1}},children:[ze,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":O,onChange:_e,onKeyDown:getHotkeyHandler([["ArrowDown",Lo],["ArrowLeft",At],["ArrowRight",no],["ArrowUp",Bo],["Backspace",qt],["Enter",_o],["Escape",wt]]),placeholder:X.length===0?x:void 0,ref:ie,readOnly:q.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:a.fontSizes.sm,marginLeft:`calc(${a.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:B})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:$=>$.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:$=>$.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",gap:"xs",w:"100%",children:[g.length>1&&jsxs(Stack,{gap:"xs",children:[jsxs(Group,{onClick:$=>{$.stopPropagation();},px:"xs",justify:"center",gap:"xs",children:[jsx(Button,{onClick:()=>{re(0),v(true),D([]),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:C?"filled":"outline",children:i}),g.map(($,ce)=>jsx(Button,{onClick:()=>{C&&v(false);let ye=[""].slice(1),V=ce;for(;V--;)ye[V]=P[V]||"";re(0),D(ye),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:!C&&P.length===g.findIndex(ye=>ye.value===$?.value)?"filled":"outline",children:$?.label},$?.value))]}),jsx(Divider,{})]}),oe>0&&jsxs(Group,{align:"center",wrap:"nowrap",px:"xs",children:[jsx(ActionIcon,{onClick:Re,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:Q.map($=>jsx(Text,{lineClamp:1,size:"xs",children:$},`${$}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>A(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:z,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${G.getTotalSize()}px`,position:"relative",width:"100%"},children:G.getVirtualItems().map($=>{let ce=R[$.index],ye=ne===$.index,V=X.includes(ce.value);return R.length>0&&ye&&!W&&G.scrollToIndex(ne),jsxs(Group,{"aria-selected":ye,align:"center","data-hovered":ye||void 0,"data-index":$.index,"data-selected":V,id:ce.vale,wrap:"nowrap",onMouseEnter:te=>{te.preventDefault(),te.stopPropagation(),W&&(re($.index),A(false));},onMouseMove:te=>{te.preventDefault(),te.stopPropagation(),A(true);},onMouseDown:te=>{te.preventDefault(),Ne(ce);},justify:"space-between",ref:G.measureElement,role:"option",gap:"xs",sx:te=>({borderRadius:te.radius.xs,padding:"15px 5px 15px",paddingLeft:C&&10*g.findIndex(ue=>ue?.value===ce.type)||5,position:"absolute",top:0,left:0,height:`${$.size}px`,transform:`translateY(${$.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"},"&:hover":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"}}),tabIndex:-1,children:[jsx(ir,{index:$.index,...ce}),!C&&ce.type!==g[g.length-1]?.value&&jsx(ActionIcon,{onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),we(ce.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},ce.value)})})})]})})})})]})})}var Lv,_v,Bv,Ov,Mv,qd=b(()=>{c();Va();Ie();Kt();he();Pe();Jr();Lv=(e=[],t=[],o="",r="",n="",a="|")=>{let s=t.map(x=>x.value).slice(),i=`${s.pop()}`,l=x=>x[o],p=x=>x[r],u=x=>{if(x[n])return typeof x[n]=="string"?x[n].split(a):x[n]},d=new Set,m=[],g=[],f=nest().rollup(x=>{let y=x[0],E=w=>w&&w.value&&!d.has(w.value),L=s.map(w=>y[`${w} ID`]),k=s.map(w=>y[w]),O=s.map((w,C)=>{if(g[C]!==k[C]){g[C]=k[C];let v=l[C]||l[l.length-1]||l,P=p[C]||p[p.length-1]||p,D=u[C]||u[u.length-1]||u;return {color:v(y,w)||void 0,icon:P(y,w)||void 0,value:`${L[C]}`,label:k[C],name:k[C],type:w,searchindex:k.slice(0,C+1).concat(D(y,w)).join("|")}}return {}}).filter(E);O.forEach(w=>d.add(w.value));let F=l[l.length-1]||l,W=p[p.length-1]||p,A=u[u.length-1]||u,B=x.map(w=>({color:F(w,i)||void 0,icon:W(w,i)||void 0,value:`${w[`${i} ID`]}`,label:w[i],name:w[i],type:i,searchindex:k.concat(w[i]).concat(A(w,i)).join("|")}));m.push(...O.concat(B));});return s.forEach(x=>{f.key(y=>`${y[`${x} ID`]}|${y[x]}`);}),f.entries(e),m},_v=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},Bv=(e,t)=>{let o=e.length,r,n=i=>r&&r.searchindex.includes(i.searchindex),s={next:()=>{for(let i=o-1;i>-1;i--){let l=e[i];if(t.test(`${l.value} ${l.label} ${l.searchindex}`)||n(l))return r=l,o=i,{done:false,value:l}}return {done:true,value:void 0}},[Symbol.iterator]:()=>s};return s},Ov=e=>`multihierarchySelector${e}`,Mv=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var Wd={};Ms(Wd,{default:()=>jv});function Wv({block:e,active:t,locale:o,variables:r,configOverride:n={}}){let a=Hv(),s=qe(e),i=Ot(o),l={variables:r},p=yo(),u=useRouter(),{sectionVariables:d,setSectionVariables:m,resetSectionVariables:g}=De(e.section_id),f=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!s?.logic)return {error:"Add a Configuration"};let W=pt({logic:s.logic},i,l).logic,A={router:u,section:{variables:d,setVariables:m,resetVariables:g}};return ko(W,i,r,o,e.id,{},A,p)},[s?.logic,t,r,d]),{type:x}=f.config||{},y=x&&$i[x]?x:"Treemap";x||(f.config={error:'Visualization missing "type"'}),$i[x]||(f.config={error:`"${x}" is not a valid Visualization Type`});let E=$i[y],L=f.error||f.config?.error||false;if(L)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:L},"type")});let{_data:k,...O}=f.config,F={locale:o,variables:r,...O,...n};return a.print&&(F.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(or,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(E,{style:{flex:1},dataFormat:W=>{let A;try{A=f.dataFormat(W);}catch(B){console.error("Error in dataFormat: ",B),A=[];}return A},linksFormat:f.linksFormat,nodesFormat:f.nodesFormat,topojsonFormat:f.topojsonFormat,config:{...F}},"viz-key")})})}var Hv,qv,$i,jv,jd=b(()=>{c();Do();ui();mn();zo();Pe();pi();Hv=()=>({}),qv={},$i={HTML:fn,...XT,...qv};jv=memo(Wv,(e,t)=>e.block.contentByLocale.logic.content===t.block.contentByLocale.logic.content&&e.active===t.active&&e.locale===t.locale&&JSON.stringify(e.variables)===JSON.stringify(t.variables)&&JSON.stringify(e.configOverride)===JSON.stringify(t.configOverride));});var Yv,Ue,Kd=b(()=>{c();ge();id();cd();ud();dd();gd();kd();Cd();Ad();Id();_d();Md();Nd();Dd();qd();Yv=JT(()=>Promise.resolve().then(()=>(jd(),Wd)),{ssr:false}),Ue={[h.PARAGRAPH]:fi,[h.STAT]:gi,[h.SUBTITLE]:hi,[h.TITLE]:yi,[h.SELECTOR]:Ti,[h.VIZ]:Yv,[h.GENERATOR]:Ci,[h.SECTION_FLAG]:Ci,[h.IMAGE]:wi,[h.NAV]:Ii,[h.RELATED]:_i,[h.RESET_BUTTON]:Oi,[h.COMPARISON_BUTTON]:Mi,[h.TABLE]:Fi,[h.BUTTON]:Di,[h.MULTIHIERARCHY_SELECTOR]:zi};});var Yd=b(()=>{c();ge();({[h.TITLE]:IconHeading,[h.GENERATOR]:IconApi,[h.SECTION_FLAG]:IconFlag,[h.STAT]:IconPercentage,[h.VIZ]:IconChartBar,[h.PARAGRAPH]:IconAlignLeft,[h.SELECTOR]:IconSelector,[h.IMAGE]:IconPhoto,[h.TABLE]:IconTable,[h.MULTIHIERARCHY_SELECTOR]:IconListTree});});var Xd=b(()=>{c();ge();({[h.TITLE]:"Title",[h.GENERATOR]:"Data",[h.STAT]:"Stat",[h.VIZ]:"Visualization",[h.PARAGRAPH]:"Paragraph",[h.SELECTOR]:"Selector",[h.SUBTITLE]:"Subtitle",[h.RESET_BUTTON]:"Reset Button",[h.COMPARISON_BUTTON]:"Comparison Button",[h.RELATED]:"Related Reports",[h.NAV]:"Navigation",[h.IMAGE]:"Image",[h.TABLE]:"Table",[h.BUTTON]:"Button",[h.FALLBACK]:"Fallback",[h.SECTION_FLAG]:"Section Flag",[h.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"});});var aR,Ui,Qd=b(()=>{c();ge();ad();Kd();Yd();Xd();aR={[h.GENERATOR]:{type:h.GENERATOR,renderer:Ue[h.GENERATOR],renderPreviewOnEdit:false},[h.SECTION_FLAG]:{type:h.SECTION_FLAG,renderer:Ue[h.SECTION_FLAG],renderPreviewOnEdit:false},[h.IMAGE]:{type:h.IMAGE,renderer:Ue[h.IMAGE],renderPreviewOnEdit:false},[h.PARAGRAPH]:{type:h.PARAGRAPH,renderer:Ue[h.PARAGRAPH],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RELATED]:{type:h.RELATED,renderer:Ue[h.RELATED],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.SELECTOR]:{type:h.SELECTOR,renderer:Ue[h.SELECTOR],adapter:hn[h.SELECTOR],nonActiveAdapter:()=>hn[h.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:false},[h.STAT]:{type:h.STAT,renderer:Ue[h.STAT],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.SUBTITLE]:{type:h.SUBTITLE,renderer:Ue[h.SUBTITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TITLE]:{type:h.TITLE,renderer:Ue[h.TITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.VIZ]:{type:h.VIZ,renderer:Ue[h.VIZ],renderPreviewOnEdit:false},[h.NAV]:{type:h.NAV,renderer:Ue[h.NAV],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RESET_BUTTON]:{type:h.RESET_BUTTON,renderer:Ue[h.RESET_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.COMPARISON_BUTTON]:{type:h.COMPARISON_BUTTON,renderer:Ue[h.COMPARISON_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TABLE]:{type:h.TABLE,renderer:Ue[h.TABLE],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.BUTTON]:{type:h.BUTTON,renderer:Ue[h.BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.MULTIHIERARCHY_SELECTOR]:{type:h.MULTIHIERARCHY_SELECTOR,renderer:Ue[h.MULTIHIERARCHY_SELECTOR],adapter:hn[h.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>hn[h.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:false}},Ui=aR;});function Rs({blockId:e,active:t=true,asComparison:o=false}){let{query:r,locale:n=bt}=useRouter(),a=nt(),s=Tt(e).data,i=Tr(e,o&&a.active?a?.variables.variables:void 0,o&&a.active?a?.variables.attributes:void 0),l=qe(s,n),p=Ot(n),u={variables:i,query:r,locale:n},d=K(E=>E.variables.variables[s.id]||{}),m=K(E=>E.variables.status[s.id]||{}),[g,f]=useState(()=>{if(![h.GENERATOR,h.VIZ,h.NAV].includes(s.type)){if(s?.type===h.SELECTOR){let k=qe(s,n),{config:O}=fr(s.id,k?.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.MULTIHIERARCHY_SELECTOR){let k=qe(s,n),{config:O}=gr(s.id,k.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.RESET_BUTTON)return {...l.simple,id:s.id,section:s.section_id};if(s?.type===h.COMPARISON_BUTTON)return {...l.simple,id:s.id,section:s.section_id};let E=st(l?.logic,p,u),{vars:L}=Lt("variables",i,E,p,void 0,u);return L}return null});useEffect(()=>{(async()=>{if(!s||s.type===h.GENERATOR)return;if(s.type===h.VIZ){f({block:s,locale:n,variables:i,active:t});return}if(!t&&!Ui[s.type].evalWhenNonActive){let{nonActiveAdapter:O}=Ui[s.type],F=O&&typeof O=="function"?O():{};f(F);return}if(s.type===h.GENERATOR){f({outputVariables:d});return}if(h.SELECTOR===s.type){let O=qe(s,n),{config:F}=fr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(h.MULTIHIERARCHY_SELECTOR===s.type){let O=qe(s,n),{config:F}=gr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(s.type===h.RELATED){let{related_reports:O}=d;f({related_reports:O});return}if(s.type===h.RESET_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.COMPARISON_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.FALLBACK){f({id:s.id,type:s.original_type,roles:s.settings.access});return}let L=st(l?.logic,p,u),{vars:k}=Lt("variables",i,L,p,void 0,u);if(s.type===h.TABLE){f({sectionId:s.section_id,...k});return}if(s.type===h.NAV){f({id:s.id,headings:s.inputs,section:s.section_id,settings:s.settings,...k});return}f(k);})();},[l,i]);let x=m.allowed||s?.type===h.NAV;if(!s||!g||!x)return null;let y=Ju[s.type];return jsx("div",{id:`bespoke-${s.type}-${s.id}`,className:`cms-block-wrapper bespoke-block-area cms-block-${e}`,children:jsx(y,{...g,settings:s.settings,asComparison:o})})}var Jd=b(()=>{c();ge();ed();Qd();zo();Pe();mr();qr();Dn();Hs();Ws();eo();});var em,pR,tm,Es,ks=b(()=>{c();em={margin:{label:"Content Margin",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},columnGutter:{label:"Column Gutter",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},width:{label:"Width",defaultValue:"full",options:[{label:"Full Width",value:"full"},{label:"Center",value:"center"}]},position:{label:"Position",defaultValue:"normal",options:[{label:"Normal",value:"normal"},{label:"Sticky",value:"sticky"}]},style:{label:"Style",defaultValue:"none",options:[{label:"None",value:"none"},{label:"Card",value:"card"}]}},pR=Object.keys(em).reduce((e,t)=>(e[t]=em[t].defaultValue,e),{}),tm={memberImageBg:false,optionsMenu:false,optionData:true,optionImage:true,optionShare:true,showAnchor:false,...pR},Es=e=>({data:typeof e.optionData=="boolean"?e.optionData:true,image:typeof e.optionImage=="boolean"?e.optionImage:true,share:typeof e.optionShare=="boolean"?e.optionShare:true});});function om({previews:e}){let t=e.map((o,r)=>({key:o?`bg-${o.content_id}`:`bg-${r}`,src:o?`/api/cms/member/image?member=${o.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:true,gap:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(o=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${o.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},o.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var rm=b(()=>{c();});function nm({direction:e,onClick:t,visible:o}){return o?jsx(ActionIcon,{className:`bespoke-sortable-table-arrow bespoke-sortable-table-arrow-${e}`,variant:"filled",size:"md",sx:{position:"absolute",top:"50%",[e==="left"?"left":"right"]:"16px",zIndex:10,opacity:.55,"&:hover":{opacity:1}},onClick:t,children:e==="left"?jsx(IconArrowLeft,{size:16}):jsx(IconArrowRight,{size:16})}):null}function sm({data:e}){let t=useRef(null),[o,r]=useState(false),[n,a]=useState(false),[s,i]=useState(false),l=useMemo(()=>(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(d=>!d.startsWith("_")).map(d=>({accessorKey:d,header:d,enableSorting:true})),[e]);return useEffect(()=>{let p=()=>{if(t.current){let{scrollWidth:u,clientWidth:d,scrollLeft:m}=t.current;r(u>d),a(m>0),i(m+d<u-1);}};return p(),window.addEventListener("resize",p),t.current?.addEventListener("scroll",p),()=>{window.removeEventListener("resize",p),t.current?.removeEventListener("scroll",p);}},[e]),jsxs("div",{className:"bespoke-sortable-table",style:{position:"relative"},children:[jsx(MantineReactTable,{columns:l,data:e,enableBottomToolbar:false,enableColumnActions:false,enablePagination:false,enableSorting:true,enableTopToolbar:false,layoutMode:"grid",enableStickyHeader:true,initialState:{density:"xs"},mantineTableProps:{sx:{tableLayout:"fixed"}},mantineTableContainerProps:{ref:t,sx:{minHeight:100,maxHeight:350,overflowX:"auto"}},mantineTableBodyCellProps:{p:"5px !important",sx:{textWrap:"wrap"}},defaultColumn:{minSize:50,maxSize:150}}),jsx(nm,{direction:"left",visible:o&&n,onClick:()=>{t.current&&t.current.scrollBy({left:-150,behavior:"smooth"});}}),jsx(nm,{direction:"right",visible:o&&s,onClick:()=>{t.current&&t.current.scrollBy({left:150,behavior:"smooth"});}})]})}var am=b(()=>{c();});function Vr(e){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(a)?a.replace(n,s=>t[s]):a}var qi=b(()=>{c();});function Wi(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var im=b(()=>{c();});function RR(e){return e?vR(Wi(Vr(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var oo,Tn=b(()=>{c();qi();im();oo=RR;});function mm(e){let{section:t}=e,o=zt(),r=useRouter(),n=K(I=>I.status.isCMS),a=K(I=>I.status.currentLocale),s=r.locale,i=n?a:s,l=50,p=Ot(i),u=yo(),d=Le("options"),m={...Zi,...d.data_tab},[g,f]=useState([]),[x,y]=useState([]),[E,L]=useState(),[k,O]=useState(),[F,W]=useState(false),[A,B]=useState({}),[w,C]=useState(true),[v,P]=useState(true),{sectionVariables:D,setSectionVariables:N,resetSectionVariables:H}=De(t.id),X=t.blocks||[],M=K(I=>({records:I.records,variables:I.variables})),U=useMemo(()=>X.reduce((I,R)=>{let z=M.records.entities.block[R],G=M.variables.variables[R],J=M.variables.status[R];return (h.GENERATOR===z.type&&G._downloadEnabled===true&&J.allowed||h.VIZ===z.type&&J.allowed)&&(I[R]={entity:z,variables:M.variables.variables[R],status:M.variables.status[R],inputVariablesFlat:z.inputs.reduce((re,ne)=>({...re,...M.variables.variables[ne]}),M.variables.attributes)}),I},{}),[X]),_=I=>{y(R=>R.includes(I)?R:[...R,I]);},j=I=>{f(R=>(R.find(G=>G.ix===I.ix)?R:[...R,I]).sort((G,J)=>G.ix>J.ix?1:-1));};function ie(I){!E&&I[0]&&le(I[0]);}function le(I){L(I),O("0");}useEffect(()=>{let I=async(R,z,G)=>{let J=dataLoad.bind({});return new Promise((re,ne)=>{J(z,null,null,(we,Re)=>{if(we)ne(we);else {let _e=G instanceof Function?G(Re):Re;R.data.unshift(_e),j(R),re(Re);}});})};if(g.length===0&&x.length===0){let R=0;for(let z of Object.values(U)){let G=z.entity;if([h.GENERATOR,h.SECTION_FLAG].includes(G.type)){let J=z.variables._downloadData||z.variables._downloadUrl||z.status.api;if(J){let re=[];typeof J=="string"?re=J.split("|||"):re=[J],re=hs(re,u);let ne=z.variables._downloadTitle||`${m.data_source} ${R+1}`,we=z.variables._downloadFileName||ne;j({ix:R,id:G.id,title:Vr(ne),fileName:we,data:Array.isArray(re)?re:[re],loading:false,type:h.GENERATOR}),_(R),R++;}}else if(G.type===h.VIZ){let J=qe(G),re=z.inputVariablesFlat,ne={variables:re},we=pt({logic:J.logic},p,ne).logic,Re={router:r,section:{variables:D,setVariables:N,resetVariables:H}},_e=ko(we,p,re,i,G.id,{},Re,u),Ae=_e.config._downloadTitle||_e.config.title||`${m.viz_source} ${R+1}`,Ye=_e.config._downloadFileName||Ae;if(_e.config._downloadEnabled!==false)try{let Ne=_e.config._downloadUrl||_e.config.data,qt=typeof Ne=="string"?[Ne]:Ne,Lo=_e.dataFormat instanceof Function?_e.dataFormat:!1,_o=_e.config._downloadDataFormat instanceof Function?_e.config._downloadDataFormat:!1;I({ix:R,id:G.id,title:Vr(Ae),fileName:Ye,data:qt,loading:!1,type:h.VIZ},Ne,_o||Lo),_(R),R++;}catch(Ne){console.error("DataLoad catch",Ne);}}}P(false);}},[U]),useEffect(()=>{g.length===x.length&&ie(g);},[g]),useEffect(()=>{if(E&&k){let I=parseInt(k,10);if(E.data[I]&&(!A[E.ix]||!A[E.ix][k])){C(true);let R=E.data[k];typeof R=="string"?Xs(R,o,i,[],void 0).then(z=>{let G=UR(z);B({...A,[E.ix]:{...A[E.ix],[I]:G}});}).catch(z=>{console.error(z);}).finally(()=>{C(false);}):(B({...A,[E.ix]:{...A[E.ix],[I]:R}}),C(false));}}},[k,E]);let q=(I,R)=>{let z=I===R?"":`-${I}`.toLowerCase();if(E){let G=E.data.length>1&&k?`-${parseInt(k,10)+1}`:"";return `${oo(E.fileName)}${z}${G}.${R.toLowerCase()}`}return `${z}.${R}`},oe=async I=>{if(E){W(true);let R=new AR,z=q(I,I);try{switch(I){case Cs.json.extension:R.file(z,JSON.stringify(ee));break;case Cs.csv.extension:R.file(z,csvFormat(ee));break;case Cs.xlsx.extension:{let{utils:G,write:J}=await import('xlsx'),re=G.book_new();G.book_append_sheet(re,G.json_to_sheet(ee),z.substring(0,30));let ne=J(re,{bookType:"xlsx",bookSST:!0,type:"binary"});R.file(z,ne,{binary:!0});break}default:break}R.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(G=>{W(!1),saveAs(G,q(I,"zip"));});}catch(G){console.error(m.error_generating,G),W(false);}}},ee=useMemo(()=>E&&A[E.ix]&&A[E.ix][k]?A[E.ix][k]:[],[A,E,k]),Q=useMemo(()=>{if(g&&g.length>0&&g.length===x.length){let I=g.map(R=>({value:`${R.ix}`,label:R.title}));return jsx(Select,{disabled:!E,style:{flex:"1"},value:`${E?.ix}`,onChange:R=>{let z=g.find(G=>`${G.ix}`===R);le(z);},data:I,icon:jsx(IconDatabase,{size:16})})}else return ""},[g,E,x]);return jsxs(Stack,{className:"cms-section-options-data",gap:"xs",py:"xs",children:[jsx(LoadingOverlay,{visible:v,overlayProps:{blur:2}}),g.length===0&&!v&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:m.no_data_src}),g.length>1&&g.length===x.length&&!v&&jsx(Input.Wrapper,{label:`${m.choose_data_src}:`,children:jsx(Group,{gap:"xs",children:Q})}),E&&k&&jsx(Stack,{gap:"xs",children:jsx(Input.Wrapper,{label:`${m.preview}
16
16
  ${ee.length>l?m.rows_preview.replace("{nrows}",l):""}:`,children:jsxs(Group,{gap:"xs",children:[jsx(Select,{disabled:!(E.data.length>1),style:{flex:"1"},value:k,onChange:I=>O(I),data:E.data.map((I,R)=>({value:`${R}`,group:typeof I=="string"?m.raw_group:m.formatted_group,label:typeof I=="string"?I:m.formatted_src.replace("{src}",E.title)})),icon:typeof E.data[k]=="string"?jsx(IconLink,{}):jsx(IconSparkles,{})}),jsx(CopyButton,{value:typeof E.data[k]=="string"?E.data[k]:"",timeout:2e3,children:({copied:I,copy:R})=>jsx(Tooltip,{label:I?m.copied:m.copy,withArrow:true,position:"top",children:jsx(ActionIcon,{variant:I?"filled":"subtle",onClick:R,disabled:typeof E.data[k]!="string",children:I?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})]})})}),E&&!w&&ee.length===0&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:m.error_preview}),E&&k&&!w&&ee.length===0&&jsx("a",{href:E.data[k],target:"_blank",rel:"noreferrer",children:jsx(Button,{leftSection:jsx(IconExternalLink,{size:16}),fullWidth:true,children:m.open_in_window.replace("{src}",E.title)})}),jsxs(Stack,{pos:"relative",mih:"430px",gap:"xs",children:[jsx(LoadingOverlay,{visible:w&&g.length>0,overlayProps:{blur:2}}),E&&!w&&ee.length>0&&jsxs(Fragment,{children:[jsx(Box,{h:"350px",children:jsx(sm,{data:ee.slice(0,l)})}),jsx(Input.Wrapper,{label:`${m.download}:`,children:jsx(Button.Group,{children:Object.values(Cs).map(I=>jsx(Button,{leftSection:jsx(I.icon,{size:24}),onClick:()=>oe(I.extension),loading:F,fullWidth:true,children:I.extension},`format-${I.extension}`))})})]})]})]})}var Cs,Zi,UR,Ji=b(()=>{c();he();am();ge();mn();Tn();qi();zo();Pe();Do();$o();Cr();js();dt();Cs={csv:{extension:"CSV",icon:IconFileTypeCsv},json:{extension:"JSON",icon:IconFileTypeJs},xlsx:{extension:"XLSX",icon:IconFileTypeXls}},Zi={data_source:"Data Source",no_data_src:"No data sources defined",viz_source:"Visualization Source",error_generating:"Error generating file.",choose_data_src:"Choose data source",original_src:"Original {src}",loading:"Loading...",error_preview:`Sorry. We could not generate the data preview as a table.
17
17
  Try to open the source and check the data directly.`,open_in_window:"Open {src} response in a new window",formatted_src:"Formatted {src}",formatted_group:"Formatted Data",raw_group:"Raw Data",rows_preview:"(First {nrows} rows as preview)",choose_format:"Choose format",processing_file:"Processing file...",download:"Download data as",preview:"Preview",copy:"Click to copy",copied:"Copied!"},UR=e=>{let t=[];return e&&e.data&&(e.data&&Array.isArray(e.data)?t=e.data:e.data&&e.data.data&&Array.isArray(e.data.data)?t=e.data.data:e.data&&e.data.data&&e.data.data.results&&Array.isArray(e.data.data.results)?t=e.data.data.results:e.data&&e.data.results&&Array.isArray(e.data.results)&&(t=e.data.results)),t};});function ym(e){let{section:t}=e,o=t.blocks||[],r=K(I=>o.map(R=>({...I.records.entities.block[R],status:I.variables.status[R]})).filter(R=>R.type===h.VIZ&&R.status.allowed)),{variant_slug1:n,slug1:a}=K(I=>I.variables.attributes),s=xu(),[i,l]=useState(Et.section),[p,u]=useState(kt.png),[d,m]=useState(false),[g,f]=useState(false),[x,y]=useState([]),[E,L]=useState(r.length>0?r[0].id:null),k=i!==Et.section,{print:O,downloadLoading:F}=Tu(t.id,n,a,k?E:null),[W,A]=useState(true),[B,w]=useState(false),C=Le("options"),v={...iE,...C.image_tab},{siteProps:P}=Xo(),D=P?.logoSrc&&typeof P.logoSrc=="string",N=t?.settings?.name||`section-${t.id}`,H=`#${N}`,X=useMantineTheme(),M=()=>{let I=j(E);return select(I).select("svg").size()===1},U=()=>`${oo(N)}`,_=()=>{let I=document.getElementById(N);return select(I).select(".bespoke-section-content").node()},j=I=>{let R=_();return select(R).select(`#bespoke-visualization-${I}.bespoke-block-area`).node()},ie=()=>new Promise(I=>{let R;i===Et.section?R=_():i===Et.viz&&(R=j(E));let z=document.createElement("div");z.style.display="flex",z.style.justifyContent="space-between",z.classList.add("bespoke-share-source"),z.style.padding=X.spacing.xs,z.style.width="100%";let G=document.createElement("div");if(G.innerText=v.source.replace("{src}",`${window.location}${H}`),G.style.fontSize=X.fontSizes.xs,z.appendChild(G),D){let J=document.createElement("img");J.src=P.logoSrc,J.style.height="30px",J.onload=()=>I(R),J.onerror=()=>{J.remove(),I(R);},z.appendChild(J),R.appendChild(z);}else R.appendChild(z),I(R);}),le=I=>{if(W)return "transparent";let R=select(I).style("background-color");return R!=="rgba(0, 0, 0, 0)"&&R!=="transparent"?R:I===document.body?"white":le(I.parentNode)},q=async(I,R)=>{let{toPng:z}=await import('html-to-image');z(I,{backgroundColor:R.background,cacheBust:true,filter:G=>G&&G.classList?!R.exclusionClasses.some(J=>G.classList.contains(J)):true}).then(G=>{let J=document.createElement("a");J.download=`${R.filename}.png`,J.href=G,J.click();}).catch(G=>{console.error("Error generating image",G);}).finally(()=>{aE(),m(false);});},oe=(I,R)=>{saveElement(I,{filename:R.filename,type:"svg",callback:()=>m(false)},{background:R.background});},ee=async()=>{m(true);let I=await ie(),R={background:le(I),exclusionClasses:["export-hidden"],filename:U()},z=p===kt.png?q:oe;try{if(I)z(I,R);else throw new Error(v.wrong_node)}catch{m(false);}},Q=async()=>{let{toCanvas:I}=await import('html-to-image');Promise.all(r.map(R=>{let z=j(R.id),G=z.querySelector("g.d3plus-geomap-tileGroup");G&&(G.style.display="none");let re=select(z).select("svg").select("g").size()>0?z:lE();return I(re).then(ne=>(G&&(G.style.display="block"),ne))})).then(R=>{y(R.map(z=>z.toDataURL())),w(false);});};return useEffect(()=>{i===Et.viz&&r.length>0?(L(r[0].id),w(true),Q()):i===Et.section&&y([]);},[i]),useEffect(()=>{E&&(M()?f(true):(f(false),u(kt.png)));},[E]),jsxs(Stack,{className:"cms-section-options-image",children:[jsx(Space,{h:"xs"}),r.length>0?jsx(Input.Wrapper,{label:`${v.choose_area}:`,children:jsx(SegmentedControl,{fullWidth:true,value:i,data:[{value:Et.section,label:jsxs(Center,{children:[jsx(IconTemplate,{size:"1rem"}),jsx(Box,{ml:10,children:v.entire_section})]})},{value:Et.viz,label:jsxs(Center,{children:[jsx(IconChartBar,{size:"1rem"}),jsx(Box,{ml:10,children:v.viz_only})]})}],onChange:I=>{l(I),I===Et.section&&u(kt.png);}})}):jsx(Text,{fw:"700",color:"gray.7",children:`${v.entire_section}:`}),i===Et.viz&&r.length>0&&jsxs(Input.Wrapper,{label:`${v.choose_viz}:`,style:{minHeight:"161px",position:"relative"},children:[!B&&x.length>0&&jsx(ScrollArea,{style:{height:250},children:jsx(SimpleGrid,{cols:3,children:r.map((I,R)=>jsx(Image,{alt:`Viz ${I.id}`,onClick:()=>{L(I.id);},style:{cursor:"pointer",border:E===I.id?"4px solid #228be6":"4px solid #eee"},radius:0,src:x[R],withPlaceholder:true,styles:()=>({figure:{height:"100%"},imageWrapper:{height:"100%"}})},`viz-option-${I.id}`))})}),jsx(LoadingOverlay,{visible:B})]}),g&&i!==Et.section&&jsx(Input.Wrapper,{label:`${v.choose_format}:`,children:jsxs(Button.Group,{children:[jsx(Button,{leftSection:jsx(IconPolaroid,{size:16}),onClick:()=>u(kt.png),variant:p===kt.png?"filled":"default",fullWidth:true,children:kt.png}),jsx(Button,{leftSection:jsx(IconCode,{size:16}),onClick:()=>u(kt.svg),variant:p===kt.svg?"filled":"default",fullWidth:true,children:kt.svg})]})}),jsx(Checkbox,{checked:W,label:`${v.transparent_bg}`,onChange:()=>A(!W),radius:"xl"}),jsx(Button,{leftSection:jsx(IconDownload,{size:16}),loading:d||F,onClick:s&&p!==kt.svg?()=>O(W):ee,fullWidth:true,children:jsx("span",{children:d||F?v.processing:v.download.replace("{imageFormat}",p)})})]})}var Et,kt,aE,iE,lE,bm=b(()=>{c();Tn();he();dt();Kt();ds();ge();Et={viz:"viz",section:"section"},kt={png:"PNG",svg:"SVG"},aE=()=>{let e=document.getElementsByClassName("bespoke-share-source");Array.from(e).forEach(t=>t.remove());},iE={wrong_node:"Wrong node in export",choose_area:"Choose image area",choose_viz:"Choose visualization",choose_format:"Choose format",transparent_bg:"Transparent background",processing:"Processing image...",download:"Download {imageFormat}",entire_section:"Entire section",viz_only:"Visualization only",source:"Source: {src}"},lE=()=>document.createElement("div");});function Tm(e){let{title:t,url:o,disabled:r=false}=e,n=r?IconCode:IconLink;return jsx(Input.Wrapper,{label:t,children:jsx(Input,{icon:jsx(n,{}),value:o,disabled:r,readOnly:true,rightSection:jsx(CopyButton,{value:o,timeout:2e3,children:({copied:a,copy:s})=>jsx(Tooltip,{label:a?"Copied":"Copy",withArrow:true,position:"right",children:jsx(ActionIcon,{variant:a?"filled":"subtle",onClick:s,disabled:r,children:a?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})})})}var xm=b(()=>{c();});function Rm(e){let{section:t}=e,[o,r]=useState(""),[n,a]=useState(""),[s,i]=useState(true),l=Le("options"),p={...ME,...l.share_tab};return useEffect(()=>{a(document.title);let{origin:u,pathname:d}=window.location,m=`${u}${d}`,g=s?t.settings?.name?.length?`#${oo(t.settings.name)}`:`#section-${t.id}`:"";r(`${m}${g}`);},[s]),jsxs(Stack,{className:"cms-section-options-share",children:[jsx(Space,{h:"xs"}),jsx(Tm,{title:`${p.title}: ${n}`,url:o}),jsx(Checkbox,{checked:s,label:p.include_section,onChange:()=>i(!s),radius:"xl"}),jsxs(Group,{justify:"center",children:[jsx(FacebookShareButton,{url:o,children:jsx(FacebookIcon,{size:32,round:true})}),jsx(TwitterShareButton,{url:o,title:n,children:jsx(TwitterIcon,{size:32,round:true})}),jsx(TelegramShareButton,{url:o,title:n,children:jsx(TelegramIcon,{size:32,round:true})}),jsx(WhatsappShareButton,{url:o,title:n,separator:":: ",children:jsx(WhatsappIcon,{size:32,round:true})}),jsx(LinkedinShareButton,{url:o,children:jsx(LinkedinIcon,{size:32,round:true})}),jsx(RedditShareButton,{url:o,title:n,windowWidth:660,windowHeight:460,children:jsx(RedditIcon,{size:32,round:true})}),jsx(EmailShareButton,{url:o,subject:n,children:jsx(EmailIcon,{size:32,round:true})})]})]})}var ME,Em=b(()=>{c();xm();dt();Tn();ME={title:"Title",include_section:"Include Section"};});function wm(e){let{section:t,initialMode:o,onEnds:r,open:n,title:a}=e,s=Es(t.settings),i=useMemo(()=>VE.filter(g=>s[g]),[s]),[l,p]=useState(o||i[0]||"data"),u=Le("options");useEffect(()=>{o!==l&&p(o);},[o]);let d={...ol,...u},m=useMemo(()=>jsxs(Fragment,{children:[jsxs(Tabs.List,{children:[s.data&&jsx(Tabs.Tab,{value:"data",children:d.download_title}),s.image&&jsx(Tabs.Tab,{value:"image",children:d.image_title}),s.share&&jsx(Tabs.Tab,{value:"share",children:d.share_title})]}),s.data&&jsx(Tabs.Panel,{value:"data",children:jsx(mm,{section:t})}),s.image&&jsx(Tabs.Panel,{value:"image",children:jsx(ym,{section:t})}),s.share&&jsx(Tabs.Panel,{value:"share",children:jsx(Rm,{section:t})})]}),[s,t,d]);return jsx("div",{className:"cms-section-options-modal",children:n&&jsx(Modal,{styles:{inner:{"@media (max-width: 768px)":{padding:0}}},className:"bespoke-options-modal",opened:true,onClose:()=>r(),size:"100%",title:a,children:jsx(Tabs,{onTabChange:p,value:l,keepMounted:false,children:m})})})}var ol,VE,Am=b(()=>{c();Ji();bm();Em();dt();ks();ol={download_title:"Download Data",image_title:"Save Image",share_title:"Share Link"},VE=["data","image","share"];});function Lm(e){let{sectionId:t,disabled:o=false}=e,[r,n]=useState(false),[a,s]=useState("data"),i=Gn(t),l=Le("options"),p={...ol,...l},u=Es(i.isSuccess?i.data.settings:{}),d=g=>{s(g),n(true);},m=()=>{n(false);};return jsxs("div",{className:"cms-section-options",children:[jsxs(Button.Group,{children:[u.data&&jsx(Button,{variant:"default",size:"compact-xs",onClick:()=>d("data"),"aria-label":p.download_title,disabled:o,children:jsx(IconTable,{size:16})}),u.image&&jsx(Button,{variant:"default",size:"compact-xs",onClick:()=>d("image"),"aria-label":p.image_title,disabled:o,children:jsx(IconCamera,{size:16})}),u.share&&jsx(Button,{variant:"default",size:"compact-xs",onClick:()=>d("share"),"aria-label":p.share_title,disabled:o,children:jsx(IconShare,{size:16})})]}),i.isSuccess&&jsx(wm,{section:i.data,initialMode:a,open:r,onEnds:m})]})}var _m=b(()=>{c();Am();he();dt();ks();});function HE({children:e,containerProps:t},o){return jsx(Flex,{ref:o,className:"bespoke-section-content",pos:"relative",align:"stretch",p:0,direction:{base:"column",md:"row"},wrap:"wrap",...t,children:e})}var Is,Mm,Fm=b(()=>{c();he();Ya();Is=Ro__default.forwardRef(function({children:t,column:o,basis:r,columnSettings:n={},sx:a={},...s},i){let l=Object.values(o).some(m=>m.settings?.display==="inline"),p=n?.width?`${n.width}px`:r,u=n?.width?`${n?.width}px`:"100%",d=n?.full?"100%":u;return jsx(Flex,{ref:i,className:"bespoke-section-col",align:"flex-start",direction:l?"row":"column",wrap:l?"wrap":"nowrap",maw:{base:"100%",md:d},miw:{base:"none",md:300},p:0,pos:"relative",sx:[{flexGrow:1,flexShrink:n?.full?0:1,flexBasis:n?.full?"100%":p},...Array.isArray(a)?a:a?[a]:[]],...s,children:t})}),Mm=Ro__default.forwardRef(HE);});var Dm=b(()=>{c();});var Rn,Vm=b(()=>{c();je();he();Dm();ge();Rn={px:e=>Number.isNaN(parseFloat(e))?"px":`${e}px`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),"%":e=>Number.isNaN(parseFloat(e))?"%":`${e}%`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")},{px:{defaultValue:400,min:25,step:5,formatter:Rn.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:Rn["%"]}};});var rl,zm=b(()=>{c();rl={backgroundColor:"#fafafa",block:{padding:10},column:{padding:12},section:{backgroundColor:"white",borderRadius:10,boxShadow:"0px 6px 10px rgba(12, 32, 50, 0.14), 0px 1px 15px rgba(12, 32, 50, 0.12), 0px 3px 5px rgba(12, 32, 50, 0.15)",margin:8,padding:32}};});function sl({previews:e,translations:t}){let{print:o}=Qe(),r=useMemo(()=>e.map(({image:n,name:a},s)=>(n?.author||n?.url)&&jsxs(Stack,{gap:0,children:[n.author&&jsxs(Text,{size:"xs",children:[a," ",t.image_by," ",jsx("strong",{children:n.author})]}),n.url&&jsxs(Text,{size:"xs",children:["URL: "," ",jsx(Anchor,{href:n.url,target:"_blank",children:n.url})]}),s+1<e.length&&jsx(Divider,{})]},n.id)),[e]);return jsx(Fragment,{children:o?jsx(Fragment,{children:r}):jsxs(Popover,{position:"right",children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"light",radius:"xl",children:jsx(IconPhoto,{size:20})})}),jsx(Popover.Dropdown,{children:r})]})})}var Gm=b(()=>{c();Zt();});function Hm(){let{locales:e}=useRouter(),t=location&&location.pathname.split("/").filter(o=>o.length>0)[0];return e?.includes(t)}var qm=b(()=>{c();});function sk({name:e,children:t,id:o,sectionSettings:r,sectionStyles:n,previews:a,translations:s}){let{print:i}=Qe(),l=r.memberImageBg&&a.some(({image:u})=>u&&(u.url||u.author)),p=useMemo(()=>r.showAnchor&&r.optionsMenu?"space-between":!r.showAnchor&&r.optionsMenu?"flex-end":r.showAnchor&&!r.optionsMenu?"flex-start":"flex-end",[r.showAnchor,r.optionsMenu]);return jsxs(ok,{className:`bespoke-Section-${o} bespoke-Section-root `,settings:r,bespokeStyles:n?.root||void 0,print:i,children:[r.memberImageBg&&jsx(om,{previews:a}),jsxs(rk,{className:`bespoke-Section-${o} bespoke-Section-container `,settings:r,bespokeStyles:n?.container,id:e?.length?oo(e):`section-${o}`,pos:"relative",children:[!i&&jsxs(Group,{justify:p,mb:"xs",children:[r.showAnchor&&jsxs(Anchor,{className:"cms-section-anchor",href:`#${r.name?oo(r.name):"section-"+o}`,sx:{"&:hover .cms-section-name":{visibility:"visible",opacity:1}},children:[jsx(Text,{span:true,size:"small",children:"#"}),jsx(Text,{span:true,size:"small",className:"cms-section-name",sx:{visibility:"hidden",opacity:0,transition:"visibility 0s, opacity 0.2s ease-in-out"},children:r.name||"section-"+o})]}),r.optionsMenu&&jsx(Lm,{sectionId:o,disabled:false})]}),jsxs(nk,{print:i,className:`bespoke-Section-${o} bespoke-Section-container`,settings:r,bespokeStyles:n?.content,children:[t,l&&jsx(sl,{previews:a,translations:s})]})]})]})}function ik({section:e,sectionLoader:t,print:o}){let{id:r,settings:n}=e,a={...tm,...n},{isEmbed:s}=Qe(),i=nt(),l=mt("Section"),p=Le("sections"),u=K(ut),d=K(A=>A.variables.status),{previews:m,isRunConsumersRunning:g}=K(A=>A.status,Xe),f={...tk,...p},x=i.active&&i.status?m.concat(i.status?.previews||[]):m,y=Object.values(u||{}).filter(A=>A.section_id===r),E=y.some(A=>{try{return d[A.id].allowed&&![h.GENERATOR,h.SECTION_FLAG].includes(A.type)||A.type===h.NAV}catch{return A.settings.allowed==="always"}}),L=y.filter(A=>![h.GENERATOR,h.SECTION_FLAG].includes(A.type)).reduce((A,B)=>(A[B.blockcol]?A[B.blockcol][B.blockrow]=B:A[B.blockcol]={[B.blockrow]:B},A),{}),k=Object.keys(y).length>0&&!n.hidden&&E;o&&(k=k&&!n.pdfHidden);let O=Object.keys(L).length;if(!k||i.active&&n.comparisonHide)return null;let F=(A,B=false)=>{let w=Array.from(new Set(A.map(v=>v.blockcol))).map(v=>({blockcol:v})).sort((v,P)=>et(v,P,"blockcol")),C=[];return w.forEach(({blockcol:v})=>{let P=A.filter(D=>D.blockcol===v).sort((D,N)=>et(D,N,"blockrow")).map(D=>{if(!D.id||!d[D.id]?.allowed&&D.type!==h.NAV)return null;let{settings:N,type:H}=u[D.id],X=N.width&&!N.width.stretch&&N.width.unit?Rn[N.width.unit](N.width.value):N.display==="inline"?"auto":"100%",M={alignSelf:H===h.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:X,minWidth:300};return jsx(Box,{className:"bespoke-Block-wrapper",id:`bespoke-Block-${D.id}`,sx:M,py:rl.block.padding,children:jsx(Rs,{blockId:D.id,asComparison:B},D.id)},D.id)});C.push(P);}),C.flat()},W=[];if(i.active&&!n.comparisonMerge){let A=y.filter(B=>![h.GENERATOR,h.SECTION_FLAG].includes(B.type)).reduce((B,w)=>({...B,[w.id]:w}),{});W=[jsx(Is,{column:A,basis:"50%",children:F(Object.values(y.filter(B=>![h.GENERATOR,h.SECTION_FLAG].includes(B.type))))},"original"),jsx(Is,{column:A,basis:"50%",children:F(Object.values(y.filter(B=>![h.GENERATOR,h.SECTION_FLAG].includes(B.type))),true)},"comparison")];}else W=Object.keys(L).sort((A,B)=>-Ns(A,B)).map(A=>{let B=L[A],w=n.columnSettings?n.columnSettings[A]:{},C=Object.values(B).sort((v,P)=>et(v,P,"blockrow"));return C.some(v=>!d[v.id]||d[v.id].allowed||v.type===h.NAV)?jsx(Is,{column:B,columnSettings:w,basis:`calc(${100/O}% - (10px * ${O}))`,children:C.map(v=>{if(!v.id||!d[v.id]?.allowed&&v.type!==h.NAV)return null;let{settings:P,type:D}=u[v.id],N=P.width&&!P.width.stretch&&P.width.unit?Rn[P.width.unit](P.width.value):P.display==="inline"?"auto":"100%",H={alignSelf:D===h.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:N,minWidth:300};return jsx(Box,{className:`bespoke-Block-wrapper bespoke-${v.type}-wrapper`,id:`bespoke-Block-${v.id}`,sx:H,py:rl.block.padding,children:jsx(Rs,{blockId:v.id},v.id)},v.id)})},A):null});return jsxs(sk,{id:r,name:e?.settings?.name,previews:x,sectionSettings:a,sectionStyles:l,translations:f,children:[g.includes(r)&&t,jsx(Mm,{containerProps:{gap:a.columnGutter||"md",wrap:i.active?"nowrap":"wrap",sx:{zIndex:20}},children:W}),s&&jsx(ak,{})]})}var tk,al,ok,rk,nk,ak,Qm,Zm=b(()=>{c();he();Nt();Jd();ks();cr();rm();_m();vo();ge();Fm();Vm();zm();Zt();dt();Gm();eo();Tn();Kt();qm();br();tk={image_by:"image by"},al=(e,t)=>o=>e?e(o,t):{},ok=({settings:e,bespokeStyles:t,print:o,children:r,...n})=>{let{position:a,shouldBreak:s}=e,i={normal:{position:"relative",backgroundColor:o?"transparent":"initial",borderRadius:0},sticky:{position:"sticky",zIndex:2,top:0,borderRadius:0,borderTop:o?"none":"initial",borderLeft:o?"none":"initial",borderRight:o?"none":"initial"}};return jsx(Paper,{component:"section",sx:u=>({...i[a],...al(t,e)(u),pageBreakBefore:s?"always":void 0}),...{normal:{radius:0},sticky:{radius:0,withBorder:true}}[a],...n,children:r})},rk=({settings:e,bespokeStyles:t,children:o,...r})=>{let{width:n}=e,a={center:{zIndex:1},full:{zIndex:1}};return jsx(Container,{sx:l=>({...a[n],...al(t,e)(l)}),...{center:{size:"lg",p:"sm",fluid:false},full:{fluid:true,p:"md"}}[n],...r,children:o})},nk=({settings:e,bespokeStyles:t,print:o,children:r,...n})=>{let{style:a}=e,s={none:{},card:{boxShadow:o?"none":"initial"}};return jsx(Paper,{sx:p=>({...s[a],...al(t,e)(p)}),...{none:{bg:"transparent"},card:{shadow:o?"none":"lg",p:"md",radius:"md"}}[a],...n,"data-screenshot-target":"true",children:r})};ak=()=>{let e=useRouter(),{query:t,locale:o}=e,{siteProps:r={logoSrc:""},profilePrefix:n,pathSegment:a}=Xo(),s=t[a],i=Array.isArray(s)?s.join("/"):[],p=Hm()?`/${o}`:"";p+=`${n}/${i}/`;let u=new URL(p,window.location.href).href;return jsxs(Group,{justify:"space-between",wrap:"nowrap",sx:{flexGrow:1},children:[jsx(Anchor,{href:u,target:"_blank",children:u}),jsx("img",{src:r.logoSrc,height:40,width:"auto",alt:"Site Logo"})]})};Qm=ik;});var Jm=b(()=>{c();ae();Y({name:"abbreviate",description:"Abbreviates a number into a smaller more human-readable number.",logicFactory(e){return t=>e.d3plus.formatAbbreviate(t)},inputType:"number",testValue:"123456",type:"formatter"});});var ef=b(()=>{c();ae();Y({name:"abs",description:"Simple Absolute Value.",logicFactory(){return e=>Math.abs(e)},inputType:"number",testValue:"-123",type:"formatter"});});var pk,tf=b(()=>{c();ae();pk=()=>function(t){let r=new RegExp(/([\$0-9\,]+)[A-z\-\s\&]*([\$0-9\,]*)/g).exec(t);return r?(r=r.slice(1).filter(n=>n.length).map(n=>(n.includes(",")&&(n.indexOf(",")===n.length-4?n=n.replace(/,000$/g,"k").replace(/([0-9]+)(,999$)/g,a=>`${parseInt(a)+1}k`):n.indexOf(",")===n.length-8&&(n=n.replace(/,000,000$/g,"M").replace(/([0-9]+)(,999,999$)/g,a=>`${parseInt(a)+1}M`))),n)),r.length===2?r.join(" - "):t.toLowerCase().match(/under|less|</g)?`< ${r[0]}`:t.toLowerCase().match(/over|more|\+|>/g)?`${r[0]}+`:`${r[0]}`):"None"},Y({name:"bucket",description:"Sanitizes bucket strings to '< n', 'n1 - n2', and 'n+'",logicFactory:pk,inputType:"number",testValue:"1234",type:"formatter"});});var of=b(()=>{c();ae();Y({name:"commas",description:"* Rounds to nearest whole number and adds commas.",logicFactory(e){return t=>e.d3.format(",")(Math.round(t))},inputType:"number",testValue:"1234.6",type:"formatter"});});var rf=b(()=>{c();ae();Y({name:"date",description:"Formats a date into '%B %d, %Y' format.",logicFactory(e){return t=>(typeof t=="string"&&(t=e.d3plus.date(t)),e.d3.timeFormat("%B %d, %Y")(t))},inputType:"date",testValue:"2022-01-01",type:"formatter"});});var nf=b(()=>{c();ae();Y({name:"dollar",description:"Adds a US dollar sign to the beginning of a String or Number.",logicFactory(e){return t=>(typeof t=="number"&&(t=e.d3plus.formatAbbreviate(t)),t.charAt(0)==="-"?t.replace("-","-$"):`$${t}`)},inputType:"number",testValue:"123",type:"formatter"});});var sf=b(()=>{c();ae();Y({name:"formatFieldName",description:"Based on field name returns a string",logicFactory(){return e=>{if(e.contentType.toLowerCase()==="stat"){if(e.field==="title")return "Stat label";if(e.field==="value")return "Stat value";if(e.field==="subtitle")return "Stat subtitle";if(e.field==="tooltip")return "Tooltip text"}return e.contentType.toLowerCase()==="section"&&e.field==="short"?"Short title":e.contentType.toLowerCase()==="description"&&e.field==="description"?"Paragraph":e.field}},inputType:"object",testValue:'{"field":"title","contentType":"stat"}',type:"formatter"});});var af=b(()=>{c();ae();Y({name:"grewTo",description:"Returns the text with grow direction: 'declined from', 'grew to' o 'stayed at'",logicFactory(){return e=>e<0?"declined from":e>0?"grew to":"stayed at"},inputType:"number",testValue:"-1234",type:"formatter"});});var lf=b(()=>{c();ae();Y({name:"grewWord",description:"Returns either 'grew', 'declined', or 'stayed' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declined":e>0?"grew":"stayed"},inputType:"number",testValue:"-1234",type:"formatter"});});var cf=b(()=>{c();ae();Y({name:"growing",description:"Returns either 'declining', 'growing' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declining":"growing"},inputType:"number",testValue:"-1234",type:"formatter"});});var Sk,pf=b(()=>{c();ae();Sk=()=>function(t){let{curr:o,currMoe:r=0,prev:n,prevMoe:a=0}=t,s;if(r||a){let i=(-n/o**2)**2*r**2,l=(1/o)**2*a**2;s=Math.sqrt(i+l);}else s=(o-n)/n;return s*100},Y({name:"growth",description:"Calculates the growth percentage between two numbers provided the following object format: {curr, prev}. Also supports calculating the growth between two margin of errors using this format: {curr, currMoe, prev, prevMoe}",logicFactory:Sk,inputType:"object",testValue:'{"curr":10,"currMoe":0,"prev":13,"prevMoe":0}',type:"formatter"});});var uf=b(()=>{c();ae();Y({name:"growthPct",description:"Abbreviates a growth value, turns it absolute, and adds a percent sign.",logicFactory(e){return t=>`${e.d3plus.formatAbbreviate(Math.abs(t))}%`},inputType:"number",testValue:"12345",type:"formatter"});});var df=b(()=>{c();ae();Y({name:"growthWord",description:"Returns either 'growth' or 'decline' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decline":"growth"},inputType:"number",testValue:"-1234",type:"formatter"});});var mf=b(()=>{c();ae();Y({name:"highWord",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign.",logicFactory(){return e=>e<0?"lower than":e>0?"higher than":"approximately the same as"},inputType:"number",testValue:"0",type:"formatter"});});var ff=b(()=>{c();ae();Y({name:"increaseWord",description:"Returns either 'increase', 'decrease', or 'change' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decrease":e>0?"increase":"change"},inputType:"number",testValue:"1234",type:"formatter"});});var gf=b(()=>{c();ae();Y({name:"increasedWord",description:"Returns either 'increased', 'decreased', or 'remained the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreased":e>0?"increased":"remained the same"},inputType:"number",testValue:"0",type:"formatter"});});var hf=b(()=>{c();ae();Y({name:"increasing",description:"Returns either 'decreasing', 'increasing' or 'maintaining' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreasing":e>0?"increasing":"maintaining"},inputType:"number",testValue:"-1234",type:"formatter"});});var yf=b(()=>{c();ae();Y({name:"largerThan",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign",logicFactory(){return e=>e<0?"smaller than":e>0?"larger than":"the same as"},inputType:"number",testValue:"-1234",type:"formatter"});});var bf=b(()=>{c();ae();Y({name:"list",description:"Joins an array of strings together, adding commas and 'and' when necessary.",logicFactory(){return e=>e.reduce((t,o,r)=>(r?r===e.length-1&&r===1?t+=` and ${o}`:r===e.length-1?t+=`, and ${o}`:t+=`, ${o}`:t+=o,t),"")},inputType:"object",testValue:'["foo","bar","bee"]',type:"formatter"});});var Sf=b(()=>{c();ae();Y({name:"longWord",description:"",logicFactory(){return e=>e<0?"shorter":e>0?"longer":"similar"},inputType:"number",testValue:"5",type:"formatter"});});var Tf=b(()=>{c();ae();Y({name:"lowerCaseFirst",description:"Converts the first letter of a string to lowercase",logicFactory(){return e=>typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e},inputType:"string",testValue:"foo",type:"formatter"});});var xf=b(()=>{c();ae();Y({name:"moreFewerWord",description:"",logicFactory(){return e=>e<0?"fewer":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var vf=b(()=>{c();ae();Y({name:"moreLess",description:"Returns either 'more' or 'less' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var Rf=b(()=>{c();ae();Y({name:"moreLess",description:"Returns either 'more than', 'less than', or 'approximately the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less than":e>0?"more than":"approximately the same"},inputType:"number",testValue:"-5",type:"formatter"});});var Ef=b(()=>{c();ae();Y({name:"olderWord",description:"",logicFactory(){return e=>e<0?"getting younger":e>0?"getting older":"staying the same age"},inputType:"number",testValue:"-5",type:"formatter"});});var kf=b(()=>{c();ae();Y({name:"olderYounger",description:"",logicFactory(){return e=>e<0?"younger than":e>0?"older than":"the same age as"},inputType:"number",testValue:"-5",type:"formatter"});});var Cf=b(()=>{c();ae();Y({name:"plural",description:"Pluralizes a word.",logicFactory(){return e=>e.replace(/\w$/g,t=>t==="y"?"ies":`${t}s`)},inputType:"string",testValue:"Foo",type:"formatter"});});var wf=b(()=>{c();ae();Y({name:"pxToInt",description:"Takes a pixel value and converts it to an integer",logicFactory(){return e=>parseInt(e.replace(/\D+/g,""),10)},inputType:"string",testValue:"12px",type:"formatter"});});var Af=b(()=>{c();ae();Y({name:"salary",description:"Displays salary values with proper precision (ie. '$74,200' instead of '$74.2k')",logicFactory(e){return t=>{let o;return t<1e6?o=e.d3.format(",")(t.toFixed(0)):o=e.d3plus.formatAbbreviate(t),`$${o}`}},inputType:"number",testValue:"1000000",type:"formatter"});});var Pf=b(()=>{c();ae();Y({name:"stripEntities",description:"Removes non breaking spaces & other html entities from a string",logicFactory(){return e=>typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e},inputType:"string",testValue:"<b>MyText</b>",type:"formatter"});});var il,If=b(()=>{c();ae();il=Y({name:"stripHTML",description:"Converts html tags to spaces, then removes redundant spaces",logicFactory(){return e=>{let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(a)?a.replace(n,s=>t[s]):a}},inputType:"string",testValue:"<b>My text</b>",type:"formatter"});});var Lf=b(()=>{c();ae();Y({name:"stripOL",description:"Removes ordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ol>/g,"").replace(/<\/ol>/g,"")},inputType:"string",testValue:"<ol><li>My list</li></ol>",type:"formatter"});});var _f=b(()=>{c();ae();Y({name:"stripP",description:"Removes all paragraph tags from a string.",logicFactory(){return e=>e.replace(/<p>/g,"").replace(/<\/p>/g,"")},inputType:"string",testValue:"<p>My p</p>",type:"formatter"});});var Bf=b(()=>{c();ae();Y({name:"stripUL",description:"Removes unordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ul>/g,"").replace(/<\/ul>/g,"")},inputType:"string",testValue:"<ul><li>My list</li></ul>",type:"formatter"});});var Of=b(()=>{c();ae();Y({name:"toKebabCase",description:"Takes a camelCase or PascalCase string and converts it to kebab-case.",logicFactory(){return e=>typeof e=="string"?(e=e.charAt(0).toLowerCase()+e.substring(1),e.replace(/([A-Z])/g,"-$1").toLowerCase()):"invalid string passed to toKebabCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var Mf=b(()=>{c();ae();Y({name:"toSpacedCase",description:"Takes a camelCase or PascalCase string and adds spaces (I know Spaced Case isn't a thing, deal with it).",logicFactory(){return e=>typeof e=="string"?e.replace(/([A-Z])/g," $1").toLowerCase().trim():"invalid string passed to toSpacedCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var Nf=b(()=>{c();ae();Y({name:"upperCaseFirst",description:"Converts the first letter of a string to uppercase",logicFactory(){return e=>e.charAt(0).toUpperCase()+e.slice(1)},inputType:"string",testValue:"my name",type:"formatter"});});var Ff=b(()=>{c();Jm();ef();tf();of();rf();nf();sf();af();lf();cf();pf();uf();df();mf();ff();gf();hf();yf();bf();Sf();Tf();xf();vf();Rf();Ef();kf();Cf();wf();Af();Pf();If();Lf();_f();Bf();Of();Mf();Nf();});function $f({onDownloadPDF:e,onDownloadCSV:t}){let[o,r]=useState(false),[n,a]=useState(false),[s,i]=useState(false),l=useMediaQuery("(max-width: 768px)"),p=Le("export"),u={...Jk,...p},d=async()=>{if(e){r(true);try{await e();}finally{r(false),i(false);}}},m=async()=>{if(t){a(true);try{await t();}finally{a(false),i(false);}}},g=(y,E,L,k,O,F)=>jsx(Button,{id:F,size:"sm",onClick:y,disabled:E,fullWidth:true,variant:"subtle",h:"auto",px:"xs",w:"100%",styles:()=>({inner:{width:"100%",display:"block"}}),children:jsxs(Group,{wrap:"nowrap",justify:"flex-start",gap:"xs",w:"100%",children:[E?jsx(Loader,{size:"1.75rem"}):L,jsxs(Stack,{gap:0,w:"100%",py:"0.5rem",className:"bespoke-report-download-btn-text-container",children:[jsx(Text,{w:"100%",size:"sm",lineClamp:1,className:"bespoke-report-download-btn-text-container-cta",children:k}),O&&jsx(Text,{size:"xs",w:"100%",lineClamp:2,maw:"100%",style:{wordWrap:"break-word",whiteSpace:"normal"},variant:"dimmed",lh:"0.9rem",h:"1.9rem",className:"bespoke-report-download-btn-text-desc",children:O})]})]})}),f=e&&g(d,o,jsx(IconFileTypePdf,{size:"1.75rem"}),u.pdf.label,u.pdf.desc,"bespoke-download-pdf-btn"),x=t&&g(m,n,jsx(IconFileTypeXls,{size:"1.75rem"}),u.xlsx.label,u.xlsx.desc,"bespoke-download-xlsx-btn");return e||t?jsx(Affix,{position:{bottom:l?rem(0):rem(20),right:l?rem(0):rem(20)},id:"bespoke-report-download-affix",style:{width:l?"100%":"auto",boxShadow:l?"0px -2px 6px rgba(0, 0, 0, 0.1)":"0px 2px 6px rgba(0, 0, 0, 0.1)",borderRadius:"0.25rem",background:"white"},p:"xs",children:jsxs(Popover,{opened:s,onChange:i,position:"top",shadow:"md",width:l?"100%":250,id:"bespoke-report-download-popover",children:[jsx(Popover.Target,{children:jsx(Button,{id:"bespoke-report-download-btn",size:"sm",onClick:()=>i(y=>!y),leftSection:jsx(IconDownload,{size:"1.2rem"}),variant:"subtle",loading:o||n,fullWidth:l,children:u.export})}),jsx(Popover.Dropdown,{p:"0.5rem",children:jsxs(Stack,{gap:"xs",children:[f,x]})})]})}):null}var Jk,Uf=b(()=>{"use client";c();dt();Jk={export:"Export",pdf:{label:"Download PDF",desc:"Generates a printable version of the report page in PDF format."},xlsx:{label:"Download XLSX",desc:"Creates a downloadable spreadsheet of the report page data."}};});function rC(e,t){let o=e.replace(/[:\\/?*[\]]/g,"");return o.trim().length===0&&(o=`Sheet${t+1}`),o.slice(0,31)}function nC(e){let t=new ArrayBuffer(e.length),o=new Uint8Array(t);for(let r=0;r<e.length;r++)o[r]=e.charCodeAt(r)&255;return t}function Gf(){let e=window.document.querySelector("title")?.textContent;return e||`data_export_${new Date().toISOString()}`}var oC,sC,Hf,qf=b(()=>{c();oC=e=>new Promise((t,o)=>{if(!e||e.length===0){o(new Error("No data provided"));return}try{let r=zr.utils.book_new();e.forEach((i,l)=>{if(i.data&&i.data.length>0){let p=i.data[0],u=zr.utils.json_to_sheet(p),d=rC(i.fileName||`Sheet${l+1}`,l),m=1;for(;r.SheetNames.includes(d);){let g=` (${m})`;d=`${d.slice(0,31-g.length)}${g}`,m++;}zr.utils.book_append_sheet(r,u,d);}});let n=zr.write(r,{bookType:"xlsx",type:"binary"}),a=new Blob([nC(n)],{type:"application/octet-stream"}),s=new AR;s.file(`${Gf()}.xlsx`,a),s.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(i=>{t(i);}).catch(o);}catch(r){o(r);}});sC=async e=>{try{let t=await oC(e);saveAs(t,`${Gf()}.zip`);}catch(t){console.error("Error generating file:",t);}},Hf=sC;});function Qe(){let e=useContext(Yf);if(e===void 0)throw new Error("usePrint must be used within a PrintContext");return e}function gC(e){return useMemo(()=>e.data.reduce((o,r)=>(r.blocks&&r.blocks.forEach(n=>{o[n]=r.id;}),o),{}),[e.data])}function hC({pathSegmentsKey:e="bespoke",sectionLoader:t,mode:o}){let{query:r}=useRouter(),n=en(),a=nt(),s=pn(),i=Mg(r.print)??false,l=o==="embed",{printReport:p,error:u,setError:d}=us();is();let m=jf.locale,g=Ot(m),f=useMemo(()=>n.data?.sort(et).filter(P=>P.settings?.hidden!==true).filter(P=>P.settings?.pdfHidden!==true).reduce((P,D)=>(D.blocks&&D.blocks.length>0&&P.push(...D.blocks),P),[])??[],[n.data]),x=gC({data:n.data||[]}),{sectionsVariables:y,resetSectionVariables:E,setSectionVariables:L}=Ec(n.data?.map(P=>P.id)||[]),k=K(ut,go),O=K(P=>P.variables,Xe),F=Le("options"),W={...Zi,...F.data_tab},A=useMemo(()=>f.reduce((P,D)=>{let N=k[D],H=O.status[D];return h.VIZ===N?.type&&H.allowed&&P.push({id:D,entity:N,variables:O.variables[D],status:O.status[D],inputVariablesFlat:N.inputs.reduce((X,M)=>({...X,...O.variables[M]}),O.attributes)}),P},[]),[f,k,O.attributes,O.status,O.variables]);function B(P){return P=P.replace(/<p>/g,""),P=P.replace(/<\/p>/g,""),P}let w=async(P,D,N)=>{let H=dataLoad.bind({});return new Promise((X,M)=>{H(D,null,null,(U,_)=>{if(U)M(U);else try{P||(P={data:[]}),Array.isArray(P.data)||(P.data=[]);let j=N instanceof Function?N(_):_;P.data.unshift(j),P.rawData=_,X(P);}catch(j){M(j);}});})},C=yo(),v=async()=>{if(!s.XlsxVizActive)return;let P=[],D=[],N=0,H=1;for(let U of A){let _=U.entity,j=qe(_),ie=U.inputVariablesFlat,le={variables:ie},q=pt({logic:j.logic},g,le).logic,oe={router:jf,section:{variables:y[x[_.id]],setVariables:L(y[x[_.id]]),resetVariables:E(y[x[_.id]])}},ee=ko(q,g,ie,m,_.id,{},oe,C),Q=ee.config._downloadTitle||ee.config.title||`${W.viz_source} ${N+1}`,I=ee.config._downloadFileName||Q;if(ee.config._downloadEnabled!==false){let R=ee.config._downloadUrl||ee.config.data;if(!R){console.error("API is undefined for block:",_.id);continue}let z=typeof R=="string"?[R]:R,G=ee.dataFormat instanceof Function?ee.dataFormat:false,J=ee.config._downloadDataFormat instanceof Function?ee.config._downloadDataFormat:false,re=ee.config._downloadSectionName,ne=ee.config._downloadSource;try{let we=await w({ix:N,id:_.id,title:il(Q),fileName:ne?re?`${H} ${B(re)}`:`${H} ${I}`:re?B(re):I,data:z,loading:!1,type:h.VIZ},R,J||G);if(ne){let Re=Array.isArray(we.rawData)?we.rawData:[we.rawData],_e=new Set;Re.forEach((Ae,Ye)=>{let Ne=ne(Ae),qt=Ne.name.trim().split(`
18
18
  `),Lo=Ne.description.trim().split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.5",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {