1import{A,r as h,j as e,I as l,T as B,B as y,t as T}from"./app-CZw4zvFM.js";import{F as i}from"./index-Tmleijx2.js";import{S as x}from"./index-D7FWo8t1.js";import{C as I}from"./index-BlW28zjE.js";import{R as w,C as g}from"./row-M-1fLFv3.js";import{I as S}from"./index-75SXKuUs.js";import{B as z}from"./index-CXJxjv7i.js";/* empty css */import"./useForm-D-jYjTVi.js";import"./useBreakpoint-PA8SwT4Z.js";import"./Addon-DOudmed9.js";import"./EllipsisOutlined-B7OjL6qX.js";import"./Overflow-uTMTJwUS.js";import"./PlusOutlined-CcDZkb5g.js";import"./Input-DSSJiXAe.js";import"./EyeOutlined-CvZlSzKJ.js";import"./SearchOutlined-C9JuSteG.js";const{Text:v}=B,{useToken:M}=T,W=({selectedFile:o,onSave:R})=>{const{message:j}=A.useApp(),{token:r}=M(),[n]=i.useForm(),[c,m]=h.useState(!1),[C,f]=h.useState(!1);h.useEffect(()=>{if(o&&n){n.resetFields(),m(!1);const t=o.metadata||o.custom_properties?.metadata||{};let s=[];Array.isArray(t)?s=t.filter(a=>a&&typeof a=="object"&&a.key&&a.key.trim()!==""):typeof t=="object"&&t!==null&&(s=Object.entries(t).filter(([a])=>a&&a.trim()!=="").map(([a,p])=>({key:a.trim(),value:p}))),n.setFieldsValue({metadata:s})}},[o,n]);const d=()=>{m(!0)},k=async t=>{try{f(!0),await R(t),m(!1),j.success("Metadata updated successfully")}catch(s){j.error("Failed to save metadata: "+(s instanceof Error?s.message:"Unknown error"))}finally{f(!1)}};return o?e.jsx(i,{form:n,layout:"vertical",onFinish:k,onValuesChange:d,children:e.jsxs(x,{orientation:"vertical",size:"large",style:{width:"100%"},children:[e.jsx(I,{title:e.jsxs(x,{children:[e.jsx(l,{name:"Tag"}),e.jsx("span",{children:"Custom Properties"}),e.jsxs(v,{style:{fontSize:12,color:r.colorTextSecondary},children:["(",(()=>{const t=o.metadata||o.custom_properties?.metadata||{};return`${Array.isArray(t)?t.length:Object.keys(t).length} properties`})(),")"]}),c&&e.jsx(z,{dot:!0,color:"orange"})]}),size:"small",style:{borderRadius:r.borderRadius,boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},children:e.jsx(i.List,{name:"metadata",children:(t,{add:s,remove:a})=>e.jsxs(x,{orientation:"vertical",style:{width:"100%"},size:"middle",children:[t.length===0&&e.jsxs("div",{style:{textAlign:"center",padding:r.paddingLG,color:r.colorTextSecondary,background:r.colorBgLayout,borderRadius:r.borderRadius,border:`1px dashed ${r.colorBorder}`},children:[e.jsx(l,{name:"Tag",style:{fontSize:24,marginBottom:r.marginSM}}),e.jsx("div",{children:"No custom metadata added yet"}),e.jsx(v,{style:{fontSize:12},children:'Click "Add metadata" to create key-value pairs'})]}),t.map(({key:p,name:u,...b})=>e.jsx("div",{style:{padding:r.paddingSM,background:r.colorBgContainer,border:`1px solid ${r.colorBorder}`,borderRadius:r.borderRadius},children:e.jsxs(w,{gutter:12,align:"middle",children:[e.jsx(g,{span:10,children:e.jsx(i.Item,{...b,name:[u,"key"],style:{marginBottom:0},children:e.jsx(S,{placeholder:"Property name",onChange:d,style:{borderRadius:r.borderRadius}})})}),e.jsx(g,{span:10,children:e.jsx(i.Item,{...b,name:[u,"value"],style:{marginBottom:0}
1,children:e.jsx(S,{placeholder:"Property value",onChange:d,style:{borderRadius:r.borderRadius}})})}),e.jsx(g,{span:4,children:e.jsx(y,{type:"text",icon:e.jsx(l,{name:"Delete"}),onClick:()=>{a(u),d()},danger:!0,style:{display:"flex",alignItems:"center",justifyContent:"center"}})})]})},p)),e.jsx(y,{type:"dashed",onClick:()=>{s(),d()},icon:e.jsx(l,{name:"Plus"}),block:!0,style:{borderRadius:r.borderRadius,height:40,borderStyle:"dashed"},children:"Add metadata property"})]})})}),e.jsx(y,{type:"primary",htmlType:"submit",loading:C,disabled:!c,block:!0,style:{height:40,borderRadius:r.borderRadius},children:c?"Save Metadata":"Saved"})]})}):null};export{W as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.