diff --git a/README.rst b/README.rst index 9776ee6..1c2ce85 100644 --- a/README.rst +++ b/README.rst @@ -105,6 +105,12 @@ If you find any bugs or issues please log them in the `issue tracker`_. Changelog ========= +**0.0.4** + +- Building as node CLI application (via `node-canvas`_) +- CLI implemented with `commander.js`_ +- Update IPRMCResultModel arrays are used by default even when one object is present + **0.0.3** - Added option to generate static visualisations @@ -150,4 +156,5 @@ Apache License 2.0. See `license`_ for details. .. _issue tracker: ../../issues .. _license: LICENSE .. _webpack: https://webpack.js.org/ -.. _jdispatcher-viewers-cli: https://gitlab.ebi.ac.uk/ebi-biows/jdispatcher-viewers-cli +.. _node-canvas: https://github.com/Automattic/node-canvas +.. _commander.js: https://github.com/tj/commander.js/ diff --git a/bin/jd-viewers-cli.js b/bin/jd-viewers-cli.js new file mode 100644 index 0000000..f1f68d0 --- /dev/null +++ b/bin/jd-viewers-cli.js @@ -0,0 +1 @@ +!function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=8)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.lineDefaults=e.rectDefaults=e.textDefaults=e.objectDefaults=e.jobIdDefaults=e.ColorSchemeEnum=void 0,function(t){t.fixed="fixed",t.dynamic="dynamic",t.ncbiblast="ncbiblast",t.blasterjs="blasterjs"}(e.ColorSchemeEnum||(e.ColorSchemeEnum={})),e.jobIdDefaults={value:"",required:!0,minLength:35,maxLength:60,pattern:/([a-z_])*-([A-Z0-9])*-\d*-\d*-\d*-(np2|p1m|p2m)$/},e.objectDefaults={selectable:!1,evented:!1,objectCaching:!1},e.textDefaults=Object.assign({},e.objectDefaults),e.rectDefaults=Object.assign({},e.objectDefaults),e.lineDefaults=Object.assign({},e.objectDefaults)},function(t,e,i){"use strict";var s=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{c(s.next(t))}catch(t){a(t)}}function r(t){try{c(s.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}c((s=s.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.getDomainURLbyDatabase=e.getUniqueIPRMCDomainDatabases=e.domainDatabaseNameToString=e.getIPRMCDataModelFlatFromXML=e.validateSubmittedDbfetchInput=e.validateSubmittedJobIdInput=e.validateJobId=e.getJdispatcherJsonURL=e.dataAsType=e.fetchData=e.numberToString=e.ObjectCache=e.BasicCanvasRenderer=void 0;const a=i(6),o=i(17),r=n(i(18)),c=i(0);e.BasicCanvasRenderer=class{constructor(t){this.element=t}getFabricCanvas(){const t={defaultCursor:"default",moveCursor:"default",hoverCursor:"default"};this.staticCanvas?this.canvas=new a.fabric.StaticCanvas(this.element,t):this.canvas=new a.fabric.Canvas(this.element,t)}setFrameSize(){this.canvas.setWidth(this.canvasWidth),this.canvas.setHeight(this.canvasHeight)}renderCanvas(){this.canvas.renderAll()}};function h(t){return`https://wwwdev.ebi.ac.uk/Tools/services/rest/${t.split("-")[0]}/result/${t}/jdp?format=json`}function l(t,e=!1){let i=!0;return t.required&&(i=i&&0!==t.value.trim().length),t.minLength&&(i=i&&t.value.trim().length>=t.minLength),t.maxLength&&(i=i&&t.value.trim().length<=t.maxLength),t.pattern&&(i=i&&t.pattern.test(t.value.trim())),e&&(i?console.log(`JobId "${t.value}" is valid!`):console.log(`JobId "${t.value}" is not valid!`)),i}function d(t){let e="Unclassified";return"IPR"===(t=t.toUpperCase())||"INTERPRO"===t?e="InterPro":"CATHGENE3D"===t||"CATH-GENE3D"===t||"GENE3D"===t?e="CATH-Gene3D":"CDD"===t?e="CDD":"PANTHER"===t?e="PANTHER":"HAMAP"===t?e="HAMAP":"PFAM"===t?e="Pfam":"PIRSF"===t?e="PIRSF":"PRINTS"===t?e="PRINTS":"PROSITE PROFILES"===t||"PROSITE_PROFILES"===t||"PROFILE"===t?e="PROSITE profiles":"PROSITE PATTERNS"===t||"PROSITE_PATTERNS"===t||"PROSITE"===t?e="PROSITE patterns":"SFLD"===t?e="SFLD":"SMART"===t?e="SMART":"SUPERFAMILY"===t||"SSF"===t?e="SUPERFAMILY":"TIGERFAMS"===t?e="TIGRFAMs":"PRODOM"===t&&(e="PRODOM"),e}e.ObjectCache=class{constructor(){this.values=new Map}get(t){if(this.values.has(t))return this.values.get(t)}put(t,e){this.values.has(t)||this.values.set(t,e)}delete(t){this.values.has(t)&&this.values.delete(t)}},e.numberToString=function(t){return Number.isInteger(t)?t+".0":t<1e-4||t>1e4?t.toExponential(2):function(t){return Math.floor(t)===t?0:t.toString().split(".")[1].length||0}(t)>3?t.toFixed(3).toString():t.toString()},e.fetchData=function(t,e="json"){return s(this,void 0,void 0,(function*(){return yield r.default(t).then(i=>{if(!i.ok)throw new Error("Could not retrieve data from "+t);if("json"!==e)return i.text();try{return i.json()}catch(e){throw new Error("Could not decode JSON data from "+t)}}).catch(t=>console.log(t))}))},e.dataAsType=function(t,e){return t},e.getJdispatcherJsonURL=h,e.validateJobId=l,e.validateSubmittedJobIdInput=function(t){const e=Object.assign({},c.jobIdDefaults);return e.value=t,e.value.startsWith("http")||e.value.includes("/")||e.value.includes("./")||!l(e)||(t=h(t)),t},e.validateSubmittedDbfetchInput=function(t,e=30){return function(t){return`https://www.ebi.ac.uk/Tools/dbfetch/dbfetch?db=iprmc;id=${t};format=iprmcxml;style=raw`}(function(t,e=30){let i="";for(const s of t.hits.slice(0,e))i+=""===i?""+s.hit_acc:","+s.hit_acc;return i}(t,e))},e.getIPRMCDataModelFlatFromXML=function(t,e=30){return function(t,e){let i=0,s={};for(const n of t.interpromatch[0].protein)if(i++,i<=e){let t=[],e={};for(const i of n.match){let s={};if(void 0!==i.ipr){const n=`${d(i._attributes.dbname)}_${i.ipr[0]._attributes.id}`;t.includes(n)||t.push(n),n in e||(e[n]=[]),s={id:i.ipr[0]._attributes.id,name:i.ipr[0]._attributes.name,dbname:d(i._attributes.dbname),type:i.ipr[0]._attributes.type,altid:i._attributes.id,altname:i._attributes.name,status:i._attributes.status,model:i._attributes.model,evd:i._attributes.evd,start:Number(i.lcn[0]._attributes.start),end:Number(i.lcn[0]._attributes.end),fragments:i.lcn[0]._attributes.fragments,score:i.lcn[0]._attributes.fragments},e[n].push(s)}else{const n=`${d(i._attributes.dbname)}_${i._attributes.id}`;t.includes(n)||t.push(n),n in e||(e[n]=[]),s={id:i._attributes.id,name:i._attributes.name,dbname:d(i._attributes.dbname),status:i._attributes.status,model:i._attributes.model,evd:i._attributes.evd,type:"Unclassified",start:Number(i.lcn[0]._attributes.start),end:Number(i.lcn[0]._attributes.end),fragments:i.lcn[0]._attributes.fragments,score:i.lcn[0]._attributes.fragments},e[n].push(s)}}s[n._attributes.id]={id:n._attributes.id,name:n._attributes.name,length:Number(n._attributes.length),matches:t.sort(),match:e}}return s}(function(t){try{return JSON.parse(o.xml2json(t,{compact:!0,spaces:2,alwaysArray:!0}))}catch(t){return console.log("Cannot parse the resulting Dbfetch response (likely not formatted XML)!"),{}}}(t),e)},e.domainDatabaseNameToString=d,e.getUniqueIPRMCDomainDatabases=function(t,e){const i=[];for(const s of e)for(const e of t[""+s].matches)i.push(e.split("_")[0]);return i.filter((t,e,i)=>i.indexOf(t)===e)},e.getDomainURLbyDatabase=function(t,e){let i="";return t.startsWith("IPR")?i="https://www.ebi.ac.uk/interpro/entry/InterPro/"+t:"CATH-Gene3D"===e?i="https://www.ebi.ac.uk/interpro/entry/cathgene3d/"+t:"CDD"===e?i="https://www.ebi.ac.uk/interpro/entry/cdd/"+t:"PANTHER"===e?i="https://www.ebi.ac.uk/interpro/entry/panther/"+t:"HAMAP"===e?i="https://www.ebi.ac.uk/interpro/entry/hamap/"+t:"Pfam"===e?i="https://www.ebi.ac.uk/interpro/entry/pfam/"+t:"PIRSF"===e?i="https://www.ebi.ac.uk/interpro/entry/pirsf/"+t:"PRINTS"===e?i="https://www.ebi.ac.uk/interpro/entry/prints/"+t:"PROSITE profiles"===e?i="https://www.ebi.ac.uk/interpro/entry/profile/"+t:"PROSITE patterns"===e?i="https://www.ebi.ac.uk/interpro/entry/prosite/"+t:"SFLD"===e?i="https://www.ebi.ac.uk/interpro/entry/sfld/"+t:"SMART"===e?i="https://www.ebi.ac.uk/interpro/entry/smart/"+t:"SUPERFAMILY"===e?i="https://www.ebi.ac.uk/interpro/entry/ssf/"+t:"TIGRFAMs"===e?i="https://www.ebi.ac.uk/interpro/entry/tigrfams/"+t:"PRODOM"===e&&(i="https://www.ebi.ac.uk/interpro/entry/prodom/"+t),i}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.colorNcbiBlastGradient=e.ncbiBlastGradient=e.colorDefaultGradient=e.defaultGradient=void 0,e.defaultGradient={0:[255,64,64],.25:[255,255,64],.5:[64,255,64],.75:[64,255,255],1:[64,64,255],keys:[0,.25,.5,.75,1]},e.colorDefaultGradient=function(t,i,s){t.setGradient("fill",{type:"linear",x1:i,y1:0,x2:s,y2:0,colorStops:{0:`rgb(${e.defaultGradient[0].join(",")})`,.25:`rgb(${e.defaultGradient[.25].join(",")})`,.5:`rgb(${e.defaultGradient[.5].join(",")})`,.75:`rgb(${e.defaultGradient[.75].join(",")})`,1:`rgb(${e.defaultGradient[1].join(",")})`}})},e.ncbiBlastGradient={0:[0,0,0],40:[0,32,233],50:[117,234,76],80:[219,61,233],200:[219,51,36],keys:[0,40,50,80,200]},e.colorNcbiBlastGradient=function(t,i,s){t.setGradient("fill",{type:"linear",x1:i,y1:0,x2:s,y2:0,colorStops:{0:`rgb(${e.ncbiBlastGradient[0].join(",")})`,.199999:`rgb(${e.ncbiBlastGradient[0].join(",")})`,.2:`rgb(${e.ncbiBlastGradient[40].join(",")})`,.399999:`rgb(${e.ncbiBlastGradient[40].join(",")})`,.4:`rgb(${e.ncbiBlastGradient[50].join(",")})`,.599999:`rgb(${e.ncbiBlastGradient[50].join(",")})`,.6:`rgb(${e.ncbiBlastGradient[80].join(",")})`,.799999:`rgb(${e.ncbiBlastGradient[80].join(",")})`,.8:`rgb(${e.ncbiBlastGradient[200].join(",")})`,1:`rgb(${e.ncbiBlastGradient[200].join(",")})`}})}},function(t,e,i){"use strict";function s(t,e,i,s,n){return(i*s-n)/(t+e)}Object.defineProperty(e,"__esModule",{value:!0}),e.getDomainPixelCoords=e.getQuerySubjPixelCoords=e.getPixelCoords=e.getTotalPixels=e.getTextLegendPaddingFactor=void 0,e.getTextLegendPaddingFactor=function(t){let e=0;return 1===t.length?e=2.5:2===t.length?e=10:3===t.length?e=15.5:4===t.length?e=21:5===t.length?e=29:6===t.length?e=35:7===t.length?e=41:8===t.length&&(e=47),e},e.getTotalPixels=s,e.getPixelCoords=function(t,e,i){return[e+i,e+t-i]},e.getQuerySubjPixelCoords=function(t,e,i,n,a,o,r){const c=s(t,e,t,n,a);return[o+r,o+c-r,o+c+a+r,o+c+a+s(t,e,i,n,a)-r]},e.getDomainPixelCoords=function(t,e,i,s,n,a){const o=t+s*(e-t)/i+a;return[o,t+n*(e-t)/i-a-o]}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.colorByDatabaseName=e.HSVtoRGB=e.getGradientSteps=e.getRgbColorFixed=e.getRgbColorGradient=void 0;const s=i(0);function n(t,e,i){let s,n,a,o,r,c=0,h=0,l=0;switch(s=Math.floor(6*t),n=6*t-s,a=i*(1-e),o=i*(1-n*e),r=i*(1-(1-n)*e),s%6){case 0:c=i,h=r,l=a;break;case 1:c=o,h=i,l=a;break;case 2:c=a,h=i,l=r;break;case 3:c=a,h=o,l=i;break;case 4:c=r,h=a,l=i;break;case 5:c=i,h=a,l=o}return[Math.round(255*c),Math.round(255*h),Math.round(255*l)]}e.getRgbColorGradient=function(t,e,i){const s=i.keys;if(s.length!=e.length)throw Error("Color Scheme and Gradient Steps should have matching lengths!");if(t+0===0)return`rgb(${i[s[0]].join(",")})`;{const i=e[0],s=e[1],a=e[2],o=e[3],r=e[4];let c;if(t=e[1]&&t=e[2]&&t=e[3]&&t=e[4]?`rgb(${i[s[4]].join(",")})`:"rgb(192,192,192)"},e.getGradientSteps=function(t,e,i,n){let a=[];if(n===s.ColorSchemeEnum.fixed)a=[0,Math.pow(10,-1),Math.pow(10,0),Math.pow(10,1),Math.pow(10,2)];else if(n===s.ColorSchemeEnum.dynamic)if(e<1e-304){const t=-304;a=[0,Math.pow(10,t),Math.pow(10,t/2),Math.pow(10,t/4),Math.pow(10,t/8)]}else if(t<1){const s=Math.log10(e);if(e<=1){let n,o,r;if(0===t&&i>0)n=Math.log10(i)-1;else{const e=Math.log10(t);n=e+(s-e)/2}o=n+(s-n)/2,r=o+(s-o)/2,a=[t,Math.pow(10,n),Math.pow(10,o),Math.pow(10,r),e]}else{const s=Math.log10(i)-Math.log10(e);a=Math.abs(s)<=2?[t,1,(2+e)/3,(2+2*e)/3,e]:Math.abs(s)<=4?[t,Math.pow(10,s/2),1,(e+1)/2,e]:[t,Math.pow(10,s/2),Math.pow(10,s/4),1,e]}}else a=[t,(3*t+e)/4,(t+e)/2,(t+3*e)/4,e];else a=n===s.ColorSchemeEnum.ncbiblast?[0,40,50,80,200]:[0,1e-5,.01,1,100];return a},e.HSVtoRGB=n,e.colorByDatabaseName=function(t){let e;return e="Pfam"==t?"rgb(211,47,47)":"SUPERFAMILY"==t?"rgb(171,71,188)":"SMART"==t?"rgb(106,27,154)":"HAMAP"==t?"rgb(57,73,171)":"PANTHER"==t?"rgb(33,150,243)":"PRODOM"==t?"rgb(0,188,212)":"PROSITE profiles"==t?"rgb(0,150,136)":"CDD"==t?"rgb(76,175,80)":"CATH-Gene3D"==t?"rgb(205,220,57)":"PIRSF"==t?"rgb(255,235,59)":"PRINTS"==t?"rgb(255,193,7)":"TIGRFAMs"==t?"rgb(255,112,67)":"SFLD"==t?"rgb(121,85,72)":"PROSITE patterns"==t?"rgb(55,71,79)":"rgb(128,128,128)",e}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.drawURLInfoTooltip=e.drawDomainInfoTooltips=e.drawDomains=e.drawContentDomainInfoText=e.drawHitTransparentBox=e.drawDomainCheckbox=e.drawProteinFeaturesText=e.drawContentSupressText=e.drawContentTitleText=e.drawCanvasWrapperStroke=e.drawFooterText=e.drawScaleTick4LabelsGroup=e.drawScaleTick5LabelsGroup=e.drawLineAxis6Buckets=e.drawLineAxis5Buckets=e.drawScaleColorGradient=e.drawScaleScoreText=e.drawCheckBoxText=e.drawScaleTypeText=e.drawDomainTooltips=e.drawDomainQueySubject=e.drawScoreText=e.drawHspNoticeText=e.drawContentSequenceInfoText=e.drawNoHitsFoundText=e.drawContentQuerySubjFooterTextGroup=e.drawContentFooterTextGroup=e.drawDomainLineTracks=e.drawLineTracks=e.drawLineTracksQuerySubject=e.drawContentHeaderTextGroup=e.drawHeaderLinkText=e.drawHeaderTextGroup=void 0;const s=i(6),n=i(1),a=i(3),o=i(2),r=i(0),c=i(4);e.drawHeaderTextGroup=function(t,e,i){const n=i,a=Object.assign({},r.textDefaults);a.fontWeight="bold",a.fontSize=e.fontSize+1,a.top=i,a.left=5;const o=t.program,c=t.version,h=new s.fabric.Text(`${o} (version: ${c})`,a);let l=[];for(const e of t.dbs)l.push(e.name);const d=l.join(", ");a.fontWeight="normal",a.fontSize=e.fontSize,i+=15,a.top=i;const u=new s.fabric.Text("Database(s): "+d,a);i+=15,a.top=i;const b=new s.fabric.Text("Sequence: ",a),f=t.query_len;i+=15,a.top=i;const p=new s.fabric.Text("Length: "+f,a),g=t.start;a.top=n,a.left=e.canvasWidth-135;const m=new s.fabric.Text(""+g,a),S=t.end;a.top=n+15;const x=new s.fabric.Text(""+S,a);return new s.fabric.Group([h,u,b,p,m,x],r.objectDefaults)},e.drawHeaderLinkText=function(t,e,i){const n=t.query_def,a=Object.assign({},r.textDefaults);return a.fontFamily="Menlo",a.fontSize=e.fontSize-2,a.evented=!0,a.top=i-15,a.left=57.5,[new s.fabric.Text(""+n,a),a]},e.drawContentHeaderTextGroup=function(t,e,i){const n=Object.assign({},r.textDefaults);n.fontWeight="bold",n.fontSize=e.fontSize+1,n.top=i+2,n.textAlign="center";const o=a.getTotalPixels(t.queryLen,t.subjLen,t.queryLen,e.contentWidth,e.contentScoringWidth),c=a.getTotalPixels(t.queryLen,t.subjLen,t.subjLen,e.contentWidth,e.contentScoringWidth);n.left=t.startQueryPixels;const h=new s.fabric.Text("Sequence Match",n);let l;h.width=o,n.left=t.startEvalPixels,l=e.colorScheme===r.ColorSchemeEnum.ncbiblast?new s.fabric.Text("Bit score",n):new s.fabric.Text("E-value",n),l.width=e.contentScoringWidth,n.left=t.startSubjPixels;const d=new s.fabric.Text("Subject Match",n);return d.width=c,new s.fabric.Group([h,l,d],r.objectDefaults)},e.drawLineTracksQuerySubject=function(t,e,i){const n=Object.assign({},r.lineDefaults);n.top=i,n.stroke="black",n.strokeWidth=e.strokeWidth;const a=[t.startQueryPixels,i,t.endQueryPixels,i];n.left=t.startQueryPixels;const o=new s.fabric.Line(a,n),c=[t.startQueryPixels,i-3,t.startQueryPixels,i+3];n.top=i-2;const h=new s.fabric.Line(c,n),l=[t.endQueryPixels,i-3,t.endQueryPixels,i+3];n.left=t.endQueryPixels;const d=new s.fabric.Line(l,n),u=[t.startSubjPixels,i,t.endSubjPixels,i];n.top=i,n.left=t.startSubjPixels;const b=new s.fabric.Line(u,n),f=[t.startSubjPixels,i-3,t.startSubjPixels,i+3];n.top=i-2;const p=new s.fabric.Line(f,n),g=[t.endSubjPixels,i-3,t.endSubjPixels,i+3];n.left=t.endSubjPixels;const m=new s.fabric.Line(g,n);return new s.fabric.Group([o,b,h,d,p,m],r.objectDefaults)},e.drawLineTracks=function(t,e,i){const n=Object.assign({},r.lineDefaults);n.top=i,n.stroke="black",n.strokeWidth=e.strokeWidth;const a=[t.startPixels,i,t.endPixels,i];n.left=t.startPixels;const o=new s.fabric.Line(a,n),c=[t.startPixels,i-3,t.startPixels,i+3];n.top=i-2;const h=new s.fabric.Line(c,n),l=[t.endPixels,i-3,t.endPixels,i+3];n.left=t.endPixels;const d=new s.fabric.Line(l,n);return new s.fabric.Group([o,h,d],r.objectDefaults)},e.drawDomainLineTracks=function(t,e,i){const n=Object.assign({},r.lineDefaults);n.top=i,n.stroke="black",n.strokeWidth=e.strokeWidth,n.strokeDashArray=e.strokeDashArray;const a=[t.startPixels,i,t.endPixels,i];return n.left=t.startPixels,new s.fabric.Line(a,n)},e.drawContentFooterTextGroup=function(t,e,i){const n=Object.assign({},r.textDefaults);n.fontSize=e.fontSize,n.top=i,n.left=t.startPixels-2.5;const o=new s.fabric.Text(""+t.start,n);let c=a.getTextLegendPaddingFactor(""+t.end);n.left=t.endPixels-c;const h=new s.fabric.Text(""+t.end,n);return new s.fabric.Group([o,h],r.objectDefaults)},e.drawContentQuerySubjFooterTextGroup=function(t,e,i){const n=Object.assign({},r.textDefaults);n.fontSize=e.fontSize,n.top=i,n.left=t.startQueryPixels-2.5;const o=new s.fabric.Text("1",n);let c=a.getTextLegendPaddingFactor(""+t.queryLen);n.left=t.endQueryPixels-c;const h=new s.fabric.Text(""+t.queryLen,n);n.left=t.startSubjPixels-2.5;const l=new s.fabric.Text("1",n);c=a.getTextLegendPaddingFactor(""+t.subjLen),n.left=t.endSubjPixels-c;const d=new s.fabric.Text(""+t.subjLen,n);return new s.fabric.Group([o,h,l,d],r.objectDefaults)},e.drawNoHitsFoundText=function(t,e){const i=Object.assign({},r.textDefaults);return i.fontWeight="bold",i.fontSize=t.fontSize+1,i.top=e,i.left=t.contentWidth/2,i.fill="red",new s.fabric.Text("--------------------No hits found--------------------",i)},e.drawContentSequenceInfoText=function(t,e,i,n){const a=Object.assign({},r.textDefaults);a.fontFamily="Menlo",a.fontSize=i.fontSize-2,a.top=n-2;const o=" ".repeat(t-(e.hit_db.length+e.hit_id.length)),c=new s.fabric.Text(o,a);let h=`${e.hit_db}:${e.hit_id} ${e.hit_desc}`,l=`${o}${e.hit_db}:${e.hit_id} ${e.hit_desc}`;return l.length>40&&(h=(l.slice(0,38)+"...").slice(o.length)),a.left=10+6*o.length,a.evented=!0,[c,new s.fabric.Text(h,a),a]},e.drawHspNoticeText=function(t,e,i,n){const a=Object.assign({},r.textDefaults);return a.fontSize=i.fontSize,a.top=n,a.left=i.contentWidth/2,a.fill="red",new s.fabric.Text(`This hit contains ${t} alignments, but only the first ${e} are displayed!`,a)},e.drawScoreText=function(t,e,i,a){const o=Object.assign({},r.textDefaults);let c;return o.fontSize=i.fontSize,o.top=a-15,o.textAlign="center",o.left=t,c=i.colorScheme===r.ColorSchemeEnum.ncbiblast?new s.fabric.Text(n.numberToString(e.hsp_bit_score),o):new s.fabric.Text(n.numberToString(e.hsp_expect),o),c},e.drawDomainQueySubject=function(t,e,i,n,a,o){const c=Object.assign({},r.rectDefaults);c.evented=!0,c.top=a,c.fill=o,c.rx=5,c.ry=5,c.top=a-15,c.left=t,c.width=e,c.height=10;const h=new s.fabric.Rect(c);return c.top=a-15,c.left=i,c.width=n,c.height=10,[h,new s.fabric.Rect(c)]},e.drawDomainTooltips=function(t,e,i,a,o,c,h){const l=Object.assign({},r.textDefaults);let d;l.fontSize=c.fontSize+1,l.textAlign="left",l.originX="top",l.originY="top",l.top=5,d=c.colorScheme===r.ColorSchemeEnum.ncbiblast?`Start: ${i}\nEnd: ${a}\nBit score: ${n.numberToString(o.hsp_bit_score)}`:`Start: ${i}\nEnd: ${a}\nE-value: ${n.numberToString(o.hsp_expect)}`;const u=new s.fabric.Text(d,l),b=Object.assign({},r.rectDefaults);b.fill="white",b.stroke="lightseagreen",b.rx=5,b.ry=5,b.originX="top",b.originY="top",b.width=140,b.height=60,b.opacity=.95;const f=new s.fabric.Rect(b);return new s.fabric.Group([f,u],{selectable:!1,evented:!1,objectCaching:!1,visible:!1,top:h,left:t+e/2})},e.drawScaleTypeText=function(t,e){const i=Object.assign({},r.textDefaults);return i.fontSize=t.fontSize+1,i.fontWeight="bold",i.top=e,i.left=t.scaleLabelWidth,new s.fabric.Text("Scale Type:",i)},e.drawCheckBoxText=function(t,e){const i=Object.assign({},r.textDefaults);i.fontSize=t.fontSize+1,i.top=e,i.left=t.scaleLabelWidth;const n=Object.assign({},r.textDefaults);n.fontSize=t.fontSize+12,n.fill="grey",n.evented=!0,n.top=e-8,n.left=t.scaleLabelWidth;const a=Object.assign({},n),o=Object.assign({},n);let c;c=t.colorScheme===r.ColorSchemeEnum.dynamic?"☒":"☐",t.colorScheme===r.ColorSchemeEnum.dynamic&&(n.fill="black"),n.left+=80;const h=new s.fabric.Text(c,n);i.left+=100;const l=new s.fabric.Text("Dynamic (E-value: min to max)",i);c=t.colorScheme===r.ColorSchemeEnum.fixed?"☒":"☐",t.colorScheme===r.ColorSchemeEnum.fixed&&(a.fill="black"),a.left+=290;const d=new s.fabric.Text(c,a);i.left+=210;const u=new s.fabric.Text("Fixed (E-value: 0.0 to 100.0)",i);c=t.colorScheme===r.ColorSchemeEnum.ncbiblast?"☒":"☐",t.colorScheme===r.ColorSchemeEnum.ncbiblast&&(o.fill="black"),o.left+=480;const b=new s.fabric.Text(c,o);return i.left+=190,[h,l,n,d,u,a,b,new s.fabric.Text("NCBI BLAST+ (Bit score: <40 to ≥200)",i),o]},e.drawScaleScoreText=function(t,e){const i=Object.assign({},r.textDefaults);let n;return i.fontSize=t.fontSize+1,i.top=e,n=t.colorScheme===r.ColorSchemeEnum.ncbiblast?"Bit score":"E-value",t.colorScheme===r.ColorSchemeEnum.ncbiblast?i.left=t.scaleLabelWidth-56:i.left=t.scaleLabelWidth-50,new s.fabric.Text(""+n,i)},e.drawScaleColorGradient=function(t,e){const i=Object.assign({},r.rectDefaults);i.top=e,i.left=t.scaleLabelWidth,i.width=t.scaleWidth,i.height=15;const n=new s.fabric.Rect(i);return t.colorScheme===r.ColorSchemeEnum.ncbiblast?o.colorNcbiBlastGradient(n,0,t.scaleWidth):o.colorDefaultGradient(n,0,t.scaleWidth),n},e.drawLineAxis5Buckets=function(t,e,i,n,a,o,c){const h=Object.assign({},r.lineDefaults);h.top=c,h.stroke="black",h.strokeWidth=o.strokeWidth;const l=[t,c,a,c];h.left=t;const d=new s.fabric.Line(l,h),u=[t,c,t,c+4],b=new s.fabric.Line(u,h),f=[e,c,e,c+4];h.left=e;const p=new s.fabric.Line(f,h),g=[i,c,i,c+4];h.left=i;const m=new s.fabric.Line(g,h),S=[n,c,n,c+4];h.left=n;const x=new s.fabric.Line(S,h),v=[a,c,a,c+4];h.left=a;const w=new s.fabric.Line(v,h);return new s.fabric.Group([d,b,p,m,x,w],r.objectDefaults)},e.drawLineAxis6Buckets=function(t,e,i,n,a,o,c,h){const l=Object.assign({},r.lineDefaults);l.top=h,l.stroke="black",l.strokeWidth=c.strokeWidth;const d=[t,h,o,h];l.left=t;const u=new s.fabric.Line(d,l),b=[t,h,t,h+4],f=new s.fabric.Line(b,l),p=[e,h,e,h+4];l.left=e;const g=new s.fabric.Line(p,l),m=[i,h,i,h+4];l.left=i;const S=new s.fabric.Line(m,l),x=[n,h,n,h+4];l.left=n;const v=new s.fabric.Line(x,l),w=[a,h,a,h+4];l.left=a;const P=new s.fabric.Line(w,l),D=[o,h,o,h+4];l.left=o;const L=new s.fabric.Line(D,l);return new s.fabric.Group([u,f,g,S,v,P,L],r.objectDefaults)},e.drawScaleTick5LabelsGroup=function(t,e,i,n){const a=Object.assign({},r.textDefaults);a.top=n,a.fontSize=i.fontSize;let o="<"+t[1];a.left=i.scaleLabelWidth+e-3*o.length-72;const c=new s.fabric.Text(o,a);o=`${t[1]} - ${t[2]}`,a.left=i.scaleLabelWidth+2*e-3*o.length-72;const h=new s.fabric.Text(o,a);o=`${t[2]} - ${t[3]}`,a.left=i.scaleLabelWidth+3*e-3*o.length-72;const l=new s.fabric.Text(o,a);o=`${t[3]} - ${t[4]}`,a.left=i.scaleLabelWidth+4*e-3*o.length-72;const d=new s.fabric.Text(o,a);o="≥"+t[4],a.left=i.scaleLabelWidth+i.scaleWidth-3*o.length-72;const u=new s.fabric.Text(o,a);return new s.fabric.Group([c,h,l,d,u],r.objectDefaults)},e.drawScaleTick4LabelsGroup=function(t,e,i,a){const o=Object.assign({},r.textDefaults);o.top=a,o.fontSize=i.fontSize,o.left=i.scaleLabelWidth-3*n.numberToString(t[0]).length;const c=new s.fabric.Text(n.numberToString(t[0]),o);o.left=i.scaleLabelWidth+e-3*n.numberToString(t[1]).length;const h=new s.fabric.Text(n.numberToString(t[1]),o);o.left=i.scaleLabelWidth+2*e-3*n.numberToString(t[2]).length;const l=new s.fabric.Text(n.numberToString(t[2]),o);o.left=i.scaleLabelWidth+3*e-3*n.numberToString(t[3]).length;const d=new s.fabric.Text(n.numberToString(t[3]),o);o.left=i.scaleLabelWidth+i.scaleWidth-3*n.numberToString(t[4]).length;const u=new s.fabric.Text(n.numberToString(t[4]),o);return new s.fabric.Group([c,h,l,d,u],r.objectDefaults)},e.drawFooterText=function(t,e){const i=Object.assign({},r.textDefaults);return i.fontSize=t.fontSize,i.evented=!0,i.top=e,i.left=225,[new s.fabric.Text("European Bioinformatics Institute 2006-2020. EBI is an Outstation of the European Molecular Biology Laboratory.",i),i]},e.drawCanvasWrapperStroke=function(t){return new s.fabric.Rect({selectable:!1,evented:!1,objectCaching:!1,top:0,left:0,width:t.canvasWidth-1,height:t.canvasHeight-1,strokeWidth:1,stroke:"lightseagreen",fill:"transparent"})},e.drawContentTitleText=function(t,e){const i=Object.assign({},r.textDefaults);return i.fontWeight="bold",i.fontSize=t.fontSize+2,i.top=e,i.left=350,new s.fabric.Text("Fast Family and Domain Prediction by InterPro",i)},e.drawContentSupressText=function(t,e,i){const n=Object.assign({},r.textDefaults);n.fontSize=t.fontSize,n.top=e,n.left=t.contentWidth/2,n.fill="red";const a=`This is a partial representation of the result, only the first ${i} hits are displayed!`;return new s.fabric.Text(""+a,n)},e.drawProteinFeaturesText=function(t,e){const i=Object.assign({},r.textDefaults);return i.fontSize=t.fontSize+1,i.fontWeight="bold",i.top=e,i.left=t.scaleLabelWidth-10,new s.fabric.Text("Select your database:",i)},e.drawDomainCheckbox=function(t,e,i,n){const a=Object.assign({},r.rectDefaults);a.top=e,a.left=i,a.height=15,a.width=15,a.evented=!0;const o=Object.assign({},r.textDefaults);return o.fontSize=t.fontSize+1,o.top=e,o.left=i+20,t.currentDisabled?(o.fill="grey",a.fill="white",a.stroke="grey"):void 0!==t.currentDomainDatabase?(a.fill=c.colorByDatabaseName(t.currentDomainDatabase),a.stroke="black"):(a.fill="white",a.stroke="grey"),[new s.fabric.Rect(a),new s.fabric.Text(n,o),a,a]},e.drawHitTransparentBox=function(t,e,i,n,a){const o=Object.assign({},r.rectDefaults);return o.fill=n,o.opacity=.5,o.rx=5,o.ry=5,o.top=i+15,o.left=t,o.width=e,o.height=a,new s.fabric.Rect(o)},e.drawContentDomainInfoText=function(t,e,i){const n=Object.assign({},r.textDefaults);n.fontFamily="Menlo",n.fontSize=e.fontSize-2,n.top=i-5;const a=" ".repeat(40-t.length),o=new s.fabric.Text(a,n);let c=""+t,h=`${a}${t}`;return h.length>40&&(c=(h.slice(0,38)+"...").slice(a.length)),n.left=12+6*a.length,n.evented=!0,[o,new s.fabric.Text(c,n),n]},e.drawDomains=function(t,e,i,n){const a=Object.assign({},r.rectDefaults);return a.evented=!0,a.top=i,a.fill=n,a.rx=5,a.ry=5,a.top=i-15,a.left=t,a.width=e,a.height=10,a.stroke="black",a.strokeWidth=.5,new s.fabric.Rect(a)},e.drawDomainInfoTooltips=function(t,e,i,n,a,o,c){const h=Object.assign({},r.textDefaults);h.fontSize=o.fontSize+1,h.textAlign="left",h.originX="top",h.originY="top",h.top=5,h.left=10,h.width=200;let l=`Start: ${i}\nEnd: ${n}\nDatabase: ${a.dbname}\n`;void 0!==a.altid&&void 0!==a.altname?l+=`ID: ${a.altid}\nName: ${a.altname}\nType: ${a.type}\nIPR ID: ${a.id}\nIPR Name: ${a.name}\n`:l+=`ID: ${a.id}\nName: ${a.name}\nType: ${a.type}\n`;const d=new s.fabric.Textbox(l,h),u=Object.assign({},r.rectDefaults);u.fill="white",u.stroke="lightseagreen",u.rx=5,u.ry=5,u.originX="top",u.originY="top",u.width=d.width+40,u.height=d.height,u.opacity=.95;const b=new s.fabric.Rect(u);return new s.fabric.Group([b,d],{selectable:!1,evented:!1,objectCaching:!1,visible:!1,top:c,left:t+e/2})},e.drawURLInfoTooltip=function(t,e,i,n,a){const o=Object.assign({},r.textDefaults);let c;if(o.fontSize=n.fontSize+1,o.originX="left",o.originY="top",o.top=5,o.left=5,e.length>150&&(e=e.slice(0,150)+"..."),""!==e){const t=6.3*e.length,n=6.3*i.length;o.width=t>n?t+5:n+5,c=new s.fabric.Text(e+"\n"+i,o)}else{const t=6.3*i.length;o.width=t+5,c=new s.fabric.Text(""+i,o)}const h=Object.assign({},r.rectDefaults);h.fill="white",h.stroke="lightseagreen",h.strokeWidth=.5,h.rx=5,h.ry=5,h.originX="left",h.originY="top",h.width=c.width+10,h.height=c.height+10,h.opacity=.95;const l=new s.fabric.Rect(h),d=new s.fabric.Group([l,c],{selectable:!1,evented:!1,objectCaching:!1,visible:!0,top:a,originX:"left"});return d.left=t+10,d}},function(t,e){t.exports=require("fabric")},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mouseOutDomainCheckbox=e.mouseDownDomainCheckbox=e.mouseOverDomainCheckbox=e.mouseOutCheckbox=e.mouseDownCheckbox=e.mouseOverCheckbox=e.mouseOutDomain=e.mouseOverDomain=e.mouseOutText=e.mouseDownText=e.mouseOverText=void 0;const s=i(5);e.mouseOverText=function(t,e,i,n,a,o){t.on("mouseover",r=>{if(r.target){r.target.set("hoverCursor","pointer"),r.target.setOptions(e),r.target.setOptions({underline:!0});const c=s.drawURLInfoTooltip(+t.left,i,n,a,+t.top+15);o.canvas.add(c),o.canvas.renderAll(),c.visible=!1}})},e.mouseDownText=function(t,e,i){t.on("mousedown",t=>{t.target&&(window.open(e,"_blank"),i.canvas.renderAll())})},e.mouseOutText=function(t,e,i){t.on("mouseout",t=>{t.target&&(t.target.setOptions(e),t.target.setOptions({underline:!1}),i.canvas.renderAll())})},e.mouseOverDomain=function(t,e,i,n,a,o,r,c){t.on("mouseover",h=>{if(h.target){let l;h.target.set("hoverCursor","pointer"),l="hsp_hit_from"in o?s.drawDomainTooltips(e,i,n,a,o,r,t.top+5):s.drawDomainInfoTooltips(e,i,n,a,o,r,t.top+5),c.canvas.add(l),l.set({visible:!0}),t.bringToFront(),l.bringToFront(),c.canvas.renderAll(),l.set({visible:!1})}})},e.mouseOutDomain=function(t,e){t.on("mouseout",t=>{t.target&&e.canvas.renderAll()})},e.mouseOverCheckbox=function(t,e,i){t.on("mouseover",t=>{t.target&&(t.target.set("hoverCursor","pointer"),t.target.setOptions(e),t.target.setOptions({fill:"black"}),i.canvas.renderAll())})},e.mouseDownCheckbox=function(t,e,i){t.on("mousedown",t=>{t.target&&i.colorScheme!=e&&(i.colorScheme=e,i.render())})},e.mouseOutCheckbox=function(t,e,i,s){t.on("mouseout",t=>{t.target&&(t.target.setOptions(e),s.colorScheme!=i&&t.target.setOptions({fill:"grey"}),s.canvas.renderAll())})},e.mouseOverDomainCheckbox=function(t,e,i,s){t.on("mouseover",t=>{if(t.target){t.target.set("hoverCursor","pointer"),t.target.setOptions(e);let n=!1;s.uniqueDomainDatabases.includes(i)||(n=!0),n?(t.target.setOptions({fill:"white",stroke:"grey"}),t.target.set("hoverCursor","default")):s.domainDatabaseList.includes(i)?(t.target.setOptions({opacity:.5,stroke:"grey"}),t.target.set("hoverCursor","pointer")):(t.target.setOptions({stroke:"black"}),t.target.set("hoverCursor","pointer")),s.canvas.renderAll()}})},e.mouseDownDomainCheckbox=function(t,e,i){t.on("mousedown",t=>{if(t.target)if(!i.domainDatabaseList.includes(e)&&i.uniqueDomainDatabases.includes(e))i.domainDatabaseList.push(e),i.currentDomainDatabase=e,i.render();else if(i.uniqueDomainDatabases.includes(e)){const t=i.domainDatabaseList.indexOf(e);t>-1&&i.domainDatabaseList.splice(t,1),i.currentDomainDatabase=void 0,i.render()}})},e.mouseOutDomainCheckbox=function(t,e,i,s){t.on("mouseout",t=>{if(t.target){let n=!1;s.uniqueDomainDatabases.includes(i)||(n=!0),s.domainDatabaseList.includes(i)?n?t.target.setOptions({stroke:"grey",fill:"white"}):(t.target.setOptions(e),t.target.setOptions({opacity:1,stroke:"black"})):t.target.setOptions({stroke:"grey",fill:"white"}),s.canvas.renderAll()}})}},function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)"default"!==i&&Object.hasOwnProperty.call(t,i)&&s(e,t,i);return n(e,t),e},o=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{c(s.next(t))}catch(t){a(t)}}function r(t){try{c(s.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}c((s=s.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const c=r(i(9)),h=r(i(10)),l=r(i(11)),d=i(12),u=i(13),b=a(i(14)),f=a(i(15)),p=i(16),g=i(19),m=i(0),S=i(1);function x(t,e){return o(this,void 0,void 0,(function*(){const i=u.promisify(b.writeFile);return fetch(t).then(t=>t.arrayBuffer()).then(t=>i(e,Buffer.from(t))).catch(t=>{console.log(t),process.exit()})}))}function v(t,e){return"json"===e?JSON.parse(b.readFileSync(t,"utf8")):b.readFileSync(t,"utf8")}c.default(),d.program.version("0.0.1").description("Generate Static Images with jdispatcher-viewers-cli").option("-vo, --visout","generate Visual Output").option("-fp, --funcpred","generate Functional Predictions").option("-i, --in ","jobID or URL/URI path to JSON (for VO and FP)").option("-ix, --inx ","URL/URI path to XML (for FP)").option("-o, --out ","file name used for output").option("-of, --outformat ","output format [png]").option("-v, --verbose","Verbose [false]").action((function(){return o(this,void 0,void 0,(function*(){if(process.argv.slice(2).length){let t,e,i,s,n;if(d.program.verbose&&(console.log("Running jdispatcher-viewers-cli..."),console.log("Your options were:"),console.log(process.argv)),d.program.visout||d.program.funcpred||(console.log("'--funcpred' or '--visout' is required!"),process.exit()),(d.program.visout||d.program.funcpred)&&(d.program.in||(console.log("Input data required!"),process.exit()),d.program.out||(console.log("Output file required!"),process.exit())),"mock_jobid-I20200317-103136-0485-5599422-np2"===d.program.in)t=f.join(process.cwd(),"./src/testdata/ncbiblast.json");else{const e=S.validateSubmittedJobIdInput(d.program.in);e.startsWith("http")?(t=f.join(process.cwd(),d.program.in+".json"),yield x(e,t),console.log(e),console.log(t)):t=f.isAbsolute(d.program.in)?d.program.in:f.join(process.cwd(),d.program.in)}if(b.existsSync(t)?(e=v(t,"json"),i=S.dataAsType(e,"SSSResultModel")):(console.log("JobID provided is not valid, or file not readable!"),process.exit()),void 0===i&&(console.log("Failed to get the SSS JSON data!"),process.exit()),d.program.visout){d.program.verbose&&console.log("Generating Visual Output...");let t={colorScheme:m.ColorSchemeEnum.dynamic,numberHits:100,numberHsps:10,logSkippedHsps:!0,canvasWrapperStroke:!0,staticCanvas:!0};s=new p.VisualOutput("canvas",i,t),s.render()}else if(d.program.funcpred){let e,n,a,o;if(d.program.verbose&&console.log("Generating Functional Predictions..."),"mock_jobid-I20200317-103136-0485-5599422-np2"===d.program.in)e=f.join(process.cwd(),"./src/testdata/iprmc.xml");else if(d.program.inx)e=f.isAbsolute(d.program.in)?d.program.inx:f.join(process.cwd(),d.program.inx);else{const t=S.validateSubmittedDbfetchInput(i);e=f.join(process.cwd(),d.program.in+".xml"),yield x(t,e)}b.existsSync(t)?(n=v(e,"xml"),a=S.getIPRMCDataModelFlatFromXML(n),o=S.dataAsType(a,"IPRMCResultModelFlat")):(console.log("XML file not readable!"),process.exit()),void 0===i&&(console.log("Failed to get the Dbfetch XML data!"),process.exit());let r={colorScheme:m.ColorSchemeEnum.dynamic,numberHits:30,canvasWrapperStroke:!0,staticCanvas:!0};s=new g.FunctionalPredictions("canvas",i,o,r),s.render()}d.program.verbose&&console.log(`Generating ${d.program.outformat.toUpperCase()} output...`),n=f.isAbsolute(d.program.out)?d.program.out:f.join(process.cwd(),d.program.out),"png"===d.program.outformat.toString().toLowerCase()?b.writeFileSync(n,s.canvas.toDataURL().replace("data:image/png;base64,",""),"base64"):"svg"===d.program.outformat.toString().toLowerCase()&&b.writeFileSync(n,s.canvas.toSVG().toString())}else console.log(h.default.green(l.default.textSync("jd-viewers-cli",{horizontalLayout:"default"}))),console.log(""),d.program.outputHelp()}))})).parseAsync(process.argv)},function(t,e){t.exports=require("clear")},function(t,e){t.exports=require("chalk")},function(t,e){t.exports=require("figlet")},function(t,e){t.exports=require("commander")},function(t,e){t.exports=require("util")},function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("path")},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VisualOutput=void 0;const s=i(2),n=i(3),a=i(4),o=i(1),r=i(0),c=i(7),h=i(5);let l=new o.ObjectCache;class d extends o.BasicCanvasRenderer{constructor(t,e,i){super(t),this.dataObj=e,this.topPadding=0,this.queryLen=0,this.subjLen=0,this.gradientSteps=[],this.queryFactor=1,this.subjFactor=1,null!=i.canvasWidth?this.canvasWidth=i.canvasWidth:this.canvasWidth=1e3,null!=i.canvasHeight?this.canvasHeight=i.canvasHeight:this.canvasHeight=110,null!=i.contentWidth?this.contentWidth=i.contentWidth:this.contentWidth=65.5*this.canvasWidth/100,null!=i.contentScoringWidth?this.contentScoringWidth=i.contentScoringWidth:this.contentScoringWidth=7*this.canvasWidth/100,null!=i.contentLabelWidth?this.contentLabelWidth=i.contentLabelWidth:this.contentLabelWidth=26.5*this.canvasWidth/100,null!=i.scaleWidth?this.scaleWidth=i.scaleWidth:this.scaleWidth=75*this.canvasWidth/100,null!=i.scaleLabelWidth?this.scaleLabelWidth=i.scaleLabelWidth:this.scaleLabelWidth=20*this.canvasWidth/100,null!=i.marginWidth?this.marginWidth=i.marginWidth:this.marginWidth=.15*this.canvasWidth/100,null!=i.colorScheme?this.colorScheme=i.colorScheme:this.colorScheme=r.ColorSchemeEnum.dynamic,null!=i.numberHits?this.numberHits=i.numberHits:this.numberHits=100,null!=i.numberHsps?this.numberHsps=i.numberHsps:this.numberHsps=10,null!=i.logSkippedHsps?this.logSkippedHsps=i.logSkippedHsps:this.logSkippedHsps=!0,null!=i.fontSize?this.fontSize=i.fontSize:this.fontSize=12,null!=i.fontWeigth?this.fontWeigth=i.fontWeigth:this.fontWeigth="normal",null!=i.fontFamily?this.fontFamily=i.fontFamily:this.fontFamily="Times New Roman",null!=i.canvasWrapperStroke?this.canvasWrapperStroke=i.canvasWrapperStroke:this.canvasWrapperStroke=!1,null!=i.staticCanvas?this.staticCanvas=i.staticCanvas:this.staticCanvas=!1,this.getFabricCanvas()}render(){this.loadInitalProperties(),this.loadInitialCoords(),this.canvas.clear(),this.drawHeaderGroup(),this.drawContentGroup(),this.drawFooterGroup(),this.wrapCanvas(),this.setFrameSize(),this.renderCanvas()}loadInitalProperties(){this.queryLen=this.dataObj.query_len;for(const t of this.dataObj.hits.slice(0,this.numberHits))t.hit_len>this.subjLen&&(this.subjLen=t.hit_len);const t=this.queryLen/this.subjLen,e=this.subjLen/this.queryLen;t>8&&(this.subjFactor=.5*this.queryLen/this.subjLen),e>8&&(this.queryFactor=.5*this.subjLen/this.queryLen)}loadInitialCoords(){this.startQueryPixels=l.get("startQueryPixels"),this.endQueryPixels=l.get("endQueryPixels"),this.startSubjPixels=l.get("startSubjPixels"),this.endSubjPixels=l.get("endSubjPixels"),this.startEvalPixels=l.get("startEvalPixels"),this.startQueryPixels||this.endQueryPixels||this.startSubjPixels||this.endSubjPixels||this.startEvalPixels||([this.startQueryPixels,this.endQueryPixels,this.startSubjPixels,this.endSubjPixels]=n.getQuerySubjPixelCoords(this.queryLen*this.queryFactor,this.subjLen*this.subjFactor,this.subjLen*this.subjFactor,this.contentWidth,this.contentScoringWidth,this.contentLabelWidth,this.marginWidth),this.startEvalPixels=this.endQueryPixels+2*this.marginWidth,l.put("startQueryPixels",this.startQueryPixels),l.put("endQueryPixels",this.endQueryPixels),l.put("startSubjPixels",this.startSubjPixels),l.put("endSubjPixels",this.endSubjPixels),l.put("startEvalPixels",this.startEvalPixels))}drawHeaderGroup(){let t,e,i;this.topPadding=2,t=l.get("textHeaderGroup"),t||(t=h.drawHeaderTextGroup(this.dataObj,{fontSize:this.fontSize,canvasWidth:this.canvasWidth},this.topPadding),l.put("textHeaderGroup",t)),this.canvas.add(t),this.topPadding+=45,e=l.get("textHeaderLink"),i=l.get("textHeaderLink_textSeqObj"),e||([e,i]=h.drawHeaderLinkText(this.dataObj,{fontSize:this.fontSize},this.topPadding),l.put("textHeaderLink",e),l.put("textHeaderLink_textSeqObj",i)),this.canvas.add(e),this.staticCanvas||null!==this.dataObj.query_url&&""!==this.dataObj.query_url&&(c.mouseOverText(e,i,this.dataObj.query_def,this.dataObj.query_url,{fontSize:this.fontSize},this),c.mouseDownText(e,this.dataObj.query_url,this),c.mouseOutText(e,i,this))}drawContentGroup(){if(this.dataObj.hits.length>0){let t,e,i;this.topPadding+=25,t=l.get("textContentHeaderGroup"),t||(t=h.drawContentHeaderTextGroup({queryLen:this.queryLen*this.queryFactor,subjLen:this.subjLen*this.subjFactor,startQueryPixels:this.startQueryPixels,startEvalPixels:this.startEvalPixels,startSubjPixels:this.startSubjPixels},{contentWidth:this.contentWidth,contentScoringWidth:this.contentScoringWidth,fontSize:this.fontSize,colorScheme:this.colorScheme},this.topPadding),l.put("textContentHeaderGroup",t)),this.canvas.add(t),this.topPadding+=20,e=l.get("lineTrackGroup"),e||(e=h.drawLineTracksQuerySubject({startQueryPixels:this.startQueryPixels,endQueryPixels:this.endQueryPixels,startSubjPixels:this.startSubjPixels,endSubjPixels:this.endSubjPixels},{strokeWidth:2},this.topPadding),l.put("lineTrackGroup",e)),this.canvas.add(e),this.topPadding+=5,i=l.get("textContentFooterGroup"),i||(i=h.drawContentQuerySubjFooterTextGroup({queryLen:this.queryLen,subjLen:this.subjLen,startQueryPixels:this.startQueryPixels,endQueryPixels:this.endQueryPixels,startSubjPixels:this.startSubjPixels,endSubjPixels:this.endSubjPixels},{fontSize:this.fontSize},this.topPadding),l.put("textContentFooterGroup",i)),this.canvas.add(i),this.topPadding+=25,this.drawDynamicContentGroup(),this.topPadding+=20,this.drawColorScaleGroup()}else{this.topPadding+=20;const t=h.drawNoHitsFoundText({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding);this.canvas.add(t)}}drawDynamicContentGroup(){let t=0,e=0;for(const i of this.dataObj.hits.slice(0,this.numberHits))i.hit_len>t&&(t=i.hit_len),i.hit_db.length+i.hit_id.length>e&&(e=i.hit_db.length+i.hit_id.length);let i=Number.MAX_VALUE,o=0,d=Number.MAX_VALUE;for(const t of this.dataObj.hits.slice(0,this.numberHits))for(const e of t.hit_hsps)this.colorScheme===r.ColorSchemeEnum.ncbiblast?(e.hsp_bit_scoreo&&(o=e.hsp_bit_score),e.hsp_bit_score0&&(d=e.hsp_bit_score)):(e.hsp_expecto&&(o=e.hsp_expect),e.hsp_expect0&&(d=e.hsp_expect));this.colorScheme,r.ColorSchemeEnum.ncbiblast,this.gradientSteps=a.getGradientSteps(i,o,d,this.colorScheme);let u=0;for(const t of this.dataObj.hits){if(u++,!(u<=this.numberHits)){let t;this.topPadding+=20,t=l.get("supressText"),t||(t=h.drawContentSupressText({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding,this.numberHits),l.put("supressText",t)),t.top=this.topPadding,this.canvas.add(t),this.topPadding+=20;break}{let i=0;const o=t.hit_hsps.length;let d,u,b;[u,b,d]=h.drawContentSequenceInfoText(e,t,{fontSize:this.fontSize},this.topPadding),this.canvas.add(u),this.canvas.add(b),this.staticCanvas||(c.mouseOverText(b,d,t.hit_def,t.hit_url,{fontSize:this.fontSize},this),c.mouseDownText(b,t.hit_url,this),c.mouseOutText(b,d,this));for(const e of t.hit_hsps){if(i++,!(i<=this.numberHsps)){if(!0===this.logSkippedHsps){let t;t=l.get("hspTextNotice"),t||(t=h.drawHspNoticeText(o,this.numberHsps,{fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding),l.put("hspTextNotice",t)),this.canvas.add(t),this.topPadding+=20}break}{const i=t.hit_len;let o,l,d,u;[o,l,d,u]=n.getQuerySubjPixelCoords(this.queryLen*this.queryFactor,this.subjLen*this.subjFactor,i,this.contentWidth,this.contentScoringWidth,this.contentLabelWidth,this.marginWidth),this.topPadding+=5;const b=h.drawLineTracksQuerySubject({startQueryPixels:o,endQueryPixels:l,startSubjPixels:d,endSubjPixels:u},{strokeWidth:1},this.topPadding);let f,p,g,m,S,x,v,w,P,D,L;this.canvas.add(b),"-1"===e.hsp_query_frame?(S=e.hsp_query_to,x=e.hsp_query_from):(S=e.hsp_query_from,x=e.hsp_query_to),"-1"===e.hsp_hit_frame?(v=e.hsp_hit_to,w=e.hsp_hit_from):(v=e.hsp_hit_from,w=e.hsp_hit_to),[f,p]=n.getDomainPixelCoords(o,l,this.queryLen,S,x,this.marginWidth),[g,m]=n.getDomainPixelCoords(d,u,i,v,w,this.marginWidth),P=this.colorScheme===r.ColorSchemeEnum.ncbiblast?a.getRgbColorFixed(e.hsp_bit_score,this.gradientSteps,s.ncbiBlastGradient):a.getRgbColorGradient(e.hsp_expect,this.gradientSteps,s.defaultGradient),this.topPadding+=10,[D,L]=h.drawDomainQueySubject(f,p,g,m,this.topPadding,P),this.canvas.add(D),this.canvas.add(L);const T=h.drawScoreText(this.startEvalPixels,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this.topPadding);T.width=this.contentScoringWidth,this.canvas.add(T),this.staticCanvas||(c.mouseOverDomain(D,f,p,S,x,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this),c.mouseOutDomain(D,this),c.mouseOverDomain(L,g,m,v,w,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this),c.mouseOutDomain(L,this))}}}}}drawColorScaleGroup(){const t=h.drawScaleTypeText({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);let e,i,s,n,a,o,l,d,u;this.canvas.add(t),[n,a,e,o,l,i,d,u,s]=h.drawCheckBoxText({colorScheme:this.colorScheme,fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding),this.canvas.add(n),this.canvas.add(a),this.staticCanvas||(c.mouseOverCheckbox(n,e,this),c.mouseOutCheckbox(n,e,r.ColorSchemeEnum.dynamic,this),c.mouseDownCheckbox(n,r.ColorSchemeEnum.dynamic,this)),this.canvas.add(o),this.canvas.add(l),this.staticCanvas||(c.mouseOverCheckbox(o,i,this),c.mouseOutCheckbox(o,i,r.ColorSchemeEnum.fixed,this),c.mouseDownCheckbox(o,r.ColorSchemeEnum.fixed,this)),this.canvas.add(d),this.canvas.add(u),this.staticCanvas||(c.mouseOverCheckbox(d,s,this),c.mouseOutCheckbox(d,s,r.ColorSchemeEnum.ncbiblast,this),c.mouseDownCheckbox(d,r.ColorSchemeEnum.ncbiblast,this)),this.topPadding+=25;const b=h.drawScaleScoreText({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);this.canvas.add(b);const f=h.drawScaleColorGradient({scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);if(this.canvas.add(f),this.colorScheme===r.ColorSchemeEnum.ncbiblast){const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/5;this.topPadding+=15;const e=h.drawLineAxis6Buckets(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+4*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=h.drawScaleTick5LabelsGroup(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}else{const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/4;this.topPadding+=15;const e=h.drawLineAxis5Buckets(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=h.drawScaleTick4LabelsGroup(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}}drawFooterGroup(){let t,e;this.topPadding+=30,t=l.get("copyrightText"),e=l.get("copyrightText_textFooterObj"),t||e||([t,e]=h.drawFooterText({fontSize:this.fontSize},this.topPadding),l.put("copyrightText",t),l.put("copyrightText_textFooterObj",e)),this.canvas.add(t)}wrapCanvas(){if(this.topPadding+=20,this.canvasHeight=this.topPadding,this.canvasWrapperStroke){const t=h.drawCanvasWrapperStroke({canvasWidth:this.canvasWidth,canvasHeight:this.canvasHeight});this.canvas.add(t)}}}e.VisualOutput=d},function(t,e){t.exports=require("xml-js")},function(t,e){t.exports=require("node-fetch")},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FunctionalPredictions=void 0;const s=i(3),n=i(4),a=i(2),o=i(1),r=i(0),c=i(7),h=i(5),l=["PRODOM","CATH-Gene3D","CDD","PANTHER","HAMAP","Pfam","PIRSF","PRINTS","PROSITE profiles","PROSITE patterns","SFLD","SMART","SUPERFAMILY","TIGRFAMs"];function d(t,e,i,s,n,a){let o,r,l,d;t.domainDatabaseList.includes(e)?t.currentDomainDatabase=e:t.currentDomainDatabase=void 0,t.currentDomainDatabaseDisabled=!1,i.includes(e)||(t.currentDomainDatabaseDisabled=!0),[l,d,o,r]=h.drawDomainCheckbox({currentDomainDatabase:t.currentDomainDatabase,currentDisabled:t.currentDomainDatabaseDisabled,fontSize:a.fontSize},s,n,e),t.canvas.add(l),t.canvas.add(d),a.staticCanvas||(c.mouseOverDomainCheckbox(l,o,e,t),c.mouseOutDomainCheckbox(l,o,e,t),c.mouseDownDomainCheckbox(l,e,t))}let u=new o.ObjectCache;class b extends o.BasicCanvasRenderer{constructor(t,e,i,s,n=l){super(t),this.sssDataObj=e,this.iprmcDataObj=i,this.domainDatabaseList=n,this.topPadding=0,this.queryStart=0,this.queryEnd=0,this.gradientSteps=[],this.uniqueDomainDatabases=[],this.currentDomainDatabaseDisabled=!1,null!=s.canvasWidth?this.canvasWidth=s.canvasWidth:this.canvasWidth=1e3,null!=s.canvasHeight?this.canvasHeight=s.canvasHeight:this.canvasHeight=110,null!=s.contentWidth?this.contentWidth=s.contentWidth:this.contentWidth=72.5*this.canvasWidth/100,null!=s.contentLabelWidth?this.contentLabelWidth=s.contentLabelWidth:this.contentLabelWidth=26.5*this.canvasWidth/100,null!=s.contentLabelLeftWidth?this.contentLabelLeftWidth=s.contentLabelLeftWidth:this.contentLabelLeftWidth=8.25*this.canvasWidth/100,null!=s.scaleWidth?this.scaleWidth=s.scaleWidth:this.scaleWidth=75*this.canvasWidth/100,null!=s.scaleLabelWidth?this.scaleLabelWidth=s.scaleLabelWidth:this.scaleLabelWidth=20*this.canvasWidth/100,null!=s.marginWidth?this.marginWidth=s.marginWidth:this.marginWidth=.15*this.canvasWidth/100,null!=s.colorScheme?this.colorScheme=s.colorScheme:this.colorScheme=r.ColorSchemeEnum.dynamic,null!=s.numberHits?this.numberHits=s.numberHits:this.numberHits=30,null!=s.fontSize?this.fontSize=s.fontSize:this.fontSize=12,null!=s.fontWeigth?this.fontWeigth=s.fontWeigth:this.fontWeigth="normal",null!=s.fontFamily?this.fontFamily=s.fontFamily:this.fontFamily="Times New Roman",null!=s.canvasWrapperStroke?this.canvasWrapperStroke=s.canvasWrapperStroke:this.canvasWrapperStroke=!1,null!=s.staticCanvas?this.staticCanvas=s.staticCanvas:this.staticCanvas=!1,this.getFabricCanvas()}render(){this.loadIPRMCProperties(),this.loadInitalProperties(),this.loadInitialCoords(),this.canvas.clear(),this.drawHeaderGroup(),this.drawContentGroup(),this.drawFooterGroup(),this.wrapCanvas(),this.setFrameSize(),this.renderCanvas()}loadInitalProperties(){this.queryStart=1,this.queryEnd=this.sssDataObj.query_len}loadInitialCoords(){this.startPixels=u.get("startPixels"),this.endPixels=u.get("endPixels"),this.startPixels||this.endPixels||([this.startPixels,this.endPixels]=s.getPixelCoords(this.contentWidth,this.contentLabelWidth,this.marginWidth),u.put("startPixels",this.startPixels),u.put("endPixels",this.endPixels))}loadIPRMCProperties(){if(null!=this.sssDataObj){if(this.uniqueDomainDatabases=u.get("uniqueDomainDatabases"),!this.uniqueDomainDatabases){let t=[];for(const e of this.sssDataObj.hits.slice(0,this.numberHits))t.push(e.hit_acc);this.uniqueDomainDatabases=o.getUniqueIPRMCDomainDatabases(this.iprmcDataObj,t),u.put("uniqueDomainDatabases",this.uniqueDomainDatabases)}for(const t of this.domainDatabaseList)if(!this.uniqueDomainDatabases.includes(o.domainDatabaseNameToString(t))){const e=this.domainDatabaseList.indexOf(t);e>-1&&this.domainDatabaseList.splice(e,1)}}}drawHeaderGroup(){let t,e,i;this.topPadding=2,t=u.get("textHeaderGroup"),t||(t=h.drawHeaderTextGroup(this.sssDataObj,{fontSize:this.fontSize,canvasWidth:this.canvasWidth},this.topPadding),u.put("textHeaderGroup",t)),this.canvas.add(t),this.topPadding+=45,e=u.get("textHeaderLink"),i=u.get("textHeaderLink_textSeqObj"),e||([e,i]=h.drawHeaderLinkText(this.sssDataObj,{fontSize:this.fontSize},this.topPadding),u.put("textHeaderLink",e),u.put("textHeaderLink_textSeqObj",i)),this.canvas.add(e),this.staticCanvas||null!=this.sssDataObj.query_url&&""!==this.sssDataObj.query_url&&(c.mouseOverText(e,i,this.sssDataObj.query_def,this.sssDataObj.query_url,{fontSize:this.fontSize},this),c.mouseDownText(e,this.sssDataObj.query_url,this),c.mouseOutText(e,i,this))}drawContentGroup(){let t;if(this.topPadding+=25,t=u.get("titleText"),t||(t=h.drawContentTitleText({fontSize:this.fontSize+1},this.topPadding),u.put("titleText",t)),this.canvas.add(t),this.sssDataObj.hits.length>0)this.topPadding+=35,this.drawPredictionsGroup(),this.topPadding+=50,this.drawDynamicContentGroup(),this.drawColorScaleGroup();else{this.topPadding+=20;const t=h.drawNoHitsFoundText({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding);this.canvas.add(t)}}drawPredictionsGroup(){let t;t=u.get("pfLabelText"),t||(t=h.drawProteinFeaturesText({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth-50},this.topPadding),u.put("pfLabelText",t)),this.canvas.add(t),d(this,"Pfam",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+190,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"SUPERFAMILY",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+260,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"SMART",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+390,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"HAMAP",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+480,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"PANTHER",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+570,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"PRODOM",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+680,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"PROSITE profiles",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+770,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),this.topPadding+=30,d(this,"CDD",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+190,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"CATH-Gene3D",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+260,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"PIRSF",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+390,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"PRINTS",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+480,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"TIGRFAMs",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+570,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"SFLD",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+680,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),d(this,"PROSITE patterns",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+770,{fontSize:this.fontSize,staticCanvas:this.staticCanvas})}drawDynamicContentGroup(){let t=0;for(const e of this.sssDataObj.hits.slice(0,this.numberHits))e.hit_db.length+e.hit_id.length>t&&(t=e.hit_db.length+e.hit_id.length);let e=Number.MAX_VALUE,i=0,l=Number.MAX_VALUE;for(const t of this.sssDataObj.hits.slice(0,this.numberHits))for(const s of t.hit_hsps)this.colorScheme===r.ColorSchemeEnum.ncbiblast?(s.hsp_bit_scorei&&(i=s.hsp_bit_score),s.hsp_bit_score0&&(l=s.hsp_bit_score)):(s.hsp_expecti&&(i=s.hsp_expect),s.hsp_expect0&&(l=s.hsp_expect));this.colorScheme,r.ColorSchemeEnum.ncbiblast,this.gradientSteps=n.getGradientSteps(e,i,l,this.colorScheme);let d=0;for(const e of this.sssDataObj.hits){if(d++,!(d<=this.numberHits)){let t;t=u.get("supressText"),t||(t=h.drawContentSupressText({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding,this.numberHits),u.put("supressText",t)),t.top=this.topPadding,this.canvas.add(t),this.topPadding+=40;break}{let i,l,d;[l,d,i]=h.drawContentSequenceInfoText(t,e,{fontSize:this.fontSize},this.topPadding),this.canvas.add(l),this.canvas.add(d),this.staticCanvas||(c.mouseOverText(d,i,e.hit_def,e.hit_url,{fontSize:this.fontSize},this),c.mouseDownText(d,e.hit_url,this),c.mouseOutText(d,i,this));const u=h.drawLineTracks({startPixels:this.startPixels,endPixels:this.endPixels},{strokeWidth:1},this.topPadding);this.canvas.add(u),this.topPadding+=5;const b=h.drawContentFooterTextGroup({start:this.queryStart,end:e.hit_len,startPixels:this.startPixels,endPixels:this.endPixels},{fontSize:this.fontSize},this.topPadding);this.canvas.add(b),this.topPadding+=15;let f="white",p=0,g=0;for(const t of e.hit_hsps){"-1"===t.hsp_hit_frame?(p=t.hsp_hit_to,g=t.hsp_hit_from):(p=t.hsp_hit_from,g=t.hsp_hit_to),f=this.colorScheme===r.ColorSchemeEnum.ncbiblast?n.getRgbColorFixed(t.hsp_bit_score,this.gradientSteps,a.ncbiBlastGradient):n.getRgbColorGradient(t.hsp_expect,this.gradientSteps,a.defaultGradient);break}let m=0,S=0;[m,S]=s.getDomainPixelCoords(this.startPixels,this.endPixels,e.hit_len,p,g,this.marginWidth);let x=0,v=this.topPadding-15;if(e.hit_acc in this.iprmcDataObj&&void 0!==this.iprmcDataObj[e.hit_acc].matches)for(const t of this.iprmcDataObj[e.hit_acc].matches){const i=o.domainDatabaseNameToString(this.iprmcDataObj[e.hit_acc].match[t][0].dbname);if(this.domainDatabaseList.includes(i)){this.topPadding+=15,x+=15;let a,r,l,d=h.drawDomainLineTracks({startPixels:this.startPixels,endPixels:this.endPixels},{strokeWidth:1,strokeDashArray:[1,5]},this.topPadding);this.canvas.add(d),d.sendToBack(),[r,l,a]=h.drawContentDomainInfoText(t.split("_")[1]+" ►",{fontSize:this.fontSize},this.topPadding),this.canvas.add(r),this.canvas.add(l);const u=o.getDomainURLbyDatabase(t.split("_")[1],i);this.staticCanvas||(c.mouseOverText(l,a,"",u,{fontSize:this.fontSize},this),c.mouseDownText(l,u,this),c.mouseOutText(l,a,this));for(const i of this.iprmcDataObj[e.hit_acc].match[t]){let t=i.start,a=i.end,o=0,r=0;[o,r]=s.getDomainPixelCoords(this.startPixels,this.endPixels,e.hit_len,t,a,this.marginWidth);const l=h.drawDomains(o,r,this.topPadding+10,n.colorByDatabaseName(i.dbname));this.canvas.add(l),this.staticCanvas||(c.mouseOverDomain(l,o,r,t,a,i,{fontSize:this.fontSize},this),c.mouseOutDomain(l,this))}}}x+=15;const w=h.drawHitTransparentBox(m,S,v,f,x);this.canvas.add(w),w.sendToBack(),this.topPadding+=40}}}drawColorScaleGroup(){const t=h.drawScaleTypeText({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);let e,i,s,n,a,o,l,d,u;this.canvas.add(t),[n,a,e,o,l,i,d,u,s]=h.drawCheckBoxText({colorScheme:this.colorScheme,fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding),this.canvas.add(n),this.canvas.add(a),this.staticCanvas||(c.mouseOverCheckbox(n,e,this),c.mouseOutCheckbox(n,e,r.ColorSchemeEnum.dynamic,this),c.mouseDownCheckbox(n,r.ColorSchemeEnum.dynamic,this)),this.canvas.add(o),this.canvas.add(l),this.staticCanvas||(c.mouseOverCheckbox(o,i,this),c.mouseOutCheckbox(o,i,r.ColorSchemeEnum.fixed,this),c.mouseDownCheckbox(o,r.ColorSchemeEnum.fixed,this)),this.canvas.add(d),this.canvas.add(u),this.staticCanvas||(c.mouseOverCheckbox(d,s,this),c.mouseOutCheckbox(d,s,r.ColorSchemeEnum.ncbiblast,this),c.mouseDownCheckbox(d,r.ColorSchemeEnum.ncbiblast,this)),this.topPadding+=25;const b=h.drawScaleScoreText({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);this.canvas.add(b);const f=h.drawScaleColorGradient({scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);if(this.canvas.add(f),this.colorScheme===r.ColorSchemeEnum.ncbiblast){const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/5;this.topPadding+=15;const e=h.drawLineAxis6Buckets(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+4*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=h.drawScaleTick5LabelsGroup(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}else{const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/4;this.topPadding+=15;const e=h.drawLineAxis5Buckets(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=h.drawScaleTick4LabelsGroup(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}}drawFooterGroup(){let t,e;this.topPadding+=30,[t,e]=h.drawFooterText({fontSize:this.fontSize},this.topPadding),this.canvas.add(t)}wrapCanvas(){if(this.topPadding+=20,this.canvasHeight=this.topPadding,this.canvasWrapperStroke){const t=h.drawCanvasWrapperStroke({canvasWidth:this.canvasWidth,canvasHeight:this.canvasHeight});this.canvas.add(t)}}}e.FunctionalPredictions=b}]); \ No newline at end of file diff --git a/dist/jd_viewers_bundle_0.0.4.min.js b/dist/jd_viewers_bundle_0.0.4.min.js new file mode 100644 index 0000000..9b42a82 --- /dev/null +++ b/dist/jd_viewers_bundle_0.0.4.min.js @@ -0,0 +1,172 @@ +!function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=36)}([function(t,e,i){(function(t){ +/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ +var n,r,s,o,a,h,c,l,u,f,d,p,g,m,v,b,y,_,x,S,w,C=C||{version:"3.6.2"};if(e.fabric=C,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?C.document=document:C.document=document.implementation.createHTMLDocument(""),C.window=window;else{var T=new(i(41).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;C.document=T.document,C.jsdomImplForWrapper=i(42).implForWrapper,C.nodeCanvas=i(43).Canvas,C.window=T,DOMParser=C.window.DOMParser}function O(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function E(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,o);var h=new ImageData(a,n,r);i.putImageData(h,0,0)}C.isTouchSupported="ontouchstart"in C.window||"ontouchstart"in C.document||C.window&&C.window.navigator&&C.window.navigator.maxTouchPoints>0,C.isLikelyNode=void 0!==t&&"undefined"==typeof window,C.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],C.DPI=96,C.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",C.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,C.reNonWord=/[ \n\.,;!\?\-]/,C.fontPaths={},C.iMatrix=[1,0,0,1,0,0],C.svgNS="http://www.w3.org/2000/svg",C.perfLimitSizeTotal=2097152,C.maxCacheSideLimit=4096,C.minCacheSideLimit=256,C.charWidthsCache={},C.textureSize=2048,C.disableStyleCopyPaste=!1,C.enableGLFiltering=!0,C.devicePixelRatio=C.window.devicePixelRatio||C.window.webkitDevicePixelRatio||C.window.mozDevicePixelRatio||1,C.browserShadowBlurConstant=1,C.arcToSegmentsCache={},C.boundsOfCurveCache={},C.cachesBoundsOfCurve=!0,C.forceGLPutImageData=!1,C.initFilterBackend=function(){return C.enableGLFiltering&&C.isWebglSupported&&C.isWebglSupported(C.textureSize)?(console.log("max texture size: "+C.maxTextureSize),new C.WebglFilterBackend({tileSize:C.textureSize})):C.Canvas2dFilterBackend?new C.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=C),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:C.util.array.fill(i,!1)}}function e(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this}function i(e,i){if(!this.__eventListeners)return this;if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var n in e)t.call(this,n,e[n]);else t.call(this,e,i);return this}function n(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n-1},complexity:function(){return this._objects.reduce((function(t,e){return t+=e.complexity?e.complexity():0}),0)}},C.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof C.Gradient||this.set(e,new C.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof C.Pattern?i&&i():this.set(e,new C.Pattern(t,i))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var e=C.util.getFunctionBody(t.clipTo);void 0!==e&&(this.clipTo=new Function("ctx",e))}},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):"function"==typeof e&&"clipTo"!==t?this._set(t,e(this.get(t))):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,s=Math.atan2,o=Math.pow,a=Math.PI/180,h=Math.PI/2,C.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/h){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/h){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*a},radiansToDegrees:function(t){return t/a},rotatePoint:function(t,e,i){t.subtractEquals(e);var n=C.util.rotateVector(t,i);return new C.Point(n.x,n.y).addEquals(e)},rotateVector:function(t,e){var i=C.util.sin(e),n=C.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},transformPoint:function(t,e,i){return i?new C.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new C.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;ie;)(e+=a[d++%f])>l&&(e=l),t[p?"lineTo":"moveTo"](e,0),p=!p;t.restore()},createCanvasElement:function(){return C.document.createElement("canvas")},copyCanvasElement:function(t){var e=C.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},toDataURL:function(t,e,i){return t.toDataURL("image/"+e,i)},createImage:function(){return C.document.createElement("img")},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var e=s(t[1],t[0]),i=o(t[0],2)+o(t[1],2),n=r(i),h=(t[0]*t[3]-t[2]*t[1])/n,c=s(t[0]*t[2]+t[1]*t[3],i);return{angle:e/a,scaleX:n,scaleY:h,skewX:c/a,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return C.iMatrix.concat();var e=C.util.degreesToRadians(t.angle),i=C.util.cos(e),n=C.util.sin(e);return[i,n,-n,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,n=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],r=C.util.multiplyTransformMatrices,s=C.util.degreesToRadians;return t.skewX&&(n=r(n,[1,0,Math.tan(s(t.skewX)),1],!0)),t.skewY&&(n=r(n,[1,Math.tan(s(t.skewY)),0,1],!0)),n},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=C.util.multiplyTransformMatrices;return t.angle&&(e=i(e,C.util.calcRotateMatrix(t))),(t.scaleX||t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,C.util.calcDimensionsMatrix(t))),e},customTransformMatrix:function(t,e,i){return C.util.composeMatrix({scaleX:t,scaleY:e,skewX:i})},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},saveObjectTransform:function(t){return{scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,n){n>0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,o=t.getImageData(e,i,2*n||1,2*n||1),a=o.data.length;for(r=3;r0?D-=2*u:1===h&&D<0&&(D+=2*u);for(var L=Math.ceil(Math.abs(D/u*2)),F=[],M=D/L,I=8/3*Math.sin(M/4)*Math.sin(M/4)/Math.sin(M/2),R=A+M,B=0;B=r?s-r:2*Math.PI-(r-s)}function r(e,i,n,r,s,o,a,h){var c;if(C.cachesBoundsOfCurve&&(c=t.call(arguments),C.boundsOfCurveCache[c]))return C.boundsOfCurveCache[c];var l,u,f,d,p,g,m,v,b=Math.sqrt,y=Math.min,_=Math.max,x=Math.abs,S=[],w=[[],[]];u=6*e-12*n+6*s,l=-3*e+9*n-9*s+3*a,f=3*n-3*e;for(var T=0;T<2;++T)if(T>0&&(u=6*i-12*r+6*o,l=-3*i+9*r-9*o+3*h,f=3*r-3*i),x(l)<1e-12){if(x(u)<1e-12)continue;0<(d=-f/u)&&d<1&&S.push(d)}else(m=u*u-4*f*l)<0||(0<(p=(-u+(v=b(m)))/(2*l))&&p<1&&S.push(p),0<(g=(-u-v)/(2*l))&&g<1&&S.push(g));for(var O,E,P,j=S.length,k=j;j--;)O=(P=1-(d=S[j]))*P*P*e+3*P*P*d*n+3*P*d*d*s+d*d*d*a,w[0][j]=O,E=P*P*P*i+3*P*P*d*r+3*P*d*d*o+d*d*d*h,w[1][j]=E;w[0][k]=e,w[1][k]=i,w[0][k+1]=a,w[1][k+1]=h;var A=[{x:y.apply(null,w[0]),y:y.apply(null,w[1])},{x:_.apply(null,w[0]),y:_.apply(null,w[1])}];return C.cachesBoundsOfCurve&&(C.boundsOfCurveCache[c]=A),A}C.util.drawArc=function(t,i,n,r){for(var s=r[0],o=r[1],a=r[2],h=r[3],c=r[4],l=[[],[],[],[]],u=e(r[5]-i,r[6]-n,s,o,h,c,a),f=0,d=u.length;f=e}))}}}(),function(){function t(e,i,n){if(n)if(!C.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}C.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}C.util.createClass=function(){var i=null,o=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof o[0]&&(i=o.shift()),a.superclass=i,a.subclasses=[],i&&(r.prototype=i.prototype,a.prototype=new r,i.subclasses.push(a));for(var h=0,c=o.length;h=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(d,e)):i.filter+=" alpha(opacity="+100*e+")",t}),C.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?p(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?p(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t=Array.prototype.slice;var e,i,n,r,s=function(e){return t.call(e,0)};try{e=s(C.document.childNodes)instanceof Array}catch(t){}function o(t,e){var i=C.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function a(t){for(var e=0,i=0,n=C.document.documentElement,r=C.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===C.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}e||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),i=C.document.defaultView&&C.document.defaultView.getComputedStyle?function(t,e){var i=C.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},n=C.document.documentElement.style,r="userSelect"in n?"userSelect":"MozUserSelect"in n?"MozUserSelect":"WebkitUserSelect"in n?"WebkitUserSelect":"KhtmlUserSelect"in n?"KhtmlUserSelect":"",C.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=C.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},C.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},C.util.getScript=function(t,e){var i=C.document.getElementsByTagName("head")[0],n=C.document.createElement("script"),r=!0;n.onload=n.onreadystatechange=function(t){if(r){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;r=!1,e(t||C.window.event),n=n.onload=n.onreadystatechange=null}},n.src=t,i.appendChild(n)},C.util.getById=function(t){return"string"==typeof t?C.document.getElementById(t):t},C.util.toArray=s,C.util.makeElement=o,C.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},C.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=o(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},C.util.getScrollLeftTop=a,C.util.getElementOffset=function(t){var e,n,r=t&&t.ownerDocument,s={left:0,top:0},o={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return o;for(var c in h)o[h[c]]+=parseInt(i(t,c),10)||0;return e=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=a(t),{left:s.left+n.left-(e.clientLeft||0)+o.left,top:s.top+n.top-(e.clientTop||0)+o.top}},C.util.getElementStyle=i,C.util.getNodeCanvas=function(t){var e=C.jsdomImplForWrapper(t);return e._canvas||e._image},C.util.cleanUpJsdomNode=function(t){if(C.isLikelyNode){var e=C.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}C.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new C.window.XMLHttpRequest,o=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(o=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s}}(),C.log=console.log,C.warn=console.warn,function(){function t(){return!1}function e(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}var i=C.window.requestAnimationFrame||C.window.webkitRequestAnimationFrame||C.window.mozRequestAnimationFrame||C.window.oRequestAnimationFrame||C.window.msRequestAnimationFrame||function(t){return C.window.setTimeout(t,1e3/60)},n=C.window.cancelAnimationFrame||C.window.clearTimeout;function r(){return i.apply(C.window,arguments)}C.util.animate=function(i){r((function(n){i||(i={});var s,o=n||+new Date,a=i.duration||500,h=o+a,c=i.onChange||t,l=i.abort||t,u=i.onComplete||t,f=i.easing||e,d="startValue"in i?i.startValue:0,p="endValue"in i?i.endValue:100,g=i.byValue||p-d;i.onStart&&i.onStart(),function t(e){var i=(s=e||+new Date)>h?a:s-o,n=i/a,m=f(i,d,g,a),v=Math.abs((m-d)/g);if(!l())return s>h?(c(p,1,1),void u(p,1,1)):(c(m,v,n),void r(t));u(p,1,1)}(o)}))},C.util.requestAnimFrame=r,C.util.cancelAnimFrame=function(){return n.apply(C.window,arguments)}}(),C.util.animateColor=function(t,e,i,n){var r=new C.Color(t).getSource(),s=new C.Color(e).getSource();n=n||{},C.util.animate(C.util.object.extend(n,{duration:i||500,startValue:r,endValue:s,byValue:s,easing:function(t,e,i,r){var s,o,a,h,c=n.colorEasing?n.colorEasing(t,r):1-Math.cos(t/r*(Math.PI/2));return s=e,o=i,a=c,h="rgba("+parseInt(s[0]+a*(o[0]-s[0]),10)+","+parseInt(s[1]+a*(o[1]-s[1]),10)+","+parseInt(s[2]+a*(o[2]-s[2]),10),h+=","+(s&&o?parseFloat(s[3]+a*(o[3]-s[3])):1),h+=")"}}))},function(){function t(t,e,i,n){return t-1&&l>-1&&l-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t)return i;a=h?i.map(s):s(i,r)}else i="";return!h&&isNaN(a)?i:a}function u(t){return new RegExp("^("+t.join("|")+")\\b","i")}function f(t,e){var i,n,r,s,o=[];for(r=0,s=e.length;r1;)h.shift(),c=e.util.multiplyTransformMatrices(c,h[0]);return c}}();var m=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function v(t){var i,n,r,o,a,h,c=t.getAttribute("viewBox"),l=1,u=1,f=t.getAttribute("width"),d=t.getAttribute("height"),p=t.getAttribute("x")||0,g=t.getAttribute("y")||0,v=t.getAttribute("preserveAspectRatio")||"",b=!c||!e.svgViewBoxElementsRegEx.test(t.nodeName)||!(c=c.match(m)),y=!f||!d||"100%"===f||"100%"===d,_=b&&y,x={},S="",w=0,C=0;if(x.width=0,x.height=0,x.toBeParsed=_,_)return x;if(b)return x.width=s(f),x.height=s(d),x;if(i=-parseFloat(c[1]),n=-parseFloat(c[2]),r=parseFloat(c[3]),o=parseFloat(c[4]),x.minX=i,x.minY=n,x.viewBoxWidth=r,x.viewBoxHeight=o,y?(x.width=r,x.height=o):(x.width=s(f),x.height=s(d),l=x.width/r,u=x.height/o),"none"!==(v=e.util.parsePreserveAspectRatioAttribute(v)).alignX&&("meet"===v.meetOrSlice&&(u=l=l>u?u:l),"slice"===v.meetOrSlice&&(u=l=l>u?l:u),w=x.width-r*l,C=x.height-o*l,"Mid"===v.alignX&&(w/=2),"Mid"===v.alignY&&(C/=2),"Min"===v.alignX&&(w=0),"Min"===v.alignY&&(C=0)),1===l&&1===u&&0===i&&0===n&&0===p&&0===g)return x;if((p||g)&&(S=" translate("+s(p)+" "+s(g)+") "),a=S+" matrix("+l+" 0 0 "+u+" "+(i*l+w)+" "+(n*u+C)+") ",x.viewboxTransform=e.parseTransformAttribute(a),"svg"===t.nodeName){for(h=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)h.appendChild(t.firstChild);t.appendChild(h)}else a=(h=t).getAttribute("transform")+a;return h.setAttribute("transform",a),x}function b(t,e){var i=g(t,e.getAttribute("xlink:href").substr(1));if(i&&i.getAttribute("xlink:href")&&b(t,i),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){i&&!e.hasAttribute(t)&&i.hasAttribute(t)&&e.setAttribute(t,i.getAttribute(t))})),!e.children.length)for(var n=i.cloneNode(!0);n.firstChild;)e.appendChild(n.firstChild);e.removeAttribute("xlink:href")}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=f(t,["use","svg:use"]),n=0;i.length&&n/i,"")));if(!s||!s.documentElement)return i&&i(null),!1;e.parseSVGDocument(s.documentElement,(function(t,e,n,r){i&&i(t,e,n,r)}),n,r)}})},loadSVGFromString:function(t,i,n,r){var s;if(t=t.trim(),void 0!==e.window.DOMParser){var o=new e.window.DOMParser;o&&o.parseFromString&&(s=o.parseFromString(t,"text/xml"))}else e.window.ActiveXObject&&((s=new ActiveXObject("Microsoft.XMLDOM")).async="false",s.loadXML(t.replace(//i,"")));e.parseSVGDocument(s.documentElement,(function(t,e,n,r){i(t,e,n,r)}),n,r)}})}(e),C.ElementsParser=function(t,e,i,n,r,s){this.elements=t,this.callback=e,this.options=i,this.reviver=n,this.svgUid=i&&i.svgUid||0,this.parsingOptions=r,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=s},(g=C.ElementsParser.prototype).parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},g.createObjects=function(){var t=this;this.elements.forEach((function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)}))},g.findTag=function(t){return C[C.util.string.capitalize(t.tagName.replace("svg:",""))]},g.createObject=function(t,e){var i=this.findTag(t);if(i&&i.fromElement)try{i.fromElement(t,this.createCallback(e,t),this.options)}catch(t){C.log(t)}else this.checkIfDone()},g.createCallback=function(t,e){var i=this;return function(n){var r;i.resolveGradient(n,e,"fill"),i.resolveGradient(n,e,"stroke"),n instanceof C.Image&&n._originalElement&&(r=n.parsePreserveAspectRatioAttribute(e)),n._removeTransformMatrix(r),i.resolveClipPath(n,e),i.reviver&&i.reviver(e,n),i.instances[t]=n,i.checkIfDone()}},g.extractPropertyDefinition=function(t,e,i){var n=t[e],r=this.regexUrl;if(r.test(n)){r.lastIndex=0;var s=r.exec(n)[1];return r.lastIndex=0,C[i][this.svgUid][s]}},g.resolveGradient=function(t,e,i){var n=this.extractPropertyDefinition(t,i,"gradientDefs");if(n){var r=e.getAttribute(i+"-opacity"),s=C.Gradient.fromElement(n,t,r,this.options);t.set(i,s)}},g.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},g.resolveClipPath=function(t,e){var i,n,r,s,o=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(o){r=[],n=C.util.invertTransform(t.calcTransformMatrix());for(var a=o[0].parentNode,h=e;h.parentNode&&h.getAttribute("clip-path")!==t.clipPath;)h=h.parentNode;h.parentNode.appendChild(a);for(var c=0;ct.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var o,a=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),h=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),c=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==c){var l=a/c,u=h/c;0<=l&&l<=1&&0<=u&&u<=1?(o=new i("Intersection")).appendPoint(new e.Point(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y))):o=new i}else o=new i(0===a||0===h?"Coincident":"Parallel");return o},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,o,a,h=new i,c=n.length;for(a=0;a0&&(h.status="Intersection"),h},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),o=n.max(r),a=new e.Point(o.x,s.y),h=new e.Point(s.x,o.y),c=i.intersectLinePolygon(s,a,t),l=i.intersectLinePolygon(a,o,t),u=i.intersectLinePolygon(o,h,t),f=i.intersectLinePolygon(h,s,t),d=new i;return d.appendPoints(c.points),d.appendPoints(l.points),d.appendPoints(u.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,o,a=e.util.array.max([t,i,n]),h=e.util.array.min([t,i,n]);if(o=(a+h)/2,a===h)r=s=0;else{var c=a-h;switch(s=o>.5?c/(2-a-h):c/(a+h),a){case t:r=(i-n)/c+(i1?1:a,o){var h=o.split(/\s*;\s*/);for(""===h[h.length-1]&&h.pop(),s=h.length;s--;){var c=h[s].split(/\s*:\s*/),l=c[0].trim(),u=c[1].trim();"stop-color"===l?i=u:"stop-opacity"===l&&(r=u)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new C.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:a,color:i.toRgb(),opacity:r}}var e=C.util.object.clone;function i(t,e,i,n){var r,s;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?s=1:"-Infinity"===r?s=0:(s=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(s*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}C.Gradient=C.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+C.Object.__uid++:this.id=C.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new C.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return C.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,s,o,a=e(this.coords,!0),h=(i=i||{},e(this.colorStops,!0)),c=a.r1>a.r2,l=this.gradientTransform?this.gradientTransform.concat():C.iMatrix.concat(),u=-this.offsetX,f=-this.offsetY,d=!!i.additionalTransform,p="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(h.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===p?(u/=t.width,f/=t.height):(u+=t.width/2,f+=t.height/2),"path"===t.type&&(u-=t.pathOffset.x,f-=t.pathOffset.y),l[4]-=u,l[5]-=f,o='id="SVGID_'+this.id+'" gradientUnits="'+p+'"',o+=' gradientTransform="'+(d?i.additionalTransform+" ":"")+C.util.matrixToSVG(l)+'" ',"linear"===this.type?s=["\n']:"radial"===this.type&&(s=["\n']),"radial"===this.type){if(c)for((h=h.concat()).reverse(),n=0,r=h.length;n0){var m=g/Math.max(a.r1,a.r2);for(n=0,r=h.length;n\n')}return s.push("linear"===this.type?"\n":"\n"),s.join("")},toLive:function(t,e){var i,n,r,s=C.util.object.clone(this.coords),o=s.x1,a=s.y1,h=s.x2,c=s.y2,l=this.colorStops;if(this.type){for(e instanceof C.Text&&"percentage"===this.gradientUnits&&(o*=e.width,a*=e.height,h*=e.width,c*=e.height),"linear"===this.type?i=t.createLinearGradient(o,a,h,c):"radial"===this.type&&(i=t.createRadialGradient(o,a,s.r1,h,c,s.r2)),n=0,r=l.length;n1?1:o,isNaN(o)&&(o=1);var a,h,c,l,u=e.getElementsByTagName("stop"),f="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",d=e.getAttribute("gradientTransform")||"",p=[],g=0,m=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(a="linear",h=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(a="radial",h=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),c=u.length;c--;)p.push(t(u[c],o));return l=C.parseTransformAttribute(d),i(n,h,s,f),"pixels"===f&&(g=-n.left,m=-n.top),new C.Gradient({id:e.getAttribute("id"),type:a,coords:h,colorStops:p,gradientUnits:f,gradientTransform:l,offsetX:g,offsetY:m})},forObject:function(t,e){return e||(e={}),i(t,e.coords,e.gradientUnits,{viewBoxWidth:100,viewBoxHeight:100}),new C.Gradient(e)}})}(),function(){"use strict";var t=C.util.toFixed;C.Pattern=C.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=C.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else if(void 0!==C.util.getFunctionBody(t.source))this.source=new Function(C.util.getFunctionBody(t.source)),e&&e(this);else{var i=this;this.source=C.util.createImage(),C.util.loadImage(t.source,(function(t){i.source=t,e&&e(i)}),null,this.crossOrigin)}},toObject:function(e){var i,n,r=C.Object.NUM_FRACTION_DIGITS;return"function"==typeof this.source?i=String(this.source):"string"==typeof this.source.src?i=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(i=this.source.toDataURL()),n={type:"pattern",source:i,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:t(this.offsetX,r),offsetY:t(this.offsetY,r),patternTransform:this.patternTransform?this.patternTransform.concat():null},C.util.populateWithProperties(this,n,e),n},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,o="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,s&&(n+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?o=e.src:e.toDataURL&&(o=e.toDataURL()),'\n\n\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e="function"==typeof this.source?this.source():this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseInt(n[1],10)||0,offsetY:parseInt(n[2],10)||0,blur:parseInt(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(o.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(o.y)+this.blur)/t.height,s)+20),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){"use strict";if(C.StaticCanvas)C.warn("fabric.StaticCanvas is already defined.");else{var t=C.util.object.extend,e=C.util.getElementOffset,i=C.util.removeFromArray,n=C.util.toFixed,r=C.util.transformPoint,s=C.util.invertTransform,o=C.util.getNodeCanvas,a=C.util.createCanvasElement,h=new Error("Could not initialize `canvas` element");C.StaticCanvas=C.util.createClass(C.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:C.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,onBeforeScaleRotate:function(){},enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this._setImageSmoothing(),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return 1!==C.devicePixelRatio&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?C.devicePixelRatio:1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=C.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},_setImageSmoothing:function(){var t=this.getContext();t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=this.imageSmoothingEnabled},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?C.util.loadImage(e,(function(e){if(e){var r=new C.Image(e,n);this[t]=r,r.canvas=this}i&&i(e)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=a();if(!t)throw h;if(t.style||(t.style={}),void 0===t.getContext)throw h;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=C.util.getById(t)||this._createCanvasElement(),C.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(),this._initRetinaScaling(),this._setImageSmoothing(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject;for(this.viewportTransform=t,i=0,n=this._objects.length;i\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push(""),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('\n','\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,s=e.height||this.height,o='viewBox="0 0 '+this.width+" "+this.height+'" ',a=C.Object.NUM_FRACTION_DIGITS;e.viewBox?o='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,o='viewBox="'+n(-i[4]/i[0],a)+" "+n(-i[5]/i[3],a)+" "+n(this.width/i[0],a)+" "+n(this.height/i[3],a)+'" '),t.push("\n',"Created with Fabric.js ",C.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+C.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(t.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,s={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(s,{additionalTransform:n?C.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,s,o,a,h="",c={},l=C.fontPaths,u=this._objects;for(o=0,a=u.length;o',"\n",h,"","\n"].join("")),h},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n\n")}else t.push('\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(r=s._objects,e=0;e0+c&&(o=s-1,i(this._objects,r),this._objects.splice(o,0,r)),c++;else 0!==(s=this._objects.indexOf(t))&&(o=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i)for(n=e,r=e-1;r>=0;--r){if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,o,a,h=this._activeObject,c=0;if(t===h&&"activeSelection"===t.type)for(n=(a=h._objects).length;n--;)r=a[n],(s=this._objects.indexOf(r))"}}),t(C.StaticCanvas.prototype,C.Observable),t(C.StaticCanvas.prototype,C.Collection),t(C.StaticCanvas.prototype,C.DataURLExporter),t(C.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=a();if(!e||!e.getContext)return null;var i=e.getContext("2d");if(!i)return null;switch(t){case"setLineDash":return void 0!==i.setLineDash;default:return null}}}),C.StaticCanvas.prototype.toJSON=C.StaticCanvas.prototype.toObject,C.isLikelyNode&&(C.StaticCanvas.prototype.createPNGStream=function(){var t=o(this.lowerCanvasEl);return t&&t.createPNGStream()},C.StaticCanvas.prototype.createJPEGStream=function(t){var e=o(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),C.BaseBrush=C.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,setShadow:function(t){return this.shadow=new C.Shadow(t),this},_setBrushStyles:function(){var t=this.canvas.contextTop;t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,C.StaticCanvas.supports("setLineDash")&&t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=C.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new C.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}}),C.PencilBrush=C.util.createClass(C.BaseBrush,{decimate:.4,initialize:function(t){this.canvas=t,this._points=[]},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&this._captureDrawingPath(t)&&this._points.length>1)if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new C.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(),this._setShadow()},_captureDrawingPath:function(t){var e=new C.Point(t.x,t.y);return this._addPoint(e)},_render:function(){var t,e,i=this.canvas.contextTop,n=this._points[0],r=this._points[1];if(this._saveAndTransform(i),i.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var s=this.width/1e3;n=new C.Point(n.x,n.y),r=new C.Point(r.x,r.y),n.x-=s,r.x+=s}for(i.moveTo(n.x,n.y),t=1,e=this._points.length;t2;for(c&&(a=t[2].xt[e-2].x?1:r.x===t[e-2].x?0:-1,h=r.y>t[e-2].y?1:r.y===t[e-2].y?0:-1),i.push("L ",r.x+a*n," ",r.y+h*n),i},createPath:function(t){var e=new C.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.setShadow(this.shadow)),e},decimatePoints:function(t,e){if(t.length<=2)return t;var i,n=this.canvas.getZoom(),r=Math.pow(e/n,2),s=t.length-1,o=t[0],a=[o];for(i=1;i=r&&(o=t[i],a.push(o));return 1===a.length&&a.push(new C.Point(a[0].x,a[0].y)),a},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points).join("");if("M 0 0 Q 0 0 0 0 L 0 0"!==t){var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}else this.canvas.requestRenderAll()}}),C.CircleBrush=C.util.createClass(C.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&this.renderTopLayer(this.contextTop);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_resetCurrentTransform:function(){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,skewX:t.original.skewX,skewY:t.original.skewY,left:t.original.left,top:t.original.top}),this._shouldCenterTransform(t.target)?("center"!==t.originX&&("right"===t.originX?t.mouseXSign=-1:t.mouseXSign=1),"center"!==t.originY&&("bottom"===t.originY?t.mouseYSign=-1:t.mouseYSign=1),t.originX="center",t.originY="center"):(t.originX=t.original.originX,t.originY=t.original.originY)},containsPoint:function(t,e,i){var n,r=i||this.getPointer(t,!0);return n=e.group&&e.group===this._activeObject&&"activeSelection"===e.group.type?this._normalizePointer(e.group,r):{x:r.x,y:r.y},e.containsPoint(n)||e._findTargetCorner(r)},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=C.util.invertTransform(i),r=this.restorePointerVpt(e);return C.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return C.util.isTransparent(t._cacheContext,Math.round(r),Math.round(s),this.targetFindTolerance)}var o=this.contextCache,a=t.selectionBackgroundColor,h=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(o),o.save(),o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),t.render(o),o.restore(),t===this._activeObject&&t._renderControls(o,{hasBorders:!1,transparentCorners:!1},{hasBorders:!1}),t.selectionBackgroundColor=a,C.util.isTransparent(o,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return"[object Array]"===Object.prototype.toString.call(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t){if(t){var e,i=this._currentTransform;return"scale"===i.action||"scaleX"===i.action||"scaleY"===i.action?e=this.centeredScaling||t.centeredScaling:"rotate"===i.action&&(e=this.centeredRotation||t.centeredRotation),e?!i.altKey:i.altKey}},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i){if(!e||!t)return"drag";switch(e){case"mtr":return"rotate";case"ml":case"mr":return i[this.altActionKey]?"skewY":"scaleX";case"mt":case"mb":return i[this.altActionKey]?"skewX":"scaleY";default:return"scale"}},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),s=i._findTargetCorner(this.getPointer(t,!0)),o=this._getActionFromCorner(n,s,t,i),a=this._getOriginFromCorner(i,s);this._currentTransform={target:i,action:o,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:a.x,originY:a.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,mouseXSign:1,mouseYSign:1,shiftKey:t.shiftKey,altKey:t[this.centeredKey],original:C.util.saveObjectTransform(i)},this._currentTransform.original.originX=a.x,this._currentTransform.original.originY=a.y,this._resetCurrentTransform(),this._beforeTransform(t)}},_translateObject:function(t,e){var i=this._currentTransform,n=i.target,r=t-i.offsetX,s=e-i.offsetY,o=!n.get("lockMovementX")&&n.left!==r,a=!n.get("lockMovementY")&&n.top!==s;return o&&n.set("left",r),a&&n.set("top",s),o||a},_changeSkewTransformOrigin:function(t,e,i){var n="originX",r={0:"center"},s=e.target.skewX,o="left",a="right",h="mt"===e.corner||"ml"===e.corner?1:-1,c=1;t=t>0?1:-1,"y"===i&&(s=e.target.skewY,o="top",a="bottom",n="originY"),r[-1]=o,r[1]=a,e.target.flipX&&(c*=-1),e.target.flipY&&(c*=-1),0===s?(e.skewSign=-h*t*c,e[n]=r[-t]):(s=s>0?1:-1,e.skewSign=s,e[n]=r[s*h*c])},_skewObject:function(t,e,i){var n,r=this._currentTransform,s=r.target,o=s.get("lockSkewingX"),a=s.get("lockSkewingY");if(o&&"x"===i||a&&"y"===i)return!1;var h,c,l=s.getCenterPoint(),u=s.toLocalPoint(new C.Point(t,e),"center","center")[i],f=s.toLocalPoint(new C.Point(r.lastX,r.lastY),"center","center")[i],d=s._getTransformedDimensions();return this._changeSkewTransformOrigin(u-f,r,i),h=s.toLocalPoint(new C.Point(t,e),r.originX,r.originY)[i],c=s.translateToOriginPoint(l,r.originX,r.originY),n=this._setObjectSkew(h,r,i,d),r.lastX=t,r.lastY=e,s.setPositionByOrigin(c,r.originX,r.originY),n},_setObjectSkew:function(t,e,i,n){var r,s,o,a,h,c,l,u,f,d,p=e.target,g=e.skewSign;return"x"===i?(h="y",c="Y",l="X",f=0,d=p.skewY):(h="x",c="X",l="Y",f=p.skewX,d=0),a=p._getTransformedDimensions(f,d),(u=2*Math.abs(t)-a[i])<=2?r=0:(r=g*Math.atan(u/p["scale"+l]/(a[h]/p["scale"+c])),r=C.util.radiansToDegrees(r)),s=p["skew"+l]!==r,p.set("skew"+l,r),0!==p["skew"+c]&&(o=p._getTransformedDimensions(),r=n[h]/o[h]*p["scale"+c],p.set("scale"+c,r)),s},_scaleObject:function(t,e,i){var n=this._currentTransform,r=n.target,s=r.lockScalingX,o=r.lockScalingY,a=r.lockScalingFlip;if(s&&o)return!1;var h,c=r.translateToOriginPoint(r.getCenterPoint(),n.originX,n.originY),l=r.toLocalPoint(new C.Point(t,e),n.originX,n.originY),u=r._getTransformedDimensions();return this._setLocalMouse(l,n),h=this._setObjectScale(l,n,s,o,i,a,u),r.setPositionByOrigin(c,n.originX,n.originY),h},_setObjectScale:function(t,e,i,n,r,s,o){var a=e.target,h=!1,c=!1,l=!1,u=t.x*a.scaleX/o.x,f=t.y*a.scaleY/o.y,d=a.scaleX!==u,p=a.scaleY!==f;if(e.newScaleX=u,e.newScaleY=f,C.Textbox&&"x"===r&&a instanceof C.Textbox){var g=a.width*(t.x/o.x);return g>=a.getMinWidth()&&(l=g!==a.width,a.set("width",g),l)}return s&&u<=0&&us?t.x<0?t.x+=s:t.x-=s:t.x=0,r(t.y)>s?t.y<0?t.y+=s:t.y-=s:t.y=0},_rotateObject:function(t,e){var r=this._currentTransform,s=r.target,o=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY);if(s.lockRotation)return!1;var a=n(r.ey-o.y,r.ex-o.x),h=n(e-o.y,t-o.x),c=i(h-a+r.theta),l=!0;if(s.snapAngle>0){var u=s.snapAngle,f=s.snapThreshold||u,d=Math.ceil(c/u)*u,p=Math.floor(c/u)*u;Math.abs(c-p)0?0:-i),e.ey-(n>0?0:-n),o,a)),this.selectionLineWidth&&this.selectionBorderColor)if(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,this.selectionDashArray.length>1&&!s){var h=e.ex+.5-(i>0?0:o),c=e.ey+.5-(n>0?0:a);t.beginPath(),C.util.drawDashedLine(t,h,c,h+o,c,this.selectionDashArray),C.util.drawDashedLine(t,h,c+a-1,h+o,c+a-1,this.selectionDashArray),C.util.drawDashedLine(t,h,c,h,c+a,this.selectionDashArray),C.util.drawDashedLine(t,h+o-1,c,h+o-1,c+a,this.selectionDashArray),t.closePath(),t.stroke()}else C.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(e.ex+.5-(i>0?0:o),e.ey+.5-(n>0?0:a),o,a)},findTarget:function(t,e){if(!this.skipTargetFind){var i,n,r=this.getPointer(t,!0),s=this._activeObject,o=this.getActiveObjects();if(this.targets=[],o.length>1&&!e&&s===this._searchPossibleTargets([s],r))return s;if(1===o.length&&s._findTargetCorner(r))return s;if(1===o.length&&s===this._searchPossibleTargets([s],r)){if(!this.preserveObjectStacking)return s;i=s,n=this.targets,this.targets=[]}var a=this._searchPossibleTargets(this._objects,r);return t[this.altSelectionKey]&&a&&i&&a!==i&&(a=i,this.targets=n),a}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&this.containsPoint(null,e,t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var s=t[r],o=s.group&&"activeSelection"!==s.group.type?this._normalizePointer(s.group,e):e;if(this._checkTarget(o,s,e)){(i=t[r]).subTargetCheck&&i instanceof C.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return C.util.transformPoint(t,C.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,o=s.getBoundingClientRect(),a=o.width||0,h=o.height||0;a&&h||("top"in o&&"bottom"in o&&(h=Math.abs(o.top-o.bottom)),"right"in o&&"left"in o&&(a=Math.abs(o.right-o.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var c=this.getRetinaScaling();return 1!==c&&(r.x/=c,r.y/=c),n=0===a||0===h?{width:1,height:1}:{width:s.width/a,height:s.height/h},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),C.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=C.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),C.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),C.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;C.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,C.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[],o={e:e};t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",o),s.push(t))})),n.forEach((function(e){-1===t.indexOf(e)&&(i=!0,e.fire("selected",o),r.push(e))})),t.length>0&&n.length>0?(o.selected=r,o.deselected=s,o.updated=r[0]||s[0],o.target=this._activeObject,i&&this.fire("selection:updated",o)):n.length>0?(1===n.length&&(o.target=r[0],this.fire("object:selected",o)),o.selected=r,o.target=this._activeObject,this.fire("selection:created",o)):t.length>0&&(o.deselected=s,this.fire("selection:cleared",o))},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&(!!this._discardActiveObject(e,t)&&(!t.onSelect({e:e})&&(this._activeObject=t,!0)))},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){C.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,C.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),this._activeObject.realizeTransform(t),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),C.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),C.StaticCanvas)"prototype"!==o&&(C.Canvas[o]=C.StaticCanvas[o])}(),function(){var t={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},e=C.util.addListener,i=C.util.removeListener,n={passive:!1};function r(t,e){return t.button&&t.button===e-1}C.util.object.extend(C.Canvas.prototype,{cursorMap:["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(e,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var i=this.upperCanvasEl,r=this._getEventPrefix();t(C.window,"resize",this._onResize),t(i,r+"down",this._onMouseDown),t(i,r+"move",this._onMouseMove,n),t(i,r+"out",this._onMouseOut),t(i,r+"enter",this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,n),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](i,"gesture",this._onGesture),eventjs[e](i,"drag",this._onDrag),eventjs[e](i,"orientation",this._onOrientationChange),eventjs[e](i,"shake",this._onShake),eventjs[e](i,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(i,"remove");var t=this._getEventPrefix();i(C.document,t+"up",this._onMouseUp),i(C.document,"touchend",this._onTouchEnd,n),i(C.document,t+"move",this._onMouseMove,n),i(C.document,"touchmove",this._onMouseMove,n)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._simpleEventHandler.bind(this,"drop"),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(n){i.fire("mouse:out",{target:e,e:t}),n&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this.currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||(!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId))},_onTouchStart:function(t){t.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();e(C.document,"touchend",this._onTouchEnd,n),e(C.document,"touchmove",this._onMouseMove,n),i(r,s+"down",this._onMouseDown)},_onMouseDown:function(t){this.__onMouseDown(t),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();i(r,s+"move",this._onMouseMove,n),e(C.document,s+"up",this._onMouseUp),e(C.document,s+"move",this._onMouseMove,n)},_onTouchEnd:function(t){if(!(t.touches.length>0)){this.__onMouseUp(t),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();i(C.document,"touchend",this._onTouchEnd,n),i(C.document,"touchmove",this._onMouseMove,n);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){e(s.upperCanvasEl,r+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(t){this.__onMouseUp(t),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(t)&&(i(C.document,s+"up",this._onMouseUp),i(C.document,s+"move",this._onMouseMove,n),e(r,s+"move",this._onMouseMove,n))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,n=this._groupSelector,s=!1,o=!n||0===n.left&&0===n.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),!r(t,3))return r(t,2)?(this.fireMiddleClick&&this._handleEvent(t,"up",2,o),void this._resetTransformEventData()):void(this.isDrawingMode&&this._isCurrentlyDrawing?this._onMouseUpInDrawingMode(t):this._isMainEvent(t)&&(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),o||(this._maybeGroupObjects(t),s||(s=this._shouldRender(e))),e&&(e.isMoving=!1),this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,o),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():o||this.renderTop()));this.fireRightClick&&this._handleEvent(t,"up",3,o)},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e:e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s1&&(e=new C.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,s=n+this._groupSelector.left,o=r+this._groupSelector.top,a=new C.Point(m(n,s),m(r,o)),h=new C.Point(v(n,s),v(r,o)),c=!this.selectionFullyContained,l=n===s&&r===o,u=this._objects.length;u--&&!((e=this._objects[u])&&e.selectable&&e.visible&&(c&&e.intersectsWithRect(a,h)||e.isContainedWithinRect(a,h)||c&&e.containsPoint(a)||c&&e.containsPoint(h))&&(i.push(e),l)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),C.util.object.extend(C.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return C.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),s=this.width,o=this.height,a=r*t,h=this.viewportTransform,c=(h[4]-(e.left||0))*t,l=(h[5]-(e.top||0))*t,u=this.interactive,f=[a,0,0,a,c,l],d=this.enableRetinaScaling,p=C.util.createCanvasElement(),g=this.contextTop;return p.width=i,p.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=f,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(p.getContext("2d"),this._objects),this.viewportTransform=h,this.width=s,this.height=o,this.calcViewportBoundaries(),this.interactive=u,this.enableRetinaScaling=d,this.contextTop=g,p}}),C.util.object.extend(C.StaticCanvas.prototype,{loadFromDatalessJSON:function(t,e,i){return this.loadFromJSON(t,e,i)},loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):C.util.object.clone(t),r=this,s=n.clipPath,o=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){s?r._enlivenObjects([s],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,o,e)})):r.__setupCanvas.call(r,n,t,o,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?C.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+C.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?C.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=C.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new C.Canvas(e);i.clipTo=this.clipTo,this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,o=e.util.degreesToRadians,a=e.StaticCanvas.supports("setLineDash"),h=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",borderDashArray:null,cornerColor:"rgba(102,153,255,0.5)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!0,rotatingPointOffset:40,perPixelTargetFind:!1,includeDefaultValues:!0,clipTo:null,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockUniScaling:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:h,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow clipTo visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,o=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return nl&&(t.zoomX/=n/l,t.width=l,t.capped=!0),r>u&&(t.zoomY/=r/u,t.height=u,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,s,o=this._cacheCanvas,a=this._limitCacheSize(this._getCacheCanvasDimensions()),h=e.minCacheSideLimit,c=a.width,l=a.height,u=a.zoomX,f=a.zoomY,d=c!==this.cacheWidth||l!==this.cacheHeight,p=this.zoomX!==u||this.zoomY!==f,g=d||p,m=0,v=0,b=!1;if(d){var y=this._cacheCanvas.width,_=this._cacheCanvas.height,x=c>y||l>_;b=x||(c<.9*y||l<.9*_)&&y>h&&_>h,x&&!a.capped&&(c>h||l>h)&&(m=.1*c,v=.1*l)}return!!g&&(b?(o.width=Math.ceil(c+m),o.height=Math.ceil(l+v)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,o.width,o.height)),r=a.x/2,s=a.y/2,this.cacheTranslationX=Math.round(o.width/2-r)+r,this.cacheTranslationY=Math.round(o.height/2-s)+s,this.cacheWidth=c,this.cacheHeight=l,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(u,f),this.zoomX=u,this.zoomY=f,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initClipping(t),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e;e=this.group&&!this.group._transformDone?this.calcTransformMatrix():this.calcOwnMatrix(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,transformMatrix:this.transformMatrix?this.transformMatrix.concat():null,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],"[object Array]"===Object.prototype.toString.call(t[e])&&"[object Array]"===Object.prototype.toString.call(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#"},getObjectScaling:function(){var t=this.scaleX,e=this.scaleY;if(this.group){var i=this.group.getObjectScaling();t*=i.scaleX,e*=i.scaleY}return{scaleX:t,scaleY:e}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||0===this.width&&0===this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this.clipTo&&e.util.clipContext(this,t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),this.clipTo&&t.restore(),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t){var i=this.clipPath;if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):(this._renderBackground(t),this._setStrokeStyles(t,this),this._setFillStyles(t,this)),this._render(t),this._drawClipPath(t),this.fill=i,this.stroke=n},_drawClipPath:function(t){var e=this.clipPath;e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){e.stroke&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,t.strokeStyle=e.stroke.toLive?e.stroke.toLive(t,this):e.stroke)},_setFillStyles:function(t,e){e.fill&&(t.fillStyle=e.fill.toLive?e.fill.toLive(t,this):e.fill)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e,i){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),a?t.setLineDash(e):i&&i(t))},_renderControls:function(t,i){var n,r,s,a=this.getViewportTransform(),h=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,h=e.util.multiplyTransformMatrices(a,h),n=e.util.qrDecompose(h),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),i.forActiveSelection?(t.rotate(o(n.angle)),r&&this.drawBordersInGroup(t,n,i)):(t.rotate(o(this.angle)),r&&this.drawBorders(t,i)),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,o=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,o*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+o)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*o*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._applyPatternGradientTransform(t,this.fill),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){this.stroke&&0!==this.strokeWidth&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY),this._setLineDash(t,this.strokeDashArray,this._renderDashedStroke),this.stroke.toLive&&"percentage"===this.stroke.gradientUnits?this._applyPatternForTransformedGradient(t,this.stroke):this._applyPatternGradientTransform(t,this.stroke),t.stroke(),t.restore())},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),o=this.canvas.getRetinaScaling(),a=r.x/this.scaleX/o,h=r.y/this.scaleY/o;s.width=a,s.height=h,(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(a,0),n.lineTo(a,h),n.lineTo(0,h),n.closePath(),n.translate(a/2,h/2),n.scale(r.zoomX/this.scaleX/o,r.zoomY/this.scaleY/o),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(o*this.scaleX/r.zoomX,o*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,o=Math.abs,a=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var h,c,l,u,f=e.util.createCanvasElement(),d=this.getBoundingRect(!0,!0),p=this.shadow,g={x:0,y:0};p&&(c=p.blur,h=p.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),g.x=2*Math.round(o(p.offsetX)+c)*o(h.scaleX),g.y=2*Math.round(o(p.offsetY)+c)*o(h.scaleY)),l=d.width+g.x,u=d.height+g.y,f.width=Math.ceil(l),f.height=Math.ceil(u);var m=new e.StaticCanvas(f,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(m.width/2,m.height/2),"center","center");var v=this.canvas;m.add(this);var b=m.toCanvasElement(a||1,t);return this.shadow=s,this.canvas=v,r&&(this.group=r),this.set(n).setCoords(),m._objects=[],m.dispose(),m=null,b},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},setGradient:function(t,i){i||(i={});var n={colorStops:[]};return n.type=i.type||(i.r1||i.r2?"radial":"linear"),n.coords={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},n.gradientUnits=i.gradientUnits||"pixels",(i.r1||i.r2)&&(n.coords.r1=i.r1,n.coords.r2=i.r2),n.gradientTransform=i.gradientTransform,e.Gradient.prototype.addColorStop.call(n,i.colorStops),this.set(t,e.Gradient.forObject(this,n))},setPatternFill:function(t,i){return this.set("fill",new e.Pattern(t,i))},setShadow:function(t){return this.set("shadow",t?new e.Shadow(t):null)},setColor:function(t){return this.set("fill",t),this},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,o(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object._fromObject=function(t,i,r,s){var o=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjects([i.clipPath],(function(t){i.clipPath=t[0];var e=s?new o(i[s],i):new o(i);r&&r(e)}))}))},e.Object.__uid=0)}(e),b=C.util.degreesToRadians,y={left:-.5,center:0,right:.5},_={top:-.5,center:0,bottom:.5},C.util.object.extend(C.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var s,o,a,h=t.x,c=t.y;return"string"==typeof e?e=y[e]:e-=.5,"string"==typeof n?n=y[n]:n-=.5,"string"==typeof i?i=_[i]:i-=.5,"string"==typeof r?r=_[r]:r-=.5,o=r-i,((s=n-e)||o)&&(a=this._getTransformedDimensions(),h=t.x+s*a.x,c=t.y+o*a.y),new C.Point(h,c)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?C.util.rotatePoint(n,t,b(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?C.util.rotatePoint(n,t,b(this.angle)):n},getCenterPoint:function(){var t=new C.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,s=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new C.Point(this.left,this.top),r=new C.Point(t.x,t.y),this.angle&&(r=C.util.rotatePoint(r,s,-b(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=b(this.angle),r=this.getScaledWidth(),s=C.util.cos(n)*r,o=C.util.sin(n)*r;e="string"==typeof this.originX?y[this.originX]:this.originX-.5,i="string"==typeof t?y[t]:t-.5,this.left+=s*(i-e),this.top+=o*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=C.util.degreesToRadians,e=C.util.multiplyTransformMatrices,i=C.util.transformPoint;C.util.object.extend(C.Object.prototype,{oCoords:null,aCoords:null,ownMatrixCache:null,matrixCache:null,getCoords:function(t,e){this.oCoords||this.setCoords();var i=t?this.aCoords:this.oCoords;return function(t){return[new C.Point(t.tl.x,t.tl.y),new C.Point(t.tr.x,t.tr.y),new C.Point(t.br.x,t.br.y),new C.Point(t.bl.x,t.bl.y)]}(e?this.calcCoords(t):i)},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===C.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===C.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=0,s=t._getImageLines(i?t.calcCoords(e):e?t.aCoords:t.oCoords);r<4;r++)if(!t.containsPoint(n[r],s))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){e=e||this._getImageLines(n?this.calcCoords(i):i?this.aCoords:this.oCoords);var r=this._findCrossPoints(t,e);return 0!==r&&r%2==1},isOnScreen:function(t){if(!this.canvas)return!1;for(var e,i=this.canvas.vptCoords.tl,n=this.canvas.vptCoords.br,r=this.getCoords(!0,t),s=0;s<4;s++)if((e=r[s]).x<=n.x&&e.x>=i.x&&e.y<=n.y&&e.y>=i.y)return!0;return!!this.intersectsWithRect(i,n,!0,t)||this._containsCenterOfCanvas(i,n,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var o in e)if(!((r=e[o]).o.y=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(0,i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(t,e){var i=this.getCoords(t,e);return C.util.makeBoundingBoxFromPoints(i)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,s=e.reviver,o=r?"":'style="'+this.getSvgStyles()+'" ',a=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",h=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",l=h&&h.absolutePositioned,u=this.stroke,f=this.fill,d=this.shadow,p=[],g=t.indexOf("COMMON_PARTS"),m=e.additionalTransform;return h&&(h.clipPathId="CLIPPATH_"+C.Object.__uid++,n='\n'+h.toClipPathSVG(s)+"\n"),l&&p.push("\n"),p.push("\n"),i=[o,c,r?"":this.addPaintOrder()," ",m?'transform="'+m+'" ':""].join(""),t[g]=i,f&&f.toLive&&p.push(f.toSVG(this)),u&&u.toLive&&p.push(u.toSVG(this)),d&&p.push(d.toSVG(this)),h&&p.push(n),p.push(t.join("")),p.push("\n"),l&&p.push("\n"),s?s(p.join("")):p.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=C.util.object.extend;function e(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}C.util.object.extend(C.Object.prototype,{hasStateChanged:function(t){var e="_"+(t=t||"stateProperties");return Object.keys(this[e]).length\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),o=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(o,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.PI;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:2*i,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%(2*i);if(0===n)t=["\n'];else{var r=e.util.cos(this.startAngle)*this.radius,s=e.util.sin(this.startAngle)*this.radius,o=e.util.cos(this.endAngle)*this.radius,a=e.util.sin(this.endAngle)*this.radius,h=n>i?"1":"0";t=['\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,this.startAngle,this.endAngle,!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){return e.Object._fromObject("Circle",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_renderDashedStroke:function(t){var i=this.width/2,n=this.height/2;t.beginPath(),e.util.drawDashedLine(t,-i,n,0,-n,this.strokeDashArray),e.util.drawDashedLine(t,0,-n,i,n,this.strokeDashArray),e.util.drawDashedLine(t,i,n,-i,n,this.strokeDashArray),t.closePath()},_toSVG:function(){var t=this.width/2,e=this.height/2;return["']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){return e.Object._fromObject("Ellipse",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,o=-this.height/2,a=0!==e||0!==i,h=.4477152502;t.beginPath(),t.moveTo(s+e,o),t.lineTo(s+n-e,o),a&&t.bezierCurveTo(s+n-h*e,o,s+n,o+h*i,s+n,o+i),t.lineTo(s+n,o+r-i),a&&t.bezierCurveTo(s+n,o+r-h*i,s+n-h*e,o+r,s+n-e,o+r),t.lineTo(s+e,o+r),a&&t.bezierCurveTo(s+h*e,o+r,s,o+r-h*i,s,o+r-i),t.lineTo(s,o+i),a&&t.bezierCurveTo(s,o+h*i,s+h*e,o,s+e,o),t.closePath(),this._renderPaintInOrder(t)},_renderDashedStroke:function(t){var i=-this.width/2,n=-this.height/2,r=this.width,s=this.height;t.beginPath(),e.util.drawDashedLine(t,i,n,i+r,n,this.strokeDashArray),e.util.drawDashedLine(t,i+r,n,i+r,n+s,this.strokeDashArray),e.util.drawDashedLine(t,i+r,n+s,i,n+s,this.strokeDashArray),e.util.drawDashedLine(t,i,n+s,i,n,this.strokeDashArray),t.closePath()},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var o=new e.Rect(i(r?e.util.object.clone(r):{},s));o.visible=o.visible&&o.width>0&&o.height>0,n(o)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t);this.width=i.width,this.height=i.height,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2,y:i.top-this.strokeWidth/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2,y:i.top+this.height/2}},_calcDimensions:function(){var t=this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,o=0,a=this.points.length;o\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+a(-this.pathOffset.x,t)+", "+a(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_parsePath:function(){for(var t,i,n,r,s,o=[],a=[],l=e.rePathCommand,u=0,f=this.path.length;um)for(var b=1,y=s.length;b"},addWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i\n"],i=0,n=this._objects.length;i\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),void 0===i.hasRotatingPoint&&(i.hasRotatingPoint=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n\n','\t\n',"\n"),s=' clip-path="url(#imageCrop_'+o+')" '}if(i.push("\t\n"),this.stroke||this.strokeDashArray){var a=this.fill;this.fill=null,t=["\t\n'],this.fill=a}return e="fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return C.util.loadImage(t,(function(t){this.setElement(t,i),this._setWidthHeight(),e&&e(this)}),this,i&&i.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);C.filterBackend||(C.filterBackend=C.initFilterBackend());var o=C.util.createCanvasElement(),a=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,h=s.width,c=s.height;o.width=h,o.height=c,this._element=o,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,C.filterBackend.applyFilters([t],s,h,c,this._element,a),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=C.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return C.filterBackend||(C.filterBackend=C.initFilterBackend()),C.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element,i=this.width,n=this.height,r=Math.min(e.naturalWidth||e.width,i*this._filterScalingX),s=Math.min(e.naturalHeight||e.height,n*this._filterScalingY),o=-i/2,a=-n/2,h=Math.max(0,this.cropX*this._filterScalingX),c=Math.max(0,this.cropY*this._filterScalingY);e&&t.drawImage(e,h,c,r,s,o,a,i,n)},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(C.util.getById(t),e),C.util.addClass(this.getElement(),C.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t),this._element&&this.crossOrigin&&(this._element.crossOrigin=this.crossOrigin)},_initFilters:function(t,e){t&&t.length?C.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=C.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,s=1,o=0,a=0,h=0,c=0,l=this.width,u=this.height,f={width:l,height:u};return!e||"none"===e.alignX&&"none"===e.alignY?(r=l/i,s=u/n):("meet"===e.meetOrSlice&&(t=(l-i*(r=s=C.util.findScaleToFit(this._element,f)))/2,"Min"===e.alignX&&(o=-t),"Max"===e.alignX&&(o=t),t=(u-n*s)/2,"Min"===e.alignY&&(a=-t),"Max"===e.alignY&&(a=t)),"slice"===e.meetOrSlice&&(t=i-l/(r=s=C.util.findScaleToCover(this._element,f)),"Mid"===e.alignX&&(h=t/2),"Max"===e.alignX&&(h=t),t=n-u/s,"Mid"===e.alignY&&(c=t/2),"Max"===e.alignY&&(c=t),i=l/r,n=u/s)),{width:i,height:n,scaleX:r,scaleY:s,offsetLeft:o,offsetTop:a,cropX:h,cropY:c}}}),C.Image.CSS_CANVAS="canvas-img",C.Image.prototype.getSvgSrc=C.Image.prototype.getSrc,C.Image.fromObject=function(t,e){var i=C.util.object.clone(t);C.util.loadImage(i.src,(function(t,n){n?e&&e(null,n):C.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],C.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],C.util.enlivenObjects([i.clipPath],(function(n){i.clipPath=n[0];var r=new C.Image(t,i);e(r)}))}))}))}),null,i.crossOrigin)},C.Image.fromURL=function(t,e,i){C.util.loadImage(t,(function(t){e&&e(new C.Image(t,i))}),null,i&&i.crossOrigin)},C.Image.ATTRIBUTE_NAMES=C.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin".split(" ")),C.Image.fromElement=function(t,i,n){var r=C.parseAttributes(t,C.Image.ATTRIBUTE_NAMES);C.Image.fromURL(r["xlink:href"],i,e(n?C.util.object.clone(n):{},r))})}(e),C.util.object.extend(C.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten()),this},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return C.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}}),this}}),C.util.object.extend(C.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound}),this}}),function(){"use strict";function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}C.isWebglSupported=function(e){if(C.isLikelyNode)return!1;e=e||C.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){C.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=C.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],o=0;o<3;o++)if(t(n,s[o])){C.webGlPrecision=s[o];break}}return this.isSupported=r,r},C.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&s){var o=C.util.createCanvasElement(),a=new ArrayBuffer(t*e*4);if(C.forceGLPutImageData)return this.imageBuffer=a,void(this.copyGLTo2D=E);var h,c,l={imageBuffer:a,destinationWidth:t,destinationHeight:e,targetCanvas:o};o.width=t,o.height=e,h=window.performance.now(),O.call(l,this.gl,l),c=window.performance.now()-h,h=window.performance.now(),E.call(l,this.gl,l),c>window.performance.now()-h?(this.imageBuffer=a,this.copyGLTo2D=E):this.copyGLTo2D=O}},createWebGLCanvas:function(t,e){var i=C.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,s){var o,a=this.gl;s&&(o=this.getCachedTexture(s,e));var h={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:a,sourceTexture:this.createTexture(a,i,n,!o&&e),targetTexture:this.createTexture(a,i,n),originalTexture:o||this.createTexture(a,i,n,!o&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},c=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,c),t.forEach((function(t){t&&t.applyTo(h)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,s=t.destinationHeight;i===r&&n===s||(e.width=r,e.height=s)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(c),r.getContext("2d").setTransform(1,0,0,1,0,0),h},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:O,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){"use strict";var t=function(){};function e(){}C.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var o={sourceWidth:i,sourceHeight:n,imageData:s.getImageData(0,0,i,n),originalEl:e,originalImageData:s.getImageData(0,0,i,n),canvasEl:r,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(o)})),o.imageData.width===i&&o.imageData.height===n||(r.width=o.imageData.width,r.height=o.imageData.height),s.putImageData(o.imageData,0,0),o}}}(),C.Image=C.Image||{},C.Image.filters=C.Image.filters||{},C.Image.filters.BaseFilter=C.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==C.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+C.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var s=t.createProgram();if(t.attachShader(s,n),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var o=this.getAttributeLocations(t,s),a=this.getUniformLocations(t,s)||{};return a.uStepW=t.getUniformLocation(s,"uStepW"),a.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:o,uniformLocations:a}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=C.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),C.Image.filters.BaseFilter.fromObject=function(t,e){var i=new C.Image.filters[t.type](t);return e&&e(i),i},function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,o=t.imageData.data,a=o.length,h=this.matrix,c=this.colorsOnly;for(s=0;s=_||o<0||o>=y||(h=4*(a*y+o),c=m[d*v+f],e+=g[h]*c,i+=g[h+1]*c,n+=g[h+2]*c,w||(r+=g[h+3]*c));S[s]=e,S[s+1]=i,S[s+2]=n,S[s+3]=w?g[s+3]:r}t.imageData=x},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;ec[0]&&r>c[1]&&s>c[2]&&n 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,o,a,h,c=t.imageData.data,l=c.length,u=1-this.alpha;i=(h=new e.Color(this.color).getSource())[0]*this.alpha,n=h[1]*this.alpha,r=h[2]*this.alpha;for(var f=0;f=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return a(e)/e*a(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,a=e.height,h=o(s*i),c=o(a*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,a,h,c):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,a,h,c):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,a,h,c):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,a,h,c)),t.imageData=r},sliceByTwo:function(t,i,r,s,o){var a,h,c=t.imageData,l=!1,u=!1,f=.5*i,d=.5*r,p=e.filterBackend.resources,g=0,m=0,v=i,b=0;for(p.sliceByTwo||(p.sliceByTwo=document.createElement("canvas")),((a=p.sliceByTwo).width<1.5*i||a.height=e)){D=n(1e3*s(C-x.x)),_[D]||(_[D]={});for(var F=S.y-y;F<=S.y+y;F++)F<0||F>=o||(L=n(1e3*s(F-x.y)),_[D][L]||(_[D][L]=d(r(i(D*m,2)+i(L*v,2))/1e3)),(T=_[D][L])>0&&(E+=T,P+=T*l[O=4*(F*e+C)],j+=T*l[O+1],k+=T*l[O+2],A+=T*l[O+3]))}f[O=4*(w*a+h)]=P/E,f[O+1]=j/E,f[O+2]=k/E,f[O+3]=A/E}return++h1&&L<-1||(y=2*L*L*L-3*L*L+1)>0&&(T+=y*d[(D=4*(A+E*e))+3],x+=y,d[D+3]<255&&(y=y*d[D+3]/250),S+=y*d[D],w+=y*d[D+1],C+=y*d[D+2],_+=y)}g[b]=S/_,g[b+1]=w/_,g[b+2]=C/_,g[b+3]=T/x}return p},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],o=1/n[1],a=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){t.textBaseline="alphabetic",t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;et&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,o,a=0,h=t.fillStyle,c=this._getLeftOffset(),l=this._getTopOffset(),u=0,f=0,d=0,p=this._textLines.length;d0&&!r){var f=this.__charBounds[e][i-1];u.left=f.left+f.width+h.kernedWidth-h.width}return u},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n0?(t.fillStyle=v,c&&v&&t.fillRect(b+s+u,l+this.offsets[e]*n+o,f,this.fontSize/15),u=d.left,f=d.width,c=p,v=m,n=r,o=a):f+=d.kernedWidth;t.fillStyle=m,p&&m&&t.fillRect(b+s+u,l+this.offsets[e]*n+o,f-_,this.fontSize/15),y+=i}else y+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,o=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",o].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],s=[],o=0;o-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}C.IText=C.util.createClass(C.Text,C.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"#333",cursorDelay:1e3,cursorDuration:600,caching:!0,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this.transformMatrix&&e.transform.apply(e,this.transformMatrix),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,o=0,a=this.get2DCursorLocation(t);n=a.charIndex,i=a.lineIndex;for(var h=0;h0?o:0)},this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),o=this.scaleX*this.canvas.getZoom(),a=this.cursorWidth/o,h=t.topOffset,c=this.getValueOfPropertyAt(n,r,"deltaY");h+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-a/2,h+t.top+c,a,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),o=this.get2DCursorLocation(n),a=s.lineIndex,h=o.lineIndex,c=s.charIndex<0?0:s.charIndex,l=o.charIndex<0?0:o.charIndex,u=a;u<=h;u++){var f,d=this._getLineLeftOffset(u)||0,p=this.getHeightOfLine(u),g=0,m=0;if(u===a&&(g=this.__charBounds[a][c].left),u>=a&&u1)&&(p/=this.lineHeight),this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",e.fillRect(t.left+d+g,t.top+t.topOffset+p,m-g,1)):(e.fillStyle=this.selectionColor,e.fillRect(t.left+d+g,t.top+t.topOffset,m-g,p)),t.topOffset+=f}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),C.IText.fromObject=function(e,i){if(t(e),e.styles)for(var n in e.styles)for(var r in e.styles[n])t(e.styles[n][r]);C.Object._fromObject("IText",e,i,"text")}}(),x=C.util.object.clone,C.util.object.extend(C.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],C.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i0&&nthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=C.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var s=i.slice(t,e);return{selectionStart:r,selectionEnd:r+C.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,s=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.calcTransformMatrix(),h={x:e.left+o,y:e.top+e.topOffset+s},c=this.canvas.getRetinaScaling(),l=this.canvas.upperCanvasEl,u=l.width/c,f=l.height/c,d=u-s,p=f-s,g=l.clientWidth/u,m=l.clientHeight/f;return h=C.util.transformPoint(h,a),(h=C.util.transformPoint(h,this.canvas.viewportTransform)).x*=g,h.y*=m,h.x<0&&(h.x=0),h.x>d&&(h.x=d),h.y<0&&(h.y=0),h.y>p&&(h.y=p),h.x+=this.canvas._offset.left,h.y+=this.canvas._offset.top,{left:h.x+"px",top:h.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,this.hiddenTextarea&&(this.hiddenTextarea.blur&&this.hiddenTextarea.blur(),this.canvas&&this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea),this.hiddenTextarea=null),this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),o=r.lineIndex,a=r.charIndex,h=s.lineIndex,c=s.charIndex;if(o!==h){if(this.styles[o])for(i=a;i=c&&(n[l-f]=n[u],delete n[u])}},shiftLineStyles:function(t,e){var i=x(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,s={},o=!1;for(var a in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var h=parseInt(a,10);h>=e&&(o=!0,s[h-e]=this.styles[t][a],delete this.styles[t][a])}for(o?this.styles[t+i]=s:delete this.styles[t+i];i>1;)i--,n&&n[i]?this.styles[t+i]={0:x(n[i])}:r?this.styles[t+i]={0:x(r)}:delete this.styles[t+i];this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],s=r?x(r):{};for(var o in i||(i=1),s){var a=parseInt(o,10);a>=e&&(r[a+i]=s[a],s[a-i]||delete r[a])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=x(n[i]));else if(r)for(var h=r[e?e-1:1];h&&i--;)this.styles[t][e+i]=x(h)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,o=0;o0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s),o=1;o0?this.insertCharStyleObject(n.lineIndex+o,0,r[o],i):i&&(this.styles[n.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(n.lineIndex+o,0,r[o],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&it?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),C.util.object.extend(C.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&this.setCursorByClick(t.e),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e=this.getLocalPointer(t),i=0,n=0,r=0,s=0,o=0,a=0,h=this._textLines.length;a0&&(s+=this._textLines[a-1].length+this.missingNewlineOffset(a-1));n=this._getLineLeftOffset(o)*this.scaleX;for(var c=0,l=this._textLines[o].length;cs||o<0?0:1);return this.flipX&&(a=r-a),a>this._text.length&&(a=this._text.length),a}}),C.util.object.extend(C.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=C.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingーtop: "+t.fontSize+";",C.document.body.appendChild(this.hiddenTextarea),C.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),C.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),C.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),C.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),C.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),C.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),C.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),C.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),C.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(C.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing&&!this.inCompositionMode){if(t.keyCode in this.keysMap)this[this.keysMap[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,s=this._text.length,o=r.length,a=o-s;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var h=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),c=this.selectionStart>h.selectionStart;this.selectionStart!==this.selectionEnd?(i=this._text.slice(this.selectionStart,this.selectionEnd),a+=this.selectionEnd-this.selectionStart):o0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,o=this._getWidthBeforeCursor(r,s),a=this._getIndexOnLine(r+1,o);return this._textLines[r].slice(s).length+a+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,o=this._getWidthBeforeCursor(r,s),a=this._getIndexOnLine(r-1,o),h=this._textLines[r].slice(0,s),c=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-h.length+(1-c)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),o=0,a=0,h=r.length;ae){n=!0;var c=s-i,l=s,u=Math.abs(c-e);o=Math.abs(l-e)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==typeof n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=C.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),S=C.util.toFixed,w=/ +/g,C.util.object.extend(C.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t",t.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var o=0,a=this._textLines.length;o",C.util.string.escapeXml(t),""].join("")},_setSVGTextLineText:function(t,e,i,n){var r,s,o,a,h,c=this.getHeightOfLine(e),l=-1!==this.textAlign.indexOf("justify"),u="",f=0,d=this._textLines[e];n+=c*(1-this._fontSizeFraction)/this.lineHeight;for(var p=0,g=d.length-1;p<=g;p++)h=p===g||this.charSpacing,u+=d[p],o=this.__charBounds[e][p],0===f?(i+=o.kernedWidth-o.width,f+=o.width):f+=o.kernedWidth,l&&!h&&this._reSpaceAndTab.test(d[p])&&(h=!0),h||(r=r||this.getCompleteStyleDeclaration(e,p),s=this.getCompleteStyleDeclaration(e,p+1),h=this._hasStyleChangedForSvg(r,s)),h&&(a=this._getStyleDeclaration(e,p)||{},t.push(this._createTextCharSpan(u,a,i,n)),u="",r=s,i+=f,f=0)},_pushTextBgRect:function(t,e,i,n,r,s){var o=C.Object.NUM_FRACTION_DIGITS;t.push("\t\t\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,o=this._textLines[e],a=this.getHeightOfLine(e)/this.lineHeight,h=0,c=0,l=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),u=0,f=o.length;uthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],o=this._styleMap[t+1];for(var a in s&&(t=s.line,n=s.offset),o&&(r=o.line===t,e=o.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var h in i[a])if(h>=n&&(!r||h=n&&!m?(a.push(h),h=[],s=d,m=!0):s+=v,m||o||h.push(f),h=h.concat(l),p=this._measureWord([f],i,u),u++,m=!1,d>g&&(g=d);return b&&a.push(h),g+r>this.dynamicMinWidth&&(this.dynamicMinWidth=g-v+r),a},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),s=0;s1e4?t.toExponential(2):function(t){return Math.floor(t)===t?0:t.toString().split(".")[1].length||0}(t)>3?t.toFixed(3).toString():t.toString()}function f(t,e="json"){return h(this,void 0,void 0,(function*(){return yield o()(t).then(i=>{if(!i.ok)throw new Error("Could not retrieve data from "+t);if("json"!==e)return i.text();try{return i.json()}catch(e){throw new Error("Could not decode JSON data from "+t)}}).catch(t=>console.log(t))}))}function d(t,e){return t}function p(t){return`https://wwwdev.ebi.ac.uk/Tools/services/rest/${t.split("-")[0]}/result/${t}/jdp?format=json`}function g(t,e=!1){let i=!0;return t.required&&(i=i&&0!==t.value.trim().length),t.minLength&&(i=i&&t.value.trim().length>=t.minLength),t.maxLength&&(i=i&&t.value.trim().length<=t.maxLength),t.pattern&&(i=i&&t.pattern.test(t.value.trim())),e&&(i?console.log(`JobId "${t.value}" is valid!`):console.log(`JobId "${t.value}" is not valid!`)),i}function m(t){const e=Object.assign({},a.b);return e.value=t,e.value.startsWith("http")||e.value.includes("/")||e.value.includes("./")||!g(e)||(t=p(t)),t}function v(t,e=30){return function(t){return`https://www.ebi.ac.uk/Tools/dbfetch/dbfetch?db=iprmc;id=${t};format=iprmcxml;style=raw`}(function(t,e=30){let i="";for(const n of t.hits.slice(0,e))i+=""===i?""+n.hit_acc:","+n.hit_acc;return i}(t,e))}function b(t,e=30){return function(t,e){let i=0,n={};for(const r of t.interpromatch[0].protein)if(i++,i<=e){let t=[],e={};for(const i of r.match){let n={};if(void 0!==i.ipr){const r=`${y(i._attributes.dbname)}_${i.ipr[0]._attributes.id}`;t.includes(r)||t.push(r),r in e||(e[r]=[]),n={id:i.ipr[0]._attributes.id,name:i.ipr[0]._attributes.name,dbname:y(i._attributes.dbname),type:i.ipr[0]._attributes.type,altid:i._attributes.id,altname:i._attributes.name,status:i._attributes.status,model:i._attributes.model,evd:i._attributes.evd,start:Number(i.lcn[0]._attributes.start),end:Number(i.lcn[0]._attributes.end),fragments:i.lcn[0]._attributes.fragments,score:i.lcn[0]._attributes.fragments},e[r].push(n)}else{const r=`${y(i._attributes.dbname)}_${i._attributes.id}`;t.includes(r)||t.push(r),r in e||(e[r]=[]),n={id:i._attributes.id,name:i._attributes.name,dbname:y(i._attributes.dbname),status:i._attributes.status,model:i._attributes.model,evd:i._attributes.evd,type:"Unclassified",start:Number(i.lcn[0]._attributes.start),end:Number(i.lcn[0]._attributes.end),fragments:i.lcn[0]._attributes.fragments,score:i.lcn[0]._attributes.fragments},e[r].push(n)}}n[r._attributes.id]={id:r._attributes.id,name:r._attributes.name,length:Number(r._attributes.length),matches:t.sort(),match:e}}return n}(function(t){try{return JSON.parse(Object(r.xml2json)(t,{compact:!0,spaces:2,alwaysArray:!0}))}catch(t){return console.log("Cannot parse the resulting Dbfetch response (likely not formatted XML)!"),{}}}(t),e)}function y(t){let e="Unclassified";return"IPR"===(t=t.toUpperCase())||"INTERPRO"===t?e="InterPro":"CATHGENE3D"===t||"CATH-GENE3D"===t||"GENE3D"===t?e="CATH-Gene3D":"CDD"===t?e="CDD":"PANTHER"===t?e="PANTHER":"HAMAP"===t?e="HAMAP":"PFAM"===t?e="Pfam":"PIRSF"===t?e="PIRSF":"PRINTS"===t?e="PRINTS":"PROSITE PROFILES"===t||"PROSITE_PROFILES"===t||"PROFILE"===t?e="PROSITE profiles":"PROSITE PATTERNS"===t||"PROSITE_PATTERNS"===t||"PROSITE"===t?e="PROSITE patterns":"SFLD"===t?e="SFLD":"SMART"===t?e="SMART":"SUPERFAMILY"===t||"SSF"===t?e="SUPERFAMILY":"TIGERFAMS"===t?e="TIGRFAMs":"PRODOM"===t&&(e="PRODOM"),e}function _(t,e){const i=[];for(const n of e)for(const e of t[""+n].matches)i.push(e.split("_")[0]);return i.filter((t,e,i)=>i.indexOf(t)===e)}function x(t,e){let i="";return t.startsWith("IPR")?i="https://www.ebi.ac.uk/interpro/entry/InterPro/"+t:"CATH-Gene3D"===e?i="https://www.ebi.ac.uk/interpro/entry/cathgene3d/"+t:"CDD"===e?i="https://www.ebi.ac.uk/interpro/entry/cdd/"+t:"PANTHER"===e?i="https://www.ebi.ac.uk/interpro/entry/panther/"+t:"HAMAP"===e?i="https://www.ebi.ac.uk/interpro/entry/hamap/"+t:"Pfam"===e?i="https://www.ebi.ac.uk/interpro/entry/pfam/"+t:"PIRSF"===e?i="https://www.ebi.ac.uk/interpro/entry/pirsf/"+t:"PRINTS"===e?i="https://www.ebi.ac.uk/interpro/entry/prints/"+t:"PROSITE profiles"===e?i="https://www.ebi.ac.uk/interpro/entry/profile/"+t:"PROSITE patterns"===e?i="https://www.ebi.ac.uk/interpro/entry/prosite/"+t:"SFLD"===e?i="https://www.ebi.ac.uk/interpro/entry/sfld/"+t:"SMART"===e?i="https://www.ebi.ac.uk/interpro/entry/smart/"+t:"SUPERFAMILY"===e?i="https://www.ebi.ac.uk/interpro/entry/ssf/"+t:"TIGRFAMs"===e?i="https://www.ebi.ac.uk/interpro/entry/tigrfams/"+t:"PRODOM"===e&&(i="https://www.ebi.ac.uk/interpro/entry/prodom/"+t),i}},function(t,e,i){"use strict";i.d(e,"r",(function(){return c})),i.d(e,"q",(function(){return l})),i.d(e,"e",(function(){return u})),i.d(e,"x",(function(){return f})),i.d(e,"w",(function(){return d})),i.d(e,"l",(function(){return p})),i.d(e,"d",(function(){return g})),i.d(e,"f",(function(){return m})),i.d(e,"y",(function(){return v})),i.d(e,"g",(function(){return b})),i.d(e,"t",(function(){return y})),i.d(e,"F",(function(){return _})),i.d(e,"m",(function(){return x})),i.d(e,"n",(function(){return S})),i.d(e,"E",(function(){return w})),i.d(e,"b",(function(){return C})),i.d(e,"B",(function(){return T})),i.d(e,"A",(function(){return O})),i.d(e,"u",(function(){return E})),i.d(e,"v",(function(){return P})),i.d(e,"D",(function(){return j})),i.d(e,"C",(function(){return k})),i.d(e,"p",(function(){return A})),i.d(e,"a",(function(){return D})),i.d(e,"i",(function(){return L})),i.d(e,"h",(function(){return F})),i.d(e,"z",(function(){return M})),i.d(e,"j",(function(){return I})),i.d(e,"s",(function(){return R})),i.d(e,"c",(function(){return B})),i.d(e,"o",(function(){return W})),i.d(e,"k",(function(){return N})),i.d(e,"G",(function(){return z}));var n=i(0),r=i(2),s=i(6),o=i(8),a=i(1),h=i(7);function c(t,e,i){const r=i,s=Object.assign({},a.f);s.fontWeight="bold",s.fontSize=e.fontSize+1,s.top=i,s.left=5;const o=t.program,h=t.version,c=new n.fabric.Text(`${o} (version: ${h})`,s);let l=[];for(const e of t.dbs)l.push(e.name);const u=l.join(", ");s.fontWeight="normal",s.fontSize=e.fontSize,i+=15,s.top=i;const f=new n.fabric.Text("Database(s): "+u,s);i+=15,s.top=i;const d=new n.fabric.Text("Sequence: ",s),p=t.query_len;i+=15,s.top=i;const g=new n.fabric.Text("Length: "+p,s),m=t.start;s.top=r,s.left=e.canvasWidth-135;const v=new n.fabric.Text(""+m,s),b=t.end;s.top=r+15;const y=new n.fabric.Text(""+b,s);return new n.fabric.Group([c,f,d,g,v,y],a.d)}function l(t,e,i){const r=t.query_def,s=Object.assign({},a.f);s.fontFamily="Menlo",s.fontSize=e.fontSize-2,s.evented=!0,s.top=i-15,s.left=57.5;return[new n.fabric.Text(""+r,s),s]}function u(t,e,i){const r=Object.assign({},a.f);r.fontWeight="bold",r.fontSize=e.fontSize+1,r.top=i+2,r.textAlign="center";const o=Object(s.e)(t.queryLen,t.subjLen,t.queryLen,e.contentWidth,e.contentScoringWidth),h=Object(s.e)(t.queryLen,t.subjLen,t.subjLen,e.contentWidth,e.contentScoringWidth);r.left=t.startQueryPixels;const c=new n.fabric.Text("Sequence Match",r);let l;c.width=o,r.left=t.startEvalPixels,l=e.colorScheme===a.a.ncbiblast?new n.fabric.Text("Bit score",r):new n.fabric.Text("E-value",r),l.width=e.contentScoringWidth,r.left=t.startSubjPixels;const u=new n.fabric.Text("Subject Match",r);u.width=h;return new n.fabric.Group([c,l,u],a.d)}function f(t,e,i){const r=Object.assign({},a.c);r.top=i,r.stroke="black",r.strokeWidth=e.strokeWidth;const s=[t.startQueryPixels,i,t.endQueryPixels,i];r.left=t.startQueryPixels;const o=new n.fabric.Line(s,r),h=[t.startQueryPixels,i-3,t.startQueryPixels,i+3];r.top=i-2;const c=new n.fabric.Line(h,r),l=[t.endQueryPixels,i-3,t.endQueryPixels,i+3];r.left=t.endQueryPixels;const u=new n.fabric.Line(l,r),f=[t.startSubjPixels,i,t.endSubjPixels,i];r.top=i,r.left=t.startSubjPixels;const d=new n.fabric.Line(f,r),p=[t.startSubjPixels,i-3,t.startSubjPixels,i+3];r.top=i-2;const g=new n.fabric.Line(p,r),m=[t.endSubjPixels,i-3,t.endSubjPixels,i+3];r.left=t.endSubjPixels;const v=new n.fabric.Line(m,r);return new n.fabric.Group([o,d,c,u,g,v],a.d)}function d(t,e,i){const r=Object.assign({},a.c);r.top=i,r.stroke="black",r.strokeWidth=e.strokeWidth;const s=[t.startPixels,i,t.endPixels,i];r.left=t.startPixels;const o=new n.fabric.Line(s,r),h=[t.startPixels,i-3,t.startPixels,i+3];r.top=i-2;const c=new n.fabric.Line(h,r),l=[t.endPixels,i-3,t.endPixels,i+3];r.left=t.endPixels;const u=new n.fabric.Line(l,r);return new n.fabric.Group([o,c,u],a.d)}function p(t,e,i){const r=Object.assign({},a.c);r.top=i,r.stroke="black",r.strokeWidth=e.strokeWidth,r.strokeDashArray=e.strokeDashArray;const s=[t.startPixels,i,t.endPixels,i];return r.left=t.startPixels,new n.fabric.Line(s,r)}function g(t,e,i){const r=Object.assign({},a.f);r.fontSize=e.fontSize,r.top=i,r.left=t.startPixels-2.5;const o=new n.fabric.Text(""+t.start,r);let h=Object(s.d)(""+t.end);r.left=t.endPixels-h;const c=new n.fabric.Text(""+t.end,r);return new n.fabric.Group([o,c],a.d)}function m(t,e,i){const r=Object.assign({},a.f);r.fontSize=e.fontSize,r.top=i,r.left=t.startQueryPixels-2.5;const o=new n.fabric.Text("1",r);let h=Object(s.d)(""+t.queryLen);r.left=t.endQueryPixels-h;const c=new n.fabric.Text(""+t.queryLen,r);r.left=t.startSubjPixels-2.5;const l=new n.fabric.Text("1",r);h=Object(s.d)(""+t.subjLen),r.left=t.endSubjPixels-h;const u=new n.fabric.Text(""+t.subjLen,r);return new n.fabric.Group([o,c,l,u],a.d)}function v(t,e){const i=Object.assign({},a.f);i.fontWeight="bold",i.fontSize=t.fontSize+1,i.top=e,i.left=t.contentWidth/2,i.fill="red";return new n.fabric.Text("--------------------No hits found--------------------",i)}function b(t,e,i,r){const s=Object.assign({},a.f);s.fontFamily="Menlo",s.fontSize=i.fontSize-2,s.top=r-2;const o=" ".repeat(t-(e.hit_db.length+e.hit_id.length)),h=new n.fabric.Text(o,s);let c=`${e.hit_db}:${e.hit_id} ${e.hit_desc}`,l=`${o}${e.hit_db}:${e.hit_id} ${e.hit_desc}`;l.length>40&&(c=(l.slice(0,38)+"...").slice(o.length)),s.left=10+6*o.length,s.evented=!0;return[h,new n.fabric.Text(c,s),s]}function y(t,e,i,r){const s=Object.assign({},a.f);s.fontSize=i.fontSize,s.top=r,s.left=i.contentWidth/2,s.fill="red";return new n.fabric.Text(`This hit contains ${t} alignments, but only the first ${e} are displayed!`,s)}function _(t,e,i,s){const o=Object.assign({},a.f);let h;return o.fontSize=i.fontSize,o.top=s-15,o.textAlign="center",o.left=t,h=i.colorScheme===a.a.ncbiblast?new n.fabric.Text(Object(r.j)(e.hsp_bit_score),o):new n.fabric.Text(Object(r.j)(e.hsp_expect),o),h}function x(t,e,i,r,s,o){const h=Object.assign({},a.e);h.evented=!0,h.top=s,h.fill=o,h.rx=5,h.ry=5,h.top=s-15,h.left=t,h.width=e,h.height=10;const c=new n.fabric.Rect(h);h.top=s-15,h.left=i,h.width=r,h.height=10;return[c,new n.fabric.Rect(h)]}function S(t,e,i,s,o,h,c){const l=Object.assign({},a.f);let u;l.fontSize=h.fontSize+1,l.textAlign="left",l.originX="top",l.originY="top",l.top=5,u=h.colorScheme===a.a.ncbiblast?`Start: ${i}\nEnd: ${s}\nBit score: ${Object(r.j)(o.hsp_bit_score)}`:`Start: ${i}\nEnd: ${s}\nE-value: ${Object(r.j)(o.hsp_expect)}`;const f=new n.fabric.Text(u,l),d=Object.assign({},a.e);d.fill="white",d.stroke="lightseagreen",d.rx=5,d.ry=5,d.originX="top",d.originY="top",d.width=140,d.height=60,d.opacity=.95;const p=new n.fabric.Rect(d);return new n.fabric.Group([p,f],{selectable:!1,evented:!1,objectCaching:!1,visible:!1,top:c,left:t+e/2})}function w(t,e){const i=Object.assign({},a.f);i.fontSize=t.fontSize+1,i.fontWeight="bold",i.top=e,i.left=t.scaleLabelWidth;return new n.fabric.Text("Scale Type:",i)}function C(t,e){const i=Object.assign({},a.f);i.fontSize=t.fontSize+1,i.top=e,i.left=t.scaleLabelWidth;const r=Object.assign({},a.f);r.fontSize=t.fontSize+12,r.fill="grey",r.evented=!0,r.top=e-8,r.left=t.scaleLabelWidth;const s=Object.assign({},r),o=Object.assign({},r);let h;h=t.colorScheme===a.a.dynamic?"☒":"☐",t.colorScheme===a.a.dynamic&&(r.fill="black"),r.left+=80;const c=new n.fabric.Text(h,r);i.left+=100;const l=new n.fabric.Text("Dynamic (E-value: min to max)",i);h=t.colorScheme===a.a.fixed?"☒":"☐",t.colorScheme===a.a.fixed&&(s.fill="black"),s.left+=290;const u=new n.fabric.Text(h,s);i.left+=210;const f=new n.fabric.Text("Fixed (E-value: 0.0 to 100.0)",i);h=t.colorScheme===a.a.ncbiblast?"☒":"☐",t.colorScheme===a.a.ncbiblast&&(o.fill="black"),o.left+=480;const d=new n.fabric.Text(h,o);i.left+=190;return[c,l,r,u,f,s,d,new n.fabric.Text("NCBI BLAST+ (Bit score: <40 to ≥200)",i),o]}function T(t,e){const i=Object.assign({},a.f);let r;i.fontSize=t.fontSize+1,i.top=e,r=t.colorScheme===a.a.ncbiblast?"Bit score":"E-value",t.colorScheme===a.a.ncbiblast?i.left=t.scaleLabelWidth-56:i.left=t.scaleLabelWidth-50;return new n.fabric.Text(""+r,i)}function O(t,e){const i=Object.assign({},a.e);i.top=e,i.left=t.scaleLabelWidth,i.width=t.scaleWidth,i.height=15;const r=new n.fabric.Rect(i);return t.colorScheme===a.a.ncbiblast?Object(o.b)(r,0,t.scaleWidth):Object(o.a)(r,0,t.scaleWidth),r}function E(t,e,i,r,s,o,h){const c=Object.assign({},a.c);c.top=h,c.stroke="black",c.strokeWidth=o.strokeWidth;const l=[t,h,s,h];c.left=t;const u=new n.fabric.Line(l,c),f=[t,h,t,h+4],d=new n.fabric.Line(f,c),p=[e,h,e,h+4];c.left=e;const g=new n.fabric.Line(p,c),m=[i,h,i,h+4];c.left=i;const v=new n.fabric.Line(m,c),b=[r,h,r,h+4];c.left=r;const y=new n.fabric.Line(b,c),_=[s,h,s,h+4];c.left=s;const x=new n.fabric.Line(_,c);return new n.fabric.Group([u,d,g,v,y,x],a.d)}function P(t,e,i,r,s,o,h,c){const l=Object.assign({},a.c);l.top=c,l.stroke="black",l.strokeWidth=h.strokeWidth;const u=[t,c,o,c];l.left=t;const f=new n.fabric.Line(u,l),d=[t,c,t,c+4],p=new n.fabric.Line(d,l),g=[e,c,e,c+4];l.left=e;const m=new n.fabric.Line(g,l),v=[i,c,i,c+4];l.left=i;const b=new n.fabric.Line(v,l),y=[r,c,r,c+4];l.left=r;const _=new n.fabric.Line(y,l),x=[s,c,s,c+4];l.left=s;const S=new n.fabric.Line(x,l),w=[o,c,o,c+4];l.left=o;const C=new n.fabric.Line(w,l);return new n.fabric.Group([f,p,m,b,_,S,C],a.d)}function j(t,e,i,r){const s=Object.assign({},a.f);s.top=r,s.fontSize=i.fontSize;let o="<"+t[1];s.left=i.scaleLabelWidth+e-3*o.length-72;const h=new n.fabric.Text(o,s);o=`${t[1]} - ${t[2]}`,s.left=i.scaleLabelWidth+2*e-3*o.length-72;const c=new n.fabric.Text(o,s);o=`${t[2]} - ${t[3]}`,s.left=i.scaleLabelWidth+3*e-3*o.length-72;const l=new n.fabric.Text(o,s);o=`${t[3]} - ${t[4]}`,s.left=i.scaleLabelWidth+4*e-3*o.length-72;const u=new n.fabric.Text(o,s);o="≥"+t[4],s.left=i.scaleLabelWidth+i.scaleWidth-3*o.length-72;const f=new n.fabric.Text(o,s);return new n.fabric.Group([h,c,l,u,f],a.d)}function k(t,e,i,s){const o=Object.assign({},a.f);o.top=s,o.fontSize=i.fontSize,o.left=i.scaleLabelWidth-3*Object(r.j)(t[0]).length;const h=new n.fabric.Text(Object(r.j)(t[0]),o);o.left=i.scaleLabelWidth+e-3*Object(r.j)(t[1]).length;const c=new n.fabric.Text(Object(r.j)(t[1]),o);o.left=i.scaleLabelWidth+2*e-3*Object(r.j)(t[2]).length;const l=new n.fabric.Text(Object(r.j)(t[2]),o);o.left=i.scaleLabelWidth+3*e-3*Object(r.j)(t[3]).length;const u=new n.fabric.Text(Object(r.j)(t[3]),o);o.left=i.scaleLabelWidth+i.scaleWidth-3*Object(r.j)(t[4]).length;const f=new n.fabric.Text(Object(r.j)(t[4]),o);return new n.fabric.Group([h,c,l,u,f],a.d)}function A(t,e){const i=Object.assign({},a.f);i.fontSize=t.fontSize,i.evented=!0,i.top=e,i.left=225;return[new n.fabric.Text("European Bioinformatics Institute 2006-2020. EBI is an Outstation of the European Molecular Biology Laboratory.",i),i]}function D(t){return new n.fabric.Rect({selectable:!1,evented:!1,objectCaching:!1,top:0,left:0,width:t.canvasWidth-1,height:t.canvasHeight-1,strokeWidth:1,stroke:"lightseagreen",fill:"transparent"})}function L(t,e){const i=Object.assign({},a.f);i.fontWeight="bold",i.fontSize=t.fontSize+2,i.top=e,i.left=350;return new n.fabric.Text("Fast Family and Domain Prediction by InterPro",i)}function F(t,e,i){const r=Object.assign({},a.f);r.fontSize=t.fontSize,r.top=e,r.left=t.contentWidth/2,r.fill="red";const s=`This is a partial representation of the result, only the first ${i} hits are displayed!`;return new n.fabric.Text(""+s,r)}function M(t,e){const i=Object.assign({},a.f);i.fontSize=t.fontSize+1,i.fontWeight="bold",i.top=e,i.left=t.scaleLabelWidth-10;return new n.fabric.Text("Select your database:",i)}function I(t,e,i,r){const s=Object.assign({},a.e);s.top=e,s.left=i,s.height=15,s.width=15,s.evented=!0;const o=Object.assign({},a.f);o.fontSize=t.fontSize+1,o.top=e,o.left=i+20,t.currentDisabled?(o.fill="grey",s.fill="white",s.stroke="grey"):void 0!==t.currentDomainDatabase?(s.fill=Object(h.a)(t.currentDomainDatabase),s.stroke="black"):(s.fill="white",s.stroke="grey");return[new n.fabric.Rect(s),new n.fabric.Text(r,o),s,s]}function R(t,e,i,r,s){const o=Object.assign({},a.e);return o.fill=r,o.opacity=.5,o.rx=5,o.ry=5,o.top=i+15,o.left=t,o.width=e,o.height=s,new n.fabric.Rect(o)}function B(t,e,i){const r=Object.assign({},a.f);r.fontFamily="Menlo",r.fontSize=e.fontSize-2,r.top=i-5;const s=" ".repeat(40-t.length),o=new n.fabric.Text(s,r);let h=""+t,c=`${s}${t}`;c.length>40&&(h=(c.slice(0,38)+"...").slice(s.length)),r.left=12+6*s.length,r.evented=!0;return[o,new n.fabric.Text(h,r),r]}function W(t,e,i,r){const s=Object.assign({},a.e);return s.evented=!0,s.top=i,s.fill=r,s.rx=5,s.ry=5,s.top=i-15,s.left=t,s.width=e,s.height=10,s.stroke="black",s.strokeWidth=.5,new n.fabric.Rect(s)}function N(t,e,i,r,s,o,h){const c=Object.assign({},a.f);c.fontSize=o.fontSize+1,c.textAlign="left",c.originX="top",c.originY="top",c.top=5,c.left=10,c.width=200;let l=`Start: ${i}\nEnd: ${r}\nDatabase: ${s.dbname}\n`;void 0!==s.altid&&void 0!==s.altname?l+=`ID: ${s.altid}\nName: ${s.altname}\nType: ${s.type}\nIPR ID: ${s.id}\nIPR Name: ${s.name}\n`:l+=`ID: ${s.id}\nName: ${s.name}\nType: ${s.type}\n`;const u=new n.fabric.Textbox(l,c),f=Object.assign({},a.e);f.fill="white",f.stroke="lightseagreen",f.rx=5,f.ry=5,f.originX="top",f.originY="top",f.width=u.width+40,f.height=u.height,f.opacity=.95;const d=new n.fabric.Rect(f);return new n.fabric.Group([d,u],{selectable:!1,evented:!1,objectCaching:!1,visible:!1,top:h,left:t+e/2})}function z(t,e,i,r,s){const o=Object.assign({},a.f);let h;if(o.fontSize=r.fontSize+1,o.originX="left",o.originY="top",o.top=5,o.left=5,e.length>150&&(e=e.slice(0,150)+"..."),""!==e){const t=6.3*e.length,r=6.3*i.length;o.width=t>r?t+5:r+5,h=new n.fabric.Text(e+"\n"+i,o)}else{const t=6.3*i.length;o.width=t+5,h=new n.fabric.Text(""+i,o)}const c=Object.assign({},a.e);c.fill="white",c.stroke="lightseagreen",c.strokeWidth=.5,c.rx=5,c.ry=5,c.originX="left",c.originY="top",c.width=h.width+10,c.height=h.height+10,c.opacity=.95;const l=new n.fabric.Rect(c),u=new n.fabric.Group([l,h],{selectable:!1,evented:!1,objectCaching:!1,visible:!0,top:s,originX:"left"});return u.left=t+10,u}},function(t,e,i){"use strict";i.d(e,"k",(function(){return r})),i.d(e,"c",(function(){return s})),i.d(e,"g",(function(){return o})),i.d(e,"i",(function(){return a})),i.d(e,"e",(function(){return h})),i.d(e,"h",(function(){return c})),i.d(e,"a",(function(){return l})),i.d(e,"d",(function(){return u})),i.d(e,"j",(function(){return f})),i.d(e,"b",(function(){return d})),i.d(e,"f",(function(){return p}));var n=i(3);function r(t,e,i,r,s,o){t.on("mouseover",a=>{if(a.target){a.target.set("hoverCursor","pointer"),a.target.setOptions(e),a.target.setOptions({underline:!0});const h=Object(n.G)(+t.left,i,r,s,+t.top+15);o.canvas.add(h),o.canvas.renderAll(),h.visible=!1}})}function s(t,e,i){t.on("mousedown",t=>{t.target&&(window.open(e,"_blank"),i.canvas.renderAll())})}function o(t,e,i){t.on("mouseout",t=>{t.target&&(t.target.setOptions(e),t.target.setOptions({underline:!1}),i.canvas.renderAll())})}function a(t,e,i,r,s,o,a,h){t.on("mouseover",c=>{if(c.target){let l;c.target.set("hoverCursor","pointer"),l="hsp_hit_from"in o?Object(n.n)(e,i,r,s,o,a,t.top+5):Object(n.k)(e,i,r,s,o,a,t.top+5),h.canvas.add(l),l.set({visible:!0}),t.bringToFront(),l.bringToFront(),h.canvas.renderAll(),l.set({visible:!1})}})}function h(t,e){t.on("mouseout",t=>{t.target&&e.canvas.renderAll()})}function c(t,e,i){t.on("mouseover",t=>{t.target&&(t.target.set("hoverCursor","pointer"),t.target.setOptions(e),t.target.setOptions({fill:"black"}),i.canvas.renderAll())})}function l(t,e,i){t.on("mousedown",t=>{t.target&&i.colorScheme!=e&&(i.colorScheme=e,i.render())})}function u(t,e,i,n){t.on("mouseout",t=>{t.target&&(t.target.setOptions(e),n.colorScheme!=i&&t.target.setOptions({fill:"grey"}),n.canvas.renderAll())})}function f(t,e,i,n){t.on("mouseover",t=>{if(t.target){t.target.set("hoverCursor","pointer"),t.target.setOptions(e);let r=!1;n.uniqueDomainDatabases.includes(i)||(r=!0),r?(t.target.setOptions({fill:"white",stroke:"grey"}),t.target.set("hoverCursor","default")):n.domainDatabaseList.includes(i)?(t.target.setOptions({opacity:.5,stroke:"grey"}),t.target.set("hoverCursor","pointer")):(t.target.setOptions({stroke:"black"}),t.target.set("hoverCursor","pointer")),n.canvas.renderAll()}})}function d(t,e,i){t.on("mousedown",t=>{if(t.target)if(!i.domainDatabaseList.includes(e)&&i.uniqueDomainDatabases.includes(e))i.domainDatabaseList.push(e),i.currentDomainDatabase=e,i.render();else if(i.uniqueDomainDatabases.includes(e)){const t=i.domainDatabaseList.indexOf(e);t>-1&&i.domainDatabaseList.splice(t,1),i.currentDomainDatabase=void 0,i.render()}})}function p(t,e,i,n){t.on("mouseout",t=>{if(t.target){let r=!1;n.uniqueDomainDatabases.includes(i)||(r=!0),n.domainDatabaseList.includes(i)?r?t.target.setOptions({stroke:"grey",fill:"white"}):(t.target.setOptions(e),t.target.setOptions({opacity:1,stroke:"black"})):t.target.setOptions({stroke:"grey",fill:"white"}),n.canvas.renderAll()}})}},function(t,e,i){"use strict";i.d(e,"b",(function(){return K})),i.d(e,"d",(function(){return Q})),i.d(e,"c",(function(){return B})),i.d(e,"a",(function(){return tt})); +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +const n="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,r=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},s=`{{lit-${String(Math.random()).slice(2)}}}`,o=`\x3c!--${s}--\x3e`,a=new RegExp(`${s}|${o}`);class h{constructor(t,e){this.parts=[],this.element=e;const i=[],n=[],r=document.createTreeWalker(e.content,133,null,!1);let o=0,h=-1,l=0;const{strings:d,values:{length:p}}=t;for(;l0;){const e=d[l],i=f.exec(e)[2],n=i.toLowerCase()+"$lit$",r=t.getAttribute(n);t.removeAttribute(n);const s=r.split(a);this.parts.push({type:"attribute",index:h,name:i,strings:s}),l+=s.length-1}}"TEMPLATE"===t.tagName&&(n.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(s)>=0){const n=t.parentNode,r=e.split(a),s=r.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},l=t=>-1!==t.index,u=()=>document.createComment(""),f=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function d(t,e){const{element:{content:i},parts:n}=t,r=document.createTreeWalker(i,133,null,!1);let s=g(n),o=n[s],a=-1,h=0;const c=[];let l=null;for(;r.nextNode();){a++;const t=r.currentNode;for(t.previousSibling===l&&(l=null),e.has(t)&&(c.push(t),null===l&&(l=t)),null!==l&&h++;void 0!==o&&o.index===a;)o.index=null!==l?-1:o.index-h,s=g(n,s),o=n[s]}c.forEach(t=>t.parentNode.removeChild(t))}const p=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},g=(t,e=-1)=>{for(let i=e+1;i"function"==typeof t&&m.has(t),b={},y={}; +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +class _{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=n?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],i=this.template.parts,r=document.createTreeWalker(t,133,null,!1);let s,o=0,a=0,h=r.nextNode();for(;o-1||i)&&-1===t.indexOf("--\x3e",r+1);const a=f.exec(t);e+=null===a?t+(i?x:o):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+s}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}} +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +const w=t=>null===t||!("object"==typeof t||"function"==typeof t),C=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class T{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return A=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class D{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;v(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=b,t(this)}if(this.__pendingValue===b)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=L(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=b}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const L=t=>t&&(A?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */;function F(t){let e=M.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},M.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(s);return i=e.keyString.get(n),void 0===i&&(i=new h(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const M=new Map,I=new WeakMap; +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */const R=new +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +class{handleAttributeExpressions(t,e,i,n){const r=e[0];if("."===r){return new j(t,e.slice(1),i).parts}if("@"===r)return[new D(t,e.slice(1),n.eventContext)];if("?"===r)return[new P(t,e.slice(1),i)];return new T(t,e,i).parts}handleTextExpression(t){return new E(t)}}; +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.2.1");const B=(t,...e)=>new S(t,e,"html",R),W=(t,e)=>`${t}--${e}`;let N=!0;void 0===window.ShadyCSS?N=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),N=!1);const z=t=>e=>{const i=W(e.type,t);let n=M.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},M.set(i,n));let r=n.stringsArray.get(e.strings);if(void 0!==r)return r;const o=e.strings.join(s);if(r=n.keyString.get(o),void 0===r){const i=e.getTemplateElement();N&&window.ShadyCSS.prepareTemplateDom(i,t),r=new h(e,i),n.keyString.set(o,r)}return n.stringsArray.set(e.strings,r),r},U=["html","svg"],Y=new Set,X=(t,e,i)=>{Y.add(t);const n=i?i.element:document.createElement("template"),r=e.querySelectorAll("style"),{length:s}=r;if(0===s)return void window.ShadyCSS.prepareTemplateStyles(n,t);const o=document.createElement("style");for(let t=0;t{U.forEach(e=>{const i=M.get(W(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),d(t,i)})})})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:r}=t;if(null==i)return void n.appendChild(e);const s=document.createTreeWalker(n,133,null,!1);let o=g(r),a=0,h=-1;for(;s.nextNode();){h++;for(s.currentNode===i&&(a=p(e),i.parentNode.insertBefore(e,i));-1!==o&&r[o].index===h;){if(a>0){for(;-1!==o;)r[o].index+=a,o=g(r,o);return}o=g(r,o)}}}(i,o,a.firstChild):a.insertBefore(o,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const h=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==h)e.insertBefore(h.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(o,a.firstChild);const t=new Set;t.add(o),d(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const G={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},H=(t,e)=>e!==t&&(e==e||t==t),V={attribute:!0,type:String,converter:G,reflect:!1,hasChanged:H};class q extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=V){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(i){const n=this[t];this[e]=i,this._requestUpdate(t,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||V}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=H){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||G,r="function"==typeof n?n:n.fromAttribute;return r?r(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||G.toAttribute)(t,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=V){const n=this.constructor,r=n._attributeNameForProperty(t,i);if(void 0!==r){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(r):this.setAttribute(r,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}_requestUpdate(t,e){let i=!0;if(void 0!==t){const n=this.constructor,r=n.getPropertyOptions(t);n._valueHasChanged(this[t],e,r.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==r.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,r))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this._requestUpdate(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}q.finalized=!0; +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +const K=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(t,e),$=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function Q(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):$(t,e)} +/** +@license +Copyright (c) 2019 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at +http://polymer.github.io/LICENSE.txt The complete set of authors may be found at +http://polymer.github.io/AUTHORS.txt The complete set of contributors may be +found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as +part of the polymer project is also subject to an additional IP rights grant +found at http://polymer.github.io/PATENTS.txt +*/ +const J="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype;Symbol(); +/** + * @license + * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");const Z={};class tt extends q{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(void 0===t)this._styles=[];else if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=[t]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?J?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==Z&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return Z}}tt.finalized=!0,tt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,s=I.has(e),o=N&&11===e.nodeType&&!!e.host,a=o&&!Y.has(n),h=a?document.createDocumentFragment():e;if(((t,e,i)=>{let n=I.get(e);void 0===n&&(r(e,e.firstChild),I.set(e,n=new E(Object.assign({templateFactory:F},i))),n.appendInto(e)),n.setValue(t),n.commit()})(t,h,Object.assign({templateFactory:z(n)},i)),a){const t=I.get(h);I.delete(h);const i=t.value instanceof _?t.value.template:void 0;X(n,h,i),r(e,e.firstChild),e.appendChild(h),I.set(e,t)}!s&&o&&window.ShadyCSS.styleElement(e.host)}},function(t,e,i){"use strict";function n(t){let e=0;return 1===t.length?e=2.5:2===t.length?e=10:3===t.length?e=15.5:4===t.length?e=21:5===t.length?e=29:6===t.length?e=35:7===t.length?e=41:8===t.length&&(e=47),e}function r(t,e,i,n,r){return(i*n-r)/(t+e)}function s(t,e,i){return[e+i,e+t-i]}function o(t,e,i,n,s,o,a){const h=r(t,e,t,n,s);return[o+a,o+h-a,o+h+s+a,o+h+s+r(t,e,i,n,s)-a]}function a(t,e,i,n,r,s){const o=t+n*(e-t)/i+s;return[o,t+r*(e-t)/i-s-o]}i.d(e,"d",(function(){return n})),i.d(e,"e",(function(){return r})),i.d(e,"b",(function(){return s})),i.d(e,"c",(function(){return o})),i.d(e,"a",(function(){return a}))},function(t,e,i){"use strict";i.d(e,"d",(function(){return r})),i.d(e,"c",(function(){return s})),i.d(e,"b",(function(){return o})),i.d(e,"a",(function(){return a}));var n=i(1);function r(t,e,i){const n=i.keys;if(n.length!=e.length)throw Error("Color Scheme and Gradient Steps should have matching lengths!");if(t+0===0)return`rgb(${i[n[0]].join(",")})`;{const i=e[0],n=e[1],r=e[2],s=e[3],o=e[4];let a;if(t=e[1]&&t=e[2]&&t=e[3]&&t=e[4]?`rgb(${i[n[4]].join(",")})`:"rgb(192,192,192)"}function o(t,e,i,r){let s=[];if(r===n.a.fixed)s=[0,Math.pow(10,-1),Math.pow(10,0),Math.pow(10,1),Math.pow(10,2)];else if(r===n.a.dynamic)if(e<1e-304){const t=-304;s=[0,Math.pow(10,t),Math.pow(10,t/2),Math.pow(10,t/4),Math.pow(10,t/8)]}else if(t<1){const n=Math.log10(e);if(e<=1){let r,o,a;if(0===t&&i>0)r=Math.log10(i)-1;else{const e=Math.log10(t);r=e+(n-e)/2}o=r+(n-r)/2,a=o+(n-o)/2,s=[t,Math.pow(10,r),Math.pow(10,o),Math.pow(10,a),e]}else{const n=Math.log10(i)-Math.log10(e);s=Math.abs(n)<=2?[t,1,(2+e)/3,(2+2*e)/3,e]:Math.abs(n)<=4?[t,Math.pow(10,n/2),1,(e+1)/2,e]:[t,Math.pow(10,n/2),Math.pow(10,n/4),1,e]}}else s=[t,(3*t+e)/4,(t+e)/2,(t+3*e)/4,e];else s=r===n.a.ncbiblast?[0,40,50,80,200]:[0,1e-5,.01,1,100];return s}function a(t){let e;return e="Pfam"==t?"rgb(211,47,47)":"SUPERFAMILY"==t?"rgb(171,71,188)":"SMART"==t?"rgb(106,27,154)":"HAMAP"==t?"rgb(57,73,171)":"PANTHER"==t?"rgb(33,150,243)":"PRODOM"==t?"rgb(0,188,212)":"PROSITE profiles"==t?"rgb(0,150,136)":"CDD"==t?"rgb(76,175,80)":"CATH-Gene3D"==t?"rgb(205,220,57)":"PIRSF"==t?"rgb(255,235,59)":"PRINTS"==t?"rgb(255,193,7)":"TIGRFAMs"==t?"rgb(255,112,67)":"SFLD"==t?"rgb(121,85,72)":"PROSITE patterns"==t?"rgb(55,71,79)":"rgb(128,128,128)",e}},function(t,e,i){"use strict";i.d(e,"c",(function(){return n})),i.d(e,"a",(function(){return r})),i.d(e,"d",(function(){return s})),i.d(e,"b",(function(){return o}));const n={0:[255,64,64],.25:[255,255,64],.5:[64,255,64],.75:[64,255,255],1:[64,64,255],keys:[0,.25,.5,.75,1]};function r(t,e,i){t.setGradient("fill",{type:"linear",x1:e,y1:0,x2:i,y2:0,colorStops:{0:`rgb(${n[0].join(",")})`,.25:`rgb(${n[.25].join(",")})`,.5:`rgb(${n[.5].join(",")})`,.75:`rgb(${n[.75].join(",")})`,1:`rgb(${n[1].join(",")})`}})}const s={0:[0,0,0],40:[0,32,233],50:[117,234,76],80:[219,61,233],200:[219,51,36],keys:[0,40,50,80,200]};function o(t,e,i){t.setGradient("fill",{type:"linear",x1:e,y1:0,x2:i,y2:0,colorStops:{0:`rgb(${s[0].join(",")})`,.199999:`rgb(${s[0].join(",")})`,.2:`rgb(${s[40].join(",")})`,.399999:`rgb(${s[40].join(",")})`,.4:`rgb(${s[50].join(",")})`,.599999:`rgb(${s[50].join(",")})`,.6:`rgb(${s[80].join(",")})`,.799999:`rgb(${s[80].join(",")})`,.8:`rgb(${s[200].join(",")})`,1:`rgb(${s[200].join(",")})`}})}},function(t,e,i){"use strict";var n=i(18),r=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=u;var s=Object.create(i(16));s.inherits=i(13);var o=i(29),a=i(22);s.inherits(u,o);for(var h=r(a.prototype),c=0;cthis.subjLen&&(this.subjLen=t.hit_len);const t=this.queryLen/this.subjLen,e=this.subjLen/this.queryLen;t>8&&(this.subjFactor=.5*this.queryLen/this.subjLen),e>8&&(this.queryFactor=.5*this.subjLen/this.queryLen)}loadInitialCoords(){this.startQueryPixels=l.get("startQueryPixels"),this.endQueryPixels=l.get("endQueryPixels"),this.startSubjPixels=l.get("startSubjPixels"),this.endSubjPixels=l.get("endSubjPixels"),this.startEvalPixels=l.get("startEvalPixels"),this.startQueryPixels||this.endQueryPixels||this.startSubjPixels||this.endSubjPixels||this.startEvalPixels||([this.startQueryPixels,this.endQueryPixels,this.startSubjPixels,this.endSubjPixels]=Object(r.c)(this.queryLen*this.queryFactor,this.subjLen*this.subjFactor,this.subjLen*this.subjFactor,this.contentWidth,this.contentScoringWidth,this.contentLabelWidth,this.marginWidth),this.startEvalPixels=this.endQueryPixels+2*this.marginWidth,l.put("startQueryPixels",this.startQueryPixels),l.put("endQueryPixels",this.endQueryPixels),l.put("startSubjPixels",this.startSubjPixels),l.put("endSubjPixels",this.endSubjPixels),l.put("startEvalPixels",this.startEvalPixels))}drawHeaderGroup(){let t,e,i;this.topPadding=2,t=l.get("textHeaderGroup"),t||(t=Object(c.r)(this.dataObj,{fontSize:this.fontSize,canvasWidth:this.canvasWidth},this.topPadding),l.put("textHeaderGroup",t)),this.canvas.add(t),this.topPadding+=45,e=l.get("textHeaderLink"),i=l.get("textHeaderLink_textSeqObj"),e||([e,i]=Object(c.q)(this.dataObj,{fontSize:this.fontSize},this.topPadding),l.put("textHeaderLink",e),l.put("textHeaderLink_textSeqObj",i)),this.canvas.add(e),this.staticCanvas||null!==this.dataObj.query_url&&""!==this.dataObj.query_url&&(Object(h.k)(e,i,this.dataObj.query_def,this.dataObj.query_url,{fontSize:this.fontSize},this),Object(h.c)(e,this.dataObj.query_url,this),Object(h.g)(e,i,this))}drawContentGroup(){if(this.dataObj.hits.length>0){let t,e,i;this.topPadding+=25,t=l.get("textContentHeaderGroup"),t||(t=Object(c.e)({queryLen:this.queryLen*this.queryFactor,subjLen:this.subjLen*this.subjFactor,startQueryPixels:this.startQueryPixels,startEvalPixels:this.startEvalPixels,startSubjPixels:this.startSubjPixels},{contentWidth:this.contentWidth,contentScoringWidth:this.contentScoringWidth,fontSize:this.fontSize,colorScheme:this.colorScheme},this.topPadding),l.put("textContentHeaderGroup",t)),this.canvas.add(t),this.topPadding+=20,e=l.get("lineTrackGroup"),e||(e=Object(c.x)({startQueryPixels:this.startQueryPixels,endQueryPixels:this.endQueryPixels,startSubjPixels:this.startSubjPixels,endSubjPixels:this.endSubjPixels},{strokeWidth:2},this.topPadding),l.put("lineTrackGroup",e)),this.canvas.add(e),this.topPadding+=5,i=l.get("textContentFooterGroup"),i||(i=Object(c.f)({queryLen:this.queryLen,subjLen:this.subjLen,startQueryPixels:this.startQueryPixels,endQueryPixels:this.endQueryPixels,startSubjPixels:this.startSubjPixels,endSubjPixels:this.endSubjPixels},{fontSize:this.fontSize},this.topPadding),l.put("textContentFooterGroup",i)),this.canvas.add(i),this.topPadding+=25,this.drawDynamicContentGroup(),this.topPadding+=20,this.drawColorScaleGroup()}else{this.topPadding+=20;const t=Object(c.y)({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding);this.canvas.add(t)}}drawDynamicContentGroup(){let t=0,e=0;for(const i of this.dataObj.hits.slice(0,this.numberHits))i.hit_len>t&&(t=i.hit_len),i.hit_db.length+i.hit_id.length>e&&(e=i.hit_db.length+i.hit_id.length);let i=Number.MAX_VALUE,o=0,u=Number.MAX_VALUE;for(const t of this.dataObj.hits.slice(0,this.numberHits))for(const e of t.hit_hsps)this.colorScheme===a.a.ncbiblast?(e.hsp_bit_scoreo&&(o=e.hsp_bit_score),e.hsp_bit_score0&&(u=e.hsp_bit_score)):(e.hsp_expecto&&(o=e.hsp_expect),e.hsp_expect0&&(u=e.hsp_expect));this.colorScheme,a.a.ncbiblast,this.gradientSteps=Object(s.b)(i,o,u,this.colorScheme);let f=0;for(const t of this.dataObj.hits){if(f++,!(f<=this.numberHits)){let t;this.topPadding+=20,t=l.get("supressText"),t||(t=Object(c.h)({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding,this.numberHits),l.put("supressText",t)),t.top=this.topPadding,this.canvas.add(t),this.topPadding+=20;break}{let i=0;const o=t.hit_hsps.length;let u,f,d;[f,d,u]=Object(c.g)(e,t,{fontSize:this.fontSize},this.topPadding),this.canvas.add(f),this.canvas.add(d),this.staticCanvas||(Object(h.k)(d,u,t.hit_def,t.hit_url,{fontSize:this.fontSize},this),Object(h.c)(d,t.hit_url,this),Object(h.g)(d,u,this));for(const e of t.hit_hsps){if(i++,!(i<=this.numberHsps)){if(!0===this.logSkippedHsps){let t;t=l.get("hspTextNotice"),t||(t=Object(c.t)(o,this.numberHsps,{fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding),l.put("hspTextNotice",t)),this.canvas.add(t),this.topPadding+=20}break}{const i=t.hit_len;let o,l,u,f;[o,l,u,f]=Object(r.c)(this.queryLen*this.queryFactor,this.subjLen*this.subjFactor,i,this.contentWidth,this.contentScoringWidth,this.contentLabelWidth,this.marginWidth),this.topPadding+=5;const d=Object(c.x)({startQueryPixels:o,endQueryPixels:l,startSubjPixels:u,endSubjPixels:f},{strokeWidth:1},this.topPadding);let p,g,m,v,b,y,_,x,S,w,C;this.canvas.add(d),"-1"===e.hsp_query_frame?(b=e.hsp_query_to,y=e.hsp_query_from):(b=e.hsp_query_from,y=e.hsp_query_to),"-1"===e.hsp_hit_frame?(_=e.hsp_hit_to,x=e.hsp_hit_from):(_=e.hsp_hit_from,x=e.hsp_hit_to),[p,g]=Object(r.a)(o,l,this.queryLen,b,y,this.marginWidth),[m,v]=Object(r.a)(u,f,i,_,x,this.marginWidth),S=this.colorScheme===a.a.ncbiblast?Object(s.c)(e.hsp_bit_score,this.gradientSteps,n.d):Object(s.d)(e.hsp_expect,this.gradientSteps,n.c),this.topPadding+=10,[w,C]=Object(c.m)(p,g,m,v,this.topPadding,S),this.canvas.add(w),this.canvas.add(C);const T=Object(c.F)(this.startEvalPixels,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this.topPadding);T.width=this.contentScoringWidth,this.canvas.add(T),this.staticCanvas||(Object(h.i)(w,p,g,b,y,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this),Object(h.e)(w,this),Object(h.i)(C,m,v,_,x,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this),Object(h.e)(C,this))}}}}}drawColorScaleGroup(){const t=Object(c.E)({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);let e,i,n,r,s,o,l,u,f;this.canvas.add(t),[r,s,e,o,l,i,u,f,n]=Object(c.b)({colorScheme:this.colorScheme,fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding),this.canvas.add(r),this.canvas.add(s),this.staticCanvas||(Object(h.h)(r,e,this),Object(h.d)(r,e,a.a.dynamic,this),Object(h.a)(r,a.a.dynamic,this)),this.canvas.add(o),this.canvas.add(l),this.staticCanvas||(Object(h.h)(o,i,this),Object(h.d)(o,i,a.a.fixed,this),Object(h.a)(o,a.a.fixed,this)),this.canvas.add(u),this.canvas.add(f),this.staticCanvas||(Object(h.h)(u,n,this),Object(h.d)(u,n,a.a.ncbiblast,this),Object(h.a)(u,a.a.ncbiblast,this)),this.topPadding+=25;const d=Object(c.B)({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);this.canvas.add(d);const p=Object(c.A)({scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);if(this.canvas.add(p),this.colorScheme===a.a.ncbiblast){const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/5;this.topPadding+=15;const e=Object(c.v)(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+4*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=Object(c.D)(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}else{const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/4;this.topPadding+=15;const e=Object(c.u)(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=Object(c.C)(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}}drawFooterGroup(){let t,e;this.topPadding+=30,t=l.get("copyrightText"),e=l.get("copyrightText_textFooterObj"),t||e||([t,e]=Object(c.p)({fontSize:this.fontSize},this.topPadding),l.put("copyrightText",t),l.put("copyrightText_textFooterObj",e)),this.canvas.add(t)}wrapCanvas(){if(this.topPadding+=20,this.canvasHeight=this.topPadding,this.canvasWrapperStroke){const t=Object(c.a)({canvasWidth:this.canvasWidth,canvasHeight:this.canvasHeight});this.canvas.add(t)}}}},function(t,e,i){"use strict";i.d(e,"a",(function(){return d}));var n=i(6),r=i(7),s=i(8),o=i(2),a=i(1),h=i(4),c=i(3);const l=["PRODOM","CATH-Gene3D","CDD","PANTHER","HAMAP","Pfam","PIRSF","PRINTS","PROSITE profiles","PROSITE patterns","SFLD","SMART","SUPERFAMILY","TIGRFAMs"];function u(t,e,i,n,r,s){let o,a,l,u;t.domainDatabaseList.includes(e)?t.currentDomainDatabase=e:t.currentDomainDatabase=void 0,t.currentDomainDatabaseDisabled=!1,i.includes(e)||(t.currentDomainDatabaseDisabled=!0),[l,u,o,a]=Object(c.j)({currentDomainDatabase:t.currentDomainDatabase,currentDisabled:t.currentDomainDatabaseDisabled,fontSize:s.fontSize},n,r,e),t.canvas.add(l),t.canvas.add(u),s.staticCanvas||(Object(h.j)(l,o,e,t),Object(h.f)(l,o,e,t),Object(h.b)(l,e,t))}let f=new o.b;class d extends o.a{constructor(t,e,i,n,r=l){super(t),this.sssDataObj=e,this.iprmcDataObj=i,this.domainDatabaseList=r,this.topPadding=0,this.queryStart=0,this.queryEnd=0,this.gradientSteps=[],this.uniqueDomainDatabases=[],this.currentDomainDatabaseDisabled=!1,null!=n.canvasWidth?this.canvasWidth=n.canvasWidth:this.canvasWidth=1e3,null!=n.canvasHeight?this.canvasHeight=n.canvasHeight:this.canvasHeight=110,null!=n.contentWidth?this.contentWidth=n.contentWidth:this.contentWidth=72.5*this.canvasWidth/100,null!=n.contentLabelWidth?this.contentLabelWidth=n.contentLabelWidth:this.contentLabelWidth=26.5*this.canvasWidth/100,null!=n.contentLabelLeftWidth?this.contentLabelLeftWidth=n.contentLabelLeftWidth:this.contentLabelLeftWidth=8.25*this.canvasWidth/100,null!=n.scaleWidth?this.scaleWidth=n.scaleWidth:this.scaleWidth=75*this.canvasWidth/100,null!=n.scaleLabelWidth?this.scaleLabelWidth=n.scaleLabelWidth:this.scaleLabelWidth=20*this.canvasWidth/100,null!=n.marginWidth?this.marginWidth=n.marginWidth:this.marginWidth=.15*this.canvasWidth/100,null!=n.colorScheme?this.colorScheme=n.colorScheme:this.colorScheme=a.a.dynamic,null!=n.numberHits?this.numberHits=n.numberHits:this.numberHits=30,null!=n.fontSize?this.fontSize=n.fontSize:this.fontSize=12,null!=n.fontWeigth?this.fontWeigth=n.fontWeigth:this.fontWeigth="normal",null!=n.fontFamily?this.fontFamily=n.fontFamily:this.fontFamily="Times New Roman",null!=n.canvasWrapperStroke?this.canvasWrapperStroke=n.canvasWrapperStroke:this.canvasWrapperStroke=!1,null!=n.staticCanvas?this.staticCanvas=n.staticCanvas:this.staticCanvas=!1,this.getFabricCanvas()}render(){this.loadIPRMCProperties(),this.loadInitalProperties(),this.loadInitialCoords(),this.canvas.clear(),this.drawHeaderGroup(),this.drawContentGroup(),this.drawFooterGroup(),this.wrapCanvas(),this.setFrameSize(),this.renderCanvas()}loadInitalProperties(){this.queryStart=1,this.queryEnd=this.sssDataObj.query_len}loadInitialCoords(){this.startPixels=f.get("startPixels"),this.endPixels=f.get("endPixels"),this.startPixels||this.endPixels||([this.startPixels,this.endPixels]=Object(n.b)(this.contentWidth,this.contentLabelWidth,this.marginWidth),f.put("startPixels",this.startPixels),f.put("endPixels",this.endPixels))}loadIPRMCProperties(){if(null!=this.sssDataObj){if(this.uniqueDomainDatabases=f.get("uniqueDomainDatabases"),!this.uniqueDomainDatabases){let t=[];for(const e of this.sssDataObj.hits.slice(0,this.numberHits))t.push(e.hit_acc);this.uniqueDomainDatabases=Object(o.i)(this.iprmcDataObj,t),f.put("uniqueDomainDatabases",this.uniqueDomainDatabases)}for(const t of this.domainDatabaseList)if(!this.uniqueDomainDatabases.includes(Object(o.d)(t))){const e=this.domainDatabaseList.indexOf(t);e>-1&&this.domainDatabaseList.splice(e,1)}}}drawHeaderGroup(){let t,e,i;this.topPadding=2,t=f.get("textHeaderGroup"),t||(t=Object(c.r)(this.sssDataObj,{fontSize:this.fontSize,canvasWidth:this.canvasWidth},this.topPadding),f.put("textHeaderGroup",t)),this.canvas.add(t),this.topPadding+=45,e=f.get("textHeaderLink"),i=f.get("textHeaderLink_textSeqObj"),e||([e,i]=Object(c.q)(this.sssDataObj,{fontSize:this.fontSize},this.topPadding),f.put("textHeaderLink",e),f.put("textHeaderLink_textSeqObj",i)),this.canvas.add(e),this.staticCanvas||null!=this.sssDataObj.query_url&&""!==this.sssDataObj.query_url&&(Object(h.k)(e,i,this.sssDataObj.query_def,this.sssDataObj.query_url,{fontSize:this.fontSize},this),Object(h.c)(e,this.sssDataObj.query_url,this),Object(h.g)(e,i,this))}drawContentGroup(){let t;if(this.topPadding+=25,t=f.get("titleText"),t||(t=Object(c.i)({fontSize:this.fontSize+1},this.topPadding),f.put("titleText",t)),this.canvas.add(t),this.sssDataObj.hits.length>0)this.topPadding+=35,this.drawPredictionsGroup(),this.topPadding+=50,this.drawDynamicContentGroup(),this.drawColorScaleGroup();else{this.topPadding+=20;const t=Object(c.y)({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding);this.canvas.add(t)}}drawPredictionsGroup(){let t;t=f.get("pfLabelText"),t||(t=Object(c.z)({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth-50},this.topPadding),f.put("pfLabelText",t)),this.canvas.add(t),u(this,"Pfam",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+190,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"SUPERFAMILY",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+260,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"SMART",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+390,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"HAMAP",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+480,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"PANTHER",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+570,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"PRODOM",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+680,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"PROSITE profiles",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+770,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),this.topPadding+=30,u(this,"CDD",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+190,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"CATH-Gene3D",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+260,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"PIRSF",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+390,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"PRINTS",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+480,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"TIGRFAMs",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+570,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"SFLD",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+680,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),u(this,"PROSITE patterns",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+770,{fontSize:this.fontSize,staticCanvas:this.staticCanvas})}drawDynamicContentGroup(){let t=0;for(const e of this.sssDataObj.hits.slice(0,this.numberHits))e.hit_db.length+e.hit_id.length>t&&(t=e.hit_db.length+e.hit_id.length);let e=Number.MAX_VALUE,i=0,l=Number.MAX_VALUE;for(const t of this.sssDataObj.hits.slice(0,this.numberHits))for(const n of t.hit_hsps)this.colorScheme===a.a.ncbiblast?(n.hsp_bit_scorei&&(i=n.hsp_bit_score),n.hsp_bit_score0&&(l=n.hsp_bit_score)):(n.hsp_expecti&&(i=n.hsp_expect),n.hsp_expect0&&(l=n.hsp_expect));this.colorScheme,a.a.ncbiblast,this.gradientSteps=Object(r.b)(e,i,l,this.colorScheme);let u=0;for(const e of this.sssDataObj.hits){if(u++,!(u<=this.numberHits)){let t;t=f.get("supressText"),t||(t=Object(c.h)({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding,this.numberHits),f.put("supressText",t)),t.top=this.topPadding,this.canvas.add(t),this.topPadding+=40;break}{let i,l,u;[l,u,i]=Object(c.g)(t,e,{fontSize:this.fontSize},this.topPadding),this.canvas.add(l),this.canvas.add(u),this.staticCanvas||(Object(h.k)(u,i,e.hit_def,e.hit_url,{fontSize:this.fontSize},this),Object(h.c)(u,e.hit_url,this),Object(h.g)(u,i,this));const f=Object(c.w)({startPixels:this.startPixels,endPixels:this.endPixels},{strokeWidth:1},this.topPadding);this.canvas.add(f),this.topPadding+=5;const d=Object(c.d)({start:this.queryStart,end:e.hit_len,startPixels:this.startPixels,endPixels:this.endPixels},{fontSize:this.fontSize},this.topPadding);this.canvas.add(d),this.topPadding+=15;let p="white",g=0,m=0;for(const t of e.hit_hsps){"-1"===t.hsp_hit_frame?(g=t.hsp_hit_to,m=t.hsp_hit_from):(g=t.hsp_hit_from,m=t.hsp_hit_to),p=this.colorScheme===a.a.ncbiblast?Object(r.c)(t.hsp_bit_score,this.gradientSteps,s.d):Object(r.d)(t.hsp_expect,this.gradientSteps,s.c);break}let v=0,b=0;[v,b]=Object(n.a)(this.startPixels,this.endPixels,e.hit_len,g,m,this.marginWidth);let y=0,_=this.topPadding-15;if(e.hit_acc in this.iprmcDataObj&&void 0!==this.iprmcDataObj[e.hit_acc].matches)for(const t of this.iprmcDataObj[e.hit_acc].matches){const i=Object(o.d)(this.iprmcDataObj[e.hit_acc].match[t][0].dbname);if(this.domainDatabaseList.includes(i)){this.topPadding+=15,y+=15;let s,a,l,u=Object(c.l)({startPixels:this.startPixels,endPixels:this.endPixels},{strokeWidth:1,strokeDashArray:[1,5]},this.topPadding);this.canvas.add(u),u.sendToBack(),[a,l,s]=Object(c.c)(t.split("_")[1]+" ►",{fontSize:this.fontSize},this.topPadding),this.canvas.add(a),this.canvas.add(l);const f=Object(o.f)(t.split("_")[1],i);this.staticCanvas||(Object(h.k)(l,s,"",f,{fontSize:this.fontSize},this),Object(h.c)(l,f,this),Object(h.g)(l,s,this));for(const i of this.iprmcDataObj[e.hit_acc].match[t]){let t=i.start,s=i.end,o=0,a=0;[o,a]=Object(n.a)(this.startPixels,this.endPixels,e.hit_len,t,s,this.marginWidth);const l=Object(c.o)(o,a,this.topPadding+10,Object(r.a)(i.dbname));this.canvas.add(l),this.staticCanvas||(Object(h.i)(l,o,a,t,s,i,{fontSize:this.fontSize},this),Object(h.e)(l,this))}}}y+=15;const x=Object(c.s)(v,b,_,p,y);this.canvas.add(x),x.sendToBack(),this.topPadding+=40}}}drawColorScaleGroup(){const t=Object(c.E)({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);let e,i,n,r,s,o,l,u,f;this.canvas.add(t),[r,s,e,o,l,i,u,f,n]=Object(c.b)({colorScheme:this.colorScheme,fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding),this.canvas.add(r),this.canvas.add(s),this.staticCanvas||(Object(h.h)(r,e,this),Object(h.d)(r,e,a.a.dynamic,this),Object(h.a)(r,a.a.dynamic,this)),this.canvas.add(o),this.canvas.add(l),this.staticCanvas||(Object(h.h)(o,i,this),Object(h.d)(o,i,a.a.fixed,this),Object(h.a)(o,a.a.fixed,this)),this.canvas.add(u),this.canvas.add(f),this.staticCanvas||(Object(h.h)(u,n,this),Object(h.d)(u,n,a.a.ncbiblast,this),Object(h.a)(u,a.a.ncbiblast,this)),this.topPadding+=25;const d=Object(c.B)({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);this.canvas.add(d);const p=Object(c.A)({scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);if(this.canvas.add(p),this.colorScheme===a.a.ncbiblast){const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/5;this.topPadding+=15;const e=Object(c.v)(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+4*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=Object(c.D)(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}else{const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/4;this.topPadding+=15;const e=Object(c.u)(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=Object(c.C)(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}}drawFooterGroup(){let t,e;this.topPadding+=30,[t,e]=Object(c.p)({fontSize:this.fontSize},this.topPadding),this.canvas.add(t)}wrapCanvas(){if(this.topPadding+=20,this.canvasHeight=this.topPadding,this.canvasWrapperStroke){const t=Object(c.a)({canvasWidth:this.canvasWidth,canvasHeight:this.canvasHeight});this.canvas.add(t)}}}},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}}},function(t,e){var i,n,r=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(t){i=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,c=[],l=!1,u=-1;function f(){l&&h&&(l=!1,h.length?c=h.concat(c):u=-1,c.length&&d())}function d(){if(!l){var t=a(f);l=!0;for(var e=c.length;e;){for(h=c,c=[];++u1)for(var i=1;i + * @license MIT + */ +var n=i(39),r=i(40),s=i(27);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return z(t).length;default:if(n)return N(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return j(this,e,i);case"utf8":case"utf-8":return O(this,e,i);case"ascii":return E(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return T(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:b(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):b(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function b(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var l=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var u=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function T(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function O(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:c>223?3:c>191?2:1;if(r+u<=i)switch(u){case 1:c<128&&(l=c);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&c)<<6|63&s)>127&&(l=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&c)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(l=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(l=h)}null===l?(l=65533,u=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),r+=u}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),c=this.slice(n,r),l=t.slice(e,i),u=0;ur)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return y(this,t,e,i);case"utf8":case"utf-8":return _(this,t,e,i);case"ascii":return x(this,t,e,i);case"latin1":case"binary":return S(this,t,e,i);case"base64":return w(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function L(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function F(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function M(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function I(t,e,i,n,s){return s||M(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function R(t,e,i,n,s){return s||M(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||A(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||A(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||A(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||A(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||A(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):L(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):L(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):L(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):L(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return I(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return I(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return R(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return R(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function z(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(12))},function(t,e,i){(function(t){function i(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===i(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===i(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===i(t)},e.isError=function(t){return"[object Error]"===i(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,i(15).Buffer)},function(t,e,i){var n=i(38),r=/\s+/g,s=/%[\dA-F]{2}/g,o=/"/g;function a(t){switch(t){case"%20":return" ";case"%3D":return"=";case"%3A":return":";case"%2F":return"/";default:return t.toLowerCase()}}function h(t){if("string"!=typeof t)throw new TypeError("Expected a string, but received "+typeof t);var e,i;return 65279===t.charCodeAt(0)&&(t=t.slice(1)),"data:image/svg+xml,"+function(t){return encodeURIComponent(t).replace(s,a)}((i=t,e=i.trim().replace(r," "),Object.keys(n).forEach((function(t){n[t].test(e)&&(e=e.replace(n[t],t))})),e).replace(o,"'"))}h.toSrcset=function(t){return h(t).replace(/ /g,"%20")},t.exports=h},function(t,e,i){"use strict";(function(e){void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,i,n,r){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var s,o,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,i)}));case 3:return e.nextTick((function(){t.call(null,i,n)}));case 4:return e.nextTick((function(){t.call(null,i,n,r)}));default:for(s=new Array(a-1),o=0;o0&&o.length>r&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=o.length,a=h,console&&console.warn&&console.warn(a)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},r=f.bind(n);return r.listener=i,n.wrapFn=r,r}function p(t,e,i){var n=t._events;if(void 0===n)return[];var r=n[e];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=r[t];if(void 0===h)return!1;if("function"==typeof h)s(h,this,e);else{var c=h.length,l=m(h,c);for(i=0;i=0;s--)if(i[s]===e||i[s].listener===e){o=i[s].listener,r=s;break}if(r<0)return this;0===r?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return p(this,t,!0)},a.prototype.rawListeners=function(t){return p(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){(e=t.exports=i(29)).Stream=e,e.Readable=e,e.Writable=i(22),e.Duplex=i(9),e.Transform=i(32),e.PassThrough=i(52)},function(t,e,i){"use strict";(function(e,n,r){var s=i(18);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,i){var n=t.entry;t.entry=null;for(;n;){var r=n.callback;e.pendingcb--,r(i),n=n.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}(e,t)}}t.exports=b;var a,h=!e.browser&&["v0.10","v0.9."].indexOf(e.version.slice(0,5))>-1?n:s.nextTick;b.WritableState=v;var c=Object.create(i(16));c.inherits=i(13);var l={deprecate:i(51)},u=i(30),f=i(19).Buffer,d=r.Uint8Array||function(){};var p,g=i(31);function m(){}function v(t,e){a=a||i(9),t=t||{};var n=e instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var r=t.highWaterMark,c=t.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var u=!1===t.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var i=t._writableState,n=i.sync,r=i.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(i),e)!function(t,e,i,n,r){--e.pendingcb,i?(s.nextTick(r,n),s.nextTick(C,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(r(n),t._writableState.errorEmitted=!0,t.emit("error",n),C(t,e))}(t,i,n,e,r);else{var o=S(i);o||i.corked||i.bufferProcessing||!i.bufferedRequest||x(t,i),n?h(_,t,i,o,r):_(t,i,o,r)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function b(t){if(a=a||i(9),!(p.call(b,this)||this instanceof a))return new b(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function y(t,e,i,n,r,s,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,i?t._writev(r,e.onwrite):t._write(r,s,e.onwrite),e.sync=!1}function _(t,e,i,n){i||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),C(t,e)}function x(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,r=new Array(n),s=e.corkedRequestsFree;s.entry=i;for(var a=0,h=!0;i;)r[a]=i,i.isBuf||(h=!1),i=i.next,a+=1;r.allBuffers=h,y(t,e,!0,e.length,r,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;i;){var c=i.chunk,l=i.encoding,u=i.callback;if(y(t,e,!1,e.objectMode?1:c.length,c,l,u),i=i.next,e.bufferedRequestCount--,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequest=i,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function w(t,e){t._final((function(i){e.pendingcb--,i&&t.emit("error",i),e.prefinished=!0,t.emit("prefinish"),C(t,e)}))}function C(t,e){var i=S(e);return i&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,s.nextTick(w,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),i}c.inherits(b,u),v.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(v.prototype,"buffer",{get:l.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(t){return!!p.call(this,t)||this===b&&(t&&t._writableState instanceof v)}})):p=function(t){return t instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(t,e,i){var n,r=this._writableState,o=!1,a=!r.objectMode&&(n=t,f.isBuffer(n)||n instanceof d);return a&&!f.isBuffer(t)&&(t=function(t){return f.from(t)}(t)),"function"==typeof e&&(i=e,e=null),a?e="buffer":e||(e=r.defaultEncoding),"function"!=typeof i&&(i=m),r.ended?function(t,e){var i=new Error("write after end");t.emit("error",i),s.nextTick(e,i)}(this,i):(a||function(t,e,i,n){var r=!0,o=!1;return null===i?o=new TypeError("May not write null values to stream"):"string"==typeof i||void 0===i||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),s.nextTick(n,o),r=!1),r}(this,r,t,i))&&(r.pendingcb++,o=function(t,e,i,n,r,s){if(!i){var o=function(t,e,i){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=f.from(e,i));return e}(e,n,r);n!==o&&(i=!0,r="buffer",n=o)}var a=e.objectMode?1:n.length;e.length+=a;var h=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(t,e,i){i(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(t,e,i){var n=this._writableState;"function"==typeof t?(i=t,t=null,e=null):"function"==typeof e&&(i=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,i){e.ending=!0,C(t,e),i&&(e.finished?s.nextTick(i):t.once("finish",i));e.ended=!0,t.writable=!1}(this,n,i)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,i(14),i(49).setImmediate,i(12))},function(t,e,i){"use strict";var n=i(19).Buffer,r=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=u,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var n=i.charCodeAt(i.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function l(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function u(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=s,s.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0)return r>0&&(t.lastNeed=r-1),r;if(--n=0)return r>0&&(t.lastNeed=r-2),r;if(--n=0)return r>0&&(2===r?r=0:t.lastNeed=r-3),r;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var n=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,i){var n=i(25).isArray;t.exports={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){t in e&&"boolean"==typeof e[t]||(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||"number"!=typeof t.spaces&&"string"!=typeof t.spaces)&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){"alwaysArray"in t&&("boolean"==typeof t.alwaysArray||n(t.alwaysArray))||(t.alwaysArray=!1)},ensureKeyExists:function(t,e){t+"Key"in e&&"string"==typeof e[t+"Key"]||(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}}},function(t,e){t.exports={isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}}},function(t,e,i){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n="undefined"!=typeof window&&void 0!==window.document,r="object"===("undefined"==typeof self?"undefined":i(self))&&self.constructor&&"DedicatedWorkerGlobalScope"===self.constructor.name,s=void 0!==t&&null!=t.versions&&null!=t.versions.node;e.isBrowser=n,e.isWebWorker=r,e.isNode=s}).call(this,i(14))},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e,i){var n,r,s=i(44),o=i(24),a=i(25).isArray;function h(t){var e=Number(t);if(!isNaN(e))return e;var i=t.toLowerCase();return"true"===i||"false"!==i&&t}function c(t,e){var i;if(n.compact){if(!r[n[t+"Key"]]&&(a(n.alwaysArray)?-1!==n.alwaysArray.indexOf(n[t+"Key"]):n.alwaysArray)&&(r[n[t+"Key"]]=[]),r[n[t+"Key"]]&&!a(r[n[t+"Key"]])&&(r[n[t+"Key"]]=[r[n[t+"Key"]]]),t+"Fn"in n&&"string"==typeof e&&(e=n[t+"Fn"](e,r)),"instruction"===t&&("instructionFn"in n||"instructionNameFn"in n))for(i in e)if(e.hasOwnProperty(i))if("instructionFn"in n)e[i]=n.instructionFn(e[i],i,r);else{var s=e[i];delete e[i],e[n.instructionNameFn(i,s,r)]=s}a(r[n[t+"Key"]])?r[n[t+"Key"]].push(e):r[n[t+"Key"]]=e}else{r[n.elementsKey]||(r[n.elementsKey]=[]);var o={};if(o[n.typeKey]=t,"instruction"===t){for(i in e)if(e.hasOwnProperty(i))break;o[n.nameKey]="instructionNameFn"in n?n.instructionNameFn(i,e,r):i,n.instructionHasAttributes?(o[n.attributesKey]=e[i][n.attributesKey],"instructionFn"in n&&(o[n.attributesKey]=n.instructionFn(o[n.attributesKey],i,r))):("instructionFn"in n&&(e[i]=n.instructionFn(e[i],i,r)),o[n.instructionKey]=e[i])}else t+"Fn"in n&&(e=n[t+"Fn"](e,r)),o[n[t+"Key"]]=e;n.addParent&&(o[n.parentKey]=r),r[n.elementsKey].push(o)}}function l(t){var e;if("attributesFn"in n&&t&&(t=n.attributesFn(t,r)),(n.trim||"attributeValueFn"in n||"attributeNameFn"in n||n.nativeTypeAttributes)&&t)for(e in t)if(t.hasOwnProperty(e)&&(n.trim&&(t[e]=t[e].trim()),n.nativeTypeAttributes&&(t[e]=h(t[e])),"attributeValueFn"in n&&(t[e]=n.attributeValueFn(t[e],e,r)),"attributeNameFn"in n)){var i=t[e];delete t[e],t[n.attributeNameFn(e,t[e],r)]=i}return t}function u(t){var e={};if(t.body&&("xml"===t.name.toLowerCase()||n.instructionHasAttributes)){for(var i,s=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(i=s.exec(t.body));)e[i[1]]=i[2]||i[3]||i[4];e=l(e)}if("xml"===t.name.toLowerCase()){if(n.ignoreDeclaration)return;r[n.declarationKey]={},Object.keys(e).length&&(r[n.declarationKey][n.attributesKey]=e),n.addParent&&(r[n.declarationKey][n.parentKey]=r)}else{if(n.ignoreInstruction)return;n.trim&&(t.body=t.body.trim());var o={};n.instructionHasAttributes&&Object.keys(e).length?(o[t.name]={},o[t.name][n.attributesKey]=e):o[t.name]=t.body,c("instruction",o)}}function f(t,e){var i;if("object"==typeof t&&(e=t.attributes,t=t.name),e=l(e),"elementNameFn"in n&&(t=n.elementNameFn(t,r)),n.compact){var s;if(i={},!n.ignoreAttributes&&e&&Object.keys(e).length)for(s in i[n.attributesKey]={},e)e.hasOwnProperty(s)&&(i[n.attributesKey][s]=e[s]);!(t in r)&&(a(n.alwaysArray)?-1!==n.alwaysArray.indexOf(t):n.alwaysArray)&&(r[t]=[]),r[t]&&!a(r[t])&&(r[t]=[r[t]]),a(r[t])?r[t].push(i):r[t]=i}else r[n.elementsKey]||(r[n.elementsKey]=[]),(i={})[n.typeKey]="element",i[n.nameKey]=t,!n.ignoreAttributes&&e&&Object.keys(e).length&&(i[n.attributesKey]=e),n.alwaysChildren&&(i[n.elementsKey]=[]),r[n.elementsKey].push(i);i[n.parentKey]=r,r=i}function d(t){n.ignoreText||(t.trim()||n.captureSpacesBetweenElements)&&(n.trim&&(t=t.trim()),n.nativeType&&(t=h(t)),n.sanitize&&(t=t.replace(/&/g,"&").replace(//g,">")),c("text",t))}function p(t){n.ignoreComment||(n.trim&&(t=t.trim()),c("comment",t))}function g(t){var e=r[n.parentKey];n.addParent||delete r[n.parentKey],r=e}function m(t){n.ignoreCdata||(n.trim&&(t=t.trim()),c("cdata",t))}function v(t){n.ignoreDoctype||(t=t.replace(/^ /,""),n.trim&&(t=t.trim()),c("doctype",t))}function b(t){t.note=t}t.exports=function(t,e){var i=s.parser(!0,{}),a={};if(r=a,n=function(t){return n=o.copyOptions(t),o.ensureFlagExists("ignoreDeclaration",n),o.ensureFlagExists("ignoreInstruction",n),o.ensureFlagExists("ignoreAttributes",n),o.ensureFlagExists("ignoreText",n),o.ensureFlagExists("ignoreComment",n),o.ensureFlagExists("ignoreCdata",n),o.ensureFlagExists("ignoreDoctype",n),o.ensureFlagExists("compact",n),o.ensureFlagExists("alwaysChildren",n),o.ensureFlagExists("addParent",n),o.ensureFlagExists("trim",n),o.ensureFlagExists("nativeType",n),o.ensureFlagExists("nativeTypeAttributes",n),o.ensureFlagExists("sanitize",n),o.ensureFlagExists("instructionHasAttributes",n),o.ensureFlagExists("captureSpacesBetweenElements",n),o.ensureAlwaysArrayExists(n),o.ensureKeyExists("declaration",n),o.ensureKeyExists("instruction",n),o.ensureKeyExists("attributes",n),o.ensureKeyExists("text",n),o.ensureKeyExists("comment",n),o.ensureKeyExists("cdata",n),o.ensureKeyExists("doctype",n),o.ensureKeyExists("type",n),o.ensureKeyExists("name",n),o.ensureKeyExists("elements",n),o.ensureKeyExists("parent",n),o.checkFnExists("doctype",n),o.checkFnExists("instruction",n),o.checkFnExists("cdata",n),o.checkFnExists("comment",n),o.checkFnExists("text",n),o.checkFnExists("instructionName",n),o.checkFnExists("elementName",n),o.checkFnExists("attributeName",n),o.checkFnExists("attributeValue",n),o.checkFnExists("attributes",n),n}(e),i.opt={strictEntities:!0},i.onopentag=f,i.ontext=d,i.oncomment=p,i.onclosetag=g,i.onerror=b,i.oncdata=m,i.ondoctype=v,i.onprocessinginstruction=u,i.write(t).close(),a[n.elementsKey]){var h=a[n.elementsKey];delete a[n.elementsKey],a[n.elementsKey]=h,delete a.text}return a}},function(t,e,i){"use strict";(function(e,n){var r=i(18);t.exports=y;var s,o=i(27);y.ReadableState=b;i(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},h=i(30),c=i(19).Buffer,l=e.Uint8Array||function(){};var u=Object.create(i(16));u.inherits=i(13);var f=i(46),d=void 0;d=f&&f.debuglog?f.debuglog("stream"):function(){};var p,g=i(47),m=i(31);u.inherits(y,h);var v=["error","close","destroy","pause","resume"];function b(t,e){t=t||{};var n=e instanceof(s=s||i(9));this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var r=t.highWaterMark,o=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=i(23).StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function y(t){if(s=s||i(9),!(this instanceof y))return new y(t);this._readableState=new b(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),h.call(this)}function _(t,e,i,n,r){var s,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,w(t)}(t,o)):(r||(s=function(t,e){var i;n=e,c.isBuffer(n)||n instanceof l||"string"==typeof e||void 0===e||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk"));var n;return i}(o,e)),s?t.emit("error",s):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),n?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):x(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!i?(e=o.decoder.write(e),o.objectMode||0!==e.length?x(t,o,e,!1):T(t,o)):x(t,o,e,!1))):n||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function w(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(d("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?r.nextTick(C,t):C(t))}function C(t){d("emit readable"),t.emit("readable"),j(t)}function T(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(O,t,e))}function O(t,e){for(var i=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):i=function(t,e,i){var n;ts.length?s.length:t;if(o===s.length?r+=s:r+=s.slice(0,t),0===(t-=o)){o===s.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=s.slice(o));break}++n}return e.length-=n,r}(t,e):function(t,e){var i=c.allocUnsafe(t),n=e.head,r=1;n.data.copy(i),t-=n.data.length;for(;n=n.next;){var s=n.data,o=t>s.length?s.length:t;if(s.copy(i,i.length-t,0,o),0===(t-=o)){o===s.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=s.slice(o));break}++r}return e.length-=r,i}(t,e);return n}(t,e.buffer,e.decoder),i);var i}function A(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,r.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function L(t,e){for(var i=0,n=t.length;i=e.highWaterMark||e.ended))return d("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?A(this):w(this),null;if(0===(t=S(t,e))&&e.ended)return 0===e.length&&A(this),null;var n,r=e.needReadable;return d("need readable",r),(0===e.length||e.length-t0?k(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&A(this)),null!==n&&this.emit("data",n),n},y.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(t,e){var i=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,d("pipe count=%d opts=%j",s.pipesCount,e);var h=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?l:y;function c(e,n){d("onunpipe"),e===i&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,d("cleanup"),t.removeListener("close",v),t.removeListener("finish",b),t.removeListener("drain",u),t.removeListener("error",m),t.removeListener("unpipe",c),i.removeListener("end",l),i.removeListener("end",y),i.removeListener("data",g),f=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}function l(){d("onend"),t.end()}s.endEmitted?r.nextTick(h):i.once("end",h),t.on("unpipe",c);var u=function(t){return function(){var e=t._readableState;d("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,j(t))}}(i);t.on("drain",u);var f=!1;var p=!1;function g(e){d("ondata"),p=!1,!1!==t.write(e)||p||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==L(s.pipes,t))&&!f&&(d("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,p=!0),i.pause())}function m(e){d("onerror",e),y(),t.removeListener("error",m),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",b),y()}function b(){d("onfinish"),t.removeListener("close",v),y()}function y(){d("unpipe"),i.unpipe(t)}return i.on("data",g),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener(e,i);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(i):t._events[e]=[i,t._events[e]]:t.on(e,i)}(t,"error",m),t.once("close",v),t.once("finish",b),t.emit("pipe",i),s.flowing||(d("pipe resume"),i.resume()),t},y.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s"}function l(t,e,i){if(e.ignoreInstruction)return"";var s;for(s in t)if(t.hasOwnProperty(s))break;var o="instructionNameFn"in e?e.instructionNameFn(s,t[s],r,n):s;if("object"==typeof t[s])return n=t,r=o,"";var a=t[s]?t[s]:"";return"instructionFn"in e&&(a=e.instructionFn(a,s,r,n)),""}function u(t,e){return e.ignoreComment?"":"\x3c!--"+("commentFn"in e?e.commentFn(t,r,n):t)+"--\x3e"}function f(t,e){return e.ignoreCdata?"":""+("cdataFn"in e?e.cdataFn(t,r,n):t.replace("","]]]]>>"))+""}function d(t,e){return e.ignoreDoctype?"":""}function p(t,e){return e.ignoreText?"":(t=(t=(t=""+t).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in e?e.textFn(t,r,n):t)}function g(t,e,i,s){return t.reduce((function(t,o){var c=a(e,i,s&&!t);switch(o.type){case"element":return t+c+function(t,e,i){n=t,r=t.name;var s=[],o="elementNameFn"in e?e.elementNameFn(t.name,t):t.name;s.push("<"+o),t[e.attributesKey]&&s.push(h(t[e.attributesKey],e,i));var a=t[e.elementsKey]&&t[e.elementsKey].length||t[e.attributesKey]&&"preserve"===t[e.attributesKey]["xml:space"];return a||(a="fullTagEmptyElementFn"in e?e.fullTagEmptyElementFn(t.name,t):e.fullTagEmptyElement),a?(s.push(">"),t[e.elementsKey]&&t[e.elementsKey].length&&(s.push(g(t[e.elementsKey],e,i+1)),n=t,r=t.name),s.push(e.spaces&&function(t,e){var i;if(t.elements&&t.elements.length)for(i=0;i")):s.push("/>"),s.join("")}(o,e,i);case"comment":return t+c+u(o[e.commentKey],e);case"doctype":return t+c+d(o[e.doctypeKey],e);case"cdata":return t+(e.indentCdata?c:"")+f(o[e.cdataKey],e);case"text":return t+(e.indentText?c:"")+p(o[e.textKey],e);case"instruction":var m={};return m[o[e.nameKey]]=o[e.attributesKey]?o:o[e.instructionKey],t+(e.indentInstruction?c:"")+l(m,e,i)}}),"")}function m(t,e,i){var n;for(n in t)if(t.hasOwnProperty(n))switch(n){case e.parentKey:case e.attributesKey:break;case e.textKey:if(e.indentText||i)return!0;break;case e.cdataKey:if(e.indentCdata||i)return!0;break;case e.instructionKey:if(e.indentInstruction||i)return!0;break;case e.doctypeKey:case e.commentKey:default:return!0}return!1}function v(t,e,i,s,o){n=t,r=e;var c="elementNameFn"in i?i.elementNameFn(e,t):e;if(null==t||""===t)return"fullTagEmptyElementFn"in i&&i.fullTagEmptyElementFn(e,t)||i.fullTagEmptyElement?"<"+c+">":"<"+c+"/>";var l=[];if(e){if(l.push("<"+c),"object"!=typeof t)return l.push(">"+p(t,i)+""),l.join("");t[i.attributesKey]&&l.push(h(t[i.attributesKey],i,s));var u=m(t,i,!0)||t[i.attributesKey]&&"preserve"===t[i.attributesKey]["xml:space"];if(u||(u="fullTagEmptyElementFn"in i?i.fullTagEmptyElementFn(e,t):i.fullTagEmptyElement),!u)return l.push("/>"),l.join("");l.push(">")}return l.push(b(t,i,s+1,!1)),n=t,r=e,e&&l.push((o?a(i,s,!1):"")+""),l.join("")}function b(t,e,i,n){var r,s,h,g=[];for(s in t)if(t.hasOwnProperty(s))for(h=o(t[s])?t[s]:[t[s]],r=0;r0?o-4:o;for(i=0;i>16&255,h[l++]=e>>8&255,h[l++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[l++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[l++]=e>>8&255,h[l++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function l(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,l=-7,u=i?r-1:0,f=i?-1:1,d=t[e+u];for(u+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[e+u],u+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+u],u+=f,l-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=c}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,c=8*s-r-1,l=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+u>=1?f/h:f*Math.pow(2,1-u))*h>=2&&(o++,h/=2),o+u>=l?(a=0,o=l):o+u>=1?(a=(e*h-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=p,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=p,o/=256,c-=8);t[i+d-p]|=128*g}},function(t,e){},function(t,e){},function(t,e){},function(t,e,i){(function(t){!function(e){e.parser=function(t,e){return new s(t,e)},e.SAXParser=s,e.SAXStream=a,e.createStream=function(t,e){return new a(t,e)},e.MAX_BUFFER_LENGTH=65536;var n,r=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function s(t,i){if(!(this instanceof s))return new s(t,i);!function(t){for(var e=0,i=r.length;e"===n?(T(this,"onsgmldeclaration",this.sgmlDecl),this.sgmlDecl="",this.state=S.TEXT):g(n)?(this.state=S.SGML_DECL_QUOTED,this.sgmlDecl+=n):this.sgmlDecl+=n;continue;case S.SGML_DECL_QUOTED:n===this.q&&(this.state=S.SGML_DECL,this.q=""),this.sgmlDecl+=n;continue;case S.DOCTYPE:">"===n?(this.state=S.TEXT,T(this,"ondoctype",this.doctype),this.doctype=!0):(this.doctype+=n,"["===n?this.state=S.DOCTYPE_DTD:g(n)&&(this.state=S.DOCTYPE_QUOTED,this.q=n));continue;case S.DOCTYPE_QUOTED:this.doctype+=n,n===this.q&&(this.q="",this.state=S.DOCTYPE);continue;case S.DOCTYPE_DTD:this.doctype+=n,"]"===n?this.state=S.DOCTYPE:g(n)&&(this.state=S.DOCTYPE_DTD_QUOTED,this.q=n);continue;case S.DOCTYPE_DTD_QUOTED:this.doctype+=n,n===this.q&&(this.state=S.DOCTYPE_DTD,this.q="");continue;case S.COMMENT:"-"===n?this.state=S.COMMENT_ENDING:this.comment+=n;continue;case S.COMMENT_ENDING:"-"===n?(this.state=S.COMMENT_ENDED,this.comment=E(this.opt,this.comment),this.comment&&T(this,"oncomment",this.comment),this.comment=""):(this.comment+="-"+n,this.state=S.COMMENT);continue;case S.COMMENT_ENDED:">"!==n?(k(this,"Malformed comment"),this.comment+="--"+n,this.state=S.COMMENT):this.state=S.TEXT;continue;case S.CDATA:"]"===n?this.state=S.CDATA_ENDING:this.cdata+=n;continue;case S.CDATA_ENDING:"]"===n?this.state=S.CDATA_ENDING_2:(this.cdata+="]"+n,this.state=S.CDATA);continue;case S.CDATA_ENDING_2:">"===n?(this.cdata&&T(this,"oncdata",this.cdata),T(this,"onclosecdata"),this.cdata="",this.state=S.TEXT):"]"===n?this.cdata+="]":(this.cdata+="]]"+n,this.state=S.CDATA);continue;case S.PROC_INST:"?"===n?this.state=S.PROC_INST_ENDING:p(n)?this.state=S.PROC_INST_BODY:this.procInstName+=n;continue;case S.PROC_INST_BODY:if(!this.procInstBody&&p(n))continue;"?"===n?this.state=S.PROC_INST_ENDING:this.procInstBody+=n;continue;case S.PROC_INST_ENDING:">"===n?(T(this,"onprocessinginstruction",{name:this.procInstName,body:this.procInstBody}),this.procInstName=this.procInstBody="",this.state=S.TEXT):(this.procInstBody+="?"+n,this.state=S.PROC_INST_BODY);continue;case S.OPEN_TAG:v(u,n)?this.tagName+=n:(A(this),">"===n?F(this):"/"===n?this.state=S.OPEN_TAG_SLASH:(p(n)||k(this,"Invalid character in tag name"),this.state=S.ATTRIB));continue;case S.OPEN_TAG_SLASH:">"===n?(F(this,!0),M(this)):(k(this,"Forward-slash in opening tag not followed by >"),this.state=S.ATTRIB);continue;case S.ATTRIB:if(p(n))continue;">"===n?F(this):"/"===n?this.state=S.OPEN_TAG_SLASH:v(l,n)?(this.attribName=n,this.attribValue="",this.state=S.ATTRIB_NAME):k(this,"Invalid attribute name");continue;case S.ATTRIB_NAME:"="===n?this.state=S.ATTRIB_VALUE:">"===n?(k(this,"Attribute without value"),this.attribValue=this.attribName,L(this),F(this)):p(n)?this.state=S.ATTRIB_NAME_SAW_WHITE:v(u,n)?this.attribName+=n:k(this,"Invalid attribute name");continue;case S.ATTRIB_NAME_SAW_WHITE:if("="===n)this.state=S.ATTRIB_VALUE;else{if(p(n))continue;k(this,"Attribute without value"),this.tag.attributes[this.attribName]="",this.attribValue="",T(this,"onattribute",{name:this.attribName,value:""}),this.attribName="",">"===n?F(this):v(l,n)?(this.attribName=n,this.state=S.ATTRIB_NAME):(k(this,"Invalid attribute name"),this.state=S.ATTRIB)}continue;case S.ATTRIB_VALUE:if(p(n))continue;g(n)?(this.q=n,this.state=S.ATTRIB_VALUE_QUOTED):(k(this,"Unquoted attribute value"),this.state=S.ATTRIB_VALUE_UNQUOTED,this.attribValue=n);continue;case S.ATTRIB_VALUE_QUOTED:if(n!==this.q){"&"===n?this.state=S.ATTRIB_VALUE_ENTITY_Q:this.attribValue+=n;continue}L(this),this.q="",this.state=S.ATTRIB_VALUE_CLOSED;continue;case S.ATTRIB_VALUE_CLOSED:p(n)?this.state=S.ATTRIB:">"===n?F(this):"/"===n?this.state=S.OPEN_TAG_SLASH:v(l,n)?(k(this,"No whitespace between attributes"),this.attribName=n,this.attribValue="",this.state=S.ATTRIB_NAME):k(this,"Invalid attribute name");continue;case S.ATTRIB_VALUE_UNQUOTED:if(!m(n)){"&"===n?this.state=S.ATTRIB_VALUE_ENTITY_U:this.attribValue+=n;continue}L(this),">"===n?F(this):this.state=S.ATTRIB;continue;case S.CLOSE_TAG:if(this.tagName)">"===n?M(this):v(u,n)?this.tagName+=n:this.script?(this.script+=""===n?M(this):k(this,"Invalid characters in closing tag");continue;case S.TEXT_ENTITY:case S.ATTRIB_VALUE_ENTITY_Q:case S.ATTRIB_VALUE_ENTITY_U:var a,h;switch(this.state){case S.TEXT_ENTITY:a=S.TEXT,h="textNode";break;case S.ATTRIB_VALUE_ENTITY_Q:a=S.ATTRIB_VALUE_QUOTED,h="attribValue";break;case S.ATTRIB_VALUE_ENTITY_U:a=S.ATTRIB_VALUE_UNQUOTED,h="attribValue"}";"===n?(this[h]+=I(this),this.entity="",this.state=a):v(this.entity.length?d:f,n)?this.entity+=n:(k(this,"Invalid character in entity name"),this[h]+="&"+this.entity+n,this.entity="",this.state=a);continue;default:throw new Error(this,"Unknown state: "+this.state)}this.position>=this.bufferCheckPosition&&function(t){for(var i=Math.max(e.MAX_BUFFER_LENGTH,10),n=0,s=0,o=r.length;si)switch(r[s]){case"textNode":O(t);break;case"cdata":T(t,"oncdata",t.cdata),t.cdata="";break;case"script":T(t,"onscript",t.script),t.script="";break;default:P(t,"Max buffer length exceeded: "+r[s])}n=Math.max(n,a)}var h=e.MAX_BUFFER_LENGTH-n;t.bufferCheckPosition=h+t.position}(this);return this} +/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var t;O(t=this),""!==t.cdata&&(T(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(T(t,"onscript",t.script),t.script="")}};try{n=i(45).Stream}catch(t){n=function(){}}var o=e.EVENTS.filter((function(t){return"error"!==t&&"end"!==t}));function a(t,e){if(!(this instanceof a))return new a(t,e);n.apply(this),this._parser=new s(t,e),this.writable=!0,this.readable=!0;var i=this;this._parser.onend=function(){i.emit("end")},this._parser.onerror=function(t){i.emit("error",t),i._parser.error=null},this._decoder=null,o.forEach((function(t){Object.defineProperty(i,"on"+t,{get:function(){return i._parser["on"+t]},set:function(e){if(!e)return i.removeAllListeners(t),i._parser["on"+t]=e,e;i.on(t,e)},enumerable:!0,configurable:!1})}))}a.prototype=Object.create(n.prototype,{constructor:{value:a}}),a.prototype.write=function(e){if("function"==typeof t&&"function"==typeof t.isBuffer&&t.isBuffer(e)){if(!this._decoder){var n=i(23).StringDecoder;this._decoder=new n("utf8")}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit("data",e),!0},a.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},a.prototype.on=function(t,e){var i=this;return i._parser["on"+t]||-1===o.indexOf(t)||(i._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),i.emit.apply(i,e)}),n.prototype.on.call(i,t,e)};var h="http://www.w3.org/XML/1998/namespace",c={xml:h,xmlns:"http://www.w3.org/2000/xmlns/"},l=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,u=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,f=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,d=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function p(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function g(t){return'"'===t||"'"===t}function m(t){return">"===t||p(t)}function v(t,e){return t.test(e)}function b(t,e){return!v(t,e)}var y,_,x,S=0;for(var w in e.STATE={BEGIN:S++,BEGIN_WHITESPACE:S++,TEXT:S++,TEXT_ENTITY:S++,OPEN_WAKA:S++,SGML_DECL:S++,SGML_DECL_QUOTED:S++,DOCTYPE:S++,DOCTYPE_QUOTED:S++,DOCTYPE_DTD:S++,DOCTYPE_DTD_QUOTED:S++,COMMENT_STARTING:S++,COMMENT:S++,COMMENT_ENDING:S++,COMMENT_ENDED:S++,CDATA:S++,CDATA_ENDING:S++,CDATA_ENDING_2:S++,PROC_INST:S++,PROC_INST_BODY:S++,PROC_INST_ENDING:S++,OPEN_TAG:S++,OPEN_TAG_SLASH:S++,ATTRIB:S++,ATTRIB_NAME:S++,ATTRIB_NAME_SAW_WHITE:S++,ATTRIB_VALUE:S++,ATTRIB_VALUE_QUOTED:S++,ATTRIB_VALUE_CLOSED:S++,ATTRIB_VALUE_UNQUOTED:S++,ATTRIB_VALUE_ENTITY_Q:S++,ATTRIB_VALUE_ENTITY_U:S++,CLOSE_TAG:S++,CLOSE_TAG_SAW_WHITE:S++,SCRIPT:S++,SCRIPT_ENDING:S++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach((function(t){var i=e.ENTITIES[t],n="number"==typeof i?String.fromCharCode(i):i;e.ENTITIES[t]=n})),e.STATE)e.STATE[e.STATE[w]]=w;function C(t,e,i){t[e]&&t[e](i)}function T(t,e,i){t.textNode&&O(t),C(t,e,i)}function O(t){t.textNode=E(t.opt,t.textNode),t.textNode&&C(t,"ontext",t.textNode),t.textNode=""}function E(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function P(t,e){return O(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,C(t,"onerror",e),t}function j(t){return t.sawRoot&&!t.closedRoot&&k(t,"Unclosed root tag"),t.state!==S.BEGIN&&t.state!==S.BEGIN_WHITESPACE&&t.state!==S.TEXT&&P(t,"Unexpected end"),O(t),t.c="",t.closed=!0,C(t,"onend"),s.call(t,t.strict,t.opt),t}function k(t,e){if("object"!=typeof t||!(t instanceof s))throw new Error("bad call to strictFail");t.strict&&P(t,e)}function A(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,i=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(i.ns=e.ns),t.attribList.length=0,T(t,"onopentagstart",i)}function D(t,e){var i=t.indexOf(":")<0?["",t]:t.split(":"),n=i[0],r=i[1];return e&&"xmlns"===t&&(n="xmlns",r=""),{prefix:n,local:r}}function L(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=D(t.attribName,!0),i=e.prefix,n=e.local;if("xmlns"===i)if("xml"===n&&t.attribValue!==h)k(t,"xml: prefix must be bound to "+h+"\nActual: "+t.attribValue);else if("xmlns"===n&&"http://www.w3.org/2000/xmlns/"!==t.attribValue)k(t,"xmlns: prefix must be bound to http://www.w3.org/2000/xmlns/\nActual: "+t.attribValue);else{var r=t.tag,s=t.tags[t.tags.length-1]||t;r.ns===s.ns&&(r.ns=Object.create(s.ns)),r.ns[n]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,T(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function F(t,e){if(t.opt.xmlns){var i=t.tag,n=D(t.tagName);i.prefix=n.prefix,i.local=n.local,i.uri=i.ns[n.prefix]||"",i.prefix&&!i.uri&&(k(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),i.uri=n.prefix);var r=t.tags[t.tags.length-1]||t;i.ns&&r.ns!==i.ns&&Object.keys(i.ns).forEach((function(e){T(t,"onopennamespace",{prefix:e,uri:i.ns[e]})}));for(var s=0,o=t.attribList.length;s",t.tagName="",void(t.state=S.SCRIPT);T(t,"onscript",t.script),t.script=""}var e=t.tags.length,i=t.tagName;t.strict||(i=i[t.looseCase]());for(var n=i;e--;){if(t.tags[e].name===n)break;k(t,"Unexpected close tag")}if(e<0)return k(t,"Unmatched closing tag: "+t.tagName),t.textNode+="",void(t.state=S.TEXT);t.tagName=i;for(var r=t.tags.length;r-- >e;){var s=t.tag=t.tags.pop();t.tagName=t.tag.name,T(t,"onclosetag",t.tagName);var o={};for(var a in s.ns)o[a]=s.ns[a];var h=t.tags[t.tags.length-1]||t;t.opt.xmlns&&s.ns!==h.ns&&Object.keys(s.ns).forEach((function(e){var i=s.ns[e];T(t,"onclosenamespace",{prefix:e,uri:i})}))}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=S.TEXT}function I(t){var e,i=t.entity,n=i.toLowerCase(),r="";return t.ENTITIES[i]?t.ENTITIES[i]:t.ENTITIES[n]?t.ENTITIES[n]:("#"===(i=n).charAt(0)&&("x"===i.charAt(1)?(i=i.slice(2),r=(e=parseInt(i,16)).toString(16)):(i=i.slice(1),r=(e=parseInt(i,10)).toString(10))),i=i.replace(/^0+/,""),isNaN(e)||r.toLowerCase()!==i?(k(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function R(t,e){"<"===e?(t.state=S.OPEN_WAKA,t.startTagPosition=t.position):p(e)||(k(t,"Non-whitespace before first tag."),t.textNode=e,t.state=S.TEXT)}function B(t,e){var i="";return e1114111||_(a)!==a)throw RangeError("Invalid code point: "+a);a<=65535?n.push(a):(t=55296+((a-=65536)>>10),e=a%1024+56320,n.push(t,e)),(r+1===s||n.length>i)&&(o+=y.apply(null,n),n.length=0)}return o},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:x,configurable:!0,writable:!0}):String.fromCodePoint=x)}(e)}).call(this,i(15).Buffer)},function(t,e,i){t.exports=r;var n=i(20).EventEmitter;function r(){n.call(this)}i(13)(r,n),r.Readable=i(21),r.Writable=i(53),r.Duplex=i(54),r.Transform=i(55),r.PassThrough=i(56),r.Stream=r,r.prototype.pipe=function(t,e){var i=this;function r(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function s(){i.readable&&i.resume&&i.resume()}i.on("data",r),t.on("drain",s),t._isStdio||e&&!1===e.end||(i.on("end",a),i.on("close",h));var o=!1;function a(){o||(o=!0,t.end())}function h(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){i.removeListener("data",r),t.removeListener("drain",s),i.removeListener("end",a),i.removeListener("close",h),i.removeListener("error",c),t.removeListener("error",c),i.removeListener("end",l),i.removeListener("close",l),t.removeListener("close",l)}return i.on("error",c),t.on("error",c),i.on("end",l),i.on("close",l),t.on("close",l),t.emit("pipe",i),t}},function(t,e){},function(t,e,i){"use strict";var n=i(19).Buffer,r=i(48);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i},t.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e,i,r,s=n.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,i=s,r=a,e.copy(i,r),a+=o.data.length,o=o.next;return s},t}(),r&&r.inspect&&r.inspect.custom&&(t.exports.prototype[r.inspect.custom]=function(){var t=r.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,i){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function s(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new s(r.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new s(r.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},i(50),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,i(12))},function(t,e,i){(function(t,e){!function(t,i){"use strict";if(!t.setImmediate){var n,r,s,o,a,h=1,c={},l=!1,u=t.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(t);f=f&&f.setTimeout?f:t,"[object process]"==={}.toString.call(t.process)?n=function(t){e.nextTick((function(){p(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?t.MessageChannel?((s=new MessageChannel).port1.onmessage=function(t){p(t.data)},n=function(t){s.port2.postMessage(t)}):u&&"onreadystatechange"in u.createElement("script")?(r=u.documentElement,n=function(t){var e=u.createElement("script");e.onreadystatechange=function(){p(t),e.onreadystatechange=null,r.removeChild(e),e=null},r.appendChild(e)}):n=function(t){setTimeout(p,0,t)}:(o="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(o)&&p(+e.data.slice(o.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),n=function(e){t.postMessage(o+e,"*")}),f.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),i=0;i=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o},a=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{h(n.next(t))}catch(t){s(t)}}function a(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((n=n.apply(t,e||[])).next())}))};let h=class extends n.a{constructor(){super(),this.data="",this.colorScheme="dynamic",this.numberHits=100,this.numberHsps=10,this.logSkippedHsps=!0,this.canvasWrapperStroke=!0}render(){return a(this,void 0,void 0,(function*(){const t={colorScheme:this.colorScheme,numberHits:this.numberHits,numberHsps:this.numberHsps,logSkippedHsps:this.logSkippedHsps,canvasWrapperStroke:this.canvasWrapperStroke};if(null===document.getElementById("canvas")){const t=document.createElement("div");t.id="canvas-wrapper";const e=document.createElement("canvas");e.id="canvas",t.appendChild(e),document.body.appendChild(t)}const e=Object(r.m)(this.data),i=yield Object(r.e)(e),o=Object(r.c)(i,"SSSResultModel");return new s.a("canvas",o,t).render(),n.c`${this.canvasDivTemplate}`}))}get canvasDivTemplate(){return n.c``}};o([Object(n.d)({type:String})],h.prototype,"data",void 0),o([Object(n.d)({type:String})],h.prototype,"colorScheme",void 0),o([Object(n.d)({type:Number})],h.prototype,"numberHits",void 0),o([Object(n.d)({type:Number})],h.prototype,"numberHsps",void 0),o([Object(n.d)({type:Boolean})],h.prototype,"logSkippedHsps",void 0),o([Object(n.d)({type:Boolean})],h.prototype,"canvasWrapperStroke",void 0),h=o([Object(n.b)("jd-visual-output")],h)},function(t,e,i){"use strict";var n=i(5),r=i(2),s=i(11),o=function(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o},a=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{h(n.next(t))}catch(t){s(t)}}function a(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((n=n.apply(t,e||[])).next())}))};let h=class extends n.a{constructor(){super(),this.data="",this.colorScheme="dynamic",this.numberHits=30,this.canvasWrapperStroke=!0}render(){return a(this,void 0,void 0,(function*(){const t={colorScheme:this.colorScheme,numberHits:this.numberHits,canvasWrapperStroke:this.canvasWrapperStroke};if(null===document.getElementById("canvas")){const t=document.createElement("div");t.id="canvas-wrapper";const e=document.createElement("canvas");e.id="canvas",t.appendChild(e),document.body.appendChild(t)}const e=Object(r.m)(this.data),i=yield Object(r.e)(e),o=Object(r.c)(i,"SSSResultModel"),a=Object(r.l)(o),h=yield Object(r.e)(a,"xml"),c=Object(r.g)(h),l=Object(r.c)(c,"IPRMCResultModelFlat");return new s.a("canvas",o,l,t).render(),n.c` ${this.canvasDivTemplate} `}))}get canvasDivTemplate(){return n.c``}};o([Object(n.d)({type:String})],h.prototype,"data",void 0),o([Object(n.d)({type:String})],h.prototype,"colorScheme",void 0),o([Object(n.d)({type:Number})],h.prototype,"numberHits",void 0),o([Object(n.d)({type:Boolean})],h.prototype,"canvasWrapperStroke",void 0),h=o([Object(n.b)("jd-functional-predictions")],h)},function(t,e,i){"use strict";var n=i(17),r=i.n(n),s=i(10),o=i(11),a=i(1),h=i(2),c=function(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o},l=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{h(n.next(t))}catch(t){s(t)}}function a(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((n=n.apply(t,e||[])).next())}))};class u{constructor(){this.listener=()=>{},this.jobIds=[],this.submitterName=""}static getInstance(){return this.instance||(this.instance=new u),this.instance}addListener(t){this.listener=t}addCanvas(t,e,i){0!==this.jobIds.length&&this.jobIds.includes(t)&&i===this.submitterName||(this.submitterName=i,this.jobIds.push(t),this.canvasInstance={jobId:t,data:e,submitter:i},this.listener(this.canvasInstance))}}const f=u.getInstance();class d{constructor(){if(this.jobId="",this.templateElement=document.getElementById("input-jobid"),this.hostElement=document.getElementById("jd-viewers-app"),null!==this.templateElement){const t=document.importNode(this.templateElement.content,!0);this.element=t.firstElementChild,this.jobIdElement=this.element.querySelector("#jobid"),this.submitListener(),this.renderForm()}}submitListener(){this.element.addEventListener("submit",this.submitHandler)}renderForm(){this.hostElement.insertAdjacentElement("afterbegin",this.element)}submitHandler(t){t.preventDefault();const e=t,i=this.jobIdElement.value.trim();let n=Object.assign({},a.b);n.value=i,Object(h.k)(n)?"mock_jobid-I20200317-103136-0485-5599422-np2"===i?f.addCanvas(i,"../src/testdata/ncbiblast.json",e.submitter.name.trim()):f.addCanvas(i,i,e.submitter.name.trim()):alert("The jobId provided is not valid!")}}c([function(t,e,i){const n=i.value;return{configurable:!0,get(){return n.bind(this)}}}],d.prototype,"submitHandler",null);new d,new class{constructor(){if(this.templateElement=document.getElementById("jd-viewers-output"),this.hostElement=document.getElementById("jd-viewers-app"),null!==this.templateElement){const t=document.importNode(this.templateElement.content,!0);this.elementCanvas=t.firstElementChild,f.addListener(t=>{this.canvasInstance=t,this.renderCanvas()})}}renderCanvas(){return l(this,void 0,void 0,(function*(){let t;this.hostElement.insertAdjacentElement("beforeend",this.elementCanvas);const e=Object(h.m)(this.canvasInstance.data),i=yield Object(h.e)(e),n=Object(h.c)(i,"SSSResultModel");if("visual-output"===this.canvasInstance.submitter)t=new s.a("canvas",n,{colorScheme:a.a.dynamic,numberHits:100,numberHsps:10,logSkippedHsps:!0,canvasWrapperStroke:!0}),t.render();else if("functional-predictions"===this.canvasInstance.submitter){let e;e="mock_jobid-I20200317-103136-0485-5599422-np2"===this.canvasInstance.jobId?"../src/testdata/iprmc.xml":Object(h.l)(n);const i=yield Object(h.e)(e,"xml"),r=Object(h.g)(i),s=Object(h.c)(r,"IPRMCResultModelFlat");t=new o.a("canvas",n,s,{colorScheme:a.a.dynamic,numberHits:30,canvasWrapperStroke:!0}),t.render()}document.getElementById("btn-svg").onclick=function(){var e;document.getElementById("svg").src=r()(t.canvas.toSVG().toString());const i=document.getElementById("canvas-wrapper");null===(e=i.parentNode)||void 0===e||e.removeChild(i)},document.getElementById("btn-png").onclick=function(){var e;const i=document.getElementById("png");i.src=t.canvas.toDataURL({format:"png",enableRetinaScaling:!0,withoutTransform:!0}).toString(),i.width=t.canvas.getWidth();const n=document.getElementById("canvas-wrapper");null===(e=n.parentNode)||void 0===e||e.removeChild(n)}}))}}}]); \ No newline at end of file diff --git a/index.html b/index.html index 443a2d8..75c8651 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ jdistpatcher-viewers - + diff --git a/package-lock.json b/package-lock.json index 96a6ccc..41acb71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jdispatcher-viewers", - "version": "0.0.3", + "version": "0.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f6addee..016e051 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jdispatcher-viewers", "description": "Interactive Visual Output and Functional Prediction visualizations", - "version": "0.0.3", + "version": "0.0.4", "module": "./dist/jd_viewers_bundle.js", "main": "./bin/jd-viewers-cli.js", "files": [