@nice2dev/ui 1.0.28 → 1.0.30

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 (107) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/NiceAssessment.doc-BB1rXcVx.cjs +1 -0
  3. package/dist/NiceAssessment.doc-C3QQawiZ.js +23 -0
  4. package/dist/NiceBackupStatusBadge.doc-Bx2bFmBQ.cjs +1 -0
  5. package/dist/NiceBackupStatusBadge.doc-CdDxIQ-M.js +25 -0
  6. package/dist/NiceConfirmDialog-BiTJVR4-.js +81 -0
  7. package/dist/NiceConfirmDialog-Bjw_rN4o.cjs +1 -0
  8. package/dist/NiceConfirmDialog-DPfYwO2B.js +81 -0
  9. package/dist/NiceConfirmDialog-Dyh42OiK.cjs +1 -0
  10. package/dist/NiceErrorBoundary-1H751jK7.cjs +1 -0
  11. package/dist/NiceErrorBoundary-B-txoU3Y.js +709 -0
  12. package/dist/NiceErrorBoundary-BHCKA1h8.cjs +1 -0
  13. package/dist/NiceErrorBoundary-CBxXcleR.js +695 -0
  14. package/dist/NiceExam.doc-BpTJpwGb.js +23 -0
  15. package/dist/NiceExam.doc-Br8pEbQb.cjs +1 -0
  16. package/dist/NiceForm-C8yEx3VV.cjs +382 -0
  17. package/dist/NiceForm-Ci3XG7s7.js +5000 -0
  18. package/dist/NiceForm-DGUTmaZT.js +5014 -0
  19. package/dist/NiceForm-DmU-gmyv.cjs +382 -0
  20. package/dist/NiceModal-BClAtR5T.js +95 -0
  21. package/dist/NiceModal-Crbhc7GB.cjs +1 -0
  22. package/dist/NiceModal-XvEKVVLa.js +95 -0
  23. package/dist/NiceModal-iKwtagFB.cjs +1 -0
  24. package/dist/NiceModuleLifecyclePanel-BO8Hw_W9.js +7619 -0
  25. package/dist/NiceModuleLifecyclePanel-Ch7HRRoy.cjs +1 -0
  26. package/dist/NiceModuleLifecyclePanel-D3k8kAey.js +7582 -0
  27. package/dist/NiceModuleLifecyclePanel-MAyTh_s5.cjs +1 -0
  28. package/dist/NicePagination-BVo-4KAD.js +172 -0
  29. package/dist/NicePagination-CaohvQsY.cjs +1 -0
  30. package/dist/NicePagination-DUnMbROj.cjs +1 -0
  31. package/dist/NicePagination-DyC6dQ7_.js +171 -0
  32. package/dist/NicePinCodeInput-C43eB9h4.js +13102 -0
  33. package/dist/NicePinCodeInput-DsyLuc0b.cjs +696 -0
  34. package/dist/NicePinCodeInput-nuRCN-9R.js +13223 -0
  35. package/dist/NicePinCodeInput-p5IFVwfY.cjs +696 -0
  36. package/dist/NicePoll.doc-DCiXvOb0.js +23 -0
  37. package/dist/NicePoll.doc-IOgqVPhc.cjs +1 -0
  38. package/dist/NicePollLive.doc-CdUyiCyf.js +23 -0
  39. package/dist/NicePollLive.doc-xBMqHeyt.cjs +1 -0
  40. package/dist/NiceQuiz.doc-BhAeGrcP.cjs +1 -0
  41. package/dist/NiceQuiz.doc-BiZq8X1P.js +23 -0
  42. package/dist/NiceSavedQueryPanel-BBFV4qiF.js +6969 -0
  43. package/dist/NiceSavedQueryPanel-CsiVNkCT.cjs +596 -0
  44. package/dist/NiceSavedQueryPanel-DV4a4axz.cjs +596 -0
  45. package/dist/NiceSavedQueryPanel-Dgbn1ExK.js +6893 -0
  46. package/dist/NiceSurvey.doc-9UorYdXy.cjs +1 -0
  47. package/dist/NiceSurvey.doc-CPF1ZEHo.js +23 -0
  48. package/dist/NiceWindow-BehN3PKk.js +1592 -0
  49. package/dist/NiceWindow-Cm9E6EAi.cjs +1 -0
  50. package/dist/NiceWindow-Dqu9ik8A.cjs +1 -0
  51. package/dist/NiceWindow-FMrVS7zo.js +1603 -0
  52. package/dist/charts-B90sSFeJ.cjs +761 -0
  53. package/dist/charts-CJruxLRY.js +4657 -0
  54. package/dist/charts-D8oj6Nf5.cjs +761 -0
  55. package/dist/charts-DaLf19vS.js +4671 -0
  56. package/dist/charts.cjs +1 -1
  57. package/dist/charts.mjs +1 -1
  58. package/dist/core-BIdbG6p3.js +27212 -0
  59. package/dist/core-BUTtIHg0.js +27766 -0
  60. package/dist/core-CESNSRyS.cjs +122 -0
  61. package/dist/core-bzK0ZnUp.cjs +122 -0
  62. package/dist/data-branching-ByQdcjKO.cjs +1 -0
  63. package/dist/data-branching-BzRFsCJu.js +6133 -0
  64. package/dist/data-branching-DahoQa4M.cjs +1 -0
  65. package/dist/data-branching-psTzlcrT.js +6255 -0
  66. package/dist/data-branching.cjs +1 -1
  67. package/dist/data-branching.mjs +1 -1
  68. package/dist/data.cjs +1 -1
  69. package/dist/data.mjs +1 -1
  70. package/dist/devops-C9gdQxuU.cjs +17 -0
  71. package/dist/devops-CaO_4qGz.js +7684 -0
  72. package/dist/devops-D7bQ3rE4.cjs +17 -0
  73. package/dist/devops-jCmpD6O-.js +8165 -0
  74. package/dist/devops.cjs +1 -1
  75. package/dist/devops.mjs +3 -3
  76. package/dist/editors.cjs +1 -1
  77. package/dist/editors.d.ts +4 -0
  78. package/dist/editors.mjs +3 -3
  79. package/dist/feedback.cjs +1 -1
  80. package/dist/feedback.mjs +3 -3
  81. package/dist/index-BK_Uwmz0.js +67774 -0
  82. package/dist/index-BpixglWg.js +69337 -0
  83. package/dist/index-CTbp81RF.cjs +5517 -0
  84. package/dist/index-DLR-aWZR.cjs +5506 -0
  85. package/dist/index.cjs +1 -1
  86. package/dist/index.css +1 -1
  87. package/dist/index.d.ts +796 -545
  88. package/dist/index.mjs +992 -979
  89. package/dist/lazy.cjs +1 -1
  90. package/dist/lazy.mjs +24 -24
  91. package/dist/navigation.cjs +1 -1
  92. package/dist/navigation.mjs +146 -146
  93. package/dist/no-code-B0mG7OQc.cjs +332 -0
  94. package/dist/no-code-BHo5WrXr.js +7425 -0
  95. package/dist/no-code-CikRvKeJ.js +7133 -0
  96. package/dist/no-code-DyA_1_Th.cjs +332 -0
  97. package/dist/no-code.cjs +1 -1
  98. package/dist/no-code.mjs +1 -1
  99. package/dist/overlays.cjs +1 -1
  100. package/dist/overlays.d.ts +4 -0
  101. package/dist/overlays.mjs +66 -66
  102. package/dist/pickerCommons-BEc3pZ_s.js +2044 -0
  103. package/dist/pickerCommons-CqhXp4QL.js +2043 -0
  104. package/dist/pickerCommons-CrITwM88.cjs +1 -0
  105. package/dist/pickerCommons-OsYJhnFE.cjs +1 -0
  106. package/dist/style.css +1 -1
  107. package/package.json +3 -3
@@ -0,0 +1,332 @@
1
+ "use strict";const e=require("react/jsx-runtime"),s=require("./core-CESNSRyS.cjs"),y=require("react"),te=require("./devops-D7bQ3rE4.cjs"),Se=[{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"}],ke=({projectId:a,components:f=[],theme:j="light",onChange:b,onSave:T,className:v,tutorial:k})=>{const[d,C]=y.useState("design");return e.jsx(te.NiceAppShell,{flush:!0,className:`nice-lowcode-studio nice-lowcode-studio--${j} ${v||""}`,menubar:e.jsxs("header",{className:"nice-lowcode-studio__header",children:[e.jsx("h1",{children:"Low-Code Studio"}),e.jsxs("nav",{className:"nice-lowcode-studio__tabs",children:[e.jsx("button",{onClick:()=>C("design"),className:d==="design"?"active":"",children:"Design"}),e.jsx("button",{onClick:()=>C("preview"),className:d==="preview"?"active":"",children:"Preview"}),e.jsx("button",{onClick:()=>C("code"),className:d==="code"?"active":"",children:"Code"})]}),e.jsx("button",{onClick:()=>T?.({}),children:"Save"}),e.jsx(s.Yl,{steps:s.Jl(k,Se)})]}),sidebar:e.jsxs("aside",{className:"nice-lowcode-studio__sidebar",children:[e.jsx("h2",{children:"Components"}),e.jsx("ul",{children:f.map(n=>e.jsx("li",{draggable:!0,children:n.name},n.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-lowcode-studio__properties",children:[e.jsx("h2",{children:"Properties"}),e.jsx("p",{children:"Select a component to edit properties"})]}),children:e.jsxs("main",{className:"nice-lowcode-studio__canvas","data-project":a,children:[d==="design"&&e.jsx("div",{className:"nice-lowcode-studio__design-canvas",children:e.jsx("p",{children:"Drop components here"})}),d==="preview"&&e.jsx("div",{className:"nice-lowcode-studio__preview",children:e.jsx("p",{children:"Preview mode"})}),d==="code"&&e.jsx("div",{className:"nice-lowcode-studio__code",children:e.jsx("pre",{children:"// Generated code will appear here"})})]})})},we=[{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"}],$e=({component:a,propTypes:f=[],onChange:j,theme:b="light",className:T,tutorial:v})=>{const[k,d]=y.useState(a||{name:"NewComponent",props:[]}),C=n=>{const c={...k,...n};d(c),j?.(c)};return e.jsxs("div",{className:`nice-component-designer nice-component-designer--${b} ${T||""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(s.Yl,{steps:s.Jl(v,we)})}),e.jsxs("section",{className:"nice-component-designer__header",children:[e.jsx("input",{type:"text",value:k.name,onChange:n=>C({name:n.target.value}),placeholder:"Component Name"}),e.jsx("input",{type:"text",value:k.description||"",onChange:n=>C({description:n.target.value}),placeholder:"Description"})]}),e.jsxs("section",{className:"nice-component-designer__props",children:[e.jsx("h3",{children:"Props"}),k.props.map((n,c)=>e.jsxs("div",{className:"nice-component-designer__prop",children:[e.jsx("input",{type:"text",value:n.name,readOnly:!0}),e.jsx("span",{children:n.type}),n.required&&e.jsx("span",{children:"required"})]},c)),e.jsx("button",{onClick:()=>C({props:[...k.props,{name:"newProp",type:"string"}]}),children:"Add Prop"})]}),e.jsxs("section",{className:"nice-component-designer__preview",children:[e.jsx("h3",{children:"Preview"}),e.jsx("pre",{children:`interface ${k.name}Props {
2
+ ${k.props.map(n=>` ${n.name}${n.required?"":"?"}: ${n.type};`).join(`
3
+ `)}
4
+ }
5
+
6
+ export const ${k.name}: React.FC<${k.name}Props> = (props) => {
7
+ return <div>Component</div>;
8
+ };`})]})]})},ze=[{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"}],Ce=({initialLayout:a,components:f=[],grid:j={columns:12,gap:16,padding:24},onChange:b,onSave:T,theme:v="light",previewMode:k="desktop",className:d,tutorial:C})=>{const[n,c]=y.useState(a||{id:"page-1",name:"New Page",rows:[]}),[$,M]=y.useState(null),w=B=>{c(B),b?.(B)},q=()=>{const B={id:`row-${Date.now()}`,columns:[{id:`col-${Date.now()}`,width:12,components:[]}]};w({...n,rows:[...n.rows,B]})},A={desktop:"100%",tablet:"768px",mobile:"375px"}[k];return e.jsx(te.NiceAppShell,{flush:!0,className:`nice-page-builder nice-page-builder--${v} ${d||""}`,toolbar:e.jsxs("header",{className:"nice-page-builder__toolbar",children:[e.jsx("input",{type:"text",value:n.name,onChange:B=>w({...n,name:B.target.value})}),e.jsxs("div",{className:"nice-page-builder__preview-modes",children:[e.jsx("button",{className:k==="desktop"?"active":"",children:"Desktop"}),e.jsx("button",{className:k==="tablet"?"active":"",children:"Tablet"}),e.jsx("button",{className:k==="mobile"?"active":"",children:"Mobile"})]}),e.jsx("button",{onClick:()=>T?.(n),children:"Save"}),e.jsx(s.Yl,{steps:s.Jl(C,ze)})]}),sidebar:e.jsxs("aside",{className:"nice-page-builder__sidebar",children:[e.jsx("h3",{children:"Components"}),e.jsx("ul",{className:"nice-page-builder__components",children:f.map(B=>e.jsxs("li",{draggable:!0,className:"nice-page-builder__component-item",children:[B.icon&&e.jsx("span",{children:B.icon}),B.name]},B.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-page-builder__properties",children:[e.jsx("h3",{children:"Properties"}),$?e.jsx("p",{children:"Edit properties for selected component"}):e.jsx("p",{children:"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:A},children:[n.rows.map(B=>e.jsx("div",{className:"nice-page-builder__row",children:B.columns.map(N=>e.jsx("div",{className:"nice-page-builder__column",style:{width:`${N.width/12*100}%`},children:N.components.length===0?e.jsx("div",{className:"nice-page-builder__dropzone",children:"Drop components here"}):N.components.map(W=>e.jsx("div",{className:`nice-page-builder__placed-component ${$===W.id?"selected":""}`,onClick:()=>M(W.id),children:W.type},W.id))},N.id))},B.id)),e.jsx("button",{onClick:q,className:"nice-page-builder__add-row",children:"+ Add Row"})]})})})},Te=({code:a,language:f="typescript",lineNumbers:j=!0,livePreview:b=!1,showDiff:T=!1,previousCode:v,theme:k="light",copyable:d=!0,onCopy:C,className:n})=>{const[c,$]=y.useState(!1),M=async()=>{await navigator.clipboard.writeText(a),$(!0),C?.(),setTimeout(()=>$(!1),2e3)},w=a.split(`
9
+ `),q=()=>e.jsx("div",{className:"nice-code-preview__line-numbers",children:w.map((W,O)=>e.jsx("span",{children:O+1},O))}),A=()=>e.jsx("pre",{className:`nice-code-preview__code language-${f}`,children:e.jsx("code",{children:a})}),B=()=>v?(v.split(`
10
+ `),a.split(`
11
+ `),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:"Previous"}),e.jsx("pre",{children:v})]}),e.jsxs("div",{className:"nice-code-preview__diff-panel nice-code-preview__diff-panel--new",children:[e.jsx("h4",{children:"Current"}),e.jsx("pre",{children:a})]})]})):null,N=()=>f!=="html"&&f!=="jsx"&&f!=="tsx"?e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("p",{children:"Live preview only available for HTML, JSX, and TSX"})}):e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("iframe",{srcDoc:f==="html"?a:'<div id="root"></div><script>/* Preview not available for JSX */<\/script>',title:"Live Preview",sandbox:"allow-scripts"})});return e.jsxs("div",{className:`nice-code-preview nice-code-preview--${k} ${n||""}`,children:[e.jsxs("header",{className:"nice-code-preview__header",children:[e.jsx("span",{className:"nice-code-preview__language",children:f}),d&&e.jsx("button",{onClick:M,className:"nice-code-preview__copy-btn",children:c?e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"check",size:14})," Copied"]}):"Copy"})]}),T&&v?B():e.jsxs("div",{className:"nice-code-preview__body",children:[j&&q(),A()]}),b&&e.jsxs("div",{className:"nice-code-preview__preview-section",children:[e.jsx("h4",{children:"Preview"}),N()]})]})},Re=[{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"}],Ne={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}},Be=[{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:[]}]}}],re={string:"edit",number:"hash",boolean:"check",array:"clipboard",object:"box",date:"calendar",enum:"bar-chart",custom:"settings"},ne=a=>{const f=["import { create } from 'zustand'"];a.middleware?.some(n=>n.type==="devtools"&&n.enabled)&&f.push("import { devtools } from 'zustand/middleware'"),a.middleware?.some(n=>n.type==="persist"&&n.enabled)&&f.push("import { persist } from 'zustand/middleware'"),a.middleware?.some(n=>n.type==="immer"&&n.enabled)&&f.push("import { immer } from 'zustand/middleware/immer'");const j=[];a.slices.forEach(n=>{j.push(`interface ${ae(n.name)}State {`),n.state.forEach(c=>{const $=oe(c.type,c.nullable);j.push(` ${c.name}: ${$};`)}),j.push("}"),j.push("")}),j.push("interface Actions {"),a.slices.forEach(n=>{n.actions.forEach(c=>{const $=c.params.map(w=>`${w.name}: ${oe(w.type)}`).join(", "),M=c.async?"Promise<void>":"void";j.push(` ${c.name}: (${$}) => ${M};`)})}),j.push("}");const b=a.slices.map(n=>`${ae(n.name)}State`).join(" & ");j.push(""),j.push(`type StoreState = ${b} & Actions;`);const T=[];a.slices.forEach(n=>{n.state.forEach(c=>{const $=c.defaultValue!==void 0?JSON.stringify(c.defaultValue):c.nullable?"null":ue(c.type);T.push(` ${c.name}: ${$},`)})});const v=[];a.slices.forEach(n=>{n.actions.forEach(c=>{const $=c.params.map(w=>w.name).join(", "),M=c.async?"async ":"";v.push(` ${c.name}: ${M}(${$}) => {`),c.async?(v.push(" set({ loading: true, error: null });"),v.push(" try {"),v.push(" // TODO: API call"),v.push(` // const response = await api.${c.name}(${$});`),c.reducerSteps.forEach(w=>{w.type==="set"&&v.push(` set({ ${w.field}: ${w.value} });`)}),v.push(" } catch (error) {"),v.push(" set({ error: error.message, loading: false });"),v.push(" }")):(v.push(" set((state) => {"),c.reducerSteps.forEach(w=>{w.type==="set"?v.push(` state.${w.field} = ${w.value};`):w.type==="push"?v.push(` state.${w.field}.push(${w.value});`):w.type==="reset"&&v.push(` state.${w.field} = null;`)}),v.push(" });")),v.push(" },")})});let k="",d="";if(a.middleware?.some(n=>n.type==="immer"&&n.enabled)&&(k+="immer(",d=")"+d),a.middleware?.some(n=>n.type==="devtools"&&n.enabled)&&(k+="devtools(",d=`, { name: '${a.devtools?.name||a.name}' })`+d),a.persist?.enabled){k+="persist(";const n=[`name: '${a.persist.key}'`];a.persist.whitelist&&n.push(`partialize: (state) => ({ ${a.persist.whitelist.map(c=>c.split(".").pop()).join(", ")} })`),d=`, { ${n.join(", ")} })`+d}return`${f.join(`
12
+ `)}
13
+
14
+ // Types
15
+ ${j.join(`
16
+ `)}
17
+
18
+ // Store
19
+ export const use${a.name} = create<StoreState>()(
20
+ ${k}(set, get) => ({
21
+ // Initial State
22
+ ${T.join(`
23
+ `)}
24
+
25
+ // Actions
26
+ ${v.join(`
27
+ `)}
28
+ })${d}
29
+ );
30
+
31
+ // Selectors
32
+ ${a.slices.flatMap(n=>n.selectors.map(c=>`export const ${c.name} = (state: StoreState) => ${c.expression.replace("state.","state.")};`)).join(`
33
+ `)}
34
+ `},ae=a=>a.charAt(0).toUpperCase()+a.slice(1),oe=(a,f)=>{const j={string:"string",number:"number",boolean:"boolean",array:"unknown[]",object:"Record<string, unknown>",date:"Date",enum:"string",custom:"unknown"}[a];return f?`${j} | null`:j},ue=a=>({string:"''",number:"0",boolean:"false",array:"[]",object:"{}",date:"new Date()",enum:"''",custom:"null"})[a],me=({store:a=Ne,templates:f=Be,onStoreChange:j,onExport:b,onSave:T,tutorial:v,className:k,style:d,"data-testid":C})=>{const[n,c]=y.useState(a),[$,M]=y.useState("slices"),[w,q]=y.useState(n.slices[0]?.id||null),[A,B]=y.useState(null),[N,W]=y.useState("zustand"),[O,L]=y.useState(!1),[m,E]=y.useState(null),[P,U]=y.useState(""),[I,J]=y.useState("string"),F=y.useMemo(()=>n.slices.find(p=>p.id===w),[n.slices,w]),V=y.useCallback(p=>{const l={...n,...p};c(l),j?.(l)},[n,j]),g=()=>{const p={id:`slice-${Date.now()}`,name:"newSlice",state:[],actions:[],selectors:[]};V({slices:[...n.slices,p]}),q(p.id)},t=()=>{if(!F||!P)return;const p={id:`field-${Date.now()}`,name:P,type:I,defaultValue:ue(I).replace(/'/g,"")},l=n.slices.map(o=>o.id===F.id?{...o,state:[...o.state,p]}:o);V({slices:l}),U("")},r=()=>{if(!F)return;const p={id:`action-${Date.now()}`,name:"newAction",params:[],reducerSteps:[]},l=n.slices.map(o=>o.id===F.id?{...o,actions:[...o.actions,p]}:o);V({slices:l}),B(p.id)},x=y.useCallback(()=>{let p="";N==="zustand"?p=ne(n):p=`// Export for ${N} coming soon...
35
+ // Store: ${n.name}`,b?.(p,N)},[n,N,b]),h=y.useMemo(()=>N==="zustand"?ne(n):`// ${N} export coming soon...`,[n,N]),i={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",accent:"var(--color-primary, #3b82f6)"},S=e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${i.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(s.oa,{name:"folder",size:16})," State Designer"]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsx("input",{type:"text",value:n.name,onChange:p=>V({name:p.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:14,fontWeight:600}})}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(s.Yl,{steps:s.Jl(v,Re)}),e.jsxs("button",{onClick:()=>L(!0),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"clipboard",size:14})," Templates"]}),e.jsxs("button",{onClick:()=>T?.(n),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(s.oa,{name:"save",size:14})," Save"]})]})]}),u=e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${i.border}`,padding:"0 20px"},children:["slices","actions","selectors","settings","preview"].map(p=>e.jsxs("button",{onClick:()=>M(p),style:{padding:"12px 20px",border:"none",background:"transparent",color:$===p?i.text:i.textMuted,cursor:"pointer",fontSize:13,fontWeight:$===p?600:400,borderBottom:$===p?`2px solid ${i.accent}`:"2px solid transparent",marginBottom:-1},children:[p==="slices"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"box",size:14})," Slices"]}),p==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"zap",size:14})," Actions"]}),p==="selectors"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"target",size:14})," Selectors"]}),p==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"settings",size:14})," Settings"]}),p==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"eye",size:14})," Preview"]})]},p))}),X=$==="slices"||$==="actions"||$==="selectors"?e.jsxs("div",{style:{width:200,borderRight:`1px solid ${i.border}`,padding:12,display:"flex",flexDirection:"column",gap:8,height:"100%",boxSizing:"border-box"},children:[e.jsx("div",{style:{fontSize:11,color:i.textMuted,marginBottom:4},children:"SLICES"}),n.slices.map(p=>e.jsxs("button",{onClick:()=>q(p.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:w===p.id?i.accent+"30":i.cardBg,color:i.text,cursor:"pointer",textAlign:"left",fontSize:13},children:[e.jsx(s.oa,{name:"box",size:14})," ",p.name,e.jsxs("div",{style:{fontSize:10,color:i.textMuted},children:[p.state.length," fields • ",p.actions.length," actions"]})]},p.id)),e.jsx("button",{onClick:g,style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${i.border}`,background:"transparent",color:i.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Slice"})]}):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(te.NiceAppShell,{flush:!0,className:`nice-state-designer ${k||""}`,style:{background:i.bg,color:i.text,fontFamily:"system-ui, sans-serif",...d},"data-testid":C,menubar:S,toolbar:u,sidebar:X,children:e.jsxs("div",{style:{height:"100%",overflow:"auto",padding:20,boxSizing:"border-box"},children:[$==="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(s.oa,{name:"box",size:16})," ",F.name]}),e.jsx("input",{type:"text",value:F.name,onChange:p=>{const l=n.slices.map(o=>o.id===F.id?{...o,name:p.target.value}:o);V({slices:l})},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:13}})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{fontSize:12,color:i.textMuted,marginBottom:12},children:["STATE FIELDS (",F.state.length,")"]}),e.jsxs("div",{style:{border:`1px solid ${i.border}`,borderRadius:8,overflow:"hidden"},children:[F.state.map(p=>e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${i.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx(s.oa,{name:re[p.type],size:14}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontFamily:"monospace"},children:p.name}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted},children:[p.type,p.nullable&&"?",p.defaultValue!==void 0&&` = ${JSON.stringify(p.defaultValue)}`]})]}),e.jsx("button",{onClick:()=>{const l=n.slices.map(o=>o.id===F.id?{...o,state:o.state.filter(z=>z.id!==p.id)}:o);V({slices:l})},"aria-label":"Delete",style:{padding:4,border:"none",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(s.oa,{name:"trash",size:14})})]},p.id)),e.jsxs("div",{style:{padding:"12px 16px",display:"flex",alignItems:"center",gap:8,background:i.cardBg},children:[e.jsx("input",{type:"text",placeholder:"fieldName",value:P,onChange:p=>U(p.target.value),style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13,fontFamily:"monospace"}}),e.jsx("select",{value:I,onChange:p=>J(p.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13},children:Object.keys(re).map(p=>e.jsx("option",{value:p,children:p},p))}),e.jsx("button",{onClick:t,disabled:!P,style:{padding:"8px 16px",borderRadius:4,border:"none",background:P?i.accent:i.border,color:"var(--bg-primary, #fff)",cursor:P?"pointer":"not-allowed",fontSize:13},children:"+ Add"})]})]})]})]}),$==="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(s.oa,{name:"zap",size:16})," Actions for ",F.name]}),e.jsx("button",{onClick:r,style:{padding:"6px 12px",borderRadius:4,border:"none",background:i.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Action"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:F.actions.map(p=>e.jsxs("div",{style:{padding:16,background:i.cardBg,borderRadius:8,border:`1px solid ${A===p.id?i.accent:i.border}`,cursor:"pointer"},onClick:()=>B(p.id),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:p.name}),p.async&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:"async"}),e.jsxs("span",{style:{fontSize:11,color:i.textMuted},children:["(",p.params.map(l=>`${l.name}: ${l.type}`).join(", "),")"]})]}),p.description&&e.jsx("div",{style:{fontSize:12,color:i.textMuted,marginTop:4},children:p.description}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted,marginTop:8},children:[p.reducerSteps.length," reducer steps"]})]},p.id))})]}),$==="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(s.oa,{name:"target",size:16})," Selectors for ",F.name]})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:F.selectors.map(p=>e.jsxs("div",{style:{padding:16,background:i.cardBg,borderRadius:8,border:`1px solid ${i.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:p.name}),p.memoized&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-success-tint-12, #22c55e20)",color:"var(--color-success, #22c55e)",borderRadius:4,fontSize:10},children:"memoized"})]}),e.jsx("code",{style:{display:"block",marginTop:8,padding:8,background:i.bg,borderRadius:4,fontSize:12,color:"var(--color-warning, #f59e0b)"},children:p.expression})]},p.id))})]}),$==="settings"&&e.jsxs("div",{style:{maxWidth:600},children:[e.jsx("h4",{style:{marginTop:0},children:"Middleware"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:n.middleware?.map(p=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:12,background:i.cardBg,borderRadius:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p.enabled,onChange:l=>{const o=n.middleware?.map(z=>z.type===p.type?{...z,enabled:l.target.checked}:z);V({middleware:o})}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,textTransform:"capitalize"},children:p.type}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted},children:[p.type==="immer"&&"Enable immutable state updates",p.type==="devtools"&&"Redux DevTools integration",p.type==="persist"&&"Persist state to storage"]})]})]},p.type))}),n.persist?.enabled&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"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:i.textMuted,marginBottom:4},children:"Storage Key"}),e.jsx("input",{type:"text",value:n.persist.key,onChange:p=>V({persist:{...n.persist,key:p.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:13,width:"100%",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:i.textMuted,marginBottom:4},children:"Storage Type"}),e.jsxs("select",{value:n.persist.storage,onChange:p=>V({persist:{...n.persist,storage:p.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.cardBg,color:i.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"})]})]})]})]})]}),$==="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:N,onChange:p=>W(p.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:13},children:[e.jsx("option",{value:"zustand",children:"Zustand"}),e.jsx("option",{value:"redux-toolkit",children:"Redux Toolkit"}),e.jsx("option",{value:"jotai",children:"Jotai"}),e.jsx("option",{value:"recoil",children:"Recoil"}),e.jsx("option",{value:"mobx",children:"MobX"})]}),e.jsxs("button",{onClick:x,style:{padding:"8px 16px",borderRadius:4,border:"none",background:i.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(h),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"clipboard",size:14})," Copy"]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:i.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:h})]})]})}),O&&e.jsx("div",{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:()=>L(!1),children:e.jsxs("div",{style:{background:i.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},onClick:p=>p.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"clipboard",size:16})," State Templates"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:f.map(p=>e.jsx("button",{onClick:()=>{p.store.slices&&V({slices:[...n.slices,...p.store.slices]}),L(!1)},style:{padding:16,borderRadius:8,border:`1px solid ${i.border}`,background:i.bg,color:i.text,cursor:"pointer",textAlign:"left"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.oa,{name:p.icon,size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600},children:p.name}),e.jsx("div",{style:{fontSize:12,color:i.textMuted},children:p.description})]})]})},p.id))})]})})]})},Ee=Object.freeze(Object.defineProperty({__proto__:null,NiceStateDesigner:me},Symbol.toStringTag,{value:"Module"})),Me={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}},Y={GET:"var(--color-success, #22c55e)",POST:"var(--color-primary, #3b82f6)",PUT:"var(--color-warning, #f59e0b)",PATCH:"var(--color-accent, #8b5cf6)",DELETE:"var(--color-error, #ef4444)",HEAD:"var(--text-muted, #6b7280)",OPTIONS:"var(--text-muted, #6b7280)"},De=a=>{const f=["import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';"],j=[];a.endpoints.forEach(d=>{d.body?.schema&&j.push(`export interface ${Z(d.name)}Request ${ge(d.body.schema)}`),j.push(`export interface ${Z(d.name)}Response {
36
+ // TODO: Define response type based on schema
37
+ data: unknown;
38
+ }`)});const b=[];a.endpoints.forEach(d=>{const C=d.pathParams?.map(A=>`${A.name}: ${A.type}`).join(", ")||"",n=d.queryParams?.length?`params?: { ${d.queryParams.map(A=>`${A.name}${A.required?"":"?"}: ${A.type}`).join("; ")} }`:"",c=d.body?`data: ${Z(d.name)}Request`:"",$=[C,n,c].filter(Boolean).join(", ");let M=`'${d.path}'`;d.pathParams?.forEach(A=>{M=M.replace(`{${A.name}}`,`\${${A.name}}`)}),d.pathParams?.length&&(M="`"+M.slice(1,-1)+"`");const w=d.cache?.enabled?`
39
+ // Cache: ${d.cache.strategy}, TTL: ${d.cache.ttl}s`:"",q=d.retry?.enabled?`
40
+ // Retry: ${d.retry.maxAttempts} attempts, ${d.retry.backoff} backoff`:"";b.push(`
41
+ /**
42
+ * ${d.description||d.name}${w}${q}
43
+ */
44
+ async ${d.name}(${$}): Promise<${Z(d.name)}Response> {
45
+ const response = await this.client.${d.method.toLowerCase()}<${Z(d.name)}Response>(
46
+ ${M}${d.queryParams?.length?", { params }":""}${d.body?", data":""}
47
+ );
48
+ return response.data;
49
+ }`)});let T="";a.auth?.type==="bearer"&&(T=`
50
+ // Auth interceptor
51
+ this.client.interceptors.request.use((config) => {
52
+ const token = ${a.auth.tokenSource||"getToken()"};
53
+ if (token) {
54
+ config.headers['${a.auth.headerName||"Authorization"}'] = '${a.auth.prefix||"Bearer"} ' + token;
55
+ }
56
+ return config;
57
+ });`);const v=a.errorHandling?.globalErrorHandler?`
58
+ // Error interceptor
59
+ this.client.interceptors.response.use(
60
+ (response) => response,
61
+ (error) => {
62
+ // Transform and handle errors
63
+ const message = error.response?.data?.message || error.message;
64
+ console.error('[API Error]', message);
65
+ return Promise.reject(error);
66
+ }
67
+ );`:"";return`${f.join(`
68
+ `)}
69
+
70
+ // Types
71
+ ${j.join(`
72
+
73
+ `)}
74
+
75
+ // API Client
76
+ export class ${a.name} {
77
+ private client: AxiosInstance;
78
+
79
+ constructor(baseURL: string = '${a.baseUrl}') {
80
+ this.client = axios.create({
81
+ baseURL,
82
+ headers: ${JSON.stringify(a.globalHeaders||{},null,8).replace(/\n/g,`
83
+ `)},
84
+ });
85
+ ${T}${v}
86
+ }
87
+ ${b.join("")}
88
+ }
89
+
90
+ // Default instance
91
+ export const ${a.name.charAt(0).toLowerCase()+a.name.slice(1)} = new ${a.name}();
92
+ `},Z=a=>a.charAt(0).toUpperCase()+a.slice(1),ge=a=>a.type==="object"&&a.properties?`{
93
+ ${Object.entries(a.properties).map(([j,b])=>{const T=a.required?.includes(j)?"":"?";return` ${j}${T}: ${xe(b)};`}).join(`
94
+ `)}
95
+ }`:"{}",xe=a=>{switch(a.type){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return a.items?`${xe(a.items)}[]`:"unknown[]";case"object":return a.properties?ge(a):"Record<string, unknown>";default:return"unknown"}},he=({flow:a=Me,dataSources:f=[],onFlowChange:j,onExport:b,onTest:T,onSave:v,className:k,style:d,"data-testid":C})=>{const[n,c]=y.useState(a),[$,M]=y.useState("endpoints"),[w,q]=y.useState(n.endpoints[0]?.id||null),[A,B]=y.useState(!1),[N,W]=y.useState(null),[O,L]=y.useState(!1),m=y.useMemo(()=>n.endpoints.find(t=>t.id===w),[n.endpoints,w]),E=y.useCallback(t=>{const r={...n,...t};c(r),j?.(r)},[n,j]),P=y.useCallback((t,r)=>{const x=n.endpoints.map(h=>h.id===t?{...h,...r}:h);E({endpoints:x})},[n.endpoints,E]),U=t=>{const r={id:`ep-${Date.now()}`,name:"newEndpoint",method:t,path:"/new-path",responses:[{status:200,description:"Success"}]};E({endpoints:[...n.endpoints,r]}),q(r.id),B(!1)},I=t=>{E({endpoints:n.endpoints.filter(r=>r.id!==t)}),w===t&&q(n.endpoints[0]?.id||null)},J=async()=>{m&&(L(!0),W(null),await new Promise(t=>setTimeout(t,1e3)),W({status:200,body:{message:"Mock response",timestamp:new Date().toISOString()}}),L(!1),T?.(m.id))},F=y.useMemo(()=>De(n),[n]),V=()=>{b?.(F)};y.useMemo(()=>{const t=new Set;return n.endpoints.forEach(r=>r.tags?.forEach(x=>t.add(x))),Array.from(t)},[n.endpoints]);const g={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",accent:"var(--color-primary, #3b82f6)"};return e.jsxs("div",{className:`nice-api-flow ${k||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:g.bg,color:g.text,fontFamily:"system-ui, sans-serif",...d},"data-testid":C,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${g.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(s.oa,{name:"plug",size:16})," API Flow"]}),e.jsx("input",{type:"text",value:n.name,onChange:t=>E({name:t.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:14,fontWeight:600}}),e.jsx("input",{type:"text",value:n.baseUrl,onChange:t=>E({baseUrl:t.target.value}),placeholder:"Base URL",style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13,width:300}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>v?.(n),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(s.oa,{name:"save",size:14})," Save"]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${g.border}`,padding:"0 20px"},children:["endpoints","auth","settings","test","preview"].map(t=>e.jsxs("button",{onClick:()=>M(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:$===t?g.text:g.textMuted,cursor:"pointer",fontSize:13,fontWeight:$===t?600:400,borderBottom:$===t?`2px solid ${g.accent}`:"2px solid transparent",marginBottom:-1},children:[t==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"link",size:14})," Endpoints"]}),t==="auth"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"lock",size:14})," Auth"]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"settings",size:14})," Settings"]}),t==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"flask",size:14})," Test"]}),t==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"eye",size:14})," Preview"]})]},t))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[$==="endpoints"&&e.jsxs("div",{style:{width:280,borderRight:`1px solid ${g.border}`,padding:12,display:"flex",flexDirection:"column",gap:4,overflow:"auto"},children:[e.jsxs("div",{style:{fontSize:11,color:g.textMuted,marginBottom:8},children:["ENDPOINTS (",n.endpoints.length,")"]}),n.endpoints.map(t=>e.jsxs("button",{onClick:()=>q(t.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:w===t.id?g.accent+"30":g.cardBg,color:g.text,cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:Y[t.method]+"30",color:Y[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:g.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.path})]})]},t.id)),e.jsx("button",{onClick:()=>B(!0),style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${g.border}`,background:"transparent",color:g.textMuted,cursor:"pointer",fontSize:13,marginTop:8},children:"+ Add Endpoint"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[$==="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=>P(m.id,{method:t.target.value}),style:{padding:"8px 12px",borderRadius:6,border:"none",background:Y[m.method]+"30",color:Y[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=>P(m.id,{path:t.target.value}),style:{flex:1,padding:"8px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:14,fontFamily:"monospace"}}),e.jsxs("button",{onClick:()=>I(m.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"trash",size:14})," 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:g.textMuted,marginBottom:4},children:"Name"}),e.jsx("input",{type:"text",value:m.name,onChange:t=>P(m.id,{name:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:g.textMuted,marginBottom:4},children:"Description"}),e.jsx("input",{type:"text",value:m.description||"",onChange:t=>P(m.id,{description:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:g.cardBg,color:g.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(s.oa,{name:"clipboard",size:14})," Parameters"]}),m.pathParams&&m.pathParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:g.textMuted,marginBottom:8},children:"PATH PARAMETERS"}),m.pathParams.map(t=>e.jsxs("div",{style:{padding:12,background:g.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:g.textMuted,fontSize:12},children:t.type}),t.required&&e.jsx("span",{style:{color:"var(--color-error, #ef4444)",fontSize:10},children:"required"})]},t.id))]}),m.queryParams&&m.queryParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:g.textMuted,marginBottom:8},children:"QUERY PARAMETERS"}),m.queryParams.map(t=>e.jsxs("div",{style:{padding:12,background:g.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:g.textMuted,fontSize:12},children:t.type}),t.defaultValue!==void 0&&e.jsxs("span",{style:{color:"var(--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:g.textMuted,marginBottom:8},children:"REQUEST BODY"}),e.jsxs("div",{style:{padding:12,background:g.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:g.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(s.oa,{name:"upload",size:16})," Responses"]}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:m.responses.map(t=>e.jsxs("div",{style:{padding:12,background:g.cardBg,borderRadius:6,minWidth:120},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,color:t.status<300?"var(--color-success, #22c55e)":t.status<400?"var(--color-warning, #f59e0b)":"var(--color-error, #ef4444)"},children:t.status}),e.jsx("div",{style:{fontSize:11,color:g.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:g.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=>P(m.id,{cache:{...m.cache,enabled:t.target.checked}})}),e.jsx(s.oa,{name:"box",size:14})," Cache"]}),m.cache?.enabled&&e.jsxs("div",{style:{fontSize:12,color:g.textMuted},children:["TTL: ",m.cache.ttl,"s • Strategy: ",m.cache.strategy]})]}),e.jsxs("div",{style:{padding:16,background:g.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=>P(m.id,{retry:{...m.retry,enabled:t.target.checked,maxAttempts:3,backoff:"exponential"}})}),e.jsx(s.oa,{name:"refresh",size:14})," Retry"]}),m.retry?.enabled&&e.jsxs("div",{style:{fontSize:12,color:g.textMuted},children:["Max: ",m.retry.maxAttempts," • ",m.retry.backoff," ","backoff"]})]})]})]}),$==="auth"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(s.oa,{name:"lock",size:16})," Authentication"]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:g.textMuted,marginBottom:8},children:"Auth Type"}),e.jsxs("select",{value:n.auth?.type||"none",onChange:t=>E({auth:{...n.auth,type:t.target.value}}),style:{padding:"10px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13,width:"100%"},children:[e.jsx("option",{value:"none",children:"None"}),e.jsx("option",{value:"bearer",children:"Bearer Token"}),e.jsx("option",{value:"basic",children:"Basic Auth"}),e.jsx("option",{value:"api-key",children:"API Key"}),e.jsx("option",{value:"oauth2",children:"OAuth 2.0"})]})]}),n.auth?.type==="bearer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:g.textMuted,marginBottom:8},children:"Token Source"}),e.jsx("input",{type:"text",value:n.auth.tokenSource||"",onChange:t=>E({auth:{...n.auth,tokenSource:t.target.value}}),placeholder:"state.auth.token",style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:g.textMuted,marginBottom:8},children:"Header Name"}),e.jsx("input",{type:"text",value:n.auth.headerName||"Authorization",onChange:t=>E({auth:{...n.auth,headerName:t.target.value}}),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13,boxSizing:"border-box"}})]})]}),e.jsxs("h4",{children:[e.jsx(s.oa,{name:"globe",size:16})," Global Headers"]}),e.jsx("div",{style:{padding:16,background:g.cardBg,borderRadius:8},children:Object.entries(n.globalHeaders||{}).map(([t,r])=>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:g.textMuted},children:":"}),e.jsx("code",{style:{flex:2,color:"var(--color-success, #22c55e)"},children:r})]},t))})]}),$==="settings"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(s.oa,{name:"settings",size:16})," Global Settings"]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:"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:n.errorHandling?.globalErrorHandler||!1,onChange:t=>E({errorHandling:{...n.errorHandling,globalErrorHandler:t.target.checked}})}),"Global error handler"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:n.errorHandling?.retryOnNetworkError||!1,onChange:t=>E({errorHandling:{...n.errorHandling,retryOnNetworkError:t.target.checked}})}),"Retry on network errors"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:n.errorHandling?.transformError||!1,onChange:t=>E({errorHandling:{...n.errorHandling,transformError:t.target.checked}})}),"Transform error responses"]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:"Default Cache Settings"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:n.cacheConfig?.enabled||!1,onChange:t=>E({cacheConfig:{...n.cacheConfig,enabled:t.target.checked}})}),"Enable caching"]}),n.cacheConfig?.enabled&&e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:g.textMuted},children:"Storage"}),e.jsxs("select",{value:n.cacheConfig.storage,onChange:t=>E({cacheConfig:{...n.cacheConfig,storage:t.target.value}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13},children:[e.jsx("option",{value:"memory",children:"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:g.textMuted},children:"Default TTL (seconds)"}),e.jsx("input",{type:"number",value:n.cacheConfig.defaultTTL,onChange:t=>E({cacheConfig:{...n.cacheConfig,defaultTTL:parseInt(t.target.value)}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${g.border}`,background:g.cardBg,color:g.text,fontSize:13,width:100}})]})]})]})]}),$==="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:Y[m.method]+"30",color:Y[m.method],fontSize:12,fontWeight:600},children:m.method}),e.jsxs("code",{style:{flex:1,fontSize:14},children:[n.baseUrl,m.path]}),e.jsx("button",{onClick:J,disabled:O,style:{padding:"10px 20px",borderRadius:6,border:"none",background:g.accent,color:"var(--bg-primary, #fff)",cursor:O?"not-allowed":"pointer",fontSize:13,fontWeight:500,opacity:O?.7:1},children:O?e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"clock",size:14})," Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"rocket",size:14})," Send Request"]})})]}),N&&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:N.status<300?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)"},children:N.status}),e.jsx("span",{style:{color:g.textMuted},children:N.status<300?"OK":"Error"})]}),e.jsx("pre",{style:{padding:16,background:g.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0},children:JSON.stringify(N.body,null,2)})]})]}),$==="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:g.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(F),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${g.border}`,background:"transparent",color:g.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"clipboard",size:14})," Copy"]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:g.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:F})]})]})]}),A&&e.jsx("div",{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:()=>B(!1),children:e.jsxs("div",{style:{background:g.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(s.oa,{name:"plus",size:16})," Add Endpoint"]}),e.jsx("p",{style:{color:g.textMuted,fontSize:13,marginBottom:16},children:"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:()=>U(t),style:{padding:"12px 24px",borderRadius:6,border:"none",background:Y[t]+"30",color:Y[t],cursor:"pointer",fontSize:14,fontWeight:600},children:t},t))})]})})]})},Ie=Object.freeze(Object.defineProperty({__proto__:null,NiceAPIFlow:he},Symbol.toStringTag,{value:"Module"})),Fe={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"}]},ie={string:"var(--color-success, #22c55e)",number:"var(--color-primary, #3b82f6)",boolean:"var(--color-warning, #f59e0b)",date:"var(--color-accent, #8b5cf6)",array:"var(--color-info, #06b6d4)",object:"var(--color-accent-pink, #ec4899)",any:"var(--text-muted, #6b7280)"},se={string:"edit",number:"hash",boolean:"check",date:"calendar",array:"clipboard",object:"box",any:"help"},de={direct:"arrow-right",format:"edit",convert:"refresh",concat:"link",split:"shuffle",calculate:"hash",lookup:"search",conditional:"help",custom:"settings"},Ae=a=>{const f=le(a.sourceSchema),j=le(a.targetSchema),b=a.fieldMappings.map(v=>{const k=a.transformations.find(n=>n.id===v.transform),d=v.targetField;if(!v.sourceField)return` result.${d} = ${JSON.stringify(v.defaultValue)};`;const C=v.sourceField.split(",").map(n=>n.trim());if(k)switch(k.type){case"concat":return` result.${d} = [${C.map(n=>`source.${n}`).join(", ")}].filter(Boolean).join('${k.config.separator||" "}');`;case"format":if(C.length===1){const n=k.config.format||"{value}";return n.includes("{value}")?` result.${d} = '${n}'.replace('{value}', String(source.${C[0]}));`:` result.${d} = formatDate(source.${C[0]}, '${n}');`}break;case"custom":return` result.${d} = ${k.config.expression?.replace(/(\w+)\.(\w+)/g,"source.$1.$2")};`;case"convert":return` result.${d} = ${k.config.convertTo}(source.${C[0]});`}if(C.length===1){const n=v.defaultValue!==void 0?` ?? ${JSON.stringify(v.defaultValue)}`:"";return` result.${d} = source.${C[0]}${n};`}return` // TODO: Manual mapping for ${d}`}),T=a.validationRules.map(v=>{switch(v.type){case"required":return` if (!data.${v.field}) errors.push('${v.message||v.field+" is required"}');`;case"pattern":return` if (data.${v.field} && !/${v.value}/.test(data.${v.field})) errors.push('${v.message||"Invalid format"}');`;default:return` // ${v.type} validation for ${v.field}`}});return`/**
96
+ * ${a.name}
97
+ * ${a.description||""}
98
+ * Auto-generated by NiceDataMapper
99
+ */
100
+
101
+ // Source Type
102
+ ${f}
103
+
104
+ // Target Type
105
+ ${j}
106
+
107
+ // Validation
108
+ export function validate${a.targetSchema.name}(data: ${a.targetSchema.name}): string[] {
109
+ const errors: string[] = [];
110
+ ${T.join(`
111
+ `)}
112
+ return errors;
113
+ }
114
+
115
+ // Mapper
116
+ export function ${a.name.charAt(0).toLowerCase()+a.name.slice(1)}(source: ${a.sourceSchema.name}): ${a.targetSchema.name} {
117
+ const result = {} as ${a.targetSchema.name};
118
+
119
+ ${b.join(`
120
+ `)}
121
+
122
+ return result;
123
+ }
124
+
125
+ // Helper functions
126
+ function formatDate(date: string | Date, format: string): string {
127
+ const d = typeof date === 'string' ? new Date(date) : date;
128
+ const year = d.getFullYear();
129
+ const month = String(d.getMonth() + 1).padStart(2, '0');
130
+ const day = String(d.getDate()).padStart(2, '0');
131
+ return format
132
+ .replace('YYYY', String(year))
133
+ .replace('MM', month)
134
+ .replace('DD', day);
135
+ }
136
+ `},le=(a,f)=>{const j=(T,v)=>{const k=" ".repeat(v),d=T.nullable?"?":"";if(T.type==="object"&&T.children){const n=T.children.map(c=>j(c,v+1)).join(`
137
+ `);return`${k}${T.name}${d}: {
138
+ ${n}
139
+ ${k}};`}const C={string:"string",number:"number",boolean:"boolean",date:"string | Date",array:"unknown[]",object:"Record<string, unknown>",any:"unknown"}[T.type];return`${k}${T.name}${d}: ${C};`},b=a.fields.map(T=>j(T,1)).join(`
140
+ `);return`interface ${a.name} {
141
+ ${b}
142
+ }`},ye=({mapping:a=Fe,sourceSchemas:f=[],targetSchemas:j=[],onMappingChange:b,onExport:T,onTest:v,onSave:k,className:d,style:C,"data-testid":n})=>{const[c,$]=y.useState(a),[M,w]=y.useState("mapping"),[q,A]=y.useState(null),[B,N]=y.useState(""),[W,O]=y.useState(""),[L,m]=y.useState(null),E=y.useCallback(r=>{const x={...c,...r};$(x),b?.(x)},[c,b]),P=(r,x="")=>{const h=[];return r.forEach(i=>{h.push(i),i.children&&h.push(...P(i.children,i.path+"."))}),h},U=y.useMemo(()=>P(c.sourceSchema.fields),[c.sourceSchema.fields]),I=y.useMemo(()=>P(c.targetSchema.fields),[c.targetSchema.fields]),J=(r,x)=>{const h={id:`mapping-${Date.now()}`,sourceField:r,targetField:x};E({fieldMappings:[...c.fieldMappings,h]})},F=r=>{E({fieldMappings:c.fieldMappings.filter(x=>x.id!==r)})},V=()=>{try{const r=JSON.parse(B),x={};c.fieldMappings.forEach(h=>{if(!h.sourceField){x[h.targetField]=h.defaultValue;return}const i=h.sourceField.split(",").map(H=>H.trim()),S=H=>H.split(".").reduce((X,p)=>X?.[p],r),u=c.transformations.find(H=>H.id===h.transform);if(u?.type==="concat")x[h.targetField]=i.map(S).filter(Boolean).join(u.config.separator||" ");else if(u?.type==="format"&&i.length===1){const H=S(i[0]);x[h.targetField]=(u.config.format||"{value}").replace("{value}",String(H))}else i.length===1&&(x[h.targetField]=S(i[0])??h.defaultValue)}),O(JSON.stringify(x,null,2)),v?.(x)}catch(r){O(`Error: ${r.message}`)}},g=y.useMemo(()=>Ae(c),[c]),t={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",accent:"var(--color-primary, #3b82f6)"};return e.jsxs("div",{className:`nice-data-mapper ${d||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...C},"data-testid":n,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${t.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(s.oa,{name:"refresh",size:16})," Data Mapper"]}),e.jsx("input",{type:"text",value:c.name,onChange:r=>E({name:r.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:14,fontWeight:600}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>k?.(c),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(s.oa,{name:"save",size:14})," Save"]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${t.border}`,padding:"0 20px"},children:["mapping","transforms","validation","test","preview"].map(r=>e.jsxs("button",{onClick:()=>w(r),style:{padding:"12px 20px",border:"none",background:"transparent",color:M===r?t.text:t.textMuted,cursor:"pointer",fontSize:13,fontWeight:M===r?600:400,borderBottom:M===r?`2px solid ${t.accent}`:"2px solid transparent",marginBottom:-1},children:[r==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"link",size:14})," Mapping"]}),r==="transforms"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"zap",size:14})," Transforms"]}),r==="validation"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"check",size:14})," Validation"]}),r==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"flask",size:14})," Test"]}),r==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"eye",size:14})," Preview"]})]},r))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[M==="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(s.oa,{name:"download",size:14})," Source: ",c.sourceSchema.name]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:U.map(r=>{const x=r.path.split(".").length-1,h=c.fieldMappings.some(i=>i.sourceField.split(",").some(S=>S.trim()===r.path));return e.jsxs("div",{draggable:!0,onDragStart:()=>m(r.path),onDragEnd:()=>m(null),style:{padding:"10px 12px",paddingLeft:12+x*16,borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8,cursor:"grab",background:h?"var(--nice-success-tint-10, #22c55e10)":"transparent",opacity:r.type==="object"&&r.children?.7:1},children:[e.jsx("span",{style:{color:ie[r.type],fontSize:14},children:e.jsx(s.oa,{name:se[r.type],size:14})}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:r.name}),e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:r.type}),h&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--color-success, #22c55e)",fontSize:10},children:e.jsx(s.oa,{name:"check",size:14})})]},r.id)})})]}),e.jsxs("div",{style:{width:300,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:t.accent+"20",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(s.oa,{name:"link",size:16})," Mappings (",c.fieldMappings.length,")"]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto",padding:8},children:c.fieldMappings.map(r=>{const x=c.transformations.find(h=>h.id===r.transform);return e.jsxs("div",{style:{padding:8,background:t.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(--color-success, #22c55e)"},children:r.sourceField||"(default)"}),e.jsx("span",{style:{color:t.textMuted},children:"→"}),e.jsx("code",{style:{color:"var(--color-primary, #3b82f6)"},children:r.targetField}),e.jsx("button",{onClick:()=>F(r.id),"aria-label":"Remove mapping",style:{marginLeft:"auto",padding:2,border:"none",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:10},children:e.jsx(s.oa,{name:"close",size:14})})]}),x&&e.jsxs("div",{style:{color:t.textMuted,display:"flex",alignItems:"center",gap:4},children:[e.jsx(s.oa,{name:de[x.type],size:14})," ",x.name]}),r.defaultValue!==void 0&&e.jsxs("div",{style:{color:"var(--color-warning, #f59e0b)"},children:["Default: ",JSON.stringify(r.defaultValue)]})]},r.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(s.oa,{name:"upload",size:14})," Target: ",c.targetSchema.name]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:I.map(r=>{const x=r.path.split(".").length-1,h=c.fieldMappings.some(i=>i.targetField===r.path);return e.jsxs("div",{onDragOver:i=>i.preventDefault(),onDrop:()=>{L&&!h&&J(L,r.path)},style:{padding:"10px 12px",paddingLeft:12+x*16,borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8,background:L&&!h?t.accent+"10":h?"#3b82f610":"transparent",transition:"background 0.15s"},children:[e.jsx("span",{style:{color:ie[r.type],fontSize:14},children:e.jsx(s.oa,{name:se[r.type],size:14})}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:r.name}),e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:r.type}),r.nullable&&e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:"?"}),h&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--color-primary, #3b82f6)",fontSize:10},children:e.jsx(s.oa,{name:"check",size:14})})]},r.id)})})]})]}),M==="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(s.oa,{name:"zap",size:16})," Transformations"]}),e.jsx("button",{onClick:()=>{const r={id:`tr-${Date.now()}`,name:"New Transform",type:"direct",config:{}};E({transformations:[...c.transformations,r]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:t.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Transform"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:16},children:c.transformations.map(r=>e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,border:`1px solid ${t.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("span",{style:{fontSize:20},children:e.jsx(s.oa,{name:de[r.type],size:20})}),e.jsx("input",{type:"text",value:r.name,onChange:x=>{const h=c.transformations.map(i=>i.id===r.id?{...i,name:x.target.value}:i);E({transformations:h})},style:{flex:1,padding:"6px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:13,fontWeight:600}})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:"Type"}),e.jsxs("select",{value:r.type,onChange:x=>{const h=c.transformations.map(i=>i.id===r.id?{...i,type:x.target.value}:i);E({transformations:h})},style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"direct",children:"Direct"}),e.jsx("option",{value:"format",children:"Format"}),e.jsx("option",{value:"convert",children:"Convert"}),e.jsx("option",{value:"concat",children:"Concatenate"}),e.jsx("option",{value:"split",children:"Split"}),e.jsx("option",{value:"calculate",children:"Calculate"}),e.jsx("option",{value:"lookup",children:"Lookup"}),e.jsx("option",{value:"conditional",children:"Conditional"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),(r.type==="format"||r.type==="concat")&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:r.type==="format"?"Format Pattern":"Separator"}),e.jsx("input",{type:"text",value:r.type==="format"?r.config.format||"":r.config.separator||"",onChange:x=>{const h=c.transformations.map(i=>i.id===r.id?{...i,config:{...i.config,[r.type==="format"?"format":"separator"]:x.target.value}}:i);E({transformations:h})},placeholder:r.type==="format"?"{value} or YYYY-MM-DD":", ",style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,fontFamily:"monospace",boxSizing:"border-box"}})]}),r.type==="custom"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:"Expression"}),e.jsx("textarea",{value:r.config.expression||"",onChange:x=>{const h=c.transformations.map(i=>i.id===r.id?{...i,config:{...i.config,expression:x.target.value}}:i);E({transformations:h})},rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,fontFamily:"monospace",resize:"vertical",boxSizing:"border-box"}})]})]},r.id))})]}),M==="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(s.oa,{name:"check",size:16})," Validation Rules"]}),e.jsx("button",{onClick:()=>{const r={id:`v-${Date.now()}`,field:"",type:"required",message:""};E({validationRules:[...c.validationRules,r]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:t.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Rule"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:c.validationRules.map(r=>e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsxs("select",{value:r.field,onChange:x=>{const h=c.validationRules.map(i=>i.id===r.id?{...i,field:x.target.value}:i);E({validationRules:h})},style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select field..."}),I.map(x=>e.jsx("option",{value:x.path,children:x.path},x.id))]}),e.jsxs("select",{value:r.type,onChange:x=>{const h=c.validationRules.map(i=>i.id===r.id?{...i,type:x.target.value}:i);E({validationRules:h})},style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"required",children:"Required"}),e.jsx("option",{value:"type",children:"Type"}),e.jsx("option",{value:"min",children:"Min"}),e.jsx("option",{value:"max",children:"Max"}),e.jsx("option",{value:"pattern",children:"Pattern"}),e.jsx("option",{value:"enum",children:"Enum"}),e.jsx("option",{value:"custom",children:"Custom"})]}),(r.type==="pattern"||r.type==="min"||r.type==="max")&&e.jsx("input",{type:"text",value:String(r.value||""),onChange:x=>{const h=c.validationRules.map(i=>i.id===r.id?{...i,value:x.target.value}:i);E({validationRules:h})},placeholder:"Value",style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,width:150}}),e.jsx("input",{type:"text",value:r.message||"",onChange:x=>{const h=c.validationRules.map(i=>i.id===r.id?{...i,message:x.target.value}:i);E({validationRules:h})},placeholder:"Error message",style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12}}),e.jsx("button",{onClick:()=>{E({validationRules:c.validationRules.filter(x=>x.id!==r.id)})},"aria-label":"Delete",style:{padding:6,border:"none",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(s.oa,{name:"trash",size:14})})]},r.id))})]}),M==="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(s.oa,{name:"download",size:16})," Input"]}),e.jsx("button",{onClick:()=>{const r={},x=(h,i)=>{h.forEach(S=>{S.children&&S.type==="object"?(i[S.name]={},x(S.children,i[S.name])):i[S.name]={string:"sample",number:42,boolean:!0,date:new Date().toISOString(),array:[],object:{},any:null}[S.type]})};x(c.sourceSchema.fields,r),N(JSON.stringify(r,null,2))},style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:11},children:"Generate Sample"})]}),e.jsx("textarea",{value:B,onChange:r=>N(r.target.value),placeholder:"Paste JSON input here...",style:{flex:1,padding:12,borderRadius:8,border:`1px solid ${t.border}`,background:t.cardBg,color:t.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(s.oa,{name:"upload",size:16})," Output"]}),e.jsxs("button",{onClick:V,style:{padding:"6px 16px",borderRadius:4,border:"none",background:t.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(s.oa,{name:"refresh",size:14})," Transform"]})]}),e.jsx("pre",{style:{flex:1,padding:12,borderRadius:8,background:t.cardBg,margin:0,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace"},children:W||"Run transform to see output"})]})]}),M==="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:()=>T?.(g),style:{padding:"8px 16px",borderRadius:4,border:"none",background:t.accent,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(g),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"clipboard",size:14})," Copy"]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:t.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:g})]})]})]})},Pe=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMapper:ye},Symbol.toStringTag,{value:"Module"})),_e=[{type:"ui-event",label:"UI Event",icon:"cursor",color:"var(--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(--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(--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(--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(--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(--color-info, #06b6d4)",configSchema:[{name:"eventName",label:"Event Name",type:"string",required:!0}]}],Oe=[{type:"action",label:"Action",icon:"zap",color:"var(--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(--color-accent, #8b5cf6)",configSchema:[{name:"expression",label:"Transform Expression",type:"code",required:!0}]},{type:"dispatch",label:"Dispatch",icon:"upload",color:"var(--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(--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(--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(--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(--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"}]}],Le=[{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"}}]}],qe=a=>{const f=a.filter(b=>b.enabled);return`/**
143
+ * Generated Event Orchestration
144
+ * @generated by NiceEventOrchestrator
145
+ */
146
+
147
+ import { createEventBus, EventHandler, EventSource } from '@nice2dev/events';
148
+
149
+ // Event Bus Instance
150
+ export const eventBus = createEventBus();
151
+
152
+ // Event Types
153
+ ${f.map(b=>`export type ${b.name.replace(/\s+/g,"")}Event = {
154
+ source: '${b.source.type}';
155
+ payload: unknown;
156
+ };`).join(`
157
+
158
+ `)}
159
+
160
+ // Event Handlers
161
+ ${f.map(b=>{const T=JSON.stringify(b.source.config,null,2),v=b.handlers.flatMap(k=>k.modifiers||[]).map(k=>`.${k.type}(${k.value})`).join("");return`
162
+ /**
163
+ * ${b.name}
164
+ * ${b.description||""}
165
+ */
166
+ export const ${b.name.replace(/\s+/g,"").toLowerCase()}Handler = eventBus
167
+ .on('${b.source.type}', ${T})${v}
168
+ .pipe(
169
+ ${b.handlers.map((k,d)=>` // Step ${d+1}: ${k.type}
170
+ async (event) => {
171
+ ${ce(k)}
172
+ },`).join(`
173
+ `)}
174
+ )
175
+ ${b.errorHandler?`.catch(async (error) => {
176
+ ${ce(b.errorHandler)}
177
+ })`:""};`}).join(`
178
+ `)}
179
+
180
+ // Initialize all handlers
181
+ export function initEventOrchestration() {
182
+ ${f.map(b=>` ${b.name.replace(/\s+/g,"").toLowerCase()}Handler.start();`).join(`
183
+ `)}
184
+ console.log('Event orchestration initialized');
185
+ }
186
+
187
+ // Cleanup
188
+ export function destroyEventOrchestration() {
189
+ ${f.map(b=>` ${b.name.replace(/\s+/g,"").toLowerCase()}Handler.stop();`).join(`
190
+ `)}
191
+ }
192
+ `},ce=a=>{switch(a.type){case"action":return`dispatch({ type: '${a.config.actionType}', payload: ${JSON.stringify(a.config.payload)} });`;case"transform":return`return (${a.config.expression})(event);`;case"dispatch":return`eventBus.emit('${a.config.eventName}', ${JSON.stringify(a.config.payload)});`;case"api-call":return`await fetch('${a.config.endpoint}', { method: '${a.config.method}', body: JSON.stringify(event.payload) });`;case"state-update":return`updateState('${a.config.path}', ${a.config.value});`;case"notification":return`showNotification({ type: '${a.config.type}', message: '${a.config.message}' });`;case"log":return`console.${a.config.level||"log"}('${a.config.message}', event);`;case"delay":return`await new Promise(r => setTimeout(r, ${a.config.duration}));`;case"branch":return`if (${a.config.condition}) { /* true branch */ } else { /* false branch */ }`;default:return"// Unknown handler type"}},be=({flows:a=Le,eventSources:f=_e,eventHandlers:j=Oe,onFlowsChange:b,onExport:T,onTest:v,className:k,style:d,"data-testid":C})=>{const[n,c]=y.useState(a),[$,M]=y.useState(n[0]?.id??null),[w,q]=y.useState("visual"),[A,B]=y.useState(!1),[N,W]=y.useState(""),[O,L]=y.useState(new Set),m=y.useMemo(()=>n.find(r=>r.id===$),[n,$]),E=y.useMemo(()=>qe(n),[n]),P=y.useCallback((r,x)=>{c(h=>{const i=h.map(S=>S.id===r?{...S,...x}:S);return b?.(i),i})},[b]),U=()=>{if(!N.trim())return;const r={id:`flow-${Date.now()}`,name:N,enabled:!0,source:{id:`src-${Date.now()}`,type:"ui-event",config:{element:"",event:"click"}},handlers:[]};c(x=>{const h=[...x,r];return b?.(h),h}),M(r.id),B(!1),W("")},I=r=>{c(x=>{const h=x.filter(i=>i.id!==r);return b?.(h),h}),$===r&&M(n[0]?.id??null)},J=r=>{if(!m)return;const x=j.find(S=>S.type===r),h={};x?.configSchema.forEach(S=>{S.default!==void 0&&(h[S.name]=S.default)});const i={id:`handler-${Date.now()}`,type:r,config:h};P(m.id,{handlers:[...m.handlers,i]}),L(S=>new Set([...S,i.id]))},F=(r,x)=>{m&&P(m.id,{handlers:m.handlers.map(h=>h.id===r?{...h,...x}:h)})},V=r=>{m&&P(m.id,{handlers:m.handlers.filter(x=>x.id!==r)})},g=(r,x)=>{if(!m)return;const h=m.handlers.find(u=>u.id===r);if(!h)return;const S=h.modifiers?.find(u=>u.type===x)?h.modifiers?.filter(u=>u.type!==x):[...h.modifiers||[],{type:x,value:500,unit:"ms"}];F(r,{modifiers:S})},t={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--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",...d},"data-testid":C,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(s.oa,{name:"zap",size:16})," Event Orchestrator"]}),e.jsx("div",{style:{display:"flex",border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(r=>e.jsxs("button",{onClick:()=>q(r),style:{padding:"6px 12px",border:"none",background:w===r?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12,textTransform:"capitalize",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:r==="visual"?"palette":r==="code"?"edit":"grid",size:14})," ",r]},r))}),e.jsxs("button",{onClick:()=>T?.(E),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"upload",size:14})," Export"]})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(w==="visual"||w==="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:"Event Flows"}),e.jsx("button",{onClick:()=>B(!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:[n.map(r=>{const x=f.find(h=>h.type===r.source.type);return e.jsxs("div",{onClick:()=>M(r.id),style:{padding:12,background:$===r.id?t.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${$===r.id?t.border:"transparent"}`,opacity:r.enabled?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.oa,{name:x?.icon??"zap",size:16}),e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:500},children:r.name}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.enabled?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)"}})]}),e.jsxs("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:[r.handlers.length," handler",r.handlers.length!==1?"s":""]})]},r.id)}),A&&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:N,onChange:r=>W(r.target.value),placeholder:"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:r=>r.key==="Enter"&&U()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>B(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:11},children:"Cancel"}),e.jsx("button",{onClick:U,style:{flex:1,padding:6,borderRadius:4,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11},children:"Add"})]})]})]})]}),(w==="visual"||w==="split")&&m&&e.jsxs("div",{style:{flex:w==="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:r=>P(m.id,{name:r.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:r=>P(m.id,{enabled:r.target.checked})}),e.jsx("span",{style:{fontSize:12},children:"Enabled"})]}),e.jsxs("button",{onClick:()=>v?.(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(s.oa,{name:"play",size:14})," Test"]}),e.jsx("button",{onClick:()=>I(m.id),"aria-label":"Delete",style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(s.oa,{name:"trash",size:14})})]}),e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,marginBottom:16,borderLeft:`4px solid ${f.find(r=>r.type===m.source.type)?.color??"var(--text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(s.oa,{name:f.find(r=>r.type===m.source.type)?.icon??"zap",size:20}),e.jsx("span",{style:{fontWeight:600},children:"Event Source"})]}),e.jsx("select",{value:m.source.type,onChange:r=>P(m.id,{source:{...m.source,type:r.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:f.map(r=>e.jsx("option",{value:r.type,children:r.label},r.type))}),f.find(r=>r.type===m.source.type)?.configSchema.map(r=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:[r.label," ",r.required&&e.jsx("span",{style:{color:"var(--color-error, #ef4444)"},children:"*"})]}),r.type==="select"?e.jsx("select",{value:String(m.source.config[r.name]??""),onChange:x=>P(m.id,{source:{...m.source,config:{...m.source.config,[r.name]:x.target.value}}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:r.options?.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))}):e.jsx("input",{type:r.type==="number"?"number":"text",value:String(m.source.config[r.name]??""),onChange:x=>P(m.id,{source:{...m.source,config:{...m.source.config,[r.name]:r.type==="number"?Number(x.target.value):x.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"}})]},r.name))]}),e.jsx("div",{style:{textAlign:"center",color:t.textMuted,marginBottom:16},children:e.jsx(s.oa,{name:"arrow-down",size:16})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[m.handlers.map((r,x)=>{const h=j.find(S=>S.type===r.type),i=O.has(r.id);return e.jsxs(y.Fragment,{children:[e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,borderLeft:`4px solid ${h?.color??"var(--text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},onClick:()=>L(S=>{const u=new Set(S);return u.has(r.id)?u.delete(r.id):u.add(r.id),u}),children:[e.jsx(s.oa,{name:h?.icon??"zap",size:16}),e.jsxs("span",{style:{fontWeight:500},children:[x+1,". ",h?.label??r.type]}),r.modifiers?.map(S=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:[S.type,": ",S.value,"ms"]},S.type)),e.jsx("span",{style:{marginLeft:"auto",color:t.textMuted,display:"inline-flex",alignItems:"center"},children:e.jsx(s.oa,{name:i?"chevron-down":"chevron-right",size:14})})]}),i&&e.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`},children:[e.jsx("select",{value:r.type,onChange:S=>F(r.id,{type:S.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:j.map(S=>e.jsx("option",{value:S.type,children:S.label},S.type))}),h?.configSchema.map(S=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:S.label}),S.type==="code"?e.jsx("textarea",{value:String(r.config[S.name]??""),onChange:u=>F(r.id,{config:{...r.config,[S.name]:u.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"}}):S.type==="select"?e.jsx("select",{value:String(r.config[S.name]??""),onChange:u=>F(r.id,{config:{...r.config,[S.name]:u.target.value}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:S.options?.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))}):e.jsx("input",{type:S.type==="number"?"number":"text",value:String(r.config[S.name]??""),onChange:u=>F(r.id,{config:{...r.config,[S.name]:S.type==="number"?Number(u.target.value):u.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"}})]},S.name)),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:"Modifiers"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["debounce","throttle","delay","retry","once"].map(S=>e.jsx("button",{onClick:()=>g(r.id,S),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${r.modifiers?.some(u=>u.type===S)?"var(--color-accent, #8b5cf6)":t.border}`,background:r.modifiers?.some(u=>u.type===S)?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:11},children:S},S))})]}),e.jsxs("button",{onClick:()=>V(r.id),style:{marginTop:12,padding:"6px 12px",borderRadius:4,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:11,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"trash",size:14})," Remove Handler"]})]})]}),x<m.handlers.length-1&&e.jsx("div",{style:{textAlign:"center",color:t.textMuted},children:e.jsx(s.oa,{name:"arrow-down",size:16})})]},r.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:"Add Handler"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center"},children:j.map(r=>e.jsxs("button",{onClick:()=>J(r.type),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${r.color}`,background:`${r.color}20`,color:t.text,cursor:"pointer",fontSize:11,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:r.icon,size:14})," ",r.label]},r.type))})]})]})]}),(w==="code"||w==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--bg-canvas, #0d1117)",borderLeft:w==="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(--text-primary, #e6edf3)",whiteSpace:"pre-wrap"},children:E})})]})]})},We=Object.freeze(Object.defineProperty({__proto__:null,NiceEventOrchestrator:be},Symbol.toStringTag,{value:"Module"})),Ve=[{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"}],ee={render:{label:"Render",icon:"palette",color:"var(--color-primary, #3b82f6)"},click:{label:"Click",icon:"cursor",color:"var(--color-success, #22c55e)",hasTarget:!0},type:{label:"Type",icon:"terminal",color:"var(--color-warning, #f59e0b)",hasTarget:!0,hasValue:!0},select:{label:"Select",icon:"clipboard",color:"var(--color-accent, #8b5cf6)",hasTarget:!0,hasValue:!0},hover:{label:"Hover",icon:"cursor",color:"var(--color-accent-pink, #ec4899)",hasTarget:!0},focus:{label:"Focus",icon:"target",color:"var(--color-info, #06b6d4)",hasTarget:!0},blur:{label:"Blur",icon:"forward",color:"var(--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(--color-warning, #eab308)",hasTarget:!0,hasValue:!0},assert:{label:"Assert",icon:"check",color:"var(--color-success, #22c55e)",hasTarget:!0,hasValue:!0},snapshot:{label:"Snapshot",icon:"camera",color:"var(--color-primary, #3b82f6)"},"a11y-check":{label:"A11y Check",icon:"accessibility",color:"var(--color-accent, #8b5cf6)"}},Ue=[{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"}}]}]}],He=a=>a.map(f=>{const j=new Set(["import { render, screen, fireEvent, waitFor } from '@testing-library/react';","import userEvent from '@testing-library/user-event';",`import { ${f.componentName} } from './${f.componentName}';`]);f.setup?.mocks.forEach(d=>{d.type==="api"&&(j.add("import { rest } from 'msw';"),j.add("import { setupServer } from 'msw/node';"))});const b=f.setup?.mocks.map(d=>d.type==="function"?`const ${d.name} = jest.fn();`:d.type==="api"?`// API mock: ${d.name}`:"").filter(Boolean).join(`
193
+ `),v=f.setup?.providers&&f.setup.providers.length>0?`const Wrapper = ({ children }) => (
194
+ ${f.setup.providers.map(d=>`<${d.name}>`).join(`
195
+ `)}
196
+ {children}
197
+ ${f.setup.providers.reverse().map(d=>`</${d.name}>`).join(`
198
+ `)}
199
+ );`:"",k=f.tests.map(d=>{const C=d.skip?".skip":d.only?".only":"",n=d.steps.map(c=>Je(c,f)).join(`
200
+ `);return`
201
+ it${C}('${d.name}', async () => {
202
+ ${n}
203
+ });`}).join(`
204
+ `);return`/**
205
+ * ${f.name}
206
+ * @generated by NiceTestBuilder
207
+ */
208
+
209
+ ${Array.from(j).join(`
210
+ `)}
211
+
212
+ describe('${f.componentName}', () => {
213
+ ${b?` // Mocks
214
+ ${b}
215
+ `:""}
216
+ ${v?` ${v}
217
+ `:""}
218
+ beforeEach(() => {
219
+ jest.clearAllMocks();
220
+ });
221
+ ${k}
222
+ });
223
+ `}).join(`
224
+
225
+ `),Je=(a,f)=>{switch(ee[a.action],a.action){case"render":{const j=f.setup?.providers&&f.setup.providers.length>0,b=f.setup?.props?` {...${JSON.stringify(f.setup.props)}}`:"";return j?`render(<${f.componentName}${b} />, { wrapper: Wrapper });`:`render(<${f.componentName}${b} />);`}case"click":return`await userEvent.click(screen.getByRole('${a.target?.replace(/[[\]'"]/g,"")}'));`;case"type":return`await userEvent.type(screen.getByRole('textbox', { name: /${a.target}/ }), '${a.value}');`;case"select":return`await userEvent.selectOptions(screen.getByRole('combobox'), '${a.value}');`;case"hover":return`await userEvent.hover(screen.getByRole('${a.target}'));`;case"focus":return`screen.getByRole('${a.target}').focus();`;case"blur":return`screen.getByRole('${a.target}').blur();`;case"submit":return"fireEvent.submit(screen.getByRole('form'));";case"wait":if(typeof a.value=="object"&&a.value!==null){const j=a.value;return j.type==="timeout"?`await new Promise(r => setTimeout(r, ${j.value}));`:`await waitFor(() => expect(/* condition */).toBeTruthy(), { timeout: ${j.timeout??1e3} });`}return`await new Promise(r => setTimeout(r, ${a.value}));`;case"assert":if(typeof a.value=="object"&&a.value!==null){const j=a.value;if(j.mock)return`expect(${j.mock}).${j.matcher}(${j.expected?JSON.stringify(j.expected):""});`;const b=a.target?`screen.getByRole('${a.target}')`:"result",T=j.expected!==void 0?JSON.stringify(j.expected):"";return`expect(${b}).${j.matcher}(${T});`}return`expect(screen.getByRole('${a.target}')).toBeInTheDocument();`;case"snapshot":return"expect(container).toMatchSnapshot();";case"a11y-check":return`const results = await axe(container);
226
+ expect(results).toHaveNoViolations();`;default:return`// ${a.action}: ${JSON.stringify(a)}`}},fe=({componentName:a="MyComponent",testSuites:f=Ue,availableMocks:j=[],onSuitesChange:b,onExport:T,onRun:v,onRunAll:k,tutorial:d,className:C,style:n,"data-testid":c})=>{const[$,M]=y.useState(f),[w,q]=y.useState($[0]?.id??null),[A,B]=y.useState(null),[N,W]=y.useState("visual"),[O,L]=y.useState(!1),[m,E]=y.useState(""),[P,U]=y.useState(new Set),I=y.useMemo(()=>$.find(o=>o.id===w),[$,w]);y.useMemo(()=>I?.tests.find(o=>o.id===A),[I,A]);const J=y.useMemo(()=>He($),[$]),F=y.useCallback((o,z)=>{M(R=>{const _=R.map(D=>D.id===o?{...D,...z}:D);return b?.(_),_})},[b]),V=()=>{if(!m.trim())return;const o={id:`suite-${Date.now()}`,name:m,componentName:a,tests:[]};M(z=>{const R=[...z,o];return b?.(R),R}),q(o.id),L(!1),E("")},g=o=>{M(z=>{const R=z.filter(_=>_.id!==o);return b?.(R),R}),w===o&&q($[0]?.id??null)},t=()=>{if(!I)return;const o={id:`test-${Date.now()}`,name:"New test",type:"unit",steps:[{id:`step-${Date.now()}`,action:"render"}]};F(I.id,{tests:[...I.tests,o]}),B(o.id),U(z=>new Set([...z,o.id]))},r=(o,z)=>{I&&F(I.id,{tests:I.tests.map(R=>R.id===o?{...R,...z}:R)})},x=o=>{I&&(F(I.id,{tests:I.tests.filter(z=>z.id!==o)}),A===o&&B(null))},h=(o,z)=>{if(!I)return;const R=I.tests.find(D=>D.id===o);if(!R)return;const _={id:`step-${Date.now()}`,action:z};r(o,{steps:[...R.steps,_]})},i=(o,z,R)=>{if(!I)return;const _=I.tests.find(D=>D.id===o);_&&r(o,{steps:_.steps.map(D=>D.id===z?{...D,...R}:D)})},S=(o,z)=>{if(!I)return;const R=I.tests.find(_=>_.id===o);R&&r(o,{steps:R.steps.filter(_=>_.id!==z)})},u={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"},H=y.useMemo(()=>{const o=$.reduce((R,_)=>R+_.tests.length,0),z=$.reduce((R,_)=>R+_.tests.filter(D=>D.skip).length,0);return{total:o,skipped:z}},[$]),X=e.jsxs("div",{style:{padding:"12px 20px",borderBottom:`1px solid ${u.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(s.oa,{name:"flask",size:16})," Test Builder"]}),e.jsxs("div",{style:{fontSize:12,color:u.textMuted},children:[H.total," tests • ",H.skipped," skipped"]}),e.jsx("div",{style:{display:"flex",border:`1px solid ${u.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(o=>e.jsxs("button",{onClick:()=>W(o),style:{padding:"6px 12px",border:"none",background:N===o?u.cardBg:"transparent",color:u.text,cursor:"pointer",fontSize:12,textTransform:"capitalize"},children:[e.jsx(s.oa,{name:o==="visual"?"palette":o==="code"?"edit":"grid",size:14})," ",o]},o))}),e.jsxs("button",{onClick:k,style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${u.border}`,background:"transparent",color:u.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.oa,{name:"play",size:14})," Run All"]}),e.jsxs("button",{onClick:()=>T?.(J),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(s.oa,{name:"upload",size:14})," Export"]}),e.jsx(s.Yl,{steps:s.Jl(d,Ve)})]}),l=N==="visual"||N==="split"?e.jsxs("div",{style:{width:220,borderRight:`1px solid ${u.border}`,display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${u.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600},children:"Test Suites"}),e.jsx("button",{onClick:()=>L(!0),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${u.border}`,background:"transparent",color:u.text,cursor:"pointer",fontSize:12},children:"+"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[$.map(o=>e.jsxs("div",{onClick:()=>{q(o.id),B(null)},style:{padding:12,background:w===o.id?u.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${w===o.id?u.border:"transparent"}`},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:o.name}),e.jsxs("div",{style:{fontSize:10,color:u.textMuted,marginTop:4},children:[o.componentName," • ",o.tests.length," test",o.tests.length!==1?"s":""]})]},o.id)),O&&e.jsxs("div",{style:{padding:12,background:u.cardBg,borderRadius:6,border:"1px solid var(--nice-primary, #3b82f6)"},children:[e.jsx("input",{type:"text",value:m,onChange:o=>E(o.target.value),placeholder:"Suite name...",autoFocus:!0,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${u.border}`,background:u.bg,color:u.text,fontSize:12,marginBottom:8,boxSizing:"border-box"},onKeyDown:o=>o.key==="Enter"&&V()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>L(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${u.border}`,background:"transparent",color:u.text,cursor:"pointer",fontSize:11},children:"Cancel"}),e.jsx("button",{onClick:V,style:{flex:1,padding:6,borderRadius:4,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11},children:"Add"})]})]})]})]}):void 0;return e.jsx(te.NiceAppShell,{flush:!0,className:`nice-test-builder ${C||""}`,style:{background:u.bg,color:u.text,fontFamily:"system-ui, sans-serif",...n},"data-testid":c,menubar:X,sidebar:l,children:e.jsxs("div",{style:{display:"flex",height:"100%",overflow:"hidden"},children:[(N==="visual"||N==="split")&&I&&e.jsxs("div",{style:{flex:N==="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:I.name,onChange:o=>F(I.id,{name:o.target.value}),style:{flex:1,padding:10,borderRadius:6,border:`1px solid ${u.border}`,background:u.cardBg,color:u.text,fontSize:16,fontWeight:600}}),e.jsxs("button",{onClick:()=>v?.(I.id),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${u.border}`,background:"transparent",color:u.text,cursor:"pointer",fontSize:12},children:[e.jsx(s.oa,{name:"play",size:14})," Run Suite"]}),e.jsx("button",{onClick:()=>g(I.id),"aria-label":"Delete",style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(s.oa,{name:"trash",size:14})})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:u.textMuted,marginBottom:6},children:"Component"}),e.jsx("input",{type:"text",value:I.componentName,onChange:o=>F(I.id,{componentName:o.target.value}),style:{width:200,padding:8,borderRadius:4,border:`1px solid ${u.border}`,background:u.cardBg,color:u.text,fontSize:13}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[I.tests.map((o,z)=>{const R=P.has(o.id),_={unit:{color:"var(--color-primary, #3b82f6)",icon:"puzzle"},integration:{color:"var(--color-success, #22c55e)",icon:"link"},e2e:{color:"var(--color-accent, #8b5cf6)",icon:"globe"},snapshot:{color:"var(--color-warning, #f59e0b)",icon:"camera"},accessibility:{color:"var(--color-accent-pink, #ec4899)",icon:"accessibility"}};return e.jsxs("div",{style:{background:u.cardBg,borderRadius:8,border:`1px solid ${A===o.id?"var(--color-primary, #3b82f6)":u.border}`,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:12,display:"flex",alignItems:"center",gap:8,cursor:"pointer",borderLeft:`4px solid ${_[o.type].color}`},onClick:()=>{B(o.id),U(D=>{const G=new Set(D);return G.has(o.id)?G.delete(o.id):G.add(o.id),G})},children:[e.jsx("span",{children:e.jsx(s.oa,{name:_[o.type].icon,size:14})}),e.jsxs("span",{style:{fontWeight:500,opacity:o.skip?.5:1},children:[z+1,". ",o.name]}),o.skip&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:4,fontSize:10},children:"SKIPPED"}),o.only&&e.jsx("span",{style:{padding:"2px 6px",background:"#8b5cf630",color:"var(--color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:"ONLY"}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:u.textMuted},children:[o.steps.length," step",o.steps.length!==1?"s":""]}),e.jsx("span",{style:{color:u.textMuted},children:e.jsx(s.oa,{name:R?"chevron-down":"chevron-right",size:14})})]}),R&&e.jsxs("div",{style:{padding:16,borderTop:`1px solid ${u.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:u.textMuted,marginBottom:4},children:"Test Name"}),e.jsx("input",{type:"text",value:o.name,onChange:D=>r(o.id,{name:D.target.value}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${u.border}`,background:u.bg,color:u.text,fontSize:12,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:u.textMuted,marginBottom:4},children:"Type"}),e.jsxs("select",{value:o.type,onChange:D=>r(o.id,{type:D.target.value}),style:{padding:8,borderRadius:4,border:`1px solid ${u.border}`,background:u.bg,color:u.text,fontSize:12},children:[e.jsx("option",{value:"unit",children:"Unit"}),e.jsx("option",{value:"integration",children:"Integration"}),e.jsx("option",{value:"e2e",children:"E2E"}),e.jsx("option",{value:"snapshot",children:"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:o.skip??!1,onChange:D=>r(o.id,{skip:D.target.checked,only:!1})}),"Skip"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:o.only??!1,onChange:D=>r(o.id,{only:D.target.checked,skip:!1})}),"Only"]})]})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:11,color:u.textMuted,marginBottom:8},children:"Steps"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.steps.map((D,G)=>{const Q=ee[D.action];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:10,background:u.bg,borderRadius:6,borderLeft:`3px solid ${Q.color}`},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontSize:11,color:u.textMuted},children:G+1}),e.jsx("span",{children:e.jsx(s.oa,{name:Q.icon,size:14})}),e.jsx("select",{value:D.action,onChange:K=>i(o.id,D.id,{action:K.target.value}),style:{padding:6,borderRadius:4,border:`1px solid ${u.border}`,background:u.cardBg,color:u.text,fontSize:11},children:Object.entries(ee).map(([K,je])=>e.jsx("option",{value:K,children:je.label},K))}),Q.hasTarget&&e.jsx("input",{type:"text",value:D.target??"",onChange:K=>i(o.id,D.id,{target:K.target.value}),placeholder:"Target selector",style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${u.border}`,background:u.cardBg,color:u.text,fontSize:11}}),Q.hasValue&&D.action!=="assert"&&e.jsx("input",{type:"text",value:typeof D.value=="string"?D.value:"",onChange:K=>i(o.id,D.id,{value:K.target.value}),placeholder:"Value",style:{width:120,padding:6,borderRadius:4,border:`1px solid ${u.border}`,background:u.cardBg,color:u.text,fontSize:11}}),e.jsx("button",{onClick:()=>S(o.id,D.id),"aria-label":"Remove step",style:{padding:4,borderRadius:4,border:"none",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(s.oa,{name:"close",size:14})})]},D.id)})})]}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Object.entries(ee).slice(0,8).map(([D,G])=>e.jsxs("button",{onClick:()=>h(o.id,D),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${G.color}40`,background:`${G.color}20`,color:u.text,cursor:"pointer",fontSize:10},children:[e.jsx(s.oa,{name:G.icon,size:14})," ",G.label]},D))}),e.jsx("div",{style:{marginTop:16,display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>x(o.id),style:{padding:"6px 12px",borderRadius:4,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:11},children:[e.jsx(s.oa,{name:"trash",size:14})," Delete Test"]})})]})]},o.id)}),e.jsx("button",{onClick:t,style:{padding:16,borderRadius:8,border:`1px dashed ${u.border}`,background:"transparent",color:u.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Test"})]})]}),(N==="code"||N==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--bg-canvas, #0d1117)",borderLeft:N==="split"?`1px solid ${u.border}`:void 0},children:e.jsx("pre",{style:{margin:0,fontFamily:"Consolas, Monaco, monospace",fontSize:12,lineHeight:1.5,color:"var(--text-primary, #e6edf3)",whiteSpace:"pre-wrap"},children:J})})]})})},Ge=Object.freeze(Object.defineProperty({__proto__:null,NiceTestBuilder:fe},Symbol.toStringTag,{value:"Module"})),Ke=[{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';
227
+ {{#if withProps}}
228
+ export interface {{componentName}}Props {
229
+ children?: React.ReactNode;
230
+ className?: string;
231
+ }
232
+ {{/if}}
233
+
234
+ export const {{componentName}}: React.FC{{#if withProps}}<{{componentName}}Props>{{/if}} = ({{#if withProps}}{ children, className }{{/if}}) => {
235
+ return (
236
+ <div className={className}>
237
+ {children}
238
+ </div>
239
+ );
240
+ };
241
+
242
+ export default {{componentName}};
243
+ `},{id:"test",name:"{{componentName}}.test.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withTests === true",content:`import { render, screen } from '@testing-library/react';
244
+ import { {{componentName}} } from './{{componentName}}';
245
+
246
+ describe('{{componentName}}', () => {
247
+ it('renders children', () => {
248
+ render(<{{componentName}}>Test Content</{{componentName}}>);
249
+ expect(screen.getByText('Test Content')).toBeInTheDocument();
250
+ });
251
+ });
252
+ `},{id:"story",name:"{{componentName}}.stories.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withStory === true",content:`import type { Meta, StoryObj } from '@storybook/react';
253
+ import { {{componentName}} } from './{{componentName}}';
254
+
255
+ const meta: Meta<typeof {{componentName}}> = {
256
+ title: 'Components/{{componentName}}',
257
+ component: {{componentName}},
258
+ };
259
+
260
+ export default meta;
261
+ type Story = StoryObj<typeof {{componentName}}>;
262
+
263
+ export const Default: Story = {
264
+ args: {},
265
+ };
266
+ `},{id:"index",name:"index.ts",path:"src/components/{{componentName}}",language:"typescript",content:`export { {{componentName}} } from './{{componentName}}';
267
+ export type { {{componentName}}Props } from './{{componentName}}';
268
+ `}]}]},{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}}
269
+ import type { Metadata } from 'next';
270
+
271
+ export const metadata: Metadata = {
272
+ title: '{{pageName}}',
273
+ description: '{{pageName}} page',
274
+ };
275
+ {{/if}}
276
+
277
+ export default function {{pascalCase pageName}}Page() {
278
+ return (
279
+ <main>
280
+ <h1>{{pageName}}</h1>
281
+ </main>
282
+ );
283
+ }
284
+ `},{id:"loading",name:"loading.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withLoading === true",content:`export default function Loading() {
285
+ return <div>Loading...</div>;
286
+ }
287
+ `},{id:"error",name:"error.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withError === true",content:`'use client';
288
+
289
+ export default function Error({
290
+ error,
291
+ reset,
292
+ }: {
293
+ error: Error & { digest?: string };
294
+ reset: () => void;
295
+ }) {
296
+ return (
297
+ <div>
298
+ <h2>Something went wrong!</h2>
299
+ <button onClick={reset}>Try again</button>
300
+ </div>
301
+ );
302
+ }
303
+ `}]},{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';
304
+
305
+ {{#if (includes methods 'GET')}}
306
+ export async function GET() {
307
+ return NextResponse.json({ message: 'GET {{routeName}}' });
308
+ }
309
+ {{/if}}
310
+
311
+ {{#if (includes methods 'POST')}}
312
+ export async function POST(request: Request) {
313
+ const body = await request.json();
314
+ return NextResponse.json({ message: 'POST {{routeName}}', data: body });
315
+ }
316
+ {{/if}}
317
+
318
+ {{#if (includes methods 'PUT')}}
319
+ export async function PUT(request: Request) {
320
+ const body = await request.json();
321
+ return NextResponse.json({ message: 'PUT {{routeName}}', data: body });
322
+ }
323
+ {{/if}}
324
+
325
+ {{#if (includes methods 'DELETE')}}
326
+ export async function DELETE() {
327
+ return NextResponse.json({ message: 'DELETE {{routeName}}' });
328
+ }
329
+ {{/if}}
330
+ `}]}]}],pe=(a,f,j)=>{let b=a;Object.entries(f).forEach(([k,d])=>{const C=new RegExp(`\\{\\{\\s*${k}\\s*\\}\\}`,"g");b=b.replace(C,String(d));const n=new RegExp(`\\{\\{\\s*pascalCase\\s+${k}\\s*\\}\\}`,"g");if(typeof d=="string"){const c=d.charAt(0).toUpperCase()+d.slice(1);b=b.replace(n,c)}});const T=/\{\{#if\s+([^}]+)\}\}([\s\S]*?)\{\{\/if\}\}/g;b=b.replace(T,(k,d,C)=>{const n=d.trim(),c=n.match(/(\w+)\s*===?\s*(\w+|true|false|'[^']*'|"[^"]*")/);if(c){const[,M,w]=c,q=f[M];let A=w;return w==="true"?A=!0:w==="false"?A=!1:(w.startsWith("'")||w.startsWith('"'))&&(A=w.slice(1,-1)),q===A?C:""}return f[n]?C:""});const v=/\{\{#if\s+\(includes\s+(\w+)\s+'([^']+)'\)\}\}([\s\S]*?)\{\{\/if\}\}/g;return b=b.replace(v,(k,d,C,n)=>{const c=f[d];return Array.isArray(c)&&c.includes(C)?n:""}),b},Ye=(a,f)=>{try{const j=a.split(/\s*(===|!==|==|!=)\s*/);if(j.length===3){const[b,T,v]=j,k=f[b.trim()],d=v.trim();let C=d;switch(d==="true"?C=!0:d==="false"?C=!1:(d.startsWith("'")||d.startsWith('"'))&&(C=d.slice(1,-1)),T){case"===":case"==":return k===C;case"!==":case"!=":return k!==C}}return!!f[a.trim()]}catch{return!0}},ve=({templates:a,presets:f=Ke,selectedTemplate:j,defaultEngine:b="handlebars",showLibrary:T=!0,onTemplateSelect:v,onTemplateCreate:k,onTemplateUpdate:d,onTemplateDelete:C,onGenerate:n,onExport:c,onImport:$,className:M,style:w,"data-testid":q="nice-code-template"})=>{const[A,B]=y.useState(a),[N,W]=y.useState(j||null),[O,L]=y.useState({}),[m,E]=y.useState("editor"),[P,U]=y.useState(null),[I,J]=y.useState(!1),[F,V]=y.useState(!1),g=y.useMemo(()=>{const l=f.flatMap(o=>o.templates);return[...A,...l]},[A,f]),t=y.useMemo(()=>g.find(l=>l.id===N),[g,N]),r=y.useMemo(()=>t?.files.find(l=>l.id===P)||t?.files[0],[t,P]);y.useEffect(()=>{if(t){const l={};t.variables.forEach(o=>{l[o.name]=o.defaultValue??""}),L(l),U(t.files[0]?.id||null)}},[t]);const x=y.useMemo(()=>t?t.files.filter(l=>l.condition?Ye(l.condition,O):!0).map(l=>({path:pe(`${l.path}/${l.name}`,O,t.engine),content:pe(l.content,O,t.engine),language:l.language})):[],[t,O]),h=y.useCallback(l=>{W(l.id),v?.(l)},[v]),i=y.useCallback(()=>{n?.(x,O)},[x,O,n]),S=y.useCallback(()=>{const l={id:crypto.randomUUID(),name:"New Template",description:"Custom template",category:"custom",icon:"file",engine:b,variables:[{id:"1",name:"name",type:"string",required:!0,defaultValue:"MyName"}],files:[{id:"1",name:"{{name}}.ts",path:"src",language:"typescript",content:`// {{name}}
331
+ export const {{name}} = {};`}]};B(o=>[...o,l]),W(l.id),J(!1),k?.(l)},[b,k]),u=y.useCallback((l,o)=>{if(!t)return;const z={...t,files:t.files.map(R=>R.id===l?{...R,content:o}:R)};B(R=>R.map(_=>_.id===z.id?z:_)),d?.(z)},[t,d]),H=y.useCallback(()=>{if(!t)return;const l={id:crypto.randomUUID(),name:"new-file.ts",path:"src",language:"typescript",content:`// New file
332
+ `},o={...t,files:[...t.files,l]};B(z=>z.map(R=>R.id===o.id?o:R)),U(l.id),d?.(o)},[t,d]),X=y.useCallback(l=>{if(!t)return;const o={...t,files:t.files.filter(z=>z.id!==l)};B(z=>z.map(R=>R.id===o.id?o:R)),U(o.files[0]?.id||null),d?.(o)},[t,d]),p=l=>{const o=O[l.name];switch(l.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!o,onChange:z=>L(R=>({...R,[l.name]:z.target.checked}))}),e.jsx("span",{children:l.name})]});case"select":return e.jsx("select",{value:String(o),onChange:z=>L(R=>({...R,[l.name]:z.target.value})),style:{width:"100%",padding:"8px 12px",background:"var(--text-secondary, #374151)",border:"1px solid var(--nice-text-secondary, #4b5563)",borderRadius:6,color:"var(--bg-primary, #fff)"},children:l.options?.map(z=>e.jsx("option",{value:z,children:z},z))});case"array":return e.jsx("input",{type:"text",value:Array.isArray(o)?o.join(", "):"",onChange:z=>L(R=>({...R,[l.name]:z.target.value.split(",").map(_=>_.trim())})),placeholder:"value1, value2, value3",style:{width:"100%",padding:"8px 12px",background:"var(--text-secondary, #374151)",border:"1px solid var(--nice-text-secondary, #4b5563)",borderRadius:6,color:"var(--bg-primary, #fff)"}});case"number":return e.jsx("input",{type:"number",value:Number(o),onChange:z=>L(R=>({...R,[l.name]:Number(z.target.value)})),style:{width:"100%",padding:"8px 12px",background:"var(--text-secondary, #374151)",border:"1px solid var(--nice-text-secondary, #4b5563)",borderRadius:6,color:"var(--bg-primary, #fff)"}});default:return e.jsx("input",{type:"text",value:String(o??""),onChange:z=>L(R=>({...R,[l.name]:z.target.value})),style:{width:"100%",padding:"8px 12px",background:"var(--text-secondary, #374151)",border:"1px solid var(--nice-text-secondary, #4b5563)",borderRadius:6,color:"var(--bg-primary, #fff)"}})}};return e.jsxs("div",{className:`nice-code-template ${M||""}`,style:{display:"flex",height:"100%",background:"var(--bg-canvas, #0d1117)",color:"var(--text-primary, #e6edf3)",fontFamily:"system-ui, sans-serif",...w},"data-testid":q,children:[T&&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(s.oa,{name:"book",size:16})," Templates"]}),e.jsx("button",{onClick:S,style:{padding:"4px 8px",background:"var(--color-primary, #3b82f6)",border:"none",borderRadius:4,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ New"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[A.length>0&&e.jsxs("div",{style:{padding:8},children:[e.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #8b949e)",padding:"8px 8px 4px",fontWeight:500},children:"CUSTOM"}),A.map(l=>e.jsxs("div",{onClick:()=>h(l),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:N===l.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(s.oa,{name:l.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:l.name}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #8b949e)"},children:l.category})]})]},l.id))]}),f.map(l=>e.jsxs("div",{style:{padding:8},children:[e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted, #8b949e)",padding:"8px 8px 4px",fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:l.icon,size:12}),l.name.toUpperCase()]}),l.templates.map(o=>e.jsxs("div",{onClick:()=>h(o),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:N===o.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(s.oa,{name:o.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:o.name}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #8b949e)"},children:o.description})]})]},o.id))]},l.id))]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--bg-elevated, #161b22)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(s.oa,{name:t.icon||"file",size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:t.name}),e.jsx("div",{style:{fontSize:12,color:"var(--text-muted, #8b949e)"},children:t.description})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>c?.(t,"json"),style:{padding:"6px 12px",background:"var(--text-secondary, #374151)",border:"none",borderRadius:6,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:i,style:{padding:"6px 16px",background:"var(--color-success, #22c55e)",border:"none",borderRadius:6,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"zap",size:14})," Generate"]})]})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--bg-elevated, #161b22)"},children:["variables","editor","preview"].map(l=>e.jsxs("button",{onClick:()=>E(l),style:{padding:"10px 20px",background:m===l?"var(--bg-canvas, #0d1117)":"transparent",border:"none",borderBottom:m===l?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",color:m===l?"var(--bg-primary, #fff)":"var(--text-muted, #8b949e)",cursor:"pointer",textTransform:"capitalize"},children:[l==="variables"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"settings",size:14})," "]}),l==="editor"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"edit",size:14})," "]}),l==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.oa,{name:"eye",size:14})," "]}),l]},l))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[m==="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:"Template Variables"}),t.variables.map(l=>e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",fontSize:12,color:"var(--text-muted, #8b949e)",marginBottom:4},children:[l.name,l.required&&e.jsx("span",{style:{color:"var(--color-error, #ef4444)"},children:" *"})]}),p(l),l.description&&e.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #6b7280)",marginTop:4},children:l.description})]},l.id))]})}),m==="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(--text-muted, #8b949e)"},children:"Files"}),e.jsx("button",{onClick:H,style:{padding:"2px 6px",background:"var(--text-secondary, #374151)",border:"none",borderRadius:4,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"+"})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:t.files.map(l=>e.jsxs("div",{onClick:()=>U(l.id),style:{padding:"8px 12px",cursor:"pointer",background:P===l.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:P===l.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:l.name}),e.jsx("button",{"aria-label":"Remove file",onClick:o=>{o.stopPropagation(),X(l.id)},style:{background:"none",border:"none",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:12,opacity:.7,display:"inline-flex",alignItems:"center"},children:e.jsx(s.oa,{name:"close",size:14})})]},l.id))})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--bg-elevated, #161b22)",fontSize:12},children:[r.path,"/",r.name,r.condition&&e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)",marginLeft:8},children:["(if: ",r.condition,")"]})]}),e.jsx("textarea",{value:r.content,onChange:l=>u(r.id,l.target.value),style:{flex:1,padding:16,background:"var(--bg-canvas, #0d1117)",color:"var(--text-primary, #e6edf3)",border:"none",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,lineHeight:1.5,resize:"none"}})]})})]}),m==="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(--bg-elevated, #161b22)"},children:e.jsxs("span",{style:{fontSize:12,color:"var(--text-muted, #8b949e)"},children:[x.length," file(s) will be generated"]})}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:x.map((l,o)=>e.jsxs("div",{style:{borderBottom:"1px solid var(--nice-border, #30363d)"},children:[e.jsxs("div",{style:{padding:"8px 16px",background:"var(--text-primary, #1f2937)",fontFamily:"monospace",fontSize:12,color:"var(--text-muted, #8b949e)",display:"flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"file",size:14})," ",l.path]}),e.jsx("pre",{style:{margin:0,padding:16,background:"var(--bg-canvas, #0d1117)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:12,lineHeight:1.5,overflow:"auto"},children:l.content})]},o))})]})]})]}):e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"var(--text-muted, #8b949e)"},children:[e.jsx("span",{style:{marginBottom:16},children:e.jsx(s.oa,{name:"book",size:64})}),e.jsx("span",{style:{fontSize:18},children:"Select a template"}),e.jsx("span",{style:{fontSize:12,marginTop:4},children:"Choose from the library or create a new template"}),e.jsxs("button",{onClick:S,style:{marginTop:20,padding:"10px 20px",background:"var(--color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--bg-primary, #fff)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.oa,{name:"plus",size:14})," Create Template"]})]})})]})},Xe=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeTemplate:ve},Symbol.toStringTag,{value:"Module"}));exports.NiceAPIFlow=he;exports.NiceAPIFlow$1=Ie;exports.NiceCodePreview=Te;exports.NiceCodeTemplate=ve;exports.NiceCodeTemplate$1=Xe;exports.NiceComponentDesigner=$e;exports.NiceDataMapper=ye;exports.NiceDataMapper$1=Pe;exports.NiceEventOrchestrator=be;exports.NiceEventOrchestrator$1=We;exports.NiceLowCodeStudio=ke;exports.NicePageBuilder=Ce;exports.NiceStateDesigner=me;exports.NiceStateDesigner$1=Ee;exports.NiceTestBuilder=fe;exports.NiceTestBuilder$1=Ge;