@nice2dev/ui-api 1.1.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -0
- package/dist/index.cjs +4 -1
- package/dist/index.mjs +2400 -5
- package/dist/ui-api.css +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,144 @@
|
|
|
1
1
|
# @nice2dev/ui-api
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3a4939d: 1.2.0 — the API cleanup announced for this version, dictionaries per language by default, and
|
|
8
|
+
three new controls. **Breaking:** every removal has a replacement, listed name by name in
|
|
9
|
+
`documentation/omniverk/OMNIVERK_UPGRADE_1.2.0.md`.
|
|
10
|
+
|
|
11
|
+
**Removed (breaking).** All 118 `@deprecated` names: the aliases without the `Nice` prefix in
|
|
12
|
+
`ui-audio`, `ui-graphics` and `ui-3d`; `NiceBarcodeGenerator` (→ `NiceBarcode`), `NiceFloorPlanCanvas`
|
|
13
|
+
(→ `NiceSpatialEditor` in `@nice2dev/ui-buildings`), the v2 props and types of `NiceTopNav`,
|
|
14
|
+
`NiceProgress.showLabel`, `NiceCountryPicker.showDialCode` / `showFlag`, `type` on
|
|
15
|
+
`NiceDateTimePicker` / `NiceDateRangeBox` (→ `dateFormatPreset`); `ZoneOccupancy` in
|
|
16
|
+
`ui-buildings` and `events`, the `SmartHome*` types; the icon variant `flat` (→ `cutout`) and
|
|
17
|
+
`NiceIconEditor` (→ `NiceVectorEditor`); `NiceSizeLegacy`; the `snapGrid` module of `ui-diagrams` (→
|
|
18
|
+
`@nice2dev/spatial-core`); the opt-in stylesheet `@nice2dev/ui/css/legacy-bg-text-aliases.css`, which
|
|
19
|
+
formed an alias cycle with `style.css`. Props that were accepted and never read — 19 on
|
|
20
|
+
`NiceModuleGrid`, and more on `NiceAutocomplete`, `NiceTaskInbox`, `NiceConsentBanner`, the
|
|
21
|
+
building and communication controls, four `ui-audio` panels and `NiceStreamDashboard` — are gone
|
|
22
|
+
from the types. `NiceResourceAllocation` in `ui-erp` is `NiceCapacityPlanner` (the one in `ui`
|
|
23
|
+
keeps its name); `NiceGenericPlayerStageVisualizer` (→ `NiceStageVisualizer`) and
|
|
24
|
+
`NiceCubeBrowserProps` are removed. The `@nice2dev/ui/overlays` entry calls its modal, drawer,
|
|
25
|
+
bottom sheet and context menu `NiceOverlayModal`, `NiceOverlayDrawer`, `NiceOverlayBottomSheet` and
|
|
26
|
+
`NiceOverlayContextMenu`: the old names belonged to different components of `@nice2dev/ui`.
|
|
27
|
+
|
|
28
|
+
**Dictionaries per language.** `NiceI18nProvider` loads only the language in use, with `import()`
|
|
29
|
+
(it was `NiceI18nLazyProvider` in 1.1.10, which stays as the same component); the controls show their
|
|
30
|
+
built-in English until it arrives — `await loadNiceDictionary(lang)` before the first render to start
|
|
31
|
+
in the language. Nothing on the main entry of `@nice2dev/i18n` imports a dictionary any more:
|
|
32
|
+
`NICE_I18N_DICTIONARIES`, `createTranslator`, `NICE_I18N_VARIANTS` / `resolvePlVariant` and the
|
|
33
|
+
translation tooling moved to the new entry `@nice2dev/i18n/all`, and `@nice2dev/ui-core` no longer
|
|
34
|
+
re-exports the dictionary map. `@nice2dev/ui` with what it bundles: 1283 kB → 952 kB gzip loaded up
|
|
35
|
+
front. The `ui-audio` controls read the app's `NiceI18nProvider` now; their own provider overrides it.
|
|
36
|
+
|
|
37
|
+
**New controls.** `NiceRecurrenceEditor`, `NiceStopwatch`, `NiceCountdownTimer` (`@nice2dev/ui`) and
|
|
38
|
+
`NicePasswordGenerator` (`@nice2dev/auth`), plus `recurrenceDates()` and `generatePassword()`.
|
|
39
|
+
`NiceScheduler` honours a weekly rule's `byDay`, which it ignored.
|
|
40
|
+
|
|
41
|
+
**Visible changes.** The palette meets WCAG AA for text on every fill: darker fills in the light
|
|
42
|
+
theme, dark text on the fills of the dark theme (new `--nice-text-on-success` / `-error` / `-info` /
|
|
43
|
+
`-accent` / `-warning`; `NiceThemeText` takes `onSuccess`, `onError`, `onInfo`, `onWarning`). Mobile
|
|
44
|
+
and platform panels follow the app theme instead of `prefers-color-scheme`. Swipes in
|
|
45
|
+
`NiceSwipeActions`, `NiceTouchTable` and `NiceMobileCalendar` work with a mouse and a pen. The
|
|
46
|
+
`ui-forms` editors have the intended spacing (it was four times too large). `NiceMAM`,
|
|
47
|
+
`NiceTranscoder`, `NiceVideoAnnotator` and `NiceStreamDashboard` use `nice-`-prefixed BEM classes.
|
|
48
|
+
|
|
49
|
+
**Fixes.** Controls that invented results ask the host instead: `NiceIntegrationHub`,
|
|
50
|
+
`NiceMLStudio` (`onExperimentRun` may return metrics), `NiceRemoteManagement`
|
|
51
|
+
(`onCaptureScreenshot`), `NicePoseDetector` (`detector`), `NiceBatchScannerProvider`,
|
|
52
|
+
`NiceCacheStrategies`; `NiceLowCodeStudio` accepts dropped components. Controls that did nothing
|
|
53
|
+
work or say why they are off: `NiceStreamDashboard` adds sources, sends chat and runs the chosen
|
|
54
|
+
transition (new `onAddPlatform`, `onSendChatMessage`, `onTransition`, `onScreenshot`,
|
|
55
|
+
`onOpenAudioMixer`, `onOpenSettings`; `receiveChatMessage` feeds incoming chat), `NiceMLStudio`
|
|
56
|
+
downloads through `onModelDownload`, `NiceETLBuilder` saves through `onSave` (its Save button had
|
|
57
|
+
no handler), `NiceTranscoder` makes jobs of picked and dropped files, `NiceAutomationEditor` offers
|
|
58
|
+
the trigger types its model has. Texts of about fifty components go
|
|
59
|
+
through `t()` in six languages, among them the AI data grid, chart and form builders, the ML
|
|
60
|
+
studio, the report designer, the song picker, `NiceProtocolConfig`, `NiceETLBuilder` and
|
|
61
|
+
`NiceInlineHelp` — every key the controls pass to `t()` now has a dictionary entry, so none of
|
|
62
|
+
them stays English under another language; `NiceDataGridAI` sorts on a query in any language, not
|
|
63
|
+
only in English. `NiceWindow`, `NiceConsole`, `NiceFileManager` and `NiceGitManager` no longer
|
|
64
|
+
crash when `accessMode` switches to or from `'hidden'`. Ids come from `createId()` (`@nice2dev/ui-core`), so nothing throws
|
|
65
|
+
outside a secure context as `crypto.randomUUID()` did on plain http. `ui-3d` runs on three r183
|
|
66
|
+
without its deprecation warnings. `NiceRemoteManagement` calls the handlers of the latest render.
|
|
67
|
+
The AI hint popover and the `ui-platform` panels follow the app theme, not the system's or a
|
|
68
|
+
`.dark` class on the host. `NiceCommandPalette` has styles and its search filters;
|
|
69
|
+
`NiceTimeoutFeedback` starts its clock; `NiceOfflineBanner` takes `online`; Monaco's workers in
|
|
70
|
+
`NiceCodeEditor` load; the `ui-audio` panels that used Bootstrap classes use Nice controls; colours
|
|
71
|
+
that reached a canvas as `var(…)` (karaoke lanes and notes) are resolved first.
|
|
72
|
+
|
|
73
|
+
## 1.1.10
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- The package description on npm shows a dash instead of the mis-encoded "—".
|
|
78
|
+
- 1.1.10 — the additive part of OmniVerk's 1.2.0 list: ui-audio builds without optional packages, one
|
|
79
|
+
i18n context, dictionaries per language, data props optional. No breaking changes.
|
|
80
|
+
|
|
81
|
+
**`@nice2dev/ui-audio` no longer breaks the consumer's build.** It imported `react-bootstrap`,
|
|
82
|
+
`recharts`, `react-window`, `react-youtube` and `pitchy` statically while declaring none of them
|
|
83
|
+
(only optional entries in `peerDependenciesMeta`), so a Vite app without them failed with "failed to
|
|
84
|
+
resolve import". Loading them with `import()` is no way out: Vite 8 (Rolldown) resolves dynamic
|
|
85
|
+
imports at build time and fails the same way, which made `hls.js` and `phaser` mandatory too.
|
|
86
|
+
`react-bootstrap`, `recharts`, `react-window` and `phaser` are now gone from the code
|
|
87
|
+
(`NiceBarFillEditor` uses Nice controls, `NiceVocalPerformanceReport` uses `NiceChart` /
|
|
88
|
+
`NicePieChart`, the karaoke editor list uses `NiceVirtualScroller`, `NiceKaraokePhaserRenderer`
|
|
89
|
+
renders with the DOM and keeps its name); `pitchy`, `react-youtube` and `hls.js` are regular
|
|
90
|
+
`dependencies`. Found on the way: in live mode the vocal performance report subtracted UltraStar note
|
|
91
|
+
numbers from MIDI pitch, so every singer got thousands of cents of deviation and 0 % accuracy — it now
|
|
92
|
+
compares pitch within the octave, as the scoring does; `NiceBarFillEditor` put a colour into a
|
|
93
|
+
percentage slider.
|
|
94
|
+
|
|
95
|
+
**Every package declares what its bundle imports.** A new CI gate checks every `import`, `import()`
|
|
96
|
+
and `require()` in the published `dist` against `dependencies` and non-optional `peerDependencies`.
|
|
97
|
+
To reach zero: `@nice2dev/licensing` no longer has `require('webpack')` in its main bundle (the webpack
|
|
98
|
+
plugin uses `compiler.webpack`; webpack 4 gets a warning instead of feature flags) and `react` is a
|
|
99
|
+
required peer; `@nice2dev/erp-adapter` lists `@microsoft/signalr` in `dependencies` (still loaded on
|
|
100
|
+
first use); `@nice2dev/icons-cursor` declares its `react-dom` peer; `@nice2dev/ui-printing` treats
|
|
101
|
+
`@nice2dev/ui` as a required peer.
|
|
102
|
+
|
|
103
|
+
**One copy of each package, one i18n context.** `@nice2dev/ui` carried its own copy of
|
|
104
|
+
`@nice2dev/ui-core` and `@nice2dev/i18n`, and `ui-forms`, `ui-api`, `ui-bi`, `ui-designers`, `ui-math`
|
|
105
|
+
and `ui-video` each carried a copy of all of `@nice2dev/ui` (about 4.4 MB each). Every copy had its own
|
|
106
|
+
React contexts: a `NiceI18nProvider` imported from `@nice2dev/i18n` did not reach the controls of
|
|
107
|
+
`@nice2dev/ui`, which kept their English defaults and `lang` `'en'`, and the dictionaries ended up in
|
|
108
|
+
an app several times. These packages now import `@nice2dev/*` instead (`ui-forms` 4.4 MB → 82 kB).
|
|
109
|
+
Keep every `@nice2dev/*` package on the same version.
|
|
110
|
+
|
|
111
|
+
**Dictionaries per language.** `NiceI18nLazyProvider` takes the same props as `NiceI18nProvider`
|
|
112
|
+
(`t`, `lang`, `overrides`, plus `fallback` and `onError`) but loads only the active language's
|
|
113
|
+
dictionary, with `import()`; until it arrives the controls show their built-in English (or
|
|
114
|
+
`fallback`), and with `t` nothing is loaded at all. Also `loadNiceDictionary(lang)`, to start in a
|
|
115
|
+
language without a flash of English, and `getLoadedNiceDictionary(lang)`. Exported from
|
|
116
|
+
`@nice2dev/i18n`, `@nice2dev/ui-core` and `@nice2dev/ui`; in the `i18n` build every language is its own
|
|
117
|
+
file. `NiceI18nProvider` and `NICE_I18N_DICTIONARIES` are unchanged and still bring all 30 dictionaries.
|
|
118
|
+
`NiceTestWrapper` (ui-core) and `NiceShowcase` (ui) use the lazy provider now, so they no longer pull
|
|
119
|
+
every dictionary into the apps that bundle them.
|
|
120
|
+
|
|
121
|
+
**Data props are optional.** These controls threw a `TypeError` without data and now render empty:
|
|
122
|
+
`NiceTreeView.nodes`, `NiceAccordion.items`, `NiceCascadeSelect.options`, `NiceAutocomplete.options`,
|
|
123
|
+
`NiceAuditLog.entries`, `NiceDocumentVersionList.versions`, `NicePermissionMatrix.roles` / `actions`,
|
|
124
|
+
`WizardStep.content`, `NiceDiagramViewer.document`, `NiceOrgChartVisualizer.data`,
|
|
125
|
+
`NiceSpatialViewer.document`, and in `@nice2dev/events` the lists of `NiceGiftRegistry`,
|
|
126
|
+
`NiceParticipantList`, `NiceExpenseSplit`, `NiceSeatingChart`, `NiceMediaCollage` and `NiceEventMedia`.
|
|
127
|
+
`NiceMap` without `center` centres on its markers (the whole world without markers), `NiceCountdown`
|
|
128
|
+
without `targetDate` shows zero and never calls `onComplete`, `NiceChat` without `onSend` is read-only
|
|
129
|
+
(no input), and `NiceInvitationDesigner` gains `defaultTemplate`. A CI ratchet counts the required
|
|
130
|
+
array props that remain.
|
|
131
|
+
|
|
132
|
+
**Smaller fixes.** `NicePieChart` draws a 100 % slice as a full circle instead of nothing. In
|
|
133
|
+
development `NiceThemeProvider` warns when `--nice-primary` / `--nice-color-primary` (or another linked
|
|
134
|
+
pair) resolves to nothing on `:root` — usually an alias cycle in the app's CSS; the theming guides say
|
|
135
|
+
which side to set. `@nice2dev/game-engine` exports `createAnimationClip`, `AnimatorController` and
|
|
136
|
+
`createAnimatorController` (two modules exported each name, so `export *` dropped all three); the other
|
|
137
|
+
implementations are `StateMachineAnimatorController`, `createStateMachineAnimatorController`,
|
|
138
|
+
`createTimelineAnimationClip` and `createRetargetingAnimationClip`.
|
|
139
|
+
|
|
140
|
+
Nothing was renamed or removed.
|
|
141
|
+
|
|
3
142
|
## 1.1.9
|
|
4
143
|
|
|
5
144
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHeoZFLH.cjs");exports.NiceAPIDesigner=e.NiceAPIDesigner;exports.NiceAPITester=e.NiceAPITester;exports.NiceIntegrationBuilder=e.NiceIntegrationBuilder;exports.NiceWebhookTester=e.NiceWebhookTester;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("@nice2dev/ui"),k=require("@nice2dev/ui-core"),m=require("react"),le=[{target:".nice-api-designer",titleKey:"tutorial.apiDesigner.intro.title",title:"API designer",contentKey:"tutorial.apiDesigner.intro.content",content:"Define endpoints, parameters, request/response schemas and security for your OpenAPI document.",placement:"auto"}],te={openapi:"3.0.3",info:{title:"Pet Store API",version:"1.0.0",description:"A sample API that manages a small pet store — list, create and fetch pets. Edit any field; the JSON preview and validation update live."},servers:[{url:"https://api.petstore.example.com/v1",description:"Production"},{url:"https://staging.petstore.example.com/v1",description:"Staging"}],paths:{"/pets":{get:{operationId:"listPets",summary:"List all pets",description:"Returns a paged list of pets.",tags:["pets"],parameters:[{name:"limit",in:"query",description:"Max items to return",required:!1,schema:{type:"integer",format:"int32"}}],responses:{200:{description:"A paged array of pets",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}}}}}},post:{operationId:"createPet",summary:"Create a pet",tags:["pets"],requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/NewPet"}}}},responses:{201:{description:"Created"}}}},"/pets/{petId}":{get:{operationId:"getPetById",summary:"Get a pet by id",tags:["pets"],parameters:[{name:"petId",in:"path",description:"Id of the pet",required:!0,schema:{type:"string"}}],responses:{200:{description:"A pet",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}}}},404:{description:"Not found"}}}}},components:{schemas:{Pet:{type:"object",description:"A pet in the store.",required:["id","name"],properties:{id:{type:"integer",format:"int64"},name:{type:"string"},tag:{type:"string"},status:{type:"string",enum:["available","pending","sold"]}}},NewPet:{type:"object",required:["name"],properties:{name:{type:"string"},tag:{type:"string"}}}},securitySchemes:{apiKey:{type:"apiKey",name:"X-API-Key",in:"header",description:"API key auth."},bearerAuth:{type:"http",scheme:"bearer",bearerFormat:"JWT",description:"JWT bearer token."}}},tags:[{name:"pets",description:"Pet operations"}]},re=["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"],de=["object","array","string","number","integer","boolean"],pe=["query","path","header","cookie"],ue=["apiKey","http","oauth2","openIdConnect"];function Z(s){var r,t;const i=[];return s.openapi||i.push({path:"openapi",message:"OpenAPI version is required",severity:"error"}),(r=s.info)!=null&&r.title||i.push({path:"info.title",message:"API title is required",severity:"error"}),(t=s.info)!=null&&t.version||i.push({path:"info.version",message:"API version is required",severity:"error"}),Object.entries(s.paths||{}).forEach(([c,o])=>{c.startsWith("/")||i.push({path:`paths.${c}`,message:"Path must start with /",severity:"error"}),re.forEach(l=>{const d=o[l.toLowerCase()];d&&!d.responses&&i.push({path:`paths.${c}.${l.toLowerCase()}.responses`,message:"Responses are required",severity:"error"})})}),i}const ie=de.map(s=>({value:String(s),label:String(s)}));function he({schema:s,onChange:i,onSave:r,readOnly:t=!1,className:c="",tutorial:o}){var z,K;const[l,d]=m.useState(s||te),[x,p]=m.useState("/pets"),[v,g]=m.useState("get"),[j,y]=m.useState("paths"),[h,C]=m.useState(()=>Z(s||te)),b=m.useCallback(N=>{d(_=>{const P=N(_);return i==null||i(P),C(Z(P)),P})},[i]),E=m.useCallback(()=>{const N="/new-endpoint";b(_=>({..._,paths:{..._.paths,[N]:{..._.paths[N],get:{summary:"New endpoint",responses:{200:{description:"Success"}}}}}})),p(N),g("get")},[b]),B=m.useCallback(N=>{b(_=>{const{[N]:P,...$}=_.paths;return{..._,paths:$}}),p(null),g(null)},[b]),L=m.useCallback(()=>{let N="NewSchema";b(_=>{var $,O,A;let P=1;for(;(O=($=_.components)==null?void 0:$.schemas)!=null&&O[N];)N=`NewSchema${P++}`;return{..._,components:{..._.components,schemas:{...(A=_.components)==null?void 0:A.schemas,[N]:{type:"object",properties:{}}}}}})},[b]),q=m.useCallback(()=>{const N=Z(l);C(N),N.filter(_=>_.severity==="error").length===0&&(r==null||r(l))},[l,r]),D=Object.entries(l.paths).flatMap(([N,_])=>re.filter(P=>_[P.toLowerCase()]).map(P=>({path:N,method:P,operation:_[P.toLowerCase()]}))),R=["info","paths","schemas","security","preview"];return e.jsxs("div",{style:{position:"relative",height:"100%"},children:[o&&e.jsx("div",{style:{position:"absolute",top:8,right:8,zIndex:5},children:e.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(o,le)})}),e.jsx(f.NiceAppShell,{flush:!0,className:`nice-api-designer ${c}`,height:"100%",style:{minHeight:600},toolbar:e.jsxs("div",{className:"nice-api-designer__toolbar",children:[e.jsx("div",{className:"nice-api-designer__tabs",children:R.map(N=>e.jsx(f.NiceButton,{size:"sm",variant:j===N?"primary":"ghost",onClick:()=>y(N),children:N.charAt(0).toUpperCase()+N.slice(1)},N))}),!t&&e.jsx(f.NiceButton,{size:"sm",variant:"primary",leftIcon:e.jsx(k.NiceIcon,{name:"check",size:14}),onClick:q,children:"Save"})]}),bottomPanel:h.length>0?e.jsx("div",{className:"nice-api-designer__errors",children:h.map((N,_)=>e.jsxs("div",{className:`nice-api-designer__error nice-api-designer__error--${N.severity}`,children:[e.jsxs("strong",{children:[N.path,":"]})," ",N.message]},_))}):void 0,children:e.jsxs("div",{className:"nice-api-designer__content",children:[j==="info"&&e.jsx(me,{schema:l,onChange:b,readOnly:t}),j==="paths"&&e.jsx(xe,{endpoints:D,schema:l,selectedPath:x,selectedMethod:v,onSelectEndpoint:(N,_)=>{p(N),g(_)},onAdd:E,onDelete:B,onChange:b,readOnly:t}),j==="schemas"&&e.jsx(ge,{schemas:((z=l.components)==null?void 0:z.schemas)||{},onAdd:L,onChange:N=>b(_=>({..._,components:{..._.components,schemas:N}})),readOnly:t}),j==="security"&&e.jsx(je,{schemes:((K=l.components)==null?void 0:K.securitySchemes)||{},onChange:N=>b(_=>({..._,components:{..._.components,securitySchemes:N}})),readOnly:t}),j==="preview"&&e.jsx(_e,{schema:l})]})})]})}function me({schema:s,onChange:i,readOnly:r}){return e.jsxs("div",{className:"nice-api-designer__info-editor",children:[e.jsx("h3",{children:"API information"}),e.jsx(f.NiceTextInput,{label:"Title",value:s.info.title,onChange:t=>i(c=>({...c,info:{...c.info,title:t}})),readOnly:r}),e.jsx(f.NiceTextInput,{label:"Version",value:s.info.version,onChange:t=>i(c=>({...c,info:{...c.info,version:t}})),readOnly:r}),e.jsx(f.NiceTextArea,{label:"Description",value:s.info.description||"",onChange:t=>i(c=>({...c,info:{...c.info,description:t}})),readOnly:r,rows:4}),e.jsx("h4",{children:"Servers"}),(s.servers||[]).map((t,c)=>e.jsxs("div",{className:"nice-api-designer__server",children:[e.jsx(f.NiceTextInput,{value:t.url,placeholder:"Server URL",onChange:o=>i(l=>{var d;return{...l,servers:(d=l.servers)==null?void 0:d.map((x,p)=>p===c?{...x,url:o}:x)}}),readOnly:r}),e.jsx(f.NiceTextInput,{value:t.description||"",placeholder:"Description",onChange:o=>i(l=>{var d;return{...l,servers:(d=l.servers)==null?void 0:d.map((x,p)=>p===c?{...x,description:o}:x)}}),readOnly:r}),!r&&e.jsx(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>i(o=>{var l;return{...o,servers:(l=o.servers)==null?void 0:l.filter((d,x)=>x!==c)}}),"aria-label":"Remove server",children:e.jsx(k.NiceIcon,{name:"close",size:14})})]},c)),!r&&e.jsx(f.NiceButton,{size:"sm",variant:"outline",leftIcon:e.jsx(k.NiceIcon,{name:"plus",size:14}),onClick:()=>i(t=>({...t,servers:[...t.servers||[],{url:"https://api.example.com"}]})),children:"Add server"})]})}function xe({endpoints:s,schema:i,selectedPath:r,selectedMethod:t,onSelectEndpoint:c,onAdd:o,onDelete:l,onChange:d,readOnly:x}){var j;const p=r&&t?(j=i.paths[r])==null?void 0:j[t]:null,v=y=>{!r||!t||!p||d(h=>({...h,paths:{...h.paths,[r]:{...h.paths[r],[t]:{...p,...y}}}}))},g=(p==null?void 0:p.parameters)??[];return e.jsxs("div",{className:"nice-api-designer__paths-editor",children:[e.jsxs("div",{className:"nice-api-designer__endpoints-list",children:[e.jsxs("div",{className:"nice-api-designer__list-header",children:[e.jsx("h3",{children:"Endpoints"}),!x&&e.jsxs(f.NiceButton,{size:"sm",variant:"ghost",onClick:o,children:[e.jsx(k.NiceIcon,{name:"plus",size:14})," Add"]})]}),s.map(({path:y,method:h})=>e.jsxs("div",{className:`nice-api-designer__endpoint ${r===y&&t===h.toLowerCase()?"nice-api-designer__endpoint--selected":""}`,onClick:()=>c(y,h.toLowerCase()),children:[e.jsx("span",{className:`nice-api-designer__method nice-api-designer__method--${h.toLowerCase()}`,children:h}),e.jsx("span",{className:"nice-api-designer__path",children:y})]},`${h}-${y}`))]}),p&&r&&t&&e.jsxs("div",{className:"nice-api-designer__operation-editor",children:[e.jsxs("h3",{children:[e.jsx("span",{className:`nice-api-designer__method nice-api-designer__method--${t}`,children:t.toUpperCase()})," ",r]}),e.jsx(f.NiceTextInput,{label:"Summary",value:p.summary||"",onChange:y=>v({summary:y}),readOnly:x}),e.jsx(f.NiceTextArea,{label:"Description",value:p.description||"",onChange:y=>v({description:y}),readOnly:x,rows:3}),e.jsx(f.NiceTextInput,{label:"Operation ID",value:p.operationId||"",onChange:y=>v({operationId:y}),readOnly:x}),e.jsxs("div",{className:"nice-api-designer__subhead",children:[e.jsx("h4",{children:"Parameters"}),!x&&e.jsxs(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>v({parameters:[...g,{name:"param",in:"query",required:!1,schema:{type:"string"}}]}),children:[e.jsx(k.NiceIcon,{name:"plus",size:14})," Add"]})]}),g.length===0&&e.jsx("p",{className:"nice-api-designer__muted",children:"No parameters."}),g.map((y,h)=>e.jsxs("div",{className:"nice-api-designer__param-row",children:[e.jsx(f.NiceTextInput,{size:"sm",value:y.name,placeholder:"name",onChange:C=>v({parameters:g.map((b,E)=>E===h?{...b,name:C}:b)}),readOnly:x}),e.jsx(f.NiceSelect,{size:"sm",value:y.in,options:pe.map(C=>({value:String(C),label:String(C)})),onChange:C=>v({parameters:g.map((b,E)=>E===h?{...b,in:C}:b)})}),e.jsx(f.NiceCheckbox,{checked:!!y.required,onChange:C=>v({parameters:g.map((b,E)=>E===h?{...b,required:C}:b)}),label:"required"}),!x&&e.jsx(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>v({parameters:g.filter((C,b)=>b!==h)}),"aria-label":`Remove ${y.name}`,children:e.jsx(k.NiceIcon,{name:"close",size:14})})]},h)),!x&&e.jsx(f.NiceButton,{className:"nice-api-designer__delete-btn",size:"sm",variant:"danger",leftIcon:e.jsx(k.NiceIcon,{name:"trash",size:14}),onClick:()=>l(r),children:"Delete endpoint"})]})]})}function ge({schemas:s,onAdd:i,onChange:r,readOnly:t}){const c=Object.keys(s),[o,l]=m.useState(c[0]??null),d=o?s[o]:null,x=(d==null?void 0:d.properties)??{},p=g=>{!o||!d||r({...s,[o]:{...d,...g}})},v=(g,j)=>{p({properties:{...x,[g]:j}})};return e.jsxs("div",{className:"nice-api-designer__schemas-editor",children:[e.jsxs("div",{className:"nice-api-designer__schemas-list",children:[e.jsxs("div",{className:"nice-api-designer__list-header",children:[e.jsx("h3",{children:"Schemas"}),!t&&e.jsxs(f.NiceButton,{size:"sm",variant:"ghost",onClick:i,children:[e.jsx(k.NiceIcon,{name:"plus",size:14})," Add"]})]}),c.map(g=>e.jsx("div",{className:`nice-api-designer__schema-item ${o===g?"nice-api-designer__schema-item--selected":""}`,onClick:()=>l(g),children:g},g))]}),o&&d&&e.jsxs("div",{className:"nice-api-designer__schema-editor",children:[e.jsx("h3",{children:o}),e.jsx(f.NiceSelect,{label:"Type",value:d.type||"object",options:ie,onChange:g=>p({type:g})}),e.jsx(f.NiceTextArea,{label:"Description",value:d.description||"",onChange:g=>p({description:g}),readOnly:t,rows:2}),e.jsxs("div",{className:"nice-api-designer__subhead",children:[e.jsx("h4",{children:"Properties"}),!t&&e.jsxs(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{let g="field",j=1;for(;x[g];)g=`field${j++}`;v(g,{type:"string"})},children:[e.jsx(k.NiceIcon,{name:"plus",size:14})," Add"]})]}),Object.keys(x).length===0&&e.jsx("p",{className:"nice-api-designer__muted",children:"No properties."}),Object.entries(x).map(([g,j])=>{const y=(d.required||[]).includes(g);return e.jsxs("div",{className:"nice-api-designer__param-row",children:[e.jsx(f.NiceTextInput,{size:"sm",value:g,onChange:h=>{if(!h||h===g||x[h])return;const C={};Object.entries(x).forEach(([b,E])=>{C[b===g?h:b]=E}),p({properties:C,required:(d.required||[]).map(b=>b===g?h:b)})},readOnly:t}),e.jsx(f.NiceSelect,{size:"sm",value:j.type||"string",options:ie,onChange:h=>v(g,{...j,type:h})}),e.jsx(f.NiceCheckbox,{checked:y,onChange:h=>p({required:h?[...d.required||[],g]:(d.required||[]).filter(C=>C!==g)}),label:"required"}),!t&&e.jsx(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{const{[g]:h,...C}=x;p({properties:C,required:(d.required||[]).filter(b=>b!==g)})},"aria-label":`Remove ${g}`,children:e.jsx(k.NiceIcon,{name:"close",size:14})})]},g)}),e.jsxs("details",{className:"nice-api-designer__raw",children:[e.jsx("summary",{children:"Raw JSON schema"}),e.jsx(f.NiceTextArea,{value:JSON.stringify(d,null,2),onChange:g=>{try{const j=JSON.parse(g);r({...s,[o]:j})}catch{}},readOnly:t,rows:8,className:"nice-api-designer__code"})]})]})]})}function je({schemes:s,onChange:i,readOnly:r}){const t=(c,o)=>i({...s,[c]:o});return e.jsxs("div",{className:"nice-api-designer__security-editor",children:[e.jsxs("div",{className:"nice-api-designer__list-header",children:[e.jsx("h3",{children:"Security schemes"}),!r&&e.jsxs(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{let c="newScheme",o=1;for(;s[c];)c=`newScheme${o++}`;t(c,{type:"apiKey",name:"X-API-Key",in:"header"})},children:[e.jsx(k.NiceIcon,{name:"plus",size:14})," Add"]})]}),Object.entries(s).map(([c,o])=>e.jsxs("div",{className:"nice-api-designer__security-item",children:[e.jsxs("div",{className:"nice-api-designer__subhead",children:[e.jsx("h4",{children:c}),!r&&e.jsx(f.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{const{[c]:l,...d}=s;i(d)},"aria-label":`Remove ${c}`,children:e.jsx(k.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-api-designer__param-row",children:[e.jsx(f.NiceSelect,{size:"sm",value:o.type,options:ue.map(l=>({value:String(l),label:String(l)})),onChange:l=>t(c,{...o,type:l})}),o.type==="apiKey"&&e.jsxs(e.Fragment,{children:[e.jsx(f.NiceTextInput,{size:"sm",value:o.name||"",placeholder:"header/param name",onChange:l=>t(c,{...o,name:l}),readOnly:r}),e.jsx(f.NiceSelect,{size:"sm",value:o.in||"header",options:["header","query","cookie"].map(l=>({value:l,label:l})),onChange:l=>t(c,{...o,in:l})})]}),o.type==="http"&&e.jsxs(e.Fragment,{children:[e.jsx(f.NiceTextInput,{size:"sm",value:o.scheme||"",placeholder:"scheme (bearer/basic)",onChange:l=>t(c,{...o,scheme:l}),readOnly:r}),e.jsx(f.NiceTextInput,{size:"sm",value:o.bearerFormat||"",placeholder:"bearerFormat (JWT)",onChange:l=>t(c,{...o,bearerFormat:l}),readOnly:r})]})]}),e.jsx(f.NiceTextInput,{size:"sm",value:o.description||"",placeholder:"Description",onChange:l=>t(c,{...o,description:l}),readOnly:r})]},c))]})}function _e({schema:s}){return e.jsxs("div",{className:"nice-api-designer__json-preview",children:[e.jsx("h3",{children:"OpenAPI specification"}),e.jsx("pre",{className:"nice-api-designer__code",children:JSON.stringify(s,null,2)})]})}const be=[{target:".nice-api-tester",titleKey:"tutorial.apiTester.intro.title",title:"API tester",contentKey:"tutorial.apiTester.intro.content",content:"Build requests with collections and environment variables, send them and assert on the responses.",placement:"auto"}],ve=["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"],ye={id:"",name:"New Request",method:"GET",url:"",headers:{},queryParams:{}};function ee(s,i){return s.replace(/\{\{(\w+)\}\}/g,(r,t)=>i[t]||`{{${t}}}`)}function fe(s,i){const r=Object.entries(i).filter(([,t])=>t).map(([t,c])=>`${encodeURIComponent(t)}=${encodeURIComponent(c)}`).join("&");return r?`${s}?${r}`:s}function Ne({collections:s=[],environments:i=[],onRequest:r,onSaveCollection:t,className:c="",tutorial:o}){const[l,d]=m.useState(s),[x,p]=m.useState(i),[v,g]=m.useState(i.find(n=>n.isActive)||null),[j,y]=m.useState({...ye,id:k.createId()}),[h,C]=m.useState(null),[b,E]=m.useState(!1),[B,L]=m.useState("none"),[q,D]=m.useState("params"),[R,z]=m.useState("body"),[K,N]=m.useState(""),[_,P]=m.useState(""),[$,O]=m.useState([]),[A,M]=m.useState([]),H=m.useRef(null),V=m.useCallback(async()=>{var T;if(!j.url)return;E(!0),C(null),O([]);const n=Object.fromEntries(Object.entries((v==null?void 0:v.variables)||{}).map(([S,I])=>[S,I.value])),a={...j,url:ee(j.url,n),headers:Object.fromEntries(Object.entries(j.headers).map(([S,I])=>[S,ee(I,n)])),queryParams:Object.fromEntries(Object.entries(j.queryParams).map(([S,I])=>[S,ee(I,n)]))},w=performance.now();try{let S;if(r)S=await r(a);else{H.current=new AbortController;const I={...a.headers};j.auth&&we(I,j.auth);const G=fe(a.url,a.queryParams),F={method:a.method,headers:I,signal:H.current.signal};["POST","PUT","PATCH"].includes(a.method)&&((T=j.body)!=null&&T.content)&&(F.body=typeof j.body.content=="string"?j.body.content:JSON.stringify(j.body.content),j.body.type==="json"&&(I["Content-Type"]="application/json"));const Y=await fetch(G,F),X=await Y.text();let Q;try{Q=JSON.parse(X)}catch{Q=X}const oe=performance.now();S={status:Y.status,statusText:Y.statusText,headers:Object.fromEntries(Y.headers.entries()),body:Q,time:Math.round(oe-w),size:new Blob([X]).size,timestamp:new Date}}if(C(S),M(I=>[...I,{request:j,response:S}].slice(-50)),_){const I=Se(_,S);O(I)}}catch(S){S.name!=="AbortError"&&C({status:0,statusText:"Error",headers:{},body:{error:S.message},time:Math.round(performance.now()-w),size:0,timestamp:new Date})}finally{E(!1),H.current=null}},[j,v,r,_]),U=m.useCallback(()=>{var n;(n=H.current)==null||n.abort(),E(!1)},[]),J=m.useCallback(()=>{y(n=>({...n,headers:{...n.headers,"":""}}))},[]),W=m.useCallback(()=>{y(n=>({...n,queryParams:{...n.queryParams,"":""}}))},[]),u=m.useCallback(()=>{if(l.length===0){const n={id:k.createId(),name:"My Collection",requests:[j]};d([n]),t==null||t(n)}else{const n={...l[0],requests:[...l[0].requests,j]};d(a=>[n,...a.slice(1)]),t==null||t(n)}},[l,j,t]);return e.jsxs("div",{className:`nice-api-tester ${c}`,style:{position:"relative"},children:[o&&e.jsx("div",{style:{position:"absolute",top:8,right:8,zIndex:5},children:e.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(o,be)})}),e.jsx("div",{className:"nice-api-tester__toolbar",children:e.jsx("div",{className:"nice-api-tester__env-selector",children:e.jsxs("select",{value:(v==null?void 0:v.id)||"",onChange:n=>g(x.find(a=>a.id===n.target.value)||null),children:[e.jsx("option",{value:"",children:"No Environment"}),x.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})})}),e.jsxs("div",{className:"nice-api-tester__request-bar",children:[e.jsx("select",{value:j.method,onChange:n=>y(a=>({...a,method:n.target.value})),className:`nice-api-tester__method nice-api-tester__method--${j.method.toLowerCase()}`,children:ve.map(n=>e.jsx("option",{value:n,children:n},n))}),e.jsx("input",{type:"text",value:j.url,onChange:n=>y(a=>({...a,url:n.target.value})),placeholder:"Enter request URL",className:"nice-api-tester__url-input"}),e.jsx("button",{onClick:b?U:V,className:`nice-api-tester__send-btn ${b?"nice-api-tester__send-btn--loading":""}`,children:b?"Cancel":"Send"}),e.jsx("button",{onClick:u,className:"nice-api-tester__save-btn",children:"Save"})]}),e.jsxs("div",{className:"nice-api-tester__main",children:[e.jsxs("div",{className:"nice-api-tester__request-panel",children:[e.jsx("div",{className:"nice-api-tester__tabs",children:["params","headers","body","auth","tests"].map(n=>e.jsx("button",{className:`nice-api-tester__tab ${q===n?"nice-api-tester__tab--active":""}`,onClick:()=>D(n),children:n.charAt(0).toUpperCase()+n.slice(1)},n))}),e.jsxs("div",{className:"nice-api-tester__tab-content",children:[q==="params"&&e.jsx(ke,{params:j.queryParams,onChange:n=>y(a=>({...a,queryParams:n})),onAdd:W}),q==="headers"&&e.jsx(Te,{headers:j.headers,onChange:n=>y(a=>({...a,headers:n})),onAdd:J}),q==="body"&&e.jsx(Ie,{body:j.body,bodyTab:B,onBodyTabChange:L,onChange:n=>y(a=>({...a,body:n}))}),q==="auth"&&e.jsx(Ee,{auth:j.auth,onChange:n=>y(a=>({...a,auth:n}))}),q==="tests"&&e.jsx(Pe,{preRequestScript:K,testScript:_,onPreRequestChange:N,onTestChange:P})]})]}),e.jsx("div",{className:"nice-api-tester__response-panel",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-api-tester__response-meta",children:[e.jsxs("span",{className:`nice-api-tester__status nice-api-tester__status--${Math.floor(h.status/100)}`,children:[h.status," ",h.statusText]}),e.jsxs("span",{className:"nice-api-tester__time",children:[h.time,"ms"]}),e.jsx("span",{className:"nice-api-tester__size",children:Ce(h.size)})]}),e.jsx("div",{className:"nice-api-tester__tabs",children:["body","headers","tests"].map(n=>e.jsxs("button",{className:`nice-api-tester__tab ${R===n?"nice-api-tester__tab--active":""}`,onClick:()=>z(n),children:[n.charAt(0).toUpperCase()+n.slice(1),n==="tests"&&$.length>0&&e.jsxs("span",{className:"nice-api-tester__test-badge",children:[$.filter(a=>a.passed).length,"/",$.length]})]},n))}),e.jsxs("div",{className:"nice-api-tester__response-content",children:[R==="body"&&e.jsx("pre",{className:"nice-api-tester__response-body",children:typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2)}),R==="headers"&&e.jsx("div",{className:"nice-api-tester__response-headers",children:Object.entries(h.headers).map(([n,a])=>e.jsxs("div",{className:"nice-api-tester__header-row",children:[e.jsx("span",{className:"nice-api-tester__header-key",children:n}),e.jsx("span",{className:"nice-api-tester__header-value",children:a})]},n))}),R==="tests"&&e.jsx("div",{className:"nice-api-tester__test-results",children:$.map((n,a)=>e.jsxs("div",{className:`nice-api-tester__test-result nice-api-tester__test-result--${n.passed?"pass":"fail"}`,children:[e.jsx("span",{className:"nice-api-tester__test-icon",children:e.jsx(k.NiceIcon,{name:n.passed?"check":"close",size:14})}),e.jsx("span",{className:"nice-api-tester__test-name",children:n.name}),n.message&&e.jsx("span",{className:"nice-api-tester__test-message",children:n.message})]},a))})]})]}):e.jsx("div",{className:"nice-api-tester__empty-response",children:b?"Loading...":"Send a request to see the response"})})]}),A.length>0&&e.jsxs("div",{className:"nice-api-tester__history",children:[e.jsx("h4",{children:"History"}),e.jsx("div",{className:"nice-api-tester__history-list",children:A.slice().reverse().map(({request:n,response:a},w)=>e.jsxs("div",{className:"nice-api-tester__history-item",onClick:()=>y(n),children:[e.jsx("span",{className:`nice-api-tester__method nice-api-tester__method--${n.method.toLowerCase()}`,children:n.method}),e.jsx("span",{className:"nice-api-tester__history-url",children:n.url}),e.jsx("span",{className:`nice-api-tester__status nice-api-tester__status--${Math.floor(a.status/100)}`,children:a.status})]},w))})]})]})}function we(s,i){var r,t,c,o,l;switch(i.type){case"bearer":s.Authorization=`${((r=i.bearer)==null?void 0:r.prefix)||"Bearer"} ${(t=i.bearer)==null?void 0:t.token}`;break;case"basic":s.Authorization=`Basic ${btoa(`${(c=i.basic)==null?void 0:c.username}:${(o=i.basic)==null?void 0:o.password}`)}`;break;case"api-key":((l=i.apiKey)==null?void 0:l.in)==="header"&&(s[i.apiKey.key]=i.apiKey.value);break}}function Ce(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Se(s,i){const r=[],t={response:{code:i.status,status:i.statusText,headers:i.headers,json:()=>i.body,text:()=>typeof i.body=="string"?i.body:JSON.stringify(i.body),responseTime:i.time},test:(c,o)=>{const l=performance.now();try{o(),r.push({name:c,passed:!0,duration:performance.now()-l})}catch(d){r.push({name:c,passed:!1,message:d.message,duration:performance.now()-l})}},expect:c=>({to:{equal:o=>{if(c!==o)throw new Error(`Expected ${o} but got ${c}`)},be:{oneOf:o=>{if(!o.includes(c))throw new Error(`Expected ${c} to be one of ${o}`)}},have:{property:o=>{if(typeof c!="object"||c===null||!(o in c))throw new Error(`Expected object to have property ${o}`)}}}})};try{new Function("pm",s)(t)}catch(c){r.push({name:"Script Error",passed:!1,message:c.message,duration:0})}return r}function ce({items:s,onChange:i,onAdd:r,keyPlaceholder:t="Key",valuePlaceholder:c="Value"}){return e.jsxs("div",{className:"nice-api-tester__kv-editor",children:[Object.entries(s).map(([o,l],d)=>e.jsxs("div",{className:"nice-api-tester__kv-row",children:[e.jsx("input",{type:"text",value:o,placeholder:t,onChange:x=>{const p=Object.entries(s);p[d]=[x.target.value,l],i(Object.fromEntries(p))}}),e.jsx("input",{type:"text",value:l,placeholder:c,onChange:x=>i({...s,[o]:x.target.value})}),e.jsx("button",{onClick:()=>{const{[o]:x,...p}=s;i(p)},children:"×"})]},d)),e.jsx("button",{onClick:r,className:"nice-api-tester__add-btn",children:"+ Add"})]})}function ke({params:s,onChange:i,onAdd:r}){return e.jsx(ce,{items:s,onChange:i,onAdd:r,keyPlaceholder:"Parameter",valuePlaceholder:"Value"})}function Te({headers:s,onChange:i,onAdd:r}){return e.jsx(ce,{items:s,onChange:i,onAdd:r,keyPlaceholder:"Header",valuePlaceholder:"Value"})}function Ie({body:s,bodyTab:i,onBodyTabChange:r,onChange:t}){return e.jsxs("div",{className:"nice-api-tester__body-editor",children:[e.jsx("div",{className:"nice-api-tester__body-tabs",children:["none","json","form-data","raw"].map(c=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:i===c,onChange:()=>{r(c),t({type:c,content:""})}}),c]},c))}),i!=="none"&&e.jsx("textarea",{value:typeof(s==null?void 0:s.content)=="string"?s.content:JSON.stringify(s==null?void 0:s.content,null,2),onChange:c=>t({type:i,content:c.target.value}),placeholder:i==="json"?'{ "key": "value" }':"Enter body content",rows:10,className:"nice-api-tester__body-textarea"})]})}function Ee({auth:s,onChange:i}){var r,t,c,o,l,d;return e.jsxs("div",{className:"nice-api-tester__auth-editor",children:[e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Type"}),e.jsxs("select",{value:(s==null?void 0:s.type)||"none",onChange:x=>i({type:x.target.value}),children:[e.jsx("option",{value:"none",children:"No Auth"}),e.jsx("option",{value:"api-key",children:"API Key"}),e.jsx("option",{value:"bearer",children:"Bearer Token"}),e.jsx("option",{value:"basic",children:"Basic Auth"}),e.jsx("option",{value:"oauth2",children:"OAuth 2.0"})]})]}),(s==null?void 0:s.type)==="api-key"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Key"}),e.jsx("input",{type:"text",value:((r=s.apiKey)==null?void 0:r.key)||"",onChange:x=>{var p,v;return i({...s,apiKey:{...s.apiKey,key:x.target.value,value:((p=s.apiKey)==null?void 0:p.value)||"",in:((v=s.apiKey)==null?void 0:v.in)||"header"}})},placeholder:"X-API-Key"})]}),e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Value"}),e.jsx("input",{type:"text",value:((t=s.apiKey)==null?void 0:t.value)||"",onChange:x=>{var p,v;return i({...s,apiKey:{...s.apiKey,value:x.target.value,key:((p=s.apiKey)==null?void 0:p.key)||"",in:((v=s.apiKey)==null?void 0:v.in)||"header"}})},placeholder:"your-api-key"})]}),e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Add to"}),e.jsxs("select",{value:((c=s.apiKey)==null?void 0:c.in)||"header",onChange:x=>{var p,v;return i({...s,apiKey:{...s.apiKey,in:x.target.value,key:((p=s.apiKey)==null?void 0:p.key)||"",value:((v=s.apiKey)==null?void 0:v.value)||""}})},children:[e.jsx("option",{value:"header",children:"Header"}),e.jsx("option",{value:"query",children:"Query Params"})]})]})]}),(s==null?void 0:s.type)==="bearer"&&e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Token"}),e.jsx("input",{type:"text",value:((o=s.bearer)==null?void 0:o.token)||"",onChange:x=>i({...s,bearer:{token:x.target.value}}),placeholder:"your-bearer-token"})]}),(s==null?void 0:s.type)==="basic"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Username"}),e.jsx("input",{type:"text",value:((l=s.basic)==null?void 0:l.username)||"",onChange:x=>{var p;return i({...s,basic:{...s.basic,username:x.target.value,password:((p=s.basic)==null?void 0:p.password)||""}})}})]}),e.jsxs("div",{className:"nice-api-tester__field",children:[e.jsx("label",{children:"Password"}),e.jsx("input",{type:"password",value:((d=s.basic)==null?void 0:d.password)||"",onChange:x=>{var p;return i({...s,basic:{...s.basic,password:x.target.value,username:((p=s.basic)==null?void 0:p.username)||""}})}})]})]})]})}function Pe({preRequestScript:s,testScript:i,onPreRequestChange:r,onTestChange:t}){return e.jsxs("div",{className:"nice-api-tester__tests-editor",children:[e.jsxs("div",{className:"nice-api-tester__script-section",children:[e.jsx("h4",{children:"Pre-request Script"}),e.jsx("textarea",{value:s,onChange:c=>r(c.target.value),placeholder:"// Code to run before the request",rows:5})]}),e.jsxs("div",{className:"nice-api-tester__script-section",children:[e.jsx("h4",{children:"Tests"}),e.jsx("textarea",{value:i,onChange:c=>t(c.target.value),placeholder:`pm.test("Status code is 200", function () {
|
|
2
|
+
pm.expect(pm.response.code).to.equal(200);
|
|
3
|
+
});`,rows:8})]})]})}const Ae=[{target:".nice-integration-builder",titleKey:"tutorial.integrationBuilder.intro.title",title:"Integration builder",contentKey:"tutorial.integrationBuilder.intro.content",content:"Wire a flow of nodes (triggers → actions → error handling) and connect them to build an integration.",placement:"auto"}],se=[{type:"trigger",label:"Trigger",icon:"zap",category:"Control"},{type:"http-request",label:"HTTP Request",icon:"globe",category:"Actions"},{type:"transform",label:"Transform",icon:"shuffle",category:"Data"},{type:"filter",label:"Filter",icon:"filter",category:"Data"},{type:"switch",label:"Switch",icon:"git-branch",category:"Control"},{type:"loop",label:"Loop",icon:"refresh",category:"Control"},{type:"delay",label:"Delay",icon:"clock",category:"Control"},{type:"set-variable",label:"Set Variable",icon:"edit",category:"Data"},{type:"database",label:"Database",icon:"database",category:"Actions"},{type:"email",label:"Email",icon:"mail",category:"Actions"},{type:"webhook",label:"Webhook",icon:"link",category:"Actions"},{type:"function",label:"Function",icon:"code",category:"Actions"},{type:"error-handler",label:"Error Handler",icon:"warning",category:"Control"}],qe={id:"",name:"New Flow",nodes:[],connections:[],variables:{},triggers:[],errorHandling:{strategy:"stop"}};function Re({flow:s,connectors:i=[],onChange:r,onSave:t,onRun:c,className:o="",tutorial:l}){const[d,x]=m.useState(s||{...qe,id:k.createId()}),[p,v]=m.useState(null),[g,j]=m.useState(!0),[y,h]=m.useState("canvas"),[C,b]=m.useState(!1),[E,B]=m.useState(null),[L,q]=m.useState(!1),[D,R]=m.useState(null),[z,K]=m.useState(!1),N=m.useRef(null),_=m.useCallback(u=>{x(n=>{const a=u(n);return r==null||r(a),a})},[r]),P=m.useCallback((u,n)=>{var w;const a={id:k.createId(),type:u,name:((w=se.find(T=>T.type===u))==null?void 0:w.label)||u,position:n,config:$e(u),inputs:u!=="trigger"?["input"]:[],outputs:["output"]};_(T=>({...T,nodes:[...T.nodes,a]})),v(a)},[_]),$=m.useCallback(u=>{_(n=>({...n,nodes:n.nodes.filter(a=>a.id!==u),connections:n.connections.filter(a=>a.sourceNodeId!==u&&a.targetNodeId!==u)})),v(null)},[_]),O=m.useCallback((u,n)=>{_(a=>({...a,nodes:a.nodes.map(w=>w.id===u?{...w,...n}:w)})),(p==null?void 0:p.id)===u&&v(a=>a?{...a,...n}:null)},[_,p]),A=m.useCallback((u,n,a,w)=>{u===a||d.connections.some(S=>S.sourceNodeId===u&&S.targetNodeId===a&&S.sourceOutput===n&&S.targetInput===w)||_(S=>({...S,connections:[...S.connections,{id:k.createId(),sourceNodeId:u,sourceOutput:n,targetNodeId:a,targetInput:w}]}))},[d.connections,_]),M=m.useCallback(u=>{_(n=>({...n,connections:n.connections.filter(a=>a.id!==u)}))},[_]),H=m.useCallback(u=>{if(u.preventDefault(),!E||!N.current)return;const n=N.current.getBoundingClientRect(),a=u.clientX-n.left,w=u.clientY-n.top;P(E,{x:a,y:w}),b(!1),B(null)},[E,P]),V=m.useCallback(async()=>{if(c){K(!0);try{await c(d)}finally{K(!1)}}},[d,c]),U=m.useCallback(()=>{t==null||t(d)},[d,t]),J=g&&y==="canvas"?e.jsxs("div",{className:"nice-integration-builder__palette",children:[e.jsx("h4",{children:"Nodes"}),["Control","Actions","Data"].map(u=>e.jsxs("div",{className:"nice-integration-builder__category",children:[e.jsx("h5",{children:u}),se.filter(n=>n.category===u).map(n=>e.jsxs("div",{className:"nice-integration-builder__palette-item",draggable:!0,onDragStart:()=>{b(!0),B(n.type)},onDragEnd:()=>{b(!1),B(null)},children:[e.jsx("span",{className:"nice-integration-builder__palette-icon",children:e.jsx(f.NiceIcon,{name:n.icon,size:14})}),e.jsx("span",{children:n.label})]},n.type))]},u)),i.length>0&&e.jsxs("div",{className:"nice-integration-builder__category",children:[e.jsx("h5",{children:"Connectors"}),i.map(u=>e.jsxs("div",{className:"nice-integration-builder__palette-item",children:[e.jsx("span",{className:"nice-integration-builder__palette-icon",children:e.jsx(f.NiceIcon,{name:"plug",size:14})}),e.jsx("span",{children:u.name})]},u.id))]})]}):void 0,W=p&&y==="canvas"?e.jsx(ze,{node:p,onChange:u=>O(p.id,u),onClose:()=>v(null)}):void 0;return e.jsxs("div",{style:{position:"relative",height:"100%"},children:[l&&e.jsx("div",{style:{position:"absolute",top:8,right:8,zIndex:5},children:e.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(l,Ae)})}),e.jsxs(f.NiceAppShell,{flush:!0,className:`nice-integration-builder ${o}`,height:"100%",style:{minHeight:600},sidebar:J,rightSidebar:W,toolbar:e.jsxs("div",{className:"nice-integration-builder__toolbar",children:[e.jsx("input",{type:"text",value:d.name,onChange:u=>_(n=>({...n,name:u.target.value})),className:"nice-integration-builder__name-input"}),e.jsx("div",{className:"nice-integration-builder__tabs",children:["canvas","code","variables","settings"].map(u=>e.jsx("button",{className:`nice-integration-builder__tab ${y===u?"nice-integration-builder__tab--active":""}`,onClick:()=>h(u),children:u.charAt(0).toUpperCase()+u.slice(1)},u))}),e.jsxs("div",{className:"nice-integration-builder__actions",children:[e.jsxs("button",{onClick:V,disabled:z,className:"nice-integration-builder__run-btn",children:[e.jsx(f.NiceIcon,{name:z?"clock":"play",size:14})," ",z?"Running...":"Run"]}),e.jsxs("button",{onClick:U,className:"nice-integration-builder__save-btn",children:[e.jsx(f.NiceIcon,{name:"save",size:14})," Save"]})]})]}),children:[y==="canvas"&&e.jsxs("div",{ref:N,className:`nice-integration-builder__canvas ${C?"nice-integration-builder__canvas--dragging":""}`,onDragOver:u=>u.preventDefault(),onDrop:H,onClick:()=>v(null),children:[e.jsx("svg",{className:"nice-integration-builder__connections",children:d.connections.map(u=>{const n=d.nodes.find(F=>F.id===u.sourceNodeId),a=d.nodes.find(F=>F.id===u.targetNodeId);if(!n||!a)return null;const w=n.position.x+150,T=n.position.y+30,S=a.position.x,I=a.position.y+30,G=(w+S)/2;return e.jsx("g",{onClick:()=>M(u.id),children:e.jsx("path",{d:`M ${w} ${T} C ${G} ${T}, ${G} ${I}, ${S} ${I}`,className:"nice-integration-builder__connection"})},u.id)})}),d.nodes.map(u=>e.jsx(De,{node:u,isSelected:(p==null?void 0:p.id)===u.id,onSelect:()=>v(u),onDelete:()=>$(u.id),onPositionChange:n=>O(u.id,{position:n}),onStartConnection:n=>{q(!0),R({nodeId:u.id,output:n})},onEndConnection:n=>{D&&A(D.nodeId,D.output,u.id,n),q(!1),R(null)}},u.id)),d.nodes.length===0&&e.jsx("div",{className:"nice-integration-builder__empty",children:"Drag nodes from the palette to build your flow"})]}),y==="code"&&e.jsx("div",{className:"nice-integration-builder__code-view",children:e.jsx("pre",{children:JSON.stringify(d,null,2)})}),y==="variables"&&e.jsx(Oe,{variables:d.variables,onChange:u=>_(n=>({...n,variables:u}))}),y==="settings"&&e.jsx(Be,{errorHandling:d.errorHandling,schedule:d.schedule,onChange:(u,n)=>_(a=>({...a,errorHandling:u,schedule:n}))})]})]})}function $e(s){switch(s){case"http-request":return{method:"GET",url:"",headers:{},body:""};case"transform":return{mapping:[]};case"filter":return{condition:""};case"switch":return{cases:[]};case"loop":return{collection:"",itemVariable:"item"};case"delay":return{duration:1e3};case"set-variable":return{name:"",value:""};case"database":return{operation:"query",query:""};case"email":return{to:"",subject:"",body:""};case"webhook":return{method:"POST",url:""};case"function":return{code:`// Your code here
|
|
4
|
+
return input;`};case"error-handler":return{strategy:"retry",maxRetries:3};default:return{}}}function De({node:s,isSelected:i,onSelect:r,onDelete:t,onPositionChange:c,onStartConnection:o,onEndConnection:l}){const[d,x]=m.useState(!1),[p,v]=m.useState({x:0,y:0}),g=m.useRef(null),j=se.find(h=>h.type===s.type),y=h=>{h.button===0&&(h.stopPropagation(),x(!0),v({x:h.clientX-s.position.x,y:h.clientY-s.position.y}),r())};return m.useEffect(()=>{if(!d)return;const h=b=>{c({x:b.clientX-p.x,y:b.clientY-p.y})},C=()=>{x(!1)};return window.addEventListener("mousemove",h),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",C)}},[d,p,c]),e.jsxs("div",{ref:g,className:`nice-integration-builder__node nice-integration-builder__node--${s.type} ${i?"nice-integration-builder__node--selected":""}`,style:{left:s.position.x,top:s.position.y},onMouseDown:y,children:[e.jsxs("div",{className:"nice-integration-builder__node-header",children:[e.jsx("span",{className:"nice-integration-builder__node-icon",children:e.jsx(f.NiceIcon,{name:(j==null?void 0:j.icon)||"box",size:14})}),e.jsx("span",{className:"nice-integration-builder__node-name",children:s.name}),e.jsx("button",{className:"nice-integration-builder__node-delete",onClick:h=>{h.stopPropagation(),t()},children:"×"})]}),s.inputs.map(h=>e.jsxs("div",{className:"nice-integration-builder__port nice-integration-builder__port--input",onMouseUp:()=>l(h),children:[e.jsx("span",{className:"nice-integration-builder__port-dot"}),e.jsx("span",{className:"nice-integration-builder__port-label",children:h})]},h)),s.outputs.map(h=>e.jsxs("div",{className:"nice-integration-builder__port nice-integration-builder__port--output",onMouseDown:C=>{C.stopPropagation(),o(h)},children:[e.jsx("span",{className:"nice-integration-builder__port-label",children:h}),e.jsx("span",{className:"nice-integration-builder__port-dot"})]},h))]})}function ze({node:s,onChange:i,onClose:r}){return e.jsxs("div",{className:"nice-integration-builder__properties",children:[e.jsxs("div",{className:"nice-integration-builder__properties-header",children:[e.jsx("h4",{children:s.name}),e.jsx("button",{onClick:r,children:"×"})]}),e.jsxs("div",{className:"nice-integration-builder__properties-content",children:[e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Name"}),e.jsx("input",{type:"text",value:s.name,onChange:t=>i({name:t.target.value})})]}),s.type==="http-request"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Method"}),e.jsx("select",{value:s.config.method||"GET",onChange:t=>i({config:{...s.config,method:t.target.value}}),children:["GET","POST","PUT","PATCH","DELETE"].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"URL"}),e.jsx("input",{type:"text",value:s.config.url||"",onChange:t=>i({config:{...s.config,url:t.target.value}}),placeholder:"https://api.example.com/endpoint"})]})]}),s.type==="delay"&&e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Duration (ms)"}),e.jsx("input",{type:"number",value:s.config.duration||1e3,onChange:t=>i({config:{...s.config,duration:parseInt(t.target.value,10)}})})]}),s.type==="set-variable"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Variable Name"}),e.jsx("input",{type:"text",value:s.config.name||"",onChange:t=>i({config:{...s.config,name:t.target.value}})})]}),e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Value"}),e.jsx("input",{type:"text",value:s.config.value||"",onChange:t=>i({config:{...s.config,value:t.target.value}})})]})]}),s.type==="function"&&e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Code"}),e.jsx("textarea",{value:s.config.code||"",onChange:t=>i({config:{...s.config,code:t.target.value}}),rows:10,className:"nice-integration-builder__code-input"})]}),s.type==="email"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{type:"text",value:s.config.to||"",onChange:t=>i({config:{...s.config,to:t.target.value}})})]}),e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{type:"text",value:s.config.subject||"",onChange:t=>i({config:{...s.config,subject:t.target.value}})})]}),e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Body"}),e.jsx("textarea",{value:s.config.body||"",onChange:t=>i({config:{...s.config,body:t.target.value}}),rows:5})]})]})]})]})}function Oe({variables:s,onChange:i}){const r=()=>{i({...s,newVariable:""})};return e.jsxs("div",{className:"nice-integration-builder__variables",children:[e.jsx("h4",{children:"Flow Variables"}),e.jsx("div",{className:"nice-integration-builder__variables-list",children:Object.entries(s).map(([t,c])=>e.jsxs("div",{className:"nice-integration-builder__variable-row",children:[e.jsx("input",{type:"text",value:t,onChange:o=>{const{[t]:l,...d}=s;i({...d,[o.target.value]:c})},placeholder:"Name"}),e.jsx("input",{type:"text",value:String(c),onChange:o=>i({...s,[t]:o.target.value}),placeholder:"Value"}),e.jsx("button",{onClick:()=>{const{[t]:o,...l}=s;i(l)},children:"×"})]},t))}),e.jsx("button",{onClick:r,children:"+ Add Variable"})]})}function Be({errorHandling:s,schedule:i,onChange:r}){return e.jsxs("div",{className:"nice-integration-builder__settings",children:[e.jsx("h4",{children:"Error Handling"}),e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Strategy"}),e.jsxs("select",{value:s.strategy,onChange:t=>r({...s,strategy:t.target.value},i),children:[e.jsx("option",{value:"stop",children:"Stop on error"}),e.jsx("option",{value:"continue",children:"Continue on error"}),e.jsx("option",{value:"retry",children:"Retry on error"})]})]}),s.strategy==="retry"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Max Retries"}),e.jsx("input",{type:"number",value:s.maxRetries||3,onChange:t=>r({...s,maxRetries:parseInt(t.target.value,10)},i)})]}),e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Retry Delay (ms)"}),e.jsx("input",{type:"number",value:s.retryDelay||1e3,onChange:t=>r({...s,retryDelay:parseInt(t.target.value,10)},i)})]})]}),e.jsx("h4",{children:"Schedule"}),e.jsx("div",{className:"nice-integration-builder__field",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(i==null?void 0:i.enabled)||!1,onChange:t=>r(s,{...i,enabled:t.target.checked})}),"Enable scheduled execution"]})}),(i==null?void 0:i.enabled)&&e.jsxs("div",{className:"nice-integration-builder__field",children:[e.jsx("label",{children:"Cron Expression"}),e.jsx("input",{type:"text",value:i.cron||"",onChange:t=>r(s,{...i,cron:t.target.value}),placeholder:"0 0 * * *"})]})]})}const Ke=[{target:".nice-webhook-tester",titleKey:"tutorial.webhookTester.intro.title",title:"Webhook tester",contentKey:"tutorial.webhookTester.intro.content",content:"Pick a saved payload (or write one), optionally sign it, send it to the endpoint and inspect the response.",placement:"auto"}];function ne(s){return s?Object.entries(s).map(([i,r])=>({key:i,value:r})):[]}function ae(s){const i={};for(const r of s)r.key.trim()!==""&&(i[r.key]=r.value);return i}async function He(s,i){var l;const r=(l=globalThis.crypto)==null?void 0:l.subtle;if(!r)throw new Error("Web Crypto (crypto.subtle) is unavailable in this environment");const t=new TextEncoder,c=await r.importKey("raw",t.encode(s),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),o=await r.sign("HMAC",c,t.encode(i));return[...new Uint8Array(o)].map(d=>d.toString(16).padStart(2,"0")).join("")}const Le=m.forwardRef(function(i,r){const{url:t="",method:c="POST",headers:o,payload:l="",samples:d=[],onSend:x,signing:p,onSaveSample:v,tutorial:g,className:j,style:y,id:h,"data-testid":C}=i,[b,E]=m.useState(t),[B,L]=m.useState(c),[q,D]=m.useState(()=>ne(o)),[R,z]=m.useState(l),[K,N]=m.useState(""),[_,P]=m.useState(!1),[$,O]=m.useState(null),[A,M]=m.useState(null),H=m.useMemo(()=>{const a=new Map;for(const w of d)a.set(w.id,w);return a},[d]),V=a=>{N(a);const w=H.get(a);w&&(z(w.payload),w.headers&&D(ne(w.headers)))},U=(a,w)=>{D(T=>T.map((S,I)=>I===a?{...S,...w}:S))},J=async()=>{P(!0),O(null),M(null);try{const a=ae(q);if(p&&p.secret){const I=await He(p.secret,R);a[p.header]=`${p.prefix??""}${I}`}const w=typeof performance<"u"?performance.now():Date.now(),T=await x({url:b,method:B??"POST",headers:a,body:R}),S=Math.round((typeof performance<"u"?performance.now():Date.now())-w);M({...T,durationMs:T.durationMs??S})}catch(a){O(a instanceof Error?a.message:String(a))}finally{P(!1)}},W=()=>{var w;if(!v)return;const a=typeof window<"u"&&((w=window.prompt)==null?void 0:w.call(window,"Sample name"))||"";a&&v({id:`sample_${Date.now().toString(36)}`,name:a,payload:R,headers:ae(q)})},u=A==null?"":A.status>=200&&A.status<300?" nice-webhook-tester__status--ok":" nice-webhook-tester__status--error",n="nice-webhook-tester"+(j?` ${j}`:"");return e.jsxs("div",{ref:r,id:h,className:n,style:y,"data-testid":C,children:[g&&e.jsx("div",{className:"nice-webhook-tester__tutorial",children:e.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(g,Ke)})}),e.jsxs("div",{className:"nice-webhook-tester__bar",children:[e.jsx("select",{className:"nice-webhook-tester__method",value:B,onChange:a=>L(a.target.value),"aria-label":"Method",children:["POST","PUT","GET","PATCH","DELETE"].map(a=>e.jsx("option",{value:a,children:a},a))}),e.jsx("input",{type:"text",className:"nice-webhook-tester__url",value:b,placeholder:"https://example.com/api/payments/stripe/webhook",onChange:a=>E(a.target.value),"aria-label":"URL"}),e.jsx("button",{type:"button",className:"nice-webhook-tester__send",onClick:()=>void J(),disabled:_||b.trim()==="",children:_?"Sending…":"Send"})]}),d.length>0&&e.jsx("div",{className:"nice-webhook-tester__samples",children:e.jsxs("label",{children:["Sample:"," ",e.jsxs("select",{value:K,onChange:a=>V(a.target.value),children:[e.jsx("option",{value:"",children:"— choose a saved payload —"}),d.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]})}),e.jsxs("div",{className:"nice-webhook-tester__headers",children:[e.jsxs("div",{className:"nice-webhook-tester__section-label",children:["Headers",p&&e.jsxs("span",{className:"nice-webhook-tester__signed",children:[" ","· auto-signs ",e.jsx("code",{children:p.header})]})]}),q.map((a,w)=>e.jsxs("div",{className:"nice-webhook-tester__header-row",children:[e.jsx("input",{type:"text",value:a.key,placeholder:"Header",onChange:T=>U(w,{key:T.target.value}),"aria-label":"Header name"}),e.jsx("input",{type:"text",value:a.value,placeholder:"Value",onChange:T=>U(w,{value:T.target.value}),"aria-label":"Header value"}),e.jsx("button",{type:"button",onClick:()=>D(T=>T.filter((S,I)=>I!==w)),"aria-label":"Remove header",children:e.jsx(k.NiceIcon,{name:"close",size:12})})]},w)),e.jsx("button",{type:"button",className:"nice-webhook-tester__add-header",onClick:()=>D(a=>[...a,{key:"",value:""}]),children:"+ Header"})]}),e.jsxs("div",{className:"nice-webhook-tester__payload",children:[e.jsxs("div",{className:"nice-webhook-tester__section-label",children:["Payload",v&&e.jsx("button",{type:"button",className:"nice-webhook-tester__save",onClick:W,children:"Save as sample"})]}),e.jsx("textarea",{className:"nice-webhook-tester__textarea",value:R,spellCheck:!1,rows:8,placeholder:'{ "type": "payment.succeeded", "data": { ... } }',onChange:a=>z(a.target.value),"aria-label":"Payload"})]}),$&&e.jsx("div",{className:"nice-webhook-tester__error",children:$}),A&&e.jsxs("div",{className:"nice-webhook-tester__response",children:[e.jsxs("div",{className:"nice-webhook-tester__section-label",children:["Response"," ",e.jsx("span",{className:"nice-webhook-tester__status"+u,children:A.status}),A.durationMs!=null&&e.jsxs("span",{className:"nice-webhook-tester__time",children:[" · ",A.durationMs," ms"]})]}),A.body!=null&&e.jsx("pre",{className:"nice-webhook-tester__response-body",children:A.body})]})]})});exports.NiceAPIDesigner=he;exports.NiceAPITester=Ne;exports.NiceIntegrationBuilder=Re;exports.NiceWebhookTester=Le;
|