PageSourceSearch

https://toolbreezy.com/_next/static/chunks/19351-17e2fd20a69e4a66.js

js toolbreezy.com collected 2026-09-24 14:56:22 UTC 48,377 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[19351],{19351:(e,t,r)=>{r.r(t),r.d(t,{default:()=>U});var s=r(95155),n=r(12115),a=r(24722),l=r(65229),o=r(24033),i=r(52056),c=r(76907),d=r(39867),m=r(75426),u=r(5917),h=r(27784),p=r(12513),x=r(97003),f=r(33789),g=r(90235),b=r(33534),w=r(25016),k=r(34593),y=r(8879),$=r(99187),v=r(31258),j=r(65735),N=r(14827),T=r(16110),M=r(2042);let S="tb:excel-to-xml:v1",C={sheet:"One sheet, records under a single root",workbook:"Every sheet, each wrapped in its own sheet element",flat:"Every sheet, records side by side with a sheet attribute"},A={omit:"Leave the element out",nil:"Write it as xsi:nil",empty:"Write an empty element"},R={nil:"Write it as xsi:nil",text:"Keep the literal #N/A text",omit:"Leave the element out"},L={element:"a child element",attribute:"an attribute on the record",skip:"left out entirely"},D={...j.lp,headerRow:1};function X(e,t){return{root:e.root,record:e.record,structure:e.structure,namespace:e.namespace,pretty:e.pretty,indent:e.indent,blanks:e.blanks,errors:e.errors,cdata:e.cdata,declaration:e.declaration,version:e.version,percentX100:e.percentX100,sheetAttribute:e.sheetAttribute,limits:e.limits,limit:t}}function F(e,t,r){let s=Math.max(1,e.maxCol+1),n=e.rows,a=n.map(e=>{let t=Array(s).fill(null);for(let r of e.cells)r.c>=0&&r.c<s&&(t[r.c]=r);return t}),l=n[0]?.r??0,o=n[n.length-1]?.r??-1,i=0===n.length?0:o-l+1-n.length,c=new Map;n.forEach((e,t)=>c.set(e.r,t));let d=0;for(let t of e.merges){let e=t.c2>t.c1,n=t.r2>t.r1;if(!e&&!(n&&r))continue;let l=a[c.get(t.r1)??-1],o=l?.[t.c1]??null;if(o)for(let e=t.r1;e<=t.r2;e++){if(e>t.r1&&!r)continue;let n=c.get(e);if(void 0===n)continue;let l=a[n];if(l)for(let r=t.c1;r<=Math.min(t.c2,s-1);r++)(e!==t.r1||r!==t.c1)&&!l[r]&&(l[r]={...o,c:r},d++)}}let m=t>0?t-1:-1,u=m>=0&&m<a.length?a[m]??Array(s).fill(null):Array(s).fill(null),h=[];for(let e=0;e<s;e++){let r=(u[e]?.shown??"").replace(/\s+/g," ").trim();h.push(t>0&&""!==r?r:`column ${(0,y.WD)(e)}`)}let p=m>=0?m+1:0;return{width:s,rows:a.slice(p),rowRefs:n.slice(p).map(e=>e.r+1),headers:h,blankRows:i,filledFromMerge:d}}let E=Date.UTC(1899,11,30);function O(e,t,r,s=0,n=0){return(Date.UTC(e,t-1,r,s,n)-E)/864e5}function P(e,t){return{c:e,kind:"text",shown:t,raw:t,formula:""}}function W(e,t,r="General"){return{c:e,kind:"number",shown:(0,y.ZV)(t,r),raw:String(t),formula:"",text:String(t),code:r,value:t}}function z(e,t){return{c:e,kind:"number",shown:(0,y.ln)(Number(t)),raw:t,formula:"",text:t,code:"0",value:Number(t)}}function J(e,t,r,s){let n=(0,y.zi)(t,r,!1);return{c:e,kind:"date",shown:n.replace("T"," "),raw:n.replace("T"," "),formula:"",code:s,value:t,dateKind:r,iso:n}}function U(){let[e,t]=(0,n.useState)(null),[E,U]=(0,n.useState)(""),[_,I]=(0,n.useState)(D),[q,B]=(0,n.useState)({}),[K,V]=(0,n.useState)(null),[G,H]=(0,n.useState)(!0),[Z,Q]=(0,n.useState)("xml"),[Y,ee]=(0,n.use
1State)(!1),[et,er]=(0,n.useState)(""),[es,en]=(0,n.useState)(!1),[ea,el]=(0,n.useState)(!1),eo=(0,n.useRef)(null),ei=(0,n.useRef)(0);(0,n.useEffect)(()=>{let e={...D};try{let t=window.localStorage.getItem(S);t&&(e={...e,...JSON.parse(t)})}catch{}let t=new URLSearchParams(window.location.search),r=t.get("st");r&&r in C&&(e.structure=r);let s=t.get("bl");s&&s in A&&(e.blanks=s);let n=t.get("er");n&&n in R&&(e.errors=n);let a=t.get("r");a&&(e.root=a.slice(0,60));let l=t.get("rc");l&&(e.record=l.slice(0,60));let o=t.get("ns");o&&(e.namespace=o.slice(0,200));let i=(0,p.LK)(t,"hr",0,50);null!==i&&(e.headerRow=Math.floor(i));let c=Number(t.get("i"));(2===c||4===c)&&(e.indent=c),"1"===t.get("c")&&(e.cdata=!0),"1"===t.get("px")&&(e.percentX100=!0),"0"===t.get("nl")&&(e.limits=!1),"0"===t.get("pr")&&(e.pretty=!1),e.structure in C||(e.structure=D.structure),e.blanks in A||(e.blanks=D.blanks),e.errors in R||(e.errors=D.errors),[2,4].includes(e.indent)||(e.indent=D.indent),"1.0"!==e.version&&"1.1"!==e.version&&(e.version="1.0"),e.limit=0,I(e)},[]),(0,h.Vd)(S,()=>JSON.stringify(_),[_]);let ec=(0,n.useCallback)(()=>{let e=new URLSearchParams({st:_.structure,bl:_.blanks,er:_.errors,r:_.root,rc:_.record,hr:String(_.headerRow),i:String(_.indent)});return""!==_.namespace.trim()&&e.set("ns",_.namespace.trim()),_.cdata&&e.set("c","1"),_.percentX100&&e.set("px","1"),_.limits||e.set("nl","0"),_.pretty||e.set("pr","0"),e},[_]),ed=(0,n.useCallback)(async e=>{if(!e)return;let r=Array.from(e),s=r.find(e=>/\.(xlsx|xlsm|xltx|xltm|ods|ots)$/i.test(e.name));if(!s){let e=r[0],t="That is not a spreadsheet this tool can read. Bring an .xlsx, .xlsm or .ods file.";e&&/\.(xls|xlsb)$/i.test(e.name)?t="That is the old binary Excel format, which is a different thing entirely. Open it in Excel or LibreOffice, save it as .xlsx, and bring it back.":e&&/\.csv$/i.test(e.name)?t="That is a CSV, not a workbook. Our CSV to XML converter is the right page for it.":e&&/\.xml$/i.test(e.name)&&(t="That is already XML. The XML formatter will tidy it, and XML to JSON will convert it."),er(t);return}er(""),ee(!0);let n=++ei.current,a={name:s.name,size:s.size},l="";try{a.book=/\.(ods|ots)$/i.test(s.name)?await (0,$.G2)(s):await (0,$.Fx)(s)}catch(e){l=(0,M.oh)(e,e instanceof Error?e.message:"That file could not be read.")}if(ei.current!==n)return;if(ee(!1),l){t(null),U(""),er(l);return}B({}),V(null),t(a);let o=a.book?.sheets??[],i=o.find(e=>!e.hidden&&e.rows.length>0)??o[0];U(i?.name??"")},[]);(0,n.useEffect)(()=>{let e=e=>{let t=e.clipboardData?.files;t&&t.length>0&&ed(t)};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[ed]);let em=e?.book?.sheets??[],eu=(0,n.useMemo)(()=>em.filter(e=>e.rows.length>0),[em]),eh=(0,n.useMemo)(()=>em.find(e=>e.name===E)??null,[em,E]),ep=(0,n.useMemo)(()=>eh?F(eh,_.headerRow,G):null,[eh,_.headerRow,G]),ex=(0,n.useMemo)(()=>eh&&ep?{name:eh.name,rows:ep.rows,rowRefs:ep.rowRefs,headers:ep.headers,width:ep.width}:null,[eh,ep]),ef=(0,n.useMemo)(()=>ex?(0,j.j7)(ex,q,_.percentX100):null,[ex,q,_.percentX100]),eg=(0,n.useMemo)(()=>{if(!ex||!ef)return null;if("sheet"===_.structure||eu.length<2)return{inputs:[ex],plans:[ef.columns]};let e=[],t=[];for(let r of eu){if(r.name===ex.name){e.push(ex),t.push(ef.columns);continue}let s=F(r,_.headerRow,G),n={name:r.name,rows:s.rows,rowRefs:s.rowRefs,headers:s.headers,width:s.width};e.push(n),t.push((0,j.j7)(n,{},_.percentX100).columns)}return{inputs:e,plans:t}},[ex,ef,_.structure,_.headerRow,_.percentX100,eu,G]),eb=(0,n.useMemo)(()=>eg?(0,j.Pk)(eg.inputs,eg.plans,X(_,0)):null,[eg,_]),ew=(0,n.useMemo)(()=>eg?(0,j.Pk)(eg.inputs,eg.plans,X(_,120)):null,[eg,_]),ek=(0,n.useMemo)(()=>{if(!eg||!eb)return"";let e=eg.inputs.map((e,t)=>({name:e.name,columns:eg.plans[t]??[]}));return(0,j.UM)(e,X(_,0),eb.nillable)},[eg,eb,_]),ey=(0,n.useMemo)(()=>eb?new TextEncoder().encode(eb.xml).length:0,[eb]),e$=(0,n.useMemo)(()=>{if(!eb)return null;let e=ey>2097152?ew:eb;if(!e)return null;let t=(0,j.y$)(_.record,"record").name;return{partial:e!==eb,records:e.records,result:(0,j.nr)(e.xml,e.slots,t,2e4)}},[eb,ew,ey,_.record]),ev=ew?.xml??"",ej="xsd"===Z?ek:ev,eN="xsd"===Z?ek:eb?.xml??"",eT=ef?.columns.filter(e=>"skip"!==e.placement)??[],eM=(ef?.columns.length??0)-eT.length,eS=(eb?.records??0)>(ew?.records??0);function eC(e){I(t=>({...t,...e}))}function eA(e,t){B(r=>({...r,[e]:{...r[e],...t}}))}let eR=e?e.name.replace(/\.(xlsx|xlsm|xltx|xltm|ods|fods|ots)$/i,"").replace(/[\\/:*?"<>|]/g,"-").replace(/\s+/g," ").trim()||"sheet":"workbook";async function eL(){if(eb&&ek&&!ea){el(!0);try{let{default:e}=await Promise.all([r.e(15376),r.e(7496)]).then(r.t.bind(r,7496,23)),t=new e;t.file(`${eR}.xml`,eb.xml),t.file(`${eR}.xsd`,ek);let s=await t.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}});(0,N.WN)(s,`${eR}-xml.zip`)}catch{er("The ZIP could not be built. Download the XML and the XSD one at a time instead.")}finally{el(!1)}}}let eD=e$?.result??null,eX=null!==eD&&eD.ran&&eD.wellFormed&&0===eD.lost;return(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-input",children:"Choose a spreadsheet"}),(0,s.jsxs)("div",{onDragOver:e=>{e.preventDefault(),en(!0)},onDragLeave:()=>en(!1),onDrop:e=>{e.preventDefault(),en(!1),ed(e.dataTransfer.files)},onClick:()=>eo.current?.click(),onKeyDown:e=>
1{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),eo.current?.click())},role:"button",tabIndex:0,"aria-label":"Choose a spreadsheet to convert to XML",className:(0,w.cn)("flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md border border-dashed px-4 py-8 text-center text-sm transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",es?"border-primary bg-accent":"border-input hover:bg-accent"),children:[(0,s.jsx)("span",{className:"font-medium",children:Y?"Reading your file...":"Click to choose an .xlsx or .ods file"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"or drag one into the box, or paste a file you copied. Nothing is uploaded."}),(0,s.jsx)("input",{ref:eo,id:"xx-input",type:"file",accept:".xlsx,.xlsm,.xltx,.xltm,.ods,.ots,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet",className:"hidden",onChange:e=>{ed(e.target.files),eo.current&&(eo.current.value="")}})]}),!e&&(0,s.jsx)(x.$,{variant:"outline",size:"sm",onClick:function(){er(""),B({}),V(null),ei.current++,t({name:"sample-orders.xlsx",size:0,book:function(){let e=["18 Colfax Ave\nSuite 300\nDenver CO 80202","4 Harbor Rd\nPortland ME 04101",`900 Mill St\vAkron OH 44301`,"77 Pine Way\nBoise ID 83702","12 Rue Cler\nParis"],t=[];for(let r of[["4019283746501928101","en-US","Ada Whitfield","Whitfield Supply",1284.5,[2026,1,15],[2026,1,22,9,30],.15,!0,0,"confirmed"],["4019283746501928102","en-GB","Grace Bell","Bell and Rowe",92.99,[2026,1,16],[2026,1,24,14,0],.05,!1,1,"confirmed"],["4019283746501928103","fr-FR","Alan Mercier","Mercier Freres",15400,[2026,1,18],[2026,2,3,8,15],.25,!0,2,null],["4019283746501928104","en-US","Rosa Nunez","Nunez Interiors",340.75,[2026,1,19],[2026,1,27,11,45],0,!1,3,"confirmed"],["4019283746501928105","de-DE","Karl Adler","Adler GmbH",7.05,[2026,1,21],[2026,2,9,16,20],.1,!0,4,"held"]]){let s=[];s.push(z(0,r[0])),s.push(P(1,r[1])),s.push(P(2,r[2])),s.push(P(3,r[3])),s.push(W(4,r[4],"#,##0.00"));let n=r[5];s.push(J(5,O(n[0]??2026,n[1]??1,n[2]??1),"date","yyyy-mm-dd"));let a=r[6];s.push(J(6,O(a[0]??2026,a[1]??1,a[2]??1,a[3],a[4]),"datetime","yyyy-mm-dd hh:mm")),s.push(W(7,r[7],"0%")),s.push(function(e,t){let r=t?"TRUE":"FALSE";return{c:8,kind:"bool",shown:r,raw:r,formula:""}}(0,r[8])),s.push(P(9,e[r[9]]??""));let l=r[10];s.push(null===l?{c:10,kind:"error",shown:"#N/A",raw:"#N/A",formula:""}:P(10,l)),t.push(s)}return{sheets:[{name:"Orders",hidden:!1,rows:[{r:0,cells:["Order ID","xml:lang","Customer Name","Customer/Name","2026 Total","Order Date","Ship By","Discount","Priority","Ship To","Status"].map((e,t)=>P(t,e))},...t.map((e,t)=>({r:t+1,cells:e}))],maxCol:10,rowsCapped:!1,colsCapped:!1,merges:[],staleFormulas:0,staleRefs:[]},{name:"Returns",hidden:!1,rows:[{r:0,cells:[P(0,"RMA"),P(1,"Order ID"),P(2,"Reason")]},{r:1,cells:[P(0,"RMA-1041"),z(1,"4019283746501928102"),P(2,"wrong size")]},{r:2,cells:[P(0,"RMA-1042"),z(1,"4019283746501928105"),P(2,"arrived damaged")]}],maxCol:2,rowsCapped:!1,colsCapped:!1,merges:[],staleFormulas:0,staleRefs:[]}],extraSheets:0,format:"xlsx",date1904:!1}}()}),U("Orders")},children:"Load a sample workbook"})]}),et&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:et}),e&&(0,s.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-3 text-sm",children:[(0,s.jsx)(a.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate font-medium",children:e.name}),(0,s.jsxs)("span",{className:"block text-xs text-muted-foreground",children:[e.size>0?`${(0,v.z)(e.size)}, `:"",em.length," sheet",1===em.length?"":"s",", ",eu.length," with data"]})]}),(0,s.jsx)(x.$,{variant:"ghost",size:"icon","aria-label":"Remove this file",onClick:function(){t(null),U(""),er(""),B({}),V(null)},children:(0,s.jsx)(l.A,{})})]}),em.length>0&&ep&&ef&&eb&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-2 rounded-lg border bg-card p-4",children:[(0,s.jsx)(g.J,{children:"Sheet to read the structure from"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:em.map(e=>{let t=0===e.rows.length,r=e.name===E;return(0,s.jsxs)("button",{type:"button",disabled:t,onClick:()=>{U(e.name),B({}),V(null)},className:(0,w.cn)("rounded-md border px-3 py-1.5 text-sm transition-colors",t&&"curs
1or-not-allowed opacity-50",r&&!t?"border-primary bg-accent font-medium":"hover:bg-accent"),children:[e.name,(0,s.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"empty":e.hidden?`hidden, ${e.rows.length} rows`:`${e.rows.length} rows`})]},e.name)})}),(e?.book?.extraSheets??0)>0&&(0,s.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-500",children:["This file carries more than ",k.gK," sheets. The first ",k.gK," were read and the other ",e?.book?.extraSheets," were never opened."]}),"sheet"!==_.structure&&eu.length>1&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["All ",eu.length," sheets with data go into the document. The renames and types below apply to ",E,", and every other sheet gets its own automatic types."]})]}),(0,s.jsxs)("div",{className:"grid gap-3 rounded-lg border bg-card p-4 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5 sm:col-span-2",children:[(0,s.jsx)(g.J,{htmlFor:"xx-structure",children:"Shape of the document"}),(0,s.jsx)("select",{id:"xx-structure",value:_.structure,onChange:e=>eC({structure:e.target.value}),className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:Object.keys(C).map(e=>(0,s.jsx)("option",{value:e,children:C[e]},e))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-root",children:"Root element"}),(0,s.jsx)(f.p,{id:"xx-root",value:_.root,onChange:e=>eC({root:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-record",children:"Element for each row"}),(0,s.jsx)(f.p,{id:"xx-record",value:_.record,onChange:e=>eC({record:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-1.5 sm:col-span-2",children:[(0,s.jsx)(g.J,{htmlFor:"xx-ns",children:"Target namespace, if the receiving system wants one"}),(0,s.jsx)(f.p,{id:"xx-ns",value:_.namespace,placeholder:"https://your-company.example/orders",onChange:e=>eC({namespace:e.target.value})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Leave it empty for no namespace. Filled in, the root carries it as the default xmlns and the schema is written with elementFormDefault qualified, which is what makes the two agree."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-header",children:"Header row"}),(0,s.jsxs)("select",{id:"xx-header",value:_.headerRow,onChange:e=>eC({headerRow:Number(e.target.value)}),className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:[(0,s.jsx)("option",{value:0,children:"No header, name the elements column A style"}),[1,2,3,4,5].map(e=>(0,s.jsxs)("option",{value:e,children:["Row ",e," of the filled rows"]},e))]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-indent",children:"Layout"}),(0,s.jsxs)("select",{id:"xx-indent",value:_.pretty?String(_.indent):"0",onChange:e=>{let t=e.target.value;"0"===t?eC({pretty:!1}):eC({pretty:!0,indent:Number(t)})},className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:[(0,s.jsx)("option",{value:"2",children:"Indented, two spaces"}),(0,s.jsx)("option",{value:"4",children:"Indented, four spaces"}),(0,s.jsx)("option",{value:"0",children:"One line, no indenting"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-3 rounded-lg border bg-card p-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,s.jsx)(g.J,{children:"Elements, attributes and the type each one gets"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[eT.length," in the record",eM>0?`, ${eM} left out`:"",","," ",eb.totalRecords," row",1===eb.totalRecords?"":"s"]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:ef.columns.map(e=>{let t=K===e.c,r="skip"===e.placement,n=e.mismatches>0||""!==e.renamed||""!==e.clash;return(0,s.jsxs)("button",{type:"button",onClick:()=>V(t?null:e.c),className:(0,w.cn)("flex items-center gap-2 rounded-md border px-3 py-1.5 text-left text-sm transition-colors",r&&"opacity-50",t?"border-primary bg-accent":"hover:bg-accent",!t&&n&&!r&&"border-amber-500/70"),children:[(0,s.jsxs)("span",{className:"font-mono text-xs",children:["attribute"===e.placement?"@":"",e.name]}),(0,s.jsxs)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r?"left out":j.ir[e.type],e.mismatches>0&&`, ${e.mismatches} do not fit`]}),""!==e.renamed&&(0,s.jsx)("span",{className:"rounded bg-amber-500/15 px-1 py-0.5 text-[11px] text-amber-700 dark:text-amber-400",children:"renamed"}),(0,s.jsx)(o.A,{className:(0,w.cn)("h-3.5 w-3.5 shrink-0 transition-transform",t&&"rotate-180")}
1)]},e.c)})}),null!==K&&(()=>{let e=ef.columns.find(e=>e.c===K);if(!e)return null;let t=(0,j.PX)(e);return(0,s.jsxs)("div",{className:"space-y-3 rounded-md border bg-background p-3 text-sm",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"font-medium",children:["Column ",(0,y.WD)(e.c),", headed ",e.header]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[e.filled," filled cell",1===e.filled?"":"s",", ",e.blanks," blank",e.errors>0?`, ${e.errors} holding an error`:"",". Read as"," ",j.ir[e.auto]," from the cells themselves.",e.percent&&" The cells are percent formatted, so 15% is stored as 0.15."]})]}),e.evidence.length>0&&(0,s.jsxs)("div",{className:"rounded-md border bg-muted/30 p-2.5",children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:"The cells that decided the type"}),(0,s.jsx)("ul",{className:"mt-1 space-y-0.5 font-mono text-xs",children:e.evidence.map(e=>(0,s.jsxs)("li",{children:[(0,s.jsx)("span",{className:"font-semibold",children:e.ref})," ",(0,s.jsxs)("span",{className:"text-muted-foreground",children:[""===e.value?"(no text)":e.value," reads as ",e.cls]})]},e.ref))})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-name",children:"Name in the XML"}),(0,s.jsx)(f.p,{id:"xx-name",value:e.input,onChange:t=>eA(e.c,{name:t.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-type",children:"Type"}),(0,s.jsx)("select",{id:"xx-type",value:e.type,onChange:t=>eA(e.c,{type:t.target.value}),className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:j._5.map(t=>(0,s.jsxs)("option",{value:t,children:[j.ir[t],t===e.auto?" (read from the cells)":""]},t))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-place",children:"Written as"}),(0,s.jsx)("select",{id:"xx-place",value:e.placement,onChange:t=>eA(e.c,{placement:t.target.value}),className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:Object.keys(L).map(e=>(0,s.jsx)("option",{value:e,children:L[e]},e))})]})]}),""!==e.renamed&&(0,s.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-500",children:["The header became ",e.name,", because ",e.renamed,"."]}),""!==e.clash&&(0,s.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-500",children:[e.clash,"."]}),t.length>0&&(0,s.jsxs)("div",{className:"rounded-md border border-sky-500/40 bg-sky-500/5 p-2.5 text-xs",children:[(0,s.jsx)("p",{className:"font-medium",children:"What the placement costs"}),(0,s.jsx)("ul",{className:"mt-1 space-y-0.5 text-muted-foreground",children:t.map(e=>(0,s.jsx)("li",{children:e},e))})]}),e.mismatches>0&&(0,s.jsxs)("div",{className:"space-y-1.5 rounded-md border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,s.jsxs)("p",{className:"font-medium",children:[e.mismatches," cell",1===e.mismatches?"":"s"," ",1===e.mismatches?"is":"are"," not ",j.ir[e.type],", so"," ",1===e.mismatches?"it is":"they are"," left out rather than written as a value the schema rejects"]}),(0,s.jsx)("ul",{className:"space-y-0.5 font-mono text-xs",children:e.mismatchRefs.map(e=>(0,s.jsx)("li",{children:e},e))}),e.mismatches>e.mismatchRefs.length&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The first ",e.mismatchRefs.length," are listed and"," ",e.mismatches-e.mismatchRefs.length," more were found. Switching this column to xs:string keeps every one of them."]})]})]})})(),ef.renames.length>0&&(0,s.jsxs)("div",{className:"space-y-0.5 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs",children:[(0,s.jsxs)("p",{className:"font-medium",children:[ef.renames.length," header",1===ef.renames.length?"":"s"," could not be an XML name as written"]}),ef.renames.slice(0,5).map(e=>(0,s.jsx)("p",{children:e},e)),ef.renames.length>5&&(0,s.jsxs)("p",{children:["and ",ef.renames.length-5," more were repaired the same way."]})]}),(0,s.jsxs)("div",{className:"space-y-1 border-t pt-3 text-xs text-muted-foreground",children:[ep.blankRows>
10&&(0,s.jsxs)("p",{children:[ep.blankRows," completely empty row",1===ep.blankRows?"":"s"," inside the used range ",1===ep.blankRows?"was":"were"," skipped."]}),ep.filledFromMerge>0&&(0,s.jsxs)("p",{children:[ep.filledFromMerge," cell",1===ep.filledFromMerge?"":"s"," sat inside a merged region and took the merged value, which is a reading of what the sheet meant rather than something the file stores."]}),eh&&eh.staleFormulas>0&&(0,s.jsxs)("p",{children:[eh.staleFormulas," cell",1===eh.staleFormulas?"":"s"," hold a formula whose last saved result is missing, so they come through as blank rather than as a zero.",eh.staleRefs.length>0&&` First one is ${eh.staleRefs[0]}.`]}),eh&&(eh.rowsCapped||eh.colsCapped)&&(0,s.jsxs)("p",{className:"text-amber-700 dark:text-amber-500",children:["This sheet is bigger than the limits here. Only the first ",k.pX," rows and"," ",k.Tj," columns were read, so the document below is not the whole sheet."]})]})]}),(0,s.jsxs)("div",{className:"grid gap-3 rounded-lg border bg-card p-4 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-blank",children:"A blank cell becomes"}),(0,s.jsx)("select",{id:"xx-blank",value:_.blanks,onChange:e=>eC({blanks:e.target.value}),className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:Object.keys(A).map(e=>(0,s.jsx)("option",{value:e,children:A[e]},e))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"xx-error",children:"An error cell becomes"}),(0,s.jsx)("select",{id:"xx-error",value:_.errors,onChange:e=>eC({errors:e.target.value}),className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",children:Object.keys(R).map(e=>(0,s.jsx)("option",{value:e,children:R[e]},e))})]}),(0,s.jsxs)("div",{className:"space-y-2 text-sm sm:col-span-2",children:[(0,s.jsxs)("label",{className:"flex items-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:_.limits,onChange:e=>eC({limits:e.target.checked}),className:"mt-0.5 h-4 w-4 rounded border-input"}),(0,s.jsxs)("span",{children:["Put this file's limits in the schema",(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Adds maxLength on text and totalDigits on decimals, taken from your data. Useful documentation, and a trap if next month's file is wider, so turn it off when the schema has to outlive this one file."})]})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:_.percentX100,onChange:e=>eC({percentX100:e.target.checked}),className:"mt-0.5 h-4 w-4 rounded border-input"}),(0,s.jsxs)("span",{children:["Write a percent cell as 15 rather than 0.15",(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:"The sheet stores the fraction. Turn this on only if whatever reads the XML expects the displayed number."})]})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:_.cdata,onChange:e=>eC({cdata:e.target.checked}),className:"mt-0.5 h-4 w-4 rounded border-input"}),(0,s.jsxs)("span",{children:["Wrap text columns in CDATA",(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Worth it for a column full of markup. The escaping is identical either way, so this only changes how the file reads to a person."})]})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:G,onChange:e=>H(e.target.checked),className:"mt-0.5 h-4 w-4 rounded border-input"}),(0,s.jsxs)("span",{children:["Repeat a merged value into every cell it covers",(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:"A label written once and merged over six rows leaves five records missing that field. Off, those records simply do not carry it."})]})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("div",{className:"flex gap-1",children:["xml","xsd","check"].map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>Q(e),className:(0,w.cn)("flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm transition-colors",Z===e?"border-primary bg-accent font-medium":"hover:bg-accent"),children:["xml"===e?"XML":"xsd"===e?"Schema":"Survival check","check"===e&&eD?.ran&&(0,s.jsx)("span",{className:(0,w.cn)("h-2 w-2 rounded-full",eX?"bg-emerald-500":"bg-amber-500")})]},e))}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[eb.records," record",1===eb.records?"":"s",", ",(0,v.z)(ey)]})]}),0===eb.totalRecords&&(0,s.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-500",children:"No rows were found below the header row on this sheet, so the document has no records in it. Try a different sheet, or set the header row to match where your labels actually sit."}),eb.notices.map(e=>(0,s.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-500",children:e},e)),"check"!==Z&&eS&&(0,s.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-500",children:["The box below shows the first ",ew?.records??0," of ",eb.records," records. Copy and Download both give you every one of them."]}),"check"===Z?(0,s.jsx)("div",{className:"space-y-3 rounded-lg border bg-card p-4 text-sm",children:eD?.ran?eD.wellFormed?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:(0,w.cn)("space-y-1 rounded-md border p-3",eX?"border-emerald-500/40 bg-emerald-500/5":"border-amber-500/40 bg-amber-500/5"),children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[eX?(0,s.jsx)(c.A,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-500"}
1):(0,s.jsx)(i.A,{className:"h-4 w-4 text-amber-600 dark:text-amber-500"}),eX?`The document parsed and all ${eD.checked} values came back exactly as they went in`:`${eD.lost.toLocaleString()} value${1===eD.lost?"":"s"} did not come back the way ${1===eD.lost?"it":"they"} went in`]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The finished document was read back with your browser's own parser and every value compared as text against the cell it came from.",eD.skipped>0&&` ${eD.skipped.toLocaleString()} values past the first ${eD.checked.toLocaleString()} were not compared.`,e$?.partial&&` This file is large, so the check ran on the first ${e$.records} records rather than all ${eb.records}.`]})]}),eD.losses.length>0&&(0,s.jsx)("ul",{className:"space-y-1.5 font-mono text-xs",children:eD.losses.map(e=>(0,s.jsxs)("li",{className:"rounded border p-2",children:[(0,s.jsx)("span",{className:"font-semibold",children:e.ref})," ",e.name,","," ",(0,s.jsx)("span",{className:"font-sans text-muted-foreground",children:e.reason}),(0,s.jsxs)("span",{className:"mt-0.5 block break-all text-muted-foreground",children:["wrote ",JSON.stringify(e.written).slice(0,80)," and read back"," ",JSON.stringify(e.read).slice(0,80)]})]},`${e.ref}-${e.name}`))}),eD.lost>eD.losses.length&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The list stops at ",j.I$,". The other"," ",(eD.lost-eD.losses.length).toLocaleString()," are the same kind of problem and are counted in the number above."]}),eb.changes.length>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"font-medium",children:"What was changed on the way out"}),(0,s.jsx)("ul",{className:"space-y-1 text-xs text-muted-foreground",children:eb.changes.map(e=>(0,s.jsxs)("li",{children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.count})," ",e.label,(0,s.jsxs)("span",{className:"font-mono",children:[" (",e.refs.join(", "),e.count>e.refs.length?" and more":"",")"]})]},e.label))})]}),(0,s.jsx)("p",{className:"border-t pt-3 text-xs text-muted-foreground",children:"Well formed is not the same as valid. This proves the document parses and that no value was damaged getting there. Browsers carry no schema engine, so nothing here validates the document against the XSD, or against a schema someone else handed you."})]}):(0,s.jsxs)("div",{className:"space-y-1.5 rounded-md border border-destructive/50 bg-destructive/5 p-3",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-medium text-destructive",children:[(0,s.jsx)(i.A,{className:"h-4 w-4"}),"The document did not parse"]}),(0,s.jsx)("p",{className:"text-xs",children:eD.parseError}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"This is almost always a root, record or element name that is not a legal XML name. Change it above and the check runs again."})]}):(0,s.jsx)("p",{className:"text-muted-foreground",children:"The check runs in your browser once the document is built."})}):(0,s.jsx)("pre",{className:"max-h-96 overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-relaxed",children:(0,s.jsx)("code",{children:ej||"Nothing to show yet."})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsxs)(x.$,{onClick:function(){eb&&(0,N.WN)(new Blob([eb.xml],{type:"application/xml"}),`${eR}.xml`)},disabled:!eb.xml,children:[(0,s.jsx)(d.A,{}),"Download the XML"]}),(0,s.jsxs)(x.$,{variant:"outline",onClick:function(){ek&&(0,N.WN)(new Blob([ek],{type:"application/xml"}),`${eR}.xsd`)},disabled:!ek,children:[(0,s.jsx)(d.A,{}),"Download the XSD"]}),(0,s.jsxs)(x.$,{variant:"outline",onClick:()=>void eL(),disabled:ea||!ek,children:[(0,s.jsx)(d.A,{}),ea?"Zipping...":"Both as a ZIP"]}),(0,s.jsx)(T.i,{value:eN,label:`Copy the ${"xsd"===Z?"schema":"XML"}`,icon:(0,s.jsx)(m.A,{}),copiedIcon:(0,s.jsx)(u.A,{}),variant:"outline",disabled:!eN})]})]}),(0,s.jsx)(b.ToolActions,{getParams:ec,title:"Excel to XML Converter"})]})}},65735:(e,t,r)=>{r.d(t,{I$:()=>N,PX:()=>A,Pk:()=>y,UM:()=>M,X1:()=>c,_5:()=>h,dc:()=>d,ir:()=>u,j7:()=>b,lg:()=>i,lp:()=>w,nr:()=>T,y$:()=>o});var s=r(4506),n=r(8879);let a=/[\p{L}_]/u,l=/[\p{L}\p{N}\p{M}._·-]/u;function o(e,t){let r=e.replace(/\s+/g," ").trim();if(""===r)return{name:t,reason:"the header is blank"};let s=[],n="",o=0,i=0;for(let e of r){if(l.test(e)){n+=e;continue}if(":"===e){n+="_",i++;continue}n+="_",o++}i>0&&s.push("a colon in an XML name means a namespace prefix"),o>0&&s.push(`${o} character${1===o?"":"s"} an XML name cannot hold became underscores`);let c=n.charAt(0);return(""!==c&&a.test(c)||(n=`_${n}`,s.push("an XML name cannot start with a digit, a dot or a hyphen")),/^xml/i.test(n)&&(n=`_${n}`,s.push("names beginning with the letters xml are reserved by the spec")),""===n)?{name:t,reason:"nothing legal was left of the header"}:{name:n,reason:n===r?"":s.join(", ")}}function i(e){let t="",r=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s),a=e.charAt(s);if(9===n||10===n||13===n){t+=a;continue}if(n<32){r++;continue}if(n>=55296&&n<=56319){let n=e.charCodeAt(s+1);if(n>=56320&&n<=57343){t+=a+e.charAt(s+1),s++;continue}r++;continue}if(n>=56320&&n<=57343||65534===n||65535===n){r++;continue}t+=a}return{text:t,removed:r}}function c(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#13;")}function d(e){return c(e).replace(/"/g,"&quot;").replace(/\n/g,"&#10;").replace(/\t/g,"&#9;")}function m(e){return d(i(e).text)}let u={string:"xs:string",integer:"xs:integer",decimal:"xs:decimal",double:"xs:double",boolean:"xs:boolean",date:"xs:date",dateTime:"xs:dateTime",time:"xs:time",duration:"xs:duration"},h=["string","integer","decimal","double","boolean","date","dateTime","time","duration"];function p(e){if(!e)return"blank";if("error"===e.kind)return"error";if("bool"===e.kind)return"boolean";if("date"===e.kind){let t=e.dateKind??"date";return"datetime"===t?"dateTime":"time"===t?"time":"duration"===t?"duration":"date"}if("number"===e.kind){let t=(0,s.V)(e).trim();return/[eE]/.test(t)?"double":/^[-+]?\d+$/.test(t)?"integer":"decimal"}return""===e.shown.trim()?"blank":"string"}let x={text:"",kind:"blank",note:""};function f(e){return{text:e.shown,kind:"refused",note:""}}function g(e,t,r){let a=p(e);if(!e||"blank"===a)return x;if("error"===a)return{text:e.shown,kind:"error",note:""};let l=()=>{let t=(0,s.V)(e).trim();return r&&e.code&&(0,n.pP)(e.code)?(0,n.xj)(t,2):t};switch(t){case"integer":{if("number"!==e.kind)return f(e);let t=l();if(!/^[-+]?\d+$/.test(t))return f(e);
1return{text:t.replace(/^\+/,""),kind:"ok",note:""}}case"decimal":{if("number"!==e.kind)return f(e);let t=l();if(/[eE]/.test(t))return f(e);return{text:t.replace(/^\+/,""),kind:"ok",note:""}}case"double":if("number"!==e.kind)return f(e);return{text:l().replace(/^\+/,""),kind:"ok",note:""};case"boolean":if("bool"===e.kind)return{text:"TRUE"===e.shown?"true":"false",kind:"ok",note:"xs:boolean only takes true and false in lower case, so the sheet TRUE and FALSE were lowered"};if("number"===e.kind){let t=(0,s.V)(e).trim();if("1"===t||"0"===t)return{text:t,kind:"ok",note:""}}return f(e);case"date":case"dateTime":case"time":{if("date"!==e.kind)return f(e);let r=e.dateKind??"date";if("duration"===r||"time"===t&&"time"!==r||"time"!==t&&"time"===r)return f(e);let s=e.iso??"";if(""===s)return f(e);if("dateTime"===t&&!s.includes("T"))return{text:`${s}T00:00:00`,kind:"ok",note:"midnight was added to make a legal xs:dateTime"};if("date"===t&&s.includes("T"))return{text:s.slice(0,10),kind:"ok",note:"the clock time was dropped to fit xs:date"};return{text:s,kind:"ok",note:""}}case"duration":{let t=e.days??e.value??null;if(null===t||"text"===e.kind)return f(e);return{text:function(e){let t=Math.round(86400*Math.abs(e)),r=Math.floor(t/3600),s=Math.floor((t-3600*r)/60),n=t-3600*r-60*s,a="";return r>0&&(a+=`${r}H`),s>0&&(a+=`${s}M`),(n>0||""===a)&&(a+=`${n}S`),`${e<0?"-":""}PT${a}`}(t),kind:"ok",note:"an elapsed time past 24 hours is not a legal xs:time, so it was written as an xs:duration"}}
1default:if("number"===e.kind)return{text:l(),kind:"ok",note:""};if("date"===e.kind)return{text:e.iso??e.shown,kind:"ok",note:""};return{text:e.shown,kind:"ok",note:""}}}function b(e,t,r){let a=[],l=[],c=[],d=new Set;for(let m=0;m<e.width;m++){let u=t[m]??{},h=(e.headers[m]??"").replace(/\s+/g," ").trim(),x=`column${m+1}`,f=o(h,x),b=u.name??f.name,w=""===b.trim()?f.name:o(b,x).name,k="";if(d.has(w)){let e=w,t=2;for(;d.has(`${e}_${t}`);)t++;w=`${e}_${t}`,k=`${e} was already taken, so column ${(0,n.WD)(m)} became ${w}`,c.push(k)}if(d.add(w),""!==f.reason&&void 0===u.name){let e=""===h?`column ${(0,n.WD)(m)}`:h;l.push(`${e} became ${w}, because ${f.reason}`)}let y=new Map,$=[],v=new Set,j=0,N=0,T=0,M=0,S=0,C=0,A=!1,R=0,L=0,D=0;e.rows.forEach((t,a)=>{let l=t[m]??null,o=p(l);if(y.set(o,(y.get(o)??0)+1),"blank"===o)return void N++;if("error"===o?T++:j++,!l)return;let c=`${(0,n.WD)(m)}${e.rowRefs[a]??a+1}`;if(!v.has(o)&&$.length<4&&(v.add(o),$.push({ref:c,value:l.shown.slice(0,32),cls:o})),l.code&&(0,n.pP)(l.code)&&(A=!0),"integer"===o||"decimal"===o){let e=(0,s.V)(l).trim().replace(/^[-+]/,""),t=e.indexOf("."),a=t<0?e:e.slice(0,t),o=t<0?"":e.slice(t+1),i=r&&l.code&&(0,n.pP)(l.code)?2:0,c=Math.max(1,a.replace(/^0+(?=\d)/,"").length+i),d=Math.max(0,o.length-i);S=Math.max(S,c+d),C=Math.max(C,d)}let d=(0,s.a)(l),u=i(d);M=Math.max(M,u.text.length),D=Math.max(D,u.text.length),/[\n\t]/.test(d)&&R++,u.removed>0&&L++});let X=function(e){let t=[...e.keys()].filter(e=>"blank"!==e&&"error"!==e);if(0===t.length)return"string";let r=e=>t.every(t=>e.includes(t));return r(["integer"])?"integer":r(["integer","decimal"])?"decimal":r(["integer","decimal","double"])?"double":r(["date"])?"date":r(["date","dateTime"])?"dateTime":r(["time"])?"time":r(["duration"])?"duration":r(["boolean"])?"boolean":"string"}(y),F=u.type??X,E=u.placement??"element",O=0,P=[];"string"!==F&&e.rows.forEach((t,s)=>{let a=t[m]??null;if(a&&"refused"===g(a,F,r).kind&&(O++,P.length<8)){let t=`${(0,n.WD)(m)}${e.rowRefs[s]??s+1}`,r=""===a.shown.trim()?"(no text)":a.shown.slice(0,30);P.push(`${t} ${r}`)}}),a.push({c:m,header:""===h?`column ${(0,n.WD)(m)}`:h,name:w,input:u.name??f.name,placement:E,type:F,auto:X,evidence:$,filled:j,blanks:N,errors:T,mismatches:O,mismatchRefs:P,maxLength:M,totalDigits:S,fractionDigits:C,percent:A,newlines:R,illegal:L,longest:D,renamed:void 0===u.name?f.reason:"",clash:k})}return{columns:a,renames:l,clashes:c}}let w={root:"records",record:"record",structure:"sheet",namespace:"",pretty:!0,indent:2,blanks:"omit",errors:"nil",cdata:!1,declaration:!0,version:"1.0",percentX100:!1,sheetAttribute:!0,limits:!0,limit:0};class k{add(e,t){let r=this.map.get(e);if(r){r.count++,r.refs.length<6&&r.refs.push(t);return}this.map.set(e,{label:e,count:1,refs:[t]})}list(){return[...this.map.values()].sort((e,t)=>t.count-e.count)}constructor(){this.map=new Map}}function y(e,t,r){let a=r.pretty?" ".repeat(Math.max(0,r.indent)):"",l=r.pretty?"\n":"",i=[],c=[],d=new k,h=[],p=new Set,x="flat"===r.structure,f="workbook"===r.structure,b=o(r.root,"records").name,w=o(r.record,"record").name,y=0;for(let t of e)y+=t.rows.length;let v=r.limit>0?r.limit:1/0,N=!1,T=new Set,M=0,S=0;for(let l=0;l<e.length;l++){let o=e[l],h=t[l];if(!o||!h)continue;let b=h.filter(e=>"skip"!==e.placement),k=f?2:1;f&&i.push(`${a}<sheet name="${m(o.name)}">`);for(let t=0;t<o.rows.length&&!(M>=v);t++){let l=o.rows[t];if(!l)continue;let h=o.rowRefs[t]??t+1,f=[],y=[];for(let t of(x&&r.sheetAttribute&&e.length>1&&f.push(`sheet="${m(o.name)}"`),b)){let e=l[t.c]??null,a=`${(0,n.WD)(t.c)}${h}`,o="attribute"===t.placement,i=g(e,t.type,r.percentX100);if("refused"===i.kind){d.add(`${t.name}: a cell is not ${u[t.type]}, so it was left out rather than written as a value the schema rejects`,a);continue}if("error"===i.kind){if("omit"===r.errors){d.add(`${t.name}: an error cell was left out`,a);continue}if("text"===r.errors){let n=e?(0,s.a)(e):"",l=$(i.text,t,o,r,d,a);o?f.push(l):y.push(l),c.push(j(a,S,t,o,n,i.text,r)),d.add(`${t.name}: an error cell was written as its literal text`,a);continue}if(o){d.add(`${t.name}: an error cell in an attribute cannot be nil, because only an element can be, so it was left out`,a);continue}p.add(t.name),N=!0,y.push(`<${t.name} xsi:nil="true"/>`),d.add(`${t.name}: an error cell became xsi:nil, so the value is absent rather than wrong`,a);continue}if("blank"===i.kind){if("omit"===r.blanks)continue;if("empty"===r.blanks){"string"!==t.type&&T.add(`${t.name} (${u[t.type]})`),o?f.push(`${t.name}=""`):y.push(`<${t.name}/>`);continue}if(o){d.add(`${t.name}: a blank cell in an attribute cannot be nil, so it was left out`,a);continue}p.add(t.name),N=!0,y.push(`<${t.name} xsi:nil="true"/>`);continue}let m=e?(0,s.a)(e):"";""!==i.note&&d.add(`${t.name}: ${i.note}`,a);let x=$(i.text,t,o,r,d,a);o?f.push(x):y.push(x),c.push(j(a,S,t,o,m,i.text,r))}let v=f.length>0?`<${w} ${f.join(" ")}`:`<${w}`;if(0===y.length)i.push(`${a.repeat(k)}${v}/>`);else if(r.pretty){for(let e of(i.push(`${a.repeat(k)}${v}>`),y))i.push(`${a.repeat(k+1)}${e}`);i.push(`${a.repeat(k)}</${w}>`)}else i.push(`${v}>${y.join("")}</${w}>`);M++,S++}if(f&&i.push(`${a}</sheet>`),M>=v)break}let C=[];r.declaration&&C.push(`<?xml version="${r.version}" encoding="UTF-8"?>`);let A=""===r.namespace.trim()?"":` xmlns="${m(r.namespace.trim())}"`,R=N?' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"':"";return C.push(`<${b}${A}${R}>`),i.unshift(...C),i.push(`</${b}>`),T.size>0&&h.push(`An empty element is not a legal value for a typed element, so ${[...T].join(", ")} will fail validation while blanks are written as empty elements. Leaving them out or marking them nil both validate.`),"1.1"===r.version&&h.push("XML 1.1 lets the control characters through as references, and plenty of parsers refuse a 1.1 document outright. Pick it only if the system reading the file asked for it."),{xml:i.join(l),records:M,totalRecords:y,slots:c,changes:d.list(),notices:h,nillable:p}}function $(e,t,r,s,n,a){let l=v(e,s,t,n,a);if(r)return/[\n\t]/.test(l)&&n.add(`${t.name}: a line break inside an attribute is written as a character reference, because a literal one comes back as a space`,a),`${t.name}="${d(l)}"`;let o=s.cdata&&"string"===t.type?`<![CDATA[${l.split("]]>").join("]]]]><![CDATA[>")}]]>`:c(l);return`<${t.name}>${o}</${t.name}>`}function v(e,t,r,s,n){if("1.0"!==t.version)return e;let a=i(e);return a.removed>0&&s&&s.add(`${r.name}: ${1===a.removed?"a character":`${a.removed} characters`} XML 1.0 does not allow at all ${1===a.removed?"was":"were"} removed`,n),a.text}function j(e,t,r,s,n,a,l){return{ref:e,record:t,name:r.name,attribute:s,stored:n,written:v(a,l,r,null,e)}}let N=12;function T(e,t,r,s){let n={ran:!1,wellFormed:!1,parseError:"",checked:0,skipped:t.length,losses:[],lost:0,deliberate:0};if("undefined"==typeof DOMParser)return n;let a=new DOMParser().parseFromString(e,"application/xml"),l=a.getElementsByTagName("parsererror")[0];if(l)return{...n,ran:!0,parseError:(l.textContent??"The document could not be parsed.").replace(/\s+/g," ").slice(0,240)};let o=[],i=a.documentElement;for(let e of Array.from(i?.children??[])){if(e.localName===r){o.push(e);continue}if("sheet"===e.localName)for(let t of Array.from(e.children))t.localName===r&&o.push(t)}let c=[],d=0,m=0,u=0;for(let e of t){if(m>=s)break;
1let t=o[e.record];if(!t)continue;m++;let r=null;if(e.attribute)r=t.getAttribute(e.name);else{let s=t.children;for(let t=0;t<s.length;t++){let n=s[t];if(n&&n.localName===e.name){r=n.textContent??"";break}}}if(null===r){d++,c.length<N&&c.push({ref:e.ref,name:e.name,written:e.written,read:"",reason:"it is not in the document that came back"});continue}if(r===e.written){e.written!==e.stored&&u++;continue}let n="the text that came back is not the text that went in";e.attribute&&e.written.replace(/[\n\t\r]/g," ")===r?n="attribute value normalization replaced its line breaks with spaces":e.written.replace(/\r\n?/g,"\n")===r?n="the carriage returns were normalized away":e.written.trim()===r.trim()&&(n="the whitespace around it changed"),d++,c.length<N&&c.push({ref:e.ref,name:e.name,written:e.written,read:r,reason:n})}return{ran:!0,wellFormed:!0,parseError:"",checked:m,skipped:Math.max(0,t.length-m),losses:c,lost:d,deliberate:u}}function M(e,t,r){let s=" ".repeat(Math.max(1,t.indent)),n=o(t.root,"records").name,a=o(t.record,"record").name,l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>');let i=['xmlns:xs="http://www.w3.org/2001/XMLSchema"'];if(""!==t.namespace.trim()){let e=m(t.namespace.trim());i.push(`targetNamespace="${e}"`),i.push(`xmlns="${e}"`),i.push('elementFormDefault="qualified"')}l.push(`<xs:schema ${i.join(" ")}>`);let c="flat"===t.structure,d=e=>e.columns.filter(e=>"skip"!==e.placement),h=e=>d(e).filter(e=>"element"===e.placement).map(e=>e.name),p=[];{let t=new Set;for(let r of e)for(let e of d(r))t.has(e.name)||(t.add(e.name),p.push(e))}let x=new Set(e.length>0?h(e[0]):[]);for(let t of e.slice(1)){let e=new Set(h(t));for(let t of[...x])e.has(t)||x.delete(t)}let f=!(e.length<=1||1===new Set(e.map(e=>h(e).join("␟"))).size),g=(e,n,a)=>{let l=[],o=e.filter(e=>"element"===e.placement),i=e.filter(e=>"attribute"===e.placement);if(l.push(`${n}<xs:complexType>`),o.length>0){let e=f?"xs:all":"xs:sequence";for(let a of(l.push(`${n}${s}<${e}>`),o)){let e=f&&!x.has(a.name);l.push(...function(e,t,r,s,n,a=!1){let l=a||C(e,n)?' minOccurs="0"':"",o=s.has(e.name)||e.blanks>0&&"nil"===n.blanks||e.errors>0&&"nil"===n.errors?' nillable="true"':"",i=S(e,n);return 0===i.length?[`${t}<xs:element name="${e.name}" type="${u[e.type]}"${l}${o}/>`]:[`${t}<xs:element name="${e.name}"${l}${o}>`,`${t}${r}<xs:simpleType>`,`${t}${r}${r}<xs:restriction base="${u[e.type]}">`,...i.map(e=>`${t}${r.repeat(3)}${e}`),`${t}${r}${r}</xs:restriction>`,`${t}${r}</xs:simpleType>`,`${t}</xs:element>`]}(a,`${n}${s}${s}`,s,r,t,e))}l.push(`${n}${s}</${e}>`)}for(let e of(a&&l.push(`${n}${s}<xs:attribute name="sheet" type="xs:string" use="optional"/>`),i))l.push(...function(e,t,r,s){let n=C(e,s)||e.blanks>0||e.errors>0?' use="optional"':' use="required"',a=S(e,s);return 0===a.length?[`${t}<xs:attribute name="${e.name}" type="${u[e.type]}"${n}/>`]:[`${t}<xs:attribute name="${e.name}"${n}>`,`${t}${r}<xs:simpleType>`,`${t}${r}${r}<xs:restriction base="${u[e.type]}">`,...a.map(e=>`${t}${r.repeat(3)}${e}`),`${t}${r}${r}</xs:restriction>`,`${t}${r}</xs:simpleType>`,`${t}</xs:attribute>`]}(e,`${n}${s}`,s,t));return l.push(`${n}</xs:complexType>`),l};if(l.push(`${s}<xs:element name="${n}">`),l.push(`${s.repeat(2)}<xs:complexType>`),l.push(`${s.repeat(3)}<xs:sequence>`),"workbook"===t.structure)l.push(`${s.repeat(4)}<xs:element name="sheet" maxOccurs="unbounded">`),l.push(`${s.repeat(5)}<xs:complexType>`),l.push(`${s.repeat(6)}<xs:sequence>`),l.push(`${s.repeat(7)}<xs:element name="${a}" minOccurs="0" maxOccurs="unbounded">`),l.push(...g(p,s.repeat(8),!1)),l.push(`${s.repeat(7)}</xs:element>`),l.push(`${s.repeat(6)}</xs:sequence>`),l.push(`${s.repeat(6)}<xs:attribute name="name" type="xs:string" use="required"/>`),l.push(`${s.repeat(5)}</xs:complexType>`),l.push(`${s.repeat(4)}</xs:element>`);else{let r=c?p:(e[0]?.columns??[]).filter(e=>"skip"!==e.placement);l.push(`${s.repeat(4)}<xs:element name="${a}" minOccurs="0" maxOccurs="unbounded">`),l.push(...g(r,s.repeat(5),c&&t.sheetAttribute&&e.length>1)),l.push(`${s.repeat(4)}</xs:element>`)}return l.push(`${s.repeat(3)}</xs:sequence>`),l.push(`${s.repeat(2)}</xs:complexType>`),l.push(`${s}</xs:element>`),l.push("</xs:schema>"),f&&l.splice(1,0,"\x3c!-- These sheets do not carry the same columns in the same order, so a re
1cord is described","     by xs:all: every column from every sheet, each at most once, and the ones that are not","     on every sheet marked optional. Element ORDER is therefore not constrained here. Put","     the same columns in the same order on every sheet to get an ordered xs:sequence back. --\x3e"),l.join("\n")}function S(e,t){let r=[];return t.limits&&("string"===e.type&&e.maxLength>0&&r.push(`<xs:maxLength value="${e.maxLength}"/>`),"decimal"===e.type&&e.totalDigits>0&&(r.push(`<xs:totalDigits value="${e.totalDigits}"/>`),r.push(`<xs:fractionDigits value="${e.fractionDigits}"/>`))),r}function C(e,t){return!!(e.mismatches>0)||!!(e.blanks>0)&&"omit"===t.blanks||!!(e.errors>0)&&"omit"===t.errors}function A(e){let t=[];if(e.newlines>0){let r=e.newlines;t.push(`as an attribute, the ${r} cell${1===r?"":"s"} holding a line break ${1===r?"is":"are"} written as a character reference so the text survives, though many readers still show it on one line`)}if(e.errors>0){let r=e.errors;t.push(`as an attribute, the ${r} error cell${1===r?"":"s"} cannot be nil, because only an element can be`)}if(e.longest>2e3&&t.push(`as an attribute, the longest value here runs to ${e.longest.toLocaleString()} characters, which is legal and unreadable`),e.illegal>0){let r=e.illegal;t.push(`${r} cell${1===r?"":"s"} hold a character XML 1.0 forbids outright, which is removed either way`)}return t}}}]);

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.