-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.mjs
More file actions
2 lines (2 loc) · 17.9 KB
/
module.mjs
File metadata and controls
2 lines (2 loc) · 17.9 KB
1
2
// jsonstat-suite v4.0.1 Copyright 2026 Xavier Badosa https://jsonstat.com
import e from"jsonstat-toolkit";function t(t,n){return null==t?null:("string"!=typeof t&&void 0!==t.length||(t=e(t)),0===t.length||"dataset"!==t.class&&"collection"!==t.class&&"bundle"!==t.class?null:(null===t.value&&(t.value=Array(t.n).fill(null)),"dataset"===t.class?t:t.Dataset(n)))}function n(e){if(null===e||0===e.length||"dataset"!==e.class)return!1;let t=1;for(let n=e.length;n--;)t*=e.Dimension(n).length;return t===e.n}function l(e,t,n){return(t.label||n).capitalize()+function(e,t){let n,l,o="";return e&&"metric"===e.role&&t.unit&&(n=t.unit.hasOwnProperty("label")?t.unit.label:"",l=t.unit.hasOwnProperty("symbol")?t.unit.symbol:"",n+l!==""&&(o=""===l?n:""===n?l:"start"===t.unit.position?l+n:n+" "+l,o=" ("+o+")")),o}(e,t)}function o(e,t,n){let o,i,r='<select name="'+t+'">',a=[];if(null!==n[1]){if(o=e.id,a=e.Dimension(),2===o.length)return(e.Dimension(n[0]).label||n[0]).capitalize()}else if(i=e.Dimension(t),o=i.id,a=i.Category(),1===o.length)return;return o.forEach(function(e,t){const o=e!==n[0]?"":'selected="selected" ';null!==n[1]&&e===n[1]||(r+="<option "+o+'value="'+e+'">'+l(i,a[t],e)+"</option>")}),r+="</select>",r}function i(e,i,r){function a(e){void 0!==i?i.innerHTML=s[e]:window.alert(s[e])}if(void 0===e)return void a("urierror");if(void 0===i)return void a("selerror");void 0===r&&(r={});const s=void 0===r.i18n||void 0===r.i18n.msgs?{urierror:"tbrowser: A valid JSON-stat input must be specified.",selerror:"tbrowser: A valid selector must be specified.",jsonerror:"The request did not return a valid JSON-stat dataset.",dimerror:"Only one dimension was found in the dataset. At least two are required.",dataerror:"Selection returned no data!",source:"Source",filters:"Filters",constants:"Constants",rc:"Rows & Columns",na:"n/a"}:r.i18n.msgs,u=void 0===r.i18n||void 0===r.i18n.locale?"en-US":r.i18n.locale,c=r.dsid||0,d=r.status||!1,f=r.tblclass||"",h=r.nonconst||!1,b=t(e,c);if(!n(b))return void a("jsonerror");let p;h&&(p=function(e){let t=0;const n=e.size.slice(0),l=[];return n.forEach(function(n,o){const i=o-t,r=e.Dimension(i);1===n&&(delete e.__tree__.dimension[e.id[i]],e.size.splice(i,1),e.id.splice(i,1),e.length--,t++,l.push(r.label.capitalize()+": "+r.Category(0).label.capitalize()))}),l}(b)),1!==b.length?function e(t,n,i,a){"function"==typeof r.callback&&r.callback(i);let c="",f="",b="",m="",g="",y="",v=null!==n.label?'<span class="label">'+n.label.capitalize()+"</span>":"",w=n.source?s.source+": "+n.source:"";const O=i.rows,E=n.Dimension(O),S=E.id,x=i.cols,A=n.Dimension(x),D=A.id,j=n.role&&n.role.metric?n.role.metric[0]:null,P=null!==j?n.Dimension(j):null,k=function(e){return e.hasOwnProperty("unit")&&e.unit&&e.unit.hasOwnProperty("decimals")?e.unit.decimals:null},z=i.filters,C=JSON.parse(JSON.stringify(z)),N=[];h&&p.length&&(v='<span class="label">'+p.join(". ")+"</span>"),""!==w&&"."!==w.slice(-1)&&(w+="."),b+="<caption>"+v+"<form>";for(const e in z){const t=n.Dimension(e),i=t.label?t.label.capitalize():e.capitalize();t.length>1?g+="<p>"+o(n,e,[z[e],null])+" <strong>"+i+"</strong></p>":N.push({label:i,value:l(t,t.Category(0)),name:e,id:t.id[0]})}""!==g&&(g='<fieldset id="filters"><legend>'+s.filters+"</legend>"+g+"</fieldset>"),N.forEach(function(e){y+="<p>"+e.value+" <strong>"+e.label+'</strong></p><input type="hidden" name="'+e.name+'" value="'+e.id+'" />'}),""!==y&&(y='<fieldset id="constants"><legend>'+s.constants+"</legend>"+y+"</fieldset>"),b+=y+g+'<fieldset id="rowscols"><legend>'+s.rc+"</legend>"+o(n,"rows",[O,x])+" <a>↔</a> "+o(n,"cols",[x,O])+"</fieldset></form></caption>",m+="<tbody>";const R=Number.toLocaleString&&"none"!==u?function(e,t){return null===t?e.toLocaleString(u):e.toLocaleString(u,{minimumFractionDigits:t,maximumFractionDigits:t})}:function(e,t){return null===t?e:e.toFixed(t)};if(S.forEach(function(e){C[O]=e;const t=n.Data(C),o=function(e,t){let n;const l=x!==j?null===P?null:k(P.Category(C[j])):k(A.Category(t));null!==e.value?(n=R(e.value,l),d&&null!==e.status&&(n+=" ("+e.status+")")):n=e.status||s.na,m+="<td>"+n+"</td>"};null!==t?(m+='<tr><th scope="row">'+l(E,E.Category(e))+"</th>",Array.isArray(t)?t.forEach(function(e,t){o(e,t)}):o(t,0),m+="</tr>"):m="ERROR"}),"ERROR"===m)return s.dataerror;m+="</tbody>",c+="<thead><tr><th></th>",D.forEach(function(e){c+='<th scope="col">'+l(A,A.Category(e))+"</th>"}),c+="</tr></thead>",""!==w&&(f='<tfoot><tr><td colspan="'+(D.length+1)+'">'+w+"</td></tr></tfoot>"),t.innerHTML='<table class="'+a+'">'+b+c+m+f+"</table>",[].slice.call(t.querySelectorAll("select")).forEach(function(l){l.addEventListener("change",function(l){e(t,n,function(e,t,n){const l={filters:{}};return n.forEach(function(e){"rows"===e.name||"cols"===e.name?l[e.name]=e.value:l.filters[e.name]=e.value}),"rowscols"===t&&e.id.forEach(function(t,n){t!==l.rows&&t!==l.cols?void 0===l.filters[t]&&(l.filters[t]=e.Dimension(n).id[0]):delete l.filters[t]}),l}(n,l.target.parentElement.getAttribute("id"),function(e){const t=[];return[].slice.call(e.querySelectorAll("select, input")).forEach(function(e){t.push({name:e.name,value:e.value})}),t}(t)),a)},!1)}),t.querySelector("a").addEventListener("click",function(){i.cols=O,i.rows=x,e(t,n,i,a)},!1)}(i,b,function(e,t){if("object"==typeof t)return{rows:t.rows,cols:t.cols,filters:t.filters};const n={},l=[],o=e.id;let i,r;if(t){const n="bigger"===t?function(e,t){return e.len<t.len?1:-1}:function(e,t){return e.len>t.len?1:-1};e.Dimension().forEach(function(e,t){l.push({id:o[t],len:e.length})}),l.sort(n),i=l[0].id,r=l[1].id}else i=o[0],r=o[1];return e.Dimension(i).length<e.Dimension(r).length&&(i=r+(r=i,"")),o.forEach(function(t){t!==i&&t!==r&&(n[t]=e.Dimension(t).id[0])}),{rows:i,cols:r,filters:n}}(b,r.preset),f):a("dimerror")}function r(e,l){if(void 0===e)return null;void 0===l&&(l={});let o="",i="",r="",a=0,s=l.na||"n/a",u=l.dsid||0,c=l.vlabel||null,d=l.slabel||null,f=l.counter||!1,h=l.tblclass||"",b=l.numclass||"",p=l.valclass||"",m=l.status||!1,g=l.locale||"en-US",y=l.source||"Source",v=t(e,u),w=v.role&&v.role.metric?v.id.indexOf(v.role.metric[0]):null,O=v.Dimension({role:"metric"}),E={},S=Number.toLocaleString&&"none"!==g?function(e,t){return null===t?e.toLocaleString(g):e.toLocaleString(g,{minimumFractionDigits:t,maximumFractionDigits:t})}:function(e,t){return null===t?e:e.toFixed(t)},x=function(e,t){let n=null;e.forEach(function(e,l){const r=j===l?' class="'+b+" "+p+'"':"";let a=s;t?(w===l&&(n=E[e]),null!==e&&(a=j===l?S(e,n):e),i+="<td"+r+">"+a+"</td>"):o+="<th"+r+">"+e+"</th>"})},A=f?function(e,t){t?i+='<tr><td class="'+b+'">'+t+"</td>":o+='<th class="'+b+'">#</th>',x(e,t),i+="</tr>"}:function(e,t){i+="<tr>",x(e,t),i+="</tr>"};if(!n(v))return null;O&&O[0].Category().forEach(function(e){const t=e.unit&&e.unit.hasOwnProperty("decimals")?e.unit.decimals:null;E[e.label]=t}),console.log(v),console.log(v.Transform({status:m,vlabel:c,slabel:d}));const D=v.Transform({status:m,vlabel:c,slabel:d}),j=D[0].length-1;return D.forEach(function(e,t){A(e,t)}),v.source&&(a=v.length+1,f&&a++,m&&a++,y+=": "+v.source,"."!==y.slice(-1)&&(y+="."),r='<tfoot><td colspan="'+a+'">'+y+"</td></tfoot>"),'<table class="'+h+'"><caption>'+(l.caption||v.label||"")+"</caption><thead><tr>"+o+"</tr></thead><tbody>"+i+"</tbody>"+r+"</table>"}function a(e,t){const n={};return Array.isArray(e[t])?(e[t].forEach(function(e,t){null!==e&&(n[String(t)]=e)}),n):e[t]}function s(t,n){if(void 0===t)return null;void 0===n&&(n={}),"boolean"!=typeof n.ovalue&&(n.ovalue=!1),"boolean"!=typeof n.ostatus&&(n.ostatus=!1),"boolean"!=typeof n.instance&&(n.instance=!1);const l=n.vlabel||"Value",o=n.slabel||"Status",i=n.type||"array",r=n.label||"",s=n.header||null,u=[],c=[],d=[],f=[],h={},b={},p=function(e,t){let n=1,l=0;for(let o=0;o<v;o++)n*=o>0?t[v-o]:1,l+=n*e[v-o-1];return l};let m,g=function(e,n){const o=t[e][l];d[p(n,c)]=isNaN(o)?null:o};switch(i){case"array":t=function(e){const t=e[0],n=e.slice(1),l=[];for(let e=0,o=n.length;e<o;e++){let o={};for(let l=0,i=t.length;l<i;l++)o[t[l]]=n[e][l];l.push(o)}return l}(t);break;case"object":t=function(e){const t=e.cols.map(function(e){return e.id}),n=e.rows,l=[];for(let e=0,o=n.length;e<o;e++){let o={};for(let l=0,i=t.length;l<i;l++)o[t[l]]=n[e].c[l].v;l.push(o)}return l}(t)}const y=t.length;n.hasOwnProperty("drop")&&Array.isArray(n.drop)&&n.drop.length&&t.forEach(function(e){n.drop.forEach(function(t){delete e[t]})});for(const e in t[0])if(e!==l)if(e!==o){if(u.push(e),s)m=s.dimension[e],h[e]=m.category.index;else{h[e]=[];for(let n=0;n<y;n++){const l=t[n][e];-1===h[e].indexOf(l)&&h[e].push(l)}}c.push(h[e].length),b[e]={label:s?m.label:e,category:{index:h[e]}},s&&(b[e].category.label=m.category.label,m.category.unit&&(b[e].category.unit=m.category.unit))}else g=function(e,n){const i=t[e][l],r=t[e][o];d[p(n,c)]=isNaN(i)?null:i,f[p(n,c)]=""===r?null:r};const v=u.length;for(let e=0;e<y;e++){const n=[];for(let l=0;l<v;l++){const o=u[l];n.push(h[o].indexOf(t[e][o]))}g(e,n)}const w={version:"2.0",class:"dataset",value:d,dimension:b,id:u,size:c};return r&&(w.label=r),f.length&&(w.status=f),s&&(s.label&&(w.label=s.label),s.source&&(w.source=s.source),s.updated&&(w.updated=s.updated),s.href&&(w.href=s.href),s.role&&(w.role=s.role)),n.ovalue&&(w.value=a(w,"value")),n.ostatus&&w.hasOwnProperty("status")&&(w.status=a(w,"status")),n.instance?e(w):w}function u(e,t){if(void 0===e)return null;void 0===t&&(t={});const n="jsonstat"===e.substring(0,8),l={time:[],geo:[],metric:[]},o=n?e.substring(8,9):t.delimiter||",";let i,r,a,u=[],c=null,d=null,f=!1,h=n?"value":t.vlabel,b=n?"status":t.slabel,p=";"===o?t.decimal||",":t.decimal||".";const m=function(e,t){t=t||",";const n=new RegExp("(\\"+t+'|\\r?\\n|\\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^"\\'+t+"\\r\\n]*))","gi"),l=[[]];let o,i,r=null;for(;r=n.exec(e);)i=r[1],i.length&&i!=t&&l.push([]),o=r[2]?r[2].replace(new RegExp('""',"g"),'"'):r[3],l[l.length-1].push(o);return l}(e.trim(),o);if(n){for(p=m[0][1],a=m[0][2],m.shift();"data"!==m[0][0];)u.push(m.shift());m.shift(),d={dimension:{}},u.forEach(function(e){let t,n,o,i,r,s,u,c;switch(e[0]){case"dimension":if(d.dimension[e[1]]={},i=d.dimension[e[1]],i.label=e[2],i.category={},r=i.category,r.index=[],n={},o=2*e[3]+3,e.length>=o){for(t=4;t<o;t++)u=e[t],c=e[++t],Object.defineProperty(n,u,{value:c,writable:!0,configurable:!0,enumerable:!0}),r.label=n,r.index.push(u);"string"==typeof e[t]&&-1!==["time","geo","metric"].indexOf(e[t])&&(l[e[t]].push(e[1]),f=!0,"metric"===e[t]&&"string"==typeof e[++t]&&(r.unit={},r.index.forEach(function(n,l){const o=e[t+l].split(a);r.unit[n]={},s=r.unit[n],void 0!==o[0]&&""!==o[0]&&(s.decimals=1*o[0]),void 0!==o[1]&&""!==o[1]&&(s.label=o[1]),void 0!==o[2]&&""!==o[2]&&(s.symbol=o[2]),void 0!==o[1]&&-1!==["start","end"].indexOf(o[3])&&(s.position=o[3])})))}break;case"label":case"source":case"updated":case"href":d[e[0]]=e[1]||null}}),f&&(l.time.length||delete l.time,l.geo.length||delete l.geo,l.metric.length||delete l.metric,d.role=l)}if(i=m.length,r=m[0].length,void 0!==h){for(;r--;)if(m[0][r]===h){c=r;break}if(null===c)return null}else c=r-1,h=m[0][c];if(","===p)for(r=1;r<i;r++)m[r][c]=Number(m[r][c].replace(",","."));else for(r=1;r<i;r++)m[r][c]=Number(m[r][c]);return s(m,{header:d,vlabel:h,slabel:b,type:"array",label:t.label||"",ovalue:t.ovalue||!1,ostatus:t.ostatus||!1,instance:t.instance||!1})}function c(t,n){if("object"!=typeof t)return null;if(t.hasOwnProperty("data")&&t.hasOwnProperty("meta")&&t.data.hasOwnProperty("dataSets")&&t.data.hasOwnProperty("structures")&&Array.isArray(t.data.structures)&&(t.dataSets=t.data.dataSets,t.structure=t.data.structures[0],t.header=t.meta),!t.hasOwnProperty("dataSets")||!Array.isArray(t.dataSets))return null;if(1!==t.dataSets.length)return null;t.dataSets[0].hasOwnProperty("observations")||function(e){const t=e.dataSets[0],n=t.series,l=e.structure,o=l.dimensions,i={};Object.keys(n).forEach(function(e){const t=n[e].observations;Object.keys(t).forEach(function(l){i[e+":"+l]=t[l].concat(n[e].attributes)})}),t.observations=i,delete t.series,o.observation=o.series.concat(o.observation),delete o.series,l.attributes.observation=l.attributes.observation.concat(l.attributes.series),delete l.attributes.series}(t),void 0===n?n={ovalue:!1,ostatus:!1,instance:!1}:("boolean"!=typeof n.ovalue&&(n.ovalue=!1),"boolean"!=typeof n.ostatus&&(n.ostatus=!1),"boolean"!=typeof n.instance&&(n.instance=!1));const l=t.structure,o=t.dataSets[0].observations,i=l.attributes.observation,r=l.dimensions;if(!r.hasOwnProperty("observation"))return null;if(r.hasOwnProperty("series")&&Object.keys(r.series).length)return null;let a=1,s=[],u=function(){},c=i.findIndex(function(e){return"OBS_STATUS"===e.id});const d=[],f=[],h={},b={time:[],geo:[]},p=function(e,t){const n=e.size;for(let e=n.length-t.length;e--;)t.push(0);let l=0,o=1;for(let e=0,i=n.length;e<i;e++)o*=e>0?n[i-e]:1,l+=o*t[i-e-1];return l},m=function(e){if(h[e.id]={label:e.name},e.hasOwnProperty("role"))switch(e.role){case"REF_AREA":b.geo.push(e.id);break;case"TIME_PERIOD":b.time.push(e.id)}Object.defineProperty(h[e.id],"category",{value:{index:[],label:{}},writable:!0,enumerable:!0}),d.push(e.id),f.push(e.values.length),a*=e.values.length;const t=h[e.id].category;e.values.forEach(function(e){t.index.push(e.id),Object.defineProperty(t.label,e.id,{value:e.name,writable:!0,enumerable:!0})})},g=t.header.links?t.header.links.find(function(e){return"request"===e.rel}):null;-1!==c&&(i[c].values.length?s=i[c].values:c=-1),r.observation.forEach(m),r.hasOwnProperty("dataSet")&&r.dataSet.forEach(m);const y={version:"2.0",class:"dataset",updated:t.header.prepared||null,source:t.header.sender.name||null,label:l.name||null,id:d,size:f,dimension:h,value:n.ovalue?{}:new Array(a).fill(null)};g&&(y.link={alternate:[{type:"application/vnd.sdmx.data+json",href:g.href}]}),b.geo.length+b.time.length>0&&(b.time.length||delete b.time,b.geo.length||delete b.geo,y.role=b),-1!==c&&(y.status=n.ostatus?{}:new Array(a).fill(null),y.extension={status:{label:{}}},s.forEach(function(e){y.extension.status.label[e.id]=e.name}),u=n.ostatus?function(e,t){const n=o[e][c];null!==n&&(y.status[p(y,t)]=s[n].id)}:function(e,t){const n=o[e][c];y.status[p(y,t)]=null===n?null:s[n].id}),c++;for(let e in o){const t=e.split(":");n.ovalue&&null===o[e][0]||(y.value[p(y,t)]=o[e][0]),u(e,t)}return n.instance?e(y):y}function d(t,n){if(void 0===t||!Array.isArray(t))return null;const l=JSON.parse(JSON.stringify(t)),o=l[0];if(!o.hasOwnProperty("version")||!o.hasOwnProperty("class")||"dataset"!==o.class)return null;void 0===n&&(n={});const i=void 0===n.label?null:n.label,r=void 0===n.by?null:n.by;let a,u,c,d=[];if(null===r){for(let e=1,t=l.length;e<t;e++)d=d.concat(l[e].value);return o.value=d,null!==i&&(o.label=i),o}const f=function(e,t,n){if(Array.isArray(e))e=e.concat(t);else for(const l in t)e[l]=0===t[l]?n:t[l];return e};l.forEach(function(t,n){const l=e(t).Transform({status:!0}),o=t.dimension[r].category;0===n?(d=[l[0]],a=o.index,u=o.label,c=o.unit):(a=function(e,t,n){if(Array.isArray(e))e=e.concat(t);else for(const l in t)e[l]=t[l]+n;return e}(a,o.index,Object.keys(a).length),u=f(u,o.label,n),c=f(c,o.unit,n)),d=d.concat(l.slice(1))});const h=s(d);return o.value=h.value,o.size=h.size,o.status=h.status||null,o.label=i||"",o.href=null,o.dimension[r].category.index=a||null,o.dimension[r].category.label=u||null,o.dimension[r].category.unit=c||null,o}function f(e,t){return null==e?"":-1!==e.indexOf(t)?'"'+e+'"':e}function h(e,l){if(void 0===e)return null;void 0===l&&(l={});const o={content:!1,field:!1},i=!0===l.rich,r=l.na||"n/a",a=l.delimiter||",",s=l.separator||"|",u=";"===a?l.decimal||",":l.decimal||".",c=!0===l.array,d=t(e,l.dsid||0),h=c?function(e){w.push(e)}:function(e){w+=e+"\n"};let b=l.content||"label",p=l.field||"label",m=i?"value":l.vlabel||"Value",g=i?"status":l.slabel||"Status",y=!0===l.status,v=c?[]:"",w=c?[]:"",O=c?function(e){v.push(e)}:function(e){v+=e+"\n"};if(!n(d))return null;i?y=null!==d.status:("[id] label"===b&&(o.content=!0,b="id"),"[id] label"===p&&(o.field=!0,p="id"));const E=!i&&l.by&&-1!==d.id.indexOf(l.by)?l.by:null,S=E&&void 0!==l.drop&&Array.isArray(l.drop)?l.drop:null;if(E)return function(e,t){const n=[],l=t.by,o=t.idlabel,i=t.drop,r=t.na,a=t.delimiter,s=t.decimal,u=o.content?"id":t.content,c=o.field?"label":t.field,d=e.toTable({drop:i,content:u,by:l,type:"arrobj"}),h=Object.keys(d[0]),b=function(e,t,n,l,i){return e.map(e=>"label"===n?-1!==l.id.indexOf(e)?f((o.field?"["+e+"] ":"")+l.Dimension(e).label,t):f((o.field?"["+e+"] ":"")+l.Dimension(i).Category(e).label,t):f(e,t)).join(t)+"\n"}(h,a,c,e,l),p="."!==s?function(e){return null===e?f(r,a):String(e).replace(".",s)}:function(e){return null===e?f(r,a):e};return d.forEach(t=>{let l=[];h.forEach(n=>{const i=t[n],r="string"==typeof i?f(o.content?"["+i+"] "+e.Dimension(n).Category(i).label:i,a):p(i);l.push(r)}),n.push(l.join(a))}),b+n.join("\n")}(d,{drop:S,na:r,delimiter:a,decimal:u,content:b,field:p,by:E,idlabel:o});const x=d.toTable({vlabel:m,slabel:g,status:y,field:i||o.field?"id":p,content:i||o.content?"id":b,type:"array"}),A=x[0].indexOf("id"===p?"value":m),D=y?x[0].indexOf("id"===p?"status":g):-1;return x.forEach(function(e,t){e.forEach(function(n,l){const i=d.Dimension(l);t&&l===A?null===n?e[l]=f(r,a):"."!==u&&(e[l]=String(e[l]).replace(".",u)):t&&l===D&&null===n?e[l]="":(o.content&&t&&i?e[l]="["+e[l]+"] "+i.Category(e[l]).label:o.field&&0===t&&(e[l]=i?"["+e[l]+"] "+i.label:"value"===e[l]?m:g),e[l]=f(e[l],a))}),O(e.join(a))}),i&&(h("jsonstat"+a+u+a+s),["label","source","updated","href"].forEach(function(e){d[e]&&h(e+a+f(d[e],a))}),d.id.forEach(function(e,t){const n=[],l=d.Dimension(t),o=l.role;let i=!1,r="";r+="dimension"+a+f(e,a)+a+f(l.label,a)+a+l.length,"metric"===o&&l.__tree__.category.unit&&(i=!0),l.id.forEach(function(e,t){const o=[],u=l.Category(t);r+=a+f(e,a)+a+f(u.label,a),i&&(o.push(u.unit.hasOwnProperty("decimals")?u.unit.decimals:""),o.push(u.unit.label||""),u.unit.symbol&&(o.push(u.unit.symbol),o.push(u.unit.position)),n.push(f(o.join(s),a)))}),null!==o&&"classification"!==o&&(r+=a+l.role,i&&(r+=a+n.join(a))),h(r)}),v=c?w.concat(["data"],v):w+"data\n"+v),v}String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};var b="4.0.1";export{r as datalist,u as fromCSV,c as fromSDMX,s as fromTable,d as join,i as tbrowser,h as toCSV,b as version};