@uniformdev/mesh-sdk-react 17.7.1-alpha.34 → 18.0.1-alpha.3

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/index.js CHANGED
@@ -1,4 +1,451 @@
1
- "use strict";var dn=Object.create;var dt=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var un=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var Ua=(e,t)=>{for(var r in t)dt(e,r,{get:t[r],enumerable:!0})},lt=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pn(t))!mn.call(e,o)&&o!==r&&dt(e,o,{get:()=>t[o],enumerable:!(a=cn(t,o))||a.enumerable});return e},se=(e,t,r)=>(lt(e,t,"default"),r&&lt(r,t,"default")),le=(e,t,r)=>(r=e!=null?dn(un(e)):{},lt(t||!e||!e.__esModule?dt(r,"default",{value:e,enumerable:!0}):r,e)),gn=e=>lt(dt({},"__esModule",{value:!0}),e);var ne={};Ua(ne,{AddListButton:()=>h.AddListButton,Button:()=>h.Button,Callout:()=>h.Callout,DamSelectedItem:()=>En,DataResourceVariablesList:()=>An,DataSourceEditor:()=>Wn,DataTypeEditor:()=>Qn,DefaultSearchRow:()=>gr,DefaultSelectedItem:()=>Rr,EntrySearch:()=>qr,Heading:()=>h.Heading,Icons:()=>ft,Input:()=>h.Input,InputComboBox:()=>h.InputComboBox,InputKeywordSearch:()=>h.InputKeywordSearch,InputSelect:()=>h.InputSelect,InputToggle:()=>h.InputToggle,InputVariables:()=>va,KeywordSearchInput:()=>h.InputKeywordSearch,Label:()=>h.Label,LoadingIndicator:()=>h.LoadingIndicator,LoadingOverlay:()=>h.LoadingOverlay,Menu:()=>h.Menu,MenuItem:()=>h.MenuItem,MeshApp:()=>Zn,ProductPreviewList:()=>nr,ProductQuery:()=>Vn,ProductQueryContext:()=>ar,ProductSearch:()=>In,ProductSearchContext:()=>jr,ProductSearchRow:()=>$r,ProductSelectedItem:()=>Jr,RequestBody:()=>On,RequestHeaders:()=>Gn,RequestMethodSelect:()=>Hn,RequestParameters:()=>Nn,RequestProvider:()=>it,RequestTypeContainer:()=>xa,RequestUrl:()=>Fn,RequestUrlInput:()=>$n,ResolvableLoadingValue:()=>tr,ScrollableList:()=>h.ScrollableList,ScrollableListItem:()=>h.ScrollableListItem,SelectionField:()=>rr,Switch:()=>h.Switch,TextVariableRenderer:()=>ha,Textarea:()=>h.Textarea,Theme:()=>h.Theme,UniformMeshLocationContext:()=>ma,UniformMeshLocationContextProvider:()=>tt,UniformMeshSdkContext:()=>et,UniformMeshSdkContextProvider:()=>Un,VariableEditor:()=>ga,VariablesList:()=>Bn,VariablesProvider:()=>at,badgeIcon:()=>Pt,createLocationValidator:()=>Jn,damSelectItemImage:()=>It,damSelectedItemContainer:()=>ea,damSelectedItemCopy:()=>aa,damSelectedItemDetails:()=>ra,damSelectedItemIcon:()=>na,damSelectedItemInfoBtn:()=>da,damSelectedItemInner:()=>ta,damSelectedItemLinkBtn:()=>_t,damSelectedItemLinkContainer:()=>sa,damSelectedItemMediaContainer:()=>la,damSelectedItemPopover:()=>ia,damSelectedItemPopoverLabel:()=>Je,damSelectedItemSmallText:()=>De,damSelectedItemTitle:()=>oa,draggableContainer:()=>Er,draggableIcon:()=>Rt,draggableIconOffset:()=>Ur,draggableIconWrapper:()=>Mr,entrySearchBtn:()=>Tr,entrySearchConfig:()=>Vr,entrySearchConfigHidden:()=>kr,entrySearchLoadMoreBtn:()=>Lr,entrySearchResultList:()=>Dr,entrySearchSelectIcon:()=>_r,entrySearchSelectImg:()=>Ir,entrySearchSelectInput:()=>kn,entrySearchSelectOption:()=>Dn,entrySearchWrapper:()=>Pr,productSearchRowActiveIcon:()=>Nr,productSearchRowCategory:()=>Gr,productSearchRowContainer:()=>Br,productSearchRowContent:()=>Ar,productSearchRowContentActive:()=>zr,productSearchRowDetails:()=>Hr,productSearchRowTitle:()=>Or,productSelectedItemContainer:()=>Kr,productSelectedItemContent:()=>Yr,productSelectedItemDetails:()=>Qr,productSelectedItemIcon:()=>Zr,productSelectedItemImage:()=>Tt,productSelectedItemLinkContainer:()=>Xr,productedSelectedItemLinkBtn:()=>Lt,productedSelectedItemSmallText:()=>Vt,searchRowBtn:()=>ur,searchRowContainer:()=>lr,searchRowContainerActive:()=>cr,searchRowContainerWithPopover:()=>dr,searchRowPopover:()=>pr,searchRowText:()=>xt,searchRowTextSmall:()=>bt,selectItemLinkBtn:()=>St,selectItemLinkContainer:()=>Sr,selectItemPopover:()=>wr,selectItemPopoverLabel:()=>Oe,selectItemSmallText:()=>be,selectedItemContainer:()=>fr,selectedItemCopy:()=>yr,selectedItemDetails:()=>hr,selectedItemIcon:()=>xr,selectedItemInner:()=>vr,selectedItemTitle:()=>br,urlEncodeRequestParameter:()=>Ra,urlEncodeRequestUrl:()=>Ca,useInitializeUniformMeshSdk:()=>La,useMeshLocation:()=>Ee,useProductQueryContext:()=>or,useProductSearchContext:()=>Xe,useRequest:()=>K,useUniformMeshLocation:()=>Xn,useUniformMeshLocationContext:()=>rt,useUniformMeshSdk:()=>ua,useUniformMeshSdkContext:()=>pa,useVariables:()=>ge,variablesToList:()=>nt});module.exports=gn(ne);var c=require("@emotion/react"),x=le(require("react"));var ft={};Ua(ft,{Caution:()=>qa,Checkmark:()=>ct,ChevronDown:()=>pt,Close:()=>Ba,Danger:()=>Aa,ExclamationPoint:()=>za,Info:()=>ut,Lightbulb:()=>Oa,MagnifyingGlass:()=>Ga,MaximizeAlt:()=>Ha,Minus:()=>mt,MoreVerticalAlt:()=>Ze,Plus:()=>gt});var Ft=require("@emotion/react/jsx-runtime"),fn=e=>(0,Ft.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 16 16",fill:"currentColor",...e,children:(0,Ft.jsx)("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})}),qa=fn;var $t=require("@emotion/react/jsx-runtime"),vn=e=>(0,$t.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 40 40",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,$t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 39.2A19.2 19.2 0 1 0 20 .8a19.2 19.2 0 0 0 0 38.4Zm8.897-22.303a2.4 2.4 0 0 0-3.394-3.394L17.6 21.407l-3.103-3.104a2.4 2.4 0 0 0-3.394 3.394l4.8 4.8a2.4 2.4 0 0 0 3.394 0l9.6-9.6Z"})}),ct=vn;var Wt=require("@emotion/react/jsx-runtime"),hn=e=>(0,Wt.jsx)("svg",{viewBox:"0 0 24 24",width:"1em",height:"1em",...e,children:(0,Wt.jsx)("path",{d:"M5.293 8.293a1 1 0 0 1 1.414 0L12 13.586l5.293-5.293a1 1 0 1 1 1.414 1.414l-6 6a1 1 0 0 1-1.414 0l-6-6a1 1 0 0 1 0-1.414Z"})}),pt=hn;var Ae=require("@emotion/react/jsx-runtime"),yn=e=>(0,Ae.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 19 19",fill:"currentColor",...e,children:(0,Ae.jsxs)("g",{fillRule:"evenodd",children:[(0,Ae.jsx)("path",{d:"M16.578 1.636a1.174 1.174 0 0 1 0 1.66L3.296 16.578a1.174 1.174 0 1 1-1.66-1.66L14.918 1.636a1.174 1.174 0 0 1 1.66 0Z"}),(0,Ae.jsx)("path",{d:"M1.636 1.636a1.174 1.174 0 0 1 1.66 0l13.282 13.282a1.174 1.174 0 1 1-1.66 1.66L1.636 3.296a1.174 1.174 0 0 1 0-1.66Z"})]})}),Ba=yn;var Kt=require("@emotion/react/jsx-runtime"),bn=e=>(0,Kt.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 12 16",fill:"currentColor",...e,children:(0,Kt.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})}),Aa=bn;var Qt=require("@emotion/react/jsx-runtime"),xn=e=>(0,Qt.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 14 16",fill:"currentColor",...e,children:(0,Qt.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})}),za=xn;var Ye=require("@emotion/react/jsx-runtime"),wn=e=>(0,Ye.jsxs)("svg",{width:"1em",height:"1em",fill:"currentColor",...e,children:[(0,Ye.jsx)("path",{xmlns:"http://www.w3.org/2000/svg",d:"M11 10.98a1 1 0 1 1 2 0v6a1 1 0 1 1-2 0v-6zm1-4.929a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"}),(0,Ye.jsx)("path",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zM4 12a8 8 0 1 0 16 0 8 8 0 0 0-16 0z"})]}),ut=wn;var Yt=require("@emotion/react/jsx-runtime"),Sn=e=>(0,Yt.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 12 16",fill:"currentColor",...e,children:(0,Yt.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})}),Oa=Sn;var de=require("@emotion/react/jsx-runtime"),Cn=e=>(0,de.jsxs)("svg",{width:"1em",height:"1em",viewBox:"0 0 26 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,de.jsxs)("g",{clipPath:"url(#magnifying-glass_svg__a)",children:[(0,de.jsx)("path",{d:"M11.539 0C5.484 0 .559 4.741.559 10.57c0 5.827 4.925 10.568 10.98 10.568 6.055 0 10.98-4.74 10.98-10.569C22.52 4.741 17.595 0 11.54 0Zm0 19.187c-4.937 0-8.954-3.866-8.954-8.618 0-4.752 4.017-8.618 8.954-8.618s8.954 3.866 8.954 8.618c0 4.752-4.017 8.618-8.954 8.618Z"}),(0,de.jsx)("path",{d:"m25.196 22.334-5.811-5.593a1.041 1.041 0 0 0-1.434 0 .95.95 0 0 0 0 1.38l5.812 5.593c.198.19.457.286.716.286.26 0 .519-.096.717-.286a.95.95 0 0 0 0-1.38Z"})]}),(0,de.jsx)("defs",{children:(0,de.jsx)("clipPath",{id:"magnifying-glass_svg__a",children:(0,de.jsx)("path",{fill:"#fff",transform:"translate(.558)",d:"M0 0h24.935v24H0z"})})})]}),Ga=Cn;var Zt=require("@emotion/react/jsx-runtime"),Rn=e=>(0,Zt.jsx)("svg",{width:"1em",height:"1em",fill:"currentColor",...e,children:(0,Zt.jsx)("path",{xmlns:"http://www.w3.org/2000/svg",d:"M3 3h6v2H6.462l4.843 4.843-1.415 1.414L5 6.367V9H3V3zm0 18h6v-2H6.376l4.929-4.928-1.415-1.414L5 17.548V15H3v6zm12 0h6v-6h-2v2.524l-4.867-4.866-1.414 1.414L17.647 19H15v2zm6-18h-6v2h2.562l-4.843 4.843 1.414 1.414L19 6.39V9h2V3z"})}),Ha=Rn;var Xt=require("@emotion/react/jsx-runtime"),Pn=e=>(0,Xt.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,Xt.jsx)("path",{d:"M4 12a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1Z",fill:"currentColor"})}),mt=Pn;var Jt=require("@emotion/react/jsx-runtime"),Tn=e=>(0,Jt.jsx)("svg",{width:"1em",height:"1em",fill:"currentColor",...e,children:(0,Jt.jsx)("path",{xmlns:"http://www.w3.org/2000/svg",d:"M14 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm0 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm0 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"})}),Ze=Tn;var jt=require("@emotion/react/jsx-runtime"),Ln=e=>(0,jt.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 46 46",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,jt.jsx)("path",{d:"M44.203 21.203H24.797V1.797a1.797 1.797 0 1 0-3.594 0v19.406H1.797a1.797 1.797 0 1 0 0 3.594h19.406v19.406a1.797 1.797 0 0 0 3.594 0V24.797h19.406a1.797 1.797 0 0 0 0-3.594Z"})}),gt=Ln;var sr=require("@emotion/react"),io=require("@uniformdev/design-system");var er=require("@emotion/react/jsx-runtime");function te({src:e,alt:t,className:r}){let a=e&&typeof e!="string"?e:null;return a?(0,er.jsx)(a,{className:r}):(0,er.jsx)("img",{src:e,alt:t,className:r})}var z=require("@emotion/react"),$=require("@uniformdev/design-system"),pe=le(require("react")),yt=require("react-use");var Wa=require("@emotion/react"),ht=require("@uniformdev/design-system"),Ka=require("react-icons/cg");var ze=require("@emotion/react/jsx-runtime"),tr=({value:e,text:t,loading:r})=>(0,ze.jsxs)(ze.Fragment,{children:[!!t&&t,!t&&(0,ze.jsxs)(ze.Fragment,{children:[r&&`${e} (Loading...)`,!r&&`${e} (Unresolvable)`]})]});var vt=require("@emotion/react"),Na=vt.css`
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+
27
+ // src/index.ts
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ AddListButton: () => import_design_system21.AddListButton,
31
+ Button: () => import_design_system21.Button,
32
+ Callout: () => import_design_system21.Callout,
33
+ DamSelectedItem: () => DamSelectedItem,
34
+ DataResourceVariablesList: () => DataResourceVariablesList,
35
+ DataSourceEditor: () => DataSourceEditor,
36
+ DataTypeEditor: () => DataTypeEditor,
37
+ DefaultSearchRow: () => DefaultSearchRow,
38
+ DefaultSelectedItem: () => DefaultSelectedItem,
39
+ EntrySearch: () => EntrySearch,
40
+ Heading: () => import_design_system21.Heading,
41
+ Icons: () => icons_exports,
42
+ Input: () => import_design_system21.Input,
43
+ InputComboBox: () => import_design_system21.InputComboBox,
44
+ InputKeywordSearch: () => import_design_system21.InputKeywordSearch,
45
+ InputSelect: () => import_design_system21.InputSelect,
46
+ InputToggle: () => import_design_system21.InputToggle,
47
+ InputVariables: () => InputVariables,
48
+ KeywordSearchInput: () => import_design_system21.InputKeywordSearch,
49
+ Label: () => import_design_system21.Label,
50
+ LoadingIndicator: () => import_design_system21.LoadingIndicator,
51
+ LoadingOverlay: () => import_design_system21.LoadingOverlay,
52
+ Menu: () => import_design_system21.Menu,
53
+ MenuItem: () => import_design_system21.MenuItem,
54
+ MeshApp: () => MeshApp,
55
+ ProductPreviewList: () => ProductPreviewList,
56
+ ProductQuery: () => ProductQuery,
57
+ ProductQueryContext: () => ProductQueryContext,
58
+ ProductSearch: () => ProductSearch,
59
+ ProductSearchContext: () => ProductSearchContext,
60
+ ProductSearchRow: () => ProductSearchRow,
61
+ ProductSelectedItem: () => ProductSelectedItem,
62
+ RequestBody: () => RequestBody,
63
+ RequestHeaders: () => RequestHeaders,
64
+ RequestMethodSelect: () => RequestMethodSelect,
65
+ RequestParameters: () => RequestParameters,
66
+ RequestProvider: () => RequestProvider,
67
+ RequestTypeContainer: () => RequestTypeContainer,
68
+ RequestUrl: () => RequestUrl,
69
+ RequestUrlInput: () => RequestUrlInput,
70
+ ResolvableLoadingValue: () => ResolvableLoadingValue,
71
+ ScrollableList: () => import_design_system21.ScrollableList,
72
+ ScrollableListItem: () => import_design_system21.ScrollableListItem,
73
+ SelectionField: () => SelectionField,
74
+ Switch: () => import_design_system21.Switch,
75
+ TextVariableRenderer: () => TextVariableRenderer,
76
+ Textarea: () => import_design_system21.Textarea,
77
+ Theme: () => import_design_system21.Theme,
78
+ UniformMeshLocationContext: () => UniformMeshLocationContext,
79
+ UniformMeshLocationContextProvider: () => UniformMeshLocationContextProvider,
80
+ UniformMeshSdkContext: () => UniformMeshSdkContext,
81
+ UniformMeshSdkContextProvider: () => UniformMeshSdkContextProvider,
82
+ VariableEditor: () => VariableEditor,
83
+ VariablesList: () => VariablesList,
84
+ VariablesProvider: () => VariablesProvider,
85
+ badgeIcon: () => badgeIcon,
86
+ createLocationValidator: () => createLocationValidator,
87
+ damSelectItemImage: () => damSelectItemImage,
88
+ damSelectedItemContainer: () => damSelectedItemContainer,
89
+ damSelectedItemCopy: () => damSelectedItemCopy,
90
+ damSelectedItemDetails: () => damSelectedItemDetails,
91
+ damSelectedItemIcon: () => damSelectedItemIcon,
92
+ damSelectedItemInfoBtn: () => damSelectedItemInfoBtn,
93
+ damSelectedItemInner: () => damSelectedItemInner,
94
+ damSelectedItemLinkBtn: () => damSelectedItemLinkBtn,
95
+ damSelectedItemLinkContainer: () => damSelectedItemLinkContainer,
96
+ damSelectedItemMediaContainer: () => damSelectedItemMediaContainer,
97
+ damSelectedItemPopover: () => damSelectedItemPopover,
98
+ damSelectedItemPopoverLabel: () => damSelectedItemPopoverLabel,
99
+ damSelectedItemSmallText: () => damSelectedItemSmallText,
100
+ damSelectedItemTitle: () => damSelectedItemTitle,
101
+ draggableContainer: () => draggableContainer,
102
+ draggableIcon: () => draggableIcon,
103
+ draggableIconOffset: () => draggableIconOffset,
104
+ draggableIconWrapper: () => draggableIconWrapper,
105
+ entrySearchBtn: () => entrySearchBtn,
106
+ entrySearchConfig: () => entrySearchConfig,
107
+ entrySearchConfigHidden: () => entrySearchConfigHidden,
108
+ entrySearchLoadMoreBtn: () => entrySearchLoadMoreBtn,
109
+ entrySearchResultList: () => entrySearchResultList,
110
+ entrySearchSelectIcon: () => entrySearchSelectIcon,
111
+ entrySearchSelectImg: () => entrySearchSelectImg,
112
+ entrySearchSelectInput: () => entrySearchSelectInput,
113
+ entrySearchSelectOption: () => entrySearchSelectOption,
114
+ entrySearchWrapper: () => entrySearchWrapper,
115
+ productSearchRowActiveIcon: () => productSearchRowActiveIcon,
116
+ productSearchRowCategory: () => productSearchRowCategory,
117
+ productSearchRowContainer: () => productSearchRowContainer,
118
+ productSearchRowContent: () => productSearchRowContent,
119
+ productSearchRowContentActive: () => productSearchRowContentActive,
120
+ productSearchRowDetails: () => productSearchRowDetails,
121
+ productSearchRowTitle: () => productSearchRowTitle,
122
+ productSelectedItemContainer: () => productSelectedItemContainer,
123
+ productSelectedItemContent: () => productSelectedItemContent,
124
+ productSelectedItemDetails: () => productSelectedItemDetails,
125
+ productSelectedItemIcon: () => productSelectedItemIcon,
126
+ productSelectedItemImage: () => productSelectedItemImage,
127
+ productSelectedItemLinkContainer: () => productSelectedItemLinkContainer,
128
+ productedSelectedItemLinkBtn: () => productedSelectedItemLinkBtn,
129
+ productedSelectedItemSmallText: () => productedSelectedItemSmallText,
130
+ searchRowBtn: () => searchRowBtn,
131
+ searchRowContainer: () => searchRowContainer,
132
+ searchRowContainerActive: () => searchRowContainerActive,
133
+ searchRowContainerWithPopover: () => searchRowContainerWithPopover,
134
+ searchRowPopover: () => searchRowPopover,
135
+ searchRowText: () => searchRowText,
136
+ searchRowTextSmall: () => searchRowTextSmall,
137
+ selectItemLinkBtn: () => selectItemLinkBtn,
138
+ selectItemLinkContainer: () => selectItemLinkContainer,
139
+ selectItemPopover: () => selectItemPopover,
140
+ selectItemPopoverLabel: () => selectItemPopoverLabel,
141
+ selectItemSmallText: () => selectItemSmallText,
142
+ selectedItemContainer: () => selectedItemContainer,
143
+ selectedItemCopy: () => selectedItemCopy,
144
+ selectedItemDetails: () => selectedItemDetails,
145
+ selectedItemIcon: () => selectedItemIcon,
146
+ selectedItemInner: () => selectedItemInner,
147
+ selectedItemTitle: () => selectedItemTitle,
148
+ urlEncodeRequestParameter: () => urlEncodeRequestParameter,
149
+ urlEncodeRequestUrl: () => urlEncodeRequestUrl,
150
+ useInitializeUniformMeshSdk: () => useInitializeUniformMeshSdk,
151
+ useMeshLocation: () => useMeshLocation,
152
+ useProductQueryContext: () => useProductQueryContext,
153
+ useProductSearchContext: () => useProductSearchContext,
154
+ useRequest: () => useRequest,
155
+ useUniformMeshLocation: () => useUniformMeshLocation,
156
+ useUniformMeshLocationContext: () => useUniformMeshLocationContext,
157
+ useUniformMeshSdk: () => useUniformMeshSdk,
158
+ useUniformMeshSdkContext: () => useUniformMeshSdkContext,
159
+ useVariables: () => useVariables,
160
+ variablesToList: () => variablesToList
161
+ });
162
+ module.exports = __toCommonJS(src_exports);
163
+
164
+ // ../../scripts/emotion-jsx-shim.js
165
+ var import_react = require("@emotion/react");
166
+ var React = __toESM(require("react"));
167
+
168
+ // src/assets/icons/index.ts
169
+ var icons_exports = {};
170
+ __export(icons_exports, {
171
+ Caution: () => Caution_default,
172
+ Checkmark: () => Checkmark_default,
173
+ ChevronDown: () => ChevronDown_default,
174
+ Close: () => Close_default,
175
+ Danger: () => Danger_default,
176
+ ExclamationPoint: () => ExclamationPoint_default,
177
+ Info: () => Info_default,
178
+ Lightbulb: () => Lightbulb_default,
179
+ MagnifyingGlass: () => MagnifyingGlass_default,
180
+ MaximizeAlt: () => MaximizeAlt_default,
181
+ Minus: () => Minus_default,
182
+ MoreVerticalAlt: () => MoreVerticalAlt_default,
183
+ Plus: () => Plus_default
184
+ });
185
+
186
+ // src/assets/icons/Caution.tsx
187
+ var import_jsx_runtime = require("@emotion/react/jsx-runtime");
188
+ var SvgCaution = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
189
+ "svg",
190
+ {
191
+ xmlns: "http://www.w3.org/2000/svg",
192
+ width: "1em",
193
+ height: "1em",
194
+ viewBox: "0 0 16 16",
195
+ fill: "currentColor",
196
+ ...props,
197
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
198
+ "path",
199
+ {
200
+ fillRule: "evenodd",
201
+ d: "M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"
202
+ }
203
+ )
204
+ }
205
+ );
206
+ var Caution_default = SvgCaution;
207
+
208
+ // src/assets/icons/Checkmark.tsx
209
+ var import_jsx_runtime2 = require("@emotion/react/jsx-runtime");
210
+ var SvgCheckmark = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
211
+ "svg",
212
+ {
213
+ width: "1em",
214
+ height: "1em",
215
+ viewBox: "0 0 40 40",
216
+ fill: "currentColor",
217
+ xmlns: "http://www.w3.org/2000/svg",
218
+ ...props,
219
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
220
+ "path",
221
+ {
222
+ fillRule: "evenodd",
223
+ clipRule: "evenodd",
224
+ d: "M20 39.2A19.2 19.2 0 1 0 20 .8a19.2 19.2 0 0 0 0 38.4Zm8.897-22.303a2.4 2.4 0 0 0-3.394-3.394L17.6 21.407l-3.103-3.104a2.4 2.4 0 0 0-3.394 3.394l4.8 4.8a2.4 2.4 0 0 0 3.394 0l9.6-9.6Z"
225
+ }
226
+ )
227
+ }
228
+ );
229
+ var Checkmark_default = SvgCheckmark;
230
+
231
+ // src/assets/icons/ChevronDown.tsx
232
+ var import_jsx_runtime3 = require("@emotion/react/jsx-runtime");
233
+ var SvgChevronDown = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M5.293 8.293a1 1 0 0 1 1.414 0L12 13.586l5.293-5.293a1 1 0 1 1 1.414 1.414l-6 6a1 1 0 0 1-1.414 0l-6-6a1 1 0 0 1 0-1.414Z" }) });
234
+ var ChevronDown_default = SvgChevronDown;
235
+
236
+ // src/assets/icons/Close.tsx
237
+ var import_jsx_runtime4 = require("@emotion/react/jsx-runtime");
238
+ var SvgClose = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
239
+ "svg",
240
+ {
241
+ xmlns: "http://www.w3.org/2000/svg",
242
+ width: "1em",
243
+ height: "1em",
244
+ viewBox: "0 0 19 19",
245
+ fill: "currentColor",
246
+ ...props,
247
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("g", { fillRule: "evenodd", children: [
248
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M16.578 1.636a1.174 1.174 0 0 1 0 1.66L3.296 16.578a1.174 1.174 0 1 1-1.66-1.66L14.918 1.636a1.174 1.174 0 0 1 1.66 0Z" }),
249
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M1.636 1.636a1.174 1.174 0 0 1 1.66 0l13.282 13.282a1.174 1.174 0 1 1-1.66 1.66L1.636 3.296a1.174 1.174 0 0 1 0-1.66Z" })
250
+ ] })
251
+ }
252
+ );
253
+ var Close_default = SvgClose;
254
+
255
+ // src/assets/icons/Danger.tsx
256
+ var import_jsx_runtime5 = require("@emotion/react/jsx-runtime");
257
+ var SvgDanger = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
258
+ "svg",
259
+ {
260
+ xmlns: "http://www.w3.org/2000/svg",
261
+ width: "1em",
262
+ height: "1em",
263
+ viewBox: "0 0 12 16",
264
+ fill: "currentColor",
265
+ ...props,
266
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
267
+ "path",
268
+ {
269
+ fillRule: "evenodd",
270
+ d: "M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"
271
+ }
272
+ )
273
+ }
274
+ );
275
+ var Danger_default = SvgDanger;
276
+
277
+ // src/assets/icons/ExclamationPoint.tsx
278
+ var import_jsx_runtime6 = require("@emotion/react/jsx-runtime");
279
+ var SvgExclamationPoint = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
280
+ "svg",
281
+ {
282
+ xmlns: "http://www.w3.org/2000/svg",
283
+ width: "1em",
284
+ height: "1em",
285
+ viewBox: "0 0 14 16",
286
+ fill: "currentColor",
287
+ ...props,
288
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
289
+ "path",
290
+ {
291
+ fillRule: "evenodd",
292
+ d: "M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"
293
+ }
294
+ )
295
+ }
296
+ );
297
+ var ExclamationPoint_default = SvgExclamationPoint;
298
+
299
+ // src/assets/icons/Info.tsx
300
+ var import_jsx_runtime7 = require("@emotion/react/jsx-runtime");
301
+ var SvgInfo = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "1em", height: "1em", fill: "currentColor", ...props, children: [
302
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
303
+ "path",
304
+ {
305
+ xmlns: "http://www.w3.org/2000/svg",
306
+ d: "M11 10.98a1 1 0 1 1 2 0v6a1 1 0 1 1-2 0v-6zm1-4.929a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"
307
+ }
308
+ ),
309
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
310
+ "path",
311
+ {
312
+ xmlns: "http://www.w3.org/2000/svg",
313
+ fillRule: "evenodd",
314
+ clipRule: "evenodd",
315
+ d: "M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zM4 12a8 8 0 1 0 16 0 8 8 0 0 0-16 0z"
316
+ }
317
+ )
318
+ ] });
319
+ var Info_default = SvgInfo;
320
+
321
+ // src/assets/icons/Lightbulb.tsx
322
+ var import_jsx_runtime8 = require("@emotion/react/jsx-runtime");
323
+ var SvgLightbulb = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
324
+ "svg",
325
+ {
326
+ xmlns: "http://www.w3.org/2000/svg",
327
+ width: "1em",
328
+ height: "1em",
329
+ viewBox: "0 0 12 16",
330
+ fill: "currentColor",
331
+ ...props,
332
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
333
+ "path",
334
+ {
335
+ fillRule: "evenodd",
336
+ d: "M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"
337
+ }
338
+ )
339
+ }
340
+ );
341
+ var Lightbulb_default = SvgLightbulb;
342
+
343
+ // src/assets/icons/MagnifyingGlass.tsx
344
+ var import_jsx_runtime9 = require("@emotion/react/jsx-runtime");
345
+ var SvgMagnifyingGlass = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
346
+ "svg",
347
+ {
348
+ width: "1em",
349
+ height: "1em",
350
+ viewBox: "0 0 26 24",
351
+ fill: "currentColor",
352
+ xmlns: "http://www.w3.org/2000/svg",
353
+ ...props,
354
+ children: [
355
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { clipPath: "url(#magnifying-glass_svg__a)", children: [
356
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M11.539 0C5.484 0 .559 4.741.559 10.57c0 5.827 4.925 10.568 10.98 10.568 6.055 0 10.98-4.74 10.98-10.569C22.52 4.741 17.595 0 11.54 0Zm0 19.187c-4.937 0-8.954-3.866-8.954-8.618 0-4.752 4.017-8.618 8.954-8.618s8.954 3.866 8.954 8.618c0 4.752-4.017 8.618-8.954 8.618Z" }),
357
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m25.196 22.334-5.811-5.593a1.041 1.041 0 0 0-1.434 0 .95.95 0 0 0 0 1.38l5.812 5.593c.198.19.457.286.716.286.26 0 .519-.096.717-.286a.95.95 0 0 0 0-1.38Z" })
358
+ ] }),
359
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("clipPath", { id: "magnifying-glass_svg__a", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "#fff", transform: "translate(.558)", d: "M0 0h24.935v24H0z" }) }) })
360
+ ]
361
+ }
362
+ );
363
+ var MagnifyingGlass_default = SvgMagnifyingGlass;
364
+
365
+ // src/assets/icons/MaximizeAlt.tsx
366
+ var import_jsx_runtime10 = require("@emotion/react/jsx-runtime");
367
+ var SvgMaximizeAlt = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("svg", { width: "1em", height: "1em", fill: "currentColor", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
368
+ "path",
369
+ {
370
+ xmlns: "http://www.w3.org/2000/svg",
371
+ d: "M3 3h6v2H6.462l4.843 4.843-1.415 1.414L5 6.367V9H3V3zm0 18h6v-2H6.376l4.929-4.928-1.415-1.414L5 17.548V15H3v6zm12 0h6v-6h-2v2.524l-4.867-4.866-1.414 1.414L17.647 19H15v2zm6-18h-6v2h2.562l-4.843 4.843 1.414 1.414L19 6.39V9h2V3z"
372
+ }
373
+ ) });
374
+ var MaximizeAlt_default = SvgMaximizeAlt;
375
+
376
+ // src/assets/icons/Minus.tsx
377
+ var import_jsx_runtime11 = require("@emotion/react/jsx-runtime");
378
+ var SvgMinus = (props) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M4 12a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1Z", fill: "currentColor" }) });
379
+ var Minus_default = SvgMinus;
380
+
381
+ // src/assets/icons/MoreVerticalAlt.tsx
382
+ var import_jsx_runtime12 = require("@emotion/react/jsx-runtime");
383
+ var SvgMoreVerticalAlt = (props) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "1em", height: "1em", fill: "currentColor", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
384
+ "path",
385
+ {
386
+ xmlns: "http://www.w3.org/2000/svg",
387
+ d: "M14 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm0 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm0 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"
388
+ }
389
+ ) });
390
+ var MoreVerticalAlt_default = SvgMoreVerticalAlt;
391
+
392
+ // src/assets/icons/Plus.tsx
393
+ var import_jsx_runtime13 = require("@emotion/react/jsx-runtime");
394
+ var SvgPlus = (props) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
395
+ "svg",
396
+ {
397
+ width: "1em",
398
+ height: "1em",
399
+ viewBox: "0 0 46 46",
400
+ fill: "currentColor",
401
+ xmlns: "http://www.w3.org/2000/svg",
402
+ ...props,
403
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M44.203 21.203H24.797V1.797a1.797 1.797 0 1 0-3.594 0v19.406H1.797a1.797 1.797 0 1 0 0 3.594h19.406v19.406a1.797 1.797 0 0 0 3.594 0V24.797h19.406a1.797 1.797 0 0 0 0-3.594Z" })
404
+ }
405
+ );
406
+ var Plus_default = SvgPlus;
407
+
408
+ // src/components/commerce/ProductPreviewList.tsx
409
+ var import_react7 = require("@emotion/react");
410
+ var import_design_system3 = require("@uniformdev/design-system");
411
+
412
+ // src/components/Image/Image.tsx
413
+ var import_jsx_runtime14 = require("@emotion/react/jsx-runtime");
414
+ function Image({ src, alt, className }) {
415
+ const CompImage = src && typeof src !== "string" ? src : null;
416
+ return CompImage ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CompImage, { className }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src, alt, className });
417
+ }
418
+
419
+ // src/components/commerce/ProductQuery.tsx
420
+ var import_react4 = require("@emotion/react");
421
+ var import_design_system2 = require("@uniformdev/design-system");
422
+ var import_react5 = __toESM(require("react"));
423
+ var import_react_use = require("react-use");
424
+
425
+ // src/components/commerce/SelectionField.tsx
426
+ var import_react3 = require("@emotion/react");
427
+ var import_design_system = require("@uniformdev/design-system");
428
+ var import_cg = require("react-icons/cg");
429
+
430
+ // src/components/commerce/ResolvableLoadingValue.tsx
431
+ var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
432
+ var ResolvableLoadingValue = ({
433
+ value,
434
+ text,
435
+ loading
436
+ }) => {
437
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
438
+ !!text && text,
439
+ !text && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
440
+ loading && `${value} (Loading...)`,
441
+ !loading && `${value} (Unresolvable)`
442
+ ] })
443
+ ] });
444
+ };
445
+
446
+ // src/components/commerce/styles/SelectField.styles.ts
447
+ var import_react2 = require("@emotion/react");
448
+ var selectionFieldBtnContainer = import_react2.css`
2
449
  align-items: center;
3
450
  background: var(--gray-100);
4
451
  border: 1px solid var(--gray-300);
@@ -7,66 +454,459 @@
7
454
  justify-content: space-between;
8
455
  margin-bottom: var(--spacing-sm);
9
456
  margin-right: var(--spacing-sm);
10
- `,Fa=vt.css`
457
+ `;
458
+ var selectionFieldBtnLabel = import_react2.css`
11
459
  color: var(--gray-800);
12
460
  padding: var(--spacing-3);
13
- `,$a=vt.css`
461
+ `;
462
+ var selectionFieldBtn = import_react2.css`
14
463
  border: none;
15
464
  border-left: 1px solid var(--gray-300);
16
465
  background: var(--gray-100);
17
466
  padding: var(--spacing-3);
18
- `;var ce=require("@emotion/react/jsx-runtime"),rr=({id:e,label:t,loading:r,selectedValues:a,values:o,onAdd:i,onRemove:n})=>{var p;let s=(p=o==null?void 0:o.filter(d=>!(a!=null&&a.includes(d.id.toString()))))!=null?p:[],l=(d,u)=>{d.preventDefault(),n(u)};return(0,ce.jsxs)("div",{children:[(0,ce.jsx)(ht.InputSelect,{id:e,name:e,label:t,onChange:d=>i(d.target.value),disabled:r,options:[{value:"",label:"Add..."},...s.map(d=>({value:d.id,label:d.name||d.id}))],value:"",css:Array.isArray(a)&&a.length>0?Wa.css`
467
+ `;
468
+
469
+ // src/components/commerce/SelectionField.tsx
470
+ var import_jsx_runtime16 = require("@emotion/react/jsx-runtime");
471
+ var SelectionField = ({
472
+ id,
473
+ label,
474
+ loading,
475
+ selectedValues,
476
+ values,
477
+ onAdd,
478
+ onRemove
479
+ }) => {
480
+ var _a;
481
+ const availableValues = (_a = values == null ? void 0 : values.filter((brand) => !(selectedValues == null ? void 0 : selectedValues.includes(brand.id.toString())))) != null ? _a : [];
482
+ const handleRemoveClick = (e, value) => {
483
+ e.preventDefault();
484
+ onRemove(value);
485
+ };
486
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
487
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
488
+ import_design_system.InputSelect,
489
+ {
490
+ id,
491
+ name: id,
492
+ label,
493
+ onChange: (e) => onAdd(e.target.value),
494
+ disabled: loading,
495
+ options: [
496
+ { value: "", label: "Add..." },
497
+ ...availableValues.map((option) => {
498
+ return {
499
+ value: option.id,
500
+ label: option.name || option.id
501
+ };
502
+ })
503
+ ],
504
+ value: "",
505
+ css: Array.isArray(selectedValues) && selectedValues.length > 0 ? import_react3.css`
19
506
  margin-bottom: var(--spacing-base);
20
- `:""}),a==null?void 0:a.map(d=>{var u;return(0,ce.jsxs)("div",{css:Na,children:[(0,ce.jsx)("span",{css:Fa,children:(0,ce.jsx)(tr,{value:d,loading:r,text:(u=o.find(y=>y.id===d))==null?void 0:u.name})}),(0,ce.jsx)("button",{css:$a,title:"remove",onClick:y=>l(y,d),children:(0,ce.jsx)(ht.Icon,{icon:Ka.CgClose,iconColor:"currentColor",size:20})})]},d)})]})};var C=require("@emotion/react/jsx-runtime"),Qa={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},Vn=({value:e,setValue:t,brands:r,categories:a,loading:o,categoriesLoading:i,brandsLoading:n,logoIcon:s,onGetProducts:l,sortOptions:p,sortOrderOptions:d,categoryLabel:u="Product Category",brandLabel:y="Brand",disableBrands:f,restrictToSingleCategory:P=!1})=>{var N,b,Q;let w=async m=>{t({...Qa,...e||{},...m})},T=(0,pe.useMemo)(()=>({...Qa,...e||{}}),[e]),[Be,Ke]=(0,yt.useAsyncFn)(async m=>await l(m),[l]);(0,yt.useDebounce)(async()=>{await Ke({brand:T.brand,categories:T.categories,keyword:T.keyword,sort:T.sort,sortOrder:T.sortOrder,count:T.count})},250,[T]);let ee=(0,pe.useMemo)(()=>{let m=[];return a==null||a.forEach(Z=>{let B=Za(Z,void 0);m.push(...B)}),m},[a]),ve=(0,pe.useMemo)(()=>[{value:"",label:"All categories"},...ee.map(m=>({label:m.name,value:m.id}))],[ee]),ie=(0,pe.useMemo)(()=>(r==null?void 0:r.map(m=>({id:m.id.toString(),name:m.name})))||[],[r]),Qe=m=>{if(!m)return;let Z=(e==null?void 0:e.categories)||[];w({categories:[...Z,m]})},st=m=>{var Z;w({categories:(Z=e==null?void 0:e.categories)==null?void 0:Z.filter(B=>B!==m)})},Re=m=>{w({brand:m.target.value})},H=m=>{w({count:m||1})};return o?(0,C.jsx)("div",{children:"Loading..."}):(0,C.jsx)(ar.Provider,{value:{categories:a,logoIcon:s},children:(0,C.jsxs)("div",{css:z.css`
507
+ ` : ""
508
+ }
509
+ ),
510
+ selectedValues == null ? void 0 : selectedValues.map((selectedValue) => {
511
+ var _a2;
512
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: selectionFieldBtnContainer, children: [
513
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { css: selectionFieldBtnLabel, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
514
+ ResolvableLoadingValue,
515
+ {
516
+ value: selectedValue,
517
+ loading,
518
+ text: (_a2 = values.find((v) => v.id === selectedValue)) == null ? void 0 : _a2.name
519
+ }
520
+ ) }),
521
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
522
+ "button",
523
+ {
524
+ css: selectionFieldBtn,
525
+ title: "remove",
526
+ onClick: (e) => handleRemoveClick(e, selectedValue),
527
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system.Icon, { icon: import_cg.CgClose, iconColor: "currentColor", size: 20 })
528
+ }
529
+ )
530
+ ] }, selectedValue);
531
+ })
532
+ ] });
533
+ };
534
+
535
+ // src/components/commerce/ProductQuery.tsx
536
+ var import_jsx_runtime17 = require("@emotion/react/jsx-runtime");
537
+ var initialState = {
538
+ count: 1,
539
+ categories: [],
540
+ brand: "",
541
+ keyword: "",
542
+ sort: "date_modified",
543
+ sortOrder: "desc"
544
+ };
545
+ var ProductQuery = ({
546
+ value,
547
+ setValue,
548
+ brands,
549
+ categories,
550
+ loading,
551
+ categoriesLoading,
552
+ brandsLoading,
553
+ logoIcon,
554
+ onGetProducts,
555
+ sortOptions,
556
+ sortOrderOptions,
557
+ categoryLabel = "Product Category",
558
+ brandLabel = "Brand",
559
+ disableBrands,
560
+ restrictToSingleCategory = false
561
+ }) => {
562
+ var _a, _b, _c;
563
+ const setFormState = async (state) => {
564
+ setValue({
565
+ ...initialState,
566
+ ...value || {},
567
+ ...state
568
+ });
569
+ };
570
+ const formState = (0, import_react5.useMemo)(() => {
571
+ return {
572
+ ...initialState,
573
+ ...value || {}
574
+ };
575
+ }, [value]);
576
+ const [getProductsState, getProductsFn] = (0, import_react_use.useAsyncFn)(
577
+ async (options) => {
578
+ return await onGetProducts(options);
579
+ },
580
+ [onGetProducts]
581
+ );
582
+ (0, import_react_use.useDebounce)(
583
+ async () => {
584
+ await getProductsFn({
585
+ brand: formState.brand,
586
+ categories: formState.categories,
587
+ keyword: formState.keyword,
588
+ sort: formState.sort,
589
+ sortOrder: formState.sortOrder,
590
+ count: formState.count
591
+ });
592
+ },
593
+ 250,
594
+ [formState]
595
+ );
596
+ const categoryOptions = (0, import_react5.useMemo)(() => {
597
+ const options = [];
598
+ categories == null ? void 0 : categories.forEach((category) => {
599
+ const categoryOptions2 = traverseCategory(category, void 0);
600
+ options.push(...categoryOptions2);
601
+ });
602
+ return options;
603
+ }, [categories]);
604
+ const singleChoiceCategoryOptions = (0, import_react5.useMemo)(() => {
605
+ return [
606
+ {
607
+ value: "",
608
+ label: "All categories"
609
+ },
610
+ ...categoryOptions.map((option) => ({
611
+ label: option.name,
612
+ value: option.id
613
+ }))
614
+ ];
615
+ }, [categoryOptions]);
616
+ const brandOptions = (0, import_react5.useMemo)(() => {
617
+ return (brands == null ? void 0 : brands.map((b) => ({
618
+ id: b.id.toString(),
619
+ name: b.name
620
+ }))) || [];
621
+ }, [brands]);
622
+ const handleAddProductCategory = (category) => {
623
+ if (!category) {
624
+ return;
625
+ }
626
+ const categories2 = (value == null ? void 0 : value.categories) || [];
627
+ setFormState({
628
+ categories: [...categories2, category]
629
+ });
630
+ };
631
+ const handleRemoveProductCategory = (category) => {
632
+ var _a2;
633
+ setFormState({
634
+ categories: (_a2 = value == null ? void 0 : value.categories) == null ? void 0 : _a2.filter((c) => c !== category)
635
+ });
636
+ };
637
+ const handleBrandChange = (e) => {
638
+ setFormState({
639
+ brand: e.target.value
640
+ });
641
+ };
642
+ const handleCountChange = (value2) => {
643
+ const localValue = value2 || 1;
644
+ setFormState({ count: localValue });
645
+ };
646
+ if (loading) {
647
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: "Loading..." });
648
+ }
649
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ProductQueryContext.Provider, { value: { categories, logoIcon }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
650
+ "div",
651
+ {
652
+ css: import_react4.css`
21
653
  > :not(:last-child) {
22
654
  margin-bottom: var(--spacing-md);
23
655
  }
24
- `,children:[P?(0,C.jsx)($.InputSelect,{id:"selection-field-product-category",label:u,disabled:o,value:(b=(N=T.categories)==null?void 0:N[0])!=null?b:"",options:ve,onChange:m=>{w({categories:m.target.value===""?[]:[m.target.value]})}}):(0,C.jsx)(rr,{loading:i||!1,id:"selection-field-product-category",label:u,onAdd:Qe,onRemove:st,selectedValues:T.categories,values:ee}),(0,C.jsxs)("div",{css:z.css`
656
+ `,
657
+ children: [
658
+ restrictToSingleCategory ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
659
+ import_design_system2.InputSelect,
660
+ {
661
+ id: "selection-field-product-category",
662
+ label: categoryLabel,
663
+ disabled: loading,
664
+ value: (_b = (_a = formState.categories) == null ? void 0 : _a[0]) != null ? _b : "",
665
+ options: singleChoiceCategoryOptions,
666
+ onChange: (e) => {
667
+ setFormState({
668
+ categories: e.target.value === "" ? [] : [e.target.value]
669
+ });
670
+ }
671
+ }
672
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
673
+ SelectionField,
674
+ {
675
+ loading: categoriesLoading || false,
676
+ id: "selection-field-product-category",
677
+ label: categoryLabel,
678
+ onAdd: handleAddProductCategory,
679
+ onRemove: handleRemoveProductCategory,
680
+ selectedValues: formState.categories,
681
+ values: categoryOptions
682
+ }
683
+ ),
684
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
685
+ "div",
686
+ {
687
+ css: import_react4.css`
25
688
  display: flex;
26
689
  flex-wrap: wrap;
27
690
  column-gap: var(--spacing-lg);
28
691
  row-gap: var(--spacing-md);
29
- ${(0,$.mq)("md")} {
692
+ ${(0, import_design_system2.mq)("md")} {
30
693
  flex-wrap: nowrap;
31
694
  }
32
- `,children:[f?null:(0,C.jsx)("div",{css:z.css`
695
+ `,
696
+ children: [
697
+ disableBrands ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
698
+ "div",
699
+ {
700
+ css: import_react4.css`
33
701
  width: 50%;
34
- `,children:(0,C.jsx)($.InputSelect,{id:"brand",name:"brand",label:y,disabled:n,value:T.brand,onChange:Re,options:[{value:"",label:"Choose..."},...ie.map(m=>({value:m.id,label:m.name}))]})}),(0,C.jsx)("div",{css:z.css`
702
+ `,
703
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
704
+ import_design_system2.InputSelect,
705
+ {
706
+ id: "brand",
707
+ name: "brand",
708
+ label: brandLabel,
709
+ disabled: brandsLoading,
710
+ value: formState.brand,
711
+ onChange: handleBrandChange,
712
+ options: [
713
+ { value: "", label: "Choose..." },
714
+ ...brandOptions.map((brand) => {
715
+ return { value: brand.id, label: brand.name };
716
+ })
717
+ ]
718
+ }
719
+ )
720
+ }
721
+ ),
722
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
723
+ "div",
724
+ {
725
+ css: import_react4.css`
35
726
  flex-grow: 1;
36
727
  position: relative;
37
- `,children:(0,C.jsx)($.Input,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:T.keyword,placeholder:"Enter keyword",onChange:m=>w({keyword:m.target.value})})})]}),(0,C.jsxs)("div",{css:z.css`
728
+ `,
729
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
730
+ import_design_system2.Input,
731
+ {
732
+ id: "keyword-search",
733
+ name: "keyword-search",
734
+ label: "Keyword",
735
+ value: formState.keyword,
736
+ placeholder: "Enter keyword",
737
+ onChange: (e) => setFormState({ keyword: e.target.value })
738
+ }
739
+ )
740
+ }
741
+ )
742
+ ]
743
+ }
744
+ ),
745
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
746
+ "div",
747
+ {
748
+ css: import_react4.css`
38
749
  display: flex;
39
750
  flex-wrap: wrap;
40
751
  column-gap: var(--spacing-lg);
41
752
  row-gap: var(--spacing-md);
42
- ${(0,$.mq)("md")} {
753
+ ${(0, import_design_system2.mq)("md")} {
43
754
  flex-wrap: nowrap;
44
755
  }
45
- `,children:[(0,C.jsxs)("div",{css:z.css`
756
+ `,
757
+ children: [
758
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
759
+ "div",
760
+ {
761
+ css: import_react4.css`
46
762
  width: 100%;
47
- ${(0,$.mq)("md")} {
763
+ ${(0, import_design_system2.mq)("md")} {
48
764
  width: 33.333333%;
49
765
  }
50
766
  position: relative;
51
- `,children:[(0,C.jsx)($.Input,{id:"count",name:"count",type:"number",min:1,step:1,value:T.count,onChange:m=>H(m.target.valueAsNumber),label:"Count"}),(0,C.jsxs)("div",{css:z.css`
767
+ `,
768
+ children: [
769
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
770
+ import_design_system2.Input,
771
+ {
772
+ id: "count",
773
+ name: "count",
774
+ type: "number",
775
+ min: 1,
776
+ step: 1,
777
+ value: formState.count,
778
+ onChange: (e) => handleCountChange(e.target.valueAsNumber),
779
+ label: "Count"
780
+ }
781
+ ),
782
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
783
+ "div",
784
+ {
785
+ css: import_react4.css`
52
786
  position: absolute;
53
787
  bottom: var(--spacing-sm);
54
788
  right: var(--spacing-sm);
55
789
  display: flex;
56
790
  gap: var(--spacing-sm);
57
- `,children:[(0,C.jsx)(Ya,{onCountChange:()=>H(T.count-1),countIcon:"decrement",disabled:T.count===1}),(0,C.jsx)(Ya,{onCountChange:()=>H(T.count+1),countIcon:"increment"})]})]}),Array.isArray(p)&&p.length>0?(0,C.jsx)("div",{css:z.css`
791
+ `,
792
+ children: [
793
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
794
+ CountButton,
795
+ {
796
+ onCountChange: () => handleCountChange(formState.count - 1),
797
+ countIcon: "decrement",
798
+ disabled: formState.count === 1
799
+ }
800
+ ),
801
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
802
+ CountButton,
803
+ {
804
+ onCountChange: () => handleCountChange(formState.count + 1),
805
+ countIcon: "increment"
806
+ }
807
+ )
808
+ ]
809
+ }
810
+ )
811
+ ]
812
+ }
813
+ ),
814
+ Array.isArray(sortOptions) && sortOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
815
+ "div",
816
+ {
817
+ css: import_react4.css`
58
818
  flex-grow: 1;
59
- ${(0,$.mq)("md")} {
819
+ ${(0, import_design_system2.mq)("md")} {
60
820
  width: 33.333333%;
61
821
  }
62
- `,children:(0,C.jsx)($.InputSelect,{id:"sort",name:"sort",label:"Sort",value:T.sort,onChange:m=>w({sort:m.target.value}),options:[{value:"",label:"Select a sort"},...p.map(m=>({value:m.sortKey,label:m.name}))]})}):null,Array.isArray(d)&&d.length>0?(0,C.jsx)("div",{css:z.css`
822
+ `,
823
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
824
+ import_design_system2.InputSelect,
825
+ {
826
+ id: "sort",
827
+ name: "sort",
828
+ label: "Sort",
829
+ value: formState.sort,
830
+ onChange: (e) => setFormState({ sort: e.target.value }),
831
+ options: [
832
+ { value: "", label: "Select a sort" },
833
+ ...sortOptions.map((option) => {
834
+ return {
835
+ value: option.sortKey,
836
+ label: option.name
837
+ };
838
+ })
839
+ ]
840
+ }
841
+ )
842
+ }
843
+ ) : null,
844
+ Array.isArray(sortOrderOptions) && sortOrderOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
845
+ "div",
846
+ {
847
+ css: import_react4.css`
63
848
  flex-grow: 1;
64
- `,children:(0,C.jsx)($.InputSelect,{id:"sort-order",name:"sort-order",label:"Sort Order",value:T.sortOrder,onChange:m=>w({sortOrder:m.target.value}),options:d.map(m=>({value:m.sortOrderKey,label:m.name}))})}):null]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{css:z.css`
849
+ `,
850
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
851
+ import_design_system2.InputSelect,
852
+ {
853
+ id: "sort-order",
854
+ name: "sort-order",
855
+ label: "Sort Order",
856
+ value: formState.sortOrder,
857
+ onChange: (e) => setFormState({ sortOrder: e.target.value }),
858
+ options: sortOrderOptions.map((option) => {
859
+ return {
860
+ value: option.sortOrderKey,
861
+ label: option.name
862
+ };
863
+ })
864
+ }
865
+ )
866
+ }
867
+ ) : null
868
+ ]
869
+ }
870
+ ),
871
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
872
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
873
+ "h3",
874
+ {
875
+ css: import_react4.css`
65
876
  font-size: var(--fs-md);
66
877
  line-height: var(--spacing-md);
67
878
  font-weight: var(--fw-bold);
68
879
  margin-bottom: var(--spacing-xs);
69
- `,children:"Result Preview"}),(0,C.jsx)(nr,{products:(Q=Be.value)==null?void 0:Q.products})]})]})})};function Za(e,t){var i;let r=[],a=t?`${t.name} > `:"",o={id:e.id.toString(),name:`${a}${e.name}`};return r.push(o),(i=e.children)==null||i.forEach(n=>{let s=Za(n,o);r.push(...s)}),r}function Ya({onCountChange:e,countIcon:t,disabled:r}){return(0,C.jsx)("button",{css:z.css`
880
+ `,
881
+ children: "Result Preview"
882
+ }
883
+ ),
884
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ProductPreviewList, { products: (_c = getProductsState.value) == null ? void 0 : _c.products })
885
+ ] })
886
+ ]
887
+ }
888
+ ) });
889
+ };
890
+ function traverseCategory(result, parent) {
891
+ var _a;
892
+ const results = [];
893
+ const namePrefix = parent ? `${parent.name} > ` : "";
894
+ const value = {
895
+ id: result.id.toString(),
896
+ name: `${namePrefix}${result.name}`
897
+ };
898
+ results.push(value);
899
+ (_a = result.children) == null ? void 0 : _a.forEach((child) => {
900
+ const childValues = traverseCategory(child, value);
901
+ results.push(...childValues);
902
+ });
903
+ return results;
904
+ }
905
+ function CountButton({ onCountChange, countIcon, disabled }) {
906
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
907
+ "button",
908
+ {
909
+ css: import_react4.css`
70
910
  width: 2.25rem;
71
911
  height: 2.25rem;
72
912
  border: 1px solid var(--gray-300);
@@ -78,17 +918,45 @@
78
918
  &:hover {
79
919
  background-color: var(--gray-200);
80
920
  }
81
- ${r?z.css`
921
+ ${disabled ? import_react4.css`
82
922
  cursor: not-allowed;
83
923
  opacity: 0.3;
84
- `:""}
85
- `,onClick:e,disabled:r,children:t==="increment"?(0,C.jsx)(gt,{css:z.css`
924
+ ` : ""}
925
+ `,
926
+ onClick: onCountChange,
927
+ disabled,
928
+ children: countIcon === "increment" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
929
+ Plus_default,
930
+ {
931
+ css: import_react4.css`
86
932
  width: 1rem;
87
933
  height: 1rem;
88
- `}):(0,C.jsx)(mt,{css:z.css`
934
+ `
935
+ }
936
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
937
+ Minus_default,
938
+ {
939
+ css: import_react4.css`
89
940
  width: 1rem;
90
941
  height: 1rem;
91
- `})})}var ar=pe.default.createContext(void 0),or=()=>{let e=(0,pe.useContext)(ar);if(!e)throw new Error("useProductQueryContext must be used within a <ProductQueryContext> provider");return e};var X=require("@emotion/react"),Xa=X.css`
942
+ `
943
+ }
944
+ )
945
+ }
946
+ );
947
+ }
948
+ var ProductQueryContext = import_react5.default.createContext(void 0);
949
+ var useProductQueryContext = () => {
950
+ const context = (0, import_react5.useContext)(ProductQueryContext);
951
+ if (!context) {
952
+ throw new Error("useProductQueryContext must be used within a <ProductQueryContext> provider");
953
+ }
954
+ return context;
955
+ };
956
+
957
+ // src/components/commerce/styles/ProductPreviewList.styles.ts
958
+ var import_react6 = require("@emotion/react");
959
+ var productPreviewListLinkBtn = import_react6.css`
92
960
  align-items: center;
93
961
  background: var(--white);
94
962
  border-radius: var(--rounded-base);
@@ -103,65 +971,175 @@
103
971
  &:hover {
104
972
  background: var(--gray-50);
105
973
  }
106
- `,Ja=X.css`
974
+ `;
975
+ var productPreviewListSmallText = import_react6.css`
107
976
  font-size: var(--fs-sm);
108
- `,ja=X.css`
977
+ `;
978
+ var productPreviewListIcon = import_react6.css`
109
979
  width: 1rem;
110
980
  height: 1rem;
111
- `,ir=X.css`
981
+ `;
982
+ var productPreviewListDetailsText = import_react6.css`
112
983
  margin-right: var(--spacing-lg);
113
984
  font-size: var(--fs-sm);
114
- `,eo=X.css`
985
+ `;
986
+ var productPreviewListItem = import_react6.css`
115
987
  border: 1px solid var(--gray-200);
116
988
  border-radius: var(--rounded-md);
117
989
  background: var(--gray-50);
118
990
  margin: var(--spacing-base) 0;
119
- `,to=X.css`
991
+ `;
992
+ var productPreviewListItemDetailsContainer = import_react6.css`
120
993
  align-items: center;
121
994
  display: flex;
122
995
  flex-grow: 1;
123
996
  gap: var(--spacing-base);
124
997
  padding: var(--spacing-sm);
125
998
  margin-right: var(--spacing-sm);
126
- `,ro=X.css`
999
+ `;
1000
+ var productPreviewListImage = import_react6.css`
127
1001
  background: var(--gray-200);
128
1002
  width: 3.5rem;
129
1003
  height: 3.5rem;
130
1004
  object-fit: cover;
131
- `,ao=X.css`
1005
+ `;
1006
+ var productPreviewListImageDefault = import_react6.css`
132
1007
  background: var(--gray-100);
133
1008
  height: 3.5rem;
134
1009
  width: 3.5rem;
135
- `,oo=X.css`
1010
+ `;
1011
+ var productPreviewListTitle = import_react6.css`
136
1012
  margin-top: 0;
137
1013
  font-weight: var(--fw-bold);
138
1014
  font-size: var(--fs-sm);
139
1015
  width: calc(100% / 3);
140
- `,no=X.css`
1016
+ `;
1017
+ var productPreviewListCategoryText = import_react6.css`
141
1018
  display: block;
142
1019
  font-weight: var(--fw-regular);
143
- `;var U=require("@emotion/react/jsx-runtime"),nr=({products:e})=>{let{categories:t,logoIcon:r}=or();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("p",{css:sr.css`
1020
+ `;
1021
+
1022
+ // src/components/commerce/ProductPreviewList.tsx
1023
+ var import_jsx_runtime18 = require("@emotion/react/jsx-runtime");
1024
+ var ProductPreviewList = ({
1025
+ products
1026
+ }) => {
1027
+ const { categories, logoIcon } = useProductQueryContext();
1028
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
1029
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1030
+ "p",
1031
+ {
1032
+ css: import_react7.css`
144
1033
  margin-bottom: var(--spacing-base);
145
- `,children:["Matching ",(e==null?void 0:e.length)||0," products"]}),(0,U.jsx)("ul",{css:[sr.css`
1034
+ `,
1035
+ children: [
1036
+ "Matching ",
1037
+ (products == null ? void 0 : products.length) || 0,
1038
+ " products"
1039
+ ]
1040
+ }
1041
+ ),
1042
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1043
+ "ul",
1044
+ {
1045
+ css: [
1046
+ import_react7.css`
146
1047
  max-height: 24rem;
147
1048
  overflow-x: auto;
148
- `,io.scrollbarStyles],children:e==null?void 0:e.map((a,o)=>{var s,l;let[i]=(a==null?void 0:a.categories)||[],n=typeof i=="undefined"||!t||(s=t.find(p=>p.id===i.id))==null?void 0:s.name;return(0,U.jsx)("li",{css:eo,children:(0,U.jsxs)("div",{css:to,"data-test-id":`product-item-${a.sku||a.id}`,children:[a.thumbnailUrl?(0,U.jsx)("img",{src:a.thumbnailUrl,alt:typeof a.title=="string"?a.title:a.name||`Product ${o}`,css:ro,"data-test-id":"product-image"}):(0,U.jsx)("div",{css:ao}),(0,U.jsxs)("h4",{css:oo,"data-test-id":"product-name",children:[a.title||a.name,n&&(0,U.jsx)("span",{css:no,children:n})]}),a&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("p",{css:ir,"data-test-id":"product-sku",children:["SKU: ",a.sku||a.id,(0,U.jsx)("br",{})]}),a.price!==void 0?(0,U.jsxs)("p",{css:ir,"data-test-id":"product-price",children:["Price: ",a.price]}):null,a.editLink||a.url?(0,U.jsxs)("a",{css:Xa,href:(l=a.editLink)!=null?l:a.url,title:`Go to ${a.title||a.name}`,target:"_blank",rel:"noopener noreferrer","data-test-id":"edit-product-button",children:[(0,U.jsx)("span",{css:Ja,children:"Edit"}),r?(0,U.jsx)(te,{src:r,alt:"Logo",css:ja}):null]}):null]})]})},`product-${a.id}`)})})]})};var go=require("@uniformdev/design-system"),we=le(require("react")),Dt=require("react-use");var mr=require("@emotion/react"),Te=require("react");var ye=require("@emotion/react"),lr=ye.css`
1049
+ `,
1050
+ import_design_system3.scrollbarStyles
1051
+ ],
1052
+ children: products == null ? void 0 : products.map((product, index) => {
1053
+ var _a, _b;
1054
+ const [category] = (product == null ? void 0 : product.categories) || [];
1055
+ const categoryName = typeof category === "undefined" || !categories ? void 0 : (_a = categories.find((c) => c.id === category.id)) == null ? void 0 : _a.name;
1056
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("li", { css: productPreviewListItem, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1057
+ "div",
1058
+ {
1059
+ css: productPreviewListItemDetailsContainer,
1060
+ "data-test-id": `product-item-${product.sku || product.id}`,
1061
+ children: [
1062
+ product.thumbnailUrl ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1063
+ "img",
1064
+ {
1065
+ src: product.thumbnailUrl,
1066
+ alt: typeof product.title === "string" ? product.title : product.name || `Product ${index}`,
1067
+ css: productPreviewListImage,
1068
+ "data-test-id": "product-image"
1069
+ }
1070
+ ) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { css: productPreviewListImageDefault }),
1071
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("h4", { css: productPreviewListTitle, "data-test-id": "product-name", children: [
1072
+ product.title || product.name,
1073
+ categoryName && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { css: productPreviewListCategoryText, children: categoryName })
1074
+ ] }),
1075
+ product && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
1076
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("p", { css: productPreviewListDetailsText, "data-test-id": "product-sku", children: [
1077
+ "SKU: ",
1078
+ product.sku || product.id,
1079
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("br", {})
1080
+ ] }),
1081
+ product.price !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("p", { css: productPreviewListDetailsText, "data-test-id": "product-price", children: [
1082
+ "Price: ",
1083
+ product.price
1084
+ ] }) : null,
1085
+ product.editLink || product.url ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1086
+ "a",
1087
+ {
1088
+ css: productPreviewListLinkBtn,
1089
+ href: (_b = product.editLink) != null ? _b : product.url,
1090
+ title: `Go to ${product.title || product.name}`,
1091
+ target: "_blank",
1092
+ rel: "noopener noreferrer",
1093
+ "data-test-id": "edit-product-button",
1094
+ children: [
1095
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { css: productPreviewListSmallText, children: "Edit" }),
1096
+ logoIcon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Image, { src: logoIcon, alt: "Logo", css: productPreviewListIcon }) : null
1097
+ ]
1098
+ }
1099
+ ) : null
1100
+ ] })
1101
+ ]
1102
+ }
1103
+ ) }, `product-${product.id}`);
1104
+ })
1105
+ }
1106
+ )
1107
+ ] });
1108
+ };
1109
+
1110
+ // src/components/commerce/ProductSearch.tsx
1111
+ var import_design_system9 = require("@uniformdev/design-system");
1112
+ var import_react21 = __toESM(require("react"));
1113
+ var import_react_use3 = require("react-use");
1114
+
1115
+ // src/components/EntrySearch/DefaultSearchRow.tsx
1116
+ var import_react9 = require("@emotion/react");
1117
+ var import_react10 = require("react");
1118
+
1119
+ // src/components/EntrySearch/styles/DefaultSearchRow.styles.ts
1120
+ var import_react8 = require("@emotion/react");
1121
+ var searchRowContainer = import_react8.css`
149
1122
  cursor: pointer;
150
1123
  padding: var(--spacing-sm);
151
1124
  position: relative;
152
1125
  transition: background-color var(--duration-fast) var(--timing-ease-out),
153
1126
  color var(--duration-fast) var(--timing-ease-out);
154
- `,dr=ye.css`
1127
+ `;
1128
+ var searchRowContainerWithPopover = import_react8.css`
155
1129
  padding-right: var(--spacing-lg);
156
- `,cr=ye.css`
1130
+ `;
1131
+ var searchRowContainerActive = import_react8.css`
157
1132
  background: var(--brand-secondary-3);
158
1133
  color: var(--white);
159
- `,bt=ye.css`
1134
+ `;
1135
+ var searchRowTextSmall = import_react8.css`
160
1136
  font-size: var(--fs-xs);
161
- `,xt=ye.css`
1137
+ `;
1138
+ var searchRowText = import_react8.css`
162
1139
  font-weight: var(--fw-bold);
163
1140
  margin-right: var(--spacing-sm);
164
- `,pr=ye.css`
1141
+ `;
1142
+ var searchRowPopover = import_react8.css`
165
1143
  background: var(--white);
166
1144
  border-left: 4px solid var(--brand-secondary-3);
167
1145
  border-radius: var(--rounded-base);
@@ -173,20 +1151,128 @@
173
1151
  right: var(--spacing-xl);
174
1152
  z-index: var(--z-10);
175
1153
  width: max-content;
176
- `,ur=ye.css`
1154
+ `;
1155
+ var searchRowBtn = import_react8.css`
177
1156
  position: absolute;
178
1157
  inset: 0 var(--spacing-sm) 0 auto;
179
- `;var W=require("@emotion/react/jsx-runtime"),gr=({result:e,isSelected:t,triggerSelection:r})=>{let a=(0,Te.useRef)(null),o=(0,Te.useRef)(null),[i,n]=(0,Te.useState)(!1);(0,Te.useEffect)(()=>{function l(p){a.current&&!a.current.contains(p.target)&&o.current&&!o.current.contains(p.target)&&n(!1)}return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[o]);let s=l=>{l.stopPropagation(),n(!i)};return(0,W.jsxs)("div",{css:[lr,t?cr:void 0,e.popoverData?dr:void 0],"data-value":e.id,role:"option",tabIndex:-1,onClick:()=>r(),children:[e.title,e.popoverData&&t?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("button",{type:"button",ref:a,css:ur,"aria-controls":"path-details",onClick:l=>s(l),"aria-expanded":i,children:(0,W.jsx)(ut,{width:24,height:24})}),(0,W.jsxs)("div",{id:"path-details","aria-hidden":!i,ref:o,css:[pr,i?mr.css`
1158
+ `;
1159
+
1160
+ // src/components/EntrySearch/DefaultSearchRow.tsx
1161
+ var import_jsx_runtime19 = require("@emotion/react/jsx-runtime");
1162
+ var DefaultSearchRow = ({ result, isSelected, triggerSelection }) => {
1163
+ const buttonRef = (0, import_react10.useRef)(null);
1164
+ const popoverRef = (0, import_react10.useRef)(null);
1165
+ const [showInfo, setShowInfo] = (0, import_react10.useState)(false);
1166
+ (0, import_react10.useEffect)(() => {
1167
+ function handleClickOutside(event) {
1168
+ if (buttonRef.current && !buttonRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
1169
+ setShowInfo(false);
1170
+ }
1171
+ }
1172
+ document.addEventListener("mousedown", handleClickOutside);
1173
+ return () => {
1174
+ document.removeEventListener("mousedown", handleClickOutside);
1175
+ };
1176
+ }, [popoverRef]);
1177
+ const click = (event) => {
1178
+ event.stopPropagation();
1179
+ setShowInfo(!showInfo);
1180
+ };
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1182
+ "div",
1183
+ {
1184
+ css: [
1185
+ searchRowContainer,
1186
+ isSelected ? searchRowContainerActive : void 0,
1187
+ result.popoverData ? searchRowContainerWithPopover : void 0
1188
+ ],
1189
+ "data-value": result.id,
1190
+ role: "option",
1191
+ tabIndex: -1,
1192
+ onClick: () => triggerSelection(),
1193
+ children: [
1194
+ result.title,
1195
+ result.popoverData && isSelected ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1196
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1197
+ "button",
1198
+ {
1199
+ type: "button",
1200
+ ref: buttonRef,
1201
+ css: searchRowBtn,
1202
+ "aria-controls": "path-details",
1203
+ onClick: (e) => click(e),
1204
+ "aria-expanded": showInfo,
1205
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Info_default, { width: 24, height: 24 })
1206
+ }
1207
+ ),
1208
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1209
+ "div",
1210
+ {
1211
+ id: "path-details",
1212
+ "aria-hidden": !showInfo,
1213
+ ref: popoverRef,
1214
+ css: [
1215
+ searchRowPopover,
1216
+ showInfo ? import_react9.css`
180
1217
  visibility: visible;
181
- `:mr.css`
1218
+ ` : import_react9.css`
182
1219
  visibility: hidden;
183
- `],children:[e.metadata&&Object.entries(e.metadata).map(([l,p],d)=>(0,W.jsxs)("div",{css:bt,children:[(0,W.jsxs)("span",{css:xt,children:[l,":"]}),p]},d)),Object.entries(e.popoverData).map(([l,p],d)=>(0,W.jsxs)("div",{css:bt,children:[(0,W.jsxs)("span",{css:xt,children:[l,":"]}),p]},d))]})]}):null]},e.id)};var ue=require("@emotion/react"),Cr=require("@uniformdev/design-system"),Le=require("react"),Ct=require("react-icons/cg"),lo=require("timeago.js");function wt(e,t){let r=window.open(e,"_blank"),a=setInterval(()=>{r!=null&&r.closed&&(clearInterval(a),t())},500)}var Y=require("@emotion/react"),so=require("@uniformdev/design-system"),fr=Y.css`
1220
+ `
1221
+ ],
1222
+ children: [
1223
+ result.metadata && Object.entries(result.metadata).map(([key, value], index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { css: searchRowTextSmall, children: [
1224
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { css: searchRowText, children: [
1225
+ key,
1226
+ ":"
1227
+ ] }),
1228
+ value
1229
+ ] }, index)),
1230
+ Object.entries(result.popoverData).map(([key, value], index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { css: searchRowTextSmall, children: [
1231
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { css: searchRowText, children: [
1232
+ key,
1233
+ ":"
1234
+ ] }),
1235
+ value
1236
+ ] }, index))
1237
+ ]
1238
+ }
1239
+ )
1240
+ ] }) : null
1241
+ ]
1242
+ },
1243
+ result.id
1244
+ );
1245
+ };
1246
+
1247
+ // src/components/EntrySearch/DefaultSelectedItem.tsx
1248
+ var import_react12 = require("@emotion/react");
1249
+ var import_design_system5 = require("@uniformdev/design-system");
1250
+ var import_react13 = require("react");
1251
+ var import_cg2 = require("react-icons/cg");
1252
+ var import_timeago = require("timeago.js");
1253
+
1254
+ // src/utils/openWindowWithCloseCallback.ts
1255
+ function openWindowWithCloseCallback(href, callback) {
1256
+ const openedNewWindow = window.open(href, "_blank");
1257
+ const interval = setInterval(() => {
1258
+ if (openedNewWindow == null ? void 0 : openedNewWindow.closed) {
1259
+ clearInterval(interval);
1260
+ callback();
1261
+ }
1262
+ }, 500);
1263
+ }
1264
+
1265
+ // src/components/EntrySearch/styles/DefaultSelectedItem.styles.ts
1266
+ var import_react11 = require("@emotion/react");
1267
+ var import_design_system4 = require("@uniformdev/design-system");
1268
+ var selectedItemContainer = import_react11.css`
184
1269
  border: 1px solid var(--gray-200);
185
1270
  background: var(--gray-50);
186
1271
  border-radius: var(--rounded-base);
187
1272
  display: flex;
188
1273
  width: 100%;
189
- `,vr=Y.css`
1274
+ `;
1275
+ var selectedItemInner = import_react11.css`
190
1276
  align-items: center;
191
1277
  display: flex;
192
1278
  flex-grow: 1;
@@ -194,22 +1280,27 @@
194
1280
  margin-inline: 0 var(--spacing-sm);
195
1281
  padding: var(--spacing-base) var(--spacing-base) var(--spacing-base) var(--spacing-lg);
196
1282
  position: relative;
197
- `,hr=Y.css`
1283
+ `;
1284
+ var selectedItemDetails = import_react11.css`
198
1285
  flex-grow: 1;
199
- `,yr=Y.css`
1286
+ `;
1287
+ var selectedItemCopy = import_react11.css`
200
1288
  align-items: start;
201
1289
  display: inline-flex;
202
1290
  position: relative;
203
- `,br=Y.css`
1291
+ `;
1292
+ var selectedItemTitle = import_react11.css`
204
1293
  color: var(--brand-secondary-1);
205
1294
  font-size: var(--fs-base);
206
1295
  font-weight: var(--fw-bold);
207
1296
  line-height: 1;
208
1297
  margin: 0;
209
- `,xr=Y.css`
1298
+ `;
1299
+ var selectedItemIcon = import_react11.css`
210
1300
  width: 1.5rem;
211
1301
  height: 1.5rem;
212
- `,wr=Y.css`
1302
+ `;
1303
+ var selectItemPopover = import_react11.css`
213
1304
  background: var(--white);
214
1305
  border-radius: var(--rounded-base);
215
1306
  border-left: 4px solid var(--brand-secondary-3);
@@ -218,22 +1309,26 @@
218
1309
  padding: var(--spacing-base);
219
1310
  z-index: var(--z-10);
220
1311
  width: max-content;
221
- `,be=Y.css`
1312
+ `;
1313
+ var selectItemSmallText = import_react11.css`
222
1314
  font-size: var(--fs-sm);
223
- `,Oe=Y.css`
1315
+ `;
1316
+ var selectItemPopoverLabel = import_react11.css`
224
1317
  font-weight: var(--fw-bold);
225
1318
  margin-right: var(--spacing-sm);
226
- `,Sr=Y.css`
1319
+ `;
1320
+ var selectItemLinkContainer = import_react11.css`
227
1321
  display: flex;
228
1322
  flex-direction: column;
229
1323
  gap: var(--spacing-sm);
230
1324
 
231
- ${(0,so.mq)("md")} {
1325
+ ${(0, import_design_system4.mq)("md")} {
232
1326
  flex-direction: row;
233
1327
  min-width: 200px;
234
1328
  justify-content: end;
235
1329
  }
236
- `,St=Y.css`
1330
+ `;
1331
+ var selectItemLinkBtn = import_react11.css`
237
1332
  align-items: center;
238
1333
  background: var(--white);
239
1334
  border-radius: var(--rounded-base);
@@ -248,29 +1343,263 @@
248
1343
  &:hover {
249
1344
  background: var(--gray-50);
250
1345
  }
251
- `;var R=require("@emotion/react/jsx-runtime"),Rr=({selectedItem:e,logoIcon:t,onDeselect:r,onEditClosed:a})=>{var p;let o=(0,Le.useRef)(null),i=(0,Le.useRef)(null),[n,s]=(0,Le.useState)(!1);(0,Le.useEffect)(()=>{let d=y=>{o.current&&!o.current.contains(y.target)&&i.current&&!i.current.contains(y.target)&&s(!1)},u=()=>{s(!1)};return window.addEventListener("resize",u,!0),document.addEventListener("scroll",d,!0),document.addEventListener("mousedown",d),()=>{window.removeEventListener("resize",u,!0),document.removeEventListener("scroll",d,!0),document.removeEventListener("mousedown",d)}},[i]);let l=()=>{var d;if(s(!n),i.current&&o.current){let u=(d=o==null?void 0:o.current)==null?void 0:d.getBoundingClientRect(),y=i.current.offsetWidth;i.current.style.top=`${u.top+30}px`,i.current.style.left=`${u.left-y+30}px`}};return(0,R.jsx)("div",{css:fr,children:(0,R.jsxs)("div",{css:vr,children:[(0,R.jsxs)("div",{css:hr,children:[(0,R.jsxs)("div",{css:yr,children:[(0,R.jsx)("h4",{css:[br,e.popoverData?ue.css`
1346
+ `;
1347
+
1348
+ // src/components/EntrySearch/DefaultSelectedItem.tsx
1349
+ var import_jsx_runtime20 = require("@emotion/react/jsx-runtime");
1350
+ var DefaultSelectedItem = ({
1351
+ selectedItem,
1352
+ logoIcon,
1353
+ onDeselect,
1354
+ onEditClosed
1355
+ }) => {
1356
+ var _a;
1357
+ const buttonRef = (0, import_react13.useRef)(null);
1358
+ const popoverRef = (0, import_react13.useRef)(null);
1359
+ const [showInfo, setShowInfo] = (0, import_react13.useState)(false);
1360
+ (0, import_react13.useEffect)(() => {
1361
+ const eventHandler = (event) => {
1362
+ if (buttonRef.current && !buttonRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
1363
+ setShowInfo(false);
1364
+ }
1365
+ };
1366
+ const resizeHandler = () => {
1367
+ setShowInfo(false);
1368
+ };
1369
+ window.addEventListener("resize", resizeHandler, true);
1370
+ document.addEventListener("scroll", eventHandler, true);
1371
+ document.addEventListener("mousedown", eventHandler);
1372
+ return () => {
1373
+ window.removeEventListener("resize", resizeHandler, true);
1374
+ document.removeEventListener("scroll", eventHandler, true);
1375
+ document.removeEventListener("mousedown", eventHandler);
1376
+ };
1377
+ }, [popoverRef]);
1378
+ const popoverClick = () => {
1379
+ var _a2;
1380
+ setShowInfo(!showInfo);
1381
+ if (popoverRef.current && buttonRef.current) {
1382
+ const buttonPos = (_a2 = buttonRef == null ? void 0 : buttonRef.current) == null ? void 0 : _a2.getBoundingClientRect();
1383
+ const popoverWidth = popoverRef.current.offsetWidth;
1384
+ popoverRef.current.style["top"] = `${buttonPos.top + 30}px`;
1385
+ popoverRef.current.style["left"] = `${buttonPos.left - popoverWidth + 30}px`;
1386
+ }
1387
+ };
1388
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { css: selectedItemContainer, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { css: selectedItemInner, children: [
1389
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { css: selectedItemDetails, children: [
1390
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { css: selectedItemCopy, children: [
1391
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1392
+ "h4",
1393
+ {
1394
+ css: [
1395
+ selectedItemTitle,
1396
+ selectedItem.popoverData ? import_react12.css`
252
1397
  margin-bottom: var(--spacing-sm);
253
- `:""],title:`ID: ${e.id}`,"data-test-id":"entry-id",children:e.title||e.id||""}),e.popoverData?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)("button",{type:"button",ref:o,css:ue.css`
1398
+ ` : ""
1399
+ ],
1400
+ title: `ID: ${selectedItem.id}`,
1401
+ "data-test-id": "entry-id",
1402
+ children: selectedItem.title || selectedItem.id || ""
1403
+ }
1404
+ ),
1405
+ selectedItem.popoverData ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
1406
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1407
+ "button",
1408
+ {
1409
+ type: "button",
1410
+ ref: buttonRef,
1411
+ css: import_react12.css`
254
1412
  margin: calc(var(--spacing-xs) * -1) 0 calc(var(--spacing-xs) * -1) var(--spacing-sm);
255
- `,"aria-controls":"path-details","aria-expanded":n,onClick:l,children:(0,R.jsx)(Cr.Icon,{icon:Ct.CgInfo,iconColor:"gray",size:24,css:ue.css`
1413
+ `,
1414
+ "aria-controls": "path-details",
1415
+ "aria-expanded": showInfo,
1416
+ onClick: popoverClick,
1417
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1418
+ import_design_system5.Icon,
1419
+ {
1420
+ icon: import_cg2.CgInfo,
1421
+ iconColor: "gray",
1422
+ size: 24,
1423
+ css: import_react12.css`
256
1424
  opacity: var(--opacity-75);
257
- `})}),(0,R.jsx)("div",{id:"path-details","aria-hidden":!n,ref:i,css:[wr,n?ue.css`
1425
+ `
1426
+ }
1427
+ )
1428
+ }
1429
+ ),
1430
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1431
+ "div",
1432
+ {
1433
+ id: "path-details",
1434
+ "aria-hidden": !showInfo,
1435
+ ref: popoverRef,
1436
+ css: [
1437
+ selectItemPopover,
1438
+ showInfo ? import_react12.css`
258
1439
  visibility: visible;
259
- `:ue.css`
1440
+ ` : import_react12.css`
260
1441
  visibility: hidden;
261
- `],children:Object.entries(e.popoverData).map(([d,u],y)=>(0,R.jsxs)("div",{css:be,children:[(0,R.jsxs)("span",{css:Oe,children:[d,":"]}),u]},y))})]}):null]}),e.createdDate&&(0,R.jsxs)("div",{css:be,children:[(0,R.jsx)("span",{css:Oe,children:"Created:"}),(0,lo.format)((p=e.createdDate)!=null?p:0)]}),e.metadata?Object.entries(e.metadata).filter(([d])=>["type","status"].includes(d.toLocaleLowerCase())).map(([d,u])=>(0,R.jsxs)("div",{css:[be,ue.css`
1442
+ `
1443
+ ],
1444
+ children: Object.entries(selectedItem.popoverData).map(([key, value], index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { css: selectItemSmallText, children: [
1445
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { css: selectItemPopoverLabel, children: [
1446
+ key,
1447
+ ":"
1448
+ ] }),
1449
+ value
1450
+ ] }, index))
1451
+ }
1452
+ )
1453
+ ] }) : null
1454
+ ] }),
1455
+ selectedItem.createdDate && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { css: selectItemSmallText, children: [
1456
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { css: selectItemPopoverLabel, children: "Created:" }),
1457
+ (0, import_timeago.format)((_a = selectedItem.createdDate) != null ? _a : 0)
1458
+ ] }),
1459
+ selectedItem.metadata ? Object.entries(selectedItem.metadata).filter(([key]) => ["type", "status"].includes(key.toLocaleLowerCase())).map(([key, value]) => {
1460
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1461
+ "div",
1462
+ {
1463
+ css: [
1464
+ selectItemSmallText,
1465
+ import_react12.css`
262
1466
  order: 1;
263
- `],children:[(0,R.jsxs)("span",{css:Oe,children:[d,":"]}),u]},d)):null,e.metadata?Object.entries(e.metadata).filter(([d])=>!["type","status"].includes(d.toLocaleLowerCase())).map(([d,u])=>(0,R.jsxs)("div",{css:[be,ue.css`
1467
+ `
1468
+ ],
1469
+ children: [
1470
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { css: selectItemPopoverLabel, children: [
1471
+ key,
1472
+ ":"
1473
+ ] }),
1474
+ value
1475
+ ]
1476
+ },
1477
+ key
1478
+ );
1479
+ }) : null,
1480
+ selectedItem.metadata ? Object.entries(selectedItem.metadata).filter(([key]) => !["type", "status"].includes(key.toLocaleLowerCase())).map(([key, value]) => {
1481
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1482
+ "div",
1483
+ {
1484
+ css: [
1485
+ selectItemSmallText,
1486
+ import_react12.css`
264
1487
  order: 1;
265
- `],children:[(0,R.jsxs)("span",{css:[Oe,ue.css`
1488
+ `
1489
+ ],
1490
+ children: [
1491
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1492
+ "span",
1493
+ {
1494
+ css: [
1495
+ selectItemPopoverLabel,
1496
+ import_react12.css`
266
1497
  order: 1;
267
- `],children:[d,":"]}),u]},d)):null]}),(0,R.jsxs)("div",{css:Sr,children:[e.editLink?(0,R.jsxs)("a",{href:e.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",onClick:d=>{a&&(wt(d.currentTarget.href,()=>a(e)),d.preventDefault())},css:St,children:[(0,R.jsx)("span",{css:be,children:"Edit"}),(0,R.jsx)(te,{src:t,css:xr,alt:"Logo"})]}):null,(0,R.jsxs)("button",{type:"button",onClick:()=>{r(e)},css:St,children:[(0,R.jsx)("span",{css:be,children:"Unlink"}),(0,R.jsx)(Cr.Icon,{icon:Ct.CgClose,iconColor:"red",size:16})]})]})]})},e.id)};var J=require("@emotion/react"),q=require("@uniformdev/design-system"),re=le(require("react")),Ge=require("react-beautiful-dnd"),po=require("react-use"),uo=require("uuid");var Ve=require("react");function co(e,{delay:t=500,minDuration:r=200}={delay:500,minDuration:200}){let[a,o]=(0,Ve.useState)("IDLE"),i=(0,Ve.useRef)(void 0);return(0,Ve.useEffect)(()=>{e&&a==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!e)return o("IDLE");i.current=setTimeout(()=>{o("EXPIRE")},r),o("DISPLAY")},t),o("DELAY")),!e&&a!=="DISPLAY"&&(clearTimeout(i.current),o("IDLE"))},[e,a,t,r]),(0,Ve.useEffect)(()=>()=>clearTimeout(i.current),[]),a==="DISPLAY"||a==="EXPIRE"}var A=require("@emotion/react"),Pr=A.css`
1498
+ `
1499
+ ],
1500
+ children: [
1501
+ key,
1502
+ ":"
1503
+ ]
1504
+ }
1505
+ ),
1506
+ value
1507
+ ]
1508
+ },
1509
+ key
1510
+ );
1511
+ }) : null
1512
+ ] }),
1513
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { css: selectItemLinkContainer, children: [
1514
+ selectedItem.editLink ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1515
+ "a",
1516
+ {
1517
+ href: selectedItem.editLink,
1518
+ title: "edit",
1519
+ rel: "noopener noreferrer",
1520
+ target: "_blank",
1521
+ onClick: (e) => {
1522
+ if (onEditClosed) {
1523
+ openWindowWithCloseCallback(e.currentTarget.href, () => onEditClosed(selectedItem));
1524
+ e.preventDefault();
1525
+ }
1526
+ },
1527
+ css: selectItemLinkBtn,
1528
+ children: [
1529
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { css: selectItemSmallText, children: "Edit" }),
1530
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Image, { src: logoIcon, css: selectedItemIcon, alt: "Logo" })
1531
+ ]
1532
+ }
1533
+ ) : null,
1534
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1535
+ "button",
1536
+ {
1537
+ type: "button",
1538
+ onClick: () => {
1539
+ onDeselect(selectedItem);
1540
+ },
1541
+ css: selectItemLinkBtn,
1542
+ children: [
1543
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { css: selectItemSmallText, children: "Unlink" }),
1544
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_design_system5.Icon, { icon: import_cg2.CgClose, iconColor: "red", size: 16 })
1545
+ ]
1546
+ }
1547
+ )
1548
+ ] })
1549
+ ] }) }, selectedItem.id);
1550
+ };
1551
+
1552
+ // src/components/EntrySearch/EntrySearch.tsx
1553
+ var import_react16 = require("@emotion/react");
1554
+ var import_design_system6 = require("@uniformdev/design-system");
1555
+ var React5 = __toESM(require("react"));
1556
+ var import_react_beautiful_dnd = require("react-beautiful-dnd");
1557
+ var import_react_use2 = require("react-use");
1558
+ var import_uuid = require("uuid");
1559
+
1560
+ // src/hooks/useLoadingDelay.ts
1561
+ var import_react14 = require("react");
1562
+ function useLoadingDelay(loading, { delay = 500, minDuration = 200 } = {
1563
+ delay: 500,
1564
+ minDuration: 200
1565
+ }) {
1566
+ const [state, setState] = (0, import_react14.useState)("IDLE");
1567
+ const timeout = (0, import_react14.useRef)(void 0);
1568
+ (0, import_react14.useEffect)(() => {
1569
+ if (loading && state === "IDLE") {
1570
+ clearTimeout(timeout.current);
1571
+ timeout.current = setTimeout(() => {
1572
+ if (!loading) {
1573
+ return setState("IDLE");
1574
+ }
1575
+ timeout.current = setTimeout(() => {
1576
+ setState("EXPIRE");
1577
+ }, minDuration);
1578
+ setState("DISPLAY");
1579
+ }, delay);
1580
+ setState("DELAY");
1581
+ }
1582
+ if (!loading && state !== "DISPLAY") {
1583
+ clearTimeout(timeout.current);
1584
+ setState("IDLE");
1585
+ }
1586
+ }, [loading, state, delay, minDuration]);
1587
+ (0, import_react14.useEffect)(() => {
1588
+ return () => clearTimeout(timeout.current);
1589
+ }, []);
1590
+ return state === "DISPLAY" || state === "EXPIRE";
1591
+ }
1592
+
1593
+ // src/components/EntrySearch/styles/EntrySearch.styles.ts
1594
+ var import_react15 = require("@emotion/react");
1595
+ var entrySearchWrapper = import_react15.css`
268
1596
  background: var(--white);
269
1597
  border: 1px solid var(--gray-300);
270
1598
  border-radius: var(--rounded-base);
271
1599
  padding: calc(var(--spacing-base) - 0.25rem) var(--spacing-sm);
272
1600
  margin-bottom: var(--spacing-base);
273
- `,Tr=A.css`
1601
+ `;
1602
+ var entrySearchBtn = import_react15.css`
274
1603
  align-items: center;
275
1604
  display: flex;
276
1605
  position: relative;
@@ -278,7 +1607,8 @@
278
1607
  width: 100%;
279
1608
  background-color: transparent;
280
1609
  border: 0;
281
- `,Lr=A.css`
1610
+ `;
1611
+ var entrySearchLoadMoreBtn = import_react15.css`
282
1612
  color: var(--brand-secondary-1);
283
1613
  display: block;
284
1614
  font-weight: var(--fw-bold);
@@ -294,15 +1624,18 @@
294
1624
  background: var(--gray-100);
295
1625
  outline: none;
296
1626
  }
297
- `,Vr=A.css`
1627
+ `;
1628
+ var entrySearchConfig = import_react15.css`
298
1629
  background: var(--white);
299
1630
  border: 1px solid var(--gray-300);
300
1631
  border-radius: var(--rounded-base);
301
1632
  padding: calc(var(--spacing-base) - 0.25rem) var(--spacing-base);
302
1633
  display: block;
303
- `,kr=A.css`
1634
+ `;
1635
+ var entrySearchConfigHidden = import_react15.css`
304
1636
  display: none;
305
- `,Dr=A.css`
1637
+ `;
1638
+ var entrySearchResultList = import_react15.css`
306
1639
  overflow-y: auto;
307
1640
  height: 16rem;
308
1641
  margin-bottom: var(--spacing-base);
@@ -311,26 +1644,31 @@
311
1644
  & > :not(:last-child) {
312
1645
  border-bottom: 1px solid var(--gray-200);
313
1646
  }
314
- `,kn=A.css`
1647
+ `;
1648
+ var entrySearchSelectInput = import_react15.css`
315
1649
  background-color: var(--gray-50);
316
1650
  max-width: 33.33%;
317
- `,_r=A.css`
1651
+ `;
1652
+ var entrySearchSelectIcon = import_react15.css`
318
1653
  align-items: center;
319
1654
  display: flex;
320
1655
  position: absolute;
321
1656
  inset: 0 0 0 auto;
322
1657
  pointer-events: none;
323
1658
  padding-right: var(--spacing-sm);
324
- `,Ir=A.css`
1659
+ `;
1660
+ var entrySearchSelectImg = import_react15.css`
325
1661
  color: var(--brand-secondary-1);
326
1662
  width: 1.25rem;
327
1663
  height: 1.25rem;
328
1664
  transition: transform var(--duration-fast) var(--timing-ease-out);
329
1665
  transform: rotate(0);
330
- `,Dn=A.css`
1666
+ `;
1667
+ var entrySearchSelectOption = import_react15.css`
331
1668
  background: var(--white);
332
1669
  color: var(--brand-secondary-1);
333
- `,Er=A.css`
1670
+ `;
1671
+ var draggableContainer = import_react15.css`
334
1672
  position: relative;
335
1673
  margin-block: var(--spacing-sm) 0;
336
1674
 
@@ -342,96 +1680,552 @@
342
1680
  left: auto !important;
343
1681
  top: auto !important;
344
1682
  }
345
- `,Mr=A.css`
1683
+ `;
1684
+ var draggableIconWrapper = import_react15.css`
346
1685
  align-items: center;
347
1686
  display: flex;
348
1687
  position: absolute;
349
1688
  inset: 0 auto 0 0;
350
1689
  margin-block: auto;
351
1690
  opacity: 0;
352
- `,Rt=A.css`
1691
+ `;
1692
+ var draggableIcon = import_react15.css`
353
1693
  color: var(--brand-secondary-1);
354
- `,Ur=A.css`
1694
+ `;
1695
+ var draggableIconOffset = import_react15.css`
355
1696
  position: absolute;
356
1697
  left: 0.375rem;
357
- `,Pt=A.css`
1698
+ `;
1699
+ var badgeIcon = import_react15.css`
358
1700
  width: calc(var(--spacing-lg) + var(--spacing-xs));
359
1701
  height: calc(var(--spacing-lg) + var(--spacing-xs));
360
- `;var v=require("@emotion/react/jsx-runtime"),_n=({searchText:e,selectedContentType:t})=>{let r="No content found";return t&&t!=="any"&&(r=`No ${t} content was found`),e&&(r=`${r} for keyword '${e}'.`),(0,v.jsx)(q.Callout,{type:"info",children:r})},qr=({search:e,results:t,contentTypes:r,selectedItems:a,logoIcon:o,select:i,multiSelect:n,multiSelectId:s,rowComponent:l,selectedItemComponent:p,totalResults:d,cursor:u,resultsLoading:y,requireContentType:f,onAddNew:P,onEditClosed:w,onCancel:T,noResultsComponent:Be,helpComponent:Ke,onSort:ee,typeSelectorLabel:ve="Content Type Select",typeSelectorAllTypesOptionText:ie="All content types",loadingIndicatorDelay:Qe=1e3})=>{var Ia,Ea,Ma;let Re=()=>f?Array.isArray(r)&&r.length>0?r[0].id:"":"any",[H,N]=re.useState(""),[b,Q]=re.useState(Re),[m,Z]=re.useState(!1),[B,Pe]=re.useState([]),[Qo,Va]=re.useState(!1),Gt=re.useRef(`x${(0,uo.v4)()}`);(0,po.useDebounce)(()=>{e(H,{count:5,offset:0,contentType:b==="any"?void 0:b})},300,[H,b]);let Yo=co(y,{delay:Qe}),Zo=g=>{B.some(L=>L.id===g.id)?Pe(L=>L.filter(he=>he.id!==g.id)):Pe(n?L=>[...L,g]:[g])},Xo=a==null?void 0:a.map(g=>g.id+g.title).join(",");re.useEffect(()=>{Array.isArray(a)&&Pe(a)},[Xo]);let Jo=()=>{Q(Re()),N(""),Pe(a!=null&&a.length?a:[])},jo=()=>{Z(g=>!g),m||Jo()},ka=g=>{let L=(B==null?void 0:B.filter(he=>he.id!==g.id))||[];Pe(L),i(L,"")},en=g=>{g.preventDefault(),i(B,b),Z(!1)},tn=g=>{g.preventDefault(),Z(!1),T&&T()},rn=()=>{e(H,{count:5,offset:(t==null?void 0:t.length)||0,contentType:b==="any"?void 0:b,cursor:u}),Va(!0);let g=setTimeout(()=>{Va(!1)},750);return()=>clearTimeout(g)},an=!(a==null?void 0:a.length)||n,on=l||gr,Da=p||Rr,nn=Be||_n,_a=o&&typeof o!="string"?o:null,sn=_a?(0,v.jsx)(_a,{css:Pt}):(0,v.jsx)("img",{src:o,alt:"Logo",css:Pt}),ln=g=>{var L,he;if(g.destination&&g.source.droppableId===((L=g.destination)==null?void 0:L.droppableId)){let F=[...a||[]],[Ht]=(he=F==null?void 0:F.splice(g.source.index,1))!=null?he:[];return F==null||F.splice(g.destination.index,0,Ht),ee&&(Pe(F),ee==null||ee(F)),F}};return(0,v.jsx)("div",{css:J.css`
1702
+ `;
1703
+
1704
+ // src/components/EntrySearch/EntrySearch.tsx
1705
+ var import_jsx_runtime21 = require("@emotion/react/jsx-runtime");
1706
+ var DefaultNoResults = ({ searchText, selectedContentType }) => {
1707
+ let message = "No content found";
1708
+ if (selectedContentType && selectedContentType !== "any") {
1709
+ message = `No ${selectedContentType} content was found`;
1710
+ }
1711
+ if (searchText) {
1712
+ message = `${message} for keyword '${searchText}'.`;
1713
+ }
1714
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system6.Callout, { type: "info", children: message });
1715
+ };
1716
+ var EntrySearch = ({
1717
+ search,
1718
+ results,
1719
+ contentTypes,
1720
+ selectedItems,
1721
+ logoIcon,
1722
+ select,
1723
+ multiSelect,
1724
+ multiSelectId,
1725
+ rowComponent,
1726
+ selectedItemComponent,
1727
+ totalResults,
1728
+ cursor,
1729
+ resultsLoading,
1730
+ requireContentType,
1731
+ onAddNew,
1732
+ onEditClosed,
1733
+ onCancel,
1734
+ noResultsComponent,
1735
+ helpComponent,
1736
+ onSort,
1737
+ typeSelectorLabel = "Content Type Select",
1738
+ typeSelectorAllTypesOptionText = "All content types",
1739
+ loadingIndicatorDelay = 1e3
1740
+ }) => {
1741
+ var _a, _b, _c;
1742
+ const pageSize = 5;
1743
+ const resolveInitialContentTypeState = () => {
1744
+ if (!requireContentType) {
1745
+ return "any";
1746
+ }
1747
+ if (Array.isArray(contentTypes) && contentTypes.length > 0) {
1748
+ return contentTypes[0].id;
1749
+ }
1750
+ return "";
1751
+ };
1752
+ const [textInput, setTextInput] = React5.useState("");
1753
+ const [contentTypeSelected, setContentTypeSelected] = React5.useState(resolveInitialContentTypeState);
1754
+ const [listOpen, setListOpen] = React5.useState(false);
1755
+ const [selectedListItems, setSelectedListItems] = React5.useState([]);
1756
+ const [loadingMore, setLoadingMore] = React5.useState(false);
1757
+ const listBoxId = React5.useRef(`x${(0, import_uuid.v4)()}`);
1758
+ (0, import_react_use2.useDebounce)(
1759
+ () => {
1760
+ search(textInput, {
1761
+ count: pageSize,
1762
+ offset: 0,
1763
+ contentType: contentTypeSelected === "any" ? void 0 : contentTypeSelected
1764
+ });
1765
+ },
1766
+ 300,
1767
+ [textInput, contentTypeSelected]
1768
+ );
1769
+ const showLoadingOverlay = useLoadingDelay(resultsLoading, { delay: loadingIndicatorDelay });
1770
+ const handleListItemSelect = (selectedResult) => {
1771
+ if (selectedListItems.some((item) => item.id === selectedResult.id)) {
1772
+ setSelectedListItems((prev) => prev.filter((item) => item.id !== selectedResult.id));
1773
+ } else {
1774
+ if (!multiSelect) {
1775
+ setSelectedListItems([selectedResult]);
1776
+ } else {
1777
+ setSelectedListItems((prev) => [...prev, selectedResult]);
1778
+ }
1779
+ }
1780
+ };
1781
+ const selectedItemsHash = selectedItems == null ? void 0 : selectedItems.map((item) => item.id + item.title).join(",");
1782
+ React5.useEffect(
1783
+ () => {
1784
+ if (Array.isArray(selectedItems)) {
1785
+ setSelectedListItems(selectedItems);
1786
+ }
1787
+ },
1788
+ [selectedItemsHash]
1789
+ );
1790
+ const resetForm = () => {
1791
+ setContentTypeSelected(resolveInitialContentTypeState());
1792
+ setTextInput("");
1793
+ setSelectedListItems((selectedItems == null ? void 0 : selectedItems.length) ? selectedItems : []);
1794
+ };
1795
+ const handleListButtonClick = () => {
1796
+ setListOpen((prevState) => !prevState);
1797
+ if (!listOpen) {
1798
+ resetForm();
1799
+ }
1800
+ };
1801
+ const handleDeselect = (result) => {
1802
+ const newValue = (selectedListItems == null ? void 0 : selectedListItems.filter((product) => product.id !== result.id)) || [];
1803
+ setSelectedListItems(newValue);
1804
+ select(newValue, "");
1805
+ };
1806
+ const handleAcceptClick = (e) => {
1807
+ e.preventDefault();
1808
+ select(selectedListItems, contentTypeSelected);
1809
+ setListOpen(false);
1810
+ };
1811
+ const handleCancelClick = (e) => {
1812
+ e.preventDefault();
1813
+ setListOpen(false);
1814
+ if (onCancel)
1815
+ onCancel();
1816
+ };
1817
+ const handleLoadMoreClick = () => {
1818
+ search(textInput, {
1819
+ count: pageSize,
1820
+ offset: (results == null ? void 0 : results.length) || 0,
1821
+ contentType: contentTypeSelected === "any" ? void 0 : contentTypeSelected,
1822
+ cursor
1823
+ });
1824
+ setLoadingMore(true);
1825
+ const timeout = setTimeout(() => {
1826
+ setLoadingMore(false);
1827
+ }, 750);
1828
+ return () => clearTimeout(timeout);
1829
+ };
1830
+ const showSelectedItems = selectedItems == null ? void 0 : selectedItems.length;
1831
+ const showSearchBox = !showSelectedItems || multiSelect;
1832
+ const ResolvedRowComponent = rowComponent || DefaultSearchRow;
1833
+ const ResolvedSelectedItemComponent = selectedItemComponent || DefaultSelectedItem;
1834
+ const ResolvedNoResultsComponent = noResultsComponent || DefaultNoResults;
1835
+ const CompIcon = logoIcon && typeof logoIcon !== "string" ? logoIcon : null;
1836
+ const resolvedIcon = CompIcon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CompIcon, { css: badgeIcon }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("img", { src: logoIcon, alt: "Logo", css: badgeIcon });
1837
+ const onDragEnd = (res) => {
1838
+ var _a2, _b2;
1839
+ if (res.destination && res.source.droppableId === ((_a2 = res.destination) == null ? void 0 : _a2.droppableId)) {
1840
+ const result = [...selectedItems || []];
1841
+ const [removed] = (_b2 = result == null ? void 0 : result.splice(res.source.index, 1)) != null ? _b2 : [];
1842
+ result == null ? void 0 : result.splice(res.destination.index, 0, removed);
1843
+ if (onSort) {
1844
+ setSelectedListItems(result);
1845
+ onSort == null ? void 0 : onSort(result);
1846
+ }
1847
+ return result;
1848
+ }
1849
+ };
1850
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1851
+ "div",
1852
+ {
1853
+ css: import_react16.css`
361
1854
  width: 100%;
362
- `,children:(0,v.jsxs)("div",{css:J.css`
1855
+ `,
1856
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1857
+ "div",
1858
+ {
1859
+ css: import_react16.css`
363
1860
  position: relative;
364
1861
  margin-block: var(--spacing-base);
365
- `,children:[an?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{css:Pr,"data-test-id":"component-search",children:(0,v.jsxs)("button",{css:Tr,onClick:jo,type:"button","aria-haspopup":!0,"aria-expanded":m,"aria-controls":`entry-search-config-${Gt.current}`,children:[sn,(0,v.jsx)("span",{css:J.css`
1862
+ `,
1863
+ children: [
1864
+ showSearchBox ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
1865
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { css: entrySearchWrapper, "data-test-id": "component-search", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1866
+ "button",
1867
+ {
1868
+ css: entrySearchBtn,
1869
+ onClick: handleListButtonClick,
1870
+ type: "button",
1871
+ "aria-haspopup": true,
1872
+ "aria-expanded": listOpen,
1873
+ "aria-controls": `entry-search-config-${listBoxId.current}`,
1874
+ children: [
1875
+ resolvedIcon,
1876
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1877
+ "span",
1878
+ {
1879
+ css: import_react16.css`
366
1880
  margin-left: var(--spacing-base);
367
- `,children:"Select"}),(0,v.jsx)("span",{css:_r,children:(0,v.jsx)(pt,{css:[Ir,m?J.css`
1881
+ `,
1882
+ children: "Select"
1883
+ }
1884
+ ),
1885
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { css: entrySearchSelectIcon, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1886
+ ChevronDown_default,
1887
+ {
1888
+ css: [
1889
+ entrySearchSelectImg,
1890
+ !listOpen ? void 0 : import_react16.css`
368
1891
  transform: rotate(180deg);
369
- `:void 0]})})]})}),(0,v.jsxs)("div",{id:`entry-search-config-${Gt.current}`,"aria-hidden":!m,css:[Vr,m?void 0:kr],children:[Ke||null,(0,v.jsxs)("div",{css:J.css`
1892
+ `
1893
+ ]
1894
+ }
1895
+ ) })
1896
+ ]
1897
+ }
1898
+ ) }),
1899
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1900
+ "div",
1901
+ {
1902
+ id: `entry-search-config-${listBoxId.current}`,
1903
+ "aria-hidden": !listOpen,
1904
+ css: [entrySearchConfig, listOpen ? void 0 : entrySearchConfigHidden],
1905
+ children: [
1906
+ helpComponent || null,
1907
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1908
+ "div",
1909
+ {
1910
+ css: import_react16.css`
370
1911
  display: flex;
371
1912
  gap: calc(var(--spacing-base) - 0.25rem);
372
1913
  margin-bottom: var(--spacing-base);
373
- `,children:[(0,v.jsx)(q.InputSelect,{onChange:g=>Q(g.target.value),value:b,label:ve,showLabel:!1,options:[...f?[]:[{value:"any",label:ie}],...r?r.map(g=>({value:g.id,label:g.name})):[]]}),(0,v.jsx)("div",{css:J.css`
1914
+ `,
1915
+ children: [
1916
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1917
+ import_design_system6.InputSelect,
1918
+ {
1919
+ onChange: (e) => setContentTypeSelected(e.target.value),
1920
+ value: contentTypeSelected,
1921
+ label: typeSelectorLabel,
1922
+ showLabel: false,
1923
+ options: [
1924
+ ...!requireContentType ? [{ value: "any", label: typeSelectorAllTypesOptionText }] : [],
1925
+ ...contentTypes ? contentTypes.map((option) => {
1926
+ return {
1927
+ value: option.id,
1928
+ label: option.name
1929
+ };
1930
+ }) : []
1931
+ ]
1932
+ }
1933
+ ),
1934
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1935
+ "div",
1936
+ {
1937
+ css: import_react16.css`
374
1938
  flex-grow: 1;
375
- `,children:(0,v.jsx)(q.InputKeywordSearch,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:N,disabledFieldSubmission:!0,value:H})})]}),(0,v.jsxs)("div",{css:[Dr,q.scrollbarStyles],id:Gt.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list",children:[(0,v.jsx)(q.LoadingOverlay,{isActive:Yo}),Array.isArray(t)&&t.length>0?t.map(g=>(0,v.jsx)(on,{isSelected:B.some(L=>L.id===g.id),result:g,triggerSelection:()=>Zo(g)},g.id)):y?null:(0,v.jsx)(nn,{searchText:H||H,selectedContentType:(Ea=(Ia=r==null?void 0:r.find(g=>g.id===b))==null?void 0:Ia.name)!=null?Ea:b}),!y&&typeof d!="undefined"&&t&&(t==null?void 0:t.length)<d&&(0,v.jsx)("button",{type:"button",css:Lr,onClick:rn,children:Qo?(0,v.jsx)(q.LoadingIndicator,{}):"Load More"})]}),(0,v.jsxs)("div",{css:J.css`
1939
+ `,
1940
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1941
+ import_design_system6.InputKeywordSearch,
1942
+ {
1943
+ inputFieldName: "searchText",
1944
+ placeholder: "Enter keyword to narrow your results",
1945
+ onSearchTextChanged: setTextInput,
1946
+ disabledFieldSubmission: true,
1947
+ value: textInput
1948
+ }
1949
+ )
1950
+ }
1951
+ )
1952
+ ]
1953
+ }
1954
+ ),
1955
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1956
+ "div",
1957
+ {
1958
+ css: [entrySearchResultList, import_design_system6.scrollbarStyles],
1959
+ id: listBoxId.current,
1960
+ role: "listbox",
1961
+ tabIndex: 0,
1962
+ "data-test-id": "entry-list",
1963
+ children: [
1964
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system6.LoadingOverlay, { isActive: showLoadingOverlay }),
1965
+ Array.isArray(results) && results.length > 0 ? results.map((result) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1966
+ ResolvedRowComponent,
1967
+ {
1968
+ isSelected: selectedListItems.some((item) => item.id === result.id),
1969
+ result,
1970
+ triggerSelection: () => handleListItemSelect(result)
1971
+ },
1972
+ result.id
1973
+ )) : resultsLoading ? null : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1974
+ ResolvedNoResultsComponent,
1975
+ {
1976
+ searchText: textInput || textInput,
1977
+ selectedContentType: (_b = (_a = contentTypes == null ? void 0 : contentTypes.find((t) => t.id === contentTypeSelected)) == null ? void 0 : _a.name) != null ? _b : contentTypeSelected
1978
+ }
1979
+ ),
1980
+ !resultsLoading && typeof totalResults !== "undefined" && results && (results == null ? void 0 : results.length) < totalResults && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", css: entrySearchLoadMoreBtn, onClick: handleLoadMoreClick, children: !loadingMore ? "Load More" : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system6.LoadingIndicator, {}) })
1981
+ ]
1982
+ }
1983
+ ),
1984
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1985
+ "div",
1986
+ {
1987
+ css: import_react16.css`
376
1988
  display: flex;
377
1989
  justify-content: space-between;
378
- `,children:[(0,v.jsx)("div",{children:P&&((Ma=r==null?void 0:r.length)!=null?Ma:0)>0?(0,v.jsx)(q.Menu,{menuLabel:"Add new menu",menuTrigger:(0,v.jsx)(q.Button,{buttonType:"secondary",children:"Add New"}),children:r==null?void 0:r.map(g=>(0,v.jsx)(q.MenuItem,{css:J.css`
1990
+ `,
1991
+ children: [
1992
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { children: onAddNew && ((_c = contentTypes == null ? void 0 : contentTypes.length) != null ? _c : 0) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1993
+ import_design_system6.Menu,
1994
+ {
1995
+ menuLabel: "Add new menu",
1996
+ menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system6.Button, { buttonType: "secondary", children: "Add New" }),
1997
+ children: contentTypes == null ? void 0 : contentTypes.map((ct) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1998
+ import_design_system6.MenuItem,
1999
+ {
2000
+ css: import_react16.css`
379
2001
  background: var(--white);
380
2002
  color: var(--brand-secondary-1);
381
- `,onClick:()=>P(g),children:g.name},g.id))}):null}),(0,v.jsxs)("div",{css:J.css`
2003
+ `,
2004
+ onClick: () => onAddNew(ct),
2005
+ children: ct.name
2006
+ },
2007
+ ct.id
2008
+ ))
2009
+ }
2010
+ ) : null }),
2011
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2012
+ "div",
2013
+ {
2014
+ css: import_react16.css`
382
2015
  display: flex;
383
2016
  gap: var(--spacing-base);
384
- `,children:[(0,v.jsx)(q.Button,{buttonType:"unimportant",onClick:tn,children:"Cancel"}),(0,v.jsx)(q.Button,{disabled:!B.length,onClick:en,"data-test-id":"entry-accept-button",children:"Accept"})]})]})]})]}):null,m?null:n&&B.length>1?(0,v.jsx)(Ge.DragDropContext,{onDragEnd:g=>ln(g),children:(0,v.jsx)(Ge.Droppable,{droppableId:s||"canvas-multi-select",children:g=>(0,v.jsxs)("div",{...g.droppableProps,ref:g.innerRef,css:J.css`
2017
+ `,
2018
+ children: [
2019
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system6.Button, { buttonType: "unimportant", onClick: handleCancelClick, children: "Cancel" }),
2020
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2021
+ import_design_system6.Button,
2022
+ {
2023
+ disabled: !selectedListItems.length,
2024
+ onClick: handleAcceptClick,
2025
+ "data-test-id": "entry-accept-button",
2026
+ children: "Accept"
2027
+ }
2028
+ )
2029
+ ]
2030
+ }
2031
+ )
2032
+ ]
2033
+ }
2034
+ )
2035
+ ]
2036
+ }
2037
+ )
2038
+ ] }) : null,
2039
+ !listOpen ? multiSelect && selectedListItems.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_beautiful_dnd.DragDropContext, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_beautiful_dnd.Droppable, { droppableId: multiSelectId || "canvas-multi-select", children: (provided) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2040
+ "div",
2041
+ {
2042
+ ...provided.droppableProps,
2043
+ ref: provided.innerRef,
2044
+ css: import_react16.css`
385
2045
  margin-block: var(--spacing-sm) 0;
386
- `,children:[B==null?void 0:B.map((L,he)=>{if(L!=null&&L.id)return(0,v.jsx)(Ge.Draggable,{draggableId:L.id,index:he,children:(F,Ht)=>(0,v.jsxs)("div",{css:Er,ref:F.innerRef,"data-dragging":Ht.isDragging,...F.draggableProps,...F.dragHandleProps,children:[(0,v.jsxs)("span",{css:Mr,children:[(0,v.jsx)(Ze,{css:[Rt,Ur],width:24,height:24}),(0,v.jsx)(Ze,{css:Rt,width:24,height:24})]}),(0,v.jsx)(Da,{logoIcon:o,selectedItem:L,onDeselect:Nt=>ka(Nt),onEditClosed:w?Nt=>w(Nt):void 0},`selected-item-${L.id}`)]})},L.id)}),g.placeholder]})})}):B==null?void 0:B.map(g=>(0,v.jsx)(Da,{logoIcon:o,selectedItem:g,onDeselect:L=>ka(L),onEditClosed:w?L=>w(L):void 0},`selected-item-${g.id}`))]})})};var Fr=require("@emotion/react");var xe=require("@emotion/react"),Br=xe.css`
2046
+ `,
2047
+ children: [
2048
+ selectedListItems == null ? void 0 : selectedListItems.map((selectedItem, index) => {
2049
+ if (selectedItem == null ? void 0 : selectedItem.id) {
2050
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_beautiful_dnd.Draggable, { draggableId: selectedItem.id, index, children: (provided2, snapshot) => {
2051
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2052
+ "div",
2053
+ {
2054
+ css: draggableContainer,
2055
+ ref: provided2.innerRef,
2056
+ "data-dragging": snapshot.isDragging,
2057
+ ...provided2.draggableProps,
2058
+ ...provided2.dragHandleProps,
2059
+ children: [
2060
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { css: draggableIconWrapper, children: [
2061
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2062
+ MoreVerticalAlt_default,
2063
+ {
2064
+ css: [draggableIcon, draggableIconOffset],
2065
+ width: 24,
2066
+ height: 24
2067
+ }
2068
+ ),
2069
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MoreVerticalAlt_default, { css: draggableIcon, width: 24, height: 24 })
2070
+ ] }),
2071
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2072
+ ResolvedSelectedItemComponent,
2073
+ {
2074
+ logoIcon,
2075
+ selectedItem,
2076
+ onDeselect: (item) => handleDeselect(item),
2077
+ onEditClosed: onEditClosed ? (item) => onEditClosed(item) : void 0
2078
+ },
2079
+ `selected-item-${selectedItem.id}`
2080
+ )
2081
+ ]
2082
+ }
2083
+ );
2084
+ } }, selectedItem.id);
2085
+ }
2086
+ }),
2087
+ provided.placeholder
2088
+ ]
2089
+ }
2090
+ ) }) }) : selectedListItems == null ? void 0 : selectedListItems.map((selectedItem) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2091
+ ResolvedSelectedItemComponent,
2092
+ {
2093
+ logoIcon,
2094
+ selectedItem,
2095
+ onDeselect: (item) => handleDeselect(item),
2096
+ onEditClosed: onEditClosed ? (item) => onEditClosed(item) : void 0
2097
+ },
2098
+ `selected-item-${selectedItem.id}`
2099
+ )) : null
2100
+ ]
2101
+ }
2102
+ )
2103
+ }
2104
+ );
2105
+ };
2106
+
2107
+ // src/components/commerce/ProductSearchRow.tsx
2108
+ var import_react18 = require("@emotion/react");
2109
+
2110
+ // src/components/commerce/styles/ProductSearchRow.styles.ts
2111
+ var import_react17 = require("@emotion/react");
2112
+ var productSearchRowContainer = import_react17.css`
387
2113
  cursor: pointer;
388
2114
  padding: var(--spacing-sm) 0;
389
2115
  margin-right: var(--spacing-sm);
390
2116
  position: relative;
391
2117
  transition: background-color var(--duration-fast) var(--timing-ease-out),
392
2118
  color var(--duration-fast) var(--timing-ease-out);
393
- `,Ar=xe.css`
2119
+ `;
2120
+ var productSearchRowContent = import_react17.css`
394
2121
  border: 2px solid transparent;
395
2122
  border-radius: var(--rounded-base);
396
2123
  display: flex;
397
2124
  align-items: center;
398
2125
  gap: var(--spacing-base);
399
2126
  padding: var(--spacing-sm) var(--spacing-xs);
400
- `,zr=xe.css`
2127
+ `;
2128
+ var productSearchRowContentActive = import_react17.css`
401
2129
  background-color: var(--green-50);
402
- `,Or=xe.css`
2130
+ `;
2131
+ var productSearchRowTitle = import_react17.css`
403
2132
  font-size: var(--fs-sm);
404
2133
  font-weight: var(--fw-bold);
405
2134
  width: 50%;
406
- `,Gr=xe.css`
2135
+ `;
2136
+ var productSearchRowCategory = import_react17.css`
407
2137
  font-weight: var(--fw-normal);
408
2138
  display: block;
409
- `,Hr=xe.css`
2139
+ `;
2140
+ var productSearchRowDetails = import_react17.css`
410
2141
  font-size: var(--fs-sm);
411
2142
  > * {
412
2143
  display: block;
413
2144
  }
414
- `,Nr=xe.css`
2145
+ `;
2146
+ var productSearchRowActiveIcon = import_react17.css`
415
2147
  display: block;
416
2148
  height: 1.5rem;
417
2149
  width: 1.5rem;
418
2150
  color: var(--brand-secondary-3);
419
2151
  margin-left: auto;
420
- `;var j=require("@emotion/react/jsx-runtime");function $r({result:e,isSelected:t,triggerSelection:r}){var s;let{categories:a,logoIcon:o}=Xe(),[i]=e.categories||[{id:"",name:""}],n=typeof i=="undefined"||!a||(s=a.find(l=>l.id===i.id))==null?void 0:s.name;return(0,j.jsx)("div",{"data-value":e.id,role:"option",tabIndex:-1,onClick:()=>r(),css:[Br],children:(0,j.jsxs)("div",{css:[Ar,t?zr:void 0],children:[e.thumbnailUrl?(0,j.jsx)("img",{src:e.thumbnailUrl,alt:`Thumbnail for ${e.title}`,css:Fr.css`
2152
+ `;
2153
+
2154
+ // src/components/commerce/ProductSearchRow.tsx
2155
+ var import_jsx_runtime22 = require("@emotion/react/jsx-runtime");
2156
+ function ProductSearchRow({
2157
+ result,
2158
+ isSelected,
2159
+ triggerSelection
2160
+ }) {
2161
+ var _a;
2162
+ const { categories, logoIcon } = useProductSearchContext();
2163
+ const [category] = result.categories || [{ id: "", name: "" }];
2164
+ const categoryName = typeof category === "undefined" || !categories ? void 0 : (_a = categories.find((c) => c.id === category.id)) == null ? void 0 : _a.name;
2165
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2166
+ "div",
2167
+ {
2168
+ "data-value": result.id,
2169
+ role: "option",
2170
+ tabIndex: -1,
2171
+ onClick: () => triggerSelection(),
2172
+ css: [productSearchRowContainer],
2173
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { css: [productSearchRowContent, isSelected ? productSearchRowContentActive : void 0], children: [
2174
+ result.thumbnailUrl ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2175
+ "img",
2176
+ {
2177
+ src: result.thumbnailUrl,
2178
+ alt: `Thumbnail for ${result.title}`,
2179
+ css: import_react18.css`
421
2180
  background-color: var(--gray-200);
422
2181
  width: 3rem;
423
2182
  height: 3rem;
424
2183
  object-fit: cover;
425
- `}):(0,j.jsx)(te,{src:o,alt:"Logo",css:Fr.css`
2184
+ `
2185
+ }
2186
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2187
+ Image,
2188
+ {
2189
+ src: logoIcon,
2190
+ alt: "Logo",
2191
+ css: import_react18.css`
426
2192
  height: 2.25rem;
427
2193
  width: 2.25rem;
428
- `}),(0,j.jsxs)("h4",{css:[Or],children:[e.title,n?(0,j.jsx)("span",{css:[Gr],children:n}):null]}),(0,j.jsxs)("p",{css:[Hr],children:["SKU: ",e.sku||e.id,e.price!==void 0?(0,j.jsx)("span",{children:e.price}):null]}),t?(0,j.jsx)(ct,{css:[Nr]}):null]})},e.id)}var ke=require("@emotion/react"),kt=require("@uniformdev/design-system"),mo=require("react-icons/cg");var me=require("@emotion/react"),Wr=require("@uniformdev/design-system"),Kr=me.css`
2194
+ `
2195
+ }
2196
+ ),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("h4", { css: [productSearchRowTitle], children: [
2198
+ result.title,
2199
+ categoryName ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { css: [productSearchRowCategory], children: categoryName }) : null
2200
+ ] }),
2201
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { css: [productSearchRowDetails], children: [
2202
+ "SKU: ",
2203
+ result.sku || result.id,
2204
+ result.price !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: result.price }) : null
2205
+ ] }),
2206
+ isSelected ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Checkmark_default, { css: [productSearchRowActiveIcon] }) : null
2207
+ ] })
2208
+ },
2209
+ result.id
2210
+ );
2211
+ }
2212
+
2213
+ // src/components/commerce/ProductSelectedItem.tsx
2214
+ var import_react20 = require("@emotion/react");
2215
+ var import_design_system8 = require("@uniformdev/design-system");
2216
+ var import_cg3 = require("react-icons/cg");
2217
+
2218
+ // src/components/commerce/styles/ProductSelectedItem.styles.ts
2219
+ var import_react19 = require("@emotion/react");
2220
+ var import_design_system7 = require("@uniformdev/design-system");
2221
+ var productSelectedItemContainer = import_react19.css`
429
2222
  border: 1px solid var(--gray-200);
430
2223
  border-radius: var(--rounded-base);
431
2224
  background: var(--gray-50);
432
2225
  display: flex;
433
2226
  width: 100%;
434
- `,Qr=me.css`
2227
+ `;
2228
+ var productSelectedItemDetails = import_react19.css`
435
2229
  align-items: center;
436
2230
  display: flex;
437
2231
  padding: var(--spacing-base) var(--spacing-base) var(--spacing-base) var(--spacing-lg);
@@ -439,22 +2233,25 @@
439
2233
  flex-grow: 1;
440
2234
  gap: var(--spacing-sm);
441
2235
  margin-inline: 0 var(--spacing-sm);
442
- `,Yr=me.css`
2236
+ `;
2237
+ var productSelectedItemContent = import_react19.css`
443
2238
  display: flex;
444
2239
  align-items: center;
445
2240
  gap: var(--spacing-sm);
446
2241
  flex-grow: 1;
447
2242
 
448
- ${(0,Wr.mq)("lg")} {
2243
+ ${(0, import_design_system7.mq)("lg")} {
449
2244
  width: 50%;
450
2245
  margin-bottom: 0;
451
2246
  }
452
- `,Tt=me.css`
2247
+ `;
2248
+ var productSelectedItemImage = import_react19.css`
453
2249
  background-color: var(--gray-200);
454
2250
  width: 3.5rem;
455
2251
  height: 3.5rem;
456
2252
  object-fit: cover;
457
- `,Lt=me.css`
2253
+ `;
2254
+ var productedSelectedItemLinkBtn = import_react19.css`
458
2255
  align-items: center;
459
2256
  background: var(--white);
460
2257
  border-radius: var(--rounded-base);
@@ -469,50 +2266,277 @@
469
2266
  &:hover {
470
2267
  background: var(--gray-50);
471
2268
  }
472
- `,Vt=me.css`
2269
+ `;
2270
+ var productedSelectedItemSmallText = import_react19.css`
473
2271
  font-size: var(--fs-sm);
474
- `,Zr=me.css`
2272
+ `;
2273
+ var productSelectedItemIcon = import_react19.css`
475
2274
  display: block;
476
2275
  width: 1rem;
477
2276
  height: 1rem;
478
- `,Xr=me.css`
2277
+ `;
2278
+ var productSelectedItemLinkContainer = import_react19.css`
479
2279
  display: flex;
480
2280
  flex-direction: column;
481
2281
  gap: var(--spacing-sm);
482
2282
 
483
- ${(0,Wr.mq)("md")} {
2283
+ ${(0, import_design_system7.mq)("md")} {
484
2284
  flex-direction: row;
485
2285
  min-width: 200px;
486
2286
  justify-content: end;
487
2287
  }
488
- `;var k=require("@emotion/react/jsx-runtime");function Jr({selectedItem:e,onDeselect:t}){var n;let{categories:r,logoIcon:a}=Xe(),[o]=e.categories||[{id:"",name:""}],i=typeof o=="undefined"||!r||(n=r.find(s=>s.id===o.id))==null?void 0:n.name;return(0,k.jsx)("div",{css:[Kr],children:(0,k.jsxs)("article",{css:[Qr],children:[(0,k.jsxs)("div",{css:[Yr],children:[e.thumbnailUrl?(0,k.jsx)("img",{src:e.thumbnailUrl,alt:i,css:[Tt],loading:"lazy"}):(0,k.jsx)("div",{css:[Tt]}),(0,k.jsxs)("div",{css:ke.css`
2288
+ `;
2289
+
2290
+ // src/components/commerce/ProductSelectedItem.tsx
2291
+ var import_jsx_runtime23 = require("@emotion/react/jsx-runtime");
2292
+ function ProductSelectedItem({
2293
+ selectedItem,
2294
+ onDeselect
2295
+ }) {
2296
+ var _a;
2297
+ const { categories, logoIcon } = useProductSearchContext();
2298
+ const [category] = selectedItem.categories || [{ id: "", name: "" }];
2299
+ const categoryName = typeof category === "undefined" || !categories ? void 0 : (_a = categories.find((c) => c.id === category.id)) == null ? void 0 : _a.name;
2300
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { css: [productSelectedItemContainer], children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("article", { css: [productSelectedItemDetails], children: [
2301
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { css: [productSelectedItemContent], children: [
2302
+ selectedItem.thumbnailUrl ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2303
+ "img",
2304
+ {
2305
+ src: selectedItem.thumbnailUrl,
2306
+ alt: categoryName,
2307
+ css: [productSelectedItemImage],
2308
+ loading: "lazy"
2309
+ }
2310
+ ) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { css: [productSelectedItemImage] }),
2311
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2312
+ "div",
2313
+ {
2314
+ css: import_react20.css`
489
2315
  > :not(:last-child) {
490
2316
  margin-bottom: var(--spacing-xs);
491
2317
  }
492
- `,children:[(0,k.jsxs)("h4",{css:ke.css`
2318
+ `,
2319
+ children: [
2320
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2321
+ "h4",
2322
+ {
2323
+ css: import_react20.css`
493
2324
  margin-top: 0px;
494
2325
  font-weight: var(--fw-bold);
495
- `,children:[e.title||e.id||"",i&&(0,k.jsx)("span",{css:ke.css`
2326
+ `,
2327
+ children: [
2328
+ selectedItem.title || selectedItem.id || "",
2329
+ categoryName && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2330
+ "span",
2331
+ {
2332
+ css: import_react20.css`
496
2333
  display: block;
497
2334
  font-weight: var(--fw-regular);
498
- `,children:i})]}),(0,k.jsxs)("ul",{css:ke.css`
2335
+ `,
2336
+ children: categoryName
2337
+ }
2338
+ )
2339
+ ]
2340
+ }
2341
+ ),
2342
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2343
+ "ul",
2344
+ {
2345
+ css: import_react20.css`
499
2346
  font-size: var(--fs-sm);
500
2347
 
501
- ${(0,kt.mq)("sm")} {
2348
+ ${(0, import_design_system8.mq)("sm")} {
502
2349
  display: flex;
503
2350
  gap: var(--spacing-base);
504
2351
  }
505
- `,children:[(0,k.jsxs)("li",{children:[(0,k.jsx)("span",{css:ke.css`
2352
+ `,
2353
+ children: [
2354
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("li", { children: [
2355
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2356
+ "span",
2357
+ {
2358
+ css: import_react20.css`
506
2359
  margin-right: var(--spacing-xs);
507
- `,children:"SKU:"}),e.sku||e.id]}),e.price!==void 0?(0,k.jsxs)("li",{children:[(0,k.jsx)("span",{css:ke.css`
2360
+ `,
2361
+ children: "SKU:"
2362
+ }
2363
+ ),
2364
+ selectedItem.sku || selectedItem.id
2365
+ ] }),
2366
+ selectedItem.price !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("li", { children: [
2367
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2368
+ "span",
2369
+ {
2370
+ css: import_react20.css`
508
2371
  margin-right: var(--spacing-xs);
509
- `,children:"Price:"}),(0,k.jsx)("span",{children:e.price})]}):null]})]})]}),(0,k.jsxs)("div",{css:Xr,children:[e.editLink?(0,k.jsxs)("a",{href:e.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:Lt,children:[(0,k.jsx)("span",{css:Vt,children:"Edit"}),(0,k.jsx)(te,{src:a,alt:"Logo",css:Zr})]}):null,(0,k.jsxs)("button",{type:"button",onClick:()=>{t==null||t(e)},css:Lt,children:[(0,k.jsx)("span",{css:Vt,children:"Unlink"}),(0,k.jsx)(kt.Icon,{icon:mo.CgClose,iconColor:"red",size:16})]})]})]})},e.id)}var He=require("@emotion/react/jsx-runtime");function In({selectedProducts:e,setSelectedProducts:t,onGetCategories:r,onSearchProducts:a,logoIcon:o,multiSelect:i,multiSelectId:n,selectedItemComponent:s,rowComponent:l,errorComponent:p,helpComponent:d,noResultsComponent:u,onSort:y,typeSelectorAllTypesOptionText:f="All categories",typeSelectorLabel:P="Select Category"}){var Re,H;let{value:w,loading:T,error:Be}=(0,Dt.useAsync)(async()=>await r(),[r]),Ke=w==null?void 0:w.map(N=>N.id).join(","),ee=(0,we.useMemo)(()=>w?w.map(b=>({id:b.id,name:b.name})):void 0,[Ke]),ve=(0,we.useRef)(),[ie,Qe]=(0,Dt.useAsyncFn)(async(N,b)=>{let Q=await a({text:N,options:{limit:b==null?void 0:b.count,offset:b==null?void 0:b.offset,categoryId:b==null?void 0:b.contentType,cursor:b==null?void 0:b.cursor}});return(b==null?void 0:b.offset)===0&&(ve.current=[]),(ve.current=ve.current||[]).push(...Q.products),Q},[a]),st=async N=>{await t(N)};return Be||ie.error?(0,He.jsx)(p||(({categoriesError:b,searchError:Q})=>(0,He.jsxs)(go.Callout,{type:"error",children:["There was an error: ",(b==null?void 0:b.message)||(Q==null?void 0:Q.message)]})),{categoriesError:Be,searchError:ie.error}):(0,He.jsx)(jr.Provider,{value:{categories:w,logoIcon:o},children:(0,He.jsx)(qr,{search:Qe,results:ve.current,logoIcon:o,selectedItems:e,select:st,multiSelectId:n||"product-search-multi-select",multiSelect:i,contentTypes:ee,selectedItemComponent:s||Jr,rowComponent:l||$r,totalResults:(Re=ie.value)==null?void 0:Re.total,cursor:(H=ie.value)==null?void 0:H.cursor,resultsLoading:ie.loading||T,helpComponent:d,noResultsComponent:u,onSort:y,typeSelectorAllTypesOptionText:f,typeSelectorLabel:P})})}var jr=we.default.createContext(void 0),Xe=()=>{let e=(0,we.useContext)(jr);if(!e)throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");return e};var _e=require("@emotion/react"),ca=require("@uniformdev/design-system"),Ie=require("react"),Et=require("react-icons/cg"),vo=require("timeago.js");var O=require("@emotion/react"),fo=require("@uniformdev/design-system"),ea=O.css`
2372
+ `,
2373
+ children: "Price:"
2374
+ }
2375
+ ),
2376
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: selectedItem.price })
2377
+ ] }) : null
2378
+ ]
2379
+ }
2380
+ )
2381
+ ]
2382
+ }
2383
+ )
2384
+ ] }),
2385
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { css: productSelectedItemLinkContainer, children: [
2386
+ selectedItem.editLink ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2387
+ "a",
2388
+ {
2389
+ href: selectedItem.editLink,
2390
+ title: "edit",
2391
+ rel: "noopener noreferrer",
2392
+ target: "_blank",
2393
+ css: productedSelectedItemLinkBtn,
2394
+ children: [
2395
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { css: productedSelectedItemSmallText, children: "Edit" }),
2396
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Image, { src: logoIcon, alt: "Logo", css: productSelectedItemIcon })
2397
+ ]
2398
+ }
2399
+ ) : null,
2400
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2401
+ "button",
2402
+ {
2403
+ type: "button",
2404
+ onClick: () => {
2405
+ onDeselect == null ? void 0 : onDeselect(selectedItem);
2406
+ },
2407
+ css: productedSelectedItemLinkBtn,
2408
+ children: [
2409
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { css: productedSelectedItemSmallText, children: "Unlink" }),
2410
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system8.Icon, { icon: import_cg3.CgClose, iconColor: "red", size: 16 })
2411
+ ]
2412
+ }
2413
+ )
2414
+ ] })
2415
+ ] }) }, selectedItem.id);
2416
+ }
2417
+
2418
+ // src/components/commerce/ProductSearch.tsx
2419
+ var import_jsx_runtime24 = require("@emotion/react/jsx-runtime");
2420
+ function ProductSearch({
2421
+ selectedProducts,
2422
+ setSelectedProducts,
2423
+ onGetCategories,
2424
+ onSearchProducts,
2425
+ logoIcon,
2426
+ multiSelect,
2427
+ multiSelectId,
2428
+ selectedItemComponent,
2429
+ rowComponent,
2430
+ errorComponent,
2431
+ helpComponent,
2432
+ noResultsComponent,
2433
+ onSort,
2434
+ typeSelectorAllTypesOptionText = "All categories",
2435
+ typeSelectorLabel = "Select Category"
2436
+ }) {
2437
+ var _a, _b;
2438
+ const {
2439
+ value: categories,
2440
+ loading: categoriesLoading,
2441
+ error: categoriesError
2442
+ } = (0, import_react_use3.useAsync)(async () => {
2443
+ return await onGetCategories();
2444
+ }, [onGetCategories]);
2445
+ const categoryIds = categories == null ? void 0 : categories.map((c) => c.id).join(",");
2446
+ const categoryOptions = (0, import_react21.useMemo)(
2447
+ () => {
2448
+ if (!categories) {
2449
+ return void 0;
2450
+ }
2451
+ const result = categories.map((category) => ({
2452
+ id: category.id,
2453
+ name: category.name
2454
+ }));
2455
+ return result;
2456
+ },
2457
+ [categoryIds]
2458
+ );
2459
+ const combinedSearchResults = (0, import_react21.useRef)();
2460
+ const [handleSearchState, handleSearch] = (0, import_react_use3.useAsyncFn)(
2461
+ async (text, options) => {
2462
+ const result = await onSearchProducts({
2463
+ text,
2464
+ options: {
2465
+ limit: options == null ? void 0 : options.count,
2466
+ offset: options == null ? void 0 : options.offset,
2467
+ categoryId: options == null ? void 0 : options.contentType,
2468
+ cursor: options == null ? void 0 : options.cursor
2469
+ }
2470
+ });
2471
+ if ((options == null ? void 0 : options.offset) === 0) {
2472
+ combinedSearchResults.current = [];
2473
+ }
2474
+ (combinedSearchResults.current = combinedSearchResults.current || []).push(...result.products);
2475
+ return result;
2476
+ },
2477
+ [onSearchProducts]
2478
+ );
2479
+ const handleSelect = async (items) => {
2480
+ await setSelectedProducts(items);
2481
+ };
2482
+ if (categoriesError || handleSearchState.error) {
2483
+ const ErrorComp = errorComponent ? errorComponent : ({ categoriesError: categoriesError2, searchError }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_design_system9.Callout, { type: "error", children: [
2484
+ "There was an error: ",
2485
+ (categoriesError2 == null ? void 0 : categoriesError2.message) || (searchError == null ? void 0 : searchError.message)
2486
+ ] });
2487
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ErrorComp, { categoriesError, searchError: handleSearchState.error });
2488
+ }
2489
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ProductSearchContext.Provider, { value: { categories, logoIcon }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2490
+ EntrySearch,
2491
+ {
2492
+ search: handleSearch,
2493
+ results: combinedSearchResults.current,
2494
+ logoIcon,
2495
+ selectedItems: selectedProducts,
2496
+ select: handleSelect,
2497
+ multiSelectId: multiSelectId || "product-search-multi-select",
2498
+ multiSelect,
2499
+ contentTypes: categoryOptions,
2500
+ selectedItemComponent: selectedItemComponent || ProductSelectedItem,
2501
+ rowComponent: rowComponent || ProductSearchRow,
2502
+ totalResults: (_a = handleSearchState.value) == null ? void 0 : _a.total,
2503
+ cursor: (_b = handleSearchState.value) == null ? void 0 : _b.cursor,
2504
+ resultsLoading: handleSearchState.loading || categoriesLoading,
2505
+ helpComponent,
2506
+ noResultsComponent,
2507
+ onSort,
2508
+ typeSelectorAllTypesOptionText,
2509
+ typeSelectorLabel
2510
+ }
2511
+ ) });
2512
+ }
2513
+ var ProductSearchContext = import_react21.default.createContext(void 0);
2514
+ var useProductSearchContext = () => {
2515
+ const context = (0, import_react21.useContext)(ProductSearchContext);
2516
+ if (!context) {
2517
+ throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");
2518
+ }
2519
+ return context;
2520
+ };
2521
+
2522
+ // src/components/dam/DamSelectedItem.tsx
2523
+ var import_react23 = require("@emotion/react");
2524
+ var import_design_system11 = require("@uniformdev/design-system");
2525
+ var import_react24 = require("react");
2526
+ var import_cg4 = require("react-icons/cg");
2527
+ var import_timeago2 = require("timeago.js");
2528
+
2529
+ // src/components/dam/DamSelectedItem.styles.ts
2530
+ var import_react22 = require("@emotion/react");
2531
+ var import_design_system10 = require("@uniformdev/design-system");
2532
+ var damSelectedItemContainer = import_react22.css`
510
2533
  border: 1px solid var(--gray-200);
511
2534
  background: var(--gray-50);
512
2535
  border-radius: var(--rounded-base);
513
2536
  display: flex;
514
2537
  width: 100%;
515
- `,ta=O.css`
2538
+ `;
2539
+ var damSelectedItemInner = import_react22.css`
516
2540
  align-items: center;
517
2541
  display: flex;
518
2542
  flex-grow: 1;
@@ -520,23 +2544,28 @@
520
2544
  margin-inline: 0 var(--spacing-sm);
521
2545
  padding: var(--spacing-base) var(--spacing-base) var(--spacing-base) var(--spacing-lg);
522
2546
  position: relative;
523
- `,ra=O.css`
2547
+ `;
2548
+ var damSelectedItemDetails = import_react22.css`
524
2549
  flex-grow: 1;
525
- `,aa=O.css`
2550
+ `;
2551
+ var damSelectedItemCopy = import_react22.css`
526
2552
  align-items: center;
527
2553
  display: flex;
528
2554
  position: relative;
529
- `,oa=O.css`
2555
+ `;
2556
+ var damSelectedItemTitle = import_react22.css`
530
2557
  color: var(--brand-secondary-1);
531
2558
  font-size: var(--fs-base);
532
2559
  font-weight: var(--fw-bold);
533
2560
  line-height: 1;
534
2561
  margin: 0;
535
2562
  word-break: break-word;
536
- `,na=O.css`
2563
+ `;
2564
+ var damSelectedItemIcon = import_react22.css`
537
2565
  width: 1.5rem;
538
2566
  height: 1.5rem;
539
- `,ia=O.css`
2567
+ `;
2568
+ var damSelectedItemPopover = import_react22.css`
540
2569
  background: var(--white);
541
2570
  border-radius: var(--rounded-base);
542
2571
  border-left: 4px solid var(--brand-secondary-3);
@@ -545,22 +2574,26 @@
545
2574
  padding: var(--spacing-base);
546
2575
  z-index: var(--z-10);
547
2576
  width: max-content;
548
- `,De=O.css`
2577
+ `;
2578
+ var damSelectedItemSmallText = import_react22.css`
549
2579
  font-size: var(--fs-sm);
550
- `,Je=O.css`
2580
+ `;
2581
+ var damSelectedItemPopoverLabel = import_react22.css`
551
2582
  font-weight: var(--fw-bold);
552
2583
  margin-right: var(--spacing-sm);
553
- `,sa=O.css`
2584
+ `;
2585
+ var damSelectedItemLinkContainer = import_react22.css`
554
2586
  display: flex;
555
2587
  flex-direction: column;
556
2588
  gap: var(--spacing-sm);
557
2589
 
558
- ${(0,fo.mq)("md")} {
2590
+ ${(0, import_design_system10.mq)("md")} {
559
2591
  flex-direction: row;
560
2592
  justify-content: end;
561
2593
  min-width: 200px;
562
2594
  }
563
- `,_t=O.css`
2595
+ `;
2596
+ var damSelectedItemLinkBtn = import_react22.css`
564
2597
  align-items: center;
565
2598
  background: var(--white);
566
2599
  border-radius: var(--rounded-base);
@@ -575,40 +2608,340 @@
575
2608
  &:hover {
576
2609
  background: var(--gray-50);
577
2610
  }
578
- `,la=O.css`
2611
+ `;
2612
+ var damSelectedItemMediaContainer = import_react22.css`
579
2613
  display: flex;
580
2614
  margin-top: var(--spacing-sm);
581
2615
  gap: var(--spacing-sm);
582
- `,da=O.css`
2616
+ `;
2617
+ var damSelectedItemInfoBtn = import_react22.css`
583
2618
  background: none;
584
2619
  outline: none;
585
2620
  border: none;
586
2621
  margin: calc(var(--spacing-xs) * -1) 0 calc(var(--spacing-xs) * -1) var(--spacing-sm);
587
- `,It=O.css`
2622
+ `;
2623
+ var damSelectItemImage = import_react22.css`
588
2624
  display: block;
589
2625
  max-width: 100%;
590
2626
  min-width: 100px;
591
2627
  height: auto;
592
- `;var S=require("@emotion/react/jsx-runtime");function En({selectedItem:e,onDeselect:t,onEditClosed:r,logoIcon:a,itemDetailsRendererComponent:o}){let i=(0,Ie.useRef)(null),n=(0,Ie.useRef)(null),[s,l]=(0,Ie.useState)(!1);(0,Ie.useEffect)(()=>{let u=f=>{i.current&&!i.current.contains(f.target)&&n.current&&!n.current.contains(f.target)&&l(!1)},y=()=>{l(!1)};return window.addEventListener("resize",y,!0),document.addEventListener("scroll",u,!0),document.addEventListener("mousedown",u),()=>{window.removeEventListener("resize",y,!0),document.removeEventListener("scroll",u,!0),document.removeEventListener("mousedown",u)}},[n]);let p=()=>{var u;if(l(!s),n.current&&i.current){let y=(u=i==null?void 0:i.current)==null?void 0:u.getBoundingClientRect();n.current.style.top=`${y.top+30}px`}},d=o!=null?o:Mn;return(0,S.jsx)("div",{css:[ea,_e.css`
2628
+ `;
2629
+
2630
+ // src/components/dam/DamSelectedItem.tsx
2631
+ var import_jsx_runtime25 = require("@emotion/react/jsx-runtime");
2632
+ function DamSelectedItem({
2633
+ selectedItem,
2634
+ onDeselect,
2635
+ onEditClosed,
2636
+ logoIcon,
2637
+ itemDetailsRendererComponent
2638
+ }) {
2639
+ const buttonRef = (0, import_react24.useRef)(null);
2640
+ const popoverRef = (0, import_react24.useRef)(null);
2641
+ const [showInfo, setShowInfo] = (0, import_react24.useState)(false);
2642
+ (0, import_react24.useEffect)(() => {
2643
+ const eventHandler = (event) => {
2644
+ if (buttonRef.current && !buttonRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
2645
+ setShowInfo(false);
2646
+ }
2647
+ };
2648
+ const resizeHandler = () => {
2649
+ setShowInfo(false);
2650
+ };
2651
+ window.addEventListener("resize", resizeHandler, true);
2652
+ document.addEventListener("scroll", eventHandler, true);
2653
+ document.addEventListener("mousedown", eventHandler);
2654
+ return () => {
2655
+ window.removeEventListener("resize", resizeHandler, true);
2656
+ document.removeEventListener("scroll", eventHandler, true);
2657
+ document.removeEventListener("mousedown", eventHandler);
2658
+ };
2659
+ }, [popoverRef]);
2660
+ const popoverClick = () => {
2661
+ var _a;
2662
+ setShowInfo(!showInfo);
2663
+ if (popoverRef.current && buttonRef.current) {
2664
+ const buttonPos = (_a = buttonRef == null ? void 0 : buttonRef.current) == null ? void 0 : _a.getBoundingClientRect();
2665
+ popoverRef.current.style["top"] = `${buttonPos.top + 30}px`;
2666
+ }
2667
+ };
2668
+ const ResolvedItemDetailsRendererComponent = itemDetailsRendererComponent != null ? itemDetailsRendererComponent : DefaultDamItemRenderer;
2669
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2670
+ "div",
2671
+ {
2672
+ css: [
2673
+ damSelectedItemContainer,
2674
+ import_react23.css`
593
2675
  margin: 0 0 1rem 0;
594
- `],children:(0,S.jsxs)("div",{css:ta,children:[(0,S.jsxs)("div",{css:ra,children:[(0,S.jsxs)("div",{css:aa,children:[(0,S.jsx)("h4",{css:[oa],title:`ID: ${e.id}`,"data-test-id":"dam-selected-item",children:e.title||e.id||""}),e.popoverData?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button",ref:i,css:da,"aria-controls":"path-details","aria-expanded":s,onClick:p,children:(0,S.jsx)(ca.Icon,{icon:Et.CgInfo,iconColor:"gray",size:24,css:_e.css`
2676
+ `
2677
+ ],
2678
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: damSelectedItemInner, children: [
2679
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: damSelectedItemDetails, children: [
2680
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: damSelectedItemCopy, children: [
2681
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2682
+ "h4",
2683
+ {
2684
+ css: [damSelectedItemTitle],
2685
+ title: `ID: ${selectedItem.id}`,
2686
+ "data-test-id": "dam-selected-item",
2687
+ children: selectedItem.title || selectedItem.id || ""
2688
+ }
2689
+ ),
2690
+ selectedItem.popoverData ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2691
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2692
+ "button",
2693
+ {
2694
+ type: "button",
2695
+ ref: buttonRef,
2696
+ css: damSelectedItemInfoBtn,
2697
+ "aria-controls": "path-details",
2698
+ "aria-expanded": showInfo,
2699
+ onClick: popoverClick,
2700
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2701
+ import_design_system11.Icon,
2702
+ {
2703
+ icon: import_cg4.CgInfo,
2704
+ iconColor: "gray",
2705
+ size: 24,
2706
+ css: import_react23.css`
595
2707
  opacity: var(--opacity-75);
596
- `})}),(0,S.jsx)("div",{id:"path-details","aria-hidden":!s,ref:n,css:[ia,s?_e.css`
2708
+ `
2709
+ }
2710
+ )
2711
+ }
2712
+ ),
2713
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2714
+ "div",
2715
+ {
2716
+ id: "path-details",
2717
+ "aria-hidden": !showInfo,
2718
+ ref: popoverRef,
2719
+ css: [
2720
+ damSelectedItemPopover,
2721
+ showInfo ? import_react23.css`
597
2722
  visibility: visible;
598
- `:_e.css`
2723
+ ` : import_react23.css`
599
2724
  visibility: hidden;
600
- `],children:Object.entries(e.popoverData).map(([u,y],f)=>(0,S.jsxs)("div",{css:De,children:[(0,S.jsxs)("span",{css:Je,children:[u,":"]}),y]},f))})]}):null]}),(0,S.jsx)(d,{item:e})]}),(0,S.jsxs)("div",{css:sa,children:[e.editLink?typeof e.editLink=="string"?(0,S.jsxs)("a",{href:e.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",onClick:u=>{r&&(wt(u.currentTarget.href,()=>r(e)),u.preventDefault())},css:_t,children:[(0,S.jsx)("span",{css:De,children:"Edit"}),a?(0,S.jsx)(te,{src:a,css:na,alt:"Logo"}):null]}):e.editLink:null,(0,S.jsxs)("button",{type:"button",onClick:()=>{t(e)},css:_t,children:[(0,S.jsx)("span",{css:De,children:"Unlink"}),(0,S.jsx)(ca.Icon,{icon:Et.CgClose,iconColor:"red",size:16})]})]})]})},e.id)}function Mn({item:e}){let t=null;return e.previewUrl&&typeof e.previewUrl=="string"?e.type==="image"?t=(0,S.jsx)("img",{src:e.previewUrl,alt:e.id,width:"200",css:It}):e.type==="video"&&(t=(0,S.jsx)("video",{src:e.previewUrl,title:e.id,width:"200",controls:!0,css:It})):e.previewUrl&&typeof e.previewUrl!="string"&&(t=e.previewUrl),t||e.metadata?(0,S.jsxs)("div",{css:la,children:[t?(0,S.jsx)("div",{children:t}):null,(0,S.jsxs)("ul",{children:[e.metadata?Object.entries(e.metadata).map(([r,a])=>(0,S.jsxs)("li",{css:[De,_e.css`
2725
+ `
2726
+ ],
2727
+ children: Object.entries(selectedItem.popoverData).map(([key, value], index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: damSelectedItemSmallText, children: [
2728
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { css: damSelectedItemPopoverLabel, children: [
2729
+ key,
2730
+ ":"
2731
+ ] }),
2732
+ value
2733
+ ] }, index))
2734
+ }
2735
+ )
2736
+ ] }) : null
2737
+ ] }),
2738
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ResolvedItemDetailsRendererComponent, { item: selectedItem })
2739
+ ] }),
2740
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: damSelectedItemLinkContainer, children: [
2741
+ selectedItem.editLink ? typeof selectedItem.editLink === "string" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2742
+ "a",
2743
+ {
2744
+ href: selectedItem.editLink,
2745
+ title: "edit",
2746
+ rel: "noopener noreferrer",
2747
+ target: "_blank",
2748
+ onClick: (e) => {
2749
+ if (onEditClosed) {
2750
+ openWindowWithCloseCallback(e.currentTarget.href, () => onEditClosed(selectedItem));
2751
+ e.preventDefault();
2752
+ }
2753
+ },
2754
+ css: damSelectedItemLinkBtn,
2755
+ children: [
2756
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { css: damSelectedItemSmallText, children: "Edit" }),
2757
+ logoIcon ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Image, { src: logoIcon, css: damSelectedItemIcon, alt: "Logo" }) : null
2758
+ ]
2759
+ }
2760
+ ) : selectedItem.editLink : null,
2761
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2762
+ "button",
2763
+ {
2764
+ type: "button",
2765
+ onClick: () => {
2766
+ onDeselect(selectedItem);
2767
+ },
2768
+ css: damSelectedItemLinkBtn,
2769
+ children: [
2770
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { css: damSelectedItemSmallText, children: "Unlink" }),
2771
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_design_system11.Icon, { icon: import_cg4.CgClose, iconColor: "red", size: 16 })
2772
+ ]
2773
+ }
2774
+ )
2775
+ ] })
2776
+ ] })
2777
+ },
2778
+ selectedItem.id
2779
+ );
2780
+ }
2781
+ function DefaultDamItemRenderer({ item }) {
2782
+ let preview = null;
2783
+ if (item.previewUrl && typeof item.previewUrl === "string") {
2784
+ if (item.type === "image") {
2785
+ preview = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("img", { src: item.previewUrl, alt: item.id, width: "200", css: damSelectItemImage });
2786
+ } else if (item.type === "video") {
2787
+ preview = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("video", { src: item.previewUrl, title: item.id, width: "200", controls: true, css: damSelectItemImage });
2788
+ }
2789
+ } else if (item.previewUrl && typeof item.previewUrl !== "string") {
2790
+ preview = item.previewUrl;
2791
+ }
2792
+ return preview || item.metadata ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: damSelectedItemMediaContainer, children: [
2793
+ preview ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: preview }) : null,
2794
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("ul", { children: [
2795
+ item.metadata ? Object.entries(item.metadata).map(([key, value]) => {
2796
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2797
+ "li",
2798
+ {
2799
+ css: [
2800
+ damSelectedItemSmallText,
2801
+ import_react23.css`
601
2802
  order: 1;
602
- `],children:[(0,S.jsxs)("span",{css:[Je,_e.css`
2803
+ `
2804
+ ],
2805
+ children: [
2806
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2807
+ "span",
2808
+ {
2809
+ css: [
2810
+ damSelectedItemPopoverLabel,
2811
+ import_react23.css`
603
2812
  order: 1;
604
- `],children:[r,":"]}),a]},r)):null,e.createdDate?(0,S.jsxs)("li",{css:De,children:[(0,S.jsx)("span",{css:Je,children:"Date:"}),(0,vo.format)(e.createdDate)]}):null]})]}):null}var At=require("@uniformdev/design-system");var Se=require("react");var ho=require("@uniformdev/design-system"),Mt=require("react");var je=require("@emotion/react/jsx-runtime"),et=(0,Mt.createContext)(void 0),Un=({children:e})=>{let t;return typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"&&(t={sdk:window.UniformMeshSDK}),(0,je.jsxs)(et.Provider,{value:t,children:[(0,je.jsx)(ho.Theme,{}),(0,je.jsx)(tt,{children:e})]})},pa=()=>{let e=(0,Mt.useContext)(et);if(!e)throw new Error("useUniformMeshSdkContext must be used within <MeshApp /> or <UniformMeshSdkContext />");return e};function ua(){let{sdk:e}=pa();return e}var yo=require("@emotion/react/jsx-runtime"),ma=(0,Se.createContext)(void 0),tt=({children:e})=>{let t=ua(),[r,a]=(0,Se.useState)(t.getCurrentLocation()),o=i=>{a(n=>({...n,value:i.newValue}))};return(0,Se.useEffect)(()=>(t.events.on("onValueChanged",o),()=>{t.events.off("onValueChanged",o)}),[t]),(0,yo.jsx)(ma.Provider,{value:{location:r},children:e})},rt=()=>{let e=(0,Se.useContext)(ma);if(!e)throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");return e};var bo=!1;function Ee(e){let{location:t}=rt(),r=e;if(e==="dataTypeInstance"&&(r="dataResource",bo||(console.warn("`dataTypeInstance` mesh location is deprecated, please switch to `dataResource` instead."),bo=!0)),r&&t.type!==r)throw new Error(`Expected location type ${e} but got ${t.type}`);return{...t,setValue:o=>{let{newValue:i,options:n}=o(t.value);t.setValue(i,n)}}}var Po=require("@emotion/react"),To=le(require("@yaireo/tagify/dist/react.tagify")),G=le(require("react"));var Ut=require("@emotion/react"),xo=Ut.css`
2813
+ `
2814
+ ],
2815
+ children: [
2816
+ key,
2817
+ ":"
2818
+ ]
2819
+ }
2820
+ ),
2821
+ value
2822
+ ]
2823
+ },
2824
+ key
2825
+ );
2826
+ }) : null,
2827
+ item.createdDate ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("li", { css: damSelectedItemSmallText, children: [
2828
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { css: damSelectedItemPopoverLabel, children: "Date:" }),
2829
+ (0, import_timeago2.format)(item.createdDate)
2830
+ ] }) : null
2831
+ ] })
2832
+ ] }) : null;
2833
+ }
2834
+
2835
+ // src/components/DataResourceVariablesList.tsx
2836
+ var import_design_system15 = require("@uniformdev/design-system");
2837
+
2838
+ // src/components/UniformMeshLocationContext.tsx
2839
+ var import_react26 = require("react");
2840
+
2841
+ // src/components/UniformMeshSdkContext.tsx
2842
+ var import_design_system12 = require("@uniformdev/design-system");
2843
+ var import_react25 = require("react");
2844
+ var import_jsx_runtime26 = require("@emotion/react/jsx-runtime");
2845
+ var UniformMeshSdkContext = (0, import_react25.createContext)(void 0);
2846
+ var UniformMeshSdkContextProvider = ({ children }) => {
2847
+ let value = void 0;
2848
+ if (typeof window !== "undefined" && typeof window.UniformMeshSDK !== "undefined") {
2849
+ value = {
2850
+ sdk: window.UniformMeshSDK
2851
+ };
2852
+ }
2853
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(UniformMeshSdkContext.Provider, { value, children: [
2854
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system12.Theme, {}),
2855
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UniformMeshLocationContextProvider, { children })
2856
+ ] });
2857
+ };
2858
+ var useUniformMeshSdkContext = () => {
2859
+ const context = (0, import_react25.useContext)(UniformMeshSdkContext);
2860
+ if (!context) {
2861
+ throw new Error("useUniformMeshSdkContext must be used within <MeshApp /> or <UniformMeshSdkContext />");
2862
+ }
2863
+ return context;
2864
+ };
2865
+
2866
+ // src/hooks/useUniformMeshSdk.ts
2867
+ function useUniformMeshSdk() {
2868
+ const { sdk } = useUniformMeshSdkContext();
2869
+ return sdk;
2870
+ }
2871
+
2872
+ // src/components/UniformMeshLocationContext.tsx
2873
+ var import_jsx_runtime27 = require("@emotion/react/jsx-runtime");
2874
+ var UniformMeshLocationContext = (0, import_react26.createContext)(
2875
+ void 0
2876
+ );
2877
+ var UniformMeshLocationContextProvider = ({
2878
+ children
2879
+ }) => {
2880
+ const sdk = useUniformMeshSdk();
2881
+ const [location, setLocation] = (0, import_react26.useState)(sdk.getCurrentLocation());
2882
+ const valueChangeListener = (event) => {
2883
+ setLocation((old) => ({ ...old, value: event.newValue }));
2884
+ };
2885
+ (0, import_react26.useEffect)(() => {
2886
+ sdk.events.on("onValueChanged", valueChangeListener);
2887
+ return () => {
2888
+ sdk.events.off("onValueChanged", valueChangeListener);
2889
+ };
2890
+ }, [sdk]);
2891
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(UniformMeshLocationContext.Provider, { value: { location }, children });
2892
+ };
2893
+ var useUniformMeshLocationContext = () => {
2894
+ const context = (0, import_react26.useContext)(UniformMeshLocationContext);
2895
+ if (!context) {
2896
+ throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");
2897
+ }
2898
+ return context;
2899
+ };
2900
+
2901
+ // src/hooks/useMeshLocation.ts
2902
+ var legacyWarned = false;
2903
+ function useMeshLocation(expectedLocation) {
2904
+ const { location } = useUniformMeshLocationContext();
2905
+ let effectiveExpected = expectedLocation;
2906
+ if (expectedLocation === "dataTypeInstance") {
2907
+ effectiveExpected = "dataResource";
2908
+ if (!legacyWarned) {
2909
+ console.warn(
2910
+ "`dataTypeInstance` mesh location is deprecated, please switch to `dataResource` instead."
2911
+ );
2912
+ legacyWarned = true;
2913
+ }
2914
+ }
2915
+ if (effectiveExpected && location.type !== effectiveExpected) {
2916
+ throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
2917
+ }
2918
+ const proxyLocation = {
2919
+ ...location,
2920
+ setValue: (dispatch) => {
2921
+ const { newValue, options } = dispatch(location.value);
2922
+ location.setValue(newValue, options);
2923
+ }
2924
+ };
2925
+ return proxyLocation;
2926
+ }
2927
+
2928
+ // src/components/Variables/InputVariables.tsx
2929
+ var import_react28 = require("@emotion/react");
2930
+ var import_react29 = __toESM(require("@yaireo/tagify/dist/react.tagify"));
2931
+ var React11 = __toESM(require("react"));
2932
+
2933
+ // src/components/Variables/InputVariables.styles.ts
2934
+ var import_react27 = require("@emotion/react");
2935
+ var variablesFormContainer = import_react27.css`
605
2936
  > * {
606
2937
  margin: var(--spacing-base) 0 0;
607
2938
  }
608
- `,wo=Ut.css`
2939
+ `;
2940
+ var variablesFormBtnGroup = import_react27.css`
609
2941
  display: flex;
610
2942
  gap: var(--spacing-sm);
611
- `,So=Ut.css`
2943
+ `;
2944
+ var tagifyStyles = import_react27.css`
612
2945
  :root {
613
2946
  --tagify-dd-color-primary: rgb(53, 149, 246);
614
2947
  --tagify-dd-bg-color: var(--white);
@@ -1105,14 +3438,246 @@
1105
3438
  opacity: 0;
1106
3439
  transition: inherit;
1107
3440
  }
1108
- `;var Ne=le(require("react"));var Me=require("@uniformdev/design-system"),qt=require("formik");var ae=require("@emotion/react/jsx-runtime");function ga({variable:e,onSubmit:t,onCancel:r}){var o,i,n,s,l,p,d,u,y;let{variables:a}=ge();return(0,ae.jsx)(qt.Formik,{initialValues:{name:e,default:(i=(o=a[e])==null?void 0:o.default)!=null?i:"",displayName:(s=(n=a[e])==null?void 0:n.displayName)!=null?s:"",helpText:(p=(l=a[e])==null?void 0:l.helpText)!=null?p:"",order:(d=a[e])==null?void 0:d.order,type:(y=(u=a[e])==null?void 0:u.type)!=null?y:""},onSubmit:f=>{let P={...f,helpText:f.helpText||void 0,type:f.type||void 0,displayName:f.displayName||void 0};return t(P)},children:({getFieldProps:f,initialValues:P})=>(0,ae.jsxs)(qt.Form,{css:xo,children:[(0,ae.jsx)(Me.Input,{...f("name"),label:"Name",disabled:P.name!=="",caption:"This cannot change once created."}),(0,ae.jsx)(Me.Input,{...f("helpText"),label:"Help Text",caption:"Appears in the composition data resource when entering a value for this variable.",autoComplete:"off"}),(0,ae.jsx)(Me.Input,{...f("default"),label:"Default Value",autoComplete:"off"}),(0,ae.jsxs)("div",{css:wo,children:[(0,ae.jsx)(Me.Button,{type:"submit",children:"Save"}),(0,ae.jsx)(Me.Button,{type:"button",buttonType:"ghost",onClick:r,children:"cancel"})]})]})})}var Bt=require("@emotion/react/jsx-runtime"),Ro=Ne.createContext(null);function at({value:e,onChange:t,editVariableComponent:r,children:a}){let[o,i]=Ne.useState(),n=r!=null?r:ga,s={dispatch:l=>{if(l.type==="set"){let{name:p,...d}=l.variable;t({...s.variables,[l.variable.name]:d}),l.openEditor&&i(l.variable.name)}else if(l.type==="edit")i(l.variable);else if(l.type==="remove"){let p={...e};delete p[l.variable],t(p)}else if(l.type==="reorder")t(l.result);else throw new Error(`Unknown event ${JSON.stringify(l)}`)},variables:e};return(0,Bt.jsxs)(Ro.Provider,{value:s,children:[a,typeof o!="undefined"?(0,Bt.jsx)(n,{onSubmit:l=>{i(void 0);let{name:p,...d}=l;t({...e,[p]:d})},onCancel:()=>i(void 0),variable:o}):null]})}function ge(){let e=Ne.useContext(Ro);if(!e)throw new Error("No VariablesProvider present");return e}var Ue=require("@emotion/react/jsx-runtime");function fa(e){return e.replace(/\${{.*?"value":"([^"]+)".*?}}/g,"${$1}").replace(/[\r\n]+/g,"")}function va({"aria-label":e,value:t,disableVariables:r,onChange:a,onPaste:o}){let{variables:i,dispatch:n}=ge(),s=G.useRef(i),l=G.useRef(n),p=G.useRef(a),d=G.useRef();G.useEffect(()=>{s.current=i},[i]),G.useEffect(()=>{l.current=n},[n]),G.useEffect(()=>{p.current=a},[a]),G.useEffect(()=>{var f;((f=d==null?void 0:d.current)==null?void 0:f.DOM)&&o&&(d.current.DOM.input.onpaste=()=>{var P,w;return o(fa((w=(P=d.current)==null?void 0:P.getInputValue())!=null?w:""))})}),G.useEffect(()=>{var P,w,T;let f=fa((w=(P=d.current)==null?void 0:P.getInputValue())!=null?w:"");t!==f&&((T=d.current)==null||T.loadOriginalValues(t))},[t]);let u=G.useCallback(f=>{p.current(fa(f))},[]),y=G.useCallback(f=>{s.current[f]||l.current({type:"set",variable:{name:f,default:""},openEditor:!0})},[]);return(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(Po.Global,{styles:So}),(0,Ue.jsx)(To.default,{tagifyRef:d,"aria-label":e,defaultValue:t,autoFocus:!1,whitelist:Object.entries(i).map(([f,P])=>{var w;return{name:(w=P.displayName)!=null?w:f,value:f}}),settings:{pattern:r?null:/\$/,enforceWhitelist:r,mixTagsInterpolator:["${","}"],duplicates:!0,tagTextProp:"name",dropdown:{position:"text",enabled:0,mapValueTo:f=>f.name,includeSelectedTags:!0,searchKeys:["name","value"],highlightFirst:!0}},InputMode:"textarea",onAdd:f=>{var w;let P=(w=f.detail.data)==null?void 0:w.value;P&&y(P)},onRemove:f=>{u(f.detail.tagify.getInputValue())},onChange:f=>{u(f.detail.value)},onInput:f=>{u(f.detail.tagify.getInputValue())}})]})}var _o=require("@emotion/react"),D=require("@uniformdev/design-system"),Fe=require("react-beautiful-dnd");var ot=require("@emotion/react"),Lo=e=>ot.css`
3441
+ `;
3442
+
3443
+ // src/components/Variables/VariablesProvider.tsx
3444
+ var React10 = __toESM(require("react"));
3445
+
3446
+ // src/components/Variables/VariableEditor.tsx
3447
+ var import_design_system13 = require("@uniformdev/design-system");
3448
+ var import_formik = require("formik");
3449
+ var import_jsx_runtime28 = require("@emotion/react/jsx-runtime");
3450
+ function VariableEditor({ variable, onSubmit, onCancel }) {
3451
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3452
+ const { variables } = useVariables();
3453
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3454
+ import_formik.Formik,
3455
+ {
3456
+ initialValues: {
3457
+ name: variable,
3458
+ default: (_b = (_a = variables[variable]) == null ? void 0 : _a.default) != null ? _b : "",
3459
+ displayName: (_d = (_c = variables[variable]) == null ? void 0 : _c.displayName) != null ? _d : "",
3460
+ helpText: (_f = (_e = variables[variable]) == null ? void 0 : _e.helpText) != null ? _f : "",
3461
+ order: (_g = variables[variable]) == null ? void 0 : _g.order,
3462
+ type: (_i = (_h = variables[variable]) == null ? void 0 : _h.type) != null ? _i : ""
3463
+ },
3464
+ onSubmit: (values) => {
3465
+ const finalValue = {
3466
+ ...values,
3467
+ helpText: values.helpText || void 0,
3468
+ type: values.type || void 0,
3469
+ displayName: values.displayName || void 0
3470
+ };
3471
+ return onSubmit(finalValue);
3472
+ },
3473
+ children: ({ getFieldProps, initialValues }) => {
3474
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_formik.Form, { css: variablesFormContainer, children: [
3475
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3476
+ import_design_system13.Input,
3477
+ {
3478
+ ...getFieldProps("name"),
3479
+ label: "Name",
3480
+ disabled: initialValues.name !== "",
3481
+ caption: "This cannot change once created."
3482
+ }
3483
+ ),
3484
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3485
+ import_design_system13.Input,
3486
+ {
3487
+ ...getFieldProps("helpText"),
3488
+ label: "Help Text",
3489
+ caption: "Appears in the composition data resource when entering a value for this variable.",
3490
+ autoComplete: "off"
3491
+ }
3492
+ ),
3493
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Input, { ...getFieldProps("default"), label: "Default Value", autoComplete: "off" }),
3494
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { css: variablesFormBtnGroup, children: [
3495
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Button, { type: "submit", children: "Save" }),
3496
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Button, { type: "button", buttonType: "ghost", onClick: onCancel, children: "cancel" })
3497
+ ] })
3498
+ ] });
3499
+ }
3500
+ }
3501
+ );
3502
+ }
3503
+
3504
+ // src/components/Variables/VariablesProvider.tsx
3505
+ var import_jsx_runtime29 = require("@emotion/react/jsx-runtime");
3506
+ var VariablesContext = React10.createContext(null);
3507
+ function VariablesProvider({
3508
+ value,
3509
+ onChange,
3510
+ editVariableComponent,
3511
+ children
3512
+ }) {
3513
+ const [editing, setEditing] = React10.useState();
3514
+ const Editor2 = editVariableComponent != null ? editVariableComponent : VariableEditor;
3515
+ const contextValue = {
3516
+ dispatch: (event) => {
3517
+ if (event.type === "set") {
3518
+ const { name, ...varValue } = event.variable;
3519
+ onChange({ ...contextValue.variables, [event.variable.name]: varValue });
3520
+ if (event.openEditor) {
3521
+ setEditing(event.variable.name);
3522
+ }
3523
+ } else if (event.type === "edit") {
3524
+ setEditing(event.variable);
3525
+ } else if (event.type === "remove") {
3526
+ const newValue = { ...value };
3527
+ delete newValue[event.variable];
3528
+ onChange(newValue);
3529
+ } else if (event.type === "reorder") {
3530
+ onChange(event.result);
3531
+ } else {
3532
+ throw new Error(`Unknown event ${JSON.stringify(event)}`);
3533
+ }
3534
+ },
3535
+ variables: value
3536
+ };
3537
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(VariablesContext.Provider, { value: contextValue, children: [
3538
+ children,
3539
+ typeof editing !== "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3540
+ Editor2,
3541
+ {
3542
+ onSubmit: (val) => {
3543
+ setEditing(void 0);
3544
+ const { name, ...varValue } = val;
3545
+ onChange({ ...value, [name]: varValue });
3546
+ },
3547
+ onCancel: () => setEditing(void 0),
3548
+ variable: editing
3549
+ }
3550
+ ) : null
3551
+ ] });
3552
+ }
3553
+ function useVariables() {
3554
+ const context = React10.useContext(VariablesContext);
3555
+ if (!context) {
3556
+ throw new Error("No VariablesProvider present");
3557
+ }
3558
+ return context;
3559
+ }
3560
+
3561
+ // src/components/Variables/InputVariables.tsx
3562
+ var import_jsx_runtime30 = require("@emotion/react/jsx-runtime");
3563
+ function cleanTagifyValue(rawValue) {
3564
+ return rawValue.replace(/\${{.*?"value":"([^"]+)".*?}}/g, "${$1}").replace(/[\r\n]+/g, "");
3565
+ }
3566
+ function InputVariables({
3567
+ "aria-label": ariaLabel,
3568
+ value,
3569
+ disableVariables,
3570
+ onChange,
3571
+ onPaste
3572
+ }) {
3573
+ const { variables, dispatch } = useVariables();
3574
+ const currentVariables = React11.useRef(variables);
3575
+ const currentDispatch = React11.useRef(dispatch);
3576
+ const currentSetValue = React11.useRef(onChange);
3577
+ const tagifyRef = React11.useRef();
3578
+ React11.useEffect(() => {
3579
+ currentVariables.current = variables;
3580
+ }, [variables]);
3581
+ React11.useEffect(() => {
3582
+ currentDispatch.current = dispatch;
3583
+ }, [dispatch]);
3584
+ React11.useEffect(() => {
3585
+ currentSetValue.current = onChange;
3586
+ }, [onChange]);
3587
+ React11.useEffect(() => {
3588
+ var _a;
3589
+ if (((_a = tagifyRef == null ? void 0 : tagifyRef.current) == null ? void 0 : _a.DOM) && onPaste) {
3590
+ tagifyRef.current.DOM.input.onpaste = () => {
3591
+ var _a2, _b;
3592
+ return onPaste(cleanTagifyValue((_b = (_a2 = tagifyRef.current) == null ? void 0 : _a2.getInputValue()) != null ? _b : ""));
3593
+ };
3594
+ }
3595
+ });
3596
+ React11.useEffect(() => {
3597
+ var _a, _b, _c;
3598
+ const currentTagifyValue = cleanTagifyValue((_b = (_a = tagifyRef.current) == null ? void 0 : _a.getInputValue()) != null ? _b : "");
3599
+ if (value !== currentTagifyValue) {
3600
+ (_c = tagifyRef.current) == null ? void 0 : _c.loadOriginalValues(value);
3601
+ }
3602
+ }, [value]);
3603
+ const handleSetValue = React11.useCallback((rawValue) => {
3604
+ currentSetValue.current(cleanTagifyValue(rawValue));
3605
+ }, []);
3606
+ const handleAddTag = React11.useCallback((newTagName) => {
3607
+ if (!currentVariables.current[newTagName]) {
3608
+ currentDispatch.current({
3609
+ type: "set",
3610
+ variable: { name: newTagName, default: "" },
3611
+ openEditor: true
3612
+ });
3613
+ }
3614
+ }, []);
3615
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
3616
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react28.Global, { styles: tagifyStyles }),
3617
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3618
+ import_react29.default,
3619
+ {
3620
+ tagifyRef,
3621
+ "aria-label": ariaLabel,
3622
+ defaultValue: value,
3623
+ autoFocus: false,
3624
+ whitelist: Object.entries(variables).map(([k, v]) => {
3625
+ var _a;
3626
+ return { name: (_a = v.displayName) != null ? _a : k, value: k };
3627
+ }),
3628
+ settings: {
3629
+ pattern: disableVariables ? null : /\$/,
3630
+ enforceWhitelist: disableVariables,
3631
+ mixTagsInterpolator: ["${", "}"],
3632
+ duplicates: true,
3633
+ tagTextProp: "name",
3634
+ dropdown: {
3635
+ position: "text",
3636
+ enabled: 0,
3637
+ mapValueTo: (v) => v.name,
3638
+ includeSelectedTags: true,
3639
+ searchKeys: ["name", "value"],
3640
+ highlightFirst: true
3641
+ }
3642
+ },
3643
+ InputMode: "textarea",
3644
+ onAdd: (e) => {
3645
+ var _a;
3646
+ const newTagName = (_a = e.detail.data) == null ? void 0 : _a.value;
3647
+ if (newTagName) {
3648
+ handleAddTag(newTagName);
3649
+ }
3650
+ },
3651
+ onRemove: (e) => {
3652
+ handleSetValue(e.detail.tagify.getInputValue());
3653
+ },
3654
+ onChange: (e) => {
3655
+ handleSetValue(e.detail.value);
3656
+ },
3657
+ onInput: (e) => {
3658
+ handleSetValue(e.detail.tagify.getInputValue());
3659
+ }
3660
+ }
3661
+ )
3662
+ ] });
3663
+ }
3664
+
3665
+ // src/components/Variables/VariablesList.tsx
3666
+ var import_react31 = require("@emotion/react");
3667
+ var import_design_system14 = require("@uniformdev/design-system");
3668
+ var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
3669
+
3670
+ // src/components/Variables/styles/VariablesList.styles.ts
3671
+ var import_react30 = require("@emotion/react");
3672
+ var tableRow = (isDragging) => import_react30.css`
1109
3673
  position: relative;
1110
- ${e?`
3674
+ ${isDragging ? `
1111
3675
  display: table;
1112
3676
  left: auto !important;
1113
3677
  top: auto !important;
1114
- `:void 0}
1115
- `,Vo=ot.css`
3678
+ ` : void 0}
3679
+ `;
3680
+ var tableCellDragIcon = import_react30.css`
1116
3681
  &::after {
1117
3682
  content: '';
1118
3683
  display: block;
@@ -1129,7 +3694,8 @@
1129
3694
  &:hover::after {
1130
3695
  opacity: 1;
1131
3696
  }
1132
- `,ko=ot.css`
3697
+ `;
3698
+ var variableName = import_react30.css`
1133
3699
  border: none;
1134
3700
  color: var(--brand-secondary-5);
1135
3701
  font-weight: var(--fw-medium);
@@ -1139,27 +3705,957 @@
1139
3705
  text-overflow: ellipsis;
1140
3706
  white-space: nowrap;
1141
3707
  max-width: 20ch;
1142
- `,Do=ot.css`
3708
+ `;
3709
+ var variableValue = import_react30.css`
1143
3710
  overflow: hidden;
1144
3711
  text-overflow: ellipsis;
1145
3712
  white-space: nowrap;
1146
3713
  max-width: 20ch;
1147
- `;function nt(e){return Object.entries(e||{}).sort(([t,r],[a,o])=>{var i,n;return r.order&&o.order?r.order-o.order:r.order?1:o.order?-1:((i=r.displayName)!=null?i:t).localeCompare((n=o.displayName)!=null?n:a)}).map(([t,r])=>({name:t,...r}))}var V=require("@emotion/react/jsx-runtime");function Bn(){let{variables:e,dispatch:t}=ge(),r=nt(e),a=o=>{var i,n;if(o.destination&&o.source.droppableId===((i=o.destination)==null?void 0:i.droppableId)){let s=[...r||[]],[l]=(n=s==null?void 0:s.splice(o.source.index,1))!=null?n:[];s==null||s.splice(o.destination.index,0,l);let p=s.reduce((d,u,y)=>({...d,[u.name]:{type:u.type,default:u.default,order:y}}),{});return t({type:"reorder",result:p}),s}};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Fe.DragDropContext,{onDragEnd:o=>a(o),children:(0,V.jsx)(Fe.Droppable,{droppableId:"variables-table",children:o=>(0,V.jsxs)(D.Table,{...o.droppableProps,ref:o.innerRef,children:[(0,V.jsx)(D.TableHead,{children:(0,V.jsxs)(D.TableRow,{children:[(0,V.jsx)(D.TableCellHead,{children:"Name"}),(0,V.jsx)(D.TableCellHead,{children:"Default Value"}),(0,V.jsx)(D.TableCellHead,{})]})}),(0,V.jsxs)(D.TableBody,{children:[r.map(({name:i,displayName:n,default:s},l)=>{let p=n!=null?n:i;return(0,V.jsx)(Fe.Draggable,{draggableId:i,index:l,isDragDisabled:r.length===1,children:(d,u)=>(0,V.jsxs)(D.TableRow,{ref:d.innerRef,...d.dragHandleProps,...d.draggableProps,id:p,css:Lo(u.isDragging),"data-dragging":u.isDragging,children:[(0,V.jsx)(D.TableCellData,{css:r.length>1?Vo:void 0,children:(0,V.jsx)("button",{css:ko,type:"button",onClick:y=>{y.preventDefault(),t({type:"edit",variable:i})},title:p,children:p})}),(0,V.jsx)(D.TableCellData,{children:(0,V.jsx)("span",{css:Do,title:s,children:s})}),(0,V.jsx)(D.TableCellData,{align:"right",children:(0,V.jsx)("button",{type:"button",title:`delete ${p}`,css:[D.button,_o.css`
3714
+ `;
3715
+
3716
+ // src/components/Variables/variablesToList.ts
3717
+ function variablesToList(variables) {
3718
+ return Object.entries(variables || {}).sort(([aKey, a], [bKey, b]) => {
3719
+ var _a, _b;
3720
+ if (a.order && b.order) {
3721
+ return a.order - b.order;
3722
+ } else if (a.order) {
3723
+ return 1;
3724
+ } else if (b.order) {
3725
+ return -1;
3726
+ }
3727
+ return ((_a = a.displayName) != null ? _a : aKey).localeCompare((_b = b.displayName) != null ? _b : bKey);
3728
+ }).map(([name, definition]) => ({
3729
+ name,
3730
+ ...definition
3731
+ }));
3732
+ }
3733
+
3734
+ // src/components/Variables/VariablesList.tsx
3735
+ var import_jsx_runtime31 = require("@emotion/react/jsx-runtime");
3736
+ function VariablesList() {
3737
+ const { variables, dispatch } = useVariables();
3738
+ const sorted = variablesToList(variables);
3739
+ const onDragEnd = (res) => {
3740
+ var _a, _b;
3741
+ if (res.destination && res.source.droppableId === ((_a = res.destination) == null ? void 0 : _a.droppableId)) {
3742
+ const result = [...sorted || []];
3743
+ const [removed] = (_b = result == null ? void 0 : result.splice(res.source.index, 1)) != null ? _b : [];
3744
+ result == null ? void 0 : result.splice(res.destination.index, 0, removed);
3745
+ const resultAsObj = result.reduce(
3746
+ (acc, item, index) => ({
3747
+ ...acc,
3748
+ [item.name]: { type: item.type, default: item.default, order: index }
3749
+ }),
3750
+ {}
3751
+ );
3752
+ dispatch({ type: "reorder", result: resultAsObj });
3753
+ return result;
3754
+ }
3755
+ };
3756
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3757
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_beautiful_dnd2.DragDropContext, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_beautiful_dnd2.Droppable, { droppableId: "variables-table", children: (provided) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_design_system14.Table, { ...provided.droppableProps, ref: provided.innerRef, children: [
3758
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_design_system14.TableRow, { children: [
3759
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableCellHead, { children: "Name" }),
3760
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableCellHead, { children: "Default Value" }),
3761
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableCellHead, {})
3762
+ ] }) }),
3763
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_design_system14.TableBody, { children: [
3764
+ sorted.map(({ name, displayName, default: defaultValue }, index) => {
3765
+ const text = displayName != null ? displayName : name;
3766
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3767
+ import_react_beautiful_dnd2.Draggable,
3768
+ {
3769
+ draggableId: name,
3770
+ index,
3771
+ isDragDisabled: sorted.length === 1,
3772
+ children: (provided2, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3773
+ import_design_system14.TableRow,
3774
+ {
3775
+ ref: provided2.innerRef,
3776
+ ...provided2.dragHandleProps,
3777
+ ...provided2.draggableProps,
3778
+ id: text,
3779
+ css: tableRow(snapshot.isDragging),
3780
+ "data-dragging": snapshot.isDragging,
3781
+ children: [
3782
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableCellData, { css: sorted.length > 1 ? tableCellDragIcon : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3783
+ "button",
3784
+ {
3785
+ css: variableName,
3786
+ type: "button",
3787
+ onClick: (e) => {
3788
+ e.preventDefault();
3789
+ dispatch({ type: "edit", variable: name });
3790
+ },
3791
+ title: text,
3792
+ children: text
3793
+ }
3794
+ ) }),
3795
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableCellData, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { css: variableValue, title: defaultValue, children: defaultValue }) }),
3796
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.TableCellData, { align: "right", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3797
+ "button",
3798
+ {
3799
+ type: "button",
3800
+ title: `delete ${text}`,
3801
+ css: [
3802
+ import_design_system14.button,
3803
+ import_react31.css`
1148
3804
  background: transparent;
1149
- `],"aria-controls":p,onClick:()=>t({type:"remove",variable:i}),children:(0,V.jsx)(D.Icon,{icon:"trash",iconColor:"red"})})})]})},i)}),o.placeholder]})]})})}),(0,V.jsx)(D.AddListButton,{onButtonClick:()=>t({type:"edit",variable:""}),"aria-label":"Add variable",buttonText:"add variable",icon:"math-plus",css:{marginLeft:"var(--spacing-md)"}})]})}var oe=require("@emotion/react/jsx-runtime");function An({setVariables:e,noVariables:t,typeRenderers:r}){let{value:a,metadata:{dataType:o}}=Ee("dataTypeInstance"),i=nt(o.variables);return i.length===0?t?(0,oe.jsx)(t,{}):(0,oe.jsx)(At.Callout,{type:"note",children:"No settings are required."}):(0,oe.jsx)("div",{children:i.map(n=>{var l,p,d;let s=n.type&&(l=r==null?void 0:r[n.type])!=null?l:ha;return(0,oe.jsx)("div",{children:(0,oe.jsx)(s,{definition:n,value:(d=(p=a==null?void 0:a[n.name])!=null?p:n.default)!=null?d:"",setValue:u=>{e(y=>{let f=u===n.default,P={...y};return f||u===void 0?delete P[n.name]:P[n.name]=u,{newValue:P}})}})},n.name)})})}function ha({definition:e,value:t,setValue:r}){return(0,oe.jsxs)("div",{children:[(0,oe.jsx)(At.Input,{label:e.displayName||e.name,value:t,caption:e.helpText,onChange:a=>{r(a.target.value)}}),e.default!==""?(0,oe.jsxs)("small",{children:["Default value: ",e.default]}):null]})}var wa=require("@emotion/react"),Bo=le(require("@monaco-editor/react")),Ao=require("@uniformdev/design-system"),zo=require("react");var $e=le(require("react")),Eo=require("@emotion/react/jsx-runtime"),Io=$e.createContext(null);function it({value:e,onChange:t,children:r}){let a=$e.useMemo(()=>({dispatch:o=>{if(o.type==="setRelativeUrl")t(i=>({...i,relativeUrl:o.relativeUrl}));else if(o.type==="updateParameter")t(i=>{let n=[...i.parameters];return typeof o.index=="number"?n[o.index]=o.parameter:n.push(o.parameter),{...i,parameters:n}});else if(o.type==="removeParameter")t(i=>{let n=[...i.parameters];return n.splice(o.index,1),{...i,parameters:n}});else if(o.type==="updateHeader")t(i=>{let n=[...i.headers];return typeof o.index!="undefined"?n[o.index]=o.header:n.push(o.header),{...i,headers:n}});else if(o.type==="removeHeader")t(i=>{let n=[...i.headers];return n.splice(o.index,1),{...i,headers:n}});else if(o.type==="setMethod")t(i=>({...i,method:o.method}));else if(o.type==="setBody")t(i=>{let n=[...i.headers],s=n.findIndex(({key:l})=>l.trim().toLocaleLowerCase()==="content-type");return s>-1?n[s].value=o.contentType:n.push({key:"Content-Type",value:o.contentType}),{...i,body:o.body,headers:n}});else throw new Error(`Unknown event ${JSON.stringify(o)}`)},request:e}),[t,e]);return(0,Eo.jsx)(Io.Provider,{value:a,children:r})}function K(){let e=$e.useContext(Io);if(!e)throw new Error("No RequestProvider present");return e}var ya=require("@emotion/react"),zt=ya.css`
3805
+ `
3806
+ ],
3807
+ "aria-controls": text,
3808
+ onClick: () => dispatch({ type: "remove", variable: name }),
3809
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system14.Icon, { icon: "trash", iconColor: "red" })
3810
+ }
3811
+ ) })
3812
+ ]
3813
+ }
3814
+ )
3815
+ },
3816
+ name
3817
+ );
3818
+ }),
3819
+ provided.placeholder
3820
+ ] })
3821
+ ] }) }) }),
3822
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3823
+ import_design_system14.AddListButton,
3824
+ {
3825
+ onButtonClick: () => dispatch({ type: "edit", variable: "" }),
3826
+ "aria-label": "Add variable",
3827
+ buttonText: "add variable",
3828
+ icon: "math-plus",
3829
+ css: { marginLeft: "var(--spacing-md)" }
3830
+ }
3831
+ )
3832
+ ] });
3833
+ }
3834
+
3835
+ // src/components/DataResourceVariablesList.tsx
3836
+ var import_jsx_runtime32 = require("@emotion/react/jsx-runtime");
3837
+ function DataResourceVariablesList({
3838
+ setVariables,
3839
+ noVariables: NoVariablesComponent,
3840
+ typeRenderers
3841
+ }) {
3842
+ const {
3843
+ value,
3844
+ metadata: { dataType }
3845
+ } = useMeshLocation("dataTypeInstance");
3846
+ const variableDefinitions = variablesToList(dataType.variables);
3847
+ if (variableDefinitions.length === 0) {
3848
+ if (NoVariablesComponent) {
3849
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(NoVariablesComponent, {});
3850
+ }
3851
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system15.Callout, { type: "note", children: "No settings are required." });
3852
+ }
3853
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: variableDefinitions.map((variableDefinition) => {
3854
+ var _a, _b, _c;
3855
+ const VariableRenderer = variableDefinition.type ? (_a = typeRenderers == null ? void 0 : typeRenderers[variableDefinition.type]) != null ? _a : TextVariableRenderer : TextVariableRenderer;
3856
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3857
+ VariableRenderer,
3858
+ {
3859
+ definition: variableDefinition,
3860
+ value: (_c = (_b = value == null ? void 0 : value[variableDefinition.name]) != null ? _b : variableDefinition.default) != null ? _c : "",
3861
+ setValue: (newVariableValue) => {
3862
+ setVariables((previousValue) => {
3863
+ const isDefaultValue = newVariableValue === variableDefinition.default;
3864
+ const newVariables = { ...previousValue };
3865
+ if (isDefaultValue || newVariableValue === void 0) {
3866
+ delete newVariables[variableDefinition.name];
3867
+ } else {
3868
+ newVariables[variableDefinition.name] = newVariableValue;
3869
+ }
3870
+ return { newValue: newVariables };
3871
+ });
3872
+ }
3873
+ }
3874
+ ) }, variableDefinition.name);
3875
+ }) });
3876
+ }
3877
+ function TextVariableRenderer({ definition, value, setValue }) {
3878
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
3879
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3880
+ import_design_system15.Input,
3881
+ {
3882
+ label: definition.displayName || definition.name,
3883
+ value,
3884
+ caption: definition.helpText,
3885
+ onChange: (e) => {
3886
+ setValue(e.target.value);
3887
+ }
3888
+ }
3889
+ ),
3890
+ definition.default !== "" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("small", { children: [
3891
+ "Default value: ",
3892
+ definition.default
3893
+ ] }) : null
3894
+ ] });
3895
+ }
3896
+
3897
+ // src/components/Request/RequestBody.tsx
3898
+ var import_react33 = require("@emotion/react");
3899
+ var import_react34 = __toESM(require("@monaco-editor/react"));
3900
+ var import_design_system16 = require("@uniformdev/design-system");
3901
+ var import_react35 = require("react");
3902
+
3903
+ // src/components/Request/RequestProvider.tsx
3904
+ var React12 = __toESM(require("react"));
3905
+ var import_jsx_runtime33 = require("@emotion/react/jsx-runtime");
3906
+ var RequestContext = React12.createContext(null);
3907
+ function RequestProvider({ value, onChange, children }) {
3908
+ const contextValue = React12.useMemo(() => {
3909
+ return {
3910
+ dispatch: (event) => {
3911
+ if (event.type === "setRelativeUrl") {
3912
+ onChange((old) => ({
3913
+ ...old,
3914
+ relativeUrl: event.relativeUrl
3915
+ }));
3916
+ } else if (event.type === "updateParameter") {
3917
+ onChange((old) => {
3918
+ const newParameters = [...old.parameters];
3919
+ if (typeof event.index === "number") {
3920
+ newParameters[event.index] = event.parameter;
3921
+ } else {
3922
+ newParameters.push(event.parameter);
3923
+ }
3924
+ return { ...old, parameters: newParameters };
3925
+ });
3926
+ } else if (event.type === "removeParameter") {
3927
+ onChange((old) => {
3928
+ const newParameters = [...old.parameters];
3929
+ newParameters.splice(event.index, 1);
3930
+ return { ...old, parameters: newParameters };
3931
+ });
3932
+ } else if (event.type === "updateHeader") {
3933
+ onChange((old) => {
3934
+ const newHeaders = [...old.headers];
3935
+ if (typeof event.index !== "undefined") {
3936
+ newHeaders[event.index] = event.header;
3937
+ } else {
3938
+ newHeaders.push(event.header);
3939
+ }
3940
+ return { ...old, headers: newHeaders };
3941
+ });
3942
+ } else if (event.type === "removeHeader") {
3943
+ onChange((old) => {
3944
+ const newHeaders = [...old.headers];
3945
+ newHeaders.splice(event.index, 1);
3946
+ return { ...old, headers: newHeaders };
3947
+ });
3948
+ } else if (event.type === "setMethod") {
3949
+ onChange((old) => ({ ...old, method: event.method }));
3950
+ } else if (event.type === "setBody") {
3951
+ onChange((old) => {
3952
+ const newHeaders = [...old.headers];
3953
+ const contentTypeIndex = newHeaders.findIndex(
3954
+ ({ key }) => key.trim().toLocaleLowerCase() === "content-type"
3955
+ );
3956
+ if (contentTypeIndex > -1) {
3957
+ newHeaders[contentTypeIndex].value = event.contentType;
3958
+ } else {
3959
+ newHeaders.push({ key: "Content-Type", value: event.contentType });
3960
+ }
3961
+ return {
3962
+ ...old,
3963
+ body: event.body,
3964
+ headers: newHeaders
3965
+ };
3966
+ });
3967
+ } else {
3968
+ throw new Error(`Unknown event ${JSON.stringify(event)}`);
3969
+ }
3970
+ },
3971
+ request: value
3972
+ };
3973
+ }, [onChange, value]);
3974
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RequestContext.Provider, { value: contextValue, children });
3975
+ }
3976
+ function useRequest() {
3977
+ const context = React12.useContext(RequestContext);
3978
+ if (!context) {
3979
+ throw new Error("No RequestProvider present");
3980
+ }
3981
+ return context;
3982
+ }
3983
+
3984
+ // src/components/Request/styles/Request.styles.ts
3985
+ var import_react32 = require("@emotion/react");
3986
+ var innerContentStyles = import_react32.css`
1150
3987
  background: var(--white);
1151
- `,Mo=e=>ya.css`
3988
+ `;
3989
+ var requestTypeContainer = (bgColor) => import_react32.css`
1152
3990
  align-items: start;
1153
- background: ${e};
3991
+ background: ${bgColor};
1154
3992
  display: grid;
1155
3993
  grid-template-columns: 12ch 1fr;
1156
3994
  gap: var(--spacing-sm);
1157
- `;var Uo=require("@emotion/react/jsx-runtime"),xa=({bgColor:e="transparent",children:t,...r})=>(0,Uo.jsx)("div",{css:Mo(e),...r,children:t});var We=require("@emotion/react/jsx-runtime"),zn=[{label:"Text",value:"plaintext"},{label:"JSON",value:"json"},{label:"YAML",value:"yaml"},{label:"JavaScript",value:"javascript"},{label:"XML",value:"xml"},{label:"HTML",value:"html"}],qo={plaintext:"text/plain",json:"application/json",yaml:"application/x-yaml",javascript:"application/javascript",xml:"application/xml",html:"text/html"};function On(){let{request:e,dispatch:t}=K(),[r,a]=(0,zo.useState)("json");return(0,We.jsxs)("div",{css:wa.css`
3995
+ `;
3996
+
3997
+ // src/components/Request/RequestTypeContainer.tsx
3998
+ var import_jsx_runtime34 = require("@emotion/react/jsx-runtime");
3999
+ var RequestTypeContainer = ({
4000
+ bgColor = "transparent",
4001
+ children,
4002
+ ...props
4003
+ }) => {
4004
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { css: requestTypeContainer(bgColor), ...props, children });
4005
+ };
4006
+
4007
+ // src/components/Request/RequestBody.tsx
4008
+ var import_jsx_runtime35 = require("@emotion/react/jsx-runtime");
4009
+ var LANGUAGE_OPTIONS = [
4010
+ { label: "Text", value: "plaintext" },
4011
+ { label: "JSON", value: "json" },
4012
+ { label: "YAML", value: "yaml" },
4013
+ { label: "JavaScript", value: "javascript" },
4014
+ { label: "XML", value: "xml" },
4015
+ { label: "HTML", value: "html" }
4016
+ ];
4017
+ var LANGUAGE_TO_CONTENT_TYPE = {
4018
+ plaintext: "text/plain",
4019
+ json: "application/json",
4020
+ yaml: "application/x-yaml",
4021
+ javascript: "application/javascript",
4022
+ xml: "application/xml",
4023
+ html: "text/html"
4024
+ };
4025
+ function RequestBody() {
4026
+ const { request, dispatch } = useRequest();
4027
+ const [language, setLanguage] = (0, import_react35.useState)("json");
4028
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
4029
+ "div",
4030
+ {
4031
+ css: import_react33.css`
1158
4032
  background: var(--white);
1159
- `,children:[(0,We.jsx)(xa,{bgColor:"var(--gray-100)",css:wa.css`
4033
+ `,
4034
+ children: [
4035
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4036
+ RequestTypeContainer,
4037
+ {
4038
+ bgColor: "var(--gray-100)",
4039
+ css: import_react33.css`
1160
4040
  padding: var(--spacing-sm) var(--spacing-base);
1161
- `,children:(0,We.jsx)(Ao.InputSelect,{label:"Language",showLabel:!1,options:zn,value:r,onChange:o=>{let i=o.currentTarget.value;a(i),e.body&&t({type:"setBody",body:e.body,contentType:qo[i]})}})}),(0,We.jsx)(Bo.default,{height:200,value:e.body,language:r,options:{language:r,minimap:{enabled:!1},folding:!1},onChange:o=>{o&&t({type:"setBody",body:o,contentType:qo[r]})}})]})}var _=require("@uniformdev/design-system");var E=require("@emotion/react/jsx-runtime");function Gn({disableVariables:e}){var o,i;let{dispatch:t,request:r}=K(),a=[...r.headers,{key:"",value:""}];return(0,E.jsx)("div",{css:zt,children:(0,E.jsxs)(_.Table,{children:[(0,E.jsx)(_.TableHead,{children:(0,E.jsxs)(_.TableRow,{children:[(0,E.jsx)(_.TableCellHead,{children:"Name"}),(0,E.jsx)(_.TableCellHead,{children:"Value"})]})}),(0,E.jsxs)(_.TableBody,{children:[(i=(o=r.baseRequest)==null?void 0:o.headers)==null?void 0:i.map(n=>(0,E.jsxs)(_.TableRow,{children:[(0,E.jsxs)(_.TableCellData,{width:"50%",children:[n.key,(0,E.jsx)("br",{}),(0,E.jsx)("i",{css:{color:"var(--gray-500)"},children:(0,E.jsx)("small",{children:"from data source"})})]}),(0,E.jsxs)(_.TableCellData,{width:"50%",children:[(0,E.jsx)("i",{css:{color:"var(--gray-500)"},children:n.value}),r.headers.find(s=>s.key===n.key)?(0,E.jsx)(_.WarningMessage,{message:"overridden below"}):null]})]},n.key)),a.map((n,s)=>(0,E.jsxs)(_.TableRow,{children:[(0,E.jsx)(_.TableCellData,{width:"50%",children:(0,E.jsx)(_.Input,{label:n.key,value:n.key,showLabel:!1,onChange:l=>{l.currentTarget.value?t({type:"updateHeader",header:{key:l.currentTarget.value,value:n.value},index:s}):t({type:"removeHeader",index:s})}})}),(0,E.jsx)(_.TableCellData,{width:"50%",children:n.key?(0,E.jsx)(_.Input,{showLabel:!1,label:n.value,value:n.value,onChange:l=>t({type:"updateHeader",header:{key:n.key,value:l.currentTarget.value},index:s})}):null})]},s))]})]})})}var Oo=require("@uniformdev/design-system");var Go=require("@emotion/react/jsx-runtime");function Hn(e){var a;let{request:t,dispatch:r}=K();return(0,Go.jsx)(Oo.InputSelect,{...e,options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"HEAD",value:"HEAD"}],value:(a=t.method)!=null?a:"GET",onChange:o=>r({type:"setMethod",method:o.currentTarget.value})})}var I=require("@uniformdev/design-system");var M=require("@emotion/react/jsx-runtime");function Nn({disableVariables:e}){var o,i;let{dispatch:t,request:r}=K(),a=[...r.parameters,{key:"",value:""}];return(0,M.jsx)("div",{css:zt,children:(0,M.jsxs)(I.Table,{children:[(0,M.jsx)(I.TableHead,{children:(0,M.jsxs)(I.TableRow,{children:[(0,M.jsx)(I.TableCellHead,{children:"Name"}),(0,M.jsx)(I.TableCellHead,{children:"Value"})]})}),(0,M.jsxs)(I.TableBody,{children:[(i=(o=r.baseRequest)==null?void 0:o.parameters)==null?void 0:i.map(n=>(0,M.jsxs)(I.TableRow,{children:[(0,M.jsxs)(I.TableCellData,{width:"50%",children:[n.key,(0,M.jsx)("br",{}),(0,M.jsx)("i",{css:{color:"var(--gray-500)"},children:(0,M.jsx)("small",{children:"from data source"})})]}),(0,M.jsxs)(I.TableCellData,{width:"50%",children:[(0,M.jsx)("i",{css:{color:"var(--gray-500)"},children:n.value}),r.parameters.find(s=>s.key===n.key)?(0,M.jsx)(I.WarningMessage,{message:"overridden below"}):null]})]},n.key)),a.map((n,s)=>(0,M.jsxs)(I.TableRow,{children:[(0,M.jsx)(I.TableCellData,{width:"50%",children:(0,M.jsx)(I.Input,{label:n.key,value:n.key,showLabel:!1,onChange:l=>{l.currentTarget.value?t({type:"updateParameter",parameter:{key:l.currentTarget.value,value:n.value},index:s}):t({type:"removeParameter",index:s})}})}),(0,M.jsx)(I.TableCellData,{width:"50%",children:n.key?(0,M.jsx)(I.Input,{showLabel:!1,label:n.value,value:n.value,onChange:l=>t({type:"updateParameter",parameter:{key:n.key,value:l.currentTarget.value},index:s})}):null})]},s))]})]})})}var Ho=require("@emotion/react"),No=require("react");function Ca(e,t){return Sa(encodeURI(e),t)}function Ra(e,t){return{key:Sa(encodeURIComponent(e.key),t),value:Sa(encodeURIComponent(e.value),t)}}function Sa(e,t){return e.replace(/(\$|%24)%7B(.*?)%7D/g,(r,a,o)=>{var n;let i=decodeURIComponent(o);return(n=t==null?void 0:t[i])!=null&&n.default?t[i].default:`\${${i}}`})}var fe=require("@emotion/react/jsx-runtime");function Fn(){var a,o;let{variables:e}=ge(),{request:t}=K(),r=(0,No.useMemo)(()=>{var i;return(i=t.baseRequest)!=null&&i.parameters?t.baseRequest.parameters.filter(n=>!t.parameters.find(s=>s.key===n.key)).concat(t.parameters):t.parameters},[(a=t.baseRequest)==null?void 0:a.parameters,t.parameters]);return(0,fe.jsxs)("small",{css:Ho.css`
4041
+ `,
4042
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4043
+ import_design_system16.InputSelect,
4044
+ {
4045
+ label: "Language",
4046
+ showLabel: false,
4047
+ options: LANGUAGE_OPTIONS,
4048
+ value: language,
4049
+ onChange: (e) => {
4050
+ const selectedLanguage = e.currentTarget.value;
4051
+ setLanguage(selectedLanguage);
4052
+ if (request.body) {
4053
+ dispatch({
4054
+ type: "setBody",
4055
+ body: request.body,
4056
+ contentType: LANGUAGE_TO_CONTENT_TYPE[selectedLanguage]
4057
+ });
4058
+ }
4059
+ },
4060
+ "data-test-id": "body-select"
4061
+ }
4062
+ )
4063
+ }
4064
+ ),
4065
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4066
+ import_react34.default,
4067
+ {
4068
+ height: 200,
4069
+ value: request.body,
4070
+ language,
4071
+ options: {
4072
+ language,
4073
+ minimap: { enabled: false },
4074
+ folding: false
4075
+ },
4076
+ onChange: (body) => {
4077
+ if (body) {
4078
+ dispatch({ type: "setBody", body, contentType: LANGUAGE_TO_CONTENT_TYPE[language] });
4079
+ }
4080
+ }
4081
+ }
4082
+ )
4083
+ ]
4084
+ }
4085
+ );
4086
+ }
4087
+
4088
+ // src/components/Request/RequestHeaders.tsx
4089
+ var import_design_system17 = require("@uniformdev/design-system");
4090
+ var import_jsx_runtime36 = require("@emotion/react/jsx-runtime");
4091
+ function RequestHeaders({ disableVariables }) {
4092
+ var _a, _b;
4093
+ const { dispatch, request } = useRequest();
4094
+ const deezHeaders = [...request.headers, { key: "", value: "" }];
4095
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { css: innerContentStyles, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.Table, { children: [
4096
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_design_system17.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.TableRow, { children: [
4097
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_design_system17.TableCellHead, { children: "Name" }),
4098
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_design_system17.TableCellHead, { children: "Value" })
4099
+ ] }) }),
4100
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.TableBody, { children: [
4101
+ (_b = (_a = request.baseRequest) == null ? void 0 : _a.headers) == null ? void 0 : _b.map((baseHeader) => {
4102
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.TableRow, { children: [
4103
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.TableCellData, { width: "50%", children: [
4104
+ baseHeader.key,
4105
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("br", {}),
4106
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("i", { css: { color: "var(--gray-500)" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("small", { children: "from data source" }) })
4107
+ ] }),
4108
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.TableCellData, { width: "50%", children: [
4109
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("i", { css: { color: "var(--gray-500)" }, children: baseHeader.value }),
4110
+ request.headers.find((p) => p.key === baseHeader.key) ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_design_system17.WarningMessage, { message: "overridden below" }) : null
4111
+ ] })
4112
+ ] }, baseHeader.key);
4113
+ }),
4114
+ deezHeaders.map((header, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_design_system17.TableRow, { children: [
4115
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_design_system17.TableCellData, { width: "50%", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4116
+ import_design_system17.Input,
4117
+ {
4118
+ label: header.key,
4119
+ value: header.key,
4120
+ showLabel: false,
4121
+ onChange: (e) => {
4122
+ if (e.currentTarget.value) {
4123
+ dispatch({
4124
+ type: "updateHeader",
4125
+ header: { key: e.currentTarget.value, value: header.value },
4126
+ index
4127
+ });
4128
+ } else {
4129
+ dispatch({ type: "removeHeader", index });
4130
+ }
4131
+ },
4132
+ "data-test-id": "header-key"
4133
+ }
4134
+ ) }),
4135
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_design_system17.TableCellData, { width: "50%", children: header.key ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4136
+ import_design_system17.Input,
4137
+ {
4138
+ showLabel: false,
4139
+ label: header.value,
4140
+ value: header.value,
4141
+ onChange: (e) => dispatch({
4142
+ type: "updateHeader",
4143
+ header: { key: header.key, value: e.currentTarget.value },
4144
+ index
4145
+ }),
4146
+ "data-test-id": "header-value"
4147
+ }
4148
+ ) : null })
4149
+ ] }, index))
4150
+ ] })
4151
+ ] }) });
4152
+ }
4153
+
4154
+ // src/components/Request/RequestMethodSelect.tsx
4155
+ var import_design_system18 = require("@uniformdev/design-system");
4156
+ var import_jsx_runtime37 = require("@emotion/react/jsx-runtime");
4157
+ function RequestMethodSelect(props) {
4158
+ var _a;
4159
+ const { request, dispatch } = useRequest();
4160
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4161
+ import_design_system18.InputSelect,
4162
+ {
4163
+ ...props,
4164
+ options: [
4165
+ { label: "GET", value: "GET" },
4166
+ { label: "POST", value: "POST" },
4167
+ { label: "HEAD", value: "HEAD" }
4168
+ ],
4169
+ value: (_a = request.method) != null ? _a : "GET",
4170
+ onChange: (e) => dispatch({ type: "setMethod", method: e.currentTarget.value })
4171
+ }
4172
+ );
4173
+ }
4174
+
4175
+ // src/components/Request/RequestParameters.tsx
4176
+ var import_design_system19 = require("@uniformdev/design-system");
4177
+ var import_jsx_runtime38 = require("@emotion/react/jsx-runtime");
4178
+ function RequestParameters({ disableVariables }) {
4179
+ var _a, _b;
4180
+ const { dispatch, request } = useRequest();
4181
+ const deezParameters = [...request.parameters, { key: "", value: "" }];
4182
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { css: innerContentStyles, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.Table, { children: [
4183
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_design_system19.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.TableRow, { children: [
4184
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_design_system19.TableCellHead, { children: "Name" }),
4185
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_design_system19.TableCellHead, { children: "Value" })
4186
+ ] }) }),
4187
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.TableBody, { children: [
4188
+ (_b = (_a = request.baseRequest) == null ? void 0 : _a.parameters) == null ? void 0 : _b.map((baseParameter) => {
4189
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.TableRow, { children: [
4190
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.TableCellData, { width: "50%", children: [
4191
+ baseParameter.key,
4192
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("br", {}),
4193
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("i", { css: { color: "var(--gray-500)" }, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("small", { children: "from data source" }) })
4194
+ ] }),
4195
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.TableCellData, { width: "50%", children: [
4196
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("i", { css: { color: "var(--gray-500)" }, children: baseParameter.value }),
4197
+ request.parameters.find((p) => p.key === baseParameter.key) ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_design_system19.WarningMessage, { message: "overridden below" }) : null
4198
+ ] })
4199
+ ] }, baseParameter.key);
4200
+ }),
4201
+ deezParameters.map((parameter, index) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_design_system19.TableRow, { children: [
4202
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_design_system19.TableCellData, { width: "50%", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4203
+ import_design_system19.Input,
4204
+ {
4205
+ label: parameter.key,
4206
+ value: parameter.key,
4207
+ showLabel: false,
4208
+ onChange: (e) => {
4209
+ if (e.currentTarget.value) {
4210
+ dispatch({
4211
+ type: "updateParameter",
4212
+ parameter: { key: e.currentTarget.value, value: parameter.value },
4213
+ index
4214
+ });
4215
+ } else {
4216
+ dispatch({ type: "removeParameter", index });
4217
+ }
4218
+ },
4219
+ "data-test-id": "parameter-key"
4220
+ }
4221
+ ) }),
4222
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_design_system19.TableCellData, { width: "50%", children: parameter.key ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4223
+ import_design_system19.Input,
4224
+ {
4225
+ showLabel: false,
4226
+ label: parameter.value,
4227
+ value: parameter.value,
4228
+ onChange: (e) => dispatch({
4229
+ type: "updateParameter",
4230
+ parameter: { key: parameter.key, value: e.currentTarget.value },
4231
+ index
4232
+ }),
4233
+ "data-test-id": "parameter-value"
4234
+ }
4235
+ ) : null })
4236
+ ] }, index))
4237
+ ] })
4238
+ ] }) });
4239
+ }
4240
+
4241
+ // src/components/Request/RequestUrl.tsx
4242
+ var import_react36 = require("@emotion/react");
4243
+ var import_react37 = require("react");
4244
+
4245
+ // src/components/Request/urlEncodeRequestParameter.ts
4246
+ function urlEncodeRequestUrl(url, varValues) {
4247
+ return decodeVariablesInUrlEncodedString(encodeURI(url), varValues);
4248
+ }
4249
+ function urlEncodeRequestParameter(parameter, varValues) {
4250
+ return {
4251
+ key: decodeVariablesInUrlEncodedString(encodeURIComponent(parameter.key), varValues),
4252
+ value: decodeVariablesInUrlEncodedString(encodeURIComponent(parameter.value), varValues)
4253
+ };
4254
+ }
4255
+ function decodeVariablesInUrlEncodedString(string, varValues) {
4256
+ return string.replace(/(\$|%24)%7B(.*?)%7D/g, (_all, _money, body) => {
4257
+ var _a;
4258
+ const varName = decodeURIComponent(body);
4259
+ return ((_a = varValues == null ? void 0 : varValues[varName]) == null ? void 0 : _a.default) ? varValues[varName].default : `\${${varName}}`;
4260
+ });
4261
+ }
4262
+
4263
+ // src/components/Request/RequestUrl.tsx
4264
+ var import_jsx_runtime39 = require("@emotion/react/jsx-runtime");
4265
+ function RequestUrl() {
4266
+ var _a, _b;
4267
+ const { variables } = useVariables();
4268
+ const { request } = useRequest();
4269
+ const mergedParameters = (0, import_react37.useMemo)(() => {
4270
+ var _a2;
4271
+ if (!((_a2 = request.baseRequest) == null ? void 0 : _a2.parameters)) {
4272
+ return request.parameters;
4273
+ }
4274
+ return request.baseRequest.parameters.filter((baseParam) => !request.parameters.find((p) => p.key === baseParam.key)).concat(request.parameters);
4275
+ }, [(_a = request.baseRequest) == null ? void 0 : _a.parameters, request.parameters]);
4276
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
4277
+ "small",
4278
+ {
4279
+ css: import_react36.css`
1162
4280
  display: inline-block;
1163
4281
  margin-bottom: var(--spacing-xs);
1164
4282
  word-break: break-word;
1165
- `,children:[t.baseRequest?(0,fe.jsx)("span",{children:(o=t.baseRequest)==null?void 0:o.baseUrl}):null,(0,fe.jsxs)("span",{css:{fontWeight:t.baseRequest?"bold":"inherit"},children:[Ca(t.relativeUrl,e),r.length>0?(0,fe.jsxs)(fe.Fragment,{children:["?",r.map((i,n)=>{let s=Ra(i,e);return(0,fe.jsxs)("span",{children:[n>0?"&":null,s.key,"=",s.value]},n)})]}):null]})]})}var Fo=require("@emotion/react/jsx-runtime");function $n(e){let{request:t,dispatch:r}=K();return(0,Fo.jsx)(va,{...e,value:t.relativeUrl,onPaste:a=>{var i,n,s;let o=a.indexOf("?");if(o>=0){let l=a.substring(0,o);((i=t.baseRequest)==null?void 0:i.baseUrl)&&l.startsWith((n=t.baseRequest)==null?void 0:n.baseUrl)&&(l=l.substring((s=t.baseRequest)==null?void 0:s.baseUrl.length)),r({type:"setRelativeUrl",relativeUrl:l});for(let p=t.parameters.length-1;p>=0;p--)r({type:"removeParameter",index:p});try{new URLSearchParams(a.substring(o)).forEach((d,u)=>{r({type:"updateParameter",parameter:{key:u,value:d}})})}catch(p){}}},onChange:a=>{r({type:"setRelativeUrl",relativeUrl:a})}})}var Pa=require("@emotion/react/jsx-runtime");function Wn({onChange:e,children:t}){var o;let{value:r}=Ee("dataSource"),a=$o(r);return(0,Pa.jsx)(at,{value:(o=r.variables)!=null?o:{},onChange:i=>e(n=>({newValue:{...n,variables:i}})),children:(0,Pa.jsx)(it,{value:a,onChange:i=>{e(n=>{let s=$o(n),l=i(s);return{newValue:Kn(n,l)}})},children:t})})}function $o(e){var t,r,a;return{headers:(t=e==null?void 0:e.headers)!=null?t:[],parameters:(r=e==null?void 0:e.parameters)!=null?r:[],relativeUrl:(a=e==null?void 0:e.baseUrl)!=null?a:""}}function Kn(e,t){return{...e,baseUrl:t.relativeUrl,headers:t.headers.length?t.headers:void 0,parameters:t.parameters}}var Ta=require("@emotion/react/jsx-runtime");function Qn({onChange:e,children:t}){var i;let{value:r,metadata:{dataSource:a}}=Ee("dataType"),o=Wo(r,a);return(0,Ta.jsx)(at,{value:(i=r.variables)!=null?i:{},onChange:n=>e(s=>({newValue:{...s,variables:n}})),children:(0,Ta.jsx)(it,{value:o,onChange:n=>{e(s=>{let l=Wo(s,a),p=n(l);return{newValue:Yn(s,p)}})},children:t})})}function Wo(e,t){var r,a;return{...e,headers:(r=e.headers)!=null?r:[],parameters:(a=e.parameters)!=null?a:[],relativeUrl:e.path,baseRequest:{baseUrl:t.baseUrl,headers:t.headers,parameters:t.parameters}}}function Yn(e,t){var r;return{...e,path:t.relativeUrl,headers:t.headers.length?t.headers:void 0,parameters:t.parameters.length?t.parameters:void 0,method:(r=t.method)!=null?r:"GET",body:t.body}}var Ot=require("@uniformdev/design-system");var Ko=require("@uniformdev/mesh-sdk"),qe=require("react"),La=({autoResizingDisabled:e}={})=>{let[t,r]=(0,qe.useState)(),[a,o]=(0,qe.useState)(),i=(0,qe.useRef)(!1);return(0,qe.useEffect)(()=>{typeof window=="undefined"||a||(typeof window.UniformMeshSDK=="undefined"&&!i.current?(i.current=!0,(0,Ko.initializeUniformMeshSDK)({autoResizingDisabled:e}).then(n=>{o(n)}).catch(n=>{r(n)}).finally(()=>{i.current=!1})):o(window.UniformMeshSDK))},[e]),{initializing:!a&&!t,error:t,sdk:a}};var Ce=require("@emotion/react/jsx-runtime"),Zn=({children:e,loadingComponent:t,errorComponent:r})=>{let{initializing:a,error:o,sdk:i}=La();if(a||!i){let n=t;return n?(0,Ce.jsx)(n,{}):(0,Ce.jsx)(Ot.LoadingIndicator,{})}if(o){let n=r;if(n)return(0,Ce.jsx)(n,{error:o});throw o}return(0,Ce.jsxs)(et.Provider,{value:{sdk:i},children:[(0,Ce.jsx)(Ot.Theme,{}),(0,Ce.jsx)(tt,{children:e})]})};function Xn(){let{location:e}=rt();return e}function Jn(e,t){return r=>e(a=>{let{newValue:o,options:i}=r(a);return{newValue:o,options:t(o,i)}})}var h=require("@uniformdev/design-system");se(ne,require("@uniformdev/mesh-sdk"),module.exports);0&&(module.exports={AddListButton,Button,Callout,DamSelectedItem,DataResourceVariablesList,DataSourceEditor,DataTypeEditor,DefaultSearchRow,DefaultSelectedItem,EntrySearch,Heading,Icons,Input,InputComboBox,InputKeywordSearch,InputSelect,InputToggle,InputVariables,KeywordSearchInput,Label,LoadingIndicator,LoadingOverlay,Menu,MenuItem,MeshApp,ProductPreviewList,ProductQuery,ProductQueryContext,ProductSearch,ProductSearchContext,ProductSearchRow,ProductSelectedItem,RequestBody,RequestHeaders,RequestMethodSelect,RequestParameters,RequestProvider,RequestTypeContainer,RequestUrl,RequestUrlInput,ResolvableLoadingValue,ScrollableList,ScrollableListItem,SelectionField,Switch,TextVariableRenderer,Textarea,Theme,UniformMeshLocationContext,UniformMeshLocationContextProvider,UniformMeshSdkContext,UniformMeshSdkContextProvider,VariableEditor,VariablesList,VariablesProvider,badgeIcon,createLocationValidator,damSelectItemImage,damSelectedItemContainer,damSelectedItemCopy,damSelectedItemDetails,damSelectedItemIcon,damSelectedItemInfoBtn,damSelectedItemInner,damSelectedItemLinkBtn,damSelectedItemLinkContainer,damSelectedItemMediaContainer,damSelectedItemPopover,damSelectedItemPopoverLabel,damSelectedItemSmallText,damSelectedItemTitle,draggableContainer,draggableIcon,draggableIconOffset,draggableIconWrapper,entrySearchBtn,entrySearchConfig,entrySearchConfigHidden,entrySearchLoadMoreBtn,entrySearchResultList,entrySearchSelectIcon,entrySearchSelectImg,entrySearchSelectInput,entrySearchSelectOption,entrySearchWrapper,productSearchRowActiveIcon,productSearchRowCategory,productSearchRowContainer,productSearchRowContent,productSearchRowContentActive,productSearchRowDetails,productSearchRowTitle,productSelectedItemContainer,productSelectedItemContent,productSelectedItemDetails,productSelectedItemIcon,productSelectedItemImage,productSelectedItemLinkContainer,productedSelectedItemLinkBtn,productedSelectedItemSmallText,searchRowBtn,searchRowContainer,searchRowContainerActive,searchRowContainerWithPopover,searchRowPopover,searchRowText,searchRowTextSmall,selectItemLinkBtn,selectItemLinkContainer,selectItemPopover,selectItemPopoverLabel,selectItemSmallText,selectedItemContainer,selectedItemCopy,selectedItemDetails,selectedItemIcon,selectedItemInner,selectedItemTitle,urlEncodeRequestParameter,urlEncodeRequestUrl,useInitializeUniformMeshSdk,useMeshLocation,useProductQueryContext,useProductSearchContext,useRequest,useUniformMeshLocation,useUniformMeshLocationContext,useUniformMeshSdk,useUniformMeshSdkContext,useVariables,variablesToList});
4283
+ `,
4284
+ children: [
4285
+ request.baseRequest ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: (_b = request.baseRequest) == null ? void 0 : _b.baseUrl }) : null,
4286
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { css: { fontWeight: request.baseRequest ? "bold" : "inherit" }, children: [
4287
+ urlEncodeRequestUrl(request.relativeUrl, variables),
4288
+ mergedParameters.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
4289
+ "?",
4290
+ mergedParameters.map((param, index) => {
4291
+ const encoded = urlEncodeRequestParameter(param, variables);
4292
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { children: [
4293
+ index > 0 ? "&" : null,
4294
+ encoded.key,
4295
+ "=",
4296
+ encoded.value
4297
+ ] }, index);
4298
+ })
4299
+ ] }) : null
4300
+ ] })
4301
+ ]
4302
+ }
4303
+ );
4304
+ }
4305
+
4306
+ // src/components/Request/RequestUrlInput.tsx
4307
+ var import_jsx_runtime40 = require("@emotion/react/jsx-runtime");
4308
+ function RequestUrlInput(props) {
4309
+ const { request, dispatch } = useRequest();
4310
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4311
+ InputVariables,
4312
+ {
4313
+ ...props,
4314
+ value: request.relativeUrl,
4315
+ onPaste: (value) => {
4316
+ var _a, _b, _c;
4317
+ const indexOfQueryString = value.indexOf("?");
4318
+ if (indexOfQueryString >= 0) {
4319
+ let relativeUrl = value.substring(0, indexOfQueryString);
4320
+ if (((_a = request.baseRequest) == null ? void 0 : _a.baseUrl) && relativeUrl.startsWith((_b = request.baseRequest) == null ? void 0 : _b.baseUrl)) {
4321
+ relativeUrl = relativeUrl.substring((_c = request.baseRequest) == null ? void 0 : _c.baseUrl.length);
4322
+ }
4323
+ dispatch({ type: "setRelativeUrl", relativeUrl });
4324
+ for (let index = request.parameters.length - 1; index >= 0; index--) {
4325
+ dispatch({ type: "removeParameter", index });
4326
+ }
4327
+ try {
4328
+ const query = new URLSearchParams(value.substring(indexOfQueryString));
4329
+ query.forEach((value2, key) => {
4330
+ dispatch({ type: "updateParameter", parameter: { key, value: value2 } });
4331
+ });
4332
+ } catch (e) {
4333
+ }
4334
+ }
4335
+ },
4336
+ onChange: (value) => {
4337
+ dispatch({ type: "setRelativeUrl", relativeUrl: value });
4338
+ }
4339
+ }
4340
+ );
4341
+ }
4342
+
4343
+ // src/components/DataSourceEditor.tsx
4344
+ var import_jsx_runtime41 = require("@emotion/react/jsx-runtime");
4345
+ function DataSourceEditor({ onChange, children }) {
4346
+ var _a;
4347
+ const { value } = useMeshLocation("dataSource");
4348
+ const currentRequestValue = convertDataSourceToRequestData(value);
4349
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4350
+ VariablesProvider,
4351
+ {
4352
+ value: (_a = value.variables) != null ? _a : {},
4353
+ onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
4354
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4355
+ RequestProvider,
4356
+ {
4357
+ value: currentRequestValue,
4358
+ onChange: (requestDispatch) => {
4359
+ onChange((previousDataSource) => {
4360
+ const previousDataSourceAsRequestData = convertDataSourceToRequestData(previousDataSource);
4361
+ const updatedRequestData = requestDispatch(previousDataSourceAsRequestData);
4362
+ return {
4363
+ newValue: convertRequestDataToDataSource(previousDataSource, updatedRequestData)
4364
+ };
4365
+ });
4366
+ },
4367
+ children
4368
+ }
4369
+ )
4370
+ }
4371
+ );
4372
+ }
4373
+ function convertDataSourceToRequestData(dataSource) {
4374
+ var _a, _b, _c;
4375
+ return {
4376
+ headers: (_a = dataSource == null ? void 0 : dataSource.headers) != null ? _a : [],
4377
+ parameters: (_b = dataSource == null ? void 0 : dataSource.parameters) != null ? _b : [],
4378
+ relativeUrl: (_c = dataSource == null ? void 0 : dataSource.baseUrl) != null ? _c : ""
4379
+ };
4380
+ }
4381
+ function convertRequestDataToDataSource(dataSource, requestData) {
4382
+ return {
4383
+ ...dataSource,
4384
+ baseUrl: requestData.relativeUrl,
4385
+ headers: requestData.headers.length ? requestData.headers : void 0,
4386
+ parameters: requestData.parameters
4387
+ };
4388
+ }
4389
+
4390
+ // src/components/DataTypeEditor.tsx
4391
+ var import_jsx_runtime42 = require("@emotion/react/jsx-runtime");
4392
+ function DataTypeEditor({ onChange, children }) {
4393
+ var _a;
4394
+ const {
4395
+ value,
4396
+ metadata: { dataSource }
4397
+ } = useMeshLocation("dataType");
4398
+ const currentRequestValue = convertDataTypeToRequestData(value, dataSource);
4399
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4400
+ VariablesProvider,
4401
+ {
4402
+ value: (_a = value.variables) != null ? _a : {},
4403
+ onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
4404
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4405
+ RequestProvider,
4406
+ {
4407
+ value: currentRequestValue,
4408
+ onChange: (requestDispatch) => {
4409
+ onChange((previousDataType) => {
4410
+ const previousDataTypeAsRequestData = convertDataTypeToRequestData(previousDataType, dataSource);
4411
+ const updatedRequestData = requestDispatch(previousDataTypeAsRequestData);
4412
+ return {
4413
+ newValue: convertRequestDataToDataType(previousDataType, updatedRequestData)
4414
+ };
4415
+ });
4416
+ },
4417
+ children
4418
+ }
4419
+ )
4420
+ }
4421
+ );
4422
+ }
4423
+ function convertDataTypeToRequestData(dataType, dataSource) {
4424
+ var _a, _b;
4425
+ return {
4426
+ ...dataType,
4427
+ headers: (_a = dataType.headers) != null ? _a : [],
4428
+ parameters: (_b = dataType.parameters) != null ? _b : [],
4429
+ relativeUrl: dataType.path,
4430
+ baseRequest: {
4431
+ baseUrl: dataSource.baseUrl,
4432
+ headers: dataSource.headers,
4433
+ parameters: dataSource.parameters
4434
+ }
4435
+ };
4436
+ }
4437
+ function convertRequestDataToDataType(dataType, requestData) {
4438
+ var _a;
4439
+ return {
4440
+ ...dataType,
4441
+ path: requestData.relativeUrl,
4442
+ headers: requestData.headers.length ? requestData.headers : void 0,
4443
+ parameters: requestData.parameters.length ? requestData.parameters : void 0,
4444
+ method: (_a = requestData.method) != null ? _a : "GET",
4445
+ body: requestData.body
4446
+ };
4447
+ }
4448
+
4449
+ // src/components/MeshApp.tsx
4450
+ var import_design_system20 = require("@uniformdev/design-system");
4451
+
4452
+ // src/hooks/useInitializeUniformMeshSdk.ts
4453
+ var import_mesh_sdk = require("@uniformdev/mesh-sdk");
4454
+ var import_react38 = require("react");
4455
+ var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
4456
+ const [error, setError] = (0, import_react38.useState)();
4457
+ const [sdk, setSdk] = (0, import_react38.useState)();
4458
+ const initializationInProgress = (0, import_react38.useRef)(false);
4459
+ (0, import_react38.useEffect)(
4460
+ () => {
4461
+ if (typeof window === "undefined" || sdk) {
4462
+ return;
4463
+ }
4464
+ if (typeof window.UniformMeshSDK === "undefined" && !initializationInProgress.current) {
4465
+ initializationInProgress.current = true;
4466
+ (0, import_mesh_sdk.initializeUniformMeshSDK)({ autoResizingDisabled }).then((sdk2) => {
4467
+ setSdk(sdk2);
4468
+ }).catch((err) => {
4469
+ setError(err);
4470
+ }).finally(() => {
4471
+ initializationInProgress.current = false;
4472
+ });
4473
+ } else {
4474
+ setSdk(window.UniformMeshSDK);
4475
+ }
4476
+ },
4477
+ [autoResizingDisabled]
4478
+ );
4479
+ return {
4480
+ initializing: !sdk && !error,
4481
+ error,
4482
+ sdk
4483
+ };
4484
+ };
4485
+
4486
+ // src/components/MeshApp.tsx
4487
+ var import_jsx_runtime43 = require("@emotion/react/jsx-runtime");
4488
+ var MeshApp = ({
4489
+ children,
4490
+ loadingComponent,
4491
+ errorComponent
4492
+ }) => {
4493
+ const { initializing, error, sdk } = useInitializeUniformMeshSdk();
4494
+ if (initializing || !sdk) {
4495
+ const LoadingComponent = loadingComponent;
4496
+ return LoadingComponent ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(LoadingComponent, {}) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system20.LoadingIndicator, {});
4497
+ }
4498
+ if (error) {
4499
+ const ErrorComponent = errorComponent;
4500
+ if (ErrorComponent) {
4501
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ErrorComponent, { error });
4502
+ }
4503
+ throw error;
4504
+ }
4505
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(UniformMeshSdkContext.Provider, { value: { sdk }, children: [
4506
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system20.Theme, {}),
4507
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(UniformMeshLocationContextProvider, { children })
4508
+ ] });
4509
+ };
4510
+
4511
+ // src/hooks/useUniformMeshLocation.ts
4512
+ function useUniformMeshLocation() {
4513
+ const { location } = useUniformMeshLocationContext();
4514
+ return location;
4515
+ }
4516
+
4517
+ // src/utils/createLocationValidator.ts
4518
+ function createLocationValidator(setValue, validate) {
4519
+ return (dispatch) => setValue((previous) => {
4520
+ const { newValue, options } = dispatch(previous);
4521
+ return { newValue, options: validate(newValue, options) };
4522
+ });
4523
+ }
4524
+
4525
+ // src/index.ts
4526
+ var import_design_system21 = require("@uniformdev/design-system");
4527
+ __reExport(src_exports, require("@uniformdev/mesh-sdk"), module.exports);
4528
+ // Annotate the CommonJS export names for ESM import in node:
4529
+ 0 && (module.exports = {
4530
+ AddListButton,
4531
+ Button,
4532
+ Callout,
4533
+ DamSelectedItem,
4534
+ DataResourceVariablesList,
4535
+ DataSourceEditor,
4536
+ DataTypeEditor,
4537
+ DefaultSearchRow,
4538
+ DefaultSelectedItem,
4539
+ EntrySearch,
4540
+ Heading,
4541
+ Icons,
4542
+ Input,
4543
+ InputComboBox,
4544
+ InputKeywordSearch,
4545
+ InputSelect,
4546
+ InputToggle,
4547
+ InputVariables,
4548
+ KeywordSearchInput,
4549
+ Label,
4550
+ LoadingIndicator,
4551
+ LoadingOverlay,
4552
+ Menu,
4553
+ MenuItem,
4554
+ MeshApp,
4555
+ ProductPreviewList,
4556
+ ProductQuery,
4557
+ ProductQueryContext,
4558
+ ProductSearch,
4559
+ ProductSearchContext,
4560
+ ProductSearchRow,
4561
+ ProductSelectedItem,
4562
+ RequestBody,
4563
+ RequestHeaders,
4564
+ RequestMethodSelect,
4565
+ RequestParameters,
4566
+ RequestProvider,
4567
+ RequestTypeContainer,
4568
+ RequestUrl,
4569
+ RequestUrlInput,
4570
+ ResolvableLoadingValue,
4571
+ ScrollableList,
4572
+ ScrollableListItem,
4573
+ SelectionField,
4574
+ Switch,
4575
+ TextVariableRenderer,
4576
+ Textarea,
4577
+ Theme,
4578
+ UniformMeshLocationContext,
4579
+ UniformMeshLocationContextProvider,
4580
+ UniformMeshSdkContext,
4581
+ UniformMeshSdkContextProvider,
4582
+ VariableEditor,
4583
+ VariablesList,
4584
+ VariablesProvider,
4585
+ badgeIcon,
4586
+ createLocationValidator,
4587
+ damSelectItemImage,
4588
+ damSelectedItemContainer,
4589
+ damSelectedItemCopy,
4590
+ damSelectedItemDetails,
4591
+ damSelectedItemIcon,
4592
+ damSelectedItemInfoBtn,
4593
+ damSelectedItemInner,
4594
+ damSelectedItemLinkBtn,
4595
+ damSelectedItemLinkContainer,
4596
+ damSelectedItemMediaContainer,
4597
+ damSelectedItemPopover,
4598
+ damSelectedItemPopoverLabel,
4599
+ damSelectedItemSmallText,
4600
+ damSelectedItemTitle,
4601
+ draggableContainer,
4602
+ draggableIcon,
4603
+ draggableIconOffset,
4604
+ draggableIconWrapper,
4605
+ entrySearchBtn,
4606
+ entrySearchConfig,
4607
+ entrySearchConfigHidden,
4608
+ entrySearchLoadMoreBtn,
4609
+ entrySearchResultList,
4610
+ entrySearchSelectIcon,
4611
+ entrySearchSelectImg,
4612
+ entrySearchSelectInput,
4613
+ entrySearchSelectOption,
4614
+ entrySearchWrapper,
4615
+ productSearchRowActiveIcon,
4616
+ productSearchRowCategory,
4617
+ productSearchRowContainer,
4618
+ productSearchRowContent,
4619
+ productSearchRowContentActive,
4620
+ productSearchRowDetails,
4621
+ productSearchRowTitle,
4622
+ productSelectedItemContainer,
4623
+ productSelectedItemContent,
4624
+ productSelectedItemDetails,
4625
+ productSelectedItemIcon,
4626
+ productSelectedItemImage,
4627
+ productSelectedItemLinkContainer,
4628
+ productedSelectedItemLinkBtn,
4629
+ productedSelectedItemSmallText,
4630
+ searchRowBtn,
4631
+ searchRowContainer,
4632
+ searchRowContainerActive,
4633
+ searchRowContainerWithPopover,
4634
+ searchRowPopover,
4635
+ searchRowText,
4636
+ searchRowTextSmall,
4637
+ selectItemLinkBtn,
4638
+ selectItemLinkContainer,
4639
+ selectItemPopover,
4640
+ selectItemPopoverLabel,
4641
+ selectItemSmallText,
4642
+ selectedItemContainer,
4643
+ selectedItemCopy,
4644
+ selectedItemDetails,
4645
+ selectedItemIcon,
4646
+ selectedItemInner,
4647
+ selectedItemTitle,
4648
+ urlEncodeRequestParameter,
4649
+ urlEncodeRequestUrl,
4650
+ useInitializeUniformMeshSdk,
4651
+ useMeshLocation,
4652
+ useProductQueryContext,
4653
+ useProductSearchContext,
4654
+ useRequest,
4655
+ useUniformMeshLocation,
4656
+ useUniformMeshLocationContext,
4657
+ useUniformMeshSdk,
4658
+ useUniformMeshSdkContext,
4659
+ useVariables,
4660
+ variablesToList
4661
+ });