import{u as m,R as n,j as a,S as d,h,H as c}from"./vendor-ClLR6ncd.js";import{b as f,s as S,S as x}from"./model-Cn8i8hm_.js";import{L as j}from"./index-OtVJl4GC.js";import{E as l}from"./Messages-BRmQDxrZ.js";import"./ui-DKzyPIqx.js";import"./lodash-ZyeDnt0e.js";import"./model-Dfrorm_S.js";import{c as g}from"./model-AmaTU-rL.js";import"./ui-BOPU8Yl4.js";import"./index-CQ79H_Lz.js";import"./useNamespaces-B-2wwTCG.js";import"./model-DgFcCvKB.js";import"./WithMeasure-BDk9QPMF.js";import"./Autocomplete-Cjt7Q9VV.js";import"./Chip-DoCs8Smb.js";import"./highlightSearch-BTHB3jgf.js";import"./TableRow-CGDSOtFZ.js";import"./TableSortLabel-BJFq2axQ.js";import"./Box-Co2WcNPC.js";import"./TypographyWithTooltip-BFAG3Va9.js";import"./Link-BLwKPJFF.js";function T(){const{shapeId:e}=m(),t=!1,r=g(t,decodeURI(e)),[i,p]=n.useState({dirty:!1,value:"",fullUri:t}),o=n.useCallback(u=>{p({dirty:!0,value:u,fullUri:t})},[t]),s=f(r.data,i.value,"../..");return n.useEffect(()=>{r.isSuccess&&r.data&&(!i.dirty||i.fullUri!==t)&&o(JSON.stringify(r.data,null,2))},[t,i.dirty,i.fullUri,o,r.data,r.isSuccess]),r.isLoading?a.jsx(j,{}):r.isError?a.jsx(l,{error:r.error}):r.isSuccess&&!r.data?a.jsx(l,{error:`Shape not found by triple id ${e}`}):a.jsxs(d,{spacing:2,sx:{flexGrow:1},children:[a.jsx(d,{direction:"row",spacing:2,alignItems:"center",children:a.jsxs(h,{noWrap:!0,variant:"h4",children:["Edit ",S(r.data)||e," SHACL Shape"]})}),a.jsx(x,{value:i.value,onChange:o}),a.jsx(l,{error:s.error}),a.jsxs(d,{direction:"row",spacing:2,children:[a.jsx(c,{disabled:s.isLoading,onClick:()=>{p({dirty:!1,value:JSON.stringify(r.data,null,2),fullUri:t})},children:"Reset"}),a.jsx(c,{variant:"contained",disabled:s.isLoading||!i.dirty,onClick:s.mutate,children:"Save"})]})]})}export{T as default};
