@rcsb/rcsb-statistics 0.3.44-dev.aipcb.2 → 0.3.44-dev.aipcb.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/build/ai/chart-catalog.json +60 -18
- package/build/ai/chart-core.d.ts +36 -5
- package/build/ai/chart-core.js +1 -1
- package/build/index.html +1 -1
- package/build/static/css/{221.be447a2a.chunk.css → 221.efddfa04.chunk.css} +2 -1
- package/build/static/css/{489.00de475c.chunk.css → 489.886871bf.chunk.css} +15 -2
- package/build/static/js/489.0b19498e.chunk.js +1 -0
- package/build/static/js/717.11c5b1df.chunk.js +2 -0
- package/build/static/js/{main.a02d7dee.js → main.4341a6ec.js} +2 -2
- package/package.json +1 -1
- package/build/static/js/489.37e3a556.chunk.js +0 -1
- package/build/static/js/717.312e799d.chunk.js +0 -2
- /package/build/static/js/{717.312e799d.chunk.js.LICENSE.txt → 717.11c5b1df.chunk.js.LICENSE.txt} +0 -0
- /package/build/static/js/{main.a02d7dee.js.LICENSE.txt → main.4341a6ec.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_rcsb_rcsb_statistics=self.webpackChunk_rcsb_rcsb_statistics||[]).push([[489],{8596(e,t,r){function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const o=r(3482),l=e=>Boolean(e&&"object"==typeof e&&!Array.isArray(e)),s=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c=e=>{throw new Error(e)};function u(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"Chart";if(t.$ref)return u(e,r.$defs[t.$ref.split("/").pop()],r,n);if(t.anyOf)return void(t.anyOf.some(t=>{try{return u(e,t,r,n),!0}catch(e){return!1}})||c("".concat(n," has an invalid value.")));const a=t.type;("object"===a&&!l(e)||"array"===a&&!Array.isArray(e)||"integer"===a&&!Number.isInteger(e)||"number"===a&&("number"!=typeof e||!Number.isFinite(e))||"string"===a&&"string"!=typeof e||"boolean"===a&&"boolean"!=typeof e)&&c("".concat(n," must be ").concat(a,".")),t.enum&&!t.enum.includes(e)&&c("".concat(n," is not supported.")),"number"==typeof e&&(void 0!==t.minimum&&e<t.minimum||void 0!==t.maximum&&e>t.maximum)&&c("".concat(n," is outside the supported range.")),"string"==typeof e&&(t.minLength&&e.trim().length<t.minLength||t.maxLength&&e.length>t.maxLength||/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/.test(e))&&c("".concat(n," has invalid text.")),Array.isArray(e)&&((t.minItems&&e.length<t.minItems||t.maxItems&&e.length>t.maxItems||t.uniqueItems&&new Set(e.map(e=>JSON.stringify(e))).size!==e.length)&&c("".concat(n," has an invalid number of items.")),e.forEach((e,a)=>u(e,t.items,r,"".concat(n,"[").concat(a,"]")))),l(e)&&((t.required||[]).forEach(t=>{s(e,t)||c("".concat(n,".").concat(t," is required."))}),Object.keys(e).forEach(a=>{s(t.properties||{},a)?u(e[a],t.properties[a],r,"".concat(n,".").concat(a)):!1===t.additionalProperties&&c("".concat(n,".").concat(a," is not supported."))}))}function m(e){u(e,o.specSchema);const t=JSON.parse(JSON.stringify(e)),r=o.dimensions[t.dimension];return!["line","area"].includes(t.chartType)||r.ordered&&"vertical"===t.orientation&&"labelAsc"===t.sort||c("Line and area charts require release year or resolution, vertical orientation, and ascending labels."),"area"===t.chartType&&"linear"!==t.scale&&c("Area charts require a linear scale for their zero baseline."),["pie","doughnut"].includes(t.chartType)&&(r.overlapping||1!==t.series.length||t.cumulative||"linear"!==t.scale)&&c("Pie and doughnut charts require a single non-overlapping series (release year or methodology), linear scale, and non-cumulative values."),!t.cumulative||"releaseYear"===t.dimension&&"labelAsc"===t.sort||c("Cumulative charts require release year in chronological order."),"percent"===t.measure&&"linear"!==t.scale&&c("Percentages require a linear scale."),new Set(t.series.map(e=>e.label)).size!==t.series.length&&c("Give each comparison series a different label."),[t.filters,...t.series.map(e=>e.filters)].forEach(e=>e.forEach(e=>{const t=o.filters[e.field];t.operators.includes(e.operator)||c("Unsupported operator for ".concat(t.label,".")),"in"===e.operator?(Array.isArray(e.value)||c("".concat(t.label," requires a list.")),e.value.forEach(e=>{"taxonomy"===t.kind?(!Number.isInteger(e)||e<=0)&&c("Taxonomy IDs must be positive integers."):("string"!=typeof e||t.values&&!t.values.includes(e)||"identifier"===t.kind&&!/^[A-Z0-9]{1,10}$/.test(e))&&c("Invalid value for ".concat(t.label,"."))})):("number"!=typeof e.value||e.value<t.minimum||e.value>t.maximum||"year"===t.kind&&!Number.isInteger(e.value))&&c("Invalid range for ".concat(t.label,"."))})),t.series.forEach(e=>{const r=[...t.filters,...e.filters];["releaseYear","resolution"].forEach(e=>{const t=r.filter(t=>t.field===e&&"gte"===t.operator).map(e=>e.value),n=r.filter(t=>t.field===e&&"lte"===t.operator).map(e=>e.value);t.length&&n.length&&Math.max(...t)>Math.min(...n)&&c("The ".concat(e," lower bound exceeds its upper bound."))}),"integrativeInput"===t.dimension&&r.some(e=>"methodology"===e.field&&!e.value.includes("integrative"))&&c("Integrative input charts cannot exclude integrative structures.")}),t}function d(e){const t=m(e);return a(a({},o.presentationDefaults),{},{borderWidth:["line","area"].includes(t.chartType)?2:1},t.presentation)}function p(e){const t=o.filters[e.field];let r=e.value;return"year"===t.kind&&(r="".concat(r,"-").concat("gte"===e.operator?"01-01":"12-31")),"taxonomy"===t.kind&&(r=r.map(String)),{type:"terminal",service:"text",parameters:{attribute:t.attribute,operator:{in:"in",gte:"greater_or_equal",lte:"less_or_equal"}[e.operator],value:r}}}function h(e){const t=new Set;return e.flatMap(r=>{const n=o.filters[r.field];if(!["number","year"].includes(n.kind))return[p(r)];if(t.has(r.field))return[];t.add(r.field);const i=e.filter(e=>e.field===r.field),l=i.filter(e=>"gte"===e.operator).map(e=>e.value),s=i.filter(e=>"lte"===e.operator).map(e=>e.value);if(!l.length||!s.length)return[p(a(a({},r),{},{operator:l.length?"gte":"lte",value:l.length?Math.max(...l):Math.min(...s)}))];const c=Math.max(...l),u=Math.min(...s);return[{type:"terminal",service:"text",parameters:{attribute:n.attribute,operator:"range",value:{from:"year"===n.kind?"".concat(c,"-01-01"):c,to:"year"===n.kind?"".concat(u,"-12-31"):u,include_lower:!0,include_upper:!0}}}]})}function g(e){const t=m(e),r=o.dimensions[t.dimension],n={name:"chart",aggregation_type:r.aggregation,attribute:r.attribute,min_interval_population:1};return"terms"===r.aggregation&&(n.max_num_intervals=1e3),"date_histogram"===r.aggregation&&(n.interval="year"),"histogram"===r.aggregation&&(n.interval=t.interval),t.series.map(e=>{const a=[...t.filters,...e.filters,...r.requiredFilter?[r.requiredFilter]:[]],i={return_type:"entry",request_options:{results_content_type:["experimental"],paginate:{start:0,rows:0},facets:[n]}};return a.length&&(i.query={type:"group",logical_operator:"and",nodes:h(a).map(e=>({type:"group",logical_operator:"and",nodes:[e]}))}),i})}function y(e){return"".concat(o.filters[e.field].label," ").concat("in"===e.operator?"is any of":"gte"===e.operator?"≥":"≤"," ").concat(Array.isArray(e.value)?e.value.join(", "):e.value)}function b(e){const t=[];return o.dimensions[e.dimension].overlapping&&t.push("An entry may occur in more than one category. Bucket counts must not be summed as a unique entry total."),e.series.length>1&&t.push("Comparison cohorts may overlap; each is counted independently."),"sourceOrganism"===e.dimension&&t.push("Source organisms are those recorded for any matching entry; they are not expression hosts. All source types are included."),"releaseYear"===e.dimension&&t.push("Counts describe the current archive by initial release year, not historical archive snapshots. The current year is incomplete."),e.cumulative&&t.push("Cumulative values begin at the earliest year included by the filters."),"area"===e.chartType&&t.push("Area series use a zero baseline and are not stacked; overlapping cohorts are counted independently."),"logarithmic"===e.scale&&t.push("Zero values are omitted from the logarithmic chart; the table retains them."),"percent"===e.measure&&t.push("The denominator is every matching entry in that series, including entries missing the chart attribute."),t}e.exports={catalog:o,validateSchema:u,validateChartSpec:m,getChartPresentation:d,buildChartRequests:g,buildChartDrilldownRequest:function(e,t,r){var n;const a=m(e);(!Number.isInteger(r)||r<0||r>=a.series.length)&&c("Select a valid chart series."),("string"!=typeof t||!t.trim()||t.length>300||/[\u0000-\u001f\u007f]/.test(t))&&c("Select a valid chart category.");const i={attribute:o.dimensions[a.dimension].attribute,operator:"exact_match",value:t};if("releaseYear"===a.dimension){(!/^\d{4}$/.test(t)||Number(t)<o.filters.releaseYear.minimum||Number(t)>o.filters.releaseYear.maximum)&&c("Select a valid release year.");const e="".concat(Number(t)+1,"-01-01");i.operator=a.cumulative?"less":"range",i.value=a.cumulative?e:{from:"".concat(t,"-01-01"),to:e,include_lower:!0,include_upper:!1}}else if("resolution"===a.dimension){const e=Number(t);(!/^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(t)||!Number.isFinite(e)||e<0||e>o.filters.resolution.maximum||Math.abs(e/a.interval-Math.round(e/a.interval))>1e-8)&&c("Select a valid resolution interval."),i.operator="range",i.value={from:e,to:Number((e+a.interval).toPrecision(12)),include_lower:!0,include_upper:!1}}return{return_type:"entry",query:{type:"group",logical_operator:"and",nodes:[...(null===(n=g(a)[r].query)||void 0===n?void 0:n.nodes)||[],{type:"group",logical_operator:"and",nodes:[{type:"terminal",service:"text",parameters:i}]}]},request_options:{results_content_type:["experimental"],paginate:{start:0,rows:25}}}},describeFilter:y,describeChart:function(e){return m(e),"".concat(e.cumulative?"Cumulative ":"").concat("count"===e.measure?"PDB entry counts":"Percentage of matching PDB entries"," by ").concat(o.dimensions[e.dimension].label.toLowerCase(),"; ").concat(e.chartType," chart; ").concat(e.series.length," ").concat(1===e.series.length?"series":"comparison series",".")},chartWarnings:b,chartChanges:function(e,t){return e?(m(e),m(t),[...new Set([...Object.keys(e),...Object.keys(t)])].filter(r=>JSON.stringify(e[r])!==JSON.stringify(t[r])).flatMap(r=>{if("presentation"===r){const r=d(e),n=d(t),a={palette:"Color palette",legend:"Legend",grid:"Grid lines",lineStyle:"Line style",pointRadius:"Point radius",borderWidth:"Border width",barRadius:"Bar corner radius",doughnutCutout:"Doughnut cutout"},i=(e,t)=>"grid"===e?t?"shown":"hidden":"doughnutCutout"===e?"".concat(t,"%"):String(t);return Object.keys(n).filter(e=>r[e]!==n[e]).map(e=>"".concat(a[e],": ").concat(i(e,r[e])," → ").concat(i(e,n[e]),"."))}return"filters"===r?"Filters: ".concat(t.filters.length?t.filters.map(y).join("; "):"none","."):"series"===r?"Series: ".concat(t.series.map(e=>"".concat(e.label).concat(e.filters.length?" (".concat(e.filters.map(y).join("; "),")"):"")).join("; "),"."):"".concat(r,": ").concat(String(e[r])," → ").concat(String(t[r]))})):["Create a new chart."]},formatChartData:function(e,t){const r=m(e);Array.isArray(t)&&t.length===r.series.length||c("A response is required for every chart series.");const n=o.dimensions[r.dimension];let i=!1;const s=t.map((e,t)=>{var n;(!l(e)||!Number.isInteger(e.total_count)||e.total_count<0)&&c("The Search API did not return a valid entry count.");const a=null===(n=e.facets)||void 0===n||null===(n=n.find(e=>"chart"===e.name))||void 0===n?void 0:n.buckets;Array.isArray(a)||0===e.total_count||c("The Search API did not return the requested chart aggregation."),(a||[]).length>=1e3&&(i=!0);const o=new Map;return(a||[]).forEach(t=>{(!Number.isInteger(t.population)||t.population<0||t.population>e.total_count||!["string","number"].includes(typeof t.label)||String(t.label).length>300)&&c("The Search API returned an invalid chart bucket.");let n=String(t.label);if("releaseYear"===r.dimension){const e=n.match(/\d{4}/);e||c("The Search API returned an invalid release year."),n=e[0]}"resolution"===r.dimension&&((!Number.isFinite(Number(n))||Number(n)<0)&&c("The Search API returned an invalid resolution interval."),n=String(Number(Number(n).toPrecision(12)))),o.has(n)&&c("The Search API returned duplicate chart buckets."),o.set(n,t.population)}),{label:r.series[t].label,total:e.total_count,values:o}});let u=[...new Set(s.flatMap(e=>[...e.values.keys()]))];const d=u.every(e=>Number.isFinite(Number(e)));if(u.sort((e,t)=>d?Number(e)-Number(t):e.localeCompare(t)),"releaseYear"===r.dimension&&u.length){const e=Number(u[0]),t=Number(u[u.length-1]);t-e>200&&c("The Search API returned an unsupported year range."),u=Array.from({length:t-e+1},(t,r)=>String(e+r))}if("resolution"===r.dimension&&u.length){const e=Number(u[0]),t=Math.round((Number(u[u.length-1])-e)/r.interval)+1;t>1e3&&c("This resolution histogram exceeds 1,000 bins. Increase the bin width or narrow the resolution range."),u=Array.from({length:t},(t,n)=>String(Number((e+n*r.interval).toPrecision(12))))}const p=u.map(e=>({label:e,counts:s.map(t=>t.values.get(e)||0)}));if(r.cumulative){const e=s.map(()=>0);p.forEach(t=>{t.counts=t.counts.map((t,r)=>e[r]+=t)})}"countDesc"===r.sort&&p.sort((e,t)=>t.counts.reduce((e,t)=>e+t,0)-e.counts.reduce((e,t)=>e+t,0)||e.label.localeCompare(t.label));const h=!n.ordered,g=(h?p.slice(0,r.topN):p).map(e=>a(a({},e),{},{values:e.counts.map((e,t)=>"percent"===r.measure?s[t].total?100*e/s[t].total:0:e)})),y=b(r);return h&&p.length>g.length&&y.push("Showing ".concat(g.length," of ").concat(p.length).concat(i?"+":""," categories returned. Omitted categories are not combined into an invented “Other” count.")),i&&y.push("The category aggregation reached its 1,000-bucket limit. Narrow the filters for a more complete category listing."),["pie","doughnut"].includes(r.chartType)&&(i||g.length!==p.length)&&c("A pie or doughnut chart must show all categories. Increase the category limit or use a bar chart."),["pie","doughnut"].includes(r.chartType)&&g.reduce((e,t)=>e+t.counts[0],0)!==s[0].total&&c("A pie or doughnut chart requires complete, non-overlapping categories covering every matching entry. Use a bar chart for this population."),{rows:g,series:s.map(e=>({label:e.label,total:e.total})),warnings:y,retrievedAt:(new Date).toISOString(),categoryCount:p.length}}}},489(e,t,r){"use strict";r.r(t),r.d(t,{default:()=>Q});var n=r(9711),a=r(4062),i=r(8354),o=r(2917),l=r(5411),s=r(5042);const c=s.YrT,u=s.cO3,m=s.i5c,d=s.VSk,p=s.yGN,h=s.a4x,g=s.QPV,y=s.vQY;var b=r(9281),f=r(8596);function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach(function(t){w(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function w(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const S=e=>{const t=String(e);return'"'.concat((/^[\s]*[=+@-]|^[\t\r\n]/.test(t)?"'".concat(t):t).replace(/"/g,'""'),'"')};function C(e,t,r){const n=URL.createObjectURL(new Blob([e],{type:r})),a=document.createElement("a");a.href=n,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(n),0)}var O=r(8804),A=r(6619),N=r(9806);function P(e,t,r){const n=[];let a="";for(const i of t.split(/\s+/)){const t=a?"".concat(a," ").concat(i):i;for(a&&e.measureText(t).width>r?(n.push(a),a=i):a=t;e.measureText(a).width>r&&a.length>1;){let t=a.length-1;for(;t>1&&e.measureText(a.slice(0,t)).width>r;)t--;n.push(a.slice(0,t)),a=a.slice(t)}}return a.trim()&&n.push(a.trim()),n}function x(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const a=document.createElement("canvas"),i=a.getContext("2d");if(!i)throw new Error("PNG export is not supported in this browser.");const o=e.width/(e.clientWidth||e.width),l=Math.round(20*o),s=Math.max(e.width,Math.round(400*o)),c=s-2*l;i.font="600 ".concat(18*o,"px sans-serif");const u=P(i,t.title,c);i.font="".concat(11*o,"px sans-serif");const m=P(i,"Source: RCSB PDB Search API · Retrieved ".concat(new Date(r.retrievedAt).toISOString().slice(0,10)," · Released PDB entries only.").concat(n?" ".concat(n):""),c),d=25*u.length*o,p=16*m.length*o;a.width=s,a.height=Math.ceil(e.height+d+p+4*l),i.fillStyle="#ffffff",i.fillRect(0,0,a.width,a.height),i.fillStyle="#243746",i.font="600 ".concat(18*o,"px sans-serif"),i.textBaseline="top",u.forEach((e,t)=>i.fillText(e,l,l+25*t*o));const h=2*l+d;return i.drawImage(e,(s-e.width)/2,h),i.fillStyle="#526675",i.font="".concat(11*o,"px sans-serif"),m.forEach((t,r)=>i.fillText(t,l,h+e.height+l+16*r*o)),a.toDataURL("image/png",1)}var k=r(2329);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach(function(t){I(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function I(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const T={bar:"Bar",line:"Line",area:"Area",pie:"Pie",doughnut:"Doughnut"},R={accessible:["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"],warm:["#b83b32","#e77932","#a54f73","#d4a02e","#7c3e58","#dc6b68","#914b28","#f0bb6a"],cool:["#286f9e","#279c95","#625d9d","#68a6c1","#365f73","#758eaf","#397f64","#9abcc7"],monochrome:["#253f56","#49657b","#6f879a","#8da1b1","#b1c0cc","#334e65","#5b758a","#8196a7"]},D=e=>["pie","doughnut"].includes(e.chartType),q=e=>"bar"===e.chartType&&"horizontal"===e.orientation?"y":"x",L=(e,t)=>"resolution"===e.dimension?"".concat(t,"–").concat(Number((Number(t)+e.interval).toPrecision(12))," Å"):t;function B(e,t){return(0,f.validateChartSpec)(_(_(_({},e),{},{chartType:t},["line","area"].includes(t)?{orientation:"vertical"}:{}),["pie","doughnut","area"].includes(t)?{scale:"linear"}:{}))}function z(e,t){return Object.keys(T).filter(r=>{try{const n=B(e,r);return!D(n)||1===t.series.length&&t.rows.length>0&&t.categoryCount===t.rows.length&&t.rows.length<1e3&&t.rows.reduce((e,t)=>e+t.counts[0],0)===t.series[0].total&&t.series[0].total>0}catch(e){return!1}})}function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach(function(t){Y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Y(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function U(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,l=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw a}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return $(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}A.t1.register(A.PP,A.kc,A.OJ,A.E8,A.No,A.Bs,A.FN,A.m_,A.s$);const J=[A.dN,N.Ay];function W(e){var t;let r=e.spec,o=e.data,s=e.preview,c=void 0!==s&&s,u=e.onSpecChange,m=e.disabled,d=void 0!==m&&m,p=e.readOnly,v=void 0!==p&&p;const E=(0,b.t)().settings,w=(0,n.useRef)(null),A=U((0,n.useState)(!1),2),N=A[0],P=A[1],j=U((0,n.useState)(r),2),I=j[0],F=j[1],Y=U((0,n.useState)(""),2),$=Y[0],W=Y[1],G=U((0,n.useState)(null),2),V=G[0],Z=G[1],K=U((0,n.useState)(""),2),H=K[0],X=K[1],Q=U((0,n.useState)(0),2),ee=Q[0],te=Q[1],re=U((0,n.useState)(null),2),ne=re[0],ae=re[1],ie=(0,n.useRef)({active:!1,suppressClick:!1});(0,n.useEffect)(()=>{F(r),W("")},[r]),(0,n.useEffect)(()=>{Z(null),X(""),te(0)},[o]);const oe=(0,f.getChartPresentation)(I),le=I.categoryLabel||f.catalog.dimensions[I.dimension].label,se="y"===q(I),ce=D(I),ue=!ce&&o.rows.length>1,me=["line","area"].includes(I.chartType),de="".concat(I.chartType,"-").concat(I.orientation,"-").concat(I.scale,"-").concat(I.dimension,"-").concat(o.retrievedAt),pe=(null==ne?void 0:ne.key)===de?{min:ne.min,max:ne.max}:null;(0,n.useEffect)(()=>{ae(null),ie.current={active:!1,suppressClick:!1}},[de]);const he=e=>{if(!d&&!v)try{const t=(0,f.validateChartSpec)(e(I));if(!z(t,o).includes(t.chartType))throw new Error("This chart type needs a complete, non-overlapping population. Choose a bar chart.");null==u||u(t),F(t),W("")}catch(e){W(e instanceof Error?e.message:"This chart setting is not supported.")}},ge=e=>he(t=>M(M({},t),{},{presentation:M(M({},t.presentation),e)})),ye=(e,t)=>{e<0||e>=o.rows.length||t<0||t>=o.series.length||(Z({row:e,series:t}),X(String(e)),te(t))},be=e=>{var t,r;if(e!==w.current)return;const n=null===(t=e.scales)||void 0===t?void 0:t[q(I)];ae(null!==(r=e.isZoomedOrPanned)&&void 0!==r&&r.call(e)&&n?{min:n.min,max:n.max,key:de}:null)},fe=function(e,t,r){const n=(0,f.getChartPresentation)(e),a="default"===n.palette?r:R[n.palette],i=a.length?a:R.accessible;return{labels:t.rows.map(t=>L(e,t.label)),datasets:t.series.map((r,a)=>{var o;const l=i[a%i.length];return{label:r.label,data:t.rows.map(t=>"logarithmic"===e.scale&&0===t.values[a]?null:t.values[a]),backgroundColor:D(e)?t.rows.map((e,t)=>i[t%i.length]):"area"===e.chartType?(0,k.c)(l).alpha(.25).rgbString():l,borderColor:l,borderWidth:n.borderWidth,borderRadius:n.barRadius,pointRadius:void 0===(null===(o=e.presentation)||void 0===o?void 0:o.pointRadius)&&t.rows.length>40?1:n.pointRadius,pointHitRadius:8,pointHoverRadius:Math.max(4,n.pointRadius+1),tension:"smooth"===n.lineStyle?.15:0,stepped:"stepped"===n.lineStyle,fill:"area"===e.chartType&&"origin"}})}}(I,o,E.colorScheme),ve=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=(0,f.getChartPresentation)(e),a=q(e),i="x"===a?"y":"x",o=e.categoryLabel||f.catalog.dimensions[e.dimension].label,l=e.valueLabel||("percent"===e.measure?"Matching PDB entries (%)":"Number of PDB entries"),s=D(e),c=!s&&t.rows.length>1,u=e=>{var t;let n=e.chart;return null===(t=r.onGestureComplete)||void 0===t?void 0:t.call(r,n)};return _(_({responsive:!0,maintainAspectRatio:!1,animation:!1,indexAxis:a,onClick:r.onSelect},"doughnut"===e.chartType?{cutout:"".concat(n.doughnutCutout,"%")}:{}),{},{plugins:_({legend:{display:"hidden"!==n.legend&&("auto"!==n.legend||s||t.series.length>1),position:"auto"===n.legend||"hidden"===n.legend?"bottom":n.legend},tooltip:{callbacks:{label:t=>"".concat(t.dataset.label,": ").concat(Number(t.raw).toLocaleString(void 0,{maximumFractionDigits:2})).concat("percent"===e.measure?"%":" entries")}}},c?{zoom:{limits:{[a]:{min:0,max:t.rows.length-1,minRange:1}},pan:{enabled:!0,mode:a,modifierKey:"shift",threshold:10,onPanStart:r.onGestureStart,onPanComplete:u},zoom:{mode:a,wheel:{enabled:!0,modifierKey:"ctrl",speed:.1},pinch:{enabled:!0},drag:{enabled:!1},onZoomStart:r.onGestureStart,onZoomComplete:u}}}:{})},s?{}:{scales:{[i]:{type:e.scale,beginAtZero:"linear"===e.scale,grid:{display:n.grid},title:{display:!0,text:l}},[a]:{type:"category",grid:{display:n.grid},title:{display:!0,text:o},ticks:{autoSkip:"x"===a,maxRotation:55}}}})}(I,o,{onSelect:(e,t,r)=>{var n,a,i;ie.current.active||ie.current.suppressClick||null!==(n=r.isZoomingOrPanning)&&void 0!==n&&n.call(r)||null!==(a=e.native)&&void 0!==a&&a.ctrlKey||null!==(i=e.native)&&void 0!==i&&i.shiftKey||t.length&&ye(t[0].index,t[0].datasetIndex)},onGestureStart:()=>{ie.current={active:!0,suppressClick:!0}},onGestureComplete:e=>{ie.current.active=!1,be(e)}});pe&&!ce&&Object.assign(ve.scales[q(I)],pe);const Ee=e=>{w.current&&(e?w.current.zoom({[q(I)]:e},"none"):w.current.resetZoom("none"),be(w.current))};let we=null,Se="";try{V&&(we=function(e,t,r,n){if(!Number.isInteger(r)||!Number.isInteger(n)||r<0||n<0||r>=t.rows.length||n>=t.series.length)return null;const a=t.rows[r],i=t.series[n],o=(0,f.buildChartDrilldownRequest)(e,a.label,n);return{label:"".concat(e.cumulative?"Through ":"").concat(L(e,a.label)),series:i.label,count:a.counts[n],value:a.values[n],total:i.total,href:"/search?request=".concat(encodeURIComponent(JSON.stringify(o)))}}(I,o,V.row,V.series))}catch(e){Se=e instanceof Error?e.message:"Matching structures are not available for this category."}const Ce=me?O.N1:"doughnut"===I.chartType?O.nu:"pie"===I.chartType?O.Fq:O.yP;return n.createElement("section",{className:"ai-chart-result".concat(c?" ai-chart-preview":""),"aria-label":c?"Proposed chart preview":"Applied chart"},n.createElement("div",{className:"ai-chart-result-heading"},n.createElement("div",null,n.createElement("div",{className:"ai-chart-eyebrow"},c?"Proposed chart · not yet applied":"Applied chart"),n.createElement("h2",null,I.title)),n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>{P(!N),ae(null)}},N?n.createElement(y,null):n.createElement(g,null)," ",N?"Chart":"Data table")),n.createElement("div",{className:"ai-chart-totals"},o.series.map(e=>n.createElement("span",{key:e.label},n.createElement("strong",null,e.total.toLocaleString())," matching entries · ",e.label))),n.createElement("details",{className:"ai-chart-customize"},n.createElement("summary",null,"Customize chart"),n.createElement("fieldset",{disabled:d||v},n.createElement("div",{className:"ai-chart-style-grid"},n.createElement("label",null,"Chart type",n.createElement(l.A.Select,{size:"sm",value:I.chartType,onChange:e=>he(t=>B(t,e.target.value))},z(I,o).map(e=>n.createElement("option",{key:e,value:e},T[e])))),n.createElement("label",null,"Color palette",n.createElement(l.A.Select,{size:"sm",value:oe.palette,onChange:e=>ge({palette:e.target.value})},["default","accessible","warm","cool","monochrome"].map(e=>n.createElement("option",{key:e,value:e},e[0].toUpperCase()+e.slice(1))))),n.createElement("label",null,"Legend",n.createElement(l.A.Select,{size:"sm",value:oe.legend,onChange:e=>ge({legend:e.target.value})},["auto","top","bottom","left","right","hidden"].map(e=>n.createElement("option",{key:e,value:e},e[0].toUpperCase()+e.slice(1))))),!ce&&n.createElement("label",null,"Value scale",n.createElement(l.A.Select,{size:"sm",value:I.scale,onChange:e=>he(t=>M(M({},t),{},{scale:e.target.value}))},n.createElement("option",{value:"linear"},"Linear"),n.createElement("option",{value:"logarithmic",disabled:"percent"===I.measure||"area"===I.chartType||!o.rows.some(e=>e.values.some(e=>e>0))},"Logarithmic"))),"bar"===I.chartType&&n.createElement("label",null,"Orientation",n.createElement(l.A.Select,{size:"sm",value:I.orientation,onChange:e=>he(t=>M(M({},t),{},{orientation:e.target.value}))},n.createElement("option",{value:"vertical"},"Vertical"),n.createElement("option",{value:"horizontal"},"Horizontal"))),!ce&&n.createElement("label",{className:"ai-chart-grid-toggle"},n.createElement("input",{type:"checkbox",checked:oe.grid,onChange:e=>ge({grid:e.target.checked})})," Show grid lines"),me&&n.createElement(n.Fragment,null,n.createElement("label",null,"Line style",n.createElement(l.A.Select,{size:"sm",value:oe.lineStyle,onChange:e=>ge({lineStyle:e.target.value})},n.createElement("option",{value:"straight"},"Straight"),n.createElement("option",{value:"smooth"},"Smooth"),n.createElement("option",{value:"stepped"},"Stepped"))),n.createElement("label",null,"Point radius",n.createElement(l.A.Control,{size:"sm",type:"number",min:0,max:8,step:1,value:void 0===(null===(t=I.presentation)||void 0===t?void 0:t.pointRadius)&&o.rows.length>40?1:oe.pointRadius,onChange:e=>ge({pointRadius:Number(e.target.value)})}))),n.createElement("label",null,"Border width",n.createElement(l.A.Control,{size:"sm",type:"number",min:1,max:5,step:1,value:oe.borderWidth,onChange:e=>ge({borderWidth:Number(e.target.value)})})),"bar"===I.chartType&&n.createElement("label",null,"Bar corner radius",n.createElement(l.A.Control,{size:"sm",type:"number",min:0,max:12,step:1,value:oe.barRadius,onChange:e=>ge({barRadius:Number(e.target.value)})})),"doughnut"===I.chartType&&n.createElement("label",null,"Doughnut hole (%)",n.createElement(l.A.Control,{size:"sm",type:"number",min:20,max:85,step:1,value:oe.doughnutCutout,onChange:e=>ge({doughnutCutout:Number(e.target.value)})})))),n.createElement("p",null,v?"Customize the active preview or discard it before changing this previous chart.":d?"Chart settings are paused while your request is running.":"Changes update this chart immediately without an AI request. Available chart types follow the data’s counting and ordering rules.")),$&&n.createElement(i.A,{variant:"danger"},$),!N&&ue&&n.createElement("div",{className:"ai-chart-zoom"},n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>Ee(1.4)},"Zoom in"),n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>Ee(.7)},"Zoom out"),n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>Ee(),disabled:!pe},"Reset zoom"),n.createElement("small",null,"Ctrl + wheel or pinch to zoom categories. Shift + drag to pan. Values and totals do not change.")),o.rows.length?N?n.createElement("div",{className:"ai-chart-table"},n.createElement("table",{className:"table table-striped table-sm"},n.createElement("caption",null,"Live PDB entry counts. ","percent"===I.measure?"Percentages use each series total as the denominator.":""," Select a value to inspect matching structures."),n.createElement("thead",null,n.createElement("tr",null,n.createElement("th",{scope:"col"},le),o.series.map(e=>n.createElement("th",{scope:"col",key:e.label},e.label)))),n.createElement("tbody",null,o.rows.map((e,t)=>n.createElement("tr",{key:e.label},n.createElement("th",{scope:"row"},L(I,e.label)),e.values.map((r,a)=>n.createElement("td",{key:a},n.createElement("button",{type:"button",className:"ai-chart-cell","aria-label":"Inspect ".concat(L(I,e.label),", ").concat(o.series[a].label),onClick:()=>ye(t,a)},r.toLocaleString(void 0,{maximumFractionDigits:2}),"percent"===I.measure?"% (".concat(e.counts[a].toLocaleString()," entries)"):"")))))))):n.createElement("div",{onPointerDownCapture:e=>{ie.current.active||e.ctrlKey||e.shiftKey||(ie.current.suppressClick=!1)},style:{height:se?Math.min(900,Math.max(340,25*o.rows.length+100)):400}},n.createElement(Ce,{key:de,ref:w,data:fe,options:ve,plugins:ce?[]:J})):n.createElement("div",{className:"ai-chart-empty"},"No entries have chart values for these filters. Refine the request to broaden the population."),o.rows.length>0&&n.createElement("div",{className:"ai-chart-inspect"},n.createElement("p",null,"Click a chart value or choose a category to inspect its PDB entries."),n.createElement("div",{className:"ai-chart-inspect-controls"},n.createElement("label",null,"Inspect category",n.createElement(l.A.Select,{size:"sm",value:H,onChange:e=>{X(e.target.value),e.target.value?ye(Number(e.target.value),ee):Z(null)}},n.createElement("option",{value:""},"Choose a category…"),o.rows.map((e,t)=>n.createElement("option",{key:e.label,value:t},L(I,e.label))))),o.series.length>1&&n.createElement("label",null,"Inspect series",n.createElement(l.A.Select,{size:"sm",value:ee,onChange:e=>{te(Number(e.target.value)),H&&ye(Number(H),Number(e.target.value))}},o.series.map((e,t)=>n.createElement("option",{key:e.label,value:t},e.label))))),we&&n.createElement("div",{className:"ai-chart-selection",role:"status"},n.createElement("strong",null,we.label),n.createElement("p",null,we.series,": ",we.count.toLocaleString()," matching PDB entries","percent"===I.measure?" (".concat(we.value.toLocaleString(void 0,{maximumFractionDigits:2}),"% of ").concat(we.total.toLocaleString()," matching entries)"):"",".","resolution"===I.dimension?" This bin includes its lower bound and excludes its upper bound.":""),n.createElement("a",{href:we.href,target:"_blank",rel:"noopener noreferrer"},"View matching structures")),Se&&n.createElement(i.A,{variant:"warning"},Se)),n.createElement("div",{className:"ai-chart-export-row"},n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>C(function(e,t){return[[e.categoryLabel||"Category",...t.series.flatMap(t=>["".concat(t.label,": entry count"),..."percent"===e.measure?["".concat(t.label,": percent of ").concat(t.total," matching entries")]:[]])],...t.rows.map(t=>[t.label,...t.counts.flatMap((r,n)=>[r,..."percent"===e.measure?[t.values[n]]:[]])])].map(e=>e.map(S).join(",")).join("\r\n")}(I,o),"pdb-chart-data.csv","text/csv;charset=utf-8")},n.createElement(h,null)," CSV"),n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>C(JSON.stringify({chart:I,data:o,searchRequests:(0,f.buildChartRequests)(I),view:{categoryAxis:ce?null:q(I),bounds:pe}},null,2),"pdb-chart.json","application/json")},n.createElement(h,null)," Chart + data JSON"),!N&&o.rows.length>0&&n.createElement(a.A,{size:"sm",variant:"outline-secondary",onClick:()=>{if(!w.current)return;const e=document.createElement("a");e.href=pe?x(w.current.canvas,I,o,"Zoomed view; full data available in CSV/JSON."):x(w.current.canvas,I,o),e.download="pdb-chart.png",e.click()}},n.createElement(h,null)," PNG"),n.createElement("span",null,"Retrieved ",new Date(o.retrievedAt).toLocaleString())),n.createElement("p",{className:"ai-chart-export-scope"},"PNG captures the visible chart view. CSV and JSON include the full data."),n.createElement("details",{className:"ai-chart-provenance"},n.createElement("summary",null,"Data source, filters, and counting rules"),n.createElement("p",null,"Live ",n.createElement("a",{href:"https://search.rcsb.org/#faceted-queries",target:"_blank",rel:"noopener noreferrer"},"RCSB PDB Search API"),". Released PDB entries only; computed models excluded. Missing attribute values are not a category."),n.createElement("p",null,I.filters.length?I.filters.map(f.describeFilter).join("; "):"No population filters."),I.series.map(e=>n.createElement("p",{key:e.label},n.createElement("strong",null,e.label,":")," ",e.filters.length?e.filters.map(f.describeFilter).join("; "):"No additional cohort filters.")),o.warnings.length>0&&n.createElement("ul",null,o.warnings.map(e=>n.createElement("li",{key:e},e))),n.createElement("details",null,n.createElement("summary",null,"Reproducible Search API requests"),n.createElement("pre",null,JSON.stringify((0,f.buildChartRequests)(I),null,2)))))}function G(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?G(Object(r),!0).forEach(function(t){Z(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Z(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function K(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,l=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw a}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return H(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}const X=[{title:"Track growth by experimental method",prompt:"Compare cumulative PDB growth since 2000 for X-ray diffraction, electron microscopy, and solution NMR as an area chart."},{title:"Follow an archive trend",prompt:"Compare annual releases of X-ray and electron microscopy structures since 2015 as a line chart."},{title:"Investigate integrative structures",prompt:"Chart the input data types used in integrative PDB structures."},{title:"Explore resolution distributions",prompt:"Show X-ray structure resolution from 0 to 4 angstroms as a vertical bar histogram with 0.5 angstrom bins."},{title:"Compare structure methodologies",prompt:"Compare experimental and integrative structures in the current PDB archive as a doughnut chart, using an accessible color palette."}];function Q(){const e=function(e){const t=e.aiCommands||("undefined"!=typeof window?window.__RCSB_AI_COMMANDS__:void 0);return t&&"function"==typeof t.execute&&"function"==typeof t.getStatus?t:void 0}((0,b.t)().settings.config),t=K((0,n.useState)(null),2),r=t[0],s=t[1],h=K((0,n.useState)([]),2),g=h[0],y=h[1],v=K((0,n.useState)(""),2),w=v[0],S=v[1],C=K((0,n.useState)(null),2),O=C[0],A=C[1],N=K((0,n.useState)(null),2),P=N[0],x=N[1],k=K((0,n.useState)([]),2),j=k[0],_=k[1],I=K((0,n.useState)(!1),2),T=I[0],R=I[1],D=K((0,n.useState)("Interpreting your chart request…"),2),q=D[0],L=D[1],B=K((0,n.useState)(""),2),z=B[0],F=B[1],M=(0,n.useRef)(null),Y=(0,n.useRef)(0),U=(0,n.useRef)(null),$=(0,n.useRef)(null),J=(0,n.useRef)(null);(0,n.useEffect)(()=>{var t;let r=!0;const n=e=>{if(!r)return;const t=JSON.stringify([e.connected,e.provider,e.model,e.connectionId]);var n;null!==J.current&&t!==J.current&&(Y.current+=1,null===(n=M.current)||void 0===n||n.abort(),M.current=null,R(!1),A(null),_([]),F(e.connected?"Your AI connection or model changed. Prepare a new preview before applying it.":"Reconnect your AI provider in AI Settings. Your applied chart has not changed.")),J.current=t,s(e)},a=()=>null==e?void 0:e.getStatus().then(n).catch(()=>n({connected:!1})),i=null==e||null===(t=e.subscribe)||void 0===t?void 0:t.call(e,n);return a(),window.addEventListener("focus",a),()=>{var e;r=!1,null==i||i(),window.removeEventListener("focus",a),Y.current+=1,null===(e=M.current)||void 0===e||e.abort()}},[e]),(0,n.useEffect)(()=>{var e,t;null===(e=U.current)||void 0===e||null===(t=e.scrollTo)||void 0===t||t.call(e,{top:g.length?U.current.scrollHeight:0,behavior:g.length?"smooth":"auto"})},[g,T,j]);const G=async function(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:w).trim();if(!t||t.length>4e3||T||M.current||!e||null==r||!r.connected)return;const n=++Y.current,a=new AbortController;M.current=a;const i=[...g,{role:"user",content:t}].slice(-15);y(i),S(""),_([]),F(""),R(!0),L("Interpreting your chart request…");try{const t=function(e){var t,r;if(!e||!e.ok||!["ready","clarification"].includes(e.status)||"string"!=typeof e.message)throw new Error("The AI service returned an incomplete chart response. Your current chart has not changed.");if("clarification"===e.status){if(!Array.isArray(e.questions)||e.questions.length>4||e.questions.some(e=>"string"!=typeof e.question||e.options&&(!Array.isArray(e.options)||e.options.length>8||e.options.some(e=>"string"!=typeof e))))throw new Error("The AI service returned an invalid clarification. Please rephrase your request.");return e}if("configureChart"!==(null===(t=e.command)||void 0===t?void 0:t.action))throw new Error("The AI service returned an unsupported command.");const n=(0,f.validateChartSpec)(e.command.spec),a=null===(r=e.preview)||void 0===r?void 0:r.chartData;if(!a||!Array.isArray(a.rows)||a.rows.length>1e3||!Array.isArray(a.series)||a.series.length!==n.series.length||!Array.isArray(a.warnings)||a.warnings.length>20||a.warnings.some(e=>"string"!=typeof e||e.length>1e3)||!Number.isInteger(a.categoryCount)||a.categoryCount<a.rows.length||!Number.isFinite(Date.parse(a.retrievedAt)))throw new Error("Live chart data was not returned. Your current chart has not changed.");if(a.series.some((e,t)=>e.label!==n.series[t].label||!Number.isInteger(e.total)||e.total<0)||a.rows.some(e=>"string"!=typeof e.label||!Array.isArray(e.counts)||e.counts.length!==a.series.length||!Array.isArray(e.values)||e.values.length!==a.series.length||e.counts.some(e=>!Number.isInteger(e)||e<0)||e.values.some(e=>!Number.isFinite(e)||e<0)))throw new Error("Live chart data did not pass validation. Your current chart has not changed.");if(new Set(a.rows.map(e=>e.label)).size!==a.rows.length||a.rows.some(e=>e.counts.some((t,r)=>t>a.series[r].total||Math.abs(e.values[r]-("percent"===n.measure?a.series[r].total?100*t/a.series[r].total:0:t))>1e-6)))throw new Error("Chart values do not match the validated entry counts.");return E(E({},e),{},{command:{action:"configureChart",spec:n}})}(await e.execute({action:"configureChart",messages:i,context:{currentChart:(null==P?void 0:P.command.spec)||null,pendingChart:(null==O?void 0:O.command.spec)||null},previousCommand:(null==O?void 0:O.command)||(null==P?void 0:P.command)||null},{signal:a.signal,onProgress:e=>{if(n!==Y.current||a.signal.aborted)return;const t={planning:"Interpreting your chart request…",lookup:"Looking up PDB metadata…",building:"Preparing the chart specification…",validating:"Validating the chart and loading live PDB counts…"};t[e]&&L(t[e])}}));if(n!==Y.current||a.signal.aborted)return;y([...i,{role:"assistant",content:t.message}]),_(t.questions||[]),"ready"===t.status&&A({command:t.command,data:t.preview.chartData,preview:t.preview})}catch(e){if(n!==Y.current||a.signal.aborted)return;F(e instanceof Error?e.message:"The chart could not be prepared. Your current chart has not changed.")}finally{n===Y.current&&(R(!1),M.current=null)}},Z=()=>{var e;Y.current+=1,null===(e=M.current)||void 0===e||e.abort(),M.current=null,R(!1),F("Request cancelled. Your current chart and previous proposal have not changed.")},H=(null==e?void 0:e.settingsUrl)||"/search/ai-settings",Q=Boolean(e&&(null==r?void 0:r.connected)),ee=O||P,te=O?(0,f.chartChanges)((null==P?void 0:P.command.spec)||null,O.command.spec):[];return n.createElement("article",{className:"ai-chart-workspace"},n.createElement("header",{className:"ai-chart-page-heading"},n.createElement("div",null,n.createElement("h1",null,"AI Powered Chart Builder"),n.createElement("p",null,"Describe a question. Review a chart grounded in live PDB data.")),n.createElement(a.A,{variant:"outline-secondary",href:H},n.createElement(d,null)," AI Settings")),!Q&&n.createElement(i.A,{variant:"info",className:"ai-chart-connect"},e&&null===r?"Checking your AI connection…":n.createElement(n.Fragment,null,"Connect a provider in ",n.createElement("a",{href:H},"AI Settings")," to create and refine charts. The chart builder uses the same connection as the AI Query Builder."),!e&&n.createElement("div",{className:"small mt-1"},"AI commands are available when this app is hosted in a configured Sierra environment.")),n.createElement("div",{className:"ai-chart-layout"},n.createElement("section",{className:"ai-chart-chat","aria-label":"Chart conversation"},n.createElement("div",{className:"ai-chart-panel-heading"},n.createElement("strong",null,"Build a chart"),n.createElement(a.A,{variant:"link",size:"sm",onClick:()=>{var e;Z(),y([]),A(null),x(null),_([]),S(""),F(""),null===(e=$.current)||void 0===e||e.focus()},disabled:!g.length&&!P},n.createElement(u,null)," Start over")),n.createElement("div",{ref:U,className:"ai-chart-conversation","aria-live":"polite",role:"region","aria-label":"Chart conversation and examples",tabIndex:0},!g.length&&n.createElement(n.Fragment,null,n.createElement("p",{className:"ai-chart-welcome"},"What would you like to learn about the PDB archive?"),n.createElement("p",{className:"ai-chart-muted"},"Compare methods, organisms, ligands, release-year trends, resolution distributions, or integrative input data. Start with an example or ask your own question."),n.createElement("div",{className:"ai-chart-examples"},X.map(e=>n.createElement("button",{key:e.title,onClick:()=>{var t;S(e.prompt),null===(t=$.current)||void 0===t||t.focus()}},n.createElement("strong",null,e.title),n.createElement("span",null,e.prompt))))),g.map((e,t)=>n.createElement("div",{key:t,className:"ai-chart-message ai-chart-message-".concat(e.role)},n.createElement("span",{className:"visually-hidden"},"user"===e.role?"You":"AI",": "),e.content)),j.map((e,t)=>{var r;return n.createElement("div",{key:t,className:"ai-chart-question"},n.createElement("strong",null,e.question),n.createElement("div",null,null===(r=e.options)||void 0===r?void 0:r.map(t=>n.createElement(a.A,{key:t,size:"sm",variant:"outline-primary",disabled:T||!Q,onClick:()=>G("".concat(e.question,"\n").concat(t))},t))))}),T&&n.createElement("div",{role:"status",className:"ai-chart-wait"},n.createElement(o.A,{animation:"border",size:"sm"}),n.createElement("span",null,q))),z&&n.createElement(i.A,{variant:"danger",className:"m-3 mb-0",dismissible:!0,onClose:()=>F("")},z),n.createElement(l.A,{className:"ai-chart-composer",onSubmit:e=>{e.preventDefault(),G()}},n.createElement(l.A.Label,{htmlFor:"ai-chart-prompt"},ee?"Refine this chart":"Describe your chart"),n.createElement(l.A.Control,{as:"textarea",id:"ai-chart-prompt",ref:$,rows:3,maxLength:4e3,value:w,onChange:e=>S(e.target.value),placeholder:ee?"Try “make it an area chart”, “use a cool palette”, or “hide the gridlines”…":"For example, compare X-ray and cryo-EM structure releases over time…",disabled:T}),n.createElement("div",{className:"ai-chart-composer-actions"},n.createElement("span",null,(null==r?void 0:r.model)||"Your connected AI model"),T?n.createElement(a.A,{variant:"outline-secondary",onClick:Z},n.createElement(p,null)," Cancel"):n.createElement(a.A,{type:"submit",disabled:!Q||!w.trim()},n.createElement(m,null)," Build Chart")))),n.createElement("div",{className:"ai-chart-canvas"},O&&n.createElement("div",{className:"ai-chart-review"},n.createElement("div",null,n.createElement("strong",null,"Review before applying"),n.createElement("p",null,(0,f.describeChart)(O.command.spec))),te.length?n.createElement("ul",null,te.map(e=>n.createElement("li",{key:e},e))):n.createElement("p",null,"No chart settings changed."),O.data.warnings.length>0&&n.createElement("details",null,n.createElement("summary",null,O.data.warnings.length," counting ",1===O.data.warnings.length?"note":"notes"),n.createElement("ul",null,O.data.warnings.map(e=>n.createElement("li",{key:e},e)))),n.createElement("div",{className:"ai-chart-review-actions"},n.createElement(a.A,{disabled:T,onClick:()=>{x(O),A(null)}},n.createElement(c,null)," Apply chart"),n.createElement(a.A,{variant:"outline-secondary",disabled:T,onClick:()=>A(null)},"Discard proposal"))),ee?n.createElement(W,{key:"".concat(ee.data.retrievedAt,"-").concat(Boolean(O)),spec:ee.command.spec,data:ee.data,preview:Boolean(O),onSpecChange:e=>{if(ee&&!T&&!M.current)try{const t=(0,f.validateChartSpec)(V(V({},ee.command.spec),{},{chartType:e.chartType,orientation:e.orientation,scale:e.scale},e.presentation?{presentation:e.presentation}:{})),r=new Set((0,f.chartWarnings)(ee.command.spec)),n=[...new Set([...ee.data.warnings.filter(e=>!r.has(e)),...(0,f.chartWarnings)(t)])],a=V(V({},ee.data),{},{warnings:n}),i={command:{action:"configureChart",spec:t},data:a,preview:V(V({},ee.preview),{},{summary:(0,f.describeChart)(t),changes:(0,f.chartChanges)((null==P?void 0:P.command.spec)||null,t),warnings:n,chartData:a})};O?A(i):x(i),F("")}catch(e){F(e instanceof Error?e.message:"Those chart settings are not compatible with this data.")}},disabled:T}):n.createElement("div",{className:"ai-chart-placeholder"},n.createElement("p",null,"A validated preview will appear here. Nothing is applied until you choose Apply chart.")),P&&O&&n.createElement("details",{className:"ai-chart-previous"},n.createElement("summary",null,"View currently applied chart"),n.createElement(W,{spec:P.command.spec,data:P.data,readOnly:!0})))))}},3482(e){"use strict";e.exports=JSON.parse('{"version":1,"action":"configureChart","name":"AI Powered Chart Builder","checkedAt":"2026-09-13","sources":["https://search.rcsb.org/#faceted-queries","https://search.rcsb.org/rcsbsearch/v2/metadata/schema"],"countingRules":["Every value is a live count of released PDB entries, not polymer entities, atoms, chains, downloads, citations, or unique sequences. Computed models are excluded.","Categories may overlap when an entry has multiple methods, organisms, polymer types, input datasets, or resolution values. Do not sum overlapping buckets to claim a unique total.","Percentages use all matching entries in each cohort as the denominator, including entries missing the chart attribute. They are not normalized to the displayed top categories.","All filters are entry-level requirements. An organism and ligand filter may match different entities in the same entry. Do not promise same-chain, binding-site, or same-entity relationships.","Lower and upper bounds on one numeric or date attribute are combined into one inclusive interval. At least one value must satisfy both bounds; different reported resolutions cannot satisfy opposite ends of the interval.","Cumulative release-year counts start at the selected lower release-year bound, not necessarily the beginning of the archive. Current-year counts are incomplete.","Area charts require an ordered dimension, ascending labels, vertical orientation and linear scale. Their translucent series are not stacked. Doughnut charts follow the same complete, non-overlapping partition rules as pie charts.","Presentation settings change appearance only. They cannot change chart counts, filters, aggregation attributes, or destinations. Use only the supported palettes, legend positions, grid, line styles and numeric drawing controls.","Selecting a bucket searches matching entries, keeping every global and cohort filter. The clicked bucket is an independent requirement: in a multi-valued entry, the value in the bucket may differ from the value satisfying a population filter. Resolution buckets use one half-open interval including the lower bound and excluding the upper bound.","Comparisons use up to four explicit named cohorts with independent additional filters; cohorts may overlap. Never fabricate counts or arbitrary Search API attributes.","Ask a clarification when a request needs unsupported statistics, ambiguous units or entity relationships, or an unknown organism taxon. Preserve the existing chart and filters during refinement unless the user requests a change."],"dimensions":{"releaseYear":{"label":"Release year","attribute":"rcsb_accession_info.initial_release_date","aggregation":"date_histogram","interval":"year","ordered":true,"overlapping":false},"method":{"label":"Experimental method","attribute":"exptl.method","aggregation":"terms","ordered":false,"overlapping":true},"sourceOrganism":{"label":"Source organism","attribute":"rcsb_entity_source_organism.ncbi_scientific_name","aggregation":"terms","ordered":false,"overlapping":true},"resolution":{"label":"Resolution (Å)","attribute":"rcsb_entry_info.resolution_combined","aggregation":"histogram","ordered":true,"overlapping":true},"polymerType":{"label":"Polymer type","attribute":"entity_poly.rcsb_entity_polymer_type","aggregation":"terms","ordered":false,"overlapping":true},"integrativeInput":{"label":"Integrative input data type","attribute":"rcsb_ihm_dataset_list.name","aggregation":"terms","ordered":false,"overlapping":true,"requiredFilter":{"field":"methodology","operator":"in","value":["integrative"]}},"methodology":{"label":"Structure determination methodology","attribute":"rcsb_entry_info.structure_determination_methodology","aggregation":"terms","ordered":false,"overlapping":false}},"filters":{"releaseYear":{"label":"Release year","attribute":"rcsb_accession_info.initial_release_date","kind":"year","operators":["gte","lte"],"minimum":1971,"maximum":2100},"method":{"label":"Experimental method","attribute":"exptl.method","kind":"enum","operators":["in"],"values":["X-RAY DIFFRACTION","ELECTRON MICROSCOPY","SOLUTION NMR","SOLID-STATE NMR","NEUTRON DIFFRACTION","ELECTRON CRYSTALLOGRAPHY","FIBER DIFFRACTION","POWDER DIFFRACTION","SOLUTION SCATTERING","INFRARED SPECTROSCOPY","EPR","FLUORESCENCE TRANSFER"]},"resolution":{"label":"Resolution (Å)","attribute":"rcsb_entry_info.resolution_combined","kind":"number","operators":["gte","lte"],"minimum":0.01,"maximum":1000},"sourceTaxonomy":{"label":"Source organism NCBI taxonomy ID (including descendants)","attribute":"rcsb_entity_source_organism.taxonomy_lineage.id","kind":"taxonomy","operators":["in"]},"sourceOrganism":{"label":"Exact source organism scientific name","attribute":"rcsb_entity_source_organism.ncbi_scientific_name","kind":"text","operators":["in"]},"ligand":{"label":"Non-polymer chemical component ID present in entry","attribute":"rcsb_nonpolymer_entity.rcsb_nonpolymer_comp_id","kind":"identifier","operators":["in"]},"polymerType":{"label":"Polymer type present in entry","attribute":"entity_poly.rcsb_entity_polymer_type","kind":"enum","operators":["in"],"values":["Protein","DNA","RNA","NA-hybrid","Other"]},"methodology":{"label":"Structure determination methodology","attribute":"rcsb_entry_info.structure_determination_methodology","kind":"enum","operators":["in"],"values":["experimental","integrative"]}},"knownTaxa":{"human":9606,"mouse":10090,"Escherichia coli":562,"Saccharomyces cerevisiae":4932},"presentationDefaults":{"palette":"default","legend":"auto","grid":true,"lineStyle":"smooth","pointRadius":3,"borderWidth":1,"barRadius":0,"doughnutCutout":60},"specSchema":{"type":"object","additionalProperties":false,"required":["version","title","categoryLabel","valueLabel","dimension","chartType","measure","scale","orientation","sort","topN","interval","cumulative","filters","series"],"properties":{"version":{"type":"integer","enum":[1]},"title":{"type":"string","minLength":1,"maxLength":140},"categoryLabel":{"type":"string","minLength":1,"maxLength":100},"valueLabel":{"type":"string","minLength":1,"maxLength":100},"dimension":{"type":"string","enum":["releaseYear","method","sourceOrganism","resolution","polymerType","integrativeInput","methodology"]},"chartType":{"type":"string","enum":["bar","line","area","pie","doughnut"]},"measure":{"type":"string","enum":["count","percent"]},"scale":{"type":"string","enum":["linear","logarithmic"]},"orientation":{"type":"string","enum":["vertical","horizontal"]},"sort":{"type":"string","enum":["labelAsc","countDesc"]},"topN":{"type":"integer","minimum":1,"maximum":60},"interval":{"type":"number","minimum":0.1,"maximum":100},"cumulative":{"type":"boolean"},"presentation":{"$ref":"#/$defs/presentation"},"filters":{"type":"array","maxItems":12,"items":{"$ref":"#/$defs/filter"}},"series":{"type":"array","minItems":1,"maxItems":4,"items":{"type":"object","additionalProperties":false,"required":["label","filters"],"properties":{"label":{"type":"string","minLength":1,"maxLength":80},"filters":{"type":"array","maxItems":8,"items":{"$ref":"#/$defs/filter"}}}}}},"$defs":{"presentation":{"type":"object","additionalProperties":false,"properties":{"palette":{"type":"string","enum":["default","accessible","warm","cool","monochrome"]},"legend":{"type":"string","enum":["auto","top","bottom","left","right","hidden"]},"grid":{"type":"boolean"},"lineStyle":{"type":"string","enum":["straight","smooth","stepped"]},"pointRadius":{"type":"integer","minimum":0,"maximum":8},"borderWidth":{"type":"integer","minimum":1,"maximum":5},"barRadius":{"type":"integer","minimum":0,"maximum":12},"doughnutCutout":{"type":"integer","minimum":20,"maximum":85}}},"filter":{"type":"object","additionalProperties":false,"required":["field","operator","value"],"properties":{"field":{"type":"string","enum":["releaseYear","method","resolution","sourceTaxonomy","sourceOrganism","ligand","polymerType","methodology"]},"operator":{"type":"string","enum":["in","gte","lte"]},"value":{"anyOf":[{"type":"number"},{"type":"array","minItems":1,"maxItems":10,"uniqueItems":true,"items":{"anyOf":[{"type":"string","minLength":1,"maxLength":120},{"type":"integer","minimum":1,"maximum":999999999}]}}]}}}}}}')}}]);
|