@genome-spy/app 0.28.4 → 0.28.5
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/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -2163,7 +2163,7 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
|
|
2163
2163
|
* @license
|
2164
2164
|
* Copyright 2018 Google LLC
|
2165
2165
|
* SPDX-License-Identifier: BSD-3-Clause
|
2166
|
-
*/const Uk={},Hk=or(class extends qr{constructor(){super(...arguments),this.ot=Uk}render(t,e){return e()}update(t,[e,n]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((r,i)=>r===this.ot[i]))return Ae}else if(this.ot===e)return Ae;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,n)}});class Gk extends yt{constructor(){super(),this.inputRef=b2(),this.app=void 0,this.getDefaultValue=()=>"",this._keyListener=this._onKeyDown.bind(this),this._documentClickListener=e=>{var n;e.target!==this._inputField&&((n=this._inputField)==null||n.blur())},this._focused=!1}get genomeSpy(){return this.app.genomeSpy}get _inputField(){return this.inputRef.value}static get properties(){return{app:{type:Object}}}connectedCallback(){super.connectedCallback(),this._initializeGenome(),document.addEventListener("keydown",this._keyListener),document.addEventListener("click",this._documentClickListener)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this._keyListener),document.removeEventListener("click",this._documentClickListener)}createRenderRoot(){return this}_onKeyDown(e){switch(e.code){case"KeyF":e.metaKey||e.altKey||e.ctrlKey||(e.preventDefault(),this.inputRef.value.focus());break}}_initializeGenome(){const e=x2(this.genomeSpy.viewRoot);e&&(this._genomeResolution=e,this._genome=this.genomeSpy.genomeStore.getGenome(),this.getDefaultValue=()=>this._genome.formatInterval(e.getDomain()),e.addEventListener("domain",xs(()=>this.requestUpdate(),60,!1)))}async searchViews(e){var r;const n=new Intl.Collator("en",{usage:"search",sensitivity:"base"});for(const i of this.genomeSpy.getSearchableViews()){const o=i.getAccessor("search"),a=i.getAccessor("x"),s=i.getAccessor("x2"),c=i.getScaleResolution("x");if(!(!a||!s||!(c!=null&&c.isZoomable()))){for(const u of((r=i.getCollector())==null?void 0:r.getData())??[])if(n.compare(o(u),e)===0){const f=mc([a(u),s(u)],null,1.2);return await c.zoomTo(f),!0}}}return!1}async search(e){await(async()=>{if(this._genomeResolution&&this._genome){const r=this._genome.parseInterval(e);if(r){this._genomeResolution.zoomTo(r);return}if(await this.searchViews(e))return;this.genomeSpy.viewRoot.visit(i=>{i instanceof o2&&i.handleVerboseCommand(e)})}})(),this._inputField.value=this.getDefaultValue(),this.requestUpdate()}_onSearchHelpClicked(e){const n=e.target;n.tagName=="LI"&&this._doExampleSearch(n.innerText)}_onSearchFocused(e){const n=e.target;switch(e.type){case"focus":this._focused=!0,n.select();break;case"blur":this._focused=!1;break}}_onSearchKeyDown(e){const n=e.target;e.code=="Enter"?(e.preventDefault(),this.search(n.value).then(()=>{n.focus(),n.select()}).catch(r=>{console.log(r),alert(r)})):e.code=="Escape"?n.blur():e.stopPropagation()}_doExampleSearch(e){Qk(e,this._inputField).then(()=>{this._inputField.blur(),this.search(e)})}_getSearchHelp(){var i;const e=[];e.push(E`<p>Focus to a specific range. Examples:</p><ul><li>chr8</li><li>chr8:21,445,873</li><li>chr8:21,445,873-24,623,697</li><li>chr4:166,014,727-chr15:23,731,397</li></ul>`);for(const o of((i=this.genomeSpy)==null?void 0:i.getSearchableViews())||[]){const a=o.getTitleText()??o.spec.name,s=o.getAccessor("search"),c=s.fields.join(", "),u=Sg(3,o.getCollector().getData(),s);e.push(E`<p>Search <em>${a}</em> (${c}). Examples:</p><ul>${u.map(f=>E`<li>${f}</li>`)}</ul>`)}const n=this.app.getSampleView().attributePanel,r=n.getAttributeNames().map(o=>n.getAttributeInfo(o)).filter(o=>o.type=="nominal"||o.type=="ordinal").sort(()=>.5-Math.random()).map(o=>{var a;return[...((a=o.scale)==null?void 0:a.domain())??[]].sort(()=>.5-Math.random())[0]}).filter(o=>o!==void 0).slice(0,3);return r.length&&e.push(E`<p>Filter samples by categorical attributes. Examples:</p><ul>${r.map(o=>E`<li>${o}</li>`)}</ul>`),E`<div class="search-help" @click="${this._onSearchHelpClicked}">${e}</div>`}updated(e){this._focused&&this._inputField.select()}render(){return E`<div class="search"><input type="text" class="search-input" .value="${this.getDefaultValue()}" @mousedown="${e=>{this._focused||(this._inputField.focus(),e.preventDefault(),e.stopPropagation())}}" @keydown="${this._onSearchKeyDown.bind(this)}" @focus="${this._onSearchFocused}" @blur="${this._onSearchFocused}" ${A2(this.inputRef)}> ${Hk([123],()=>this._getSearchHelp())}</div>`}}customElements.define("genome-spy-search-field",Gk);function Qk(t,e){return new Promise(n=>{let r=0;const i=700/t.length+30;function o(){e.value=t.substring(0,r),r>=t.length?setTimeout(n,500):(r++,setTimeout(o,Math.random()*i*2))}o()})}function x2(t){let e;return t.visit(n=>{for(const r of["x","y"]){const i=n.resolutions.scale[r];if(i&&i.type=="locus"&&i.isZoomable())return e=i,tr}}),e}const w2="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMzIgMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjEuNSI+PHBhdGggZD0iTTQuNyAyMS4ycy40IDIuMyAxLjMgMy42QzcgMjYgOS44IDI4IDkuOCAyOHMzLjQtMi42IDYuNC04LjVjMCAwIDEgLjEgMS45LS40LjktLjYuOC0uNCAxLTEuMiAwIDAgMi45LjUgNi42IDAgMi4xLS4zIDQuMy0xIDYuMi0yLjUgMCAwLTEuMS0xLjctMi41LTUuMS0uNS0xLjMtMi0xLjgtNC42LTQuNmwtOC4yIDguNi0xMS45IDYuOXoiIGZpbGwtb3BhY2l0eT0iLjEiLz48cGF0aCBkPSJNMTIuNyAxNC44cy00LTEuOC0xMiAyLjdjMCAwIDEgMy43IDIuNSA1LjMgMS40IDEuNSAyLjMgMy42IDQuNiA0LjYgMCAwIDQuNy0zIDYuOS05LjJsMy0yczQuNyAyLjggMTIuNi0xLjZjMCAwLS42LTMuMy0zLTYtMi42LTMtMy44LTQuNy0zLjgtNC43cy00LjEgMi4zLTcuNSA5LjNsLTMuMyAxLjZ6IiBmaWxsPSIjN2ZiYmRkIi8+PHBhdGggZD0iTTEyLjQgMTUuNWMtLjctLjUtMi40LS44LTQuNC0uNC0yIC40LTQgMS4zLTQuOCAxLjgtLjUuMy0xLjIgMS0xLjIgMS40IDAgLjcuMyAxLjguOCAyLjQuMy4zLjcuNSAxLjQuNi44IDAgMi41LTEuNCAzLjUtMiAxLS42IDEuNi0uOCAyLjctMS4ybC0yLjkgMi40Yy0xLjMgMS4yLTIuMiAxLjUtMi40IDIuMyAwIC41IDAgMS40LjUgMS44LjQuNS42LjggMS42LjguNiAwIDEgMCAyLjYtMS41LjktLjkgMi4zLTMgMi43LTMuNy42LTEuMSAxLTIuMi43LTMtLjItMS0uNC0xLjQtLjgtMS43ek0xNy40IDE0LjJjLS4zLS41LS45LTEuMi0uMi0yLjVsMS45LTNjLjUtLjggMi0yLjMgMi42LTIuNi42LS40IDEuNS0uNiAyLS4yLjYuNCAxIDEgMS4zIDEuNS40LjYuNyAxLjMuMiAyLS43IDEtMS42LjktMi44IDEuNy0xLjIuOC0xLjkgMS4yLTIuNSAxLjlsMy44LTEuOGMxLjMtLjYgMi43LTEuMSAzLjQtLjcuOC41LjguNyAxIDEuNC4zIDEtLjIgMS45LS44IDIuNC0uNS42LTEuNS45LTIuNiAxLjItMS40LjQtNC41IDEtNS44LjUtMS4zLS41LTEuMy0xLjQtMS41LTEuOHoiIGZpbGw9IiNmZmYiLz48cGF0aCBkPSJNMTIuNyAxNC44cy00LTEuOC0xMiAyLjdjMCAwIDEgMy43IDIuNSA1LjMgMS40IDEuNSAyLjMgMy42IDQuNiA0LjYgMCAwIDQuNy0zIDYuOS05LjJsMy0yczQuNyAyLjggMTIuNi0xLjZjMCAwLS42LTMuMy0zLTYtMi42LTMtMy44LTQuNy0zLjgtNC43cy00LjEgMi4zLTcuNSA5LjNsLTMuMyAxLjZ6IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iLjUiLz48cGF0aCBkPSJNMTIuNCAxNC45czIuMS0yIDMtMmMxLjEgMCAyLjMgMi43IDIuMyAzLjUgMCAuOC0yLjEgMi40LTMuMSAyLjMgMCAwIDAtMS4yLS43LTIuNi0uOC0xLjMtMS41LTEuMi0xLjUtMS4yeiIgZmlsbD0iIzdmYmJkZCIvPjxwYXRoIGQ9Ik0xMy44IDE1LjNjLjkuOC42IDIgMS40IDEuOCAxLS4yIDEuNC0uOCAxLjMtMS41IDAtLjcgMC0uOC0uNC0xLjYtLjMtLjctMS0xLjEtMi0uNS0uNy41LTEuNCAxLjMtMS40IDEuM3MuMi0uMyAxLjEuNXoiIGZpbGw9IiNmZmYiLz48cGF0aCBkPSJNMTIuNCAxNC45czIuMS0yIDMtMmMxLjEgMCAyLjMgMi43IDIuMyAzLjUgMCAuOC0yLjEgMi40LTMuMSAyLjMgMCAwIDAtMS4yLS43LTIuNi0uOC0xLjMtMS41LTEuMi0xLjUtMS4yeiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwIiBzdHJva2Utd2lkdGg9Ii41Ii8+PC9zdmc+",C2={name:"@genome-spy/app",description:"GenomeSpy-based visualization tool for multiple patient samples",author:{name:"Kari Lavikka",email:"kari.lavikka@helsinki.fi"},contributors:[],license:"MIT",version:"0.28.
|
2166
|
+
*/const Uk={},Hk=or(class extends qr{constructor(){super(...arguments),this.ot=Uk}render(t,e){return e()}update(t,[e,n]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((r,i)=>r===this.ot[i]))return Ae}else if(this.ot===e)return Ae;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,n)}});class Gk extends yt{constructor(){super(),this.inputRef=b2(),this.app=void 0,this.getDefaultValue=()=>"",this._keyListener=this._onKeyDown.bind(this),this._documentClickListener=e=>{var n;e.target!==this._inputField&&((n=this._inputField)==null||n.blur())},this._focused=!1}get genomeSpy(){return this.app.genomeSpy}get _inputField(){return this.inputRef.value}static get properties(){return{app:{type:Object}}}connectedCallback(){super.connectedCallback(),this._initializeGenome(),document.addEventListener("keydown",this._keyListener),document.addEventListener("click",this._documentClickListener)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this._keyListener),document.removeEventListener("click",this._documentClickListener)}createRenderRoot(){return this}_onKeyDown(e){switch(e.code){case"KeyF":e.metaKey||e.altKey||e.ctrlKey||(e.preventDefault(),this.inputRef.value.focus());break}}_initializeGenome(){const e=x2(this.genomeSpy.viewRoot);e&&(this._genomeResolution=e,this._genome=this.genomeSpy.genomeStore.getGenome(),this.getDefaultValue=()=>this._genome.formatInterval(e.getDomain()),e.addEventListener("domain",xs(()=>this.requestUpdate(),60,!1)))}async searchViews(e){var r;const n=new Intl.Collator("en",{usage:"search",sensitivity:"base"});for(const i of this.genomeSpy.getSearchableViews()){const o=i.getAccessor("search"),a=i.getAccessor("x"),s=i.getAccessor("x2"),c=i.getScaleResolution("x");if(!(!a||!s||!(c!=null&&c.isZoomable()))){for(const u of((r=i.getCollector())==null?void 0:r.getData())??[])if(n.compare(o(u),e)===0){const f=mc([a(u),s(u)],null,1.2);return await c.zoomTo(f),!0}}}return!1}async search(e){await(async()=>{if(this._genomeResolution&&this._genome){const r=this._genome.parseInterval(e);if(r){this._genomeResolution.zoomTo(r);return}if(await this.searchViews(e))return;this.genomeSpy.viewRoot.visit(i=>{i instanceof o2&&i.handleVerboseCommand(e)})}})(),this._inputField.value=this.getDefaultValue(),this.requestUpdate()}_onSearchHelpClicked(e){const n=e.target;n.tagName=="LI"&&this._doExampleSearch(n.innerText)}_onSearchFocused(e){const n=e.target;switch(e.type){case"focus":this._focused=!0,n.select();break;case"blur":this._focused=!1;break}}_onSearchKeyDown(e){const n=e.target;e.code=="Enter"?(e.preventDefault(),this.search(n.value).then(()=>{n.focus(),n.select()}).catch(r=>{console.log(r),alert(r)})):e.code=="Escape"?n.blur():e.stopPropagation()}_doExampleSearch(e){Qk(e,this._inputField).then(()=>{this._inputField.blur(),this.search(e)})}_getSearchHelp(){var i;const e=[];e.push(E`<p>Focus to a specific range. Examples:</p><ul><li>chr8</li><li>chr8:21,445,873</li><li>chr8:21,445,873-24,623,697</li><li>chr4:166,014,727-chr15:23,731,397</li></ul>`);for(const o of((i=this.genomeSpy)==null?void 0:i.getSearchableViews())||[]){const a=o.getTitleText()??o.spec.name,s=o.getAccessor("search"),c=s.fields.join(", "),u=Sg(3,o.getCollector().getData(),s);e.push(E`<p>Search <em>${a}</em> (${c}). Examples:</p><ul>${u.map(f=>E`<li>${f}</li>`)}</ul>`)}const n=this.app.getSampleView().attributePanel,r=n.getAttributeNames().map(o=>n.getAttributeInfo(o)).filter(o=>o.type=="nominal"||o.type=="ordinal").sort(()=>.5-Math.random()).map(o=>{var a;return[...((a=o.scale)==null?void 0:a.domain())??[]].sort(()=>.5-Math.random())[0]}).filter(o=>o!==void 0).slice(0,3);return r.length&&e.push(E`<p>Filter samples by categorical attributes. Examples:</p><ul>${r.map(o=>E`<li>${o}</li>`)}</ul>`),E`<div class="search-help" @click="${this._onSearchHelpClicked}">${e}</div>`}updated(e){this._focused&&this._inputField.select()}render(){return E`<div class="search"><input type="text" class="search-input" .value="${this.getDefaultValue()}" @mousedown="${e=>{this._focused||(this._inputField.focus(),e.preventDefault(),e.stopPropagation())}}" @keydown="${this._onSearchKeyDown.bind(this)}" @focus="${this._onSearchFocused}" @blur="${this._onSearchFocused}" ${A2(this.inputRef)}> ${Hk([123],()=>this._getSearchHelp())}</div>`}}customElements.define("genome-spy-search-field",Gk);function Qk(t,e){return new Promise(n=>{let r=0;const i=700/t.length+30;function o(){e.value=t.substring(0,r),r>=t.length?setTimeout(n,500):(r++,setTimeout(o,Math.random()*i*2))}o()})}function x2(t){let e;return t.visit(n=>{for(const r of["x","y"]){const i=n.resolutions.scale[r];if(i&&i.type=="locus"&&i.isZoomable())return e=i,tr}}),e}const w2="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMzIgMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjEuNSI+PHBhdGggZD0iTTQuNyAyMS4ycy40IDIuMyAxLjMgMy42QzcgMjYgOS44IDI4IDkuOCAyOHMzLjQtMi42IDYuNC04LjVjMCAwIDEgLjEgMS45LS40LjktLjYuOC0uNCAxLTEuMiAwIDAgMi45LjUgNi42IDAgMi4xLS4zIDQuMy0xIDYuMi0yLjUgMCAwLTEuMS0xLjctMi41LTUuMS0uNS0xLjMtMi0xLjgtNC42LTQuNmwtOC4yIDguNi0xMS45IDYuOXoiIGZpbGwtb3BhY2l0eT0iLjEiLz48cGF0aCBkPSJNMTIuNyAxNC44cy00LTEuOC0xMiAyLjdjMCAwIDEgMy43IDIuNSA1LjMgMS40IDEuNSAyLjMgMy42IDQuNiA0LjYgMCAwIDQuNy0zIDYuOS05LjJsMy0yczQuNyAyLjggMTIuNi0xLjZjMCAwLS42LTMuMy0zLTYtMi42LTMtMy44LTQuNy0zLjgtNC43cy00LjEgMi4zLTcuNSA5LjNsLTMuMyAxLjZ6IiBmaWxsPSIjN2ZiYmRkIi8+PHBhdGggZD0iTTEyLjQgMTUuNWMtLjctLjUtMi40LS44LTQuNC0uNC0yIC40LTQgMS4zLTQuOCAxLjgtLjUuMy0xLjIgMS0xLjIgMS40IDAgLjcuMyAxLjguOCAyLjQuMy4zLjcuNSAxLjQuNi44IDAgMi41LTEuNCAzLjUtMiAxLS42IDEuNi0uOCAyLjctMS4ybC0yLjkgMi40Yy0xLjMgMS4yLTIuMiAxLjUtMi40IDIuMyAwIC41IDAgMS40LjUgMS44LjQuNS42LjggMS42LjguNiAwIDEgMCAyLjYtMS41LjktLjkgMi4zLTMgMi43LTMuNy42LTEuMSAxLTIuMi43LTMtLjItMS0uNC0xLjQtLjgtMS43ek0xNy40IDE0LjJjLS4zLS41LS45LTEuMi0uMi0yLjVsMS45LTNjLjUtLjggMi0yLjMgMi42LTIuNi42LS40IDEuNS0uNiAyLS4yLjYuNCAxIDEgMS4zIDEuNS40LjYuNyAxLjMuMiAyLS43IDEtMS42LjktMi44IDEuNy0xLjIuOC0xLjkgMS4yLTIuNSAxLjlsMy44LTEuOGMxLjMtLjYgMi43LTEuMSAzLjQtLjcuOC41LjguNyAxIDEuNC4zIDEtLjIgMS45LS44IDIuNC0uNS42LTEuNS45LTIuNiAxLjItMS40LjQtNC41IDEtNS44LjUtMS4zLS41LTEuMy0xLjQtMS41LTEuOHoiIGZpbGw9IiNmZmYiLz48cGF0aCBkPSJNMTIuNyAxNC44cy00LTEuOC0xMiAyLjdjMCAwIDEgMy43IDIuNSA1LjMgMS40IDEuNSAyLjMgMy42IDQuNiA0LjYgMCAwIDQuNy0zIDYuOS05LjJsMy0yczQuNyAyLjggMTIuNi0xLjZjMCAwLS42LTMuMy0zLTYtMi42LTMtMy44LTQuNy0zLjgtNC43cy00LjEgMi4zLTcuNSA5LjNsLTMuMyAxLjZ6IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iLjUiLz48cGF0aCBkPSJNMTIuNCAxNC45czIuMS0yIDMtMmMxLjEgMCAyLjMgMi43IDIuMyAzLjUgMCAuOC0yLjEgMi40LTMuMSAyLjMgMCAwIDAtMS4yLS43LTIuNi0uOC0xLjMtMS41LTEuMi0xLjUtMS4yeiIgZmlsbD0iIzdmYmJkZCIvPjxwYXRoIGQ9Ik0xMy44IDE1LjNjLjkuOC42IDIgMS40IDEuOCAxLS4yIDEuNC0uOCAxLjMtMS41IDAtLjcgMC0uOC0uNC0xLjYtLjMtLjctMS0xLjEtMi0uNS0uNy41LTEuNCAxLjMtMS40IDEuM3MuMi0uMyAxLjEuNXoiIGZpbGw9IiNmZmYiLz48cGF0aCBkPSJNMTIuNCAxNC45czIuMS0yIDMtMmMxLjEgMCAyLjMgMi43IDIuMyAzLjUgMCAuOC0yLjEgMi40LTMuMSAyLjMgMCAwIDAtMS4yLS43LTIuNi0uOC0xLjMtMS41LTEuMi0xLjUtMS4yeiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwIiBzdHJva2Utd2lkdGg9Ii41Ii8+PC9zdmc+",C2={name:"@genome-spy/app",description:"GenomeSpy-based visualization tool for multiple patient samples",author:{name:"Kari Lavikka",email:"kari.lavikka@helsinki.fi"},contributors:[],license:"MIT",version:"0.28.5",main:"dist/index.js",files:["dist/"],repository:{type:"git",url:"github:genome-spy/genome-spy",directory:"packages/app"},scripts:{dev:"node dev-server.js",build:"vite build",prepublishOnly:"npm run build"},dependencies:{"@floating-ui/dom":"^0.5.0","@fortawesome/fontawesome-free":"^6.1.1","@fortawesome/fontawesome-svg-core":"^6.1.1","@fortawesome/free-solid-svg-icons":"^6.1.1","@genome-spy/core":"^0.28.3","@reduxjs/toolkit":"^1.8.4",idb:"^7.0.1",lit:"^2.4.0","lz-string":"^1.4.4",mapsort:"^1.0.5","redux-batched-actions":"^0.5.0","redux-undo":"^1.0.1",snarkdown:"^2.0.0"},gitHead:"8292aa33b1923caf834b25db516e194f9d111bb8"};/**
|
2167
2167
|
* @license
|
2168
2168
|
* Copyright 2020 Google LLC
|
2169
2169
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -2176,4 +2176,4 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
|
|
2176
2176
|
* Copyright 2017 Google LLC
|
2177
2177
|
* SPDX-License-Identifier: BSD-3-Clause
|
2178
2178
|
*/const M2=t=>!f9(t)&&typeof t.then=="function";class qk extends v2{constructor(){super(...arguments),this._$Cwt=1073741823,this._$Cyt=[],this._$CK=new Xk(this),this._$CX=new Zk}render(...e){var n;return(n=e.find(r=>!M2(r)))!==null&&n!==void 0?n:Ae}update(e,n){const r=this._$Cyt;let i=r.length;this._$Cyt=n;const o=this._$CK,a=this._$CX;this.isConnected||this.disconnected();for(let s=0;s<n.length&&!(s>this._$Cwt);s++){const c=n[s];if(!M2(c))return this._$Cwt=s,c;s<i&&c===r[s]||(this._$Cwt=1073741823,i=0,Promise.resolve(c).then(async u=>{for(;a.get();)await a.get();const f=o.deref();if(f!==void 0){const l=f._$Cyt.indexOf(c);l>-1&&l<f._$Cwt&&(f._$Cwt=l,f.setValue(u))}}))}return Ae}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const Kk=or(qk);var Jk={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function T2(t){return t.replace(RegExp("^"+(t.match(/^(\t| )+/)||"")[0],"gm"),"")}function jo(t){return(t+"").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Dd(t,e){var n,r,i,o,a,s=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,c=[],u="",f=e||{},l=0;function d(h){var m=Jk[h[1]||""],g=c[c.length-1]==h;return m?m[1]?(g?c.pop():c.push(h),m[0|g]):m[0]:h}function p(){for(var h="";c.length;)h+=d(c[c.length-1]);return h}for(t=t.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(h,m,g){return f[m.toLowerCase()]=g,""}).replace(/^\n+|\n+$/g,"");i=s.exec(t);)r=t.substring(l,i.index),l=s.lastIndex,n=i[0],r.match(/[^\\](\\\\)*\\$/)||((a=i[3]||i[4])?n='<pre class="code '+(i[4]?"poetry":i[2].toLowerCase())+'"><code'+(i[2]?' class="language-'+i[2].toLowerCase()+'"':"")+">"+T2(jo(a).replace(/^\n+|\n+$/g,""))+"</code></pre>":(a=i[6])?(a.match(/\./)&&(i[5]=i[5].replace(/^\d+/gm,"")),o=Dd(T2(i[5].replace(/^\s*[>*+.-]/gm,""))),a==">"?a="blockquote":(a=a.match(/\./)?"ol":"ul",o=o.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),n="<"+a+">"+o+"</"+a+">"):i[8]?n='<img src="'+jo(i[8])+'" alt="'+jo(i[7])+'">':i[10]?(u=u.replace("<a>",'<a href="'+jo(i[11]||f[r.toLowerCase()])+'">'),n=p()+"</a>"):i[9]?n="<a>":i[12]||i[14]?n="<"+(a="h"+(i[14]?i[14].length:i[13]>"="?1:2))+">"+Dd(i[12]||i[15],f)+"</"+a+">":i[16]?n="<code>"+jo(i[16])+"</code>":(i[17]||i[1])&&(n=d(i[17]||"--"))),u+=r,u+=n;return(u+t.substring(l)+p()).replace(/^\n+|\n+$/g,"")}function I2(t,e){return!e||/^(data:|([A-Za-z]+:)?\/\/)/.test(t)||t.startsWith("/")?t:(e.endsWith("/")||(e+="/"),e+t)}function $k(t,e={}){const n=Dd(t),r=new DOMParser().parseFromString(`<!DOCTYPE html><html><body><div>${n}</div></body></html>`,"text/html");r.normalize(),k2(r.body);for(const o of r.querySelectorAll("a[href]"))o.setAttribute("target","blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("href",I2(o.getAttribute("href"),e.baseUrl));for(const o of r.querySelectorAll("img[src]"))o.setAttribute("src",I2(o.getAttribute("src"),e.baseUrl));const i=r.body.removeChild(r.querySelector("body > div"));return i.className="snarkdown",i}function k2(t){if(t.nodeType!==3){if(t.nodeType!==1||/^(script|iframe|object|embed|svg)$/i.test(t.tagName))return t.remove();for(let e=t.attributes.length;e--;){const n=t.attributes[e].name;/^(class|id|name|href|src|alt|align|valign|(on[a-z]+))$/i.test(n)||t.attributes.removeNamedItem(n)}for(let e=t.childNodes.length;e--;)k2(t.childNodes[e])}}function eN(t){t.stopPropagation(),t.preventDefault();const n=t.target.parentElement,r=n.parentElement,o=r.parentElement.querySelector(".panes"),a=[...r.children].findIndex(s=>s==n);for(const s of r.children)s.classList.remove("active-tab");for(const s of o.children)s.classList.remove("active-tab");r.children.item(a).classList.add("active-tab"),o.children.item(a).classList.add("active-tab")}var rc={},tN={get exports(){return rc},set exports(t){rc=t}};(function(t){var e=function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",o={};function a(c,u){if(!o[c]){o[c]={};for(var f=0;f<c.length;f++)o[c][c.charAt(f)]=f}return o[c][u]}var s={compressToBase64:function(c){if(c==null)return"";var u=s._compress(c,6,function(f){return r.charAt(f)});switch(u.length%4){default:case 0:return u;case 1:return u+"===";case 2:return u+"==";case 3:return u+"="}},decompressFromBase64:function(c){return c==null?"":c==""?null:s._decompress(c.length,32,function(u){return a(r,c.charAt(u))})},compressToUTF16:function(c){return c==null?"":s._compress(c,15,function(u){return n(u+32)})+" "},decompressFromUTF16:function(c){return c==null?"":c==""?null:s._decompress(c.length,16384,function(u){return c.charCodeAt(u)-32})},compressToUint8Array:function(c){for(var u=s.compress(c),f=new Uint8Array(u.length*2),l=0,d=u.length;l<d;l++){var p=u.charCodeAt(l);f[l*2]=p>>>8,f[l*2+1]=p%256}return f},decompressFromUint8Array:function(c){if(c==null)return s.decompress(c);for(var u=new Array(c.length/2),f=0,l=u.length;f<l;f++)u[f]=c[f*2]*256+c[f*2+1];var d=[];return u.forEach(function(p){d.push(n(p))}),s.decompress(d.join(""))},compressToEncodedURIComponent:function(c){return c==null?"":s._compress(c,6,function(u){return i.charAt(u)})},decompressFromEncodedURIComponent:function(c){return c==null?"":c==""?null:(c=c.replace(/ /g,"+"),s._decompress(c.length,32,function(u){return a(i,c.charAt(u))}))},compress:function(c){return s._compress(c,16,function(u){return n(u)})},_compress:function(c,u,f){if(c==null)return"";var l,d,p={},h={},m="",g="",y="",b=2,x=3,C=2,w=[],v=0,A=0,D;for(D=0;D<c.length;D+=1)if(m=c.charAt(D),Object.prototype.hasOwnProperty.call(p,m)||(p[m]=x++,h[m]=!0),g=y+m,Object.prototype.hasOwnProperty.call(p,g))y=g;else{if(Object.prototype.hasOwnProperty.call(h,y)){if(y.charCodeAt(0)<256){for(l=0;l<C;l++)v=v<<1,A==u-1?(A=0,w.push(f(v)),v=0):A++;for(d=y.charCodeAt(0),l=0;l<8;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1}else{for(d=1,l=0;l<C;l++)v=v<<1|d,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=0;for(d=y.charCodeAt(0),l=0;l<16;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1}b--,b==0&&(b=Math.pow(2,C),C++),delete h[y]}else for(d=p[y],l=0;l<C;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1;b--,b==0&&(b=Math.pow(2,C),C++),p[g]=x++,y=String(m)}if(y!==""){if(Object.prototype.hasOwnProperty.call(h,y)){if(y.charCodeAt(0)<256){for(l=0;l<C;l++)v=v<<1,A==u-1?(A=0,w.push(f(v)),v=0):A++;for(d=y.charCodeAt(0),l=0;l<8;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1}else{for(d=1,l=0;l<C;l++)v=v<<1|d,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=0;for(d=y.charCodeAt(0),l=0;l<16;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1}b--,b==0&&(b=Math.pow(2,C),C++),delete h[y]}else for(d=p[y],l=0;l<C;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1;b--,b==0&&(b=Math.pow(2,C),C++)}for(d=2,l=0;l<C;l++)v=v<<1|d&1,A==u-1?(A=0,w.push(f(v)),v=0):A++,d=d>>1;for(;;)if(v=v<<1,A==u-1){w.push(f(v));break}else A++;return w.join("")},decompress:function(c){return c==null?"":c==""?null:s._decompress(c.length,32768,function(u){return c.charCodeAt(u)})},_decompress:function(c,u,f){var l=[],d=4,p=4,h=3,m="",g=[],y,b,x,C,w,v,A,D={val:f(0),position:u,index:1};for(y=0;y<3;y+=1)l[y]=y;for(x=0,w=Math.pow(2,2),v=1;v!=w;)C=D.val&D.position,D.position>>=1,D.position==0&&(D.position=u,D.val=f(D.index++)),x|=(C>0?1:0)*v,v<<=1;switch(x){case 0:for(x=0,w=Math.pow(2,8),v=1;v!=w;)C=D.val&D.position,D.position>>=1,D.position==0&&(D.position=u,D.val=f(D.index++)),x|=(C>0?1:0)*v,v<<=1;A=n(x);break;case 1:for(x=0,w=Math.pow(2,16),v=1;v!=w;)C=D.val&D.position,D.position>>=1,D.position==0&&(D.position=u,D.val=f(D.index++)),x|=(C>0?1:0)*v,v<<=1;A=n(x);break;case 2:return""}for(l[3]=A,b=A,g.push(A);;){if(D.index>c)return"";for(x=0,w=Math.pow(2,h),v=1;v!=w;)C=D.val&D.position,D.position>>=1,D.position==0&&(D.position=u,D.val=f(D.index++)),x|=(C>0?1:0)*v,v<<=1;switch(A=x){case 0:for(x=0,w=Math.pow(2,8),v=1;v!=w;)C=D.val&D.position,D.position>>=1,D.position==0&&(D.position=u,D.val=f(D.index++)),x|=(C>0?1:0)*v,v<<=1;l[p++]=n(x),A=p-1,d--;break;case 1:for(x=0,w=Math.pow(2,16),v=1;v!=w;)C=D.val&D.position,D.position>>=1,D.position==0&&(D.position=u,D.val=f(D.index++)),x|=(C>0?1:0)*v,v<<=1;l[p++]=n(x),A=p-1,d--;break;case 2:return g.join("")}if(d==0&&(d=Math.pow(2,h),h++),l[A])m=l[A];else if(A===p)m=b+b.charAt(0);else return null;g.push(m),l[p++]=b+m.charAt(0),d--,b=m,d==0&&(d=Math.pow(2,h),h++)}}};return s}();t!=null&&(t.exports=e)})(tN);function nN(){const t=typeof process<"u"?require("util").TextEncoder:TextEncoder;return new t}let N2;function rN(){let t,e=[];for(let n=0;n<256;n++){t=n;for(let r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e}function iN(t){N2??(N2=rN());let e=-1;const n=nN().encode(t);for(let r=0;r<n.length;r++)e=e>>>8^N2[(e^n[r])&255];return(e^-1)>>>0}function L2(t){return("00000000"+iN(t).toString(16)).slice(-8)}function B2(t){const e=rc.compressToEncodedURIComponent(JSON.stringify(t));return"#"+e+L2(e)}function oN(t){if(!t||t.length<10)throw new Error("The state string in the URL is too short.");const e=t.slice(1,-8),n=t.slice(-8);if(L2(e)!==n)throw new Error("The state string in the URL is corrupted.");return JSON.parse(rc.decompressFromEncodedURIComponent(e))}let vr;function aN(t){for(const e of t.genomeSpy.getNamedScaleResolutions().values())e.isZoomable()&&e.resetZoom();t.storeHelper.dispatch([...t.provenance.isUndoable()?[Ht.ActionCreators.jumpToPast(0)]:[],si.actions.restoreDefaultVisibilities()])}async function Md(t,e){try{t.actions&&e.provenance.dispatchBookmark(t.actions),e.storeHelper.dispatch(si.actions.setViewSettings(t.viewSettings));const n=[];for(const[r,i]of Object.entries(t.scaleDomains??{})){const o=e.genomeSpy.getNamedScaleResolutions().get(r);o?n.push(o.zoomTo(i)):console.warn(`Cannot restore scale domain. Unknown name: ${r}`)}await Promise.all(n)}catch(n){console.error(n),He(E`<p>Cannot restore the state:</p><p>${n}</p>`),e.provenance.activateState(0)}}async function Uo(t,e,n={}){await Md(t,e),(vr||t.notes||n.mode=="shared"&&(t.name||t.notes))&&await sN(t,e,n)}async function sN(t,e,n={}){vr??(vr=fr("tour",e.appContainer)),await cN(t,e,n)}async function cN(t,e,n){const r=n.database,i=r?await r.getNames():[],o=i.indexOf(t.name),a=r?` ${o+1} of ${i.length}`:"",s=`${n.mode=="shared"?"Shared bookmark":"Bookmark"}${a}: ${t.name??"Unnamed"}`,c=t.notes?$k(t.notes,{baseUrl:e.genomeSpy.spec.baseUrl}):E`<span class="no-notes">No notes provided</span>`,u=async()=>{if(vr==null||vr.close(),vr=void 0,n.mode=="tour"){const m=n.afterTourBookmark;if(typeof m=="string"){const g=await n.database.get(m);if(!g)throw new Error(`No such bookmark: ${m}`);Md(g,e)}else m===null||aN(e)}},f=async m=>{const g=await r.get(i[m]);Uo(g,e,n),e.appContainer.querySelector("canvas").focus()},l=async()=>{if(await Td(e.localBookmarkDatabase,t,"add"))try{await e.localBookmarkDatabase.put(t)}catch(m){console.warn(m),He(`Cannot import bookmark: ${m}`)}},d=E`<button class="btn" @click="${u}">${n.mode=="tour"?"End tour":"Close"}</button> ${n.mode=="shared"&&e.localBookmarkDatabase?E`<button class="btn" @click="${l}">${K(F1).node[0]} Import bookmark</button>`:z} ${r?E`<button class="btn" @click="${()=>f(o-1)}" ?disabled="${o<=0}">${K(s6).node[0]} Previous</button> <button class="btn" @click="${()=>f(o+1)}" ?disabled="${o>=i.length-1}">Next ${K(A6).node[0]}</button>`:z}`,h=E`<button title="Collapse" class="btn collapse" @click="${m=>m.target.closest(".gs-modal").classList.toggle("collapsed")}">${K(u6).node[0]}</button><div class="modal-title">${s}</div><div class="modal-body markdown" style="max-width:600px">${c}</div><div class="modal-buttons">${d}</div>`;Le(h,vr.content)}function O2(t,e){const n=JSON.stringify(t,void 0,2),r=window.location,i=r.origin+r.pathname+r.search+(e?"#bookmark:"+t.name.replaceAll(" ","-"):B2(t));He(E`<div class="gs-tabs" style="width:600px"><ul class="tabs" @click="${eN}"><li class="active-tab"><button>URL</button></li><li><button>JSON</button></li></ul><div class="panes"><div class="gs-form-group active-tab"><label for="bookmark-url">Here's a link for you:</label><div class="copy-url"><input id="bookmark-url" type="text" .value="${i}"> <button @click="${a=>navigator.clipboard.writeText(i).then(()=>a.target.dispatchEvent(m9())).catch(()=>He("Failed to copy!"))}">Copy</button></div><small>The bookmark URL contains all the bookmarked data, including the possible notes, which will be shown when the link is opened.</small></div><div class="gs-form-group"><textarea id="bookmark-json" style="height:250px">
|
2179
|
-
${n}</textarea> <small>The JSON-formatted bookmark is currently available for development purposes.</small></div></div></div>`,{title:"Share a bookmark",okLabel:"Close"})}function Td(t,e,n){const r={add:"Add bookmark",edit:"Edit bookmark",share:"Share the current view state as a bookmark"}[n],i=(c,u)=>E`<div class="modal-title">${r}</div><div class="modal-body" style="width:500px">${n=="edit"?E`<div class="gs-alert warning">${K(f6).node[0]} The current visualization state will be updated to the bookmark you are editing.</div>`:z} ${n=="share"?E`<div class="gs-alert info">${K(z1).node[0]} <span>You can add an optional title and notes, which will be shown to the recipient when the bookmark link is opened.</span></div>`:z}<div class="gs-form-group"><label for="bookmark-title">Title</label> <input id="bookmark-title" type="text" ?required="${n=="add"||n=="edit"}" .value="${e.name??""}" .placeholder="${n=="share"?"Add an optional title":""}" @change="${f=>{e.name=F2(f.target.value)}}"></div><div class="gs-form-group"><label for="bookmark-notes">Notes</label> <textarea id="bookmark-notes" rows="4" .value="${e.notes??""}" .placeholder="${n=="share"?"... and notes":""}" @change="${f=>{e.notes=F2(f.target.value)}}"></textarea> <small>Notes will be shown when the bookmark is loaded. You can use <a href="https://www.markdownguide.org/basic-syntax/">markdown</a> for formatting.</small></div></div><div class="modal-buttons"><button class="btn btn-cancel" @click="${c}">Cancel</button> <button class="btn btn-primary" @click="${u}">${n=="share"?E`${K(rf).node[0]} Create a link`:"Save"}</button></div>`,o=e.name,a=()=>!!e.name,s=fr();return new Promise(c=>{const u=()=>{s.close(),c(!1)},f=async()=>{if(!a()){He("Name is missing!",{title:"Error"});return}let d=!0;t&&!(n&&e.name==o)&&await t.get(e.name)&&(d=await He(E`A bookmark with the name <em>${e.name}</em> already exists. It will be overwritten.`,{title:"Bookmark already exists",cancelButton:!0})),d&&(s.close(),c(!0))},l=()=>{s.close(),c(!0)};Le(i(u,n=="share"?l:f),s.content),s.content.querySelector("#bookmark-title").focus()})}function F2(t){if(t!==void 0&&(t=t.trim(),t.length))return t}class uN extends yt{constructor(){super(),this.app=void 0}connectedCallback(){super.connectedCallback(),this.dispatchEvent(S2("app",e=>{this.app=e}))}createRenderRoot(){return this}_createBookmarkWithCurrentState(){const e={name:void 0,timestamp:Date.now(),actions:this.app.provenance.getBookmarkableActionHistory(),scaleDomains:{}},n=this.app.storeHelper.state.viewSettings;Object.keys(n.visibilities).length&&(e.viewSettings=n);for(const[r,i]of this.app.genomeSpy.getNamedScaleResolutions().entries())i.isZoomable()&&(e.scaleDomains[r]=i.getComplexDomain());return e}async _shareCurrentState(){const e=this._createBookmarkWithCurrentState();await Td(void 0,e,"share")&&O2(e,!1)}async _addBookmark(e,n){const r=n?await e.get(n):void 0,i=!!r,o=this._createBookmarkWithCurrentState();if(o.name??(o.name=r==null?void 0:r.name),o.notes??(o.notes=r==null?void 0:r.notes),await Td(e,o,i?"edit":"add"))try{await e.put(o,r==null?void 0:r.name),this.requestUpdate()}catch(a){He(`${a}`,{title:"Cannot save the bookmark!"})}}async _loadBookmark(e,n){const r=await e.get(n);r&&Uo(r,this.app,{database:e})}_createContextMenu(e,n,r){r.stopPropagation();const i=r.target.closest("li"),o=()=>He(E`The bookmark <em>${n}</em> will be deleted.`,{title:"Are you sure?",cancelButton:!0}).then(async c=>{c&&(await e.delete(n),this.requestUpdate())}),a=[],s=e==this.app.globalBookmarkDatabase;s||(a.push({label:"Edit and replace...",icon:C6,callback:()=>this._addBookmark(e,n)}),a.push({label:"Delete",icon:j1,callback:o})),a.push({label:"Share...",icon:rf,callback:async()=>O2(await e.get(n),s)}),r2({items:a},i,"right-start")}async _makeBookmarkMenuItems(e,n){const i=(await e.getNames()).map(o=>({label:o,callback:()=>this._loadBookmark(e,o),ellipsisCallback:a=>this._createContextMenu(e,o,a)}));return i.length?[{type:"divider"},{label:n,type:"header"},...i].map(o=>t2(o)):z}_getBookmarks(){const e=(n,r)=>n?Kk(this._makeBookmarkMenuItems(n,r),E`Loading...`):z;return[e(this.app.globalBookmarkDatabase,"Bookmarks on the server"),e(this.app.localBookmarkDatabase,"Bookmarks in the web browser")]}render(){const e=this.app.localBookmarkDatabase,n=e?E`<li><a @click="${()=>this._addBookmark(e)}">Add bookmark...</a></li>`:z,r=e||this.app.globalBookmarkDatabase?E`<div class="dropdown bookmark-dropdown"><button class="tool-btn" title="Bookmarks" @click="${i=>{Sd(i)&&this.requestUpdate()}}">${K(F1).node[0]}</button><ul class="gs-dropdown-menu">${n} ${this._getBookmarks()}</ul></div>`:z;return E`<div class="btn-group">${r} <button class="tool-btn" title="Share" @click="${()=>this._shareCurrentState()}">${K(rf).node[0]}</button></div>`}}customElements.define("genome-spy-bookmark-button",uN);class lN extends yt{constructor(){super(),this.app=void 0,this.appInitialized=!1}static get properties(){return{app:{type:Object},appInitialized:{type:Boolean}}}createRenderRoot(){return this}_getToolButtons(){const e=this.app.provenance,n=[];e.isEnabled()&&n.push(E`<genome-spy-provenance-buttons .provenance="${e}"></genome-spy-provenance-buttons>`),n.push(E`<genome-spy-view-visibility></genome-spy-view-visibility>`),n.push(E`<genome-spy-bookmark-button></genome-spy-bookmark-button>`);const r=this.app.config.description?Ze(this.app.config.description):[];return r.length>1&&n.push(E`<button class="tool-btn" title="Show a description of the visualization" @click="${()=>He(E`${r.slice(1).map(i=>E`<p>${i}</p>`)}`,{title:r[0]})}">${K(z1).node[0]}</button>`),r.length>0&&n.push(E`<span class="vis-title">${r[0]}</span>`),n.push(E`<span class="spacer"></span> <a class="version" href="https://github.com/genome-spy/genome-spy/releases/tag/v${C2.version}">v${C2.version}</a> ${this.app.appContainer.requestFullscreen?E`<button class="tool-btn" title="Fullscreen" @click="${()=>this.app.toggleFullScreen()}">${K(w6).node[0]}</button>`:z} <button class="tool-btn" title="Help" @click="${()=>window.open("https://genomespy.app/docs/","_blank")}">${K(p6).node[0]}</button>`),n}render(){const e=this.app.genomeSpy;return E`<nav class="gs-toolbar"><a href="https://genomespy.app" target="_blank" class="logo"><img title="GenomeSpy" alt="GenomeSpy" src="${w2}"> </a>${this.appInitialized&&x2(e.viewRoot)?E`<genome-spy-search-field .app="${this.app}"></genome-spy-search-field>`:z} ${this._getToolButtons()}</nav>`}}customElements.define("genome-spy-toolbar",lN);class fN{constructor(e){this.storeHelper=e,this._reducers={},this.actionInfoSources=[],this._reducer=void 0,e.addReducer("provenance",(n,r)=>this._reducer?this._reducer(n,r):n??{})}addReducer(e,n){this._reducers[e]=n;const r=o=>Object.keys(this._reducers).some(a=>o.type.startsWith(a)),i=(o,a)=>r(a)?a:o??null;this._reducer=XI(qf({...this._reducers,lastAction:i}),{ignoreInitialState:!0,filter:r}),this.storeHelper.dispatch({type:"@@redux/REPLACE"+Math.random().toString(36).substring(7).split("").join(".")})}get _storeState(){return this.storeHelper.store.getState()}get _provenanceState(){return this._storeState.provenance}isEnabled(){return!!this.getPresentState()}getPresentState(){return this._provenanceState.present}addActionInfoSource(e){this.actionInfoSources.push(e)}getActionInfo(e){for(const n of this.actionInfoSources){const r=n(e);if(r)return r}}dispatchBookmark(e){this.storeHelper.dispatch([...this.isUndoable()?[Ht.ActionCreators.jumpToPast(0)]:[],...e])}isRedoable(){return this.isEnabled()&&this._provenanceState.future.length>0}redo(){this.storeHelper.dispatch(Ht.ActionCreators.redo())}isUndoable(){return this.isEnabled()&&this._provenanceState.past.length>0}undo(){this.storeHelper.dispatch(Ht.ActionCreators.undo())}isAtInitialState(){return!this.isUndoable()}isEmpty(){const e=this._provenanceState;return!this.isEnabled()||e.past.length+e.future.length<=0}activateState(e){const n=this.getCurrentIndex();e<n?this.storeHelper.dispatch(Ht.ActionCreators.jumpToPast(e)):e>n&&this.storeHelper.dispatch(Ht.ActionCreators.jumpToFuture(e-n-1))}getCurrentIndex(){var e;return(e=this._provenanceState.past)==null?void 0:e.length}getActionHistory(){const e=this._provenanceState;return e.present&&[...e.past,e.present].map(n=>n.lastAction)}getFullActionHistory(){const e=this._provenanceState;return[...e.past,e.present,...e.future].map(n=>n.lastAction)}getBookmarkableActionHistory(){var e;return(e=this.getActionHistory())==null?void 0:e.slice(1)}}function*dN(t,e=n=>+n){const n=t.length,r=new Ao,i=new Array(n).fill(0);for(const[a,s]of t.entries())s.length&&r.push(a,e(s[0]));let o=0;for(;(o=r.pop())!==void 0;){const a=t[o];let s=i[o];if(yield a[s++],s<a.length){const u=e(a[s]);r.push(o,u),i[o]=s}}}const hN="sampleCount";class pN extends ue{constructor(e,n){super(),this.view=n;const r=n.context.animator;for(const i of n.getAncestors())i instanceof md&&(this.provenance=i.provenance,this.provenance.storeHelper.subscribe(o=>r.requestTransition(()=>{this.reset(),this._mergeAndPropagate(td(o)),this.complete()})));if(!this.provenance)throw new Error("No SampleView was found!");this.contextObject=void 0}initialize(){this.contextObject=Object.create(super.getGlobalObject());const e=this.view.getEncoding().x;if(Xn(e))this.xAccessor=q(e.field);else throw new Error("Crash!")}handle(e){}getGlobalObject(){return this.contextObject}_getCollector(){if(this.parent instanceof Xr)return this.parent;throw new Error("MergeFacetsTransform must be a direct child of a Collector")}complete(){this._mergeAndPropagate(this.provenance.getPresentState()[ii]),super.complete()}_mergeAndPropagate(e){const n=[...rd(e.rootGroup)].filter(r=>Tv(Re(r)));for(const[r,i]of n.entries()){const o=Re(i);if(Tv(o)){this.contextObject[hN]=o.samples.length,this.beginBatch({type:"facet",facetId:[r]});const a=o.samples,s=this._getCollector(),c=dN(a.map(u=>s.facetBatches.get([u])??[]),this.xAccessor);for(const u of c)this._propagate(u)}}this._updateScales()}setParent(e){super.setParent(e)}_updateScales(){const e=new Set;this.view.visit(n=>{if(n instanceof be&&n.mark.encoding.y){const r=n.getScaleResolution("y");r&&e.add(r)}});for(const n of e)n.reconfigure()}}var mN="BATCHING_REDUCER.BATCH";function gN(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mN;return{type:e,meta:{batch:!0},payload:t}}function yN(t){return function e(n,r){return r&&r.meta&&r.meta.batch?r.payload.reduce(e,n):t(n,r)}}class vN{constructor(e){this._reducers=e??{},this.store=rI({reducer:{}}),this._listeners=new Set,this.store.subscribe(()=>{const n=this.store.getState();for(const r of this._listeners)r(n)})}get state(){return this.store.getState()}addReducer(e,n){this._reducers[e]=n,this.store.replaceReducer(yN(qf(this._reducers)))}subscribe(e){this._listeners.add(e)}unsubscribe(e){this._listeners.delete(e)}dispatch(e){Array.isArray(e)?this.store.dispatch(gN(e)):this.store.dispatch(e)}getDispatcher(){return e=>this.dispatch(e)}}class bN extends g2{constructor(e){super(),this.bookmarks=e,this.names=e.map(n=>n.name)}async getNames(){return this.names}async get(e){return this.bookmarks.find(n=>n.name==e)}}f1.mergeFacets=pN;class P2{constructor(e,n,r={}){const i=this;this.config=n,this.storeHelper=new vN,this.storeHelper.addReducer("viewSettings",si.reducer),this.provenance=new fN(this.storeHelper),this._initializationListeners=[],this.toolbarRef=b2(),this.appContainer=e,this._configureContainer(),this.localBookmarkDatabase=typeof n.specId=="string"?new Fk(n.specId):void 0,this.globalBookmarkDatabase=void 0,Le(E`<div class="genome-spy-app"><genome-spy-toolbar ${A2(i.toolbarRef)} .app="${i}"></genome-spy-toolbar><div class="genome-spy-container"></div></div>`,i.appContainer),i.appContainer.querySelector(".genome-spy-app").addEventListener("query-dependency",s=>{s.detail.name=="app"&&(s.detail.setter(i),s.stopPropagation())});const o=s=>this.appContainer.getElementsByClassName(s)[0];this.genomeSpy=new M1(o("genome-spy-container"),this.config,r),this.genomeSpy.viewFactory.addViewType(Ck,(s,c,u,f)=>new md(s,c,u,f,this.provenance));const a=this.genomeSpy.viewVisibilityPredicate;this.genomeSpy.viewVisibilityPredicate=s=>{var c;return((c=this.storeHelper.state.viewSettings)==null?void 0:c.visibilities[s.name])??a(s)}}addInitializationListener(e){this._initializationListeners?this._initializationListeners.push(e):e()}toggleFullScreen(){document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():this.appContainer.requestFullscreen()}isFullPage(){return this.appContainer==document.body}async launch(){var a;const e=(a=this.config.bookmarks)!=null&&a.remote?Li({baseURL:this.config.baseUrl}).load(this.config.bookmarks.remote.url).then(s=>Promise.resolve(JSON.parse(s))):Promise.resolve([]);if(!await this.genomeSpy.launch())return;this.appContainer.querySelector("canvas").setAttribute("tabindex","-1"),this.storeHelper.subscribe(tc(s=>{var c;return(c=s.viewSettings)==null?void 0:c.visibilities},(s,c)=>{var f,l;this.genomeSpy.viewRoot._invalidateCacheByPrefix("size","progeny"),(l=(f=this.getSampleView())==null?void 0:f.summaryViews)==null||l._invalidateCacheByPrefix("size","self");const u=this.genomeSpy.viewRoot.context;u.requestLayoutReflow(),u.animator.requestRender()},this.storeHelper.store.getState()));try{const s=await e;s.length&&(this.globalBookmarkDatabase=new bN(s))}catch(s){throw new Error(`Cannot load remote bookmarks: ${s}`)}try{await this._restoreStateFromUrlOrBookmark()}catch(s){He(s.toString())}this.storeHelper.subscribe(()=>{this._updateStateToUrl()}),window.addEventListener("hashchange",()=>this._restoreStateFromUrl().catch(s=>He(s.toString())),!1);const r=xs(()=>this._updateStateToUrl(),500,!1);for(const[,s]of this.genomeSpy.getNamedScaleResolutions())s.isZoomable()&&s.addEventListener("domain",r);const i=this.toolbarRef.value;i.appInitialized=!0;const o=Ze(this.genomeSpy.spec.description??[]);this.isFullPage()&&o.length>0&&(document.title="GenomeSpy - "+o);for(const s of this._initializationListeners)s();this._initializationListeners=void 0}async _restoreStateFromUrlOrBookmark(){var i;const e=(i=this.config.bookmarks)==null?void 0:i.remote,n=this.globalBookmarkDatabase;if(!await this._restoreStateFromUrl()&&e&&n){const o=e.initialBookmark??(e.tour&&(await n.getNames())[0]);if(o){const a=await n.get(o);if(!a)throw new Error(`No such bookmark: ${o}`);e.tour?await Uo(a,this,{mode:"tour",database:n,afterTourBookmark:e.afterTourBookmark}):await Md(a,this)}}}_updateStateToUrl(){const e={actions:[],scaleDomains:{}},n=this.provenance.getBookmarkableActionHistory();n!=null&&n.length&&(e.actions=n);for(const[o,a]of this.genomeSpy.getNamedScaleResolutions().entries())a.isZoomed()||(e.scaleDomains[o]=a.getComplexDomain());const r=this.storeHelper.state.viewSettings;Object.keys(r.visibilities).length&&(e.viewSettings=r);const i=e.actions.length||Object.keys(e.scaleDomains).length||e.viewSettings?B2(e):"";window.history.replaceState(void 0,document.title,window.location.pathname+window.location.search+i)}async _restoreStateFromUrl(){var r,i;const e=window.location.hash,n=(r=e.match(/^#bookmark:(.+)$/))==null?void 0:r[1];if(n){const o=(i=this.config.bookmarks)==null?void 0:i.remote,a=this.globalBookmarkDatabase;if(o&&a){const s=(await a.getNames()).find(c=>c.replaceAll(" ","-")==n);if(s){const c=await a.get(s);if(!c)throw new Error(`No such bookmark: ${s}`);return await Uo(c,this,{mode:"tour",database:a}),!0}else throw new Error(`No such bookmark: ${n}`)}}if(e&&e.length>0)try{const o=oN(e);return Uo(o,this,{mode:"shared"}),!0}catch(o){console.error(o),He(E`<p>Cannot restore the state:</p><p>${o}</p>`)}return!1}_configureContainer(){this.isFullPage()?(this.appContainer.style.margin="0",this.appContainer.style.padding="0",this.appContainer.style.overflow="hidden",AN(X5)):this.appContainer.style.position="relative"}getSampleView(){var n;if(!((n=this.genomeSpy)!=null&&n.viewRoot))return;let e;return this.genomeSpy.viewRoot.visit(r=>{if(r instanceof md)return e=r,tr}),e}}function AN(t){const e=document.querySelector("head"),n=document.createElement("link");n.setAttribute("rel","shortcut icon"),n.setAttribute("href",t),e.appendChild(n)}async function xN(t,e,n={}){let r;if(ne(t)){if(r=document.querySelector(t),!r)throw new Error(`No such element: ${t}`)}else if(t instanceof HTMLElement)r=t;else throw new Error(`Invalid element: ${t}`);let i;try{const o=Pe(e)?e:await z2(e);o.baseUrl??(o.baseUrl=""),o.width??(o.width="container"),o.padding??(o.padding=10);const a=new P2(r,o,n);i=a.genomeSpy,wN(i,n),await a.launch()}catch(o){r.innerText=o.toString(),console.error(o)}return{finalize(){for(i.destroy();r.firstChild;)r.firstChild.remove()},addEventListener(o,a){const s=i._eventListeners;let c=s.get(o);c||(c=new Set,s.set(o,c)),c.add(a)},removeEventListener(o,a){var c;(c=i._eventListeners.get(o))==null||c.delete(a)},getScaleResolutionByName(o){return i.getNamedScaleResolutions().get(o)}}}function wN(t,e){e.namedDataProvider&&t.registerNamedDataProvider(e.namedDataProvider)}async function z2(t){let e;try{e=JSON.parse(await Li().load(t))}catch(n){throw new Error(`Could not load or parse configuration: ${t}, reason: ${n.message}`)}if(!e.baseUrl){const n=t.match(/^[^?#]*\//);e.baseUrl=n&&n[0]||"./"}return e}j.GenomeSpy=M1,j.GenomeSpyApp=P2,j.embed=xN,j.html=E,j.icon=w2,j.loadSpec=z2,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|
2179
|
+
${n}</textarea> <small>The JSON-formatted bookmark is currently available for development purposes.</small></div></div></div>`,{title:"Share a bookmark",okLabel:"Close"})}function Td(t,e,n){const r={add:"Add bookmark",edit:"Edit bookmark",share:"Share the current view state as a bookmark"}[n],i=(c,u)=>E`<div class="modal-title">${r}</div><div class="modal-body" style="width:500px">${n=="edit"?E`<div class="gs-alert warning">${K(f6).node[0]} The current visualization state will be updated to the bookmark you are editing.</div>`:z} ${n=="share"?E`<div class="gs-alert info">${K(z1).node[0]} <span>You can add an optional title and notes, which will be shown to the recipient when the bookmark link is opened.</span></div>`:z}<div class="gs-form-group"><label for="bookmark-title">Title</label> <input id="bookmark-title" type="text" ?required="${n=="add"||n=="edit"}" .value="${e.name??""}" .placeholder="${n=="share"?"Add an optional title":""}" @change="${f=>{e.name=F2(f.target.value)}}"></div><div class="gs-form-group"><label for="bookmark-notes">Notes</label> <textarea id="bookmark-notes" rows="4" .value="${e.notes??""}" .placeholder="${n=="share"?"... and notes":""}" @change="${f=>{e.notes=F2(f.target.value)}}"></textarea> <small>Notes will be shown when the bookmark is loaded. You can use <a href="https://www.markdownguide.org/basic-syntax/">markdown</a> for formatting.</small></div></div><div class="modal-buttons"><button class="btn btn-cancel" @click="${c}">Cancel</button> <button class="btn btn-primary" @click="${u}">${n=="share"?E`${K(rf).node[0]} Create a link`:"Save"}</button></div>`,o=e.name,a=()=>!!e.name,s=fr();return new Promise(c=>{const u=()=>{s.close(),c(!1)},f=async()=>{if(!a()){He("Name is missing!",{title:"Error"});return}let d=!0;t&&!(n&&e.name==o)&&await t.get(e.name)&&(d=await He(E`A bookmark with the name <em>${e.name}</em> already exists. It will be overwritten.`,{title:"Bookmark already exists",cancelButton:!0})),d&&(s.close(),c(!0))},l=()=>{s.close(),c(!0)};Le(i(u,n=="share"?l:f),s.content),s.content.querySelector("#bookmark-title").focus()})}function F2(t){if(t!==void 0&&(t=t.trim(),t.length))return t}class uN extends yt{constructor(){super(),this.app=void 0}connectedCallback(){super.connectedCallback(),this.dispatchEvent(S2("app",e=>{this.app=e}))}createRenderRoot(){return this}_createBookmarkWithCurrentState(){const e={name:void 0,timestamp:Date.now(),actions:this.app.provenance.getBookmarkableActionHistory(),scaleDomains:{}},n=this.app.storeHelper.state.viewSettings;Object.keys(n.visibilities).length&&(e.viewSettings=n);for(const[r,i]of this.app.genomeSpy.getNamedScaleResolutions().entries())i.isZoomable()&&(e.scaleDomains[r]=i.getComplexDomain());return e}async _shareCurrentState(){const e=this._createBookmarkWithCurrentState();await Td(void 0,e,"share")&&O2(e,!1)}async _addBookmark(e,n){const r=n?await e.get(n):void 0,i=!!r,o=this._createBookmarkWithCurrentState();if(o.name??(o.name=r==null?void 0:r.name),o.notes??(o.notes=r==null?void 0:r.notes),await Td(e,o,i?"edit":"add"))try{await e.put(o,r==null?void 0:r.name),this.requestUpdate()}catch(a){He(`${a}`,{title:"Cannot save the bookmark!"})}}async _loadBookmark(e,n){const r=await e.get(n);r&&Uo(r,this.app,{database:e})}_createContextMenu(e,n,r){r.stopPropagation();const i=r.target.closest("li"),o=()=>He(E`The bookmark <em>${n}</em> will be deleted.`,{title:"Are you sure?",cancelButton:!0}).then(async c=>{c&&(await e.delete(n),this.requestUpdate())}),a=[],s=e==this.app.globalBookmarkDatabase;s||(a.push({label:"Edit and replace...",icon:C6,callback:()=>this._addBookmark(e,n)}),a.push({label:"Delete",icon:j1,callback:o})),a.push({label:"Share...",icon:rf,callback:async()=>O2(await e.get(n),s)}),r2({items:a},i,"right-start")}async _makeBookmarkMenuItems(e,n){const i=(await e.getNames()).map(o=>({label:o,callback:()=>this._loadBookmark(e,o),ellipsisCallback:a=>this._createContextMenu(e,o,a)}));return i.length?[{type:"divider"},{label:n,type:"header"},...i].map(o=>t2(o)):z}_getBookmarks(){const e=(n,r)=>n?Kk(this._makeBookmarkMenuItems(n,r),E`Loading...`):z;return[e(this.app.globalBookmarkDatabase,"Bookmarks on the server"),e(this.app.localBookmarkDatabase,"Bookmarks in the web browser")]}render(){const e=this.app.localBookmarkDatabase,n=e?E`<li><a @click="${()=>this._addBookmark(e)}">Add bookmark...</a></li>`:z,r=e||this.app.globalBookmarkDatabase?E`<div class="dropdown bookmark-dropdown"><button class="tool-btn" title="Bookmarks" @click="${i=>{Sd(i)&&this.requestUpdate()}}">${K(F1).node[0]}</button><ul class="gs-dropdown-menu">${n} ${this._getBookmarks()}</ul></div>`:z;return E`<div class="btn-group">${r} <button class="tool-btn" title="Share" @click="${()=>this._shareCurrentState()}">${K(rf).node[0]}</button></div>`}}customElements.define("genome-spy-bookmark-button",uN);class lN extends yt{constructor(){super(),this.app=void 0,this.appInitialized=!1}static get properties(){return{app:{type:Object},appInitialized:{type:Boolean}}}createRenderRoot(){return this}_getToolButtons(){const e=this.app.provenance,n=[];e.isEnabled()&&n.push(E`<genome-spy-provenance-buttons .provenance="${e}"></genome-spy-provenance-buttons>`),n.push(E`<genome-spy-view-visibility></genome-spy-view-visibility>`),n.push(E`<genome-spy-bookmark-button></genome-spy-bookmark-button>`);const r=this.app.config.description?Ze(this.app.config.description):[];return r.length>1&&n.push(E`<button class="tool-btn" title="Show a description of the visualization" @click="${()=>He(E`${r.slice(1).map(i=>E`<p>${i}</p>`)}`,{title:r[0]})}">${K(z1).node[0]}</button>`),r.length>0&&n.push(E`<span class="vis-title">${r[0]}</span>`),n.push(E`<span class="spacer"></span> <a class="version" href="https://github.com/genome-spy/genome-spy/releases/tag/v${C2.version}">v${C2.version}</a> ${this.app.appContainer.requestFullscreen?E`<button class="tool-btn" title="Fullscreen" @click="${()=>this.app.toggleFullScreen()}">${K(w6).node[0]}</button>`:z} <button class="tool-btn" title="Help" @click="${()=>window.open("https://genomespy.app/docs/sample-collections/analyzing/","_blank")}">${K(p6).node[0]}</button>`),n}render(){const e=this.app.genomeSpy;return E`<nav class="gs-toolbar"><a href="https://genomespy.app" target="_blank" class="logo"><img title="GenomeSpy" alt="GenomeSpy" src="${w2}"> </a>${this.appInitialized&&x2(e.viewRoot)?E`<genome-spy-search-field .app="${this.app}"></genome-spy-search-field>`:z} ${this._getToolButtons()}</nav>`}}customElements.define("genome-spy-toolbar",lN);class fN{constructor(e){this.storeHelper=e,this._reducers={},this.actionInfoSources=[],this._reducer=void 0,e.addReducer("provenance",(n,r)=>this._reducer?this._reducer(n,r):n??{})}addReducer(e,n){this._reducers[e]=n;const r=o=>Object.keys(this._reducers).some(a=>o.type.startsWith(a)),i=(o,a)=>r(a)?a:o??null;this._reducer=XI(qf({...this._reducers,lastAction:i}),{ignoreInitialState:!0,filter:r}),this.storeHelper.dispatch({type:"@@redux/REPLACE"+Math.random().toString(36).substring(7).split("").join(".")})}get _storeState(){return this.storeHelper.store.getState()}get _provenanceState(){return this._storeState.provenance}isEnabled(){return!!this.getPresentState()}getPresentState(){return this._provenanceState.present}addActionInfoSource(e){this.actionInfoSources.push(e)}getActionInfo(e){for(const n of this.actionInfoSources){const r=n(e);if(r)return r}}dispatchBookmark(e){this.storeHelper.dispatch([...this.isUndoable()?[Ht.ActionCreators.jumpToPast(0)]:[],...e])}isRedoable(){return this.isEnabled()&&this._provenanceState.future.length>0}redo(){this.storeHelper.dispatch(Ht.ActionCreators.redo())}isUndoable(){return this.isEnabled()&&this._provenanceState.past.length>0}undo(){this.storeHelper.dispatch(Ht.ActionCreators.undo())}isAtInitialState(){return!this.isUndoable()}isEmpty(){const e=this._provenanceState;return!this.isEnabled()||e.past.length+e.future.length<=0}activateState(e){const n=this.getCurrentIndex();e<n?this.storeHelper.dispatch(Ht.ActionCreators.jumpToPast(e)):e>n&&this.storeHelper.dispatch(Ht.ActionCreators.jumpToFuture(e-n-1))}getCurrentIndex(){var e;return(e=this._provenanceState.past)==null?void 0:e.length}getActionHistory(){const e=this._provenanceState;return e.present&&[...e.past,e.present].map(n=>n.lastAction)}getFullActionHistory(){const e=this._provenanceState;return[...e.past,e.present,...e.future].map(n=>n.lastAction)}getBookmarkableActionHistory(){var e;return(e=this.getActionHistory())==null?void 0:e.slice(1)}}function*dN(t,e=n=>+n){const n=t.length,r=new Ao,i=new Array(n).fill(0);for(const[a,s]of t.entries())s.length&&r.push(a,e(s[0]));let o=0;for(;(o=r.pop())!==void 0;){const a=t[o];let s=i[o];if(yield a[s++],s<a.length){const u=e(a[s]);r.push(o,u),i[o]=s}}}const hN="sampleCount";class pN extends ue{constructor(e,n){super(),this.view=n;const r=n.context.animator;for(const i of n.getAncestors())i instanceof md&&(this.provenance=i.provenance,this.provenance.storeHelper.subscribe(o=>r.requestTransition(()=>{this.reset(),this._mergeAndPropagate(td(o)),this.complete()})));if(!this.provenance)throw new Error("No SampleView was found!");this.contextObject=void 0}initialize(){this.contextObject=Object.create(super.getGlobalObject());const e=this.view.getEncoding().x;if(Xn(e))this.xAccessor=q(e.field);else throw new Error("Crash!")}handle(e){}getGlobalObject(){return this.contextObject}_getCollector(){if(this.parent instanceof Xr)return this.parent;throw new Error("MergeFacetsTransform must be a direct child of a Collector")}complete(){this._mergeAndPropagate(this.provenance.getPresentState()[ii]),super.complete()}_mergeAndPropagate(e){const n=[...rd(e.rootGroup)].filter(r=>Tv(Re(r)));for(const[r,i]of n.entries()){const o=Re(i);if(Tv(o)){this.contextObject[hN]=o.samples.length,this.beginBatch({type:"facet",facetId:[r]});const a=o.samples,s=this._getCollector(),c=dN(a.map(u=>s.facetBatches.get([u])??[]),this.xAccessor);for(const u of c)this._propagate(u)}}this._updateScales()}setParent(e){super.setParent(e)}_updateScales(){const e=new Set;this.view.visit(n=>{if(n instanceof be&&n.mark.encoding.y){const r=n.getScaleResolution("y");r&&e.add(r)}});for(const n of e)n.reconfigure()}}var mN="BATCHING_REDUCER.BATCH";function gN(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mN;return{type:e,meta:{batch:!0},payload:t}}function yN(t){return function e(n,r){return r&&r.meta&&r.meta.batch?r.payload.reduce(e,n):t(n,r)}}class vN{constructor(e){this._reducers=e??{},this.store=rI({reducer:{}}),this._listeners=new Set,this.store.subscribe(()=>{const n=this.store.getState();for(const r of this._listeners)r(n)})}get state(){return this.store.getState()}addReducer(e,n){this._reducers[e]=n,this.store.replaceReducer(yN(qf(this._reducers)))}subscribe(e){this._listeners.add(e)}unsubscribe(e){this._listeners.delete(e)}dispatch(e){Array.isArray(e)?this.store.dispatch(gN(e)):this.store.dispatch(e)}getDispatcher(){return e=>this.dispatch(e)}}class bN extends g2{constructor(e){super(),this.bookmarks=e,this.names=e.map(n=>n.name)}async getNames(){return this.names}async get(e){return this.bookmarks.find(n=>n.name==e)}}f1.mergeFacets=pN;class P2{constructor(e,n,r={}){const i=this;this.config=n,this.storeHelper=new vN,this.storeHelper.addReducer("viewSettings",si.reducer),this.provenance=new fN(this.storeHelper),this._initializationListeners=[],this.toolbarRef=b2(),this.appContainer=e,this._configureContainer(),this.localBookmarkDatabase=typeof n.specId=="string"?new Fk(n.specId):void 0,this.globalBookmarkDatabase=void 0,Le(E`<div class="genome-spy-app"><genome-spy-toolbar ${A2(i.toolbarRef)} .app="${i}"></genome-spy-toolbar><div class="genome-spy-container"></div></div>`,i.appContainer),i.appContainer.querySelector(".genome-spy-app").addEventListener("query-dependency",s=>{s.detail.name=="app"&&(s.detail.setter(i),s.stopPropagation())});const o=s=>this.appContainer.getElementsByClassName(s)[0];this.genomeSpy=new M1(o("genome-spy-container"),this.config,r),this.genomeSpy.viewFactory.addViewType(Ck,(s,c,u,f)=>new md(s,c,u,f,this.provenance));const a=this.genomeSpy.viewVisibilityPredicate;this.genomeSpy.viewVisibilityPredicate=s=>{var c;return((c=this.storeHelper.state.viewSettings)==null?void 0:c.visibilities[s.name])??a(s)}}addInitializationListener(e){this._initializationListeners?this._initializationListeners.push(e):e()}toggleFullScreen(){document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():this.appContainer.requestFullscreen()}isFullPage(){return this.appContainer==document.body}async launch(){var a;const e=(a=this.config.bookmarks)!=null&&a.remote?Li({baseURL:this.config.baseUrl}).load(this.config.bookmarks.remote.url).then(s=>Promise.resolve(JSON.parse(s))):Promise.resolve([]);if(!await this.genomeSpy.launch())return;this.appContainer.querySelector("canvas").setAttribute("tabindex","-1"),this.storeHelper.subscribe(tc(s=>{var c;return(c=s.viewSettings)==null?void 0:c.visibilities},(s,c)=>{var f,l;this.genomeSpy.viewRoot._invalidateCacheByPrefix("size","progeny"),(l=(f=this.getSampleView())==null?void 0:f.summaryViews)==null||l._invalidateCacheByPrefix("size","self");const u=this.genomeSpy.viewRoot.context;u.requestLayoutReflow(),u.animator.requestRender()},this.storeHelper.store.getState()));try{const s=await e;s.length&&(this.globalBookmarkDatabase=new bN(s))}catch(s){throw new Error(`Cannot load remote bookmarks: ${s}`)}try{await this._restoreStateFromUrlOrBookmark()}catch(s){He(s.toString())}this.storeHelper.subscribe(()=>{this._updateStateToUrl()}),window.addEventListener("hashchange",()=>this._restoreStateFromUrl().catch(s=>He(s.toString())),!1);const r=xs(()=>this._updateStateToUrl(),500,!1);for(const[,s]of this.genomeSpy.getNamedScaleResolutions())s.isZoomable()&&s.addEventListener("domain",r);const i=this.toolbarRef.value;i.appInitialized=!0;const o=Ze(this.genomeSpy.spec.description??[]);this.isFullPage()&&o.length>0&&(document.title="GenomeSpy - "+o);for(const s of this._initializationListeners)s();this._initializationListeners=void 0}async _restoreStateFromUrlOrBookmark(){var i;const e=(i=this.config.bookmarks)==null?void 0:i.remote,n=this.globalBookmarkDatabase;if(!await this._restoreStateFromUrl()&&e&&n){const o=e.initialBookmark??(e.tour&&(await n.getNames())[0]);if(o){const a=await n.get(o);if(!a)throw new Error(`No such bookmark: ${o}`);e.tour?await Uo(a,this,{mode:"tour",database:n,afterTourBookmark:e.afterTourBookmark}):await Md(a,this)}}}_updateStateToUrl(){const e={actions:[],scaleDomains:{}},n=this.provenance.getBookmarkableActionHistory();n!=null&&n.length&&(e.actions=n);for(const[o,a]of this.genomeSpy.getNamedScaleResolutions().entries())a.isZoomed()||(e.scaleDomains[o]=a.getComplexDomain());const r=this.storeHelper.state.viewSettings;Object.keys(r.visibilities).length&&(e.viewSettings=r);const i=e.actions.length||Object.keys(e.scaleDomains).length||e.viewSettings?B2(e):"";window.history.replaceState(void 0,document.title,window.location.pathname+window.location.search+i)}async _restoreStateFromUrl(){var r,i;const e=window.location.hash,n=(r=e.match(/^#bookmark:(.+)$/))==null?void 0:r[1];if(n){const o=(i=this.config.bookmarks)==null?void 0:i.remote,a=this.globalBookmarkDatabase;if(o&&a){const s=(await a.getNames()).find(c=>c.replaceAll(" ","-")==n);if(s){const c=await a.get(s);if(!c)throw new Error(`No such bookmark: ${s}`);return await Uo(c,this,{mode:"tour",database:a}),!0}else throw new Error(`No such bookmark: ${n}`)}}if(e&&e.length>0)try{const o=oN(e);return Uo(o,this,{mode:"shared"}),!0}catch(o){console.error(o),He(E`<p>Cannot restore the state:</p><p>${o}</p>`)}return!1}_configureContainer(){this.isFullPage()?(this.appContainer.style.margin="0",this.appContainer.style.padding="0",this.appContainer.style.overflow="hidden",AN(X5)):this.appContainer.style.position="relative"}getSampleView(){var n;if(!((n=this.genomeSpy)!=null&&n.viewRoot))return;let e;return this.genomeSpy.viewRoot.visit(r=>{if(r instanceof md)return e=r,tr}),e}}function AN(t){const e=document.querySelector("head"),n=document.createElement("link");n.setAttribute("rel","shortcut icon"),n.setAttribute("href",t),e.appendChild(n)}async function xN(t,e,n={}){let r;if(ne(t)){if(r=document.querySelector(t),!r)throw new Error(`No such element: ${t}`)}else if(t instanceof HTMLElement)r=t;else throw new Error(`Invalid element: ${t}`);let i;try{const o=Pe(e)?e:await z2(e);o.baseUrl??(o.baseUrl=""),o.width??(o.width="container"),o.padding??(o.padding=10);const a=new P2(r,o,n);i=a.genomeSpy,wN(i,n),await a.launch()}catch(o){r.innerText=o.toString(),console.error(o)}return{finalize(){for(i.destroy();r.firstChild;)r.firstChild.remove()},addEventListener(o,a){const s=i._eventListeners;let c=s.get(o);c||(c=new Set,s.set(o,c)),c.add(a)},removeEventListener(o,a){var c;(c=i._eventListeners.get(o))==null||c.delete(a)},getScaleResolutionByName(o){return i.getNamedScaleResolutions().get(o)}}}function wN(t,e){e.namedDataProvider&&t.registerNamedDataProvider(e.namedDataProvider)}async function z2(t){let e;try{e=JSON.parse(await Li().load(t))}catch(n){throw new Error(`Could not load or parse configuration: ${t}, reason: ${n.message}`)}if(!e.baseUrl){const n=t.match(/^[^?#]*\//);e.baseUrl=n&&n[0]||"./"}return e}j.GenomeSpy=M1,j.GenomeSpyApp=P2,j.embed=xN,j.html=E,j.icon=w2,j.loadSpec=z2,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
},
|
8
8
|
"contributors": [],
|
9
9
|
"license": "MIT",
|
10
|
-
"version": "0.28.
|
10
|
+
"version": "0.28.5",
|
11
11
|
"main": "dist/index.js",
|
12
12
|
"files": [
|
13
13
|
"dist/"
|
@@ -37,5 +37,5 @@
|
|
37
37
|
"redux-undo": "^1.0.1",
|
38
38
|
"snarkdown": "^2.0.0"
|
39
39
|
},
|
40
|
-
"gitHead": "
|
40
|
+
"gitHead": "8292aa33b1923caf834b25db516e194f9d111bb8"
|
41
41
|
}
|