1import{d as q,y as z,u as H,T as K,o as i,c as p,b as t,t as r,f as e,g as d,I as m,i as x,m as b,j as O,l as P,k as T,F as W,e as G,n as Q,p as X,A as Y,aK as S,r as v,D as E}from"./index-X3ku3MSB.js";import{_ as I}from"./JsonCodeEditor.vue_vue_type_script_setup_true_lang-Bf3XUivc.js";import{d as Z}from"./IndexPage-Bbut22W7.js";import"./LocaleSwitcher.vue_vue_type_script_setup_true_lang-C0v4-J_q.js";import"./useSeoMeta-ANddsuqs.js";const ee={class:"mt-4 grid min-h-0 flex-1 gap-6 md:grid-cols-2 md:items-stretch"},te={class:"flex min-h-72 flex-col gap-3 rounded-2xl border border-slate-100/90 bg-white/90 p-4 shadow-lg shadow-slate-900/5 backdrop-blur-sm sm:p-5 md:min-h-0"},oe={class:"flex shrink-0 flex-wrap items-center justify-between gap-2"},se={class:"text-sm font-bold text-slate-900"},ne={class:"flex flex-wrap items-center gap-2"},re={key:0,class:"rounded-xl bg-amber-50 px-3 py-2",role:"alert"},le={class:"flex items-start gap-1.5 text-sm text-amber-800"},ae={class:"min-h-0 flex-1"},ie={class:"flex min-h-72 flex-col gap-3 rounded-2xl border border-slate-100/90 bg-white/90 p-4 shadow-lg shadow-slate-900/5 backdrop-blur-sm sm:p-5 md:min-h-0"},de={class:"flex shrink-0 flex-wrap items-center justify-between gap-2"},ce={class:"text-sm font-bold text-slate-900"},ue={class:"flex flex-wrap items-center gap-2"},pe={class:"sr-only",for:"json-indent"},me=["value"],xe=["disabled"],fe=["disabled"],be={key:0,class:"rounded-xl bg-red-50 px-3 py-2",role:"alert"},he={class:"text-sm font-medium text-red-800"},ye={key:0,class:"mt-1 text-xs text-red-700"},ve={class:"min-h-0 flex-1"},ge={key:1,class:"shrink-0 text-xs font-medium text-slate-500"},Fe=q({__name:"FormatWorkspace",props:S({fileErrorKey:{},formatApi:{}},{sharedJson:{required:!0},sharedJsonModifiers:{}}),emits:S(["importFile","loadSample","clearSource"],["update:sharedJson"]),setup(f,{emit:J}){const g=z(f,"sharedJson"),{indent:h,outputText:l,error:a,stats:k,format:w,minify:_}=f.formatApi,y=J,{t:n}=H(),j=v(null),B=[{value:2,labelKey:"json.format.indent2"},{value:4,labelKey:"json.format.indent4"},{value:"tab",labelKey:"json.format.indentTab"}],c=v(!1),u=v(!1),{start:M,stop:C}=K(()=>{c.value=!1},1500,{immediate:!1}),{start:R,stop:F}=K(()=>{u.value=!1},1500,{immediate:!1}),A=E(()=>c.value?n("json.actions.copied"):u.value?n("json.actions.copyFailed"):n("json.actions.copy"));function D(){j.value?.click()}function L(V){const o=V.target;if(!(o instanceof HTMLInputElement))return;const s=o.files?.[0];o.value="",s&&y("importFile",s)}async function N(){if(l.value)try{await navigator.clipboard.writeText(l.value),u.value=!1,F(),c.value=!0,C(),M()}catch{c.value=!1,C(),u.value=!0,F(),R()}}function U(){l.value&&Z(l.value)}const $=E(()=>a.value!=null&&a.value.line!=null&&a.value.column!=null);return(V,o)=>(i(),p("div",ee,[t("section",te,[t("div",oe,[t("h2",se,r(e(n)("json.format.source")),1),t("div",ne,[t("input",{ref_key:"fileInput",ref:j,type:"file",accept:".json,application/json",class:"hidden",onChange:L},null,544),t("button",{type:"button",class:"inline-flex cursor-pointer items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-600 transition-colors duration-200 hover:border-sky-300 hover:bg-sky-50 hover:text-sky-800",onClick:D},[d(e(m),{icon:"heroicons:arrow-up-tray",class:"h-3.5 w-3.5"}),x(" "+r(e(n)("json.actions.import")),1)]),t("button",{type:"button",class:"inline-flex cursor-pointer items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-600 transition-colors duration-200 hover:border-sky-300 hover:bg-sky-50 hover:text-sky-800",onClick:o[0]||(o[0]=s=>y("loadSample"))},[d(e(m),{icon:"heroicons:document-text",class:"h-3.5 w-3.5"}),x(" "+r(e(n)("json.actions.sample")),1)]),t("button",{type:"button",class:"inline-flex cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-xs font-semibold text-slate-400 transition-colors duration-200 hover:bg-slate-100 hover:text-slate-700",onClick:o[1]||(o[1]=s=>y("clearSource"))},r(e(n)("json.actions.clear")),1)])]),f.fileErrorKey?(i(),p("div",re,[t("p",le,[d(e(m),{icon:"heroicons:exclamation-triangle",class:"mt-0.5 h-4 w-4 shrink-0"}),x(" "+r(e(n)(f.fileErrorKey)),1)])])):b("",!0),t("div",ae,[d(I,{modelValue:g.value,"onUpdate:modelValue":o[2]||(o[2]=s=>g.value=s)},null,8,["modelValue"])])]),t("section",ie,[t("div",de,[t("h2",ce,r(e(n)("json.format.output")),1),t("div",ue,[t("label",pe,r(e(n)("json.format.indent")),1),O(t("select",{id:"json-indent","onUpdate:modelValue":o[3]||(o[3]=s=>T(h)?h.value=s:null),class:"cursor-pointer rounded-xl border border-slate-200 bg-white px-2.5 py-2 text-xs font-semibold text-slate-700 transition-colors duration-200 outline-none focus:border-sky-500 focus:ring-2 focus:ring-sky-500/20"},[(i(),p(W,null,G(B,s=>t("option",{key:String(s.value),value:s.value},r(e(n)(s.labelKey)),9,me)),64))],512),[[P,e(h)]]),t("button",{type:"button",class:"inline-flex cursor-pointer items-center gap-1.5 rounded-xl bg-sky-700 px-3 py-2 text-xs font-semibold text-white transition-all duration-200 hover:bg-sky-600",onClick:o[4]||(o[4]=(...s)=>e(w)&&e(w)(...s))},[d(e(m),{icon:"heroicons:sparkles",class:"h-3.5 w-3.5"}),x(" "+r(e(n)("json.actions.format")),1)]),t("button",{type:"button",class:"inline-flex cursor-pointer items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-600 transition-colors duration-200 hover:border-sky-300 hover:text-sky-800",onClick:o[5]||(o[5]=(...s)=>e(_)&&e(_)(...s))},r(e(n)("json.actions.minify")),1),t("button",{type:"button",disabled:!e(l),class:Q(e(X)("inline-flex cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-40",e(c)?"bg-sky-100 text-sky-800":e(u)?"bg-amber-100 text-amber-900":"border border-slate-200 bg-white text-slate-600 hover:border-sky-300 hover:text-sky-800")),onClick:N},[d(e(m),{icon:e(c)?"heroicons:check":e(u)?"heroicons:exclamation-triangle":"heroicons:clipboard-document",class:"h-3.5 w-3.5"},null,8,["icon"]),x(" "+r(e(A)),1)],10,xe),t("button",{type:"button",class:"inline-flex cursor-pointer items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-600 transition-colors duration-200 hover:border-sky-300 hover:text-sky-800 disabled:cursor-not-allowed disabled:opacity-40",disabled:!e(l),onClick:U},[d(e(m),{icon:"heroicons:arrow-down-tray",class:"h-3.5 w-3.5"}),x(" "+r(e(n)("json.actions.download")),1)],8,fe)])]),e(a)?(i(),p("div",be,[t("p",he,r(e(a).message),1),e($)?(i(),p("p",ye,r(e(n)("json.format.errorAt",{line:e(a).line,column:e(a).column})),1)):b("",!0)])):b("",!0),t("div",ve,[(i(),Y(I,{key:"format-output",modelValue:e(l),"onUpdate:modelValue":o[6]||(o[6]=s=>T(l)?l.value=s:null),readonly:""},null,8,["modelValue"]))]),e(l)?(i(),p("p",ge,r(e(n)("json.format.stats",{chars:e(k).chars,bytes:e(k).bytes})),1)):b("",!0)])]))}});
1export{Fe 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.