@nice2dev/ui 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +433 -0
  2. package/dist/NiceButton-CnAIqCbd.js +101 -0
  3. package/dist/NiceButton-DzCqkG5a.cjs +1 -0
  4. package/dist/NiceCodeEditor-CK6B54mu.js +1215 -0
  5. package/dist/NiceCodeEditor-bJReZPDO.cjs +268 -0
  6. package/dist/NiceColorPicker-BV3olE3M.cjs +1 -0
  7. package/dist/NiceColorPicker-CyY-4q89.js +552 -0
  8. package/dist/NiceDataGrid-BQIqitMM.cjs +10 -0
  9. package/dist/NiceDataGrid-C1eI6Pso.js +2267 -0
  10. package/dist/NiceForm-CfAPcXdX.cjs +1 -0
  11. package/dist/NiceForm-DfKYNQti.js +5017 -0
  12. package/dist/NiceGantt-TEXbAELi.js +333 -0
  13. package/dist/NiceGantt-s2cgt5zD.cjs +1 -0
  14. package/dist/NiceHtmlEditor-CDZeF_zG.cjs +10 -0
  15. package/dist/NiceHtmlEditor-CdWgddg3.js +901 -0
  16. package/dist/NiceLoginForm-DRPldHXa.js +808 -0
  17. package/dist/NiceLoginForm-IGLUCQUE.cjs +1 -0
  18. package/dist/NiceMention-CgDp0sl9.cjs +430 -0
  19. package/dist/NiceMention-DBvFvx71.js +11653 -0
  20. package/dist/NiceMention.css +1 -1
  21. package/dist/NiceModal-BlYhFDhP.js +80 -0
  22. package/dist/NiceModal-DmWz2PDM.cjs +1 -0
  23. package/dist/NiceModuleLifecyclePanel-D8EoXqBy.cjs +1 -0
  24. package/dist/NiceModuleLifecyclePanel-SN6G7t64.js +7189 -0
  25. package/dist/NiceModuleLifecyclePanel.css +1 -1
  26. package/dist/NicePagination-BJS65foT.js +200 -0
  27. package/dist/NicePagination-D_3GfWp5.cjs +1 -0
  28. package/dist/NicePivotGrid-D_kRF1Dt.js +1180 -0
  29. package/dist/NicePivotGrid-DqluEkCI.cjs +152 -0
  30. package/dist/NiceSavedQueryPanel-C2Tn1cMW.js +5311 -0
  31. package/dist/NiceSavedQueryPanel-DDKtL1AA.cjs +586 -0
  32. package/dist/NiceScheduler-GJLvkXJ3.cjs +5 -0
  33. package/dist/NiceScheduler-UT49u2Vq.js +1710 -0
  34. package/dist/NiceSelect-CdUHd8rj.cjs +1 -0
  35. package/dist/NiceSelect-fOelG_QB.js +495 -0
  36. package/dist/NiceWindow-CqSsTjrS.cjs +1 -0
  37. package/dist/NiceWindow-DZLPhXbR.js +2223 -0
  38. package/dist/charts-BYQwl_GS.js +4789 -0
  39. package/dist/charts-C6iOu0H6.cjs +768 -0
  40. package/dist/charts.cjs +1 -1
  41. package/dist/charts.d.ts +1 -1
  42. package/dist/charts.mjs +1 -1
  43. package/dist/core-lazy-B_laOXNf.cjs +1 -0
  44. package/dist/core-lazy-VQEjdz0L.js +351 -0
  45. package/dist/data-branching-7rpktFJ-.cjs +1 -0
  46. package/dist/data-branching-BS0aFUMu.js +6428 -0
  47. package/dist/data-branching.cjs +1 -1
  48. package/dist/data-branching.mjs +1 -1
  49. package/dist/data.cjs +1 -1
  50. package/dist/data.mjs +3 -3
  51. package/dist/devops-CFytAJQr.cjs +18 -0
  52. package/dist/devops-CW8YY_zA.js +9122 -0
  53. package/dist/devops.cjs +1 -1
  54. package/dist/devops.css +1 -0
  55. package/dist/devops.mjs +5 -5
  56. package/dist/editors.cjs +1 -1
  57. package/dist/editors.mjs +8 -8
  58. package/dist/feedback.cjs +1 -1
  59. package/dist/feedback.d.ts +21 -16
  60. package/dist/feedback.mjs +3 -3
  61. package/dist/index.cjs +262 -257
  62. package/dist/index.css +1 -1
  63. package/dist/index.d.ts +374 -20
  64. package/dist/index.mjs +21602 -20317
  65. package/dist/lazy.cjs +1 -1
  66. package/dist/lazy.mjs +24 -24
  67. package/dist/navigation.cjs +1 -1
  68. package/dist/navigation.d.ts +31 -0
  69. package/dist/navigation.mjs +404 -354
  70. package/dist/no-code-BaAI_sJR.js +8318 -0
  71. package/dist/no-code-oQTeAtnW.cjs +331 -0
  72. package/dist/no-code.cjs +1 -1
  73. package/dist/no-code.mjs +1 -1
  74. package/dist/overlays.cjs +1 -1
  75. package/dist/overlays.d.ts +5 -0
  76. package/dist/overlays.mjs +1 -1
  77. package/dist/pickerCommons-BQi6IEAt.js +661 -0
  78. package/dist/pickerCommons-DvQptSPX.cjs +1 -0
  79. package/dist/style.css +7 -4
  80. package/package.json +4 -3
@@ -0,0 +1,331 @@
1
+ "use strict";const e=require("react/jsx-runtime"),a=require("@nice2dev/ui-core"),g=require("react"),de=require("./devops-CFytAJQr.cjs"),we=Object.assign(g.forwardRef(({label:o,checked:S=!1,indeterminate:f=!1,onChange:b,disabled:N,readOnly:j,loading:k,required:p,size:$="md",name:i,id:r,className:d,style:C,error:w,helperText:R,accessMode:q,displayStyle:G,showKeyboardHints:O,labelPlacement:T,errorPlacement:I,labelWidth:H,controlWidth:M},m)=>{const D=a.useNiceAccessMode(q,r),A=D==="hidden";(D==="disabled"||D==="readOnly")&&(N=!0);const{t:Y}=a.useNiceTranslation(),B=a.useControlId(r);a.useComponentDisplayClass("toggle",G);const Z=g.useMemo(()=>[{key:"Space",description:Y("shortcuts.toggle","Toggle")}],[Y]),F=g.useCallback(V=>{V&&(V.indeterminate=f),typeof m=="function"?m(V):m&&(m.current=V)},[f,m]);return A?null:e.jsxs("div",{className:`nice-field nice-field--inline nice-field--${$} ${T==="left"?"nice-field--label-left":""} ${I==="right"?"nice-field--error-right":""} ${k?"nice-field--loading":""} ${d||""}`,style:{...C,...H!=null&&{"--nice-field-label-width":typeof H=="number"?`${H}px`:H},...M!=null&&{"--nice-field-control-width":typeof M=="number"?`${M}px`:M}},"aria-busy":k||void 0,children:[T==="left"&&o&&e.jsx("span",{className:`nice-field__label ${p?"nice-field__label--required":""}`,children:o}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("label",{className:`nice-checkbox ${$!=="md"?`nice-checkbox--${$}`:""} ${N||k?"nice-checkbox--disabled":""}`,htmlFor:B,children:[e.jsx("input",{ref:F,id:B,type:"checkbox",className:"nice-checkbox__input",name:i,checked:S,disabled:N||k,readOnly:j,"aria-invalid":!!w,onChange:V=>{j||k||b?.(V.target.checked)}}),e.jsx("span",{className:"nice-checkbox__box",children:e.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:S?e.jsx("polyline",{points:"2 6 5 9 10 3"}):e.jsx("line",{x1:"2",y1:"6",x2:"10",y2:"6"})})}),T!=="left"&&o&&e.jsx("span",{children:o}),O&&e.jsx(a.NiceKeyboardHint,{shortcuts:Z,size:"sm"})]}),k&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),I==="right"&&w&&e.jsx("div",{id:`${B}-error`,className:"nice-field__error",role:"alert",children:w}),I==="right"&&!w&&R&&e.jsx("div",{id:`${B}-helper`,className:"nice-field__helper",children:R})]}),I!=="right"&&w&&e.jsx("div",{id:`${B}-error`,className:"nice-field__error",role:"alert",children:w}),I!=="right"&&!w&&R&&e.jsx("div",{id:`${B}-helper`,className:"nice-field__helper",children:R})]})}),{displayName:"NiceCheckbox"}),at=Object.freeze(Object.defineProperty({__proto__:null,NiceCheckbox:we},Symbol.toStringTag,{value:"Module"})),ke=Object.assign(g.forwardRef(({label:o,helperText:S,error:f,required:b,disabled:N,readOnly:j,size:k="md",name:p,id:$,className:i,style:r,accessMode:d,displayStyle:C,value:w,onChange:R,onBlur:q,onKeyDown:G,placeholder:O,min:T,max:I,step:H=1,precision:M,prefix:m,prefixType:D="label",prefixOptions:A,prefixValue:Y,onPrefixChange:B,suffix:Z,showStepper:F=!0,submitOnEnter:V,onSubmit:s,showKeyboardHints:t,labelPlacement:n,errorPlacement:y,loading:h,labelWidth:x,controlWidth:z,formatPreset:l,format:ee,suffixType:te="label",suffixOptions:u,suffixValue:X,onSuffixChange:c,suffixSeparator:W=!1,displayMode:K},J)=>{const L=a.useNiceAccessMode(d,$),v=L==="hidden";L==="disabled"&&(N=!0),L==="readOnly"&&(j=!0);const{t:E}=a.useNiceTranslation(),P=a.useControlId($),Q=a.useComponentDisplayStyle("input",C),ae=a.useComponentDisplayClass("input",C),[ce,$e]=g.useState(!1),[ye,ge]=g.useState(null),xe=a.useDisplayModeEdit({enabled:K,readOnly:j,disabled:N}),et=g.useMemo(()=>{let _=3;return I!=null&&(_=String(Math.abs(Math.floor(I))).length),T!=null&&T<0&&(_+=1),M&&(_+=M+1),Math.max(3,_)+1},[I,T,M]),Ce=g.useCallback(_=>{if(ee)return ee(_);if(!l)return M!=null?_.toFixed(M):String(_);switch(l){case"integer":return Math.round(_).toLocaleString();case"decimal":return _.toLocaleString(void 0,{minimumFractionDigits:M??2,maximumFractionDigits:M??2});case"money":return _.toLocaleString(void 0,{minimumFractionDigits:M??2,maximumFractionDigits:M??2,useGrouping:!0});case"percent":return(_*100).toLocaleString(void 0,{minimumFractionDigits:M??0,maximumFractionDigits:M??2})+"%";default:return String(_)}},[ee,l,M]),he=g.useMemo(()=>ce&&ye!==null?ye:w==null?"":ce?M!=null?w.toFixed(M):String(w):Ce(w),[w,ce,ye,Ce,M]),tt=w!=null&&w<0,nt=!!(m||D==="select"&&A&&A.length>0),be=tt&&nt&&!ce,rt=be?he.replace(/^[-−]/,""):he,ze=g.useCallback(_=>{let U=_;return T!==void 0&&(U=Math.max(T,U)),I!==void 0&&(U=Math.min(I,U)),M!==void 0&&(U=parseFloat(U.toFixed(M))),U},[T,I,M]),it=g.useCallback(_=>{const U=_.target.value;if(ge(U),U===""||U==="-"||U==="."||U==="-."){U===""&&R?.(null);return}const ne=parseFloat(U);if(!isNaN(ne)){let re=ne;T!==void 0&&(re=Math.max(T,re)),I!==void 0&&(re=Math.min(I,re)),R?.(re)}},[R,T,I]),pe=g.useCallback(_=>{const U=ze(_);ve.current=U,ge(null),R?.(U)},[R,ze]),se=g.useCallback(_=>pe((ve.current??0)+_*H),[pe,H]),Te=g.useCallback(()=>se(1),[se]),Ie=g.useCallback(()=>se(-1),[se]),ve=g.useRef(w);ve.current=w;const ue=g.useRef(null),le=g.useCallback(()=>{ue.current&&(clearTimeout(ue.current),ue.current=null)},[]),_e=g.useCallback(_=>{le();let U=300;const ne=()=>{_(),U=Math.max(30,U*.82),ue.current=setTimeout(ne,U)};ue.current=setTimeout(ne,400)},[le]),Re=a.useSubmitOnEnter({enabled:V,onSubmit:s}),ot=g.useCallback(_=>{if(Re(_),!j){const U=_.key==="ArrowUp"?1:_.key==="ArrowDown"?-1:_.key==="PageUp"?10:_.key==="PageDown"?-10:0;U?(_.preventDefault(),se(U)):_.key==="Home"&&T!==void 0?(_.preventDefault(),pe(T)):_.key==="End"&&I!==void 0&&(_.preventDefault(),pe(I))}G?.(_)},[Re,G,j,se,pe,T,I]),Be=g.useMemo(()=>{const _=[];return V&&_.push(a.COMMON_SHORTCUTS.submit),F&&(_.push({key:"ArrowUp",description:E("shortcuts.increment","Increase value")}),_.push({key:"ArrowDown",description:E("shortcuts.decrement","Decrease value")}),_.push({key:"PageUp",description:E("shortcuts.incrementBig","Increase by 10")}),_.push({key:"PageDown",description:E("shortcuts.decrementBig","Decrease by 10")}),T!==void 0&&_.push({key:"Home",description:E("shortcuts.toMinimum","Set to minimum")}),I!==void 0&&_.push({key:"End",description:E("shortcuts.toMaximum","Set to maximum")})),_},[V,F,T,I,E]);return v?null:e.jsxs("div",{className:`nice-field nice-field--${k} ${n==="left"?"nice-field--label-left":""} ${h?"nice-field--loading":""} ${i||""}`,style:{...r,...x!=null&&{"--nice-field-label-width":typeof x=="number"?`${x}px`:x},...z!=null&&{"--nice-field-control-width":typeof z=="number"?`${z}px`:z}},"aria-busy":h||void 0,children:[o&&e.jsxs("label",{htmlFor:P,className:`nice-field__label ${b?"nice-field__label--required":""}`,children:[o,t&&Be.length>0&&e.jsx(a.NiceKeyboardHint,{shortcuts:Be,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[xe.isDisplay?e.jsx(a.DisplayModeView,{value:w==null?"":m?e.jsxs(e.Fragment,{children:[m,he]}):he,placeholder:O,disabled:N,readOnly:j,onActivate:xe.enterEdit,ariaLabel:o}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:`nice-input nice-input--number nice-input--${k} nice-input--ds-${ae} ${W?"nice-input--suffix-sep":""} ${f?"nice-input--error":""} ${N?"nice-input--disabled":""} ${j?"nice-input--readonly":""}`,style:Q,children:[F&&!j&&e.jsx("button",{type:"button",className:"nice-input__clear nice-input__minus",onClick:Ie,onMouseDown:()=>_e(Ie),onMouseUp:le,onMouseLeave:le,disabled:N,"aria-label":E("controls.decrement","Decrement"),children:e.jsx(a.NiceIcon,{name:"minus",size:16})}),D==="select"&&A&&A.length>0?e.jsxs(e.Fragment,{children:[be&&e.jsx("span",{className:"nice-input__sign",children:"−"}),e.jsx("select",{className:"nice-input__suffix-select nice-input__icon--prefix",value:Y??A[0]?.value,disabled:N,onChange:_=>{const U=_.target.value,ne=A.find(oe=>oe.value===(Y??A[0]?.value)),re=A.find(oe=>oe.value===U);B?.(U,ne?.weight,re?.weight)},children:A.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]}):m?e.jsxs("span",{className:"nice-input__icon nice-input__icon--prefix",children:[be&&e.jsx("span",{className:"nice-input__sign",children:"−"}),m]}):null,e.jsx("input",{ref:_=>{typeof J=="function"?J(_):J&&(J.current=_),xe.autoFocusRef(_)},id:P,className:"nice-input__native",type:!ce&&(ee||l)?"text":"number",name:p,value:rt,placeholder:O,min:T,max:I,step:H,disabled:N||h,readOnly:j,"aria-invalid":!!f,onChange:it,onFocus:_=>{$e(!0),ge(null),_.target.select()},onBlur:_=>{if($e(!1),ge(null),w!=null&&M!==void 0){const U=parseFloat(w.toFixed(M));U!==w&&R?.(U)}K&&xe.exitEdit(),q?.(_)},onKeyDown:ot,style:{width:`${et}ch`}}),te==="select"&&u&&u.length>0?e.jsx("select",{className:"nice-input__suffix-select nice-input__icon--suffix",value:X??u[0]?.value,disabled:N,onChange:_=>{const U=_.target.value,ne=u.find(oe=>oe.value===(X??u[0]?.value)),re=u.find(oe=>oe.value===U);c?.(U,ne?.weight,re?.weight)},children:u.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))}):Z?e.jsx("span",{className:"nice-input__icon nice-input__icon--suffix",children:Z}):null,F&&!j&&e.jsx("button",{type:"button",className:"nice-input__clear nice-input__plus",onClick:Te,onMouseDown:()=>_e(Te),onMouseUp:le,onMouseLeave:le,disabled:N,"aria-label":E("controls.increment","Increment"),children:e.jsx(a.NiceIcon,{name:"plus",size:16})})]})}),h&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),y==="right"&&f&&e.jsx("div",{className:"nice-field__error",role:"alert",children:f}),y==="right"&&!f&&S&&e.jsx("div",{className:"nice-field__helper",children:S})]}),y!=="right"&&f&&e.jsx("div",{className:"nice-field__error",role:"alert",children:f}),y!=="right"&&!f&&S&&e.jsx("div",{className:"nice-field__helper",children:S})]})}),{displayName:"NiceNumberInput"}),st=Object.freeze(Object.defineProperty({__proto__:null,NiceNumberInput:ke},Symbol.toStringTag,{value:"Module"})),Ne=Object.assign(g.forwardRef(({label:o,helperText:S,error:f,required:b,disabled:N,readOnly:j,size:k="md",name:p,id:$,className:i,style:r,accessMode:d,displayStyle:C,variant:w,value:R,defaultValue:q,onChange:G,onBlur:O,onKeyDown:T,placeholder:I,type:H="text",maxLength:M,prefix:m,suffix:D,clearable:A,autoFocus:Y,submitOnEnter:B,onSubmit:Z,showKeyboardHints:F,labelPlacement:V,errorPlacement:s,loading:t,labelWidth:n,controlWidth:y,displayMode:h,...x},z)=>{const l=a.useNiceAccessMode(d,$),ee=l==="hidden";l==="disabled"&&(N=!0),l==="readOnly"&&(j=!0);const{t:te}=a.useNiceTranslation(),u=a.useControlId($),X=a.useComponentDisplayStyle("input",C),c=a.useComponentDisplayClass("input",C),W=w==="filled"?"filled":w==="underlined"?"underlined":"",K=g.useCallback(()=>G?.(""),[G]),J=a.useDisplayModeEdit({enabled:h,readOnly:j,disabled:N}),L=a.useSubmitOnEnter({enabled:B,onSubmit:Z}),v=g.useCallback(P=>{L(P),T?.(P)},[L,T]),E=g.useMemo(()=>{const P=[];return B&&P.push({key:"Enter",description:te("shortcuts.submit","Submit")}),A&&P.push({key:"Escape",description:te("shortcuts.clear","Clear")}),P},[B,A,te]);return ee?null:e.jsxs("div",{className:`nice-field nice-field--${k} ${V==="left"?"nice-field--label-left":""} ${V==="inside"?"nice-field--label-inside":""} ${t?"nice-field--loading":""} ${i||""}`,style:{...r,...n!=null&&{"--nice-field-label-width":typeof n=="number"?`${n}px`:n},...y!=null&&{"--nice-field-control-width":typeof y=="number"?`${y}px`:y}},"aria-busy":t||void 0,"data-floating":V==="inside"&&R?"true":void 0,children:[o&&V!=="inside"&&e.jsxs("label",{htmlFor:u,className:`nice-field__label ${b?"nice-field__label--required":""}`,children:[o,F&&E.length>0&&e.jsx(a.NiceKeyboardHint,{shortcuts:E,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[J.isDisplay?e.jsx(a.DisplayModeView,{value:R??q??"",placeholder:I,disabled:N,readOnly:j,onActivate:J.enterEdit,ariaLabel:o}):e.jsxs("div",{className:`nice-input nice-input--${k} nice-input--ds-${W||c} ${f?"nice-input--error":""} ${N?"nice-input--disabled":""} ${j?"nice-input--readonly":""}`,style:w?void 0:X,children:[m&&e.jsx("span",{className:"nice-input__icon",children:m}),e.jsx("input",{ref:P=>{typeof z=="function"?z(P):z&&(z.current=P),J.autoFocusRef(P)},id:u,className:"nice-input__native",type:H,name:p,value:R,defaultValue:q,placeholder:I,disabled:N||t,readOnly:j,maxLength:M,autoFocus:Y,"aria-invalid":!!f,"aria-describedby":f?`${u}-error`:S?`${u}-helper`:void 0,onChange:P=>G?.(P.target.value),onBlur:P=>{h&&J.exitEdit(),O?.(P)},onKeyDown:v,...x}),A&&R&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:K,"aria-label":te("controls.clear","Clear"),children:e.jsx(a.NiceIcon,{name:"close",size:14})}),D&&e.jsx("span",{className:"nice-input__icon",children:D}),o&&V==="inside"&&e.jsx("label",{htmlFor:u,className:`nice-input__floating-label ${b?"nice-input__floating-label--required":""}`,children:o})]}),t&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),s==="right"&&f&&e.jsx("div",{id:`${u}-error`,className:"nice-field__error",role:"alert",children:f}),s==="right"&&!f&&S&&e.jsx("div",{id:`${u}-helper`,className:"nice-field__helper",children:S})]}),s!=="right"&&f&&e.jsx("div",{id:`${u}-error`,className:"nice-field__error",role:"alert",children:f}),s!=="right"&&!f&&S&&e.jsx("div",{id:`${u}-helper`,className:"nice-field__helper",children:S})]})}),{displayName:"NiceTextInput"}),lt=Object.freeze(Object.defineProperty({__proto__:null,NiceTextInput:Ne},Symbol.toStringTag,{value:"Module"})),He=({code:o,language:S="typescript",lineNumbers:f=!0,livePreview:b=!1,showDiff:N=!1,previousCode:j,theme:k="light",copyable:p=!0,onCopy:$,className:i})=>{const{t:r}=a.useNiceTranslation(),[d,C]=g.useState(!1),w=async()=>{await navigator.clipboard.writeText(o),C(!0),$?.(),setTimeout(()=>C(!1),2e3)},R=o.split(`
2
+ `),q=()=>e.jsx("div",{className:"nice-code-preview__line-numbers",children:R.map((I,H)=>e.jsx("span",{children:H+1},H))}),G=()=>e.jsx("pre",{className:`nice-code-preview__code language-${S}`,children:e.jsx("code",{children:o})}),O=()=>j?e.jsxs("div",{className:"nice-code-preview__diff",children:[e.jsxs("div",{className:"nice-code-preview__diff-panel nice-code-preview__diff-panel--old",children:[e.jsx("h4",{children:r("codePreview.previous","Previous")}),e.jsx("pre",{children:j})]}),e.jsxs("div",{className:"nice-code-preview__diff-panel nice-code-preview__diff-panel--new",children:[e.jsx("h4",{children:r("codePreview.current","Current")}),e.jsx("pre",{children:o})]})]}):null,T=()=>S!=="html"?e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("p",{children:r("codePreview.livePreviewIsAvailableFor","Live preview is available for HTML only")})}):e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("iframe",{srcDoc:o,title:r("codePreview.livePreview","Live Preview"),sandbox:"allow-scripts"})});return e.jsxs("div",{className:`nice-code-preview nice-code-preview--${k} ${i||""}`,children:[e.jsxs("header",{className:"nice-code-preview__header",children:[e.jsx("span",{className:"nice-code-preview__language",children:S}),p&&e.jsx("button",{onClick:w,className:"nice-code-preview__copy-btn",children:d?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"check",size:14})," ",r("codePreview.copied","Copied")]}):r("codePreview.copy","Copy")})]}),N&&j?O():e.jsxs("div",{className:"nice-code-preview__body",children:[f&&q(),G()]}),b&&e.jsxs("div",{className:"nice-code-preview__preview-section",children:[e.jsx("h4",{children:r("codePreview.preview","Preview")}),T()]})]})},dt=[{target:".nice-lowcode-studio",titleKey:"tutorial.lowCodeStudio.intro.title",title:"Low-code studio",contentKey:"tutorial.lowCodeStudio.intro.content",content:"Drag components from the sidebar onto the canvas, then switch between Design, Preview and Code tabs to build and export your app.",placement:"auto"}],ct={components:[],layout:{type:"flex"},styles:{}},je="application/x-nice-component";function pt(o){const S=o.replace(/[^A-Za-z0-9]+(.)?/g,(f,b)=>b?b.toUpperCase():"");return/^[A-Za-z]/.test(S)?S.charAt(0).toUpperCase()+S.slice(1):`Component${S}`}function ut(o,S){return["export function Page() {"," return ("," <>",...o.components.map(b=>{const N=Object.entries(b.props).map(([j,k])=>typeof k=="string"?` ${j}=${JSON.stringify(k)}`:` ${j}={${JSON.stringify(k)}}`);return` <${S(b.type)}${N.join("")} />`})," </>"," );","}"].join(`
3
+ `)}const mt=({projectId:o,components:S=[],theme:f="light",onChange:b,onSave:N,renderComponent:j,className:k,tutorial:p})=>{const{t:$}=a.useNiceTranslation(),[i,r]=g.useState("design"),[d,C]=g.useState(ct),[w,R]=g.useState(null),[q,G]=g.useState(!1),O=g.useRef(0),T=t=>S.find(n=>n.id===t),I=t=>T(t)?.name??t,H=t=>{const n=T(t)?.icon;return n?e.jsx(a.NiceIcon,{name:n,size:14}):null},M=t=>{const n={...d,components:t};C(n),b?.(n)},m=t=>{O.current+=1;const n={id:`${t.id}-${O.current}`,type:t.id,props:{...t.defaultProps}};M([...d.components,n]),R(n.id)},D=t=>{M(d.components.filter(n=>n.id!==t)),w===t&&R(null)},A=(t,n,y)=>M(d.components.map(h=>h.id===t?{...h,props:{...h.props,[n]:y}}:h)),Y=t=>{Array.from(t.dataTransfer.types).includes(je)&&(t.preventDefault(),t.dataTransfer.dropEffect="copy",G(!0))},B=t=>{t.currentTarget.contains(t.relatedTarget)||G(!1)},Z=t=>{t.preventDefault(),G(!1);const n=T(t.dataTransfer.getData(je));n&&m(n)},F=(t,n,y)=>typeof y=="boolean"?e.jsx(we,{label:n,checked:y,onChange:h=>A(t,n,h)}):typeof y=="number"?e.jsx(ke,{label:n,value:y,onChange:h=>A(t,n,h??0)}):typeof y=="string"?e.jsx(Ne,{label:n,value:y,onChange:h=>A(t,n,h)}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n}),e.jsx("code",{children:JSON.stringify(y)})]}),V=d.components.find(t=>t.id===w),s=[{id:"design",label:$("noCode.lowCodeStudio.design","Design")},{id:"preview",label:$("noCode.preview","Preview")},{id:"code",label:$("noCode.lowCodeStudio.code","Code")}];return e.jsx(de.NiceAppShell,{flush:!0,className:`nice-lowcode-studio nice-lowcode-studio--${f} ${k||""}`,menubar:e.jsxs("header",{className:"nice-lowcode-studio__header",children:[e.jsx("h1",{children:$("noCode.lowCodeStudio.title","Low-Code Studio")}),e.jsx("nav",{className:"nice-lowcode-studio__tabs",children:s.map(t=>e.jsx("button",{type:"button","aria-pressed":i===t.id,onClick:()=>r(t.id),className:`nice-lowcode-studio__tab ${i===t.id?"nice-lowcode-studio__tab--active":""}`,children:t.label},t.id))}),e.jsx("button",{type:"button",onClick:()=>N?.(d),children:$("save","Save")}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(p,dt)})]}),sidebar:e.jsxs("aside",{className:"nice-lowcode-studio__sidebar",children:[e.jsx("h2",{children:$("noCode.componentDesigner.palette","Component Palette")}),e.jsx("ul",{children:S.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",draggable:!0,className:"nice-lowcode-studio__palette-item",title:$("noCode.lowCodeStudio.addHint","Drag onto the canvas, or click to add"),onDragStart:n=>{n.dataTransfer.setData(je,t.id),n.dataTransfer.effectAllowed="copy"},onClick:()=>m(t),children:[H(t.id),t.name]})},t.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-lowcode-studio__properties",children:[e.jsx("h2",{children:$("noCode.lowCodeStudio.properties","Properties")}),V?e.jsxs("div",{className:"nice-lowcode-studio__props",children:[e.jsx("h3",{children:I(V.type)}),Object.keys(V.props).length===0?e.jsx("p",{children:$("noCode.lowCodeStudio.noProps","This component has no properties")}):Object.entries(V.props).map(([t,n])=>e.jsx("div",{className:"nice-lowcode-studio__prop",children:F(V.id,t,n)},t))]}):e.jsx("p",{children:$("noCode.lowCodeStudio.selectHint","Select a component to edit its properties")})]}),children:e.jsxs("main",{className:"nice-lowcode-studio__canvas","data-project":o,children:[i==="design"&&e.jsx("div",{className:["nice-lowcode-studio__design-canvas",q&&"nice-lowcode-studio__design-canvas--over",d.components.length>0&&"nice-lowcode-studio__design-canvas--filled"].filter(Boolean).join(" "),onDragOver:Y,onDragLeave:B,onDrop:Z,children:d.components.length===0?e.jsx("p",{children:$("noCode.componentDesigner.dragDrop","Drag components here")}):e.jsx("ul",{className:"nice-lowcode-studio__instances",children:d.components.map(t=>e.jsxs("li",{className:`nice-lowcode-studio__instance${t.id===w?" nice-lowcode-studio__instance--selected":""}`,children:[e.jsxs("button",{type:"button",className:"nice-lowcode-studio__instance-select","aria-pressed":t.id===w,onClick:()=>R(t.id),children:[H(t.type),I(t.type)]}),e.jsx("button",{type:"button","aria-label":`${$("remove","Remove")} ${I(t.type)}`,onClick:()=>D(t.id),children:e.jsx(a.NiceIcon,{name:"close",size:12})})]},t.id))})}),i==="preview"&&e.jsx("div",{className:`nice-lowcode-studio__preview${j?" nice-lowcode-studio__preview--live":""}`,children:j?d.components.map(t=>e.jsx(g.Fragment,{children:j(t)},t.id)):e.jsx("p",{children:$("noCode.lowCodeStudio.previewUnavailable","No preview: the app has not connected its components (renderComponent).")})}),i==="code"&&e.jsx("div",{className:"nice-lowcode-studio__code",children:e.jsx(He,{code:d.components.length>0?ut(d,t=>pt(I(t))):$("noCode.lowCodeStudio.codeEmpty","// Add components to generate code"),language:"tsx",theme:f})})]})})},gt=[{target:".nice-component-designer",titleKey:"tutorial.componentDesigner.intro.title",title:"Component designer",contentKey:"tutorial.componentDesigner.intro.content",content:"Name your component, declare its props with types and requirements, and preview the generated TypeScript interface live.",placement:"auto"}],xt=({component:o,propTypes:S=[],onChange:f,theme:b="light",className:N,tutorial:j})=>{const{t:k}=a.useNiceTranslation(),[p,$]=g.useState(o||{name:"NewComponent",props:[]}),i=r=>{const d={...p,...r};$(d),f?.(d)};return e.jsxs("div",{className:`nice-component-designer nice-component-designer--${b} ${N||""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(j,gt)})}),e.jsxs("section",{className:"nice-component-designer__header",children:[e.jsx("input",{type:"text",value:p.name,onChange:r=>i({name:r.target.value}),placeholder:k("componentDesigner.componentName","Component Name")}),e.jsx("input",{type:"text",value:p.description||"",onChange:r=>i({description:r.target.value}),placeholder:k("componentDesigner.description","Description")})]}),e.jsxs("section",{className:"nice-component-designer__props",children:[e.jsx("h3",{children:k("componentDesigner.props","Props")}),p.props.map((r,d)=>e.jsxs("div",{className:"nice-component-designer__prop",children:[e.jsx("input",{type:"text",value:r.name,readOnly:!0}),e.jsx("span",{children:r.type}),r.required&&e.jsx("span",{children:k("componentDesigner.required","required")})]},d)),e.jsx("button",{onClick:()=>i({props:[...p.props,{name:"newProp",type:"string"}]}),children:k("componentDesigner.addProp","Add Prop")})]}),e.jsxs("section",{className:"nice-component-designer__preview",children:[e.jsx("h3",{children:k("componentDesigner.preview","Preview")}),e.jsx("pre",{children:`interface ${p.name}Props {
4
+ ${p.props.map(r=>` ${r.name}${r.required?"":"?"}: ${r.type};`).join(`
5
+ `)}
6
+ }
7
+
8
+ export const ${p.name}: React.FC<${p.name}Props> = (props) => {
9
+ return <div>Component</div>;
10
+ };`})]})]})},ht=[{target:".nice-page-builder",titleKey:"tutorial.pageBuilder.intro.title",title:"Page builder",contentKey:"tutorial.pageBuilder.intro.content",content:"Drag components from the sidebar onto the responsive grid, switch the desktop/tablet/mobile preview, and save the layout.",placement:"auto"}],ft=({initialLayout:o,components:S=[],grid:f={columns:12,gap:16,padding:24},onChange:b,onSave:N,theme:j="light",previewMode:k="desktop",className:p,tutorial:$})=>{const{t:i}=a.useNiceTranslation(),[r,d]=g.useState(o||{id:"page-1",name:"New Page",rows:[]}),[C,w]=g.useState(null),R=O=>{d(O),b?.(O)},q=()=>{const O={id:`row-${Date.now()}`,columns:[{id:`col-${Date.now()}`,width:12,components:[]}]};R({...r,rows:[...r.rows,O]})},G={desktop:"100%",tablet:"768px",mobile:"375px"}[k];return e.jsx(de.NiceAppShell,{flush:!0,className:`nice-page-builder nice-page-builder--${j} ${p||""}`,toolbar:e.jsxs("header",{className:"nice-page-builder__toolbar",children:[e.jsx("input",{type:"text",value:r.name,onChange:O=>R({...r,name:O.target.value})}),e.jsxs("div",{className:"nice-page-builder__preview-modes",children:[e.jsx("button",{className:`nice-page-builder__preview-mode ${k==="desktop"?"nice-page-builder__preview-mode--active":""}`,children:i("pageBuilder.desktop","Desktop")}),e.jsx("button",{className:`nice-page-builder__preview-mode ${k==="tablet"?"nice-page-builder__preview-mode--active":""}`,children:i("pageBuilder.tablet","Tablet")}),e.jsx("button",{className:`nice-page-builder__preview-mode ${k==="mobile"?"nice-page-builder__preview-mode--active":""}`,children:i("pageBuilder.mobile","Mobile")})]}),e.jsx("button",{onClick:()=>N?.(r),children:i("pageBuilder.save","Save")}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial($,ht)})]}),sidebar:e.jsxs("aside",{className:"nice-page-builder__sidebar",children:[e.jsx("h3",{children:i("pageBuilder.components","Components")}),e.jsx("ul",{className:"nice-page-builder__components",children:S.map(O=>e.jsxs("li",{draggable:!0,className:"nice-page-builder__component-item",children:[O.icon&&e.jsx(a.NiceIcon,{name:O.icon,size:14}),O.name]},O.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-page-builder__properties",children:[e.jsx("h3",{children:i("pageBuilder.properties","Properties")}),C?e.jsx("p",{children:i("pageBuilder.editPropertiesForSelectedComponent","Edit properties for selected component")}):e.jsx("p",{children:i("pageBuilder.selectAComponentToEdit","Select a component to edit")})]}),children:e.jsx("main",{className:"nice-page-builder__canvas",children:e.jsxs("div",{className:"nice-page-builder__viewport",style:{maxWidth:G},children:[r.rows.map(O=>e.jsx("div",{className:"nice-page-builder__row",children:O.columns.map(T=>e.jsx("div",{className:"nice-page-builder__column",style:{width:`${T.width/12*100}%`},children:T.components.length===0?e.jsx("div",{className:"nice-page-builder__dropzone",children:i("pageBuilder.dropComponentsHere","Drop components here")}):T.components.map(I=>e.jsx("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,className:`nice-page-builder__placed-component ${C===I.id?"nice-page-builder__placed-component--selected":""}`,onClick:()=>w(I.id),children:I.type},I.id))},T.id))},O.id)),e.jsx("button",{onClick:q,className:"nice-page-builder__add-row",children:i("pageBuilder.addRow","+ Add Row")})]})})})},yt=[{target:".nice-state-designer",titleKey:"tutorial.stateDesigner.intro.title",title:"State designer",contentKey:"tutorial.stateDesigner.intro.content",content:"Model your store as slices with fields and actions, pick a target (e.g. Zustand) and export ready-to-use state-management code.",placement:"auto"}],bt={id:"store-1",name:"AppStore",description:"Main application state store",slices:[{id:"slice-auth",name:"auth",description:"Authentication state",state:[{id:"f1",name:"user",type:"object",nullable:!0,description:"Current user"},{id:"f2",name:"isAuthenticated",type:"boolean",defaultValue:!1},{id:"f3",name:"token",type:"string",nullable:!0},{id:"f4",name:"loading",type:"boolean",defaultValue:!1},{id:"f5",name:"error",type:"string",nullable:!0}],actions:[{id:"a1",name:"login",description:"Authenticate user",async:!0,params:[{id:"p1",name:"email",type:"string",required:!0},{id:"p2",name:"password",type:"string",required:!0}],reducerSteps:[{id:"s1",type:"set",field:"loading",value:"true"},{id:"s2",type:"set",field:"error",value:"null"},{id:"s3",type:"set",field:"user",value:"response.user"},{id:"s4",type:"set",field:"token",value:"response.token"},{id:"s5",type:"set",field:"isAuthenticated",value:"true"},{id:"s6",type:"set",field:"loading",value:"false"}]},{id:"a2",name:"logout",description:"Clear user session",params:[],reducerSteps:[{id:"s1",type:"reset",field:"user"},{id:"s2",type:"set",field:"isAuthenticated",value:"false"},{id:"s3",type:"reset",field:"token"}]}],selectors:[{id:"sel1",name:"selectUser",expression:"state.auth.user",dependencies:["user"],memoized:!0},{id:"sel2",name:"selectIsLoggedIn",expression:"state.auth.isAuthenticated",dependencies:["isAuthenticated"]}]},{id:"slice-cart",name:"cart",description:"Shopping cart state",state:[{id:"f1",name:"items",type:"array",defaultValue:[],description:"Cart items"},{id:"f2",name:"total",type:"number",defaultValue:0},{id:"f3",name:"currency",type:"string",defaultValue:"USD"}],actions:[{id:"a1",name:"addItem",params:[{id:"p1",name:"item",type:"object",required:!0}],reducerSteps:[{id:"s1",type:"push",field:"items",value:"item"},{id:"s2",type:"update",field:"total",value:"state.total + item.price"}]},{id:"a2",name:"removeItem",params:[{id:"p1",name:"itemId",type:"string",required:!0}],reducerSteps:[{id:"s1",type:"remove",field:"items",value:"item.id !== itemId"}]},{id:"a3",name:"clearCart",params:[],reducerSteps:[{id:"s1",type:"set",field:"items",value:"[]"},{id:"s2",type:"set",field:"total",value:"0"}]}],selectors:[{id:"sel1",name:"selectCartItems",expression:"state.cart.items",dependencies:["items"]},{id:"sel2",name:"selectCartCount",expression:"state.cart.items.length",dependencies:["items"],memoized:!0},{id:"sel3",name:"selectCartTotal",expression:"state.cart.total",dependencies:["total"]}],computed:[{id:"c1",name:"itemCount",expression:"items.length",dependencies:["items"]}]}],middleware:[{type:"immer",enabled:!0},{type:"devtools",enabled:!0},{type:"persist",enabled:!0}],persist:{enabled:!0,key:"app-store",storage:"localStorage",whitelist:["auth.token","cart.items"],version:1},devtools:{enabled:!0,name:"AppStore",trace:!0}},vt=[{id:"tpl-auth",name:"Authentication",description:"User authentication with token",icon:"lock",store:{slices:[{id:"auth",name:"auth",state:[{id:"user",name:"user",type:"object",nullable:!0},{id:"token",name:"token",type:"string",nullable:!0},{id:"isAuthenticated",name:"isAuthenticated",type:"boolean",defaultValue:!1}],actions:[],selectors:[]}]}},{id:"tpl-crud",name:"CRUD Entity",description:"Standard entity with loading states",icon:"box",store:{slices:[{id:"entity",name:"entity",state:[{id:"items",name:"items",type:"array",defaultValue:[]},{id:"selected",name:"selected",type:"object",nullable:!0},{id:"loading",name:"loading",type:"boolean",defaultValue:!1},{id:"error",name:"error",type:"string",nullable:!0}],actions:[],selectors:[]}]}},{id:"tpl-ui",name:"UI State",description:"Theme, sidebar, modal states",icon:"palette",store:{slices:[{id:"ui",name:"ui",state:[{id:"theme",name:"theme",type:"enum",defaultValue:"light"},{id:"sidebarOpen",name:"sidebarOpen",type:"boolean",defaultValue:!0},{id:"activeModal",name:"activeModal",type:"string",nullable:!0}],actions:[],selectors:[]}]}}],Me={string:"edit",number:"hash",boolean:"check",array:"clipboard",object:"box",date:"calendar",enum:"bar-chart",custom:"settings"},De=o=>{const S=["import { create } from 'zustand'"];o.middleware?.some(i=>i.type==="devtools"&&i.enabled)&&S.push("import { devtools } from 'zustand/middleware'"),o.middleware?.some(i=>i.type==="persist"&&i.enabled)&&S.push("import { persist } from 'zustand/middleware'"),o.middleware?.some(i=>i.type==="immer"&&i.enabled)&&S.push("import { immer } from 'zustand/middleware/immer'");const f=[];o.slices.forEach(i=>{f.push(`interface ${Fe(i.name)}State {`),i.state.forEach(r=>{const d=Ee(r.type,r.nullable);f.push(` ${r.name}: ${d};`)}),f.push("}"),f.push("")}),f.push("interface Actions {"),o.slices.forEach(i=>{i.actions.forEach(r=>{const d=r.params.map(w=>`${w.name}: ${Ee(w.type)}`).join(", "),C=r.async?"Promise<void>":"void";f.push(` ${r.name}: (${d}) => ${C};`)})}),f.push("}");const b=o.slices.map(i=>`${Fe(i.name)}State`).join(" & ");f.push(""),f.push(`type StoreState = ${b} & Actions;`);const N=[];o.slices.forEach(i=>{i.state.forEach(r=>{const d=r.defaultValue!==void 0?JSON.stringify(r.defaultValue):r.nullable?"null":Ue(r.type);N.push(` ${r.name}: ${d},`)})});const j=[];o.slices.forEach(i=>{i.actions.forEach(r=>{const d=r.params.map(w=>w.name).join(", "),C=r.async?"async ":"";j.push(` ${r.name}: ${C}(${d}) => {`),r.async?(j.push(" set({ loading: true, error: null });"),j.push(" try {"),j.push(" // TODO: API call"),j.push(` // const response = await api.${r.name}(${d});`),r.reducerSteps.forEach(w=>{w.type==="set"&&j.push(` set({ ${w.field}: ${w.value} });`)}),j.push(" } catch (error) {"),j.push(" set({ error: error.message, loading: false });"),j.push(" }")):(j.push(" set((state) => {"),r.reducerSteps.forEach(w=>{w.type==="set"?j.push(` state.${w.field} = ${w.value};`):w.type==="push"?j.push(` state.${w.field}.push(${w.value});`):w.type==="reset"&&j.push(` state.${w.field} = null;`)}),j.push(" });")),j.push(" },")})});let k="",p="";if(o.middleware?.some(i=>i.type==="immer"&&i.enabled)&&(k+="immer(",p=")"+p),o.middleware?.some(i=>i.type==="devtools"&&i.enabled)&&(k+="devtools(",p=`, { name: '${o.devtools?.name||o.name}' })`+p),o.persist?.enabled){k+="persist(";const i=[`name: '${o.persist.key}'`];o.persist.whitelist&&i.push(`partialize: (state) => ({ ${o.persist.whitelist.map(r=>r.split(".").pop()).join(", ")} })`),p=`, { ${i.join(", ")} })`+p}return`${S.join(`
11
+ `)}
12
+
13
+ // Types
14
+ ${f.join(`
15
+ `)}
16
+
17
+ // Store
18
+ export const use${o.name} = create<StoreState>()(
19
+ ${k}(set, get) => ({
20
+ // Initial State
21
+ ${N.join(`
22
+ `)}
23
+
24
+ // Actions
25
+ ${j.join(`
26
+ `)}
27
+ })${p}
28
+ );
29
+
30
+ // Selectors
31
+ ${o.slices.flatMap(i=>i.selectors.map(r=>`export const ${r.name} = (state: StoreState) => ${r.expression.replace("state.","state.")};`)).join(`
32
+ `)}
33
+ `},Fe=o=>o.charAt(0).toUpperCase()+o.slice(1),Ee=(o,S)=>{const f={string:"string",number:"number",boolean:"boolean",array:"unknown[]",object:"Record<string, unknown>",date:"Date",enum:"string",custom:"unknown"}[o];return S?`${f} | null`:f},Ue=o=>({string:"''",number:"0",boolean:"false",array:"[]",object:"{}",date:"new Date()",enum:"''",custom:"null"})[o],We=({store:o=bt,templates:S=vt,onStoreChange:f,onExport:b,onSave:N,tutorial:j,className:k,style:p,"data-testid":$})=>{const{t:i}=a.useNiceTranslation(),[r,d]=g.useState(o),[C,w]=g.useState("slices"),[R,q]=g.useState(r.slices[0]?.id||null),[G,O]=g.useState(null),[T,I]=g.useState("zustand"),[H,M]=g.useState(!1),[m,D]=g.useState(null),[A,Y]=g.useState(""),[B,Z]=g.useState("string"),F=g.useMemo(()=>r.slices.find(u=>u.id===R),[r.slices,R]),V=g.useCallback(u=>{const X={...r,...u};d(X),f?.(X)},[r,f]),s=()=>{const u={id:`slice-${Date.now()}`,name:"newSlice",state:[],actions:[],selectors:[]};V({slices:[...r.slices,u]}),q(u.id)},t=()=>{if(!F||!A)return;const u={id:`field-${Date.now()}`,name:A,type:B,defaultValue:Ue(B).replace(/'/g,"")},X=r.slices.map(c=>c.id===F.id?{...c,state:[...c.state,u]}:c);V({slices:X}),Y("")},n=()=>{if(!F)return;const u={id:`action-${Date.now()}`,name:"newAction",params:[],reducerSteps:[]},X=r.slices.map(c=>c.id===F.id?{...c,actions:[...c.actions,u]}:c);V({slices:X}),O(u.id)},y=g.useCallback(()=>{let u="";T==="zustand"?u=De(r):u=`// Export for ${T} coming soon...
34
+ // Store: ${r.name}`,b?.(u,T)},[r,T,b]),h=g.useMemo(()=>T==="zustand"?De(r):`// ${T} export coming soon...`,[r,T]),x={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",accent:"var(--nice-color-primary, #3b82f6)"},z=e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${x.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"folder",size:16})," ",i("stateDesigner.stateDesigner","State Designer")]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsx("input",{type:"text",value:r.name,onChange:u=>V({name:u.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.cardBg,color:x.text,fontSize:14,fontWeight:600}})}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(j,yt)}),e.jsxs("button",{onClick:()=>M(!0),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${x.border}`,background:"transparent",color:x.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",i("stateDesigner.templates","Templates")]}),e.jsxs("button",{onClick:()=>N?.(r),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"save",size:14})," ",i("stateDesigner.save","Save")]})]})]}),l=e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${x.border}`,padding:"0 20px"},children:["slices","actions","selectors","settings","preview"].map(u=>e.jsxs("button",{onClick:()=>w(u),style:{padding:"12px 20px",border:"none",background:"transparent",color:C===u?x.text:x.textMuted,cursor:"pointer",fontSize:13,fontWeight:C===u?600:400,borderBottom:C===u?`2px solid ${x.accent}`:"2px solid transparent",marginBottom:-1},children:[u==="slices"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"box",size:14})," ",i("stateDesigner.slices","Slices")]}),u==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," ",i("stateDesigner.actions","Actions")]}),u==="selectors"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"target",size:14})," ",i("stateDesigner.selectors","Selectors")]}),u==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," ",i("stateDesigner.settings","Settings")]}),u==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," ",i("stateDesigner.preview","Preview")]})]},u))}),te=C==="slices"||C==="actions"||C==="selectors"?e.jsxs("div",{style:{width:200,borderRight:`1px solid ${x.border}`,padding:12,display:"flex",flexDirection:"column",gap:8,height:"100%",boxSizing:"border-box"},children:[e.jsx("div",{style:{fontSize:11,color:x.textMuted,marginBottom:4},children:i("stateDesigner.slices2","SLICES")}),r.slices.map(u=>e.jsxs("button",{onClick:()=>q(u.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:R===u.id?x.accent+"30":x.cardBg,color:x.text,cursor:"pointer",textAlign:"left",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"box",size:14})," ",u.name,e.jsx("div",{style:{fontSize:10,color:x.textMuted},children:i("stateDesigner.fieldsActions","{state} fields • {actions} actions").replace("{state}",String(u.state.length)).replace("{actions}",String(u.actions.length))})]},u.id)),e.jsx("button",{onClick:s,style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${x.border}`,background:"transparent",color:x.textMuted,cursor:"pointer",fontSize:13},children:i("stateDesigner.addSlice","+ Add Slice")})]}):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(de.NiceAppShell,{flush:!0,className:`nice-state-designer ${k||""}`,style:{background:x.bg,color:x.text,fontFamily:"system-ui, sans-serif",...p},"data-testid":$,menubar:z,toolbar:l,sidebar:te,children:e.jsxs("div",{style:{height:"100%",overflow:"auto",padding:20,boxSizing:"border-box"},children:[C==="slices"&&F&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"box",size:16})," ",F.name]}),e.jsx("input",{type:"text",value:F.name,onChange:u=>{const X=r.slices.map(c=>c.id===F.id?{...c,name:u.target.value}:c);V({slices:X})},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.cardBg,color:x.text,fontSize:13}})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("div",{style:{fontSize:12,color:x.textMuted,marginBottom:12},children:i("stateDesigner.stateFields","STATE FIELDS ({state})").replace("{state}",String(F.state.length))}),e.jsxs("div",{style:{border:`1px solid ${x.border}`,borderRadius:8,overflow:"hidden"},children:[F.state.map(u=>e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${x.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx(a.NiceIcon,{name:Me[u.type],size:14}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontFamily:"monospace"},children:u.name}),e.jsxs("div",{style:{fontSize:11,color:x.textMuted},children:[u.type,u.nullable&&"?",u.defaultValue!==void 0&&` = ${JSON.stringify(u.defaultValue)}`]})]}),e.jsx("button",{onClick:()=>{const X=r.slices.map(c=>c.id===F.id?{...c,state:c.state.filter(W=>W.id!==u.id)}:c);V({slices:X})},"aria-label":i("stateDesigner.delete","Delete"),style:{padding:4,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]},u.id)),e.jsxs("div",{style:{padding:"12px 16px",display:"flex",alignItems:"center",gap:8,background:x.cardBg},children:[e.jsx("input",{type:"text",placeholder:"fieldName",value:A,onChange:u=>Y(u.target.value),style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.bg,color:x.text,fontSize:13,fontFamily:"monospace"}}),e.jsx("select",{value:B,onChange:u=>Z(u.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.bg,color:x.text,fontSize:13},children:Object.keys(Me).map(u=>e.jsx("option",{value:u,children:u},u))}),e.jsx("button",{onClick:t,disabled:!A,style:{padding:"8px 16px",borderRadius:4,border:"none",background:A?x.accent:x.border,color:"var(--nice-color-white, #fff)",cursor:A?"pointer":"not-allowed",fontSize:13},children:i("stateDesigner.add","+ Add")})]})]})]})]}),C==="actions"&&F&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:16})," ",i("stateDesigner.actionsFor","Actions for {name}").replace("{name}",String(F.name))]}),e.jsx("button",{onClick:n,style:{padding:"6px 12px",borderRadius:4,border:"none",background:x.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:i("stateDesigner.addAction","+ Add Action")})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:F.actions.map(u=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,style:{padding:16,background:x.cardBg,borderRadius:8,border:`1px solid ${G===u.id?x.accent:x.border}`,cursor:"pointer"},onClick:()=>O(u.id),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:u.name}),u.async&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:"async"}),e.jsxs("span",{style:{fontSize:11,color:x.textMuted},children:["(",u.params.map(X=>`${X.name}: ${X.type}`).join(", "),")"]})]}),u.description&&e.jsx("div",{style:{fontSize:12,color:x.textMuted,marginTop:4},children:u.description}),e.jsx("div",{style:{fontSize:11,color:x.textMuted,marginTop:8},children:i("stateDesigner.reducerSteps","{reducerSteps} reducer steps").replace("{reducerSteps}",String(u.reducerSteps.length))})]},u.id))})]}),C==="selectors"&&F&&e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20},children:e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"target",size:16})," ",i("stateDesigner.selectorsFor","Selectors for {name}").replace("{name}",String(F.name))]})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:F.selectors.map(u=>e.jsxs("div",{style:{padding:16,background:x.cardBg,borderRadius:8,border:`1px solid ${x.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:u.name}),u.memoized&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-success-tint-12, #22c55e20)",color:"var(--nice-color-success, #22c55e)",borderRadius:4,fontSize:10},children:i("stateDesigner.memoized","memoized")})]}),e.jsx("code",{style:{display:"block",marginTop:8,padding:8,background:x.bg,borderRadius:4,fontSize:12,color:"var(--nice-color-warning, #f59e0b)"},children:u.expression})]},u.id))})]}),C==="settings"&&e.jsxs("div",{style:{maxWidth:600},children:[e.jsx("h4",{style:{marginTop:0},children:i("stateDesigner.middleware","Middleware")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:r.middleware?.map(u=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:12,background:x.cardBg,borderRadius:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:u.enabled,onChange:X=>{const c=r.middleware?.map(W=>W.type===u.type?{...W,enabled:X.target.checked}:W);V({middleware:c})}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,textTransform:"capitalize"},children:u.type}),e.jsxs("div",{style:{fontSize:11,color:x.textMuted},children:[u.type==="immer"&&i("stateDesigner.enableImmutableStateUpdates","Enable immutable state updates"),u.type==="devtools"&&i("stateDesigner.reduxDevtoolsIntegration","Redux DevTools integration"),u.type==="persist"&&i("stateDesigner.persistStateToStorage","Persist state to storage")]})]})]},u.type))}),r.persist?.enabled&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:i("stateDesigner.persistence","Persistence")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:x.textMuted,marginBottom:4},children:i("stateDesigner.storageKey","Storage Key")}),e.jsx("input",{type:"text",value:r.persist.key,onChange:u=>V({persist:{...r.persist,key:u.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.cardBg,color:x.text,fontSize:13,width:"100%",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:x.textMuted,marginBottom:4},children:i("stateDesigner.storageType","Storage Type")}),e.jsxs("select",{value:r.persist.storage,onChange:u=>V({persist:{...r.persist,storage:u.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.cardBg,color:x.text,fontSize:13},children:[e.jsx("option",{value:"localStorage",children:"localStorage"}),e.jsx("option",{value:"sessionStorage",children:"sessionStorage"}),e.jsx("option",{value:"indexedDB",children:"indexedDB"})]})]})]})]})]}),C==="preview"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:[e.jsxs("select",{value:T,onChange:u=>I(u.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${x.border}`,background:x.cardBg,color:x.text,fontSize:13},children:[e.jsx("option",{value:"zustand",children:i("stateDesigner.zustand","Zustand")}),e.jsx("option",{value:"redux-toolkit",children:i("stateDesigner.reduxToolkit","Redux Toolkit")}),e.jsx("option",{value:"jotai",children:i("stateDesigner.jotai","Jotai")}),e.jsx("option",{value:"recoil",children:i("stateDesigner.recoil","Recoil")}),e.jsx("option",{value:"mobx",children:i("stateDesigner.mobx","MobX")})]}),e.jsxs("button",{onClick:y,style:{padding:"8px 16px",borderRadius:4,border:"none",background:x.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",i("stateDesigner.export","Export")]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(h),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${x.border}`,background:"transparent",color:x.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",i("stateDesigner.copy","Copy")]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:x.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:h})]})]})}),H&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>M(!1),children:e.jsxs("div",{role:"presentation",style:{background:x.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},onClick:u=>u.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:16})," ",i("stateDesigner.stateTemplates","State Templates")]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:S.map(u=>e.jsx("button",{onClick:()=>{u.store.slices&&V({slices:[...r.slices,...u.store.slices]}),M(!1)},style:{padding:16,borderRadius:8,border:`1px solid ${x.border}`,background:x.bg,color:x.text,cursor:"pointer",textAlign:"left"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:u.icon,size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600},children:u.name}),e.jsx("div",{style:{fontSize:12,color:x.textMuted},children:u.description})]})]})},u.id))})]})})]})},jt=Object.freeze(Object.defineProperty({__proto__:null,NiceStateDesigner:We},Symbol.toStringTag,{value:"Module"})),St={id:"api-1",name:"UserAPI",description:"User management API client",baseUrl:"https://api.example.com/v1",version:"1.0.0",endpoints:[{id:"ep-1",name:"getUsers",description:"Get list of users",method:"GET",path:"/users",tags:["users"],queryParams:[{id:"p1",name:"page",type:"number",defaultValue:1},{id:"p2",name:"limit",type:"number",defaultValue:10},{id:"p3",name:"search",type:"string"}],responses:[{status:200,description:"Success",schema:{type:"array",items:{type:"object"}}},{status:401,description:"Unauthorized"}],cache:{enabled:!0,ttl:60,strategy:"stale-while-revalidate"}},{id:"ep-2",name:"getUserById",description:"Get single user by ID",method:"GET",path:"/users/{id}",tags:["users"],pathParams:[{id:"p1",name:"id",type:"string",required:!0}],responses:[{status:200,description:"Success"},{status:404,description:"Not found"}],cache:{enabled:!0,ttl:300,strategy:"cache-first"}},{id:"ep-3",name:"createUser",description:"Create new user",method:"POST",path:"/users",tags:["users"],body:{contentType:"application/json",schema:{type:"object",properties:{name:{type:"string"},email:{type:"string"},role:{type:"string"}},required:["name","email"]}},responses:[{status:201,description:"Created"},{status:400,description:"Validation error"}],retry:{enabled:!0,maxAttempts:3,backoff:"exponential",retryOn:[500,502,503]}},{id:"ep-4",name:"updateUser",description:"Update user by ID",method:"PUT",path:"/users/{id}",tags:["users"],pathParams:[{id:"p1",name:"id",type:"string",required:!0}],body:{contentType:"application/json",schema:{type:"object",properties:{name:{type:"string"},email:{type:"string"}}}},responses:[{status:200,description:"Updated"},{status:404,description:"Not found"}]},{id:"ep-5",name:"deleteUser",description:"Delete user by ID",method:"DELETE",path:"/users/{id}",tags:["users"],pathParams:[{id:"p1",name:"id",type:"string",required:!0}],responses:[{status:204,description:"Deleted"},{status:404,description:"Not found"}]}],auth:{type:"bearer",tokenSource:"state.auth.token",headerName:"Authorization",prefix:"Bearer"},globalHeaders:{"Content-Type":"application/json",Accept:"application/json"},errorHandling:{globalErrorHandler:!0,retryOnNetworkError:!0,transformError:!0},cacheConfig:{enabled:!0,storage:"memory",defaultTTL:300}},ie={GET:"var(--nice-color-success, #22c55e)",POST:"var(--nice-color-primary, #3b82f6)",PUT:"var(--nice-color-warning, #f59e0b)",PATCH:"var(--nice-color-accent, #8b5cf6)",DELETE:"var(--nice-color-error, #ef4444)",HEAD:"var(--nice-text-muted, #6b7280)",OPTIONS:"var(--nice-text-muted, #6b7280)"},wt=o=>{const S=["import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';"],f=[];o.endpoints.forEach(p=>{p.body?.schema&&f.push(`export interface ${me(p.name)}Request ${Ke(p.body.schema)}`),f.push(`export interface ${me(p.name)}Response {
35
+ // TODO: Define response type based on schema
36
+ data: unknown;
37
+ }`)});const b=[];o.endpoints.forEach(p=>{const $=p.pathParams?.map(q=>`${q.name}: ${q.type}`).join(", ")||"",i=p.queryParams?.length?`params?: { ${p.queryParams.map(q=>`${q.name}${q.required?"":"?"}: ${q.type}`).join("; ")} }`:"",r=p.body?`data: ${me(p.name)}Request`:"",d=[$,i,r].filter(Boolean).join(", ");let C=`'${p.path}'`;p.pathParams?.forEach(q=>{C=C.replace(`{${q.name}}`,`\${${q.name}}`)}),p.pathParams?.length&&(C="`"+C.slice(1,-1)+"`");const w=p.cache?.enabled?`
38
+ // Cache: ${p.cache.strategy}, TTL: ${p.cache.ttl}s`:"",R=p.retry?.enabled?`
39
+ // Retry: ${p.retry.maxAttempts} attempts, ${p.retry.backoff} backoff`:"";b.push(`
40
+ /**
41
+ * ${p.description||p.name}${w}${R}
42
+ */
43
+ async ${p.name}(${d}): Promise<${me(p.name)}Response> {
44
+ const response = await this.client.${p.method.toLowerCase()}<${me(p.name)}Response>(
45
+ ${C}${p.queryParams?.length?", { params }":""}${p.body?", data":""}
46
+ );
47
+ return response.data;
48
+ }`)});let N="";o.auth?.type==="bearer"&&(N=`
49
+ // Auth interceptor
50
+ this.client.interceptors.request.use((config) => {
51
+ const token = ${o.auth.tokenSource||"getToken()"};
52
+ if (token) {
53
+ config.headers['${o.auth.headerName||"Authorization"}'] = '${o.auth.prefix||"Bearer"} ' + token;
54
+ }
55
+ return config;
56
+ });`);const j=o.errorHandling?.globalErrorHandler?`
57
+ // Error interceptor
58
+ this.client.interceptors.response.use(
59
+ (response) => response,
60
+ (error) => {
61
+ // Transform and handle errors
62
+ const message = error.response?.data?.message || error.message;
63
+ console.error('[API Error]', message);
64
+ return Promise.reject(error);
65
+ }
66
+ );`:"";return`${S.join(`
67
+ `)}
68
+
69
+ // Types
70
+ ${f.join(`
71
+
72
+ `)}
73
+
74
+ // API Client
75
+ export class ${o.name} {
76
+ private client: AxiosInstance;
77
+
78
+ constructor(baseURL: string = '${o.baseUrl}') {
79
+ this.client = axios.create({
80
+ baseURL,
81
+ headers: ${JSON.stringify(o.globalHeaders||{},null,8).replace(/\n/g,`
82
+ `)},
83
+ });
84
+ ${N}${j}
85
+ }
86
+ ${b.join("")}
87
+ }
88
+
89
+ // Default instance
90
+ export const ${o.name.charAt(0).toLowerCase()+o.name.slice(1)} = new ${o.name}();
91
+ `},me=o=>o.charAt(0).toUpperCase()+o.slice(1),Ke=o=>o.type==="object"&&o.properties?`{
92
+ ${Object.entries(o.properties).map(([f,b])=>{const N=o.required?.includes(f)?"":"?";return` ${f}${N}: ${Je(b)};`}).join(`
93
+ `)}
94
+ }`:"{}",Je=o=>{switch(o.type){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return o.items?`${Je(o.items)}[]`:"unknown[]";case"object":return o.properties?Ke(o):"Record<string, unknown>";default:return"unknown"}},Ge=({flow:o=St,dataSources:S=[],onFlowChange:f,onExport:b,onTest:N,onSave:j,className:k,style:p,"data-testid":$})=>{const{t:i}=a.useNiceTranslation(),[r,d]=g.useState(o),[C,w]=g.useState("endpoints"),[R,q]=g.useState(r.endpoints[0]?.id||null),[G,O]=g.useState(!1),[T,I]=g.useState(null),[H,M]=g.useState(!1),m=g.useMemo(()=>r.endpoints.find(t=>t.id===R),[r.endpoints,R]),D=g.useCallback(t=>{const n={...r,...t};d(n),f?.(n)},[r,f]),A=g.useCallback((t,n)=>{const y=r.endpoints.map(h=>h.id===t?{...h,...n}:h);D({endpoints:y})},[r.endpoints,D]),Y=t=>{const n={id:`ep-${Date.now()}`,name:"newEndpoint",method:t,path:"/new-path",responses:[{status:200,description:i("apiFlow.success","Success")}]};D({endpoints:[...r.endpoints,n]}),q(n.id),O(!1)},B=t=>{D({endpoints:r.endpoints.filter(n=>n.id!==t)}),R===t&&q(r.endpoints[0]?.id||null)},Z=async()=>{m&&(M(!0),I(null),await new Promise(t=>setTimeout(t,1e3)),I({status:200,body:{message:i("apiFlow.mockResponse","Mock response"),timestamp:new Date().toISOString()}}),M(!1),N?.(m.id))},F=g.useMemo(()=>wt(r),[r]),V=()=>{b?.(F)};g.useMemo(()=>{const t=new Set;return r.endpoints.forEach(n=>n.tags?.forEach(y=>t.add(y))),Array.from(t)},[r.endpoints]);const s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",accent:"var(--nice-color-primary, #3b82f6)"};return e.jsxs("div",{className:`nice-api-flow ${k||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...p},"data-testid":$,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(a.NiceIcon,{name:"plug",size:16})," ",i("apiFlow.apiFlow","API Flow")]}),e.jsx("input",{type:"text",value:r.name,onChange:t=>D({name:t.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14,fontWeight:600}}),e.jsx("input",{type:"text",value:r.baseUrl,onChange:t=>D({baseUrl:t.target.value}),placeholder:i("apiFlow.baseUrl","Base URL"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,width:300}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>j?.(r),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"save",size:14})," ",i("apiFlow.save","Save")]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${s.border}`,padding:"0 20px"},children:["endpoints","auth","settings","test","preview"].map(t=>e.jsxs("button",{onClick:()=>w(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:C===t?s.text:s.textMuted,cursor:"pointer",fontSize:13,fontWeight:C===t?600:400,borderBottom:C===t?`2px solid ${s.accent}`:"2px solid transparent",marginBottom:-1},children:[t==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"link",size:14})," ",i("apiFlow.endpoints","Endpoints")]}),t==="auth"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"lock",size:14})," ",i("apiFlow.auth","Auth")]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," ",i("apiFlow.settings","Settings")]}),t==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"flask",size:14})," ",i("apiFlow.test","Test")]}),t==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," ",i("apiFlow.preview","Preview")]})]},t))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[C==="endpoints"&&e.jsxs("div",{style:{width:280,borderRight:`1px solid ${s.border}`,padding:12,display:"flex",flexDirection:"column",gap:4,overflow:"auto"},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:8},children:i("apiFlow.endpoints2","ENDPOINTS ({endpoints})").replace("{endpoints}",String(r.endpoints.length))}),r.endpoints.map(t=>e.jsxs("button",{onClick:()=>q(t.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:R===t.id?s.accent+"30":s.cardBg,color:s.text,cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:ie[t.method]+"30",color:ie[t.method],fontSize:10,fontWeight:600},children:t.method}),e.jsxs("div",{style:{flex:1,overflow:"hidden"},children:[e.jsx("div",{style:{fontFamily:"monospace",fontSize:12},children:t.name}),e.jsx("div",{style:{fontSize:10,color:s.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.path})]})]},t.id)),e.jsx("button",{onClick:()=>O(!0),style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${s.border}`,background:"transparent",color:s.textMuted,cursor:"pointer",fontSize:13,marginTop:8},children:i("apiFlow.addEndpoint2","+ Add Endpoint")})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[C==="endpoints"&&m&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:24},children:[e.jsx("select",{value:m.method,onChange:t=>A(m.id,{method:t.target.value}),style:{padding:"8px 12px",borderRadius:6,border:"none",background:ie[m.method]+"30",color:ie[m.method],fontSize:13,fontWeight:600,cursor:"pointer"},children:["GET","POST","PUT","PATCH","DELETE"].map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("input",{type:"text",value:m.path,onChange:t=>A(m.id,{path:t.target.value}),style:{flex:1,padding:"8px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14,fontFamily:"monospace"}}),e.jsxs("button",{onClick:()=>B(m.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," ",i("apiFlow.delete","Delete")]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:16,marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:4},children:i("apiFlow.name","Name")}),e.jsx("input",{type:"text",value:m.name,onChange:t=>A(m.id,{name:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:4},children:i("apiFlow.description","Description")}),e.jsx("input",{type:"text",value:m.description||"",onChange:t=>A(m.id,{description:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,boxSizing:"border-box"}})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",i("apiFlow.parameters","Parameters")]}),m.pathParams&&m.pathParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:8},children:i("apiFlow.pathParameters","PATH PARAMETERS")}),m.pathParams.map(t=>e.jsxs("div",{style:{padding:12,background:s.cardBg,borderRadius:6,marginBottom:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsx("code",{style:{fontWeight:600},children:t.name}),e.jsx("span",{style:{color:s.textMuted,fontSize:12},children:t.type}),t.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)",fontSize:10},children:i("apiFlow.required","required")})]},t.id))]}),m.queryParams&&m.queryParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:8},children:i("apiFlow.queryParameters","QUERY PARAMETERS")}),m.queryParams.map(t=>e.jsxs("div",{style:{padding:12,background:s.cardBg,borderRadius:6,marginBottom:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsx("code",{style:{fontWeight:600},children:t.name}),e.jsx("span",{style:{color:s.textMuted,fontSize:12},children:t.type}),t.defaultValue!==void 0&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)",fontSize:11},children:["= ",JSON.stringify(t.defaultValue)]})]},t.id))]}),m.body&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:8},children:i("apiFlow.requestBody","REQUEST BODY")}),e.jsxs("div",{style:{padding:12,background:s.cardBg,borderRadius:6},children:[e.jsxs("div",{style:{fontSize:12,marginBottom:8},children:["Content-Type: ",e.jsx("code",{children:m.body.contentType})]}),m.body.schema&&e.jsx("pre",{style:{margin:0,padding:12,background:s.bg,borderRadius:4,fontSize:11,overflow:"auto"},children:JSON.stringify(m.body.schema,null,2)})]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px"},children:[e.jsx(a.NiceIcon,{name:"upload",size:16})," ",i("apiFlow.responses","Responses")]}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:m.responses.map(t=>e.jsxs("div",{style:{padding:12,background:s.cardBg,borderRadius:6,minWidth:120},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,color:t.status<300?"var(--nice-color-success, #22c55e)":t.status<400?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-error, #ef4444)"},children:t.status}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:t.description})]},t.status))})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8},children:[e.jsxs("h5",{style:{margin:"0 0 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:m.cache?.enabled||!1,onChange:t=>A(m.id,{cache:{...m.cache,enabled:t.target.checked}})}),e.jsx(a.NiceIcon,{name:"box",size:14})," ",i("apiFlow.cache","Cache")]}),m.cache?.enabled&&e.jsx("div",{style:{fontSize:12,color:s.textMuted},children:i("apiFlow.ttlSStrategy","TTL: {ttl}s • Strategy: {strategy}").replace("{ttl}",String(m.cache.ttl)).replace("{strategy}",String(m.cache.strategy))})]}),e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8},children:[e.jsxs("h5",{style:{margin:"0 0 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:m.retry?.enabled||!1,onChange:t=>A(m.id,{retry:{...m.retry,enabled:t.target.checked,maxAttempts:3,backoff:"exponential"}})}),e.jsx(a.NiceIcon,{name:"refresh",size:14})," ",i("apiFlow.retry","Retry")]}),m.retry?.enabled&&e.jsx("div",{style:{fontSize:12,color:s.textMuted},children:i("apiFlow.maxBackoff","Max: {maxAttempts} • {backoff} backoff").replace("{maxAttempts}",String(m.retry.maxAttempts)).replace("{backoff}",String(m.retry.backoff))})]})]})]}),C==="auth"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(a.NiceIcon,{name:"lock",size:16})," ",i("apiFlow.authentication","Authentication")]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:8},children:i("apiFlow.authType","Auth Type")}),e.jsxs("select",{value:r.auth?.type||"none",onChange:t=>D({auth:{...r.auth,type:t.target.value}}),style:{padding:"10px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,width:"100%"},children:[e.jsx("option",{value:"none",children:i("apiFlow.none","None")}),e.jsx("option",{value:"bearer",children:i("apiFlow.bearerToken","Bearer Token")}),e.jsx("option",{value:"basic",children:i("apiFlow.basicAuth","Basic Auth")}),e.jsx("option",{value:"api-key",children:i("apiFlow.apiKey","API Key")}),e.jsx("option",{value:"oauth2",children:i("apiFlow.oauth20","OAuth 2.0")})]})]}),r.auth?.type==="bearer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:8},children:i("apiFlow.tokenSource","Token Source")}),e.jsx("input",{type:"text",value:r.auth.tokenSource||"",onChange:t=>D({auth:{...r.auth,tokenSource:t.target.value}}),placeholder:"state.auth.token",style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:8},children:i("apiFlow.headerName","Header Name")}),e.jsx("input",{type:"text",value:r.auth.headerName||"Authorization",onChange:t=>D({auth:{...r.auth,headerName:t.target.value}}),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,boxSizing:"border-box"}})]})]}),e.jsxs("h4",{children:[e.jsx(a.NiceIcon,{name:"globe",size:16})," ",i("apiFlow.globalHeaders","Global Headers")]}),e.jsx("div",{style:{padding:16,background:s.cardBg,borderRadius:8},children:Object.entries(r.globalHeaders||{}).map(([t,n])=>e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8,alignItems:"center"},children:[e.jsx("code",{style:{flex:1},children:t}),e.jsx("span",{style:{color:s.textMuted},children:":"}),e.jsx("code",{style:{flex:2,color:"var(--nice-color-success, #22c55e)"},children:n})]},t))})]}),C==="settings"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(a.NiceIcon,{name:"settings",size:16})," ",i("apiFlow.globalSettings","Global Settings")]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:i("apiFlow.errorHandling","Error Handling")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.errorHandling?.globalErrorHandler||!1,onChange:t=>D({errorHandling:{...r.errorHandling,globalErrorHandler:t.target.checked}})}),i("apiFlow.globalErrorHandler","Global error handler")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.errorHandling?.retryOnNetworkError||!1,onChange:t=>D({errorHandling:{...r.errorHandling,retryOnNetworkError:t.target.checked}})}),i("apiFlow.retryOnNetworkErrors","Retry on network errors")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.errorHandling?.transformError||!1,onChange:t=>D({errorHandling:{...r.errorHandling,transformError:t.target.checked}})}),i("apiFlow.transformErrorResponses","Transform error responses")]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:i("apiFlow.defaultCacheSettings","Default Cache Settings")}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.cacheConfig?.enabled||!1,onChange:t=>D({cacheConfig:{...r.cacheConfig,enabled:t.target.checked}})}),i("apiFlow.enableCaching","Enable caching")]}),r.cacheConfig?.enabled&&e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:s.textMuted},children:i("apiFlow.storage","Storage")}),e.jsxs("select",{value:r.cacheConfig.storage,onChange:t=>D({cacheConfig:{...r.cacheConfig,storage:t.target.value}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13},children:[e.jsx("option",{value:"memory",children:i("apiFlow.memory","Memory")}),e.jsx("option",{value:"localStorage",children:"localStorage"}),e.jsx("option",{value:"sessionStorage",children:"sessionStorage"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:s.textMuted},children:i("apiFlow.defaultTtlSeconds","Default TTL (seconds)")}),e.jsx("input",{type:"number",value:r.cacheConfig.defaultTTL,onChange:t=>D({cacheConfig:{...r.cacheConfig,defaultTTL:parseInt(t.target.value)}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,width:100}})]})]})]})]}),C==="test"&&m&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:24},children:[e.jsx("span",{style:{padding:"4px 8px",borderRadius:4,background:ie[m.method]+"30",color:ie[m.method],fontSize:12,fontWeight:600},children:m.method}),e.jsxs("code",{style:{flex:1,fontSize:14},children:[r.baseUrl,m.path]}),e.jsx("button",{onClick:Z,disabled:H,style:{padding:"10px 20px",borderRadius:6,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:H?"not-allowed":"pointer",fontSize:13,fontWeight:500,opacity:H?.7:1},children:H?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"clock",size:14})," ",i("apiFlow.testing","Testing...")]}):e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"rocket",size:14})," ",i("apiFlow.sendRequest","Send Request")]})})]}),T&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:18,fontWeight:600,color:T.status<300?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"},children:T.status}),e.jsx("span",{style:{color:s.textMuted},children:T.status<300?i("apiFlow.ok","OK"):i("apiFlow.error","Error")})]}),e.jsx("pre",{style:{padding:16,background:s.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0},children:JSON.stringify(T.body,null,2)})]})]}),C==="preview"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("button",{onClick:V,style:{padding:"8px 16px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",i("apiFlow.export","Export")]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(F),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",i("apiFlow.copy","Copy")]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:s.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:F})]})]})]}),G&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>O(!1),children:e.jsxs("div",{role:"presentation",style:{background:s.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(a.NiceIcon,{name:"plus",size:16})," ",i("apiFlow.addEndpoint","Add Endpoint")]}),e.jsx("p",{style:{color:s.textMuted,fontSize:13,marginBottom:16},children:i("apiFlow.selectHttpMethodForNew","Select HTTP method for new endpoint:")}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["GET","POST","PUT","PATCH","DELETE"].map(t=>e.jsx("button",{onClick:()=>Y(t),style:{padding:"12px 24px",borderRadius:6,border:"none",background:ie[t]+"30",color:ie[t],cursor:"pointer",fontSize:14,fontWeight:600},children:t},t))})]})})]})},kt=Object.freeze(Object.defineProperty({__proto__:null,NiceAPIFlow:Ge},Symbol.toStringTag,{value:"Module"})),Nt={id:"map-1",name:"UserToContact",description:"Transform User API response to Contact entity",sourceSchema:{name:"UserResponse",type:"object",fields:[{id:"s1",name:"id",path:"id",type:"number"},{id:"s2",name:"firstName",path:"firstName",type:"string"},{id:"s3",name:"lastName",path:"lastName",type:"string"},{id:"s4",name:"email",path:"email",type:"string"},{id:"s5",name:"phone",path:"phone",type:"string",nullable:!0},{id:"s6",name:"address",path:"address",type:"object",children:[{id:"s6a",name:"street",path:"address.street",type:"string"},{id:"s6b",name:"city",path:"address.city",type:"string"},{id:"s6c",name:"zipCode",path:"address.zipCode",type:"string"},{id:"s6d",name:"country",path:"address.country",type:"string"}]},{id:"s7",name:"metadata",path:"metadata",type:"object",children:[{id:"s7a",name:"createdAt",path:"metadata.createdAt",type:"date"},{id:"s7b",name:"updatedAt",path:"metadata.updatedAt",type:"date"}]}]},targetSchema:{name:"Contact",type:"object",fields:[{id:"t1",name:"contactId",path:"contactId",type:"string"},{id:"t2",name:"fullName",path:"fullName",type:"string"},{id:"t3",name:"emailAddress",path:"emailAddress",type:"string"},{id:"t4",name:"phoneNumber",path:"phoneNumber",type:"string",nullable:!0},{id:"t5",name:"location",path:"location",type:"string"},{id:"t6",name:"fullAddress",path:"fullAddress",type:"string"},{id:"t7",name:"createdDate",path:"createdDate",type:"string"},{id:"t8",name:"isActive",path:"isActive",type:"boolean"}]},fieldMappings:[{id:"m1",sourceField:"id",targetField:"contactId",transform:"tr-1"},{id:"m2",sourceField:"firstName,lastName",targetField:"fullName",transform:"tr-2"},{id:"m3",sourceField:"email",targetField:"emailAddress"},{id:"m4",sourceField:"phone",targetField:"phoneNumber",defaultValue:""},{id:"m5",sourceField:"address.city,address.country",targetField:"location",transform:"tr-3"},{id:"m6",sourceField:"address",targetField:"fullAddress",transform:"tr-4"},{id:"m7",sourceField:"metadata.createdAt",targetField:"createdDate",transform:"tr-5"},{id:"m8",sourceField:"",targetField:"isActive",defaultValue:!0}],transformations:[{id:"tr-1",name:"ID to String",type:"format",config:{format:"USR-{value}"}},{id:"tr-2",name:"Full Name",type:"concat",config:{separator:" "}},{id:"tr-3",name:"Location",type:"concat",config:{separator:", "}},{id:"tr-4",name:"Full Address",type:"custom",config:{expression:"`${address.street}, ${address.zipCode} ${address.city}, ${address.country}`"}},{id:"tr-5",name:"Format Date",type:"format",config:{format:"YYYY-MM-DD"}}],validationRules:[{id:"v1",field:"emailAddress",type:"required",message:"Email is required"},{id:"v2",field:"emailAddress",type:"pattern",value:"^\\S+@\\S+\\.\\S+$",message:"Invalid email format"},{id:"v3",field:"contactId",type:"required",message:"Contact ID is required"}]},Ae={string:"var(--nice-color-success, #22c55e)",number:"var(--nice-color-primary, #3b82f6)",boolean:"var(--nice-color-warning, #f59e0b)",date:"var(--nice-color-accent, #8b5cf6)",array:"var(--nice-color-info, #06b6d4)",object:"var(--nice-color-accent-pink, #ec4899)",any:"var(--nice-text-muted, #6b7280)"},Pe={string:"edit",number:"hash",boolean:"check",date:"calendar",array:"clipboard",object:"box",any:"help"},Oe={direct:"arrow-right",format:"edit",convert:"refresh",concat:"link",split:"shuffle",calculate:"hash",lookup:"search",conditional:"help",custom:"settings"},$t=o=>{const S=Le(o.sourceSchema),f=Le(o.targetSchema),b=o.fieldMappings.map(j=>{const k=o.transformations.find(i=>i.id===j.transform),p=j.targetField;if(!j.sourceField)return` result.${p} = ${JSON.stringify(j.defaultValue)};`;const $=j.sourceField.split(",").map(i=>i.trim());if(k)switch(k.type){case"concat":return` result.${p} = [${$.map(i=>`source.${i}`).join(", ")}].filter(Boolean).join('${k.config.separator||" "}');`;case"format":if($.length===1){const i=k.config.format||"{value}";return i.includes("{value}")?` result.${p} = '${i}'.replace('{value}', String(source.${$[0]}));`:` result.${p} = formatDate(source.${$[0]}, '${i}');`}break;case"custom":return` result.${p} = ${k.config.expression?.replace(/(\w+)\.(\w+)/g,"source.$1.$2")};`;case"convert":return` result.${p} = ${k.config.convertTo}(source.${$[0]});`}if($.length===1){const i=j.defaultValue!==void 0?` ?? ${JSON.stringify(j.defaultValue)}`:"";return` result.${p} = source.${$[0]}${i};`}return` // TODO: Manual mapping for ${p}`}),N=o.validationRules.map(j=>{switch(j.type){case"required":return` if (!data.${j.field}) errors.push('${j.message||j.field+" is required"}');`;case"pattern":return` if (data.${j.field} && !/${j.value}/.test(data.${j.field})) errors.push('${j.message||"Invalid format"}');`;default:return` // ${j.type} validation for ${j.field}`}});return`/**
95
+ * ${o.name}
96
+ * ${o.description||""}
97
+ * Auto-generated by NiceDataMapper
98
+ */
99
+
100
+ // Source Type
101
+ ${S}
102
+
103
+ // Target Type
104
+ ${f}
105
+
106
+ // Validation
107
+ export function validate${o.targetSchema.name}(data: ${o.targetSchema.name}): string[] {
108
+ const errors: string[] = [];
109
+ ${N.join(`
110
+ `)}
111
+ return errors;
112
+ }
113
+
114
+ // Mapper
115
+ export function ${o.name.charAt(0).toLowerCase()+o.name.slice(1)}(source: ${o.sourceSchema.name}): ${o.targetSchema.name} {
116
+ const result = {} as ${o.targetSchema.name};
117
+
118
+ ${b.join(`
119
+ `)}
120
+
121
+ return result;
122
+ }
123
+
124
+ // Helper functions
125
+ function formatDate(date: string | Date, format: string): string {
126
+ const d = typeof date === 'string' ? new Date(date) : date;
127
+ const year = d.getFullYear();
128
+ const month = String(d.getMonth() + 1).padStart(2, '0');
129
+ const day = String(d.getDate()).padStart(2, '0');
130
+ return format
131
+ .replace('YYYY', String(year))
132
+ .replace('MM', month)
133
+ .replace('DD', day);
134
+ }
135
+ `},Le=(o,S)=>{const f=(N,j)=>{const k=" ".repeat(j),p=N.nullable?"?":"";if(N.type==="object"&&N.children){const i=N.children.map(r=>f(r,j+1)).join(`
136
+ `);return`${k}${N.name}${p}: {
137
+ ${i}
138
+ ${k}};`}const $={string:"string",number:"number",boolean:"boolean",date:"string | Date",array:"unknown[]",object:"Record<string, unknown>",any:"unknown"}[N.type];return`${k}${N.name}${p}: ${$};`},b=o.fields.map(N=>f(N,1)).join(`
139
+ `);return`interface ${o.name} {
140
+ ${b}
141
+ }`},Se=(o,S="")=>{const f=[];return o.forEach(b=>{f.push(b),b.children&&f.push(...Se(b.children,b.path+"."))}),f},Ye=({mapping:o=Nt,sourceSchemas:S=[],targetSchemas:f=[],onMappingChange:b,onExport:N,onTest:j,onSave:k,className:p,style:$,"data-testid":i})=>{const{t:r}=a.useNiceTranslation(),[d,C]=g.useState(o),[w,R]=g.useState("mapping"),[q,G]=g.useState(null),[O,T]=g.useState(""),[I,H]=g.useState(""),[M,m]=g.useState(null),D=g.useCallback(t=>{const n={...d,...t};C(n),b?.(n)},[d,b]),A=g.useMemo(()=>Se(d.sourceSchema.fields),[d.sourceSchema.fields]),Y=g.useMemo(()=>Se(d.targetSchema.fields),[d.targetSchema.fields]),B=(t,n)=>{const y={id:`mapping-${Date.now()}`,sourceField:t,targetField:n};D({fieldMappings:[...d.fieldMappings,y]})},Z=t=>{D({fieldMappings:d.fieldMappings.filter(n=>n.id!==t)})},F=()=>{try{const t=JSON.parse(O),n={};d.fieldMappings.forEach(y=>{if(!y.sourceField){n[y.targetField]=y.defaultValue;return}const h=y.sourceField.split(",").map(l=>l.trim()),x=l=>l.split(".").reduce((ee,te)=>ee?.[te],t),z=d.transformations.find(l=>l.id===y.transform);if(z?.type==="concat")n[y.targetField]=h.map(x).filter(Boolean).join(z.config.separator||" ");else if(z?.type==="format"&&h.length===1){const l=x(h[0]);n[y.targetField]=(z.config.format||"{value}").replace("{value}",String(l))}else h.length===1&&(n[y.targetField]=x(h[0])??y.defaultValue)}),H(JSON.stringify(n,null,2)),j?.(n)}catch(t){H(`Error: ${t.message}`)}},V=g.useMemo(()=>$t(d),[d]),s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",accent:"var(--nice-color-primary, #3b82f6)"};return e.jsxs("div",{className:`nice-data-mapper ${p||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...$},"data-testid":i,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"refresh",size:16})," ",r("dataMapper.dataMapper","Data Mapper")]}),e.jsx("input",{type:"text",value:d.name,onChange:t=>D({name:t.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14,fontWeight:600}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>k?.(d),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"save",size:14})," ",r("dataMapper.save","Save")]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${s.border}`,padding:"0 20px"},children:["mapping","transforms","validation","test","preview"].map(t=>e.jsxs("button",{onClick:()=>R(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:w===t?s.text:s.textMuted,cursor:"pointer",fontSize:13,fontWeight:w===t?600:400,borderBottom:w===t?`2px solid ${s.accent}`:"2px solid transparent",marginBottom:-1},children:[t==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"link",size:14})," ",r("dataMapper.mapping","Mapping")]}),t==="transforms"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," ",r("dataMapper.transforms","Transforms")]}),t==="validation"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"check",size:14})," ",r("dataMapper.validation","Validation")]}),t==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"flask",size:14})," ",r("dataMapper.test","Test")]}),t==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," ",r("dataMapper.preview","Preview")]})]},t))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[w==="mapping"&&e.jsxs("div",{style:{display:"flex",gap:24,height:"100%"},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(a.NiceIcon,{name:"download",size:14})," ",r("dataMapper.source","Source: {name}").replace("{name}",String(d.sourceSchema.name))]}),e.jsx("div",{style:{flex:1,border:`1px solid ${s.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:A.map(t=>{const n=t.path.split(".").length-1,y=d.fieldMappings.some(h=>h.sourceField.split(",").some(x=>x.trim()===t.path));return e.jsxs("div",{draggable:!0,onDragStart:()=>m(t.path),onDragEnd:()=>m(null),style:{padding:"10px 12px",paddingLeft:12+n*16,borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:8,cursor:"grab",background:y?"var(--nice-success-tint-10, #22c55e10)":"transparent",opacity:t.type==="object"&&t.children?.7:1},children:[e.jsx("span",{style:{color:Ae[t.type],fontSize:14},children:e.jsx(a.NiceIcon,{name:Pe[t.type],size:14})}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:t.name}),e.jsx("span",{style:{fontSize:10,color:s.textMuted},children:t.type}),y&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--nice-color-success, #22c55e)",fontSize:10},children:e.jsx(a.NiceIcon,{name:"check",size:14})})]},t.id)})})]}),e.jsxs("div",{style:{width:300,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:s.accent+"20",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(a.NiceIcon,{name:"link",size:16})," ",r("dataMapper.mappings","Mappings ({fieldMappings})").replace("{fieldMappings}",String(d.fieldMappings.length))]}),e.jsx("div",{style:{flex:1,border:`1px solid ${s.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto",padding:8},children:d.fieldMappings.map(t=>{const n=d.transformations.find(y=>y.id===t.transform);return e.jsxs("div",{style:{padding:8,background:s.cardBg,borderRadius:6,marginBottom:8,fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:4},children:[e.jsx("code",{style:{color:"var(--nice-color-success, #22c55e)"},children:t.sourceField||"(default)"}),e.jsx("span",{style:{color:s.textMuted},children:e.jsx(a.NiceIcon,{name:"arrow-right",size:12})}),e.jsx("code",{style:{color:"var(--nice-color-primary, #3b82f6)"},children:t.targetField}),e.jsx("button",{onClick:()=>Z(t.id),"aria-label":r("dataMapper.removeMapping","Remove mapping"),style:{marginLeft:"auto",padding:2,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:10},children:e.jsx(a.NiceIcon,{name:"close",size:14})})]}),n&&e.jsxs("div",{style:{color:s.textMuted,display:"flex",alignItems:"center",gap:4},children:[e.jsx(a.NiceIcon,{name:Oe[n.type],size:14})," ",n.name]}),t.defaultValue!==void 0&&e.jsx("div",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:r("dataMapper.default","Default: {defaultValue}").replace("{defaultValue}",String(JSON.stringify(t.defaultValue)))})]},t.id)})})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:"var(--nice-primary-tint-12, #3b82f620)",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",r("dataMapper.target","Target: {name}").replace("{name}",String(d.targetSchema.name))]}),e.jsx("div",{style:{flex:1,border:`1px solid ${s.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:Y.map(t=>{const n=t.path.split(".").length-1,y=d.fieldMappings.some(h=>h.targetField===t.path);return e.jsxs("div",{onDragOver:h=>h.preventDefault(),onDrop:()=>{M&&!y&&B(M,t.path)},style:{padding:"10px 12px",paddingLeft:12+n*16,borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:8,background:M&&!y?s.accent+"10":y?"color-mix(in srgb, var(--nice-color-primary, #3b82f6) 6%, transparent)":"transparent",transition:"background 0.15s"},children:[e.jsx("span",{style:{color:Ae[t.type],fontSize:14},children:e.jsx(a.NiceIcon,{name:Pe[t.type],size:14})}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:t.name}),e.jsx("span",{style:{fontSize:10,color:s.textMuted},children:t.type}),t.nullable&&e.jsx("span",{style:{fontSize:10,color:s.textMuted},children:"?"}),y&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--nice-color-primary, #3b82f6)",fontSize:10},children:e.jsx(a.NiceIcon,{name:"check",size:14})})]},t.id)})})]})]}),w==="transforms"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:16})," ",r("dataMapper.transformations","Transformations")]}),e.jsx("button",{onClick:()=>{const t={id:`tr-${Date.now()}`,name:"New Transform",type:"direct",config:{}};D({transformations:[...d.transformations,t]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:r("dataMapper.addTransform","+ Add Transform")})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:16},children:d.transformations.map(t=>e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,border:`1px solid ${s.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("span",{style:{fontSize:20},children:e.jsx(a.NiceIcon,{name:Oe[t.type],size:20})}),e.jsx("input",{type:"text",value:t.name,onChange:n=>{const y=d.transformations.map(h=>h.id===t.id?{...h,name:n.target.value}:h);D({transformations:y})},style:{flex:1,padding:"6px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13,fontWeight:600}})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:s.textMuted,marginBottom:4},children:r("dataMapper.type","Type")}),e.jsxs("select",{value:t.type,onChange:n=>{const y=d.transformations.map(h=>h.id===t.id?{...h,type:n.target.value}:h);D({transformations:y})},style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12},children:[e.jsx("option",{value:"direct",children:r("dataMapper.direct","Direct")}),e.jsx("option",{value:"format",children:r("dataMapper.format","Format")}),e.jsx("option",{value:"convert",children:r("dataMapper.convert","Convert")}),e.jsx("option",{value:"concat",children:r("dataMapper.concatenate","Concatenate")}),e.jsx("option",{value:"split",children:r("dataMapper.split","Split")}),e.jsx("option",{value:"calculate",children:r("dataMapper.calculate","Calculate")}),e.jsx("option",{value:"lookup",children:r("dataMapper.lookup","Lookup")}),e.jsx("option",{value:"conditional",children:r("dataMapper.conditional","Conditional")}),e.jsx("option",{value:"custom",children:r("dataMapper.custom","Custom")})]})]}),(t.type==="format"||t.type==="concat")&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:s.textMuted,marginBottom:4},children:t.type==="format"?r("dataMapper.formatPattern","Format Pattern"):r("dataMapper.separator","Separator")}),e.jsx("input",{type:"text",value:t.type==="format"?t.config.format||"":t.config.separator||"",onChange:n=>{const y=d.transformations.map(h=>h.id===t.id?{...h,config:{...h.config,[t.type==="format"?"format":"separator"]:n.target.value}}:h);D({transformations:y})},placeholder:t.type==="format"?r("dataMapper.orYyyyMmDd","{value} or YYYY-MM-DD"):", ",style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12,fontFamily:"monospace",boxSizing:"border-box"}})]}),t.type==="custom"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:s.textMuted,marginBottom:4},children:r("dataMapper.expression","Expression")}),e.jsx("textarea",{value:t.config.expression||"",onChange:n=>{const y=d.transformations.map(h=>h.id===t.id?{...h,config:{...h.config,expression:n.target.value}}:h);D({transformations:y})},rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12,fontFamily:"monospace",resize:"vertical",boxSizing:"border-box"}})]})]},t.id))})]}),w==="validation"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"check",size:16})," ",r("dataMapper.validationRules","Validation Rules")]}),e.jsx("button",{onClick:()=>{const t={id:`v-${Date.now()}`,field:"",type:"required",message:""};D({validationRules:[...d.validationRules,t]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:r("dataMapper.addRule","+ Add Rule")})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:d.validationRules.map(t=>e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsxs("select",{value:t.field,onChange:n=>{const y=d.validationRules.map(h=>h.id===t.id?{...h,field:n.target.value}:h);D({validationRules:y})},style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12},children:[e.jsx("option",{value:"",children:r("dataMapper.selectField","Select field...")}),Y.map(n=>e.jsx("option",{value:n.path,children:n.path},n.id))]}),e.jsxs("select",{value:t.type,onChange:n=>{const y=d.validationRules.map(h=>h.id===t.id?{...h,type:n.target.value}:h);D({validationRules:y})},style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12},children:[e.jsx("option",{value:"required",children:r("dataMapper.required","Required")}),e.jsx("option",{value:"type",children:r("dataMapper.type","Type")}),e.jsx("option",{value:"min",children:r("dataMapper.min","Min")}),e.jsx("option",{value:"max",children:r("dataMapper.max","Max")}),e.jsx("option",{value:"pattern",children:r("dataMapper.pattern","Pattern")}),e.jsx("option",{value:"enum",children:r("dataMapper.enum","Enum")}),e.jsx("option",{value:"custom",children:r("dataMapper.custom","Custom")})]}),(t.type==="pattern"||t.type==="min"||t.type==="max")&&e.jsx("input",{type:"text",value:String(t.value||""),onChange:n=>{const y=d.validationRules.map(h=>h.id===t.id?{...h,value:n.target.value}:h);D({validationRules:y})},placeholder:r("dataMapper.value","Value"),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12,width:150}}),e.jsx("input",{type:"text",value:t.message||"",onChange:n=>{const y=d.validationRules.map(h=>h.id===t.id?{...h,message:n.target.value}:h);D({validationRules:y})},placeholder:r("dataMapper.errorMessage","Error message"),style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:12}}),e.jsx("button",{onClick:()=>{D({validationRules:d.validationRules.filter(n=>n.id!==t.id)})},"aria-label":r("dataMapper.delete","Delete"),style:{padding:6,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]},t.id))})]}),w==="test"&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:20,height:"100%"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"download",size:16})," ",r("dataMapper.input","Input")]}),e.jsx("button",{onClick:()=>{const t={},n=(y,h)=>{y.forEach(x=>{x.children&&x.type==="object"?(h[x.name]={},n(x.children,h[x.name])):h[x.name]={string:"sample",number:42,boolean:!0,date:new Date().toISOString(),array:[],object:{},any:null}[x.type]})};n(d.sourceSchema.fields,t),T(JSON.stringify(t,null,2))},style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:11},children:r("dataMapper.generateSample","Generate Sample")})]}),e.jsx("textarea",{value:O,onChange:t=>T(t.target.value),placeholder:r("dataMapper.pasteJsonInputHere","Paste JSON input here..."),style:{flex:1,padding:12,borderRadius:8,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",resize:"none"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"upload",size:16})," ",r("dataMapper.output","Output")]}),e.jsxs("button",{onClick:F,style:{padding:"6px 16px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"refresh",size:14})," ",r("dataMapper.transform","Transform")]})]}),e.jsx("pre",{style:{flex:1,padding:12,borderRadius:8,background:s.cardBg,margin:0,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace"},children:I||"Run transform to see output"})]})]}),w==="preview"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("button",{onClick:()=>N?.(V),style:{padding:"8px 16px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",r("dataMapper.export","Export")]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(V),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",r("dataMapper.copy","Copy")]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:s.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:V})]})]})]})},Ct=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMapper:Ye},Symbol.toStringTag,{value:"Module"})),zt=[{type:"ui-event",label:"UI Event",icon:"cursor",color:"var(--nice-color-primary, #3b82f6)",configSchema:[{name:"element",label:"Element Selector",type:"string",required:!0},{name:"event",label:"Event Type",type:"select",required:!0,options:[{value:"click",label:"Click"},{value:"change",label:"Change"},{value:"submit",label:"Submit"},{value:"focus",label:"Focus"},{value:"blur",label:"Blur"},{value:"keydown",label:"Key Down"},{value:"keyup",label:"Key Up"}]}]},{type:"api-response",label:"API Response",icon:"globe",color:"var(--nice-color-success, #22c55e)",configSchema:[{name:"endpoint",label:"Endpoint Pattern",type:"string",required:!0},{name:"method",label:"Method",type:"select",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"DELETE",label:"DELETE"},{value:"*",label:"Any"}]},{name:"statusCode",label:"Status Code",type:"string"}]},{type:"websocket",label:"WebSocket",icon:"plug",color:"var(--nice-color-accent, #8b5cf6)",configSchema:[{name:"channel",label:"Channel",type:"string",required:!0},{name:"messageType",label:"Message Type",type:"string"}]},{type:"timer",label:"Timer",icon:"clock",color:"var(--nice-color-warning, #f59e0b)",configSchema:[{name:"interval",label:"Interval (ms)",type:"number",required:!0,default:1e3},{name:"repeat",label:"Repeat",type:"boolean",default:!0}]},{type:"state-change",label:"State Change",icon:"bar-chart",color:"var(--nice-color-accent-pink, #ec4899)",configSchema:[{name:"selector",label:"State Selector",type:"string",required:!0},{name:"deep",label:"Deep Compare",type:"boolean",default:!1}]},{type:"broadcast",label:"Broadcast",icon:"wifi",color:"var(--nice-color-info, #06b6d4)",configSchema:[{name:"eventName",label:"Event Name",type:"string",required:!0}]}],Tt=[{type:"action",label:"Action",icon:"zap",color:"var(--nice-color-primary, #3b82f6)",configSchema:[{name:"actionType",label:"Action",type:"string",required:!0},{name:"payload",label:"Payload",type:"json"}]},{type:"transform",label:"Transform",icon:"refresh",color:"var(--nice-color-accent, #8b5cf6)",configSchema:[{name:"expression",label:"Transform Expression",type:"code",required:!0}]},{type:"dispatch",label:"Dispatch",icon:"upload",color:"var(--nice-color-success, #22c55e)",configSchema:[{name:"eventName",label:"Event Name",type:"string",required:!0},{name:"payload",label:"Payload",type:"json"}]},{type:"api-call",label:"API Call",icon:"globe",color:"var(--nice-color-warning, #f59e0b)",configSchema:[{name:"endpoint",label:"Endpoint",type:"string",required:!0},{name:"method",label:"Method",type:"select",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"DELETE",label:"DELETE"}]},{name:"body",label:"Body",type:"json"}]},{type:"state-update",label:"State Update",icon:"bar-chart",color:"var(--nice-color-accent-pink, #ec4899)",configSchema:[{name:"path",label:"State Path",type:"string",required:!0},{name:"value",label:"Value Expression",type:"code"}]},{type:"notification",label:"Notification",icon:"bell",color:"var(--nice-color-info, #06b6d4)",configSchema:[{name:"type",label:"Type",type:"select",options:[{value:"success",label:"Success"},{value:"error",label:"Error"},{value:"warning",label:"Warning"},{value:"info",label:"Info"}]},{name:"message",label:"Message",type:"string",required:!0},{name:"duration",label:"Duration (ms)",type:"number",default:3e3}]},{type:"log",label:"Console Log",icon:"edit",color:"var(--nice-text-muted, #6b7280)",configSchema:[{name:"level",label:"Level",type:"select",options:[{value:"log",label:"Log"},{value:"warn",label:"Warn"},{value:"error",label:"Error"},{value:"debug",label:"Debug"}]},{name:"message",label:"Message",type:"string"}]},{type:"delay",label:"Delay",icon:"clock",color:"var(--nice-accent, #a855f7)",configSchema:[{name:"duration",label:"Duration (ms)",type:"number",required:!0,default:1e3}]},{type:"branch",label:"Conditional Branch",icon:"shuffle",color:"var(--nice-info, #14b8a6)",configSchema:[{name:"condition",label:"Condition",type:"code",required:!0},{name:"trueBranch",label:"If True",type:"string"},{name:"falseBranch",label:"If False",type:"string"}]}],It=[{id:"flow-1",name:"Form Submit Handler",description:"Handle form submission with validation",enabled:!0,source:{id:"src-1",type:"ui-event",config:{element:"#contact-form",event:"submit"}},handlers:[{id:"h-1",type:"transform",config:{expression:"(event) => event.formData"}},{id:"h-2",type:"api-call",config:{endpoint:"/api/contact",method:"POST",body:"{{data}}"},modifiers:[{type:"debounce",value:500,unit:"ms"}]},{id:"h-3",type:"notification",config:{type:"success",message:"Form submitted successfully!"}}],errorHandler:{id:"err-1",type:"notification",config:{type:"error",message:"Failed to submit form"}}},{id:"flow-2",name:"Real-time Updates",description:"Handle WebSocket messages",enabled:!0,source:{id:"src-2",type:"websocket",config:{channel:"notifications",messageType:"update"}},handlers:[{id:"h-4",type:"state-update",config:{path:"notifications",value:"(state, data) => [...state.notifications, data]"}},{id:"h-5",type:"notification",config:{type:"info",message:"{{data.title}}",duration:5e3}}]},{id:"flow-3",name:"Auto-save Draft",description:"Periodically save form draft",enabled:!1,source:{id:"src-3",type:"timer",config:{interval:3e4,repeat:!0}},handlers:[{id:"h-6",type:"transform",config:{expression:"() => getFormData()"}},{id:"h-7",type:"api-call",config:{endpoint:"/api/draft",method:"PUT"},condition:{field:"isDirty",operator:"eq",value:!0}},{id:"h-8",type:"log",config:{level:"debug",message:"Draft saved"}}]}],_t=o=>{const S=o.filter(b=>b.enabled);return`/**
142
+ * Generated Event Orchestration
143
+ * @generated by NiceEventOrchestrator
144
+ */
145
+
146
+ import { createEventBus, EventHandler, EventSource } from '@nice2dev/events';
147
+
148
+ // Event Bus Instance
149
+ export const eventBus = createEventBus();
150
+
151
+ // Event Types
152
+ ${S.map(b=>`export type ${b.name.replace(/\s+/g,"")}Event = {
153
+ source: '${b.source.type}';
154
+ payload: unknown;
155
+ };`).join(`
156
+
157
+ `)}
158
+
159
+ // Event Handlers
160
+ ${S.map(b=>{const N=JSON.stringify(b.source.config,null,2),j=b.handlers.flatMap(k=>k.modifiers||[]).map(k=>`.${k.type}(${k.value})`).join("");return`
161
+ /**
162
+ * ${b.name}
163
+ * ${b.description||""}
164
+ */
165
+ export const ${b.name.replace(/\s+/g,"").toLowerCase()}Handler = eventBus
166
+ .on('${b.source.type}', ${N})${j}
167
+ .pipe(
168
+ ${b.handlers.map((k,p)=>` // Step ${p+1}: ${k.type}
169
+ async (event) => {
170
+ ${Ve(k)}
171
+ },`).join(`
172
+ `)}
173
+ )
174
+ ${b.errorHandler?`.catch(async (error) => {
175
+ ${Ve(b.errorHandler)}
176
+ })`:""};`}).join(`
177
+ `)}
178
+
179
+ // Initialize all handlers
180
+ export function initEventOrchestration() {
181
+ ${S.map(b=>` ${b.name.replace(/\s+/g,"").toLowerCase()}Handler.start();`).join(`
182
+ `)}
183
+ console.log('Event orchestration initialized');
184
+ }
185
+
186
+ // Cleanup
187
+ export function destroyEventOrchestration() {
188
+ ${S.map(b=>` ${b.name.replace(/\s+/g,"").toLowerCase()}Handler.stop();`).join(`
189
+ `)}
190
+ }
191
+ `},Ve=o=>{switch(o.type){case"action":return`dispatch({ type: '${o.config.actionType}', payload: ${JSON.stringify(o.config.payload)} });`;case"transform":return`return (${o.config.expression})(event);`;case"dispatch":return`eventBus.emit('${o.config.eventName}', ${JSON.stringify(o.config.payload)});`;case"api-call":return`await fetch('${o.config.endpoint}', { method: '${o.config.method}', body: JSON.stringify(event.payload) });`;case"state-update":return`updateState('${o.config.path}', ${o.config.value});`;case"notification":return`showNotification({ type: '${o.config.type}', message: '${o.config.message}' });`;case"log":return`console.${o.config.level||"log"}('${o.config.message}', event);`;case"delay":return`await new Promise(r => setTimeout(r, ${o.config.duration}));`;case"branch":return`if (${o.config.condition}) { /* true branch */ } else { /* false branch */ }`;default:return"// Unknown handler type"}},Ze=({flows:o=It,eventSources:S=zt,eventHandlers:f=Tt,onFlowsChange:b,onExport:N,onTest:j,className:k,style:p,"data-testid":$})=>{const{t:i}=a.useNiceTranslation(),[r,d]=g.useState(o),[C,w]=g.useState(r[0]?.id??null),[R,q]=g.useState("visual"),[G,O]=g.useState(!1),[T,I]=g.useState(""),[H,M]=g.useState(new Set),m=g.useMemo(()=>r.find(n=>n.id===C),[r,C]),D=g.useMemo(()=>_t(r),[r]),A=g.useCallback((n,y)=>{d(h=>{const x=h.map(z=>z.id===n?{...z,...y}:z);return b?.(x),x})},[b]),Y=()=>{if(!T.trim())return;const n={id:`flow-${Date.now()}`,name:T,enabled:!0,source:{id:`src-${Date.now()}`,type:"ui-event",config:{element:"",event:"click"}},handlers:[]};d(y=>{const h=[...y,n];return b?.(h),h}),w(n.id),O(!1),I("")},B=n=>{d(y=>{const h=y.filter(x=>x.id!==n);return b?.(h),h}),C===n&&w(r[0]?.id??null)},Z=n=>{if(!m)return;const y=f.find(z=>z.type===n),h={};y?.configSchema.forEach(z=>{z.default!==void 0&&(h[z.name]=z.default)});const x={id:`handler-${Date.now()}`,type:n,config:h};A(m.id,{handlers:[...m.handlers,x]}),M(z=>new Set([...z,x.id]))},F=(n,y)=>{m&&A(m.id,{handlers:m.handlers.map(h=>h.id===n?{...h,...y}:h)})},V=n=>{m&&A(m.id,{handlers:m.handlers.filter(y=>y.id!==n)})},s=(n,y)=>{if(!m)return;const h=m.handlers.find(l=>l.id===n);if(!h)return;const z=h.modifiers?.find(l=>l.type===y)?h.modifiers?.filter(l=>l.type!==y):[...h.modifiers||[],{type:y,value:500,unit:"ms"}];F(n,{modifiers:z})},t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-event-orchestrator ${k||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...p},"data-testid":$,children:[e.jsxs("div",{style:{padding:"12px 20px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:16})," ",i("eventOrchestrator.eventOrchestrator","Event Orchestrator")]}),e.jsx("div",{style:{display:"flex",border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(n=>e.jsxs("button",{onClick:()=>q(n),style:{padding:"6px 12px",border:"none",background:R===n?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12,textTransform:"capitalize",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:n==="visual"?"palette":n==="code"?"edit":"grid",size:14})," ",n]},n))}),e.jsxs("button",{onClick:()=>N?.(D),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",i("eventOrchestrator.export","Export")]})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(R==="visual"||R==="split")&&e.jsxs("div",{style:{width:240,borderRight:`1px solid ${t.border}`,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600},children:i("eventOrchestrator.eventFlows","Event Flows")}),e.jsx("button",{onClick:()=>O(!0),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"+"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[r.map(n=>{const y=S.find(h=>h.type===n.source.type);return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,onClick:()=>w(n.id),style:{padding:12,background:C===n.id?t.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${C===n.id?t.border:"transparent"}`,opacity:n.enabled?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:y?.icon??"zap",size:16}),e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:500},children:n.name}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n.enabled?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}})]}),e.jsx("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:n.handlers.length!==1?i("eventOrchestrator.handlersMany","{handlers} handlers").replace("{handlers}",String(n.handlers.length)):i("eventOrchestrator.handlersOne","{handlers} handler").replace("{handlers}",String(n.handlers.length))})]},n.id)}),G&&e.jsxs("div",{style:{padding:12,background:t.cardBg,borderRadius:6,border:"1px solid var(--nice-primary, #3b82f6)"},children:[e.jsx("input",{type:"text",value:T,onChange:n=>I(n.target.value),placeholder:i("eventOrchestrator.flowName","Flow name..."),autoFocus:!0,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,marginBottom:8,boxSizing:"border-box"},onKeyDown:n=>n.key==="Enter"&&Y()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>O(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:11},children:i("eventOrchestrator.cancel","Cancel")}),e.jsx("button",{onClick:Y,style:{flex:1,padding:6,borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:11},children:i("eventOrchestrator.add","Add")})]})]})]})]}),(R==="visual"||R==="split")&&m&&e.jsxs("div",{style:{flex:R==="split"?1:2,overflow:"auto",padding:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx("input",{type:"text",value:m.name,onChange:n=>A(m.id,{name:n.target.value}),style:{flex:1,padding:10,borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:16,fontWeight:600}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.enabled,onChange:n=>A(m.id,{enabled:n.target.checked})}),e.jsx("span",{style:{fontSize:12},children:i("eventOrchestrator.enabled","Enabled")})]}),e.jsxs("button",{onClick:()=>j?.(m.id),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"play",size:14})," ",i("eventOrchestrator.test","Test")]}),e.jsx("button",{onClick:()=>B(m.id),"aria-label":i("eventOrchestrator.delete","Delete"),style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]}),e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,marginBottom:16,borderLeft:`4px solid ${S.find(n=>n.type===m.source.type)?.color??"var(--nice-text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(a.NiceIcon,{name:S.find(n=>n.type===m.source.type)?.icon??"zap",size:20}),e.jsx("span",{style:{fontWeight:600},children:i("eventOrchestrator.eventSource","Event Source")})]}),e.jsx("select",{value:m.source.type,onChange:n=>A(m.id,{source:{...m.source,type:n.target.value,config:{}}}),style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:13,marginBottom:12},children:S.map(n=>e.jsx("option",{value:n.type,children:n.label},n.type))}),S.find(n=>n.type===m.source.type)?.configSchema.map(n=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:[n.label," ",n.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:"*"})]}),n.type==="select"?e.jsx("select",{value:String(m.source.config[n.name]??""),onChange:y=>A(m.id,{source:{...m.source,config:{...m.source.config,[n.name]:y.target.value}}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:n.options?.map(y=>e.jsx("option",{value:y.value,children:y.label},y.value))}):e.jsx("input",{type:n.type==="number"?"number":"text",value:String(m.source.config[n.name]??""),onChange:y=>A(m.id,{source:{...m.source,config:{...m.source.config,[n.name]:n.type==="number"?Number(y.target.value):y.target.value}}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,boxSizing:"border-box"}})]},n.name))]}),e.jsx("div",{style:{textAlign:"center",color:t.textMuted,marginBottom:16},children:e.jsx(a.NiceIcon,{name:"arrow-down",size:16})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[m.handlers.map((n,y)=>{const h=f.find(z=>z.type===n.type),x=H.has(n.id);return e.jsxs(g.Fragment,{children:[e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,borderLeft:`4px solid ${h?.color??"var(--nice-text-muted, #888)"}`},children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":H.has(n.id),onKeyDown:a.clickOnActivationKey,style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},onClick:()=>M(z=>{const l=new Set(z);return l.has(n.id)?l.delete(n.id):l.add(n.id),l}),children:[e.jsx(a.NiceIcon,{name:h?.icon??"zap",size:16}),e.jsxs("span",{style:{fontWeight:500},children:[y+1,". ",h?.label??n.type]}),n.modifiers?.map(z=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:[z.type,": ",z.value,"ms"]},z.type)),e.jsx("span",{style:{marginLeft:"auto",color:t.textMuted,display:"inline-flex",alignItems:"center"},children:e.jsx(a.NiceIcon,{name:x?"chevron-down":"chevron-right",size:14})})]}),x&&e.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`},children:[e.jsx("select",{value:n.type,onChange:z=>F(n.id,{type:z.target.value}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,marginBottom:12},children:f.map(z=>e.jsx("option",{value:z.type,children:z.label},z.type))}),h?.configSchema.map(z=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:z.label}),z.type==="code"?e.jsx("textarea",{value:String(n.config[z.name]??""),onChange:l=>F(n.id,{config:{...n.config,[z.name]:l.target.value}}),rows:3,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontFamily:"monospace",fontSize:11,resize:"vertical",boxSizing:"border-box"}}):z.type==="select"?e.jsx("select",{value:String(n.config[z.name]??""),onChange:l=>F(n.id,{config:{...n.config,[z.name]:l.target.value}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:z.options?.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}):e.jsx("input",{type:z.type==="number"?"number":"text",value:String(n.config[z.name]??""),onChange:l=>F(n.id,{config:{...n.config,[z.name]:z.type==="number"?Number(l.target.value):l.target.value}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,boxSizing:"border-box"}})]},z.name)),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:i("eventOrchestrator.modifiers","Modifiers")}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["debounce","throttle","delay","retry","once"].map(z=>e.jsx("button",{onClick:()=>s(n.id,z),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${n.modifiers?.some(l=>l.type===z)?"var(--nice-color-accent, #8b5cf6)":t.border}`,background:n.modifiers?.some(l=>l.type===z)?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:11},children:z},z))})]}),e.jsxs("button",{onClick:()=>V(n.id),style:{marginTop:12,padding:"6px 12px",borderRadius:4,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:11,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," ",i("eventOrchestrator.removeHandler","Remove Handler")]})]})]}),y<m.handlers.length-1&&e.jsx("div",{style:{textAlign:"center",color:t.textMuted},children:e.jsx(a.NiceIcon,{name:"arrow-down",size:16})})]},n.id)}),e.jsxs("div",{style:{padding:16,border:`1px dashed ${t.border}`,borderRadius:8,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:12,color:t.textMuted,marginBottom:12},children:i("eventOrchestrator.addHandler","Add Handler")}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center"},children:f.map(n=>e.jsxs("button",{onClick:()=>Z(n.type),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${n.color}`,background:`${n.color}20`,color:t.text,cursor:"pointer",fontSize:11,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:n.icon,size:14})," ",n.label]},n.type))})]})]})]}),(R==="code"||R==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--nice-bg-canvas, #0d1117)",borderLeft:R==="split"?`1px solid ${t.border}`:void 0},children:e.jsx("pre",{style:{margin:0,fontFamily:"Consolas, Monaco, monospace",fontSize:12,lineHeight:1.5,color:"var(--nice-text-primary, #e6edf3)",whiteSpace:"pre-wrap"},children:D})})]})]})},Rt=Object.freeze(Object.defineProperty({__proto__:null,NiceEventOrchestrator:Ze},Symbol.toStringTag,{value:"Module"})),Bt=[{target:".nice-test-builder",titleKey:"tutorial.testBuilder.intro.title",title:"Test builder",contentKey:"tutorial.testBuilder.intro.content",content:"Build test suites visually: add cases and interaction steps with assertions, run them, and export to a ready-to-run .test.tsx file.",placement:"auto"}],fe={render:{label:"Render",icon:"palette",color:"var(--nice-color-primary, #3b82f6)"},click:{label:"Click",icon:"cursor",color:"var(--nice-color-success, #22c55e)",hasTarget:!0},type:{label:"Type",icon:"terminal",color:"var(--nice-color-warning, #f59e0b)",hasTarget:!0,hasValue:!0},select:{label:"Select",icon:"clipboard",color:"var(--nice-color-accent, #8b5cf6)",hasTarget:!0,hasValue:!0},hover:{label:"Hover",icon:"cursor",color:"var(--nice-color-accent-pink, #ec4899)",hasTarget:!0},focus:{label:"Focus",icon:"target",color:"var(--nice-color-info, #06b6d4)",hasTarget:!0},blur:{label:"Blur",icon:"forward",color:"var(--nice-text-muted, #6b7280)",hasTarget:!0},submit:{label:"Submit",icon:"upload",color:"var(--nice-info, #14b8a6)",hasTarget:!0},keypress:{label:"Key Press",icon:"terminal",color:"var(--nice-accent, #a855f7)",hasValue:!0},wait:{label:"Wait",icon:"clock",color:"var(--nice-warning, #f97316)",hasValue:!0},scroll:{label:"Scroll",icon:"file",color:"var(--nice-success, #84cc16)",hasTarget:!0},drag:{label:"Drag & Drop",icon:"cursor",color:"var(--nice-color-warning, #eab308)",hasTarget:!0,hasValue:!0},assert:{label:"Assert",icon:"check",color:"var(--nice-color-success, #22c55e)",hasTarget:!0,hasValue:!0},snapshot:{label:"Snapshot",icon:"camera",color:"var(--nice-color-primary, #3b82f6)"},"a11y-check":{label:"A11y Check",icon:"accessibility",color:"var(--nice-color-accent, #8b5cf6)"}},Mt=[{id:"suite-1",name:"Button Component Tests",componentName:"NiceButton",setup:{mocks:[{name:"onClick",type:"function"}]},tests:[{id:"test-1",name:"renders with correct text",type:"unit",steps:[{id:"step-1",action:"render"},{id:"step-2",action:"assert",target:"button",value:{matcher:"toHaveTextContent",expected:"Click me"}}]},{id:"test-2",name:"calls onClick when clicked",type:"unit",steps:[{id:"step-3",action:"render"},{id:"step-4",action:"click",target:"button"},{id:"step-5",action:"assert",value:{mock:"onClick",matcher:"toHaveBeenCalled"}}]},{id:"test-3",name:"is disabled when loading",type:"unit",steps:[{id:"step-6",action:"render"},{id:"step-7",action:"assert",target:"button",value:{matcher:"toHaveAttribute",expected:["disabled","true"]}}]}]},{id:"suite-2",name:"Form Integration Tests",componentName:"ContactForm",setup:{mocks:[{name:"api.submit",type:"api",returnValue:{success:!0}}],providers:[{name:"FormProvider",props:{}}]},tests:[{id:"test-4",name:"submits form with valid data",type:"integration",steps:[{id:"step-8",action:"render"},{id:"step-9",action:"type",target:'input[name="email"]',value:"test@example.com"},{id:"step-10",action:"type",target:'input[name="message"]',value:"Hello!"},{id:"step-11",action:"click",target:'button[type="submit"]'},{id:"step-12",action:"wait",value:{type:"api",timeout:1e3}},{id:"step-13",action:"assert",target:".success-message",value:{matcher:"toBeInTheDocument"}}]},{id:"test-5",name:"shows validation errors",type:"integration",steps:[{id:"step-14",action:"render"},{id:"step-15",action:"click",target:'button[type="submit"]'},{id:"step-16",action:"assert",target:".error",value:{matcher:"toHaveTextContent",expected:"Email is required"}}]}]}],Dt=o=>o.map(S=>{const f=new Set(["import { render, screen, fireEvent, waitFor } from '@testing-library/react';","import userEvent from '@testing-library/user-event';",`import { ${S.componentName} } from './${S.componentName}';`]);S.setup?.mocks.forEach(p=>{p.type==="api"&&(f.add("import { rest } from 'msw';"),f.add("import { setupServer } from 'msw/node';"))});const b=S.setup?.mocks.map(p=>p.type==="function"?`const ${p.name} = jest.fn();`:p.type==="api"?`// API mock: ${p.name}`:"").filter(Boolean).join(`
192
+ `),j=S.setup?.providers&&S.setup.providers.length>0?`const Wrapper = ({ children }) => (
193
+ ${S.setup.providers.map(p=>`<${p.name}>`).join(`
194
+ `)}
195
+ {children}
196
+ ${S.setup.providers.reverse().map(p=>`</${p.name}>`).join(`
197
+ `)}
198
+ );`:"",k=S.tests.map(p=>{const $=p.skip?".skip":p.only?".only":"",i=p.steps.map(r=>Ft(r,S)).join(`
199
+ `);return`
200
+ it${$}('${p.name}', async () => {
201
+ ${i}
202
+ });`}).join(`
203
+ `);return`/**
204
+ * ${S.name}
205
+ * @generated by NiceTestBuilder
206
+ */
207
+
208
+ ${Array.from(f).join(`
209
+ `)}
210
+
211
+ describe('${S.componentName}', () => {
212
+ ${b?` // Mocks
213
+ ${b}
214
+ `:""}
215
+ ${j?` ${j}
216
+ `:""}
217
+ beforeEach(() => {
218
+ jest.clearAllMocks();
219
+ });
220
+ ${k}
221
+ });
222
+ `}).join(`
223
+
224
+ `),Ft=(o,S)=>{switch(fe[o.action],o.action){case"render":{const f=S.setup?.providers&&S.setup.providers.length>0,b=S.setup?.props?` {...${JSON.stringify(S.setup.props)}}`:"";return f?`render(<${S.componentName}${b} />, { wrapper: Wrapper });`:`render(<${S.componentName}${b} />);`}case"click":return`await userEvent.click(screen.getByRole('${o.target?.replace(/[[\]'"]/g,"")}'));`;case"type":return`await userEvent.type(screen.getByRole('textbox', { name: /${o.target}/ }), '${o.value}');`;case"select":return`await userEvent.selectOptions(screen.getByRole('combobox'), '${o.value}');`;case"hover":return`await userEvent.hover(screen.getByRole('${o.target}'));`;case"focus":return`screen.getByRole('${o.target}').focus();`;case"blur":return`screen.getByRole('${o.target}').blur();`;case"submit":return"fireEvent.submit(screen.getByRole('form'));";case"wait":if(typeof o.value=="object"&&o.value!==null){const f=o.value;return f.type==="timeout"?`await new Promise(r => setTimeout(r, ${f.value}));`:`await waitFor(() => expect(/* condition */).toBeTruthy(), { timeout: ${f.timeout??1e3} });`}return`await new Promise(r => setTimeout(r, ${o.value}));`;case"assert":if(typeof o.value=="object"&&o.value!==null){const f=o.value;if(f.mock)return`expect(${f.mock}).${f.matcher}(${f.expected?JSON.stringify(f.expected):""});`;const b=o.target?`screen.getByRole('${o.target}')`:"result",N=f.expected!==void 0?JSON.stringify(f.expected):"";return`expect(${b}).${f.matcher}(${N});`}return`expect(screen.getByRole('${o.target}')).toBeInTheDocument();`;case"snapshot":return"expect(container).toMatchSnapshot();";case"a11y-check":return`const results = await axe(container);
225
+ expect(results).toHaveNoViolations();`;default:return`// ${o.action}: ${JSON.stringify(o)}`}},Qe=({componentName:o="MyComponent",testSuites:S=Mt,availableMocks:f=[],onSuitesChange:b,onExport:N,onRun:j,onRunAll:k,tutorial:p,className:$,style:i,"data-testid":r})=>{const{t:d}=a.useNiceTranslation(),[C,w]=g.useState(S),[R,q]=g.useState(C[0]?.id??null),[G,O]=g.useState(null),[T,I]=g.useState("visual"),[H,M]=g.useState(!1),[m,D]=g.useState(""),[A,Y]=g.useState(new Set),B=g.useMemo(()=>C.find(c=>c.id===R),[C,R]);g.useMemo(()=>B?.tests.find(c=>c.id===G),[B,G]);const Z=g.useMemo(()=>Dt(C),[C]),F=g.useCallback((c,W)=>{w(K=>{const J=K.map(L=>L.id===c?{...L,...W}:L);return b?.(J),J})},[b]),V=()=>{if(!m.trim())return;const c={id:`suite-${Date.now()}`,name:m,componentName:o,tests:[]};w(W=>{const K=[...W,c];return b?.(K),K}),q(c.id),M(!1),D("")},s=c=>{w(W=>{const K=W.filter(J=>J.id!==c);return b?.(K),K}),R===c&&q(C[0]?.id??null)},t=()=>{if(!B)return;const c={id:`test-${Date.now()}`,name:"New test",type:"unit",steps:[{id:`step-${Date.now()}`,action:"render"}]};F(B.id,{tests:[...B.tests,c]}),O(c.id),Y(W=>new Set([...W,c.id]))},n=(c,W)=>{B&&F(B.id,{tests:B.tests.map(K=>K.id===c?{...K,...W}:K)})},y=c=>{B&&(F(B.id,{tests:B.tests.filter(W=>W.id!==c)}),G===c&&O(null))},h=(c,W)=>{if(!B)return;const K=B.tests.find(L=>L.id===c);if(!K)return;const J={id:`step-${Date.now()}`,action:W};n(c,{steps:[...K.steps,J]})},x=(c,W,K)=>{if(!B)return;const J=B.tests.find(L=>L.id===c);J&&n(c,{steps:J.steps.map(L=>L.id===W?{...L,...K}:L)})},z=(c,W)=>{if(!B)return;const K=B.tests.find(J=>J.id===c);K&&n(c,{steps:K.steps.filter(J=>J.id!==W)})},l={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"},ee=g.useMemo(()=>{const c=C.reduce((K,J)=>K+J.tests.length,0),W=C.reduce((K,J)=>K+J.tests.filter(L=>L.skip).length,0);return{total:c,skipped:W}},[C]),te=e.jsxs("div",{style:{padding:"12px 20px",borderBottom:`1px solid ${l.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(a.NiceIcon,{name:"flask",size:16})," ",d("testBuilder.testBuilder","Test Builder")]}),e.jsx("div",{style:{fontSize:12,color:l.textMuted},children:d("testBuilder.testsSkipped","{total} tests • {skipped} skipped").replace("{total}",String(ee.total)).replace("{skipped}",String(ee.skipped))}),e.jsx("div",{style:{display:"flex",border:`1px solid ${l.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(c=>e.jsxs("button",{onClick:()=>I(c),style:{padding:"6px 12px",border:"none",background:T===c?l.cardBg:"transparent",color:l.text,cursor:"pointer",fontSize:12,textTransform:"capitalize"},children:[e.jsx(a.NiceIcon,{name:c==="visual"?"palette":c==="code"?"edit":"grid",size:14})," ",c]},c))}),e.jsxs("button",{onClick:k,style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"play",size:14})," ",d("testBuilder.runAll","Run All")]}),e.jsxs("button",{onClick:()=>N?.(Z),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",d("testBuilder.export","Export")]}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(p,Bt)})]}),X=T==="visual"||T==="split"?e.jsxs("div",{style:{width:220,borderRight:`1px solid ${l.border}`,display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${l.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600},children:d("testBuilder.testSuites","Test Suites")}),e.jsx("button",{onClick:()=>M(!0),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:12},children:"+"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[C.map(c=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,onClick:()=>{q(c.id),O(null)},style:{padding:12,background:R===c.id?l.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${R===c.id?l.border:"transparent"}`},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:c.name}),e.jsx("div",{style:{fontSize:10,color:l.textMuted,marginTop:4},children:c.tests.length!==1?d("testBuilder.testsMany","{componentName} • {tests} tests").replace("{componentName}",String(c.componentName)).replace("{tests}",String(c.tests.length)):d("testBuilder.testsOne","{componentName} • {tests} test").replace("{componentName}",String(c.componentName)).replace("{tests}",String(c.tests.length))})]},c.id)),H&&e.jsxs("div",{style:{padding:12,background:l.cardBg,borderRadius:6,border:"1px solid var(--nice-primary, #3b82f6)"},children:[e.jsx("input",{type:"text",value:m,onChange:c=>D(c.target.value),placeholder:d("testBuilder.suiteName","Suite name..."),autoFocus:!0,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.bg,color:l.text,fontSize:12,marginBottom:8,boxSizing:"border-box"},onKeyDown:c=>c.key==="Enter"&&V()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>M(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:11},children:d("testBuilder.cancel","Cancel")}),e.jsx("button",{onClick:V,style:{flex:1,padding:6,borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:11},children:d("testBuilder.add","Add")})]})]})]})]}):void 0;return e.jsx(de.NiceAppShell,{flush:!0,className:`nice-test-builder ${$||""}`,style:{background:l.bg,color:l.text,fontFamily:"system-ui, sans-serif",...i},"data-testid":r,menubar:te,sidebar:X,children:e.jsxs("div",{style:{display:"flex",height:"100%",overflow:"hidden"},children:[(T==="visual"||T==="split")&&B&&e.jsxs("div",{style:{flex:T==="split"?1:2,overflow:"auto",padding:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx("input",{type:"text",value:B.name,onChange:c=>F(B.id,{name:c.target.value}),style:{flex:1,padding:10,borderRadius:6,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:16,fontWeight:600}}),e.jsxs("button",{onClick:()=>j?.(B.id),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"play",size:14})," ",d("testBuilder.runSuite","Run Suite")]}),e.jsx("button",{onClick:()=>s(B.id),"aria-label":d("testBuilder.delete","Delete"),style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:l.textMuted,marginBottom:6},children:d("testBuilder.component","Component")}),e.jsx("input",{type:"text",value:B.componentName,onChange:c=>F(B.id,{componentName:c.target.value}),style:{width:200,padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:13}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[B.tests.map((c,W)=>{const K=A.has(c.id),J={unit:{color:"var(--nice-color-primary, #3b82f6)",icon:"puzzle"},integration:{color:"var(--nice-color-success, #22c55e)",icon:"link"},e2e:{color:"var(--nice-color-accent, #8b5cf6)",icon:"globe"},snapshot:{color:"var(--nice-color-warning, #f59e0b)",icon:"camera"},accessibility:{color:"var(--nice-color-accent-pink, #ec4899)",icon:"accessibility"}};return e.jsxs("div",{style:{background:l.cardBg,borderRadius:8,border:`1px solid ${G===c.id?"var(--nice-color-primary, #3b82f6)":l.border}`,overflow:"hidden"},children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":A.has(c.id),onKeyDown:a.clickOnActivationKey,style:{padding:12,display:"flex",alignItems:"center",gap:8,cursor:"pointer",borderLeft:`4px solid ${J[c.type].color}`},onClick:()=>{O(c.id),Y(L=>{const v=new Set(L);return v.has(c.id)?v.delete(c.id):v.add(c.id),v})},children:[e.jsx("span",{children:e.jsx(a.NiceIcon,{name:J[c.type].icon,size:14})}),e.jsxs("span",{style:{fontWeight:500,opacity:c.skip?.5:1},children:[W+1,". ",c.name]}),c.skip&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:4,fontSize:10},children:d("testBuilder.skipped","SKIPPED")}),c.only&&e.jsx("span",{style:{padding:"2px 6px",background:"color-mix(in srgb, var(--nice-color-accent, #8b5cf6) 19%, transparent)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:d("testBuilder.only","ONLY")}),e.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:l.textMuted},children:c.steps.length!==1?d("testBuilder.stepsMany","{steps} steps").replace("{steps}",String(c.steps.length)):d("testBuilder.stepsOne","{steps} step").replace("{steps}",String(c.steps.length))}),e.jsx("span",{style:{color:l.textMuted},children:e.jsx(a.NiceIcon,{name:K?"chevron-down":"chevron-right",size:14})})]}),K&&e.jsxs("div",{style:{padding:16,borderTop:`1px solid ${l.border}`},children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:l.textMuted,marginBottom:4},children:d("testBuilder.testName","Test Name")}),e.jsx("input",{type:"text",value:c.name,onChange:L=>n(c.id,{name:L.target.value}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.bg,color:l.text,fontSize:12,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:l.textMuted,marginBottom:4},children:d("testBuilder.type","Type")}),e.jsxs("select",{value:c.type,onChange:L=>n(c.id,{type:L.target.value}),style:{padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.bg,color:l.text,fontSize:12},children:[e.jsx("option",{value:"unit",children:d("testBuilder.unit","Unit")}),e.jsx("option",{value:"integration",children:d("testBuilder.integration","Integration")}),e.jsx("option",{value:"e2e",children:"E2E"}),e.jsx("option",{value:"snapshot",children:d("testBuilder.snapshot","Snapshot")}),e.jsx("option",{value:"accessibility",children:"A11y"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:c.skip??!1,onChange:L=>n(c.id,{skip:L.target.checked,only:!1})}),d("testBuilder.skip","Skip")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:c.only??!1,onChange:L=>n(c.id,{only:L.target.checked,skip:!1})}),d("testBuilder.only2","Only")]})]})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:11,color:l.textMuted,marginBottom:8},children:d("testBuilder.steps","Steps")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:c.steps.map((L,v)=>{const E=fe[L.action];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:10,background:l.bg,borderRadius:6,borderLeft:`3px solid ${E.color}`},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontSize:11,color:l.textMuted},children:v+1}),e.jsx("span",{children:e.jsx(a.NiceIcon,{name:E.icon,size:14})}),e.jsx("select",{value:L.action,onChange:P=>x(c.id,L.id,{action:P.target.value}),style:{padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:11},children:Object.entries(fe).map(([P,Q])=>e.jsx("option",{value:P,children:Q.label},P))}),E.hasTarget&&e.jsx("input",{type:"text",value:L.target??"",onChange:P=>x(c.id,L.id,{target:P.target.value}),placeholder:d("testBuilder.targetSelector","Target selector"),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:11}}),E.hasValue&&L.action!=="assert"&&e.jsx("input",{type:"text",value:typeof L.value=="string"?L.value:"",onChange:P=>x(c.id,L.id,{value:P.target.value}),placeholder:d("testBuilder.value","Value"),style:{width:120,padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:11}}),e.jsx("button",{onClick:()=>z(c.id,L.id),"aria-label":d("testBuilder.removeStep","Remove step"),style:{padding:4,borderRadius:4,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(a.NiceIcon,{name:"close",size:14})})]},L.id)})})]}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Object.entries(fe).slice(0,8).map(([L,v])=>e.jsxs("button",{onClick:()=>h(c.id,L),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${v.color}40`,background:`${v.color}20`,color:l.text,cursor:"pointer",fontSize:10},children:[e.jsx(a.NiceIcon,{name:v.icon,size:14})," ",v.label]},L))}),e.jsx("div",{style:{marginTop:16,display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>y(c.id),style:{padding:"6px 12px",borderRadius:4,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:11},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," ",d("testBuilder.deleteTest","Delete Test")]})})]})]},c.id)}),e.jsx("button",{onClick:t,style:{padding:16,borderRadius:8,border:`1px dashed ${l.border}`,background:"transparent",color:l.textMuted,cursor:"pointer",fontSize:13},children:d("testBuilder.addTest","+ Add Test")})]})]}),(T==="code"||T==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--nice-bg-canvas, #0d1117)",borderLeft:T==="split"?`1px solid ${l.border}`:void 0},children:e.jsx("pre",{style:{margin:0,fontFamily:"Consolas, Monaco, monospace",fontSize:12,lineHeight:1.5,color:"var(--nice-text-primary, #e6edf3)",whiteSpace:"pre-wrap"},children:Z})})]})})},Et=Object.freeze(Object.defineProperty({__proto__:null,NiceTestBuilder:Qe},Symbol.toStringTag,{value:"Module"})),At=[],Pt=[{id:"react",name:"React",icon:"settings",description:"React component templates",templates:[{id:"react-component",name:"React Component",description:"Basic React functional component",category:"components",icon:"box",engine:"handlebars",variables:[{id:"componentName",name:"componentName",type:"string",required:!0,defaultValue:"MyComponent"},{id:"withProps",name:"withProps",type:"boolean",defaultValue:!0},{id:"withTests",name:"withTests",type:"boolean",defaultValue:!0},{id:"withStory",name:"withStory",type:"boolean",defaultValue:!1}],files:[{id:"component",name:"{{componentName}}.tsx",path:"src/components/{{componentName}}",language:"typescript",content:`import React from 'react';
226
+ {{#if withProps}}
227
+ export interface {{componentName}}Props {
228
+ children?: React.ReactNode;
229
+ className?: string;
230
+ }
231
+ {{/if}}
232
+
233
+ export const {{componentName}}: React.FC{{#if withProps}}<{{componentName}}Props>{{/if}} = ({{#if withProps}}{ children, className }{{/if}}) => {
234
+ return (
235
+ <div className={className}>
236
+ {children}
237
+ </div>
238
+ );
239
+ };
240
+
241
+ export default {{componentName}};
242
+ `},{id:"test",name:"{{componentName}}.test.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withTests === true",content:`import { render, screen } from '@testing-library/react';
243
+ import { {{componentName}} } from './{{componentName}}';
244
+
245
+ describe('{{componentName}}', () => {
246
+ it('renders children', () => {
247
+ render(<{{componentName}}>Test Content</{{componentName}}>);
248
+ expect(screen.getByText('Test Content')).toBeInTheDocument();
249
+ });
250
+ });
251
+ `},{id:"story",name:"{{componentName}}.stories.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withStory === true",content:`import type { Meta, StoryObj } from '@storybook/react';
252
+ import { {{componentName}} } from './{{componentName}}';
253
+
254
+ const meta: Meta<typeof {{componentName}}> = {
255
+ title: 'Components/{{componentName}}',
256
+ component: {{componentName}},
257
+ };
258
+
259
+ export default meta;
260
+ type Story = StoryObj<typeof {{componentName}}>;
261
+
262
+ export const Default: Story = {
263
+ args: {},
264
+ };
265
+ `},{id:"index",name:"index.ts",path:"src/components/{{componentName}}",language:"typescript",content:`export { {{componentName}} } from './{{componentName}}';
266
+ export type { {{componentName}}Props } from './{{componentName}}';
267
+ `}]}]},{id:"nextjs",name:"Next.js",icon:"play",description:"Next.js page and API templates",templates:[{id:"nextjs-page",name:"Next.js Page",description:"Next.js App Router page",category:"pages",icon:"file",engine:"handlebars",variables:[{id:"pageName",name:"pageName",type:"string",required:!0,defaultValue:"about"},{id:"withMetadata",name:"withMetadata",type:"boolean",defaultValue:!0},{id:"withLoading",name:"withLoading",type:"boolean",defaultValue:!1},{id:"withError",name:"withError",type:"boolean",defaultValue:!1}],files:[{id:"page",name:"page.tsx",path:"app/{{pageName}}",language:"typescript",content:`{{#if withMetadata}}
268
+ import type { Metadata } from 'next';
269
+
270
+ export const metadata: Metadata = {
271
+ title: '{{pageName}}',
272
+ description: '{{pageName}} page',
273
+ };
274
+ {{/if}}
275
+
276
+ export default function {{pascalCase pageName}}Page() {
277
+ return (
278
+ <main>
279
+ <h1>{{pageName}}</h1>
280
+ </main>
281
+ );
282
+ }
283
+ `},{id:"loading",name:"loading.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withLoading === true",content:`export default function Loading() {
284
+ return <div>Loading...</div>;
285
+ }
286
+ `},{id:"error",name:"error.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withError === true",content:`'use client';
287
+
288
+ export default function Error({
289
+ error,
290
+ reset,
291
+ }: {
292
+ error: Error & { digest?: string };
293
+ reset: () => void;
294
+ }) {
295
+ return (
296
+ <div>
297
+ <h2>Something went wrong!</h2>
298
+ <button onClick={reset}>Try again</button>
299
+ </div>
300
+ );
301
+ }
302
+ `}]},{id:"nextjs-api",name:"Next.js API Route",description:"Next.js App Router API handler",category:"api",icon:"plug",engine:"handlebars",variables:[{id:"routeName",name:"routeName",type:"string",required:!0,defaultValue:"users"},{id:"methods",name:"methods",type:"array",defaultValue:["GET","POST"]}],files:[{id:"route",name:"route.ts",path:"app/api/{{routeName}}",language:"typescript",content:`import { NextResponse } from 'next/server';
303
+
304
+ {{#if (includes methods 'GET')}}
305
+ export async function GET() {
306
+ return NextResponse.json({ message: 'GET {{routeName}}' });
307
+ }
308
+ {{/if}}
309
+
310
+ {{#if (includes methods 'POST')}}
311
+ export async function POST(request: Request) {
312
+ const body = await request.json();
313
+ return NextResponse.json({ message: 'POST {{routeName}}', data: body });
314
+ }
315
+ {{/if}}
316
+
317
+ {{#if (includes methods 'PUT')}}
318
+ export async function PUT(request: Request) {
319
+ const body = await request.json();
320
+ return NextResponse.json({ message: 'PUT {{routeName}}', data: body });
321
+ }
322
+ {{/if}}
323
+
324
+ {{#if (includes methods 'DELETE')}}
325
+ export async function DELETE() {
326
+ return NextResponse.json({ message: 'DELETE {{routeName}}' });
327
+ }
328
+ {{/if}}
329
+ `}]}]}],qe=(o,S,f)=>{let b=o;Object.entries(S).forEach(([k,p])=>{const $=new RegExp(`\\{\\{\\s*${k}\\s*\\}\\}`,"g");b=b.replace($,String(p));const i=new RegExp(`\\{\\{\\s*pascalCase\\s+${k}\\s*\\}\\}`,"g");if(typeof p=="string"){const r=p.charAt(0).toUpperCase()+p.slice(1);b=b.replace(i,r)}});const N=/\{\{#if\s+([^}]+)\}\}([\s\S]*?)\{\{\/if\}\}/g;b=b.replace(N,(k,p,$)=>{const i=p.trim(),r=i.match(/(\w+)\s*===?\s*(\w+|true|false|'[^']*'|"[^"]*")/);if(r){const[,C,w]=r,R=S[C];let q=w;return w==="true"?q=!0:w==="false"?q=!1:(w.startsWith("'")||w.startsWith('"'))&&(q=w.slice(1,-1)),R===q?$:""}return S[i]?$:""});const j=/\{\{#if\s+\(includes\s+(\w+)\s+'([^']+)'\)\}\}([\s\S]*?)\{\{\/if\}\}/g;return b=b.replace(j,(k,p,$,i)=>{const r=S[p];return Array.isArray(r)&&r.includes($)?i:""}),b},Ot=(o,S)=>{try{const f=o.split(/\s*(===|!==|==|!=)\s*/);if(f.length===3){const[b,N,j]=f,k=S[b.trim()],p=j.trim();let $=p;switch(p==="true"?$=!0:p==="false"?$=!1:(p.startsWith("'")||p.startsWith('"'))&&($=p.slice(1,-1)),N){case"===":case"==":return k===$;case"!==":case"!=":return k!==$}}return!!S[o.trim()]}catch{return!0}},Xe=({templates:o,defaultTemplates:S,onTemplatesChange:f,presets:b=Pt,selectedTemplate:N,defaultSelectedTemplate:j,onSelectedTemplateChange:k,defaultEngine:p="handlebars",showLibrary:$=!0,onTemplateSelect:i,onTemplateCreate:r,onTemplateUpdate:d,onTemplateDelete:C,onGenerate:w,onExport:R,onImport:q,className:G,style:O,"data-testid":T="nice-code-template"})=>{const{t:I}=a.useNiceTranslation(),H=o!==void 0&&f!==void 0,[M,m]=a.useControllableState({value:H?o:void 0,defaultValue:H?S:S??o,fallbackValue:At,onChange:f,componentName:"NiceCodeTemplate"});de.useIgnoredPropChangeWarning("NiceCodeTemplate","templates","onTemplatesChange",o,H);const D=N!==void 0&&k!==void 0,[A,Y]=a.useControllableState({value:D?N:void 0,defaultValue:D?j:j??N,fallbackValue:null,onChange:k,componentName:"NiceCodeTemplate"});de.useIgnoredPropChangeWarning("NiceCodeTemplate","selectedTemplate","onSelectedTemplateChange",N,D);const[B,Z]=g.useState({}),[F,V]=g.useState("editor"),[s,t]=g.useState(null),[n,y]=g.useState(!1),[h,x]=g.useState(!1),z=g.useMemo(()=>{const v=b.flatMap(E=>E.templates);return[...M,...v]},[M,b]),l=g.useMemo(()=>z.find(v=>v.id===A),[z,A]),ee=g.useMemo(()=>l?.files.find(v=>v.id===s)||l?.files[0],[l,s]);g.useEffect(()=>{if(l){const v={};l.variables.forEach(E=>{v[E.name]=E.defaultValue??""}),Z(v),t(l.files[0]?.id||null)}},[l]);const te=g.useMemo(()=>l?l.files.filter(v=>v.condition?Ot(v.condition,B):!0).map(v=>({path:qe(`${v.path}/${v.name}`,B,l.engine),content:qe(v.content,B,l.engine),language:v.language})):[],[l,B]),u=g.useCallback(v=>{Y(v.id),i?.(v)},[i,Y]),X=g.useCallback(()=>{w?.(te,B)},[te,B,w]),c=g.useCallback(()=>{const v={id:a.createId(),name:"New Template",description:I("codeTemplate.customTemplate","Custom template"),category:"custom",icon:"file",engine:p,variables:[{id:"1",name:"name",type:"string",required:!0,defaultValue:"MyName"}],files:[{id:"1",name:"{{name}}.ts",path:"src",language:"typescript",content:`// {{name}}
330
+ export const {{name}} = {};`}]};m(E=>[...E,v]),Y(v.id),y(!1),r?.(v)},[p,r,m,Y,I]),W=g.useCallback((v,E)=>{if(!l)return;const P={...l,files:l.files.map(Q=>Q.id===v?{...Q,content:E}:Q)};m(Q=>Q.map(ae=>ae.id===P.id?P:ae)),d?.(P)},[l,d,m]),K=g.useCallback(()=>{if(!l)return;const v={id:a.createId(),name:"new-file.ts",path:"src",language:"typescript",content:`// New file
331
+ `},E={...l,files:[...l.files,v]};m(P=>P.map(Q=>Q.id===E.id?E:Q)),t(v.id),d?.(E)},[l,d,m]),J=g.useCallback(v=>{if(!l)return;const E={...l,files:l.files.filter(P=>P.id!==v)};m(P=>P.map(Q=>Q.id===E.id?E:Q)),t(E.files[0]?.id||null),d?.(E)},[l,d,m]),L=v=>{const E=B[v.name];switch(v.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!E,onChange:P=>Z(Q=>({...Q,[v.name]:P.target.checked}))}),e.jsx("span",{children:v.name})]});case"select":return e.jsx("select",{value:String(E),onChange:P=>Z(Q=>({...Q,[v.name]:P.target.value})),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"},children:v.options?.map(P=>e.jsx("option",{value:P,children:P},P))});case"array":return e.jsx("input",{type:"text",value:Array.isArray(E)?E.join(", "):"",onChange:P=>Z(Q=>({...Q,[v.name]:P.target.value.split(",").map(ae=>ae.trim())})),placeholder:I("codeTemplate.value1Value2Value3","value1, value2, value3"),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"}});case"number":return e.jsx("input",{type:"number",value:Number(E),onChange:P=>Z(Q=>({...Q,[v.name]:Number(P.target.value)})),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"}});default:return e.jsx("input",{type:"text",value:String(E??""),onChange:P=>Z(Q=>({...Q,[v.name]:P.target.value})),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"}})}};return e.jsxs("div",{className:`nice-code-template ${G||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",fontFamily:"system-ui, sans-serif",...O},"data-testid":T,children:[$&&e.jsxs("div",{style:{width:280,borderRight:"1px solid var(--nice-border, #30363d)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"book",size:16})," ",I("codeTemplate.templates","Templates")]}),e.jsx("button",{onClick:c,style:{padding:"4px 8px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:4,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:I("codeTemplate.new","+ New")})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[M.length>0&&e.jsxs("div",{style:{padding:8},children:[e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)",padding:"8px 8px 4px",fontWeight:500},children:I("codeTemplate.custom","CUSTOM")}),M.map(v=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,onClick:()=>u(v),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:A===v.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(a.NiceIcon,{name:v.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:v.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:v.category})]})]},v.id))]}),b.map(v=>e.jsxs("div",{style:{padding:8},children:[e.jsxs("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)",padding:"8px 8px 4px",fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:v.icon,size:12}),v.name.toUpperCase()]}),v.templates.map(E=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,onClick:()=>u(E),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:A===E.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(a.NiceIcon,{name:E.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:E.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:E.description})]})]},E.id))]},v.id))]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(a.NiceIcon,{name:l.icon||"file",size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:l.name}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:l.description})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>R?.(l,"json"),style:{padding:"6px 12px",background:"var(--nice-text-secondary, #374151)",border:"none",borderRadius:6,color:"var(--nice-text-inverse, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",I("codeTemplate.export","Export")]}),e.jsxs("button",{onClick:X,style:{padding:"6px 16px",background:"var(--nice-color-success, #22c55e)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," ",I("codeTemplate.generate","Generate")]})]})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)"},children:["variables","editor","preview"].map(v=>e.jsxs("button",{onClick:()=>V(v),style:{padding:"10px 20px",background:F===v?"var(--nice-bg-canvas, #0d1117)":"transparent",border:"none",borderBottom:F===v?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",color:F===v?"var(--nice-text-primary, #fff)":"var(--nice-text-muted, #8b949e)",cursor:"pointer",textTransform:"capitalize"},children:[v==="variables"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," "]}),v==="editor"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"edit",size:14})," "]}),v==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," "]}),v]},v))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[F==="variables"&&e.jsx("div",{style:{flex:1,padding:20,overflow:"auto"},children:e.jsxs("div",{style:{maxWidth:500},children:[e.jsx("h3",{style:{marginBottom:20},children:I("codeTemplate.templateVariables","Template Variables")}),l.variables.map(v=>e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #8b949e)",marginBottom:4},children:[v.name,v.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:" *"})]}),L(v),v.description&&e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #6b7280)",marginTop:4},children:v.description})]},v.id))]})}),F==="editor"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{width:200,borderRight:"1px solid var(--nice-border, #30363d)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border, #30363d)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:I("codeTemplate.files","Files")}),e.jsx("button",{onClick:K,style:{padding:"2px 6px",background:"var(--nice-text-secondary, #374151)",border:"none",borderRadius:4,color:"var(--nice-text-inverse, #fff)",cursor:"pointer",fontSize:12},children:"+"})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:l.files.map(v=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:a.clickOnActivationKey,onClick:()=>t(v.id),style:{padding:"8px 12px",cursor:"pointer",background:s===v.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:s===v.id?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis"},children:v.name}),e.jsx("button",{"aria-label":I("codeTemplate.removeFile","Remove file"),onClick:E=>{E.stopPropagation(),J(v.id)},style:{background:"none",border:"none",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12,opacity:.7,display:"inline-flex",alignItems:"center"},children:e.jsx(a.NiceIcon,{name:"close",size:14})})]},v.id))})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:ee&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)",fontSize:12},children:[ee.path,"/",ee.name,ee.condition&&e.jsx("span",{style:{color:"var(--nice-color-warning, #f59e0b)",marginLeft:8},children:I("codeTemplate.if","(if: {condition})").replace("{condition}",String(ee.condition))})]}),e.jsx("textarea",{value:ee.content,onChange:v=>W(ee.id,v.target.value),style:{flex:1,padding:16,background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",border:"none",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,lineHeight:1.5,resize:"none"}})]})})]}),F==="preview"&&e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)"},children:e.jsx("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:I("codeTemplate.fileSWillBeGenerated","{generatedFiles} file(s) will be generated").replace("{generatedFiles}",String(te.length))})}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:te.map((v,E)=>e.jsxs("div",{style:{borderBottom:"1px solid var(--nice-border, #30363d)"},children:[e.jsxs("div",{style:{padding:"8px 16px",background:"var(--nice-bg-secondary, #1f2937)",fontFamily:"monospace",fontSize:12,color:"var(--nice-text-muted, #8b949e)",display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"file",size:14})," ",v.path]}),e.jsx("pre",{style:{margin:0,padding:16,background:"var(--nice-bg-canvas, #0d1117)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:12,lineHeight:1.5,overflow:"auto"},children:v.content})]},E))})]})]})]}):e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #8b949e)"},children:[e.jsx("span",{style:{marginBottom:16},children:e.jsx(a.NiceIcon,{name:"book",size:64})}),e.jsx("span",{style:{fontSize:18},children:I("codeTemplate.selectATemplate","Select a template")}),e.jsx("span",{style:{fontSize:12,marginTop:4},children:I("codeTemplate.chooseFromTheLibraryOr","Choose from the library or create a new template")}),e.jsxs("button",{onClick:c,style:{marginTop:20,padding:"10px 20px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"plus",size:14})," ",I("codeTemplate.createTemplate","Create Template")]})]})})]})},Lt=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeTemplate:Xe},Symbol.toStringTag,{value:"Module"}));exports.NiceAPIFlow=Ge;exports.NiceAPIFlow$1=kt;exports.NiceCheckbox=we;exports.NiceCheckbox$1=at;exports.NiceCodePreview=He;exports.NiceCodeTemplate=Xe;exports.NiceCodeTemplate$1=Lt;exports.NiceComponentDesigner=xt;exports.NiceDataMapper=Ye;exports.NiceDataMapper$1=Ct;exports.NiceEventOrchestrator=Ze;exports.NiceEventOrchestrator$1=Rt;exports.NiceLowCodeStudio=mt;exports.NiceNumberInput=ke;exports.NiceNumberInput$1=st;exports.NicePageBuilder=ft;exports.NiceStateDesigner=We;exports.NiceStateDesigner$1=jt;exports.NiceTestBuilder=Qe;exports.NiceTestBuilder$1=Et;exports.NiceTextInput=Ne;exports.NiceTextInput$1=lt;