import{h as C,i as v,r as e,j as n}from"./vendor-react-9M-xu2bR.js";import{AppCreationWizard as x}from"./index-Dv78M4Xq.js";import{z as S}from"./framework-BM176iet.js";import"./vendor-objectstack-YKtcdalX.js";import{b,a as y}from"./index-CTBPkbPG.js";import{b as s}from"./vendor-ui-utils-3tkeUVaX.js";import"./vendor-icons-ndICq8DC.js";import"./infrastructure-n1j_TN6w.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-zod-DxQVy2_o.js";import"./ui-components-BxvihT61.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-charts-BLNOCZWl.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";const i="objectui-app-wizard-draft";function K(){const t=C(),{appName:r}=v(),{objects:l,refresh:p}=b(),c=y(),f=(l||[]).map(a=>({name:a.name,label:a.label||a.name,icon:a.icon,selected:!1})),u=e.useCallback(()=>{try{const a=localStorage.getItem(i);if(a)return JSON.parse(a)}catch{}},[]),d=e.useCallback(async a=>{try{const o=S(a),m=c?.getClient();m&&await m.meta.saveItem("app",a.name,o),localStorage.removeItem(i),s.success(`Application "${a.title}" created successfully`),await p?.(),t(`/apps/${a.name}`)}catch(o){s.error(o?.message||"Failed to create application")}},[t,p,c]),g=e.useCallback(()=>{t(r?`/apps/${r}`:"/")},[t,r]),h=e.useCallback(a=>{try{localStorage.setItem(i,JSON.stringify(a)),s.info("Draft saved")}catch{}},[]);return n.jsx("div",{className:"mx-auto max-w-4xl py-8 px-4","data-testid":"create-app-page",children:n.jsx(x,{availableObjects:f,initialDraft:u(),onComplete:d,onCancel:g,onSaveDraft:h})})}export{K as CreateAppPage};
