@datawheel/bespoke 0.6.0-rc.8 → 0.7.0-rc.0

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.
Files changed (3) hide show
  1. package/dist/index.js +745 -595
  2. package/dist/server.js +266 -312
  3. package/package.json +2 -3
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Group, Stack, Text, useMantineTheme, List, Modal, Button, Input, MantineProvider, Box, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Flex, packSx, Menu, Card, Center, Space, Badge, Title, Tabs, TextInput, Code, Loader, Divider, SegmentedControl, Select, ActionIcon, Textarea, Paper, Alert, Container, Grid, Tooltip, createStyles, MultiSelect, Anchor, Checkbox, MediaQuery, Affix, rem, Popover, Radio, Switch, Drawer, Overlay, NumberInput, Autocomplete, Notification, Image, Accordion, Header, px, FileInput, SimpleGrid, Burger, Collapse, CopyButton, HoverCard, Breadcrumbs, Col } from '@mantine/core';
1
+ import { Group, Stack, Text, useMantineTheme, List, Modal, Button, Input, MantineProvider, Box, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Flex, packSx, Menu, Card, Center, Space, Badge, Title, Tabs, TextInput, Code, NumberInput, Loader, Divider, SegmentedControl, Select, ActionIcon, Textarea, Paper, Alert, Container, Grid, Tooltip, createStyles, MultiSelect, Anchor, Checkbox, MediaQuery, Affix, rem, Popover, Radio, Switch, Drawer, Overlay, Autocomplete, Notification, Image, Accordion, Header, px, Pagination, FileInput, SimpleGrid, Burger, Collapse, CopyButton, HoverCard, Breadcrumbs, Col } from '@mantine/core';
2
2
  import React, { forwardRef, useState, useCallback, useRef, useEffect, createContext, useContext, useMemo, Fragment as Fragment$1, createElement, memo, useImperativeHandle } from 'react';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import axios from 'axios';
@@ -20,8 +20,8 @@ import { createSlice, configureStore } from '@reduxjs/toolkit';
20
20
  import { HYDRATE, createWrapper } from 'next-redux-wrapper';
21
21
  import { Notifications, notifications } from '@mantine/notifications';
22
22
  import { useDispatch, useSelector } from 'react-redux';
23
+ import { useDebouncedValue, useClickOutside, useDisclosure, useSetState, useUncontrolled, useHotkeys, useListState, randomId, getHotkeyHandler, useMediaQuery, useMergedRef, useFullscreen } from '@mantine/hooks';
23
24
  import Router, { useRouter } from 'next/router';
24
- import { useClickOutside, useDisclosure, useDebouncedValue, useSetState, useUncontrolled, useHotkeys, useListState, randomId, getHotkeyHandler, useMediaQuery, useMergedRef, useFullscreen } from '@mantine/hooks';
25
25
  import { IconDice, IconBoxMultiple, IconEyeOff, IconChevronDown, IconBallpen, IconDatabase, IconMathFunction, IconUsers, IconLogout, IconHeading, IconApi, IconPercentage, IconChartBar, IconAlignLeft, IconSelector, IconPhoto, IconTable, IconUserCircle, IconEdit, IconServer, IconPencil, IconAlertCircle, IconCircleCheck, IconPlayerPlay, IconTrash, IconCircleX, IconPlus, IconFileAnalytics, IconHome, IconSearch, IconX, IconRefresh, IconDownload, IconCircleDashed, IconLanguage, IconSettingsFilled, IconEye, IconWorldUpload, IconBraces, IconClockHour2, IconAugmentedReality, IconGitMerge, IconGripHorizontal, IconChevronLeft, IconChevronRight, IconListCheck, IconPolaroid, IconCircleMinus, IconInfoCircle, IconGripVertical, IconCamera, IconShare, IconQuestionMark, IconCirclePlus, IconLogin, IconWorld, IconLock, IconCopy, IconBinaryTree, IconVariable, IconArrowRightCircle, IconPhotoFilled, IconFileUpload, IconIndentIncrease, IconCodeDots, IconUpload, IconCheck, IconCodePlus, IconLink, IconSparkles, IconClipboardCheck, IconClipboardCopy, IconExternalLink, IconFileTypeCsv, IconFileTypeJs, IconFileTypeXls, IconTemplate, IconCode, IconPalette, IconBold, IconItalic, IconUnderline, IconAlignCenter, IconAlignRight, IconAlignJustified, IconArrowBackUp, IconArrowForwardUp, IconLanguageOff, IconTriangleInvertedFilled, IconDeviceFloppy, IconSettings, IconMinimize, IconMaximize, IconGlobe, IconLinkOff } from '@tabler/icons-react';
26
26
  import Link from 'next/link';
27
27
  import parse2, { Element as Element$1, domToReact, Text as Text$1 } from 'html-react-parser';
@@ -51,6 +51,7 @@ import slugifyFn from 'slugify';
51
51
  import JSZip from 'jszip';
52
52
  import { saveAs } from 'file-saver';
53
53
  import { select } from 'd3-selection';
54
+ import { saveElement } from 'd3plus-export';
54
55
  import { FacebookShareButton, FacebookIcon, TwitterShareButton, TwitterIcon, TelegramShareButton, TelegramIcon, WhatsappShareButton, WhatsappIcon, LinkedinShareButton, LinkedinIcon, RedditShareButton, RedditIcon, EmailShareButton, EmailIcon } from 'react-share';
55
56
  import Head from 'next/head';
56
57
  import Editor, { useMonaco } from '@monaco-editor/react';
@@ -160,111 +161,10 @@ var init_Dialog = __esm({
160
161
  DialogContext = React.createContext(void 0);
161
162
  }
162
163
  });
163
- function ExploreFilters({ metadata, onFilter, initialReportId, initialVariantId, translations }) {
164
- const [showSelectors, setShowSelectors] = useState(false);
165
- const [selectors, setSelectors] = useState([]);
166
- const [filters, setFilters] = useState({ profile: void 0, variant: void 0 });
167
- const [selectedProfile, setSelectedProfile] = useState();
168
- const [selectedVariant, setSelectedVariant] = useState();
169
- const allMember = { id: void 0, name: translations["filters_all"] };
170
- const getVariantsCombinatory = (variantsArrays) => {
171
- const combinatory = variantsArrays.reduce((a2, b2) => a2.reduce((r2, v2) => r2.concat(b2.map((w2) => [].concat(v2, w2))), [])).map((combination) => {
172
- if (!Array.isArray(combination))
173
- return combination;
174
- return {
175
- id: combination.map((c2) => c2.id).join(","),
176
- name: combination.map((c2) => c2.name).join(" / ")
177
- };
178
- });
179
- return [allMember, ...combinatory];
180
- };
181
- const onClickProfile = (profile) => {
182
- if (profile !== selectedProfile) {
183
- setSelectedProfile(profile);
184
- setSelectedVariant(allMember);
185
- }
186
- };
187
- const onClickVariant = (variant) => {
188
- if (variant !== selectedVariant) {
189
- setSelectedVariant(variant);
190
- }
191
- };
192
- useEffect(() => {
193
- const newFilters = {};
194
- if (selectedProfile) {
195
- newFilters.profile = selectedProfile.id;
196
- }
197
- if (selectedVariant) {
198
- newFilters.variant = selectedVariant.id;
199
- }
200
- setFilters({ ...filters, ...newFilters });
201
- }, [selectedProfile, selectedVariant]);
202
- useEffect(() => {
203
- onFilter(filters);
204
- }, [filters]);
205
- useEffect(() => {
206
- if (metadata) {
207
- let worthShowSelectors = false;
208
- const selectorStructure = metadata.filter((profile) => profile.dimensions.length > 0).map((profile) => {
209
- const combinatory = getVariantsCombinatory(profile.dimensions.map((d2) => d2.variants));
210
- if (!worthShowSelectors && combinatory && combinatory.length > 2) {
211
- worthShowSelectors = true;
212
- }
213
- return {
214
- id: profile.id,
215
- name: profile.dimensions.map((d2) => d2.name).join(" / "),
216
- variants: combinatory
217
- };
218
- });
219
- setSelectors([allMember, ...selectorStructure]);
220
- setShowSelectors(worthShowSelectors ? true : selectorStructure.length > 1);
221
- if (initialReportId || initialVariantId) {
222
- if (initialReportId) {
223
- const initialReport = selectorStructure.find((ss) => ss.id === initialReportId);
224
- setSelectedProfile(initialReport);
225
- if (initialVariantId && initialReport) {
226
- setSelectedVariant(initialReport.variants.find((v2) => v2.id === initialVariantId));
227
- }
228
- }
229
- }
230
- }
231
- }, [metadata, initialReportId, initialVariantId]);
232
- return /* @__PURE__ */ jsxs(Fragment, { children: [
233
- showSelectors && /* @__PURE__ */ jsx(Group, { position: "center", className: "bespoke-explore-reports-selector", mb: "md", children: selectors.map((s2) => /* @__PURE__ */ jsx(
234
- Button,
235
- {
236
- "data-selected": s2.id === selectedProfile?.id ? "true" : "false",
237
- "data-report-name": s2.name,
238
- variant: s2.id === selectedProfile?.id ? "outline" : "subtle",
239
- onClick: () => onClickProfile(s2),
240
- children: translations?.dimension[s2.name] ?? s2.name
241
- },
242
- `p-${s2.id}`
243
- )) }),
244
- selectedProfile && selectedProfile.variants && selectedProfile.variants.length > 2 && /* @__PURE__ */ jsx(Group, { position: "center", style: { minHeight: "36px" }, className: "bespoke-explore-variant-selector", mb: "md", children: selectedProfile.variants.map((v2) => /* @__PURE__ */ jsx(
245
- Button,
246
- {
247
- "data-selected": v2.id === selectedVariant?.id ? "true" : "false",
248
- "data-variant-name": v2.name,
249
- variant: v2.id === selectedVariant?.id ? "outline" : "subtle",
250
- onClick: () => onClickVariant(v2),
251
- children: translations?.dimension[v2.name] ?? v2.name
252
- },
253
- `v-${v2.id}`
254
- )) })
255
- ] });
256
- }
257
- var ExploreFilters_default;
258
- var init_ExploreFilters = __esm({
259
- "frontend/components/explore/ExploreFilters.tsx"() {
260
- init_esm_shims();
261
- ExploreFilters_default = ExploreFilters;
262
- }
263
- });
264
164
 
265
165
  // api/http/lib.ts
266
- function http(axios11, config) {
267
- return axios11.request(config).then((response) => {
166
+ function http(axios10, config) {
167
+ return axios10.request(config).then((response) => {
268
168
  const { status, data } = response;
269
169
  return "error" in data ? { ok: false, status, error: data.error } : { ok: true, status, data: data.data };
270
170
  }, (err) => {
@@ -275,26 +175,26 @@ function http(axios11, config) {
275
175
  return { ok: false, status: 500, error: err.message };
276
176
  });
277
177
  }
278
- function httpGET(axios11, request, transformParams) {
178
+ function httpGET(axios10, request, transformParams) {
279
179
  const config = typeof request === "string" ? { url: request } : request;
280
- return (params) => http(axios11, {
180
+ return (params) => http(axios10, {
281
181
  ...config,
282
182
  method: "GET",
283
183
  params: transformParams ? transformParams(params) : params
284
184
  });
285
185
  }
286
- function httpPOST(axios11, request, transformPayload) {
186
+ function httpPOST(axios10, request, transformPayload) {
287
187
  const config = typeof request === "string" ? { url: request } : request;
288
- return (payload) => http(axios11, {
188
+ return (payload) => http(axios10, {
289
189
  ...config,
290
190
  method: "POST",
291
191
  data: transformPayload ? transformPayload(payload) : payload
292
192
  });
293
193
  }
294
- function httpDELETE(axios11, request, transformPayload) {
194
+ function httpDELETE(axios10, request, transformPayload) {
295
195
  const config = typeof request === "string" ? { url: request } : request;
296
196
  return (payload) => {
297
- return http(axios11, {
197
+ return http(axios10, {
298
198
  ...config,
299
199
  method: "DELETE",
300
200
  params: transformPayload ? transformPayload(payload) : payload
@@ -308,8 +208,8 @@ var init_lib = __esm({
308
208
  });
309
209
 
310
210
  // api/http/image/imageSave.ts
311
- function httpImageSaveFactory(axios11, provider) {
312
- return (params) => http(axios11, {
211
+ function httpImageSaveFactory(axios10, provider) {
212
+ return (params) => http(axios10, {
313
213
  method: "POST",
314
214
  url: `images/save/${provider}`,
315
215
  params: { prompt: params.prompt, provider }
@@ -323,8 +223,8 @@ var init_imageSave = __esm({
323
223
  });
324
224
 
325
225
  // api/http/image/imageSearch.ts
326
- function httpImageSearchFactory(axios11, provider) {
327
- return (params) => http(axios11, {
226
+ function httpImageSearchFactory(axios10, provider) {
227
+ return (params) => http(axios10, {
328
228
  method: "GET",
329
229
  url: `images/search/${provider}`,
330
230
  params: { prompt: params.prompt, page: params.page, provider }
@@ -338,8 +238,8 @@ var init_imageSearch = __esm({
338
238
  });
339
239
 
340
240
  // api/http/icon/listIcons.ts
341
- function httpListIconsFactory(axios11, provider) {
342
- return () => http(axios11, {
241
+ function httpListIconsFactory(axios10, provider) {
242
+ return () => http(axios10, {
343
243
  method: "GET",
344
244
  url: `list/icons/${provider}`,
345
245
  params: { provider }
@@ -353,8 +253,8 @@ var init_listIcons = __esm({
353
253
  });
354
254
 
355
255
  // api/http/icon/readIcon.ts
356
- function httpReadIconFactory(axios11, provider) {
357
- return (params) => http(axios11, {
256
+ function httpReadIconFactory(axios10, provider) {
257
+ return (params) => http(axios10, {
358
258
  method: "GET",
359
259
  url: `read/icons/${provider}/icon.svg`,
360
260
  params: { name: params.name }
@@ -367,65 +267,65 @@ var init_readIcon = __esm({
367
267
  }
368
268
  });
369
269
  function apiFactory(baseURL) {
370
- const axios11 = axios.create({ baseURL });
270
+ const axios10 = axios.create({ baseURL });
371
271
  return {
372
- createBulkBlock: httpPOST(axios11, "create/bulk/block"),
373
- createBlock: httpPOST(axios11, "create/block"),
374
- createDimension: httpPOST(axios11, "create/dimension"),
375
- createFormatter: httpPOST(axios11, "create/formatter"),
376
- createReport: httpPOST(axios11, "create/report"),
377
- createSection: httpPOST(axios11, "create/section"),
378
- createVariant: httpPOST(axios11, "create/variant"),
379
- deleteBlock: httpDELETE(axios11, "delete/block", transformDeletePayload),
380
- deleteDimension: httpDELETE(axios11, "delete/dimension", transformDeletePayload),
381
- deleteFormatter: httpDELETE(axios11, "delete/formatter", transformDeletePayload),
382
- deleteReport: httpDELETE(axios11, "delete/report", transformDeletePayload),
383
- deleteSection: httpDELETE(axios11, "delete/section", transformDeletePayload),
384
- deleteVariant: httpDELETE(axios11, "delete/variant", transformDeletePayload),
385
- readBlock: httpGET(axios11, "read/block"),
386
- readDimension: httpGET(axios11, "read/dimension"),
387
- readFormatter: httpGET(axios11, "read/formatter"),
388
- readReport: httpGET(axios11, "read/report"),
389
- readSection: httpGET(axios11, "read/section"),
390
- readVariant: httpGET(axios11, "read/variant"),
391
- updateBulkBlock: httpPOST(axios11, "update/bulk/block"),
392
- updateBlock: httpPOST(axios11, "update/block"),
393
- updateDimension: httpPOST(axios11, "update/dimension"),
394
- updateFormatter: httpPOST(axios11, "update/formatter"),
395
- updateReport: httpPOST(axios11, "update/report"),
396
- updateSection: httpPOST(axios11, "update/section"),
397
- updateVariant: httpPOST(axios11, "update/variant"),
398
- searchReport: httpGET(axios11, "search/reports"),
399
- validateVariantSlug: httpGET(axios11, "validate/variant"),
400
- readMember: httpGET(axios11, "read/members", transformReadMembers),
401
- readMemberImage: httpGET(axios11, {
272
+ createBulkBlock: httpPOST(axios10, "create/bulk/block"),
273
+ createBlock: httpPOST(axios10, "create/block"),
274
+ createDimension: httpPOST(axios10, "create/dimension"),
275
+ createFormatter: httpPOST(axios10, "create/formatter"),
276
+ createReport: httpPOST(axios10, "create/report"),
277
+ createSection: httpPOST(axios10, "create/section"),
278
+ createVariant: httpPOST(axios10, "create/variant"),
279
+ deleteBlock: httpDELETE(axios10, "delete/block", transformDeletePayload),
280
+ deleteDimension: httpDELETE(axios10, "delete/dimension", transformDeletePayload),
281
+ deleteFormatter: httpDELETE(axios10, "delete/formatter", transformDeletePayload),
282
+ deleteReport: httpDELETE(axios10, "delete/report", transformDeletePayload),
283
+ deleteSection: httpDELETE(axios10, "delete/section", transformDeletePayload),
284
+ deleteVariant: httpDELETE(axios10, "delete/variant", transformDeletePayload),
285
+ readBlock: httpGET(axios10, "read/block"),
286
+ readDimension: httpGET(axios10, "read/dimension"),
287
+ readFormatter: httpGET(axios10, "read/formatter"),
288
+ readReport: httpGET(axios10, "read/report"),
289
+ readSection: httpGET(axios10, "read/section"),
290
+ readVariant: httpGET(axios10, "read/variant"),
291
+ updateBulkBlock: httpPOST(axios10, "update/bulk/block"),
292
+ updateBlock: httpPOST(axios10, "update/block"),
293
+ updateDimension: httpPOST(axios10, "update/dimension"),
294
+ updateFormatter: httpPOST(axios10, "update/formatter"),
295
+ updateReport: httpPOST(axios10, "update/report"),
296
+ updateSection: httpPOST(axios10, "update/section"),
297
+ updateVariant: httpPOST(axios10, "update/variant"),
298
+ searchReport: httpGET(axios10, "search/reports"),
299
+ validateVariantSlug: httpGET(axios10, "validate/variant"),
300
+ readMember: httpGET(axios10, "read/members", transformReadMembers),
301
+ readMemberImage: httpGET(axios10, {
402
302
  url: "member/image",
403
303
  responseType: "blob"
404
304
  }),
405
- searchMember: httpGET(axios11, "search/members"),
406
- updateMember: httpGET(axios11, "update/members"),
407
- imageLocalSearch: httpImageSearchFactory(axios11, "local"),
408
- imageLocalSave: httpImageSaveFactory(axios11, "local"),
409
- imageFlickrSearch: httpImageSearchFactory(axios11, "flickr"),
410
- imageFlickrSave: httpImageSaveFactory(axios11, "flickr"),
411
- imageUnsplashSearch: httpImageSearchFactory(axios11, "unsplash"),
412
- imageUnsplashSave: httpImageSaveFactory(axios11, "unsplash"),
413
- imageUploadSave: httpImageSaveFactory(axios11, "upload"),
414
- imageAdobeSearch: httpImageSearchFactory(axios11, "adobe"),
415
- imageAdobeSave: httpImageSaveFactory(axios11, "adobe"),
416
- readMetadata: httpGET(axios11, "read/metadata"),
417
- regenerateSearch: httpPOST(axios11, "search/regenerate"),
418
- urlProxy: httpGET(axios11, "url/proxy"),
419
- searchRole: httpGET(axios11, "auth/search/roles"),
420
- searchUser: httpGET(axios11, "auth/search/users"),
421
- readUser: httpGET(axios11, "auth/read/user"),
422
- updateUser: httpPOST(axios11, "auth/update/user"),
423
- updateMyData: httpPOST(axios11, "auth/update/me"),
424
- revalidateReport: httpGET(axios11, "revalidate/report"),
425
- revalidateUrl: httpGET(axios11, "revalidate/url"),
426
- readPrivateBlocks: httpPOST(axios11, "read/blocks/private"),
427
- listTablerIcons: httpListIconsFactory(axios11, "tabler"),
428
- readTablerIcon: httpReadIconFactory(axios11, "tabler")
305
+ searchMember: httpGET(axios10, "search/members"),
306
+ updateMember: httpGET(axios10, "update/members"),
307
+ imageLocalSearch: httpImageSearchFactory(axios10, "local"),
308
+ imageLocalSave: httpImageSaveFactory(axios10, "local"),
309
+ imageFlickrSearch: httpImageSearchFactory(axios10, "flickr"),
310
+ imageFlickrSave: httpImageSaveFactory(axios10, "flickr"),
311
+ imageUnsplashSearch: httpImageSearchFactory(axios10, "unsplash"),
312
+ imageUnsplashSave: httpImageSaveFactory(axios10, "unsplash"),
313
+ imageUploadSave: httpImageSaveFactory(axios10, "upload"),
314
+ imageAdobeSearch: httpImageSearchFactory(axios10, "adobe"),
315
+ imageAdobeSave: httpImageSaveFactory(axios10, "adobe"),
316
+ readMetadata: httpGET(axios10, "read/metadata"),
317
+ regenerateSearch: httpPOST(axios10, "search/regenerate"),
318
+ urlProxy: httpGET(axios10, "url/proxy"),
319
+ searchRole: httpGET(axios10, "auth/search/roles"),
320
+ searchUser: httpGET(axios10, "auth/search/users"),
321
+ readUser: httpGET(axios10, "auth/read/user"),
322
+ updateUser: httpPOST(axios10, "auth/update/user"),
323
+ updateMyData: httpPOST(axios10, "auth/update/me"),
324
+ revalidateReport: httpGET(axios10, "revalidate/report"),
325
+ revalidateUrl: httpGET(axios10, "revalidate/url"),
326
+ readPrivateBlocks: httpPOST(axios10, "read/blocks/private"),
327
+ listTablerIcons: httpListIconsFactory(axios10, "tabler"),
328
+ readTablerIcon: httpReadIconFactory(axios10, "tabler")
429
329
  };
430
330
  }
431
331
  var transformDeletePayload, transformReadMembers;
@@ -2569,26 +2469,6 @@ var init_recordsSlice = __esm({
2569
2469
  }
2570
2470
  }
2571
2471
  };
2572
- },
2573
- normalizeSection: (state, action) => {
2574
- const sectionId = action.payload.section;
2575
- const section = state.entities.section[sectionId];
2576
- return {
2577
- ...state,
2578
- entities: {
2579
- ...state.entities,
2580
- section: {
2581
- // ...state.entities.section,
2582
- [sectionId]: {
2583
- ...section,
2584
- settings: {
2585
- ...section.settings,
2586
- width: "full"
2587
- }
2588
- }
2589
- }
2590
- }
2591
- };
2592
2472
  }
2593
2473
  },
2594
2474
  extraReducers: {
@@ -3520,7 +3400,6 @@ __export(actions_exports, {
3520
3400
  createEntity: () => createEntity,
3521
3401
  deleteEntity: () => deleteEntity,
3522
3402
  deleteQueryParam: () => deleteQueryParam,
3523
- normalizeSectionLayout: () => normalizeSectionLayout,
3524
3403
  readEntity: () => readEntity,
3525
3404
  readMember: () => readMember,
3526
3405
  readMetadata: () => readMetadata,
@@ -3717,12 +3596,6 @@ function removeBlocksFromState(privateBlockIds) {
3717
3596
  await dispatch(removeBlocks(privateBlockIds));
3718
3597
  };
3719
3598
  }
3720
- function normalizeSectionLayout(sectionId) {
3721
- const { normalizeSection } = recordsSlice.actions;
3722
- return async (dispatch) => {
3723
- await dispatch(normalizeSection(sectionId));
3724
- };
3725
- }
3726
3599
  function addBlockToState(newBlocks) {
3727
3600
  const { addBlocks } = recordsSlice.actions;
3728
3601
  return async (dispatch) => {
@@ -4129,6 +4002,314 @@ var init_store2 = __esm({
4129
4002
  init_withFetcher();
4130
4003
  }
4131
4004
  });
4005
+ function ExploreProvider({ children, explorePageSize }) {
4006
+ const pageSize = explorePageSize || 10;
4007
+ const defaultFilters = {
4008
+ // initial reportIds should go here to avoid multiple unnecesary requests
4009
+ profile: void 0,
4010
+ variant: void 0
4011
+ };
4012
+ const [metadata, setMetadata] = useState([]);
4013
+ const [loading, setLoading] = useState(false);
4014
+ const [resultCount, setResultCount] = useState({});
4015
+ const [totalCount, setTotalCount] = useState({});
4016
+ const [activePage, setActivePage] = useState(1);
4017
+ const [filters, setFilters] = useState(defaultFilters);
4018
+ const [query, setQuery] = useState("");
4019
+ const [debouncedQuery] = useDebouncedValue(query, 500);
4020
+ const [results, setResults] = useState([]);
4021
+ const [translations, setTranslations] = useState(DEFAULT_TRANSLATIONS);
4022
+ const [showSelectors, setShowSelectors] = useState(false);
4023
+ const [initialized, setInitialized] = useState(false);
4024
+ const dispatch = useAppDispatch();
4025
+ const { locale } = useRouter();
4026
+ const fetchMetadata = async () => {
4027
+ try {
4028
+ setLoading(true);
4029
+ dispatch(actions_exports.readMetadata({})).then((resp) => {
4030
+ const metadataCount = resp.data.reduce((acc, report) => {
4031
+ if (report.dimensions) {
4032
+ report.dimensions.forEach((dimension) => {
4033
+ if (dimension.variants) {
4034
+ dimension.variants.forEach((variant) => {
4035
+ acc[variant.id] = variant.members_count || 0;
4036
+ });
4037
+ }
4038
+ });
4039
+ }
4040
+ return acc;
4041
+ }, {});
4042
+ setMetadata(resp.data);
4043
+ setLoading(false);
4044
+ setResultCount(metadataCount);
4045
+ setTotalCount(metadataCount);
4046
+ setInitialized(true);
4047
+ }, (err) => {
4048
+ console.error(err);
4049
+ });
4050
+ } catch (error) {
4051
+ console.error("Error fetching metadata:", error);
4052
+ setMetadata([]);
4053
+ setLoading(false);
4054
+ setResultCount({});
4055
+ setTotalCount({});
4056
+ }
4057
+ };
4058
+ const setResultCountInternal = (totalPerVariant) => {
4059
+ if (totalPerVariant) {
4060
+ setResultCount(totalPerVariant);
4061
+ } else {
4062
+ setResultCount(totalCount);
4063
+ }
4064
+ };
4065
+ const initExplore = async (initialReportId, initialVariantId) => {
4066
+ if (!initialized && metadata.length === 0) {
4067
+ await fetchMetadata();
4068
+ }
4069
+ setFilters({
4070
+ profile: initialReportId,
4071
+ variant: initialVariantId
4072
+ });
4073
+ };
4074
+ useEffect(() => {
4075
+ let cancelled = false;
4076
+ if (initialized) {
4077
+ setLoading(true);
4078
+ setActivePage(1);
4079
+ doQuery(cancelled, 0);
4080
+ }
4081
+ return () => {
4082
+ cancelled = false;
4083
+ };
4084
+ }, [debouncedQuery, filters, initialized]);
4085
+ useEffect(() => {
4086
+ if (initialized) {
4087
+ const newOffset = (activePage - 1) * pageSize;
4088
+ doQuery(false, newOffset);
4089
+ }
4090
+ }, [activePage]);
4091
+ const doQuery = async (cancelled, newOffset) => {
4092
+ const filterProfile = filters.profile && !Number.isNaN(filters.profile) ? [filters.profile] : [];
4093
+ const filterVariant = filters.variant && !Number.isNaN(filters.variant) ? [filters.variant] : [];
4094
+ const params = {
4095
+ query: debouncedQuery,
4096
+ format: "profiles",
4097
+ locale,
4098
+ limit: pageSize,
4099
+ offset: newOffset,
4100
+ visible: true,
4101
+ includes: true,
4102
+ noImage: false,
4103
+ variant: filterVariant,
4104
+ dimension: [],
4105
+ report: filterProfile,
4106
+ all: false
4107
+ };
4108
+ dispatch(actions_exports.reportSearch(params)).then((resp) => {
4109
+ if (resp && resp.results && !cancelled) {
4110
+ const mergedResults = resp.results;
4111
+ setResults(mergedResults);
4112
+ setResultCount(query === "" ? false : resp.meta.variantCount);
4113
+ }
4114
+ setLoading(false);
4115
+ }).catch((e) => {
4116
+ console.error(e);
4117
+ setLoading(false);
4118
+ });
4119
+ };
4120
+ const counts = resultCount || totalCount;
4121
+ const allMember = { id: void 0, name: translations["filters_all"] || "ALL" };
4122
+ const getVariantsCombinatory = (variantsArrays) => {
4123
+ const combinatory = variantsArrays.reduce((a2, b2) => a2.reduce((r2, v2) => r2.concat(b2.map((w2) => [].concat(v2, w2))), [])).map((combination) => {
4124
+ let final;
4125
+ if (!Array.isArray(combination)) {
4126
+ combination.members_count = counts[combination.id] || 0;
4127
+ final = {
4128
+ ...combination,
4129
+ members_count: counts[combination.id] || 0
4130
+ };
4131
+ } else {
4132
+ final = {
4133
+ id: combination.map((c2) => c2.id).join(","),
4134
+ name: combination.map((c2) => c2.name).join(" / "),
4135
+ members_count: combination.reduce((t2, q2) => t2 * (counts[q2.id] || 1), 0)
4136
+ };
4137
+ }
4138
+ return final;
4139
+ });
4140
+ const allTotal = combinatory.reduce((t2, q2) => t2 + (q2.members_count || 0), 0);
4141
+ return [
4142
+ { ...allMember, members_count: allTotal },
4143
+ ...combinatory
4144
+ ];
4145
+ };
4146
+ const selectorStructure = useMemo(() => {
4147
+ let temp = [];
4148
+ if (!loading && metadata.length > 0 && counts) {
4149
+ let worthShowSelectors = false;
4150
+ const selectors = [...metadata].filter((profile) => profile.dimensions.length > 0).map((profile) => {
4151
+ const combinatory = getVariantsCombinatory(profile.dimensions.map((d2) => d2.variants));
4152
+ if (!worthShowSelectors && combinatory && combinatory.length > 2) {
4153
+ worthShowSelectors = true;
4154
+ }
4155
+ return {
4156
+ id: profile.id,
4157
+ name: profile.dimensions.map((d2) => d2.name).join(" / "),
4158
+ variants: combinatory,
4159
+ members_count: combinatory.filter((v2) => v2.id).reduce((t2, q2) => t2 + (q2.members_count || 0), 0)
4160
+ };
4161
+ });
4162
+ temp = [
4163
+ { ...allMember, members_count: selectors.reduce((t2, q2) => t2 + (q2.members_count || 0), 0) },
4164
+ ...selectors
4165
+ ];
4166
+ setShowSelectors(worthShowSelectors ? true : selectorStructure.length > 1);
4167
+ }
4168
+ return temp;
4169
+ }, [loading, counts, metadata]);
4170
+ const currentPageTotal = useMemo(() => {
4171
+ let selector;
4172
+ if (selectorStructure) {
4173
+ if (!filters.profile) {
4174
+ selector = selectorStructure.find((p2) => !p2.id);
4175
+ } else if (filters.profile) {
4176
+ selector = selectorStructure.find((p2) => p2.id === filters.profile);
4177
+ if (selector && filters.variant && selector.variants) {
4178
+ selector = selector.variants.find((p2) => p2.id === filters.variant);
4179
+ }
4180
+ }
4181
+ }
4182
+ return selector ? selector.members_count : pageSize;
4183
+ }, [filters, selectorStructure]);
4184
+ const state = {
4185
+ metadata,
4186
+ loading,
4187
+ setLoading,
4188
+ resultCount,
4189
+ totalCount,
4190
+ setResultCount: setResultCountInternal,
4191
+ activePage,
4192
+ setActivePage,
4193
+ pageSize,
4194
+ filters,
4195
+ setFilters,
4196
+ doQuery,
4197
+ query,
4198
+ setQuery,
4199
+ debouncedQuery,
4200
+ results,
4201
+ currentPageTotal,
4202
+ selectorStructure,
4203
+ translations,
4204
+ setTranslations: (t2) => {
4205
+ setTranslations({ ...DEFAULT_TRANSLATIONS, ...t2 });
4206
+ },
4207
+ showSelectors,
4208
+ initExplore
4209
+ };
4210
+ return /* @__PURE__ */ jsx(ExploreContext.Provider, { value: state, children });
4211
+ }
4212
+ var DEFAULT_TRANSLATIONS, ExploreContext, useExplore;
4213
+ var init_ExploreProvider = __esm({
4214
+ "frontend/components/report/context/ExploreProvider.tsx"() {
4215
+ init_esm_shims();
4216
+ init_store2();
4217
+ DEFAULT_TRANSLATIONS = {
4218
+ "try_another": "Try another search or filter.",
4219
+ "search": "Search",
4220
+ "filters_all": "All",
4221
+ "no_results": "No Results",
4222
+ "load_more": "Load more",
4223
+ report: {},
4224
+ dimension: {},
4225
+ variant: {}
4226
+ };
4227
+ ExploreContext = createContext({
4228
+ metadata: [],
4229
+ loading: false,
4230
+ setLoading: () => null,
4231
+ resultCount: {},
4232
+ totalCount: {},
4233
+ setResultCount: () => null,
4234
+ activePage: 1,
4235
+ setActivePage: () => null,
4236
+ pageSize: 10,
4237
+ results: [],
4238
+ filters: {},
4239
+ doQuery: () => null,
4240
+ setFilters: () => null,
4241
+ query: "",
4242
+ setQuery: () => null,
4243
+ debouncedQuery: "",
4244
+ currentPageTotal: 10,
4245
+ selectorStructure: [],
4246
+ translations: DEFAULT_TRANSLATIONS,
4247
+ setTranslations: () => null,
4248
+ showSelectors: true,
4249
+ initExplore: (p2, v2) => null
4250
+ });
4251
+ useExplore = () => useContext(ExploreContext);
4252
+ }
4253
+ });
4254
+ function ExploreFilters({ initialReportId, initialVariantId, translations }) {
4255
+ const { loading, setFilters, selectorStructure, filters, showSelectors } = useExplore();
4256
+ const onClickProfile = (profileId) => {
4257
+ if (profileId !== filters.profile) {
4258
+ setFilters({
4259
+ profile: profileId,
4260
+ variant: void 0
4261
+ });
4262
+ }
4263
+ };
4264
+ const onClickVariant = (variantId) => {
4265
+ if (variantId !== filters.variant) {
4266
+ setFilters({
4267
+ ...filters,
4268
+ variant: variantId
4269
+ });
4270
+ }
4271
+ };
4272
+ const selectedProfileObj = filters.profile ? selectorStructure.find((p2) => p2.id === filters.profile) : void 0;
4273
+ const selectedVariantObj = selectedProfileObj && selectedProfileObj.variants && filters.variant ? selectedProfileObj.variants.find((p2) => p2.id === filters.variant) : void 0;
4274
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4275
+ showSelectors && /* @__PURE__ */ jsx(Group, { position: "center", className: "bespoke-explore-reports-selector", mb: "md", children: selectorStructure.map((s2) => /* @__PURE__ */ jsxs(
4276
+ Button,
4277
+ {
4278
+ "data-selected": s2.id === selectedProfileObj?.id ? "true" : "false",
4279
+ "data-report-name": s2.name,
4280
+ variant: s2.id === selectedProfileObj?.id ? "outline" : "subtle",
4281
+ onClick: () => onClickProfile(s2.id),
4282
+ children: [
4283
+ translations?.dimension[s2.name] ?? s2.name,
4284
+ !loading && /* @__PURE__ */ jsx(Text, { span: true, size: "xs", ml: "0.2rem", children: `(${s2.members_count})` })
4285
+ ]
4286
+ },
4287
+ `p-${s2.id}`
4288
+ )) }),
4289
+ selectedProfileObj && selectedProfileObj.variants && selectedProfileObj.variants.length > 2 && /* @__PURE__ */ jsx(Group, { position: "center", style: { minHeight: "36px" }, className: "bespoke-explore-variant-selector", mb: "md", children: selectedProfileObj.variants.map((v2) => /* @__PURE__ */ jsxs(
4290
+ Button,
4291
+ {
4292
+ "data-selected": v2.id === selectedVariantObj?.id ? "true" : "false",
4293
+ "data-variant-name": v2.name,
4294
+ variant: v2.id === selectedVariantObj?.id ? "outline" : "subtle",
4295
+ onClick: () => onClickVariant(v2.id),
4296
+ children: [
4297
+ translations?.dimension[v2.name] ?? v2.name,
4298
+ !loading && /* @__PURE__ */ jsx(Text, { span: true, size: "xs", ml: "0.2rem", children: `(${v2.members_count})` })
4299
+ ]
4300
+ },
4301
+ `v-${v2.id}`
4302
+ )) })
4303
+ ] });
4304
+ }
4305
+ var ExploreFilters_default;
4306
+ var init_ExploreFilters = __esm({
4307
+ "frontend/components/explore/ExploreFilters.tsx"() {
4308
+ init_esm_shims();
4309
+ init_ExploreProvider();
4310
+ ExploreFilters_default = ExploreFilters;
4311
+ }
4312
+ });
4132
4313
  function useBespokeStyles() {
4133
4314
  const theme = useMantineTheme();
4134
4315
  return theme.other.bespokeStyles ?? {};
@@ -4215,11 +4396,16 @@ var init_ExploreTile = __esm({
4215
4396
  ExploreTile_default = ExploreTile;
4216
4397
  }
4217
4398
  });
4218
- function ExploreResults({ results = [], profilePrefix, onSelect = () => void 0, reportTile }) {
4399
+ function ExploreResults({
4400
+ profilePrefix,
4401
+ onSelect = () => void 0,
4402
+ reportTile
4403
+ }) {
4219
4404
  const [scrollSize, setScrollSize] = useState(500);
4220
4405
  const scrollAreaRef = useRef(null);
4406
+ const { results } = useExplore();
4221
4407
  const offset2 = scrollAreaRef.current?.offsetTop || 0;
4222
- const gap = 30;
4408
+ const gap = 50;
4223
4409
  useEffect(() => {
4224
4410
  const { innerHeight } = window;
4225
4411
  setScrollSize(innerHeight - offset2 - gap);
@@ -4242,80 +4428,73 @@ var init_ExploreResults = __esm({
4242
4428
  "frontend/components/explore/ExploreResults.tsx"() {
4243
4429
  init_esm_shims();
4244
4430
  init_ExploreTile();
4431
+ init_ExploreProvider();
4245
4432
  ExploreResults_default = ExploreResults;
4246
4433
  }
4247
4434
  });
4435
+ function ExplorePagination() {
4436
+ const {
4437
+ activePage,
4438
+ setActivePage,
4439
+ pageSize,
4440
+ currentPageTotal
4441
+ } = useExplore();
4442
+ const onChangePage = (page) => {
4443
+ setActivePage(page);
4444
+ };
4445
+ return /* @__PURE__ */ jsx(Group, { position: "center", children: /* @__PURE__ */ jsx(
4446
+ Pagination,
4447
+ {
4448
+ value: activePage,
4449
+ onChange: onChangePage,
4450
+ total: Math.ceil(currentPageTotal / pageSize),
4451
+ size: "sm",
4452
+ py: "xs"
4453
+ }
4454
+ ) });
4455
+ }
4456
+ var ExplorePagination_default;
4457
+ var init_ExplorePagination = __esm({
4458
+ "frontend/components/explore/ExplorePagination.tsx"() {
4459
+ init_esm_shims();
4460
+ init_ExploreProvider();
4461
+ ExplorePagination_default = ExplorePagination;
4462
+ }
4463
+ });
4248
4464
  function BespokeExplore({
4249
- locale,
4250
4465
  profilePrefix,
4251
4466
  initialReportId,
4252
4467
  initialVariantId,
4253
- translations = DEFAULT_TRANSLATIONS,
4468
+ translations,
4254
4469
  onSelect,
4255
4470
  reportTile
4256
4471
  }) {
4257
- const dispatch = useAppDispatch();
4258
- const defaultFilters = {
4259
- // initial reportIds should go here to avoid multiple unnecesary requests
4260
- profile: void 0,
4261
- variant: void 0
4262
- };
4263
- const [query, setQuery] = useState("");
4264
- const [debouncedQuery] = useDebouncedValue(query, 500);
4265
- const [results, setResults] = useState([]);
4266
- const [loading, setLoading] = useState(false);
4267
- const [filters, setFilters] = useState(defaultFilters);
4268
- const [metadata, setMetadata] = useState();
4269
4472
  const inputRef = useRef();
4473
+ const {
4474
+ query,
4475
+ setQuery,
4476
+ results,
4477
+ loading,
4478
+ translations: exploreTranslations,
4479
+ setTranslations,
4480
+ initExplore
4481
+ } = useExplore();
4270
4482
  useEffect(() => {
4271
- setLoading(true);
4272
- dispatch(actions_exports.readMetadata({})).then((resp) => {
4273
- setMetadata(resp.data);
4274
- }, (err) => {
4275
- console.error(err);
4276
- });
4483
+ initExplore(initialReportId, initialVariantId);
4277
4484
  }, []);
4278
4485
  useEffect(() => {
4279
- let cancelled = false;
4280
- if (metadata) {
4281
- setLoading(true);
4282
- const filterProfile = filters.profile && !Number.isNaN(filters.profile) ? filters.profile : [];
4283
- const filterVariant = filters.variant && !Number.isNaN(filters.variant) ? filters.variant : [];
4284
- const params = {
4285
- query: debouncedQuery,
4286
- format: "profiles",
4287
- locale,
4288
- limit: 25,
4289
- visible: true,
4290
- includes: true,
4291
- noImage: false,
4292
- variant: filterVariant,
4293
- dimension: [],
4294
- report: filterProfile,
4295
- all: false
4296
- };
4297
- dispatch(actions_exports.reportSearch(params)).then((resp) => {
4298
- if (resp && resp.results && !cancelled) {
4299
- setResults(resp.results);
4300
- }
4301
- setLoading(false);
4302
- inputRef.current?.focus();
4303
- }).catch((e) => {
4304
- console.error(e);
4305
- setLoading(false);
4306
- });
4486
+ if (!loading) {
4487
+ inputRef.current?.focus();
4307
4488
  }
4308
- return () => {
4309
- cancelled = false;
4310
- };
4311
- }, [debouncedQuery, filters, metadata]);
4312
- const onFilterChange = (newFilters) => {
4313
- setFilters(newFilters);
4314
- };
4489
+ }, [loading]);
4490
+ useEffect(() => {
4491
+ if (translations) {
4492
+ setTranslations(translations);
4493
+ }
4494
+ }, [translations]);
4315
4495
  const onClearInput = () => {
4316
4496
  setQuery("");
4317
4497
  };
4318
- const exploreTranslations = { ...DEFAULT_TRANSLATIONS, ...translations };
4319
4498
  return /* @__PURE__ */ jsxs(Container, { fluid: true, pt: "1em", children: [
4320
4499
  /* @__PURE__ */ jsx(
4321
4500
  TextInput,
@@ -4344,8 +4523,6 @@ function BespokeExplore({
4344
4523
  /* @__PURE__ */ jsx(
4345
4524
  ExploreFilters_default,
4346
4525
  {
4347
- metadata,
4348
- onFilter: onFilterChange,
4349
4526
  initialReportId,
4350
4527
  initialVariantId,
4351
4528
  translations: exploreTranslations
@@ -4353,25 +4530,25 @@ function BespokeExplore({
4353
4530
  ),
4354
4531
  /* @__PURE__ */ jsx(LoadingOverlay, { visible: loading }),
4355
4532
  !loading && results.length === 0 && /* @__PURE__ */ jsx(Alert, { title: exploreTranslations["no_results"], color: "blue", children: exploreTranslations["try_another"] }),
4356
- !loading && /* @__PURE__ */ jsx(ExploreResults_default, { results, profilePrefix, onSelect, reportTile })
4533
+ !loading && /* @__PURE__ */ jsx(
4534
+ ExploreResults_default,
4535
+ {
4536
+ profilePrefix,
4537
+ onSelect,
4538
+ reportTile
4539
+ }
4540
+ ),
4541
+ /* @__PURE__ */ jsx(ExplorePagination_default, {})
4357
4542
  ] });
4358
4543
  }
4359
- var DEFAULT_TRANSLATIONS, Explore_default;
4544
+ var Explore_default;
4360
4545
  var init_Explore = __esm({
4361
4546
  "frontend/components/explore/Explore.tsx"() {
4362
4547
  init_esm_shims();
4363
4548
  init_ExploreFilters();
4364
4549
  init_ExploreResults();
4365
- init_store2();
4366
- DEFAULT_TRANSLATIONS = {
4367
- "try_another": "Try another search or filter.",
4368
- "search": "Search",
4369
- "filters_all": "All",
4370
- "no_results": "No Results",
4371
- report: {},
4372
- dimension: {},
4373
- variant: {}
4374
- };
4550
+ init_ExplorePagination();
4551
+ init_ExploreProvider();
4375
4552
  Explore_default = BespokeExplore;
4376
4553
  }
4377
4554
  });
@@ -4415,7 +4592,7 @@ function BespokeExploreModal({
4415
4592
  target = /* @__PURE__ */ jsx(Tooltip, { label: tooltipText, ...tooltipProps, children: target });
4416
4593
  }
4417
4594
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4418
- /* @__PURE__ */ jsx(Modal, { ...mdlConfig, ...modalProps, children: /* @__PURE__ */ jsx(Explore_default, { ...exploreProps, onSelect: () => setOpened(false) }) }),
4595
+ /* @__PURE__ */ jsx(Modal, { ...mdlConfig, ...modalProps, children: opened && /* @__PURE__ */ jsx(Explore_default, { ...exploreProps, onSelect: () => setOpened(false) }) }),
4419
4596
  /* @__PURE__ */ jsx("div", { onClick: () => setOpened(true), children: children ? target : /* @__PURE__ */ jsx(Fragment, { children: actionIcon }) })
4420
4597
  ] });
4421
4598
  }
@@ -4762,10 +4939,10 @@ var init_RichText = __esm({
4762
4939
  });
4763
4940
  function InnerTooltip(props) {
4764
4941
  const { content, style = {} } = props;
4765
- const { isPrint } = useMode();
4942
+ const print = usePrint();
4766
4943
  const contentObj = /* @__PURE__ */ jsx(RichText, { component: "span", html: content, isPreview: true });
4767
4944
  const element = useMemo(() => {
4768
- return isPrint ? /* @__PURE__ */ jsx("div", { className: "bespoke-inner-tooltip-notification", children: /* @__PURE__ */ jsx(
4945
+ return print ? /* @__PURE__ */ jsx("div", { className: "bespoke-inner-tooltip-notification", children: /* @__PURE__ */ jsx(
4769
4946
  Notification,
4770
4947
  {
4771
4948
  icon: /* @__PURE__ */ jsx(IconInfoCircle, { size: "1.1rem" }),
@@ -5307,7 +5484,7 @@ function TitleView({
5307
5484
  _iconPadding,
5308
5485
  asComparison = false
5309
5486
  }) {
5310
- const { isPrint } = useMode();
5487
+ const print = usePrint();
5311
5488
  const titleHTML = sanitizeBlockContent_default(title) || "<span class='cr-block-placeholder'>Title</span>";
5312
5489
  const intOrder = settings && settings.order ? parseInt(settings.order, 10) : 1;
5313
5490
  const order2 = intOrder <= 6 ? intOrder : 1;
@@ -5350,7 +5527,7 @@ function TitleView({
5350
5527
  position: getAlignForGroup(align),
5351
5528
  children: [
5352
5529
  /* @__PURE__ */ jsxs("div", { children: [
5353
- isPrint ? titleElement : finalElement,
5530
+ print ? titleElement : finalElement,
5354
5531
  displayName && /* @__PURE__ */ jsx(Text, { className: "bespoke-comparison-title", children: memberName })
5355
5532
  ] }),
5356
5533
  tooltip && /* @__PURE__ */ jsx(InnerTooltip, { content: tooltip })
@@ -5471,7 +5648,7 @@ var init_useOnChangeSelector = __esm({
5471
5648
  });
5472
5649
  function Selector(config) {
5473
5650
  const { name, settings, options, id, defaultValue, section, component, asComparison, hideLabel } = config;
5474
- const { isPrint } = useMode();
5651
+ const print = usePrint();
5475
5652
  const selectorIdentifier = getSelectorIdentifier(id);
5476
5653
  const callback = useOnChangeSelector(id, section, selectorIdentifier, asComparison);
5477
5654
  const selectorIdentifierParam = asComparison ? `${selectorIdentifier}Compare` : selectorIdentifier;
@@ -5482,9 +5659,9 @@ function Selector(config) {
5482
5659
  (d2) => ({ value: d2.id, label: d2.label })
5483
5660
  ), [optDependency]);
5484
5661
  const printValue = useMemo(() => {
5485
- const optionsString = isPrint ? options.filter((o2) => multiValue.includes(o2.id)).map((o2) => o2.label).join(", ") : "";
5662
+ const optionsString = print ? options.filter((o2) => multiValue.includes(o2.id)).map((o2) => o2.label).join(", ") : "";
5486
5663
  return optionsString;
5487
- }, [isPrint]);
5664
+ }, [print]);
5488
5665
  const label = config.hideLabel === "true" ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(RichText, { component: "div", html: name, size: "sm", style: settings });
5489
5666
  useEffect(() => {
5490
5667
  const searchParams = new URLSearchParams(window.location.search);
@@ -5539,7 +5716,7 @@ function Selector(config) {
5539
5716
  }
5540
5717
  )
5541
5718
  }[config.type] }) }),
5542
- isPrint && /* @__PURE__ */ jsxs(Text, { children: [
5719
+ print && /* @__PURE__ */ jsxs(Text, { children: [
5543
5720
  label,
5544
5721
  ": ",
5545
5722
  printValue
@@ -5595,7 +5772,7 @@ var init_Image = __esm({
5595
5772
  init_block2();
5596
5773
  }
5597
5774
  });
5598
- function useInitialState(pathSegmentsKey, mode) {
5775
+ function useInitialState(pathSegmentsKey) {
5599
5776
  const { asPath, locale, defaultLocale } = useRouter();
5600
5777
  const [loading, setLoading] = useState(true);
5601
5778
  const { user, isLoading } = useUser();
@@ -5638,41 +5815,39 @@ function useInitialState(pathSegmentsKey, mode) {
5638
5815
  }
5639
5816
  }, [user, isLoading]);
5640
5817
  useEffect(() => {
5641
- if (mode !== "embed") {
5642
- const hasParams = Object.keys(query).some((key) => key !== pathSegmentsKey);
5643
- if ((hasParams || privateBlocks.blocks.length > 0) && privateBlocks.resolved) {
5644
- const selectorIds = Object.keys(query).map((d2) => Number(d2.match(/\d+/)));
5645
- const revalidateBlocks = selectorIds.filter((id) => id !== 0).concat(privateBlocks.blocks);
5646
- Promise.all(
5647
- revalidateBlocks.map((bid) => {
5648
- const block = blockRecords[bid];
5649
- const inputVariablesFlat = block.consumers.reduce((inputVars, cid) => ({ ...inputVars, ...variables[cid] }), {});
5650
- const blockContext = {
5651
- locale: localeDefault4,
5652
- query,
5653
- variables: {
5654
- ...inputVariablesFlat,
5655
- ...attributes
5656
- }
5657
- };
5658
- return runConsumersV2(
5659
- blockRecords,
5660
- void 0,
5661
- bid,
5662
- formatters2,
5663
- blockContext,
5664
- { variables, status },
5665
- readMemberFn,
5666
- "report"
5667
- );
5668
- })
5669
- ).then((d2) => {
5670
- setLoading(false);
5671
- d2.map((data) => dispatch(variablesActions.setVariableChange({ ...data, attributes })));
5672
- });
5673
- }
5818
+ const hasParams = Object.keys(query).some((key) => key !== pathSegmentsKey);
5819
+ if ((hasParams || privateBlocks.blocks.length > 0) && privateBlocks.resolved) {
5820
+ const selectorIds = Object.keys(query).map((d2) => Number(d2.match(/\d+/)));
5821
+ const revalidateBlocks = selectorIds.filter((id) => id !== 0).concat(privateBlocks.blocks);
5822
+ Promise.all(
5823
+ revalidateBlocks.map((bid) => {
5824
+ const block = blockRecords[bid];
5825
+ const inputVariablesFlat = block.consumers.reduce((inputVars, cid) => ({ ...inputVars, ...variables[cid] }), {});
5826
+ const blockContext = {
5827
+ locale: localeDefault4,
5828
+ query,
5829
+ variables: {
5830
+ ...inputVariablesFlat,
5831
+ ...attributes
5832
+ }
5833
+ };
5834
+ return runConsumersV2(
5835
+ blockRecords,
5836
+ void 0,
5837
+ bid,
5838
+ formatters2,
5839
+ blockContext,
5840
+ { variables, status },
5841
+ readMemberFn,
5842
+ "report"
5843
+ );
5844
+ })
5845
+ ).then((d2) => {
5846
+ setLoading(false);
5847
+ d2.map((data) => dispatch(variablesActions.setVariableChange({ ...data, attributes })));
5848
+ });
5674
5849
  }
5675
- }, [privateBlocks.resolved, mode]);
5850
+ }, [privateBlocks.resolved]);
5676
5851
  return loading || !privateBlocks.resolved;
5677
5852
  }
5678
5853
  var init_useInitialState = __esm({
@@ -6265,7 +6440,7 @@ __export(Viz_exports, {
6265
6440
  default: () => Viz
6266
6441
  });
6267
6442
  function Viz(config) {
6268
- const { isPrint, isEmbed } = useMode();
6443
+ const print = usePrint();
6269
6444
  const { block, active, locale, variables, configOverride = {} } = config;
6270
6445
  const content = getBlockContent(block);
6271
6446
  const formatterFunctions = useFormatterFunctionsForLocale(locale);
@@ -6294,8 +6469,8 @@ function Viz(config) {
6294
6469
  const Visualization = vizTypes[fallbackType];
6295
6470
  const vizPropsConfig = useMemo(() => {
6296
6471
  const { _data, ...vizPropsInnerConfig } = vizProps.config;
6297
- return printOverrides(vizPropsInnerConfig, isPrint || isEmbed);
6298
- }, [vizProps, isPrint, isEmbed]);
6472
+ return printOverrides(vizPropsInnerConfig, print);
6473
+ }, [vizProps, print]);
6299
6474
  const vizConfig = { locale, variables, ...vizPropsConfig, ...configOverride };
6300
6475
  return /* @__PURE__ */ jsx("div", { className: "bespoke-Viz", children: /* @__PURE__ */ jsx(
6301
6476
  "div",
@@ -15941,112 +16116,161 @@ var init_DataTab = __esm({
15941
16116
  };
15942
16117
  }
15943
16118
  });
15944
- function useLocalePrefix() {
15945
- const { locales: locales4 } = useRouter();
15946
- const locale = location && location.pathname.split("/").filter((segment) => segment.length > 0)[0];
15947
- return locales4?.includes(locale);
15948
- }
15949
- var init_useLocalePrefix = __esm({
15950
- "frontend/hooks/useLocalePrefix.ts"() {
15951
- init_esm_shims();
15952
- }
15953
- });
15954
16119
  function ImageTab(props) {
15955
16120
  const { section } = props;
15956
16121
  const blocksIds = section.blocks || [];
15957
- const { asPath, query, locale } = useRouter();
15958
- const prefixLocale = useLocalePrefix();
15959
- const { pathSegment } = useBespoke();
15960
16122
  const vizAvailable = useAppSelector((state) => blocksIds.map((blockId) => state.records.entities.block[blockId]).filter((block) => block.type === "visualization" && state.variables.status[block.id].allowed));
15961
16123
  const [imageContext, setImageContext] = useState(contextOptions.section);
15962
16124
  const [imageFormat, setImageFormat] = useState(formatOptions2.png);
15963
16125
  const [imageProcessing, setImageProcessing] = useState(false);
16126
+ const [svgAvailable, setSvgAvailable] = useState(false);
15964
16127
  const [vizPreviews, setVizPreviews] = useState([]);
15965
16128
  const [vizSelected, setVizSelected] = useState(vizAvailable.length > 0 ? vizAvailable[0].id : null);
15966
- const [transparentBackground, setTransparentBackground] = useState(false);
16129
+ const [transparentBackground, setTransparentBackground] = useState(true);
15967
16130
  const [loadingPreviews, setLoadingPreviews] = useState(false);
15968
16131
  const optionsTranslations = useBespokeTranslations("options");
15969
16132
  const translations = { ...DEFAULT_TRANSLATIONS3, ...optionsTranslations["image_tab"] };
15970
- const sectionId = slugify_default(section?.settings?.name) || `section-${section.id}`;
15971
- const onSaveClickSection = async () => {
15972
- const search = Object.fromEntries(new URLSearchParams(location.search));
15973
- const selectors = Object.fromEntries(
15974
- Object.entries(search).filter(([key]) => key.match(/selector\d+id/))
15975
- );
15976
- const body = {
15977
- path: asPath,
15978
- slugs: JSON.stringify(query[pathSegment]),
15979
- section: section.id,
15980
- query: selectors,
15981
- locale,
15982
- prefixLocale,
15983
- transparent: transparentBackground
15984
- };
15985
- setImageProcessing(true);
15986
- axios.post("/api/cms/img", body, { responseType: "blob" }).then((res) => {
15987
- const url = window.URL.createObjectURL(new Blob([res.data]));
16133
+ const { siteProps } = useBespoke();
16134
+ const includeLogo = siteProps?.logoSrc && typeof siteProps.logoSrc === "string";
16135
+ const sectionId = section?.settings?.name || `section-${section.id}`;
16136
+ const sectionHash = `#${sectionId}`;
16137
+ const theme = useMantineTheme();
16138
+ const vizSelectedHasSVG = () => {
16139
+ const vizNode = getVizNode(vizSelected);
16140
+ const svgCount = select(vizNode).select("svg").size();
16141
+ return svgCount === 1;
16142
+ };
16143
+ const getFileName = () => `${slugify_default(sectionId)}`;
16144
+ const getSectionNode = () => {
16145
+ const sectionNode = document.getElementById(sectionId);
16146
+ return select(sectionNode).select(".bespoke-section-content").node();
16147
+ };
16148
+ const getVizNode = (vizId) => {
16149
+ const sectionNode = getSectionNode();
16150
+ return select(sectionNode).select(`#bespoke-visualization-${vizId}.bespoke-block-area`).node();
16151
+ };
16152
+ const getSelectedNode = () => new Promise((resolve) => {
16153
+ let node;
16154
+ if (imageContext === contextOptions.section) {
16155
+ node = getSectionNode();
16156
+ } else if (imageContext === contextOptions.viz) {
16157
+ node = getVizNode(vizSelected);
16158
+ }
16159
+ const sourceContainer = document.createElement("div");
16160
+ sourceContainer.style.display = "flex";
16161
+ sourceContainer.style.justifyContent = "space-between";
16162
+ sourceContainer.classList.add("bespoke-Viz-source");
16163
+ sourceContainer.style.padding = theme.spacing.xs;
16164
+ sourceContainer.style.width = "100%";
16165
+ const sourceNode = document.createElement("div");
16166
+ sourceNode.innerText = translations["source"].replace("{src}", `${window.location}${sectionHash}`);
16167
+ sourceNode.style.fontSize = theme.fontSizes.xs;
16168
+ sourceContainer.appendChild(sourceNode);
16169
+ if (includeLogo) {
16170
+ const sourceImage = document.createElement("img");
16171
+ sourceImage.src = siteProps.logoSrc;
16172
+ sourceImage.style.height = "30px";
16173
+ sourceImage.onload = () => resolve(node);
16174
+ sourceImage.onerror = () => {
16175
+ sourceImage.remove();
16176
+ resolve(node);
16177
+ };
16178
+ sourceContainer.appendChild(sourceImage);
16179
+ node.appendChild(sourceContainer);
16180
+ } else {
16181
+ node.appendChild(sourceContainer);
16182
+ resolve(node);
16183
+ }
16184
+ });
16185
+ const getBackground = (elem) => {
16186
+ if (transparentBackground)
16187
+ return "transparent";
16188
+ const color = select(elem).style("background-color");
16189
+ if (color !== "rgba(0, 0, 0, 0)" && color !== "transparent")
16190
+ return color;
16191
+ if (elem === document.body)
16192
+ return "white";
16193
+ return getBackground(elem.parentNode);
16194
+ };
16195
+ const exportPng = async (node, config) => {
16196
+ const { toPng } = await import('html-to-image');
16197
+ toPng(
16198
+ node,
16199
+ {
16200
+ backgroundColor: config.background,
16201
+ cacheBust: true,
16202
+ filter: (innerNode) => {
16203
+ if (innerNode && innerNode.classList) {
16204
+ return !config.exclusionClasses.some((classname) => innerNode.classList.contains(classname));
16205
+ }
16206
+ return true;
16207
+ }
16208
+ }
16209
+ ).then((dataUrl) => {
15988
16210
  const link = document.createElement("a");
15989
- link.href = url;
15990
- link.setAttribute("download", "image.png");
15991
- document.body.appendChild(link);
16211
+ link.download = `${config.filename}.png`;
16212
+ link.href = dataUrl;
15992
16213
  link.click();
15993
- document.body.removeChild(link);
16214
+ cleanDOM();
15994
16215
  setImageProcessing(false);
16216
+ }).catch((err) => {
16217
+ console.log(err);
15995
16218
  });
15996
16219
  };
15997
- const onSaveClickViz = async () => {
15998
- const search = Object.fromEntries(new URLSearchParams(location.search));
15999
- const selectors = Object.fromEntries(
16000
- Object.entries(search).filter(([key]) => key.match(/selector\d+id/))
16220
+ const exportSvg = (node, config) => {
16221
+ saveElement(
16222
+ node,
16223
+ { filename: config.filename, type: "svg", callback: () => setImageProcessing(false) },
16224
+ { background: config.background }
16001
16225
  );
16002
- const body = {
16003
- path: asPath,
16004
- slugs: JSON.stringify(query[pathSegment]),
16005
- section: section.id,
16006
- viz: vizSelected,
16007
- query: selectors,
16008
- locale,
16009
- prefixLocale,
16010
- transparent: transparentBackground,
16011
- svg: imageFormat === formatOptions2.svg
16012
- };
16226
+ };
16227
+ const onSaveClick = async () => {
16013
16228
  setImageProcessing(true);
16014
- axios.post("/api/cms/img", body, { responseType: "blob" }).then((res) => {
16015
- const url = window.URL.createObjectURL(new Blob([res.data]));
16016
- const link = document.createElement("a");
16017
- link.href = url;
16018
- link.setAttribute("download", `image.${imageFormat.toLowerCase()}`);
16019
- document.body.appendChild(link);
16020
- link.click();
16021
- document.body.removeChild(link);
16229
+ const node = await getSelectedNode();
16230
+ const exportConfig = {
16231
+ background: getBackground(node),
16232
+ exclusionClasses: ["export-hidden"],
16233
+ filename: getFileName()
16234
+ };
16235
+ const exportFunction = imageFormat === formatOptions2.png ? exportPng : exportSvg;
16236
+ try {
16237
+ if (node) {
16238
+ exportFunction(node, exportConfig);
16239
+ } else {
16240
+ throw new Error(translations["wrong_node"]);
16241
+ }
16242
+ } catch (error) {
16022
16243
  setImageProcessing(false);
16023
- });
16244
+ }
16024
16245
  };
16025
16246
  const generatePreviews = async () => {
16026
16247
  const { toCanvas } = await import('html-to-image');
16027
16248
  Promise.all(
16028
- vizAvailable.map((viz) => toCanvas(getVizNode(viz.id, sectionId)))
16249
+ vizAvailable.map((viz) => toCanvas(getVizNode(viz.id)))
16029
16250
  ).then((canvases) => {
16030
16251
  setVizPreviews(canvases.map((canvas) => canvas.toDataURL()));
16031
16252
  setLoadingPreviews(false);
16032
16253
  });
16033
16254
  };
16034
- const handleContextChange = (newValue) => {
16035
- setImageContext(newValue);
16036
- if (newValue === contextOptions.section) {
16037
- setImageFormat(formatOptions2.png);
16038
- }
16039
- if (newValue === contextOptions.viz && vizAvailable.length > 0) {
16255
+ useEffect(() => {
16256
+ if (imageContext === contextOptions.viz && vizAvailable.length > 0) {
16040
16257
  setVizSelected(vizAvailable[0].id);
16041
16258
  setLoadingPreviews(true);
16042
16259
  generatePreviews();
16043
- } else if (newValue === contextOptions.section) {
16260
+ } else if (imageContext === contextOptions.section) {
16044
16261
  setVizPreviews([]);
16045
16262
  }
16046
- };
16047
- const onSelectViz = (vizId) => () => {
16048
- setVizSelected(vizId);
16049
- };
16263
+ }, [imageContext]);
16264
+ useEffect(() => {
16265
+ if (vizSelected) {
16266
+ if (vizSelectedHasSVG()) {
16267
+ setSvgAvailable(true);
16268
+ } else {
16269
+ setSvgAvailable(false);
16270
+ setImageFormat(formatOptions2.png);
16271
+ }
16272
+ }
16273
+ }, [vizSelected]);
16050
16274
  return /* @__PURE__ */ jsxs(Stack, { className: "cms-section-options-image", children: [
16051
16275
  /* @__PURE__ */ jsx(Space, { h: "xs" }),
16052
16276
  vizAvailable.length > 0 ? /* @__PURE__ */ jsx(Input.Wrapper, { label: `${translations["choose_area"]}:`, children: /* @__PURE__ */ jsx(
@@ -16070,7 +16294,12 @@ function ImageTab(props) {
16070
16294
  ] })
16071
16295
  }
16072
16296
  ],
16073
- onChange: handleContextChange
16297
+ onChange: (newValue) => {
16298
+ setImageContext(newValue);
16299
+ if (newValue === contextOptions.section) {
16300
+ setImageFormat(formatOptions2.png);
16301
+ }
16302
+ }
16074
16303
  }
16075
16304
  ) }) : /* @__PURE__ */ jsx(Text, { fw: "700", color: "gray.7", children: `${translations["entire_section"]}:` }),
16076
16305
  imageContext === contextOptions.viz && vizAvailable.length > 0 && /* @__PURE__ */ jsxs(
@@ -16080,20 +16309,27 @@ function ImageTab(props) {
16080
16309
  style: { minHeight: "161px", position: "relative" },
16081
16310
  children: [
16082
16311
  !loadingPreviews && vizPreviews.length > 0 && /* @__PURE__ */ jsx(ScrollArea, { style: { height: 250 }, children: /* @__PURE__ */ jsx(SimpleGrid, { cols: 3, children: vizAvailable.map((vizOption, ix) => /* @__PURE__ */ jsx(
16083
- VizPreview2,
16312
+ Image,
16084
16313
  {
16085
- vizId: vizOption.id,
16086
- isSelected: vizOption.id === vizSelected,
16087
- onClick: () => onSelectViz(vizAvailable[ix].id),
16088
- src: vizPreviews[ix]
16314
+ alt: `Viz ${vizOption.id}`,
16315
+ onClick: () => {
16316
+ setVizSelected(vizOption.id);
16317
+ },
16318
+ style: {
16319
+ cursor: "pointer",
16320
+ border: vizSelected === vizOption.id ? "4px solid #228be6" : "4px solid #eee"
16321
+ },
16322
+ radius: 0,
16323
+ src: vizPreviews[ix],
16324
+ withPlaceholder: true
16089
16325
  },
16090
- vizOption.id
16326
+ `viz-option-${vizOption.id}`
16091
16327
  )) }) }),
16092
16328
  /* @__PURE__ */ jsx(LoadingOverlay, { visible: loadingPreviews })
16093
16329
  ]
16094
16330
  }
16095
16331
  ),
16096
- imageContext !== contextOptions.section && /* @__PURE__ */ jsx(Input.Wrapper, { label: `${translations["choose_format"]}:`, children: /* @__PURE__ */ jsxs(Button.Group, { children: [
16332
+ svgAvailable && imageContext !== contextOptions.section && /* @__PURE__ */ jsx(Input.Wrapper, { label: `${translations["choose_format"]}:`, children: /* @__PURE__ */ jsxs(Button.Group, { children: [
16097
16333
  /* @__PURE__ */ jsx(
16098
16334
  Button,
16099
16335
  {
@@ -16115,7 +16351,7 @@ function ImageTab(props) {
16115
16351
  }
16116
16352
  )
16117
16353
  ] }) }),
16118
- imageFormat !== formatOptions2.svg && /* @__PURE__ */ jsx(
16354
+ /* @__PURE__ */ jsx(
16119
16355
  Checkbox,
16120
16356
  {
16121
16357
  checked: transparentBackground,
@@ -16129,14 +16365,14 @@ function ImageTab(props) {
16129
16365
  {
16130
16366
  leftIcon: /* @__PURE__ */ jsx(IconDownload, { size: 16 }),
16131
16367
  loading: imageProcessing,
16132
- onClick: imageContext === contextOptions.section ? onSaveClickSection : onSaveClickViz,
16368
+ onClick: onSaveClick,
16133
16369
  fullWidth: true,
16134
16370
  children: /* @__PURE__ */ jsx("span", { children: imageProcessing ? translations["processing"] : translations["download"].replace("{imageFormat}", imageFormat) })
16135
16371
  }
16136
16372
  )
16137
16373
  ] });
16138
16374
  }
16139
- var contextOptions, formatOptions2, VizPreview2, DEFAULT_TRANSLATIONS3, getSectionNode, getVizNode;
16375
+ var contextOptions, formatOptions2, cleanDOM, DEFAULT_TRANSLATIONS3;
16140
16376
  var init_ImageTab = __esm({
16141
16377
  "components/options/tabs/ImageTab.tsx"() {
16142
16378
  init_esm_shims();
@@ -16144,11 +16380,6 @@ var init_ImageTab = __esm({
16144
16380
  init_store2();
16145
16381
  init_TranslationsProvider();
16146
16382
  init_ResourceProvider();
16147
- init_useLocalePrefix();
16148
- init_d3plusPropify();
16149
- init_varSwapRecursive();
16150
- init_getBlockContent();
16151
- init_hooks();
16152
16383
  contextOptions = {
16153
16384
  viz: "viz",
16154
16385
  section: "section"
@@ -16157,50 +16388,9 @@ var init_ImageTab = __esm({
16157
16388
  png: "PNG",
16158
16389
  svg: "SVG"
16159
16390
  };
16160
- VizPreview2 = ({ vizId, isSelected = false, onClick = () => void 0, src = void 0 }) => {
16161
- const router = useRouter();
16162
- const { locale } = router;
16163
- const variables = useInputVariablesFlat(vizId);
16164
- const block = useBlockRef(vizId).data;
16165
- const content = getBlockContent(block);
16166
- const formatterFunctions = useFormatterFunctionsForLocale(locale);
16167
- const blockContext = { variables };
16168
- const transpiledLogic = varSwapRecursive_default({ logic: content.logic }, formatterFunctions, blockContext).logic;
16169
- const globals = {
16170
- router
16171
- };
16172
- const props = d3plusPropify_default(transpiledLogic, formatterFunctions, variables, locale, vizId, {}, globals);
16173
- const { title } = props.config;
16174
- return /* @__PURE__ */ jsxs(Stack, { align: "center", spacing: "xs", children: [
16175
- /* @__PURE__ */ jsx(
16176
- Image,
16177
- {
16178
- alt: `Viz ${vizId}`,
16179
- onClick,
16180
- style: {
16181
- cursor: "pointer",
16182
- border: isSelected ? "4px solid #228be6" : "4px solid #eee"
16183
- },
16184
- radius: 0,
16185
- src,
16186
- withPlaceholder: true
16187
- },
16188
- `viz-option-${vizId}`
16189
- ),
16190
- title && /* @__PURE__ */ jsx(
16191
- Text,
16192
- {
16193
- fz: "0.8rem",
16194
- fw: 700,
16195
- bg: isSelected ? "rgba(0, 0, 0, 0.2)" : "transparent",
16196
- w: "fit-content",
16197
- px: "xs",
16198
- sx: { borderRadius: "0.3rem" },
16199
- ta: "center",
16200
- children: title
16201
- }
16202
- )
16203
- ] });
16391
+ cleanDOM = () => {
16392
+ const sourceNodes = document.getElementsByClassName("bespoke-Viz-source");
16393
+ Array.from(sourceNodes).forEach((node) => node.remove());
16204
16394
  };
16205
16395
  DEFAULT_TRANSLATIONS3 = {
16206
16396
  "wrong_node": "Wrong node in export",
@@ -16214,15 +16404,6 @@ var init_ImageTab = __esm({
16214
16404
  "viz_only": "Visualization only",
16215
16405
  "source": "Source: {src}"
16216
16406
  };
16217
- getSectionNode = (sectionId) => {
16218
- console.log({ sectionId });
16219
- const sectionNode = document.getElementById(sectionId);
16220
- return select(sectionNode).select(".bespoke-section-content").node();
16221
- };
16222
- getVizNode = (vizId, sectionId) => {
16223
- const sectionNode = getSectionNode(sectionId);
16224
- return select(sectionNode).select(`#bespoke-visualization-${vizId}.bespoke-block-area`).node();
16225
- };
16226
16407
  }
16227
16408
  });
16228
16409
  function CopyInput(props) {
@@ -16244,31 +16425,12 @@ var init_CopyInput = __esm({
16244
16425
  init_esm_shims();
16245
16426
  }
16246
16427
  });
16247
- function useEmbedPath(sectionId) {
16248
- const { query, locale } = useRouter();
16249
- const prefixLocale = useLocalePrefix();
16250
- const { pathSegment } = useBespoke();
16251
- const slugs = query[pathSegment];
16252
- if (slugs && Array.isArray(slugs)) {
16253
- const search = new URLSearchParams({ section: sectionId });
16254
- const embed = `/embed/${slugs.join("/")}`;
16255
- const url = new URL(
16256
- prefixLocale ? `/${locale}${embed}` : `${embed}`,
16257
- location.href
16258
- );
16259
- url.search = search.toString();
16260
- return url.href;
16261
- }
16262
- return void 0;
16263
- }
16264
16428
  function ShareTab(props) {
16265
16429
  const { section } = props;
16266
16430
  const [shareUrl, setShareUrl] = useState("");
16267
16431
  const [title, setTitle] = useState("");
16268
16432
  const [includeSection, setIncludeSection] = useState(true);
16269
16433
  const optionsTranslations = useBespokeTranslations("options");
16270
- const embedPath = useEmbedPath(section.id);
16271
- const iframeStr = `<iframe width="100%" height="500px" frameborder="0" src="${embedPath}"></iframe>`;
16272
16434
  const translations = { ...DEFAULT_TRANSLATIONS4, ...optionsTranslations["share_tab"] };
16273
16435
  useEffect(() => {
16274
16436
  setTitle(document.title);
@@ -16289,7 +16451,6 @@ function ShareTab(props) {
16289
16451
  radius: "xl"
16290
16452
  }
16291
16453
  ),
16292
- /* @__PURE__ */ jsx(CopyInput, { title: translations["embed"], url: iframeStr }),
16293
16454
  /* @__PURE__ */ jsxs(Group, { position: "center", children: [
16294
16455
  /* @__PURE__ */ jsx(
16295
16456
  FacebookShareButton,
@@ -16352,12 +16513,9 @@ var init_ShareTab = __esm({
16352
16513
  init_esm_shims();
16353
16514
  init_CopyInput();
16354
16515
  init_TranslationsProvider();
16355
- init_useLocalePrefix();
16356
- init_ResourceProvider();
16357
16516
  DEFAULT_TRANSLATIONS4 = {
16358
16517
  "title": "Title",
16359
- "include_section": "Include Section",
16360
- "embed": "Embed"
16518
+ "include_section": "Include Section"
16361
16519
  };
16362
16520
  }
16363
16521
  });
@@ -17157,7 +17315,7 @@ var init_site = __esm({
17157
17315
  }
17158
17316
  });
17159
17317
  function ImageCredits({ previews, translations }) {
17160
- const { isPrint } = useMode();
17318
+ const print = usePrint();
17161
17319
  const credits = useMemo(() => previews.map(
17162
17320
  ({ image, name }, idx) => (image?.author || image?.url) && /* @__PURE__ */ jsxs(Stack, { spacing: 0, children: [
17163
17321
  image.author && /* @__PURE__ */ jsxs(Text, { size: "xs", children: [
@@ -17182,7 +17340,7 @@ function ImageCredits({ previews, translations }) {
17182
17340
  idx + 1 < previews.length && /* @__PURE__ */ jsx(Divider, {})
17183
17341
  ] }, image.id)
17184
17342
  ), [previews]);
17185
- return /* @__PURE__ */ jsx(Fragment, { children: isPrint ? /* @__PURE__ */ jsx(Fragment, { children: credits }) : /* @__PURE__ */ jsxs(Popover, { position: "right", children: [
17343
+ return /* @__PURE__ */ jsx(Fragment, { children: print ? /* @__PURE__ */ jsx(Fragment, { children: credits }) : /* @__PURE__ */ jsxs(Popover, { position: "right", children: [
17186
17344
  /* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "light", radius: "xl", children: /* @__PURE__ */ jsx(IconPhoto, { size: 20 }) }) }),
17187
17345
  /* @__PURE__ */ jsx(Popover.Dropdown, { children: credits })
17188
17346
  ] }) });
@@ -17202,7 +17360,7 @@ function SectionWrapper({
17202
17360
  previews,
17203
17361
  translations
17204
17362
  }) {
17205
- const { isPrint, isEmbed } = useMode();
17363
+ const print = usePrint();
17206
17364
  const showCredits = sectionSettings2.memberImageBg && previews.some(({ image }) => image && (image.url || image.author));
17207
17365
  return /* @__PURE__ */ jsxs(
17208
17366
  PositionWrapper,
@@ -17218,12 +17376,12 @@ function SectionWrapper({
17218
17376
  className: `bespoke-Section-${id} bespoke-Section-container `,
17219
17377
  settings: sectionSettings2,
17220
17378
  styles: sectionStyles?.container,
17221
- id: slugify_default(name) || `section-${id}`,
17379
+ id: name || `section-${id}`,
17222
17380
  pos: "relative",
17223
17381
  children: [
17224
- !isPrint && /* @__PURE__ */ jsxs(Group, { position: "right", mb: "xs", children: [
17382
+ !print && /* @__PURE__ */ jsxs(Group, { position: "right", mb: "xs", children: [
17225
17383
  /* @__PURE__ */ jsx(SectionResetButton, { id }),
17226
- sectionSettings2.optionsMenu && !isEmbed && /* @__PURE__ */ jsx(Options, { sectionId: id, disabled: false })
17384
+ sectionSettings2.optionsMenu && /* @__PURE__ */ jsx(Options, { sectionId: id, disabled: false })
17227
17385
  ] }),
17228
17386
  /* @__PURE__ */ jsxs(
17229
17387
  StyleWrapper,
@@ -17250,21 +17408,14 @@ function Section({ section }) {
17250
17408
  ...defaultSectionSettings,
17251
17409
  ...settings
17252
17410
  };
17253
- const { query } = useRouter();
17254
17411
  const comparison = useComparison();
17255
- const { isEmbed } = useMode();
17256
17412
  const state = useAppSelector((state2) => state2);
17257
17413
  const status = useAppSelector((state2) => state2.variables.status);
17258
17414
  const previews = useAppSelector((state2) => state2.status.previews);
17259
17415
  const comparisonPreviews = comparison.active && comparison.status ? previews.concat(comparison.status?.previews || []) : previews;
17260
17416
  const sectionStyles = useBespokeStyles()["Section"];
17261
17417
  const blockRecords = selectBlockRecords(state);
17262
- let sectionBlocks = [];
17263
- if (isEmbed && query.viz) {
17264
- sectionBlocks = Object.values(blockRecords || {}).filter((d2) => d2.section_id === id && d2.id === Number(query.viz));
17265
- } else {
17266
- sectionBlocks = Object.values(blockRecords || {}).filter((d2) => d2.section_id === id);
17267
- }
17418
+ const sectionBlocks = Object.values(blockRecords || {}).filter((d2) => d2.section_id === id);
17268
17419
  const sectionTranslations = useBespokeTranslations("sections");
17269
17420
  const translations = { ...DEFAULT_TRANSLATIONS6, ...sectionTranslations };
17270
17421
  const allowedSection = sectionBlocks.some((b2) => {
@@ -17372,7 +17523,7 @@ function Section({ section }) {
17372
17523
  );
17373
17524
  });
17374
17525
  }
17375
- return /* @__PURE__ */ jsxs(
17526
+ return /* @__PURE__ */ jsx(
17376
17527
  SectionWrapper,
17377
17528
  {
17378
17529
  id,
@@ -17381,24 +17532,21 @@ function Section({ section }) {
17381
17532
  sectionSettings: sectionSettings2,
17382
17533
  sectionStyles,
17383
17534
  translations,
17384
- children: [
17385
- /* @__PURE__ */ jsx(
17386
- ColumnsWrapper,
17387
- {
17388
- containerProps: {
17389
- gap: sectionSettings2.columnGutter || "md",
17390
- wrap: comparison.active ? "nowrap" : "wrap",
17391
- sx: { zIndex: 20 }
17392
- },
17393
- children: sectionColumns
17394
- }
17395
- ),
17396
- isEmbed && /* @__PURE__ */ jsx(EmbedSectionSrc, {})
17397
- ]
17535
+ children: /* @__PURE__ */ jsx(
17536
+ ColumnsWrapper,
17537
+ {
17538
+ containerProps: {
17539
+ gap: sectionSettings2.columnGutter || "md",
17540
+ wrap: comparison.active ? "nowrap" : "wrap",
17541
+ sx: { zIndex: 20 }
17542
+ },
17543
+ children: sectionColumns
17544
+ }
17545
+ )
17398
17546
  }
17399
17547
  );
17400
17548
  }
17401
- var DEFAULT_TRANSLATIONS6, getStyles, PositionWrapper, WidthWrapper, StyleWrapper, EmbedSectionSrc, Section_default;
17549
+ var DEFAULT_TRANSLATIONS6, getStyles, PositionWrapper, WidthWrapper, StyleWrapper, Section_default;
17402
17550
  var init_Section = __esm({
17403
17551
  "frontend/components/report/Section.tsx"() {
17404
17552
  init_esm_shims();
@@ -17419,9 +17567,6 @@ var init_Section = __esm({
17419
17567
  init_TranslationsProvider();
17420
17568
  init_ImageCredits();
17421
17569
  init_ComparisonProvider();
17422
- init_ResourceProvider();
17423
- init_useLocalePrefix();
17424
- init_slugify();
17425
17570
  DEFAULT_TRANSLATIONS6 = {
17426
17571
  "image_by": "image by"
17427
17572
  };
@@ -17482,56 +17627,18 @@ var init_Section = __esm({
17482
17627
  const sx = [defaultStyles[variant], getStyles(styles, settings)];
17483
17628
  return /* @__PURE__ */ jsx(Paper, { sx, ...defaultProps2[variant], ...props, children });
17484
17629
  };
17485
- EmbedSectionSrc = () => {
17486
- const router = useRouter();
17487
- const { query, locale } = router;
17488
- const { siteProps, profilePrefix, pathSegment } = useBespoke();
17489
- const querySlugs = query[pathSegment];
17490
- const slugs = Array.isArray(querySlugs) ? querySlugs?.join("/") : [];
17491
- const prefixLocale = useLocalePrefix();
17492
- let path = prefixLocale ? `/${locale}` : "";
17493
- path += `/${profilePrefix}/${slugs}/`;
17494
- const link = new URL(path, window?.location.href).href;
17495
- return /* @__PURE__ */ jsxs(Group, { position: "apart", noWrap: true, sx: { flexGrow: 1 }, children: [
17496
- /* @__PURE__ */ jsx(Anchor, { href: link, target: "_blank", children: link }),
17497
- /* @__PURE__ */ jsx(
17498
- "img",
17499
- {
17500
- src: siteProps.logoSrc,
17501
- width: "auto",
17502
- height: 40,
17503
- alt: "Site Logo"
17504
- }
17505
- )
17506
- ] });
17507
- };
17508
17630
  Section_default = Section;
17509
17631
  }
17510
17632
  });
17511
- function useMode() {
17512
- const mode = useContext(ModeContext);
17513
- return {
17514
- mode,
17515
- isPrint: mode === MODES.print,
17516
- isEmbed: mode === MODES.embed,
17517
- isReport: mode === MODES.report
17518
- };
17633
+ function usePrint() {
17634
+ return useContext(PrintContext);
17519
17635
  }
17520
- function Report({ pathSegmentsKey = "bespoke", mode = "report" }) {
17521
- const router = useRouter();
17522
- const { asPath, query } = router;
17636
+ function Report({ pathSegmentsKey = "bespoke" }) {
17637
+ const { asPath, query } = useRouter();
17523
17638
  const sectionList = useSectionList();
17524
17639
  const comparison = useComparison();
17525
- const [reportMode, setReportMode] = useState(mode);
17526
- useEffect(() => {
17527
- if (router.isReady) {
17528
- const { mode: mode2 } = router.query;
17529
- if (mode2 && typeof mode2 === "string" && Object.values(MODES).includes(mode2)) {
17530
- setReportMode(mode2);
17531
- }
17532
- }
17533
- }, [router.isReady, router.query]);
17534
- const printBtn = yn4(router.query.printBtn) ?? false;
17640
+ const print = yn4(query.print) ?? false;
17641
+ const printBtn = yn4(query.printBtn) ?? false;
17535
17642
  const [downloadLoading, setDownloadLoading] = useState(false);
17536
17643
  const printReport = () => {
17537
17644
  setDownloadLoading(true);
@@ -17546,8 +17653,8 @@ function Report({ pathSegmentsKey = "bespoke", mode = "report" }) {
17546
17653
  });
17547
17654
  };
17548
17655
  useScrollToAnchor();
17549
- return /* @__PURE__ */ jsxs(ModeContext.Provider, { value: reportMode, children: [
17550
- mode === MODES.print && /* @__PURE__ */ jsx(MediaQuery, { query: "print", styles: { display: "block" }, children: /* @__PURE__ */ jsx(Title, { display: "none", children: "This is the report header" }) }),
17656
+ return /* @__PURE__ */ jsxs(PrintContext.Provider, { value: print, children: [
17657
+ print && /* @__PURE__ */ jsx(MediaQuery, { query: "print", styles: { display: "block" }, children: /* @__PURE__ */ jsx(Title, { display: "none", children: "This is the report header" }) }),
17551
17658
  /* @__PURE__ */ jsxs(Container, { id: "bespoke-report", className: comparison.comparisonLoaded ? "compare" : "", p: 0, pos: "relative", fluid: true, children: [
17552
17659
  sectionList.isSuccess && sectionList.data.sort(orderSort).map((section) => /* @__PURE__ */ jsx(Section_default, { section }, section.id)),
17553
17660
  /*pdf.active*/
@@ -17555,7 +17662,7 @@ function Report({ pathSegmentsKey = "bespoke", mode = "report" }) {
17555
17662
  ] })
17556
17663
  ] });
17557
17664
  }
17558
- var MODES, ModeContext, Report_default;
17665
+ var PrintContext, Report_default;
17559
17666
  var init_Report = __esm({
17560
17667
  "frontend/components/report/Report.tsx"() {
17561
17668
  init_esm_shims();
@@ -17564,12 +17671,7 @@ var init_Report = __esm({
17564
17671
  init_Section();
17565
17672
  init_ComparisonProvider();
17566
17673
  init_useScrollToAnchor();
17567
- MODES = {
17568
- report: "report",
17569
- print: "print",
17570
- embed: "embed"
17571
- };
17572
- ModeContext = createContext("report");
17674
+ PrintContext = createContext(false);
17573
17675
  Report_default = Report;
17574
17676
  }
17575
17677
  });
@@ -17694,6 +17796,9 @@ var LoginButton_default = BespokeLoginBtn;
17694
17796
  init_esm_shims();
17695
17797
  var UserProvider_default = UserProvider;
17696
17798
 
17799
+ // frontend/index.ts
17800
+ init_ExploreProvider();
17801
+
17697
17802
  // frontend/components/auth/withPageRoleAuthRequired.tsx
17698
17803
  init_esm_shims();
17699
17804
  function withPageRoleAuthRequired(params) {
@@ -18019,7 +18124,8 @@ function parseSearchMemberParams(query) {
18019
18124
  report,
18020
18125
  all: localeIsAll,
18021
18126
  sort: normalizeList(query.sort)[0],
18022
- direction: normalizeList(query.direction)[0]
18127
+ direction: normalizeList(query.direction)[0],
18128
+ offset: Number(query.offset || 0)
18023
18129
  };
18024
18130
  }
18025
18131
 
@@ -18280,7 +18386,7 @@ function VariantSelector(props) {
18280
18386
  const showAsLabel = variantsData.length === 1 || !active;
18281
18387
  const [_variant, setVariant] = useUncontrolled({
18282
18388
  value: value ? String(value) : void 0,
18283
- defaultValue: variantsData[0].value,
18389
+ defaultValue: variantsData[0] ? variantsData[0].value : "",
18284
18390
  finalValue: void 0,
18285
18391
  onChange: onChange ? (v2) => onChange(Number(v2)) : void 0
18286
18392
  });
@@ -18291,7 +18397,7 @@ function VariantSelector(props) {
18291
18397
  {
18292
18398
  onClick: () => setActive(true),
18293
18399
  clickable: variantsData.length > 1,
18294
- children: displayValue.label
18400
+ children: displayValue ? displayValue.label : "No Variant"
18295
18401
  }
18296
18402
  ) : /* @__PURE__ */ jsx(
18297
18403
  Select,
@@ -18319,7 +18425,7 @@ function DimensionAutocomplete(props) {
18319
18425
  const [_variant, setVariant] = useUncontrolled({
18320
18426
  value: void 0,
18321
18427
  defaultValue: value?.variantId,
18322
- finalValue: Number(variantsData[0].value),
18428
+ finalValue: variantsData[0] ? Number(variantsData[0].value) : 0,
18323
18429
  onChange: () => {
18324
18430
  setMember({});
18325
18431
  }
@@ -18696,6 +18802,18 @@ init_esm_shims();
18696
18802
  init_EntityDeleteButton();
18697
18803
  init_Dialog();
18698
18804
  init_store2();
18805
+
18806
+ // libs/settings/variant.tsx
18807
+ init_esm_shims();
18808
+ var getVariantSettingsDefaults = (settings) => ({
18809
+ overrideNames: settings && typeof settings.overrideNames !== "undefined" ? settings.overrideNames : false,
18810
+ overrideRelevance: settings && typeof settings.overrideRelevance !== "undefined" ? settings.overrideRelevance : false,
18811
+ regenerateSlugs: settings && typeof settings.regenerateSlugs !== "undefined" ? settings.regenerateSlugs : false,
18812
+ keepOldMembers: settings && typeof settings.keepOldMembers !== "undefined" ? settings.keepOldMembers : true,
18813
+ doIngest: settings && typeof settings.doIngest !== "undefined" ? settings.doIngest : false,
18814
+ overrideAttributes: settings && typeof settings.overrideAttributes !== "undefined" ? settings.overrideAttributes : false,
18815
+ order: settings && typeof settings.order !== "undefined" ? settings.order : 0
18816
+ });
18699
18817
  function VariantCard({ for: variant, onEdit }) {
18700
18818
  const theme = useMantineTheme();
18701
18819
  const { newConfirmation } = useDialog();
@@ -18712,13 +18830,18 @@ function VariantCard({ for: variant, onEdit }) {
18712
18830
  console.debug("Variant edition aborted.");
18713
18831
  }
18714
18832
  }, [onEdit]);
18715
- const { slug, name } = variant;
18833
+ const { slug, name, settings } = variant;
18834
+ const variantSettings = getVariantSettingsDefaults(settings);
18716
18835
  return /* @__PURE__ */ jsxs(Card, { shadow: "xs", withBorder: true, style: { margin: theme.spacing.sm }, children: [
18717
18836
  /* @__PURE__ */ jsxs(Group, { position: "apart", children: [
18718
18837
  /* @__PURE__ */ jsxs(Center, { children: [
18719
18838
  /* @__PURE__ */ jsx(IconServer, { size: 22 }),
18720
18839
  /* @__PURE__ */ jsx(Space, { w: "xs" }),
18721
- /* @__PURE__ */ jsx(Text, { weight: "bold", children: name })
18840
+ /* @__PURE__ */ jsx(Text, { weight: "bold", children: name }),
18841
+ /* @__PURE__ */ jsxs(Text, { size: "xs", ml: "xs", children: [
18842
+ "Order: ",
18843
+ variantSettings.order
18844
+ ] })
18722
18845
  ] }),
18723
18846
  /* @__PURE__ */ jsxs(Badge, { variant: "light", children: [
18724
18847
  "/",
@@ -18979,17 +19102,6 @@ function MembersTable({ members, onClickEdit, onSort, colsToRender = [], dataTab
18979
19102
  );
18980
19103
  }
18981
19104
 
18982
- // libs/settings/variant.tsx
18983
- init_esm_shims();
18984
- var getVariantSettingsDefaults = (settings) => ({
18985
- overrideNames: settings && typeof settings.overrideNames !== "undefined" ? settings.overrideNames : false,
18986
- overrideRelevance: settings && typeof settings.overrideRelevance !== "undefined" ? settings.overrideRelevance : false,
18987
- regenerateSlugs: settings && typeof settings.regenerateSlugs !== "undefined" ? settings.regenerateSlugs : false,
18988
- keepOldMembers: settings && typeof settings.keepOldMembers !== "undefined" ? settings.keepOldMembers : true,
18989
- doIngest: settings && typeof settings.doIngest !== "undefined" ? settings.doIngest : false,
18990
- overrideAttributes: settings && typeof settings.overrideAttributes !== "undefined" ? settings.overrideAttributes : false
18991
- });
18992
-
18993
19105
  // components/builder/components/SwitchWithTooltip.tsx
18994
19106
  init_esm_shims();
18995
19107
  function SwitchWithTooltip({ switchProps, yesText, noText }) {
@@ -19274,6 +19386,7 @@ function VariantEditor({ for: variant, onClose: closeHandler }) {
19274
19386
  };
19275
19387
  const onSubmit = () => {
19276
19388
  setLoading(true);
19389
+ console.log(variantConfig.settings);
19277
19390
  dispatch(actions_exports.updateEntity("variant", variantConfig)).then(() => {
19278
19391
  setLoading(false);
19279
19392
  closeHandler();
@@ -19377,6 +19490,19 @@ function VariantEditor({ for: variant, onClose: closeHandler }) {
19377
19490
  ] }) : false,
19378
19491
  onChange: (e) => onChange("slug", e.target.value)
19379
19492
  }
19493
+ ),
19494
+ /* @__PURE__ */ jsx(Space, { h: "xs" }),
19495
+ /* @__PURE__ */ jsx(
19496
+ NumberInput,
19497
+ {
19498
+ value: variantSettings.order || 0,
19499
+ description: "It affects on explore options order",
19500
+ placeholder: "Order",
19501
+ label: "Order",
19502
+ onChange: (v2) => {
19503
+ onChangeSettings("order", v2);
19504
+ }
19505
+ }
19380
19506
  )
19381
19507
  ] }),
19382
19508
  /* @__PURE__ */ jsxs(Tabs.Panel, { value: "members", py: "md", children: [
@@ -19732,11 +19858,23 @@ function ReportEditor({ id, onClose: closeHandler }) {
19732
19858
  const onChange = useCallback((field, value) => {
19733
19859
  setConfig({ ...config, [field]: value });
19734
19860
  }, []);
19861
+ const onChangeSettings = (field, value) => {
19862
+ setConfig({
19863
+ ...config,
19864
+ //config: configUpdate,
19865
+ settings: {
19866
+ ...config.settings,
19867
+ [field]: value
19868
+ }
19869
+ });
19870
+ };
19735
19871
  if (isEditing) {
19736
19872
  return /* @__PURE__ */ jsx(DimensionEditor, { id: isEditing, onClose: () => setEditing(null) });
19737
19873
  }
19738
19874
  const loading = ref.isFetching;
19739
19875
  const dimensions = ref.isSuccess ? ref.data.dimensions : [];
19876
+ const settings = config.settings;
19877
+ const order2 = settings && settings.order ? settings.order : 0;
19740
19878
  return /* @__PURE__ */ jsx(
19741
19879
  DrawerContentWithScroll,
19742
19880
  {
@@ -19751,7 +19889,20 @@ function ReportEditor({ id, onClose: closeHandler }) {
19751
19889
  onChange: (e) => onChange("name", e.target.value)
19752
19890
  }
19753
19891
  ),
19754
- /* @__PURE__ */ jsx(Divider, { my: "xl" }),
19892
+ /* @__PURE__ */ jsx(Divider, { my: "sm" }),
19893
+ /* @__PURE__ */ jsx(
19894
+ NumberInput,
19895
+ {
19896
+ value: order2 || 0,
19897
+ description: "It affects on explore options order",
19898
+ placeholder: "Order",
19899
+ label: "Order",
19900
+ onChange: (v2) => {
19901
+ onChangeSettings("order", v2);
19902
+ }
19903
+ }
19904
+ ),
19905
+ /* @__PURE__ */ jsx(Divider, { my: "sm" }),
19755
19906
  /* @__PURE__ */ jsx(IconTitle, { icon: /* @__PURE__ */ jsx(IconDatabase, { size: 22 }), children: /* @__PURE__ */ jsx(Title, { order: 2, size: "h4", children: "Dimensions" }) }),
19756
19907
  /* @__PURE__ */ jsx(Grid, { children: dimensions.map((d2) => /* @__PURE__ */ jsx(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx(DimensionCardWithFetcher, { id: d2, onEdit: setEditing }) }, d2)) }),
19757
19908
  /* @__PURE__ */ jsx(
@@ -25806,16 +25957,15 @@ function BespokeRenderer({
25806
25957
  siteProps,
25807
25958
  profilePrefix = "/defaultPath",
25808
25959
  loader = /* @__PURE__ */ jsx(LoadingOverlay, { visible: true }),
25809
- mode = "report",
25810
25960
  mantineProviderProps = {}
25811
25961
  }) {
25812
- const loading = useInitialState(pathSegmentsKey, mode);
25962
+ const loading = useInitialState(pathSegmentsKey);
25813
25963
  if (loading)
25814
25964
  return /* @__PURE__ */ jsx(Fragment, { children: loader });
25815
- return /* @__PURE__ */ jsx(MantineProvider, { ...mantineProviderProps, theme: { other: { bespokeStyles } }, inherit: true, children: /* @__PURE__ */ jsxs(ResourceProvider, { pathSegment: pathSegmentsKey, profilePrefix, siteProps, children: [
25816
- /* @__PURE__ */ jsx(TranslationsProvider, { translations, children: /* @__PURE__ */ jsx(ComparisonProvider, { children: /* @__PURE__ */ jsx(PdfProvider, { children: /* @__PURE__ */ jsx(Report_default, { pathSegmentsKey, mode }) }) }) }),
25817
- /* @__PURE__ */ jsx("small", { className: "bespoke-timestamp", hidden: true, children: buildTime })
25965
+ return /* @__PURE__ */ jsx(MantineProvider, { ...mantineProviderProps, theme: { other: { bespokeStyles } }, inherit: true, children: /* @__PURE__ */ jsxs(ResourceProvider, { pathSegment: "bespoke", profilePrefix, siteProps, children: [
25966
+ /* @__PURE__ */ jsx(TranslationsProvider, { translations, children: /* @__PURE__ */ jsx(ComparisonProvider, { children: /* @__PURE__ */ jsx(PdfProvider, { children: /* @__PURE__ */ jsx(Report_default, {}) }) }) }),
25967
+ /* @__PURE__ */ jsx("small", { className: "bespoke-timestamp", children: buildTime })
25818
25968
  ] }) });
25819
25969
  }
25820
25970
 
25821
- export { Explore_default as BespokeExplore, ExploreModal_default as BespokeExploreModal, LoginButton_default as BespokeLoginBtn, BespokeManager, BespokeRenderer, Report_default as BespokeReport, Search_default as BespokeSearch, UserProvider_default as BespokeUserProvider, withPageRoleAuthRequired as BespokeWithPageRoleAuthRequired, CMS_ROLES, DialogProvider, actions_exports as actions, storeWrapper, useAppDispatch as useBespokeDispatch, useAppSelector as useBespokeSelector, useUser_default as useBespokeUser, useDialog };
25971
+ export { Explore_default as BespokeExplore, ExploreModal_default as BespokeExploreModal, ExploreProvider as BespokeExploreProvider, LoginButton_default as BespokeLoginBtn, BespokeManager, BespokeRenderer, Report_default as BespokeReport, Search_default as BespokeSearch, UserProvider_default as BespokeUserProvider, withPageRoleAuthRequired as BespokeWithPageRoleAuthRequired, CMS_ROLES, DialogProvider, actions_exports as actions, storeWrapper, useAppDispatch as useBespokeDispatch, useExplore as useBespokeExplore, useAppSelector as useBespokeSelector, useUser_default as useBespokeUser, useDialog };