This repository has been archived by the owner on Dec 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
js9plugins.min.js
710 lines (710 loc) · 334 KB
/
js9plugins.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};$jscomp.arrayFromIterator=function(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c};
$jscomp.arrayFromIterable=function(a){return a instanceof Array?a:$jscomp.arrayFromIterator($jscomp.makeIterator(a))};$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var d=a.length,f=0;f<d;f++){var e=a[f];if(b.call(c,e,f,a))return{i:f,v:e}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var f=a[d];f in c||(c[f]={});c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6","es3");$jscomp.polyfill("Number.isNaN",function(a){return a?a:function(a){return"number"===typeof a&&isNaN(a)}},"es6","es3");
$jscomp.polyfill("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}},"es6","es3");$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var f=b.length;c=c||0;for(0>c&&(c=Math.max(c+f,0));c<f;c++){var e=b[c];if(e===a||Object.is(e,a))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,c){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,c||0)}},"es6","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};
$jscomp.iteratorFromArray=function(a,b){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,d={next:function(){if(c<a.length){var f=c++;return{value:b(f,a[f]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6","es3");
$jscomp.polyfill("Array.prototype.fill",function(a){return a?a:function(a,c,d){var b=this.length||0;0>c&&(c=Math.max(0,b+c));if(null==d||d>b)d=b;d=Number(d);0>d&&(d=Math.max(0,b+d));for(c=Number(c||0);c<d;c++)this[c]=a;return this}},"es6","es3");$jscomp.polyfill("Number.isFinite",function(a){return a?a:function(a){return"number"!==typeof a?!1:!isNaN(a)&&Infinity!==a&&-Infinity!==a}},"es6","es3");
(function(){function a(b,c,d){function f(h,g){if(!c[h]){if(!b[h]){var k="function"==typeof require&&require;if(!g&&k)return k(h,!0);if(e)return e(h,!0);g=Error("Cannot find module '"+h+"'");throw g.code="MODULE_NOT_FOUND",g;}g=c[h]={exports:{}};b[h][0].call(g.exports,function(a){return f(b[h][1][a]||a)},g,g.exports,a,b,c,d)}return c[h].exports}for(var e="function"==typeof require&&require,h=0;h<d.length;h++)f(d[h]);return f}return a})()({1:[function(a,b,c){(function(){function b(a,b){var c=$(a).find(".JS9Archive-form")[0];
if(""!==c.ra.value&&""!==c.dec.value){var d=parseFloat(c.width.value),g=parseFloat(c.height.value);"-"!==c.dec.value[0]&&"+"!==c.dec.value[0]&&(c.dec.value="+"+c.dec.value);60<d&&(c.width.value="60",d=60);60<g&&(c.height.value="60",g=60);var h=$(c).find(".server-menu")[0],k=$(c).find(".source-menu")[0];l.Services[h.options[h.selectedIndex].value].retrieve({name:c.object.value,e:"J2000",h:g.toString(),w:d.toString(),r:c.ra.value,d:c.dec.value,c:c.gzip.checked,s:k.options[k.selectedIndex].value,source:k.options[k.selectedIndex].innerHTML,
CORS:c.CORS.checked,display:b},function(b){$(a).find(".status").html(b)})}}function c(a,b){function c(b){$(a).find(".status").html(b)}var d=$(a).find(".JS9Archive-form")[0];if(""!==d.object.value){var g=encodeURI((JS9.globalOpts.simbadProxy||"https://js9.si.edu/cgi-bin/simbad-proxy.cgi")+"?"+d.object.value);h({url:g,title:"Name",status:c},function(a,b){a=b.responseText.trim().split(" ");":"!==a[0][1]?(d.ra.value=a[0],d.dec.value=a[1]):c("<span style='color: red;'>Object not found?</span>")})}else{var k=
JS9.GetImage({display:b});b=k.getWCSSys();if("image"===b||"physical"===b)g=JS9.globalOpts.xeqPlugins,JS9.globalOpts.xeqPlugins=!1,k.setWCSSys("native",!1);var e=JS9.pix2wcs(k.raw.wcs,k.raw.header.NAXIS1/2,k.raw.header.NAXIS2/2).split(/ +/),f=JS9.PixToWCS(k.raw.header.NAXIS1/2+1,k.raw.header.NAXIS2/2+1,{display:k});d.ra.value=e[0]||"";d.dec.value=e[1]||"";e=JS9.PixToWCS(1,k.raw.header.NAXIS2/2+1,{display:k});var l=JS9.PixToWCS(k.raw.header.NAXIS1+1,k.raw.header.NAXIS2/2+1,{display:k});d.width.value=
Math.floor(Math.abs(60*(e.ra-l.ra))*Math.cos(f.dec/57.2958)*10)/10;e=JS9.PixToWCS(k.raw.header.NAXIS1/2+1,1,{display:k});l=JS9.PixToWCS(k.raw.header.NAXIS1/2+1,k.raw.header.NAXIS2+1,{display:k});d.height.value=Math.floor(10*Math.abs(60*(e.dec-l.dec)))/10;if("image"===b||"physical"===b)k.setWCSSys(b,!1),JS9.globalOpts.xeqPlugins=g}}function e(a){var b=a[0],c=$(a).data("menu"),d=$(a).data("submenu");b.options.length=0;$.each(c,function(a,c){b.options[b.options.length]=new Option(c.text,c.value)});void 0!==
d&&($(d).data("menu",c[b.selectedIndex].subdata),e(d),a.change(function(){$(d).data("menu",c[b.selectedIndex].subdata);e(d)}))}var h=a("./xhr"),l=a("./remote-service");a("./image-services");a("./catalog-services");JS9.RegisterPlugin("DataSources","ArchivesCatalogs",function(){var a=this.div,d=this.winHandle;a.innerHTML='<form class="JS9Archive-form">\n <p>\n\t <select class="service-menu JS9Select"></select>\n\t <select class="server-menu JS9Select"></select>\n\t <select class="source-menu JS9Select"></select>\n\t <p>\n\t <table width="98%">\n\t <tr><td>RA: \t</td><td>\t<input type=text name=ra\tsize=12> </td>\n\t\t<td>Dec: \t</td><td>\t<input type=text name=dec\tsize=12> </td>\n\t\t<td><input type=button value="Set RA/Dec" class="get-ra-dec JS9Button2"> </td>\n\t <tr><td>Width: </td><td>\t<input type=text name=width\tsize=12 value=15> </td>\n\t\t<td>Height: </td><td>\t<input type=text name=height\tsize=12 value=15> </td>\n <td>\n <input type=checkbox name=CORS checked>CORS\n\t\t <input type=checkbox name=gzip> compress\n </td>\n\t </tr>\n\t <tr><td>Object: </td> <td> <input type=text name=object size=12> </td>\n\t\t<td> </td>\n\t\t<td> </td>\n\t\t<td> </td>\n </tr>\n <tr>\n\t\t<td> </td>\n\t\t<td> </td>\n\t\t<td> </td>\n\t\t<td> </td>\n\t\t<td> </td>\n </tr>\n <tr>\n\t\t<td colspan="4"><span class=status></td>\n\t <td>\n <input type=button value="Cancel" class="service-cancel JS9Button2" '+
(d?"":'style="display:none;"')+'>\n \n <input type=button value="Get Data" class="service-go JS9RunButton">\n </td>\n </tr>\n\t </table>\n\t </form>';var h=$(a).find(".service-menu"),f=$(a).find(".server-menu"),n=$(a).find(".source-menu");$(h).data("submenu",f);$(f).data("submenu",n);var q=this.display;$(a).find(".service-cancel").on("mouseup",function(){d&&d.close()});$(a).find(".service-go").on("mouseup",function(){b(a,
q)});$(a).find(".get-ra-dec").on("mouseup",function(){c(a,q)});var r=[];$.each(l.Services,function(a,b){"image-service"===b.type&&r.push({text:b.params.text,value:b.params.value,subdata:b.params.surveys})});var v=[];$.each(l.Services,function(a,b){"catalog-service"===b.type&&v.push({text:b.params.text,value:b.params.value,subdata:b.params.surveys})});$(h).data("menu",[{text:"Image Servers",value:"imgserv",subdata:r},{text:"Catalog Servers",value:"catserv",subdata:v}]);e(h)},{menu:"view",menuItem:"Archives & Catalogs",
winTitle:"Archives & Catalogs",winDims:[610,210],help:"archive/archive.html"})})()},{"./catalog-services":3,"./image-services":5,"./remote-service":6,"./xhr":10}],2:[function(a,b,c){var d=a("./remote-service");a("./starbase");a("./strtod");var f=a("./template"),e=a("./xhr");b.exports=function(a){d.Register(a.value,this);this.type="catalog-service";this.params=a;this.table2cat=function(a,b){var c,d,g=this.params.shape,h=b[this.params.xcol],e=b[this.params.ycol],f=function(a,b,c){return(a=JS9.WCSToPix(b,
c,{display:a}))?{x:a.x,y:a.y}:null};switch(g){case "box":var l=function(a){return{width:7,height:7}};break;case "circle":l=function(a){return{radius:3.5}};break;case "ellipse":l=function(a){return{width:7,height:7}}}var u=[],t;for(d=c=0;c<b.data.length;c++)if(t=f(a,15*b.data[c][h],b.data[c][e])){var x=l(a,b.data[c][1],b.data[c][1]);t={id:c.toString(),shape:g,x:t.x,y:t.y,width:x.width,height:x.height,radius:x.radius,angle:0,data:{ra:15*b.data[c][h],dec:b.data[c][e]}};u[d++]=t}return u};this.retrieve=
function(a,b){this.params.calc(a);a.units=this.params.units;var c=f(this.params.url,a),d=e({url:c,title:"Catalog",status:b,CORS:a.CORS},function(b){var c=JS9.GetImage({display:a.display});b=d.responseText;var g={};g.units=a.units;JS9.LoadCatalog(a.name,b,g,{display:c})})}}},{"./remote-service":6,"./starbase":7,"./strtod":8,"./template":9,"./xhr":10}],3:[function(a,b,c){a("./strtod");a=a("./catalog-service");new a({text:"SAO",value:"saoCat",surveys:[{value:"tmc",text:"Two Mass Catalog"},{value:"gsc2",
text:"Guide Star Catalog 2"}],url:"https://www.cfa.harvard.edu/catalog/scat?catalog={s}&ra={r}&dec={d}&width={w}&height={h}&system={e}&compress={c}",calc:function(a){a.c&&(a.c="gzip");a.w*=60;a.h*=60;a.name=a.source+"@"+this.text},shape:"circle",xcol:"ra",ycol:"dec"});new a({text:"VizieR",value:"vizCat",surveys:[{value:"II/246",text:"2MASS"},{value:"2MASX",text:"2MASS Extended Source"},{value:"B/DENIS",text:"DENIS 3rd Release 2005"},{value:"GLIMPSE",text:"Spitzer's GLIMPSE"},{value:"GSC2.3",text:"GSC-II Catalog, Version 2.3.2"},
{value:"HIP2",text:"Hipparcos (2007)"},{value:"IRAS",text:"IRAS "},{value:"NVSS",text:"NRAO VLA Sky Survey"},{value:"SDSS-DR9",text:"SDSS Photometric Catalog"},{value:"Tycho-2",text:"Tycho-2"},{value:"UCAC4",text:"UCAC 4th Release"},{value:"USNO-A2",text:"USNO-A2"},{value:"USNO-B1",text:"USNO-B1"},{value:"WISE",text:"WISE"}],url:"https://vizier.u-strasbg.fr/viz-bin/asu-tsv?-source={s}&-out.add=_RAJ,_DEJ&-c={r}{d}&-c.bm={w}x{h}&-oc.form=s&-out.meta=h",calc:function(a){a.c&&(a.c="gzip");a.name=a.source+
"@"+this.text},shape:"box",xcol:"_RAJ2000",ycol:"_DEJ2000"})},{"./catalog-service":2,"./strtod":8}],4:[function(a,b,c){var d=a("./remote-service"),f=a("./template"),e=a("./xhr");b.exports=function(a){d.Register(a.value,this);this.type="image-service";this.params=a;this.retrieve=function(b,c){var d=b.display;a.calc(b);var g=f(a.url,b);e({url:g,title:"Image",status:c,type:"blob",CORS:b.CORS},function(c,g){void 0===a.handler?(c=new Blob([g.response]),c.name=b.name,JS9.fits.handleFITSFile(c,{display:d})):
a.handler(c,g,a,b)})}}},{"./remote-service":6,"./template":9,"./xhr":10}],5:[function(a,b,c){a=a("./image-service");var d=function(a){a=""!==a.name?a.source+"_"+a.name:a.source+"_"+a.r+a.d;return a=a.replace(/\s+/g,"_")+".fits"};new a({text:"DSS1@SAO",value:"saoDSS",surveys:[{value:"DSS1",text:"DSS1"}],url:"https://www.cfa.harvard.edu/archive/dss?r={r}&d={d}&w={w}&h={h}&e={e}&c={c}",calc:function(a){a.c&&(a.c="gzip");a.name=d(a)}});new a({text:"DSS@STScI",value:"stsDSS",surveys:[{value:"poss2ukstu_ir",
text:"STScI DSS2 IR"},{value:"poss2ukstu_red",text:"STScI DSS2 Red"},{value:"poss2ukstu_blue",text:"STScI DSS2 Blue"},{value:"poss1_red",text:"STScI DSS1 Red"},{value:"poss1_blue",text:"STScI DSS1 Blue"}],url:"https://stdatu.stsci.edu/cgi-bin/dss_search?r={r}&d={d}&w={w}&h={h}&e={e}&c={c}&v={s}&f=fits",calc:function(a){a.c=a.c?"gz":"none";a.name=d(a)}});new a({text:"DSS@ESO",value:"esoDSS",surveys:[{value:"DSS2-infrared",text:"ESO DSS2 IR"},{value:"DSS2-red",text:"ESO DSS2 Red"},{value:"DSS2-blue",
text:"ESO DSS2 Blue"},{value:"DSS1",text:"ESO DSS1"}],url:"https://archive.eso.org/dss/dss?ra={r}&dec={d}&equinox=J2000&x={w}&y={h}&mime-type={c}&Sky-Survey={s}",calc:function(a){a.c=a.c?"display/gz-fits":"application/x-fits";a.name=d(a)}});new a({text:"2Mass@IPAC",value:"ipac2m",surveys:[{value:"j",text:"IPAC 2Mass J"},{value:"h",text:"IPAC 2Mass H"},{value:"k",text:"IPAC 2Mass K"}],url:"https://irsa.ipac.caltech.edu/cgi-bin/Oasis/2MASSImg/nph-2massimg?objstr={r},{d}&size={radius}&band={s}",calc:function(a){a.radius=
Math.floor(60*Math.sqrt(a.w*a.w+a.h*a.h));a.name=d(a)}})},{"./image-service":4}],6:[function(a,b,c){c.Services={};c.Register=function(a,b){c.Services[a]=b}},{}],7:[function(a,b,c){function d(a){return a}function f(a){var b;for(b=0;b<a.length;b++)if(null===a[b].match(/^-+$/))return 0;return b}b.exports=function(a,b){var c,g;b=b||{};this.head={};this.type=[];this.data=[];a=a.replace(/\s+$/,"").split("\n");var h=0;if(b.skip)for(g=b.skip.split("");h<a.length&&(g[0]===a[h][0]||"\n"===g[1]&&""===a[h]);h++);
if(void 0!==a[h]&&void 0!==a[h+1]){this.headline=a[h++].trim().split(/ *\t */);b.units&&(this.unitline=a[h++].trim().split(/ *\t */));this.dashline=a[h++].trim().split(/ *\t */);for(c=f(this.dashline);0===c||c!==this.headline.length;)b.units?(this.headline=this.unitline,this.unitline=this.dashline):this.headline=this.dashline,this.dashline=a[h++].trim().split(/ *\t */),c=f(this.dashline);for(c=0;c<this.headline.length;c++)this.type[c]=b.type&&b.type[this.headline[c]]?b.type[this.headline[c]]:b.type&&
b.type.default?b.type.default:d;for(b=0;h<a.length&&g[0]!==a[h][0]&&("\n"!==g[1]||""!==a[h]);h++,b++)for(this.data[b]=a[h].split("\t"),c=0;c<this.data[b].length;c++)this.data[b][c]=this.type[c](this.data[b][c]);for(c=0;c<this.headline.length;c++)this[this.headline[c]]=c}}},{}],8:[function(a,b,c){b.exports=function(a){var b=a.trim().split(/[: ]/);if(3===b.length){var c=1;"-"===b[0].substr(0,1)&&(c=-1);var d=parseFloat(b[0]),l=parseFloat(b[1]);b=parseFloat(b[2]);c*=Math.abs(d)+l/60+b/3600}else c=parseFloat(a);
return isNaN(c)?a:c}},{}],9:[function(a,b,c){function d(a,b){var c,d="";for(c=0;c<b;c++)d+=a;return d}b.exports=function(a,b){return a.replace(/\{([a-zA-Z0-9_.%]*)\}/g,function(a,c){var g;a=b;c=c.split("%");var h=1>=c.length?"%s":c[1];c=c[0];c=c.split(".");for(g=0;g<c.length;g++)if(a.hasOwnProperty(c[g]))a=a[c[g]];else return"";c=h.substring(h.length-1);h=h.substring(0,h.length-1);h=h.split(".");g=h[0]|0;h=h[1]|0;switch(c){case "s":a=a.toString();break;case "f":a=a.toFixed(h);break;case "d":a=a.toFixed(0)}0!==
g&&g>a.length&&(a=0<g?d(" ",g-a.length)+a:a+d(" ",g-a.length));return a})}},{}],10:[function(a,b,c){b.exports=function(a,b){var c=a.status,d="",f=JS9.globalOpts.corsProxy||"https://js9.si.edu/cgi-bin/CORS-proxy.cgi";a.CORS&&(a.url=a.url.replace(/\?/g,"@"),a.url=a.url.replace(/&/g,"!"),a.url=encodeURI(a.url),a.url=f+"?Q="+a.url);1<JS9.DEBUG&&JS9.log("archive/catalog url: %s",a.url);f=new XMLHttpRequest;f.open("GET",a.url,!0);a.title&&(d=a.title);a.type&&(f.responseType=a.type);void 0!==c&&(f.addEventListener("progress",
function(a){c(d+" progress "+a.loaded.toString())}),f.addEventListener("error",function(a){c(d+" service error")}),f.addEventListener("abort",function(a){c(d+" service aborted")}));f.onload=function(a){4!==this.readyState||200!==this.status&&0!==this.status||(void 0!==c&&c(""),b(a,this))};f.send();return f}},{}]},{},[1]);
(function(){function a(a,b){var c;b=JS9.GetImage({display:b});var d=$(a).find(".js9BinningForm")[0];if(b&&b.raw){a={xcen:0,ycen:0,xdim:0,ydim:0,bin:1,filter:"",columns:"",cubecol:""};JS9.isNumber(d.xcen.value)&&(a.xcen=parseFloat(d.xcen.value));JS9.isNumber(d.ycen.value)&&(a.ycen=parseFloat(d.ycen.value));if(c=b.maybePhysicalToImage({x:a.xcen,y:a.ycen}))a.xcen=c.x,a.ycen=c.y;JS9.isNumber(d.xdim.value)&&(a.xdim=Math.floor(parseFloat(d.xdim.value)));JS9.isNumber(d.ydim.value)&&(a.ydim=Math.floor(parseFloat(d.ydim.value)));
JS9.isNumber(d.bin.value)?a.bin=parseFloat(d.bin.value):a.bin=d.bin.value;JS9.isNumber(d.bitpix.value)&&(a.bitpix=parseInt(d.bitpix.value,10));a.filter=d.filter.value;a.columns=d.columns.value;a.cubecol=d.cubecol.value;b.raw.hdu.table&&b.raw.hdu.table.columns!==a.columns&&(a.xcen=0,a.ycen=0);a.separate=$(d.separate).prop("checked");a.cubecol&&(a.separate=!0);a.binMode=$('input[name="binmode"]:checked').val();b.displaySection(a)}}function b(a,b){b||(b=this?this.display:JS9.displays[0]);if(b=JS9.GetImage({display:b}))if(a=
$(a).find(".js9BinningForm")[0],void 0!==b.raw.hdu){var c=b.raw.hdu;c.bin=c.bin||1;c.binMode=c.binMode||JS9.globalOpts.binMode||"s";a.rebin.disabled=!1;if(void 0===c.table||JS9.ishealpix(b)){c.bin=c.bin||1;var d=0<c.bin?c.bin:1/Math.abs(c.bin);b.parentFile&&b.raw.header&&void 0!==b.raw.header.LTM1_1&&(d=1/Math.abs(b.raw.header.LTM1_1));var f=b.getPan();f=b.imageToLogicalPos({x:f.ox,y:f.oy});a.xcen.value=String(Math.floor(f.x+.5*(d-1)));a.ycen.value=String(Math.floor(f.y+.5*(d-1)));a.bin.value=String(c.bin);
a.xdim.value=String(Math.floor(c.naxis1*d));a.ydim.value=String(Math.floor(c.naxis2*d));a.filter.value="";a.bitpix.value=b.raw.header.BITPIX;a.columns.value="";a.cubecol.value="";a.bin.disabled=!1;a.xcen.disabled=!1;a.ycen.disabled=!1;a.xdim.disabled=!1;a.ydim.disabled=!1;a.binmode.disabled=!1;a.filter.disabled=!0;a.filter.style.backgroundColor="#E0E0E0";a.bitpix.disabled=!0;a.bitpix.style.backgroundColor="#E0E0E0";a.columns.disabled=!0;a.columns.style.backgroundColor="#E0E0E0";a.cubecol.disabled=
!0;a.cubecol.style.backgroundColor="#E0E0E0"}else f=b.getPan(),f=b.imageToLogicalPos({x:f.ox,y:f.oy}),a.xcen.value=String(Math.floor(f.x+.5)),a.ycen.value=String(Math.floor(f.y+.5)),a.bin.value=String(c.table.bin),a.xdim.value=String(Math.floor(c.table.xdim)),a.ydim.value=String(Math.floor(c.table.ydim)),a.filter.value=c.table.filter||"",a.bitpix.value=c.table.bitpix||JS9.globalOpts.table.bitpix,a.columns.value=c.table.columns||"",a.cubecol.value="",a.bin.disabled=!1,a.xcen.disabled=!1,a.ycen.disabled=
!1,a.xdim.disabled=!1,a.ydim.disabled=!1,a.filter.disabled=!1,a.bitpix.disabled=!1,a.columns.disabled=!1,a.cubecol.disabled=!1;b.parentFile&&JS9.helper.connected&&JS9.helper.js9helper&&(a.cubecol.value="",a.cubecol.disabled=!0,a.cubecol.style.backgroundColor="#E0E0E0");"a"===c.binMode?$('input:radio[class="avg-pixels"]').prop("checked",!0):$('input:radio[class="sum-pixels"]').prop("checked",!0)}else a.rebin.disabled=!0}function c(){var c,f=this;var e=" ";var h="Block",l="blocked",g="",k=this.div,
m=this.display,p=this.winHandle,n=p?"":'style="display:none;"',q=JS9.GetImage({display:this.display});if(!q||q&&!q.raw.hdu)k.innerHTML='<p style="padding: 5px"><center>FITS image sections, with binning and filtering</center>';else{"table"===q.imtab&&(h="Bin",l="binned",JS9.ishealpix(q)||(e=' <select name="selectcube" class="js9-binning-hdulist JS9Select">'));g='<form class="js9BinningForm js9Form">\n\t <table style="margin:0px; cellspacing:0; border-collapse:separate; border-spacing:4px 10px;">\n\t <tr>\t<td><input type=button class="js9-binning-full JS9Button2" value="Load full image" style="text-align:right;"></td>\n\t\t\t<td> </td>\n\t\t\t<td> </td>\n <td>'+
e+'</td>\n\t\t </tr>\n\t <tr>\t<td>Center:</td>\n\t\t\t<td><input type=text name=xcen size=10 style="text-align:right;"></td>\n\t\t\t<td><input type=text name=ycen size=10 style="text-align:right;"></td>\n\t\t\t<td> center position of section</td>\n\t\t </tr>\n\t <tr>\t<td>Size:</td>\n\t\t\t<td><input type=text name=xdim size=10 style="text-align:right;"></td>\n\t\t\t<td><input type=text name=ydim size=10 style="text-align:right;"></td>\n\t\t\t<td> width, height of section</td>\n\t\t </tr>\n <tr>\t<td>'+
h+':</td>\n\t\t\t<td><input type=text name=bin value=1 size=10 style="text-align:right;"></td>\n\t\t\t<td></td>\n\t\t\t<td> apply '+h.toLowerCase()+" factor to "+q.imtab+"</td>\n\t\t </tr>";g="image"===q.imtab||JS9.ishealpix(q)?g+('\n\t <tr>\t<td>Mode:</td>\n <td><input type=radio name=binmode value="s" class="sum-pixels" style="text-align:left;">sum</td>\n <td><input type=radio name=binmode value="a" class="avg-pixels" style="text-align:left;">average</td>\n\t\t\t<td> sum or avg '+
l+' pixels?</td>\n\t\t </tr>\n\t\t <tr>\t<td>Bitpix:</td>\n\t\t\t<td colspan="2"><textarea name=bitpix rows="1" cols="22" style="padding-left:5px; text-align:left;" autocapitalize="off" autocorrect="off"></textarea></td>\n\t\t\t<td> image bitpix</td>\n\t\t </tr>'):g+'\n\t <tr>\t<td>Mode:</td>\n <td><input type=checkbox name=xbinmode value="s" class="sum-pixels" style="text-align:left;" checked disabled>sum</td>\n\t\t\t<td></td>\n\t\t\t<td> binned tables are summed</td>\n\t\t </tr>\n\t\t <tr>\t<td>Bitpix:</td>\n\t\t\t<td colspan="2"><textarea name=bitpix rows="1" cols="22" style="padding-left:5px; text-align:left;" autocapitalize="off" autocorrect="off"></textarea></td>\n\t\t\t<td> bitpix when binning table</td>\n\t\t </tr>';
g+=' <tr>\t<td>Filter:</td>\n\t\t\t<td colspan="2"><textarea name=filter rows="1" cols="22" style="padding-left:5px; text-align:left;" autocapitalize="off" autocorrect="off"></textarea></td>\n\t\t\t<td> event/row filter when binning table</td>\n\t\t </tr>\n\n\t\t <tr>\t<td>BinCols:</td>\n\t\t\t<td colspan="2"><textarea name=columns rows="1" cols="22" style="padding-left:5px; text-align:left;" autocapitalize="off" autocorrect="off"></textarea></td>\n\t\t\t<td> alternate binning cols for table</td>\n\t\t </tr>\n\n\t <tr>\t<td>CubeCol:</td>\n\t\t\t<td colspan="2"><textarea name=cubecol class="js9-binning-cubecol" rows="1" cols="22" style="padding-left:5px; text-align:left;" autocapitalize="off" autocorrect="off"></textarea></td>\n\t\t\t<td> table→cube: col[:min:max][:binsiz]</td>\n\t\t </tr>\n\n\t <tr>\t<td>Separate:</td>\n <td><input type=checkbox name=separate class="js9-binning-sep" style="text-align:left;"></td>\n\t\t\t<td></td>\n\t\t\t<td> display as separate image?</td>\n\t\t </tr>\n\t\t <tr>\n\t\t\t<td> </td>\n\t\t\t<td> </td>\n\t\t\t<td> </td>\n <td>\n <input type=button name=close value="Cancel" class="js9-binning-close JS9Button2" '+
n+'\'>\n \n\t\t\t <input type=button name=rebin value="Get Data" class="js9-binning-rebin JS9RunButton">\n </td>\n\t\t </tr>\n\t </table>\n\t </form>';$(k).html(g);$(k).find(".js9-binning-full").on("click",function(){var b=JS9.GetImage({display:m}),c=$(k).find(".js9BinningForm")[0];b=b.fileDimensions();c.xcen.value=0;c.ycen.value=0;c.xdim.value=b.xdim;c.ydim.value=b.ydim;a(k,m)});$(k).find(".js9-binning-rebin").on("click",function(){a(k,
m)});$(k).find(".js9-binning-close").on("click",function(){p&&p.close()});$(k).find(".js9-binning-sep").change(function(){f.sep=$(this).prop("checked")});$(k).find(".js9-binning-sep").prop("checked",!!f.sep);$(k).find(".js9-binning-cubecol").on("input",function(){c=$(this).val()?!0:!!f.sep;$(k).find(".js9-binning-sep").prop("checked",c)});if("table"===q.imtab&&q.hdus&&q.hdus.length){for(e=0;e<q.hdus.length;e++)if("EVENTS"===q.hdus[e].name||"STDEVT"===q.hdus[e].name){var r=q.hdus[e].cols;break}if(r&&
r.length){var v=$(k).find(".js9-binning-hdulist");v.append('<option value="" disabled=disabled>List columns</option>');for(e=0;e<r.length;e++){var u=r[e].name+":"+r[e].type;JS9.notNull(r[e].min)&&JS9.notNull(r[e].max)&&(u+=":"+r[e].min+":"+r[e].max);v.append("<option>"+u+"</option>")}v.prop("selectedIndex",0);v.on("change",function(){u=$(this).val().replace(/:.*/,"");JS9.CopyToClipboard(u,q);v.prop("selectedIndex",0)})}}JS9.globalOpts.runOnCR&&$(k).find(".js9BinningForm").data("enterfunc","rebin");
b.call(null,k,m)}}JS9.RegisterPlugin("FITS","Binning",c,{menu:"view",winTitle:"Image Sections, with Binning and Filtering",winResize:!0,menuItem:"Bin/Filter/Section",onplugindisplay:c,onimageload:c,onimagedisplay:c,onsetpan:c,onsetzoom:c,help:"fitsy/binning.html",winDims:[570,375]})})();JS9.Blend={};JS9.Blend.CLASS="JS9";JS9.Blend.NAME="Blend";JS9.Blend.WIDTH=550;JS9.Blend.HEIGHT=270;JS9.Blend.BASE=JS9.Blend.CLASS+JS9.Blend.NAME;JS9.Blend.blendModeHTML='When <b>Image Blending</b> is turned on, the images you select below will be combined using your chosen blend mode and optional opacity. See <a href="https://www.w3.org/TR/compositing-1/" target="blank">W3C Compositing and Blending</a> for info about compositing and blending.<p> <input type="checkbox" class="blendModeCheck" id="active" name="imageBlending" value="active" onclick="javascript:JS9.Blend.xblendmode(\'%s\', this)"><b>Image Blending</b>';
JS9.Blend.imageHTML="<span style='float: left'>$active $blend $opacity</span> <span id='blendFile'>$imfile</span>";JS9.Blend.activeHTML='<input class="blendActiveCheck" type="checkbox" id="active" name="active" value="active" onclick="javascript:JS9.Blend.xactive(\'%s\', \'%s\', this)">blend using:';JS9.Blend.blendHTML='<select class="blendModeSelect JS9Select" onchange="JS9.Blend.xblend(\'%s\', \'%s\', this)"><option selected disabled>blend mode</option><option value="normal">normal</option><option value="screen">screen</option><option value="multiply">multiply</option><option value="overlay">overlay</option><option value="darken">darken</option><option value="lighten">lighten</option><option value="color-dodge">color-dodge</option><option value="color-burn">color-burn</option><option value="hard-light">hard-light</option><option value="soft-light">soft-light</option><option value="difference">difference</option><option value="exclusion">exclusion</option><option value="hue">hue</option><option value="saturation">saturation</option><option value="color">color</option> <option value="luminosity">luminosity</option><option selected disabled>composite mode</option><option value="source-atop">source-atop</option><option value="source-in">source-in</option><option value="source-out">source-out</option><option value="source-over">source-over</option><option value="destination-atop">destination-atop</option><option value="destination-in">destination-in</option><option value="destination-out">destination-out</option><option value="destination-over">destination-over</option></select>';
JS9.Blend.opacityHTML='<select class="blendOpacitySelect JS9Select" onchange="JS9.Blend.xopacity(\'%s\', \'%s\', this)"><option selected disabled>opacity</option><option value="1.00">opaque</option><option value="0.95">0.95</option><option value="0.90">0.90</option><option value="0.85">0.85</option><option value="0.80">0.80</option><option value="0.75">0.75</option><option value="0.70">0.70</option><option value="0.65">0.65</option><option value="0.60">0.60</option><option value="0.55">0.55</option><option value="0.50">0.50</option><option value="0.45">0.45</option><option value="0.40">0.40</option><option value="0.35">0.35</option><option value="0.30">0.30</option><option value="0.25">0.25</option><option value="0.20">0.20</option><option value="0.10">0.10</option><option value="0.00">transparent</option></select>';
JS9.Blend.imfileHTML="<b>%s</b>";JS9.Blend.nofileHTML='<p><span id="blendNoFile">[Images will appear here as they are loaded]</span>';JS9.Blend.xactive=function(a,b,c){a=JS9.lookupImage(b,a);b=c.checked;a&&(c=a.blendImage(),c.active!==b&&a.blendImage(b))};JS9.Blend.xblend=function(a,b,c){a=JS9.lookupImage(b,a);if(0<=c.selectedIndex)var d=c.options[c.selectedIndex].value;a&&JS9.notNull(d)&&(c=a.blendImage(),c.mode!==d&&a.blendImage(d))};
JS9.Blend.xopacity=function(a,b,c){a=JS9.lookupImage(b,a);if(0<=c.selectedIndex)var d=c.options[c.selectedIndex].value;a&&JS9.notNull(d)&&(c=a.blendImage(),d=parseFloat(d),c.opacity!==d&&a.blendImage(null,d))};JS9.Blend.xblendmode=function(a,b){a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a));b=b.checked;a&&JS9.BlendDisplay(b,{display:a})};JS9.Blend.imid=function(a){return(a.display.id+"_"+a.id).replace(/[^A-Za-z0-9_]/g,"_")+"BlendImage"};
JS9.Blend.dispclass=function(a){return(JS9.Blend.BASE+"_"+a.display.id).replace(/[^A-Za-z0-9_]/g,"_")};JS9.Blend.displayBlend=function(a){a&&(a=a.display,this.divjq.find(".blendModeCheck").prop("checked",a.blendMode))};
JS9.Blend.imageBlend=function(a,b){var c=a.blendImage();a=JS9.Blend.imid(a);if(c){a=this.divjq.find("#"+a);a.find(".blendActiveCheck").prop("checked",c.active);if(void 0!==c.mode){var d=a.find(".blendModeSelect").val(c.mode);b&&d.change()}void 0!==c.opacity&&(c="number"===typeof c.opacity?c.opacity.toFixed(2):c.opacity,d=a.find(".blendOpacitySelect").val(c),b&&d.change())}};
JS9.Blend.activeImage=function(a){if(a){var b=JS9.Blend.imid(a);a=JS9.Blend.dispclass(a)+"_Image";$("."+a).removeClass(JS9.Blend.BASE+"ImageActive").addClass(JS9.Blend.BASE+"ImageInactive");$("#"+b).removeClass(JS9.Blend.BASE+"ImageInactive").addClass(JS9.Blend.BASE+"ImageActive")}};
JS9.Blend.addImage=function(a){var b=this,c=[],d=JS9.Blend.BASE+"Image";if(a){var f=a.id;var e=a.display.id;var h=JS9.Blend.imid(a);var l=JS9.Blend.dispclass(a)+"_Image";c.push({name:"imid",value:f});c.push({name:"active",value:sprintf(JS9.Blend.activeHTML,e,f)});c.push({name:"opacity",value:sprintf(JS9.Blend.opacityHTML,e,f)});c.push({name:"blend",value:sprintf(JS9.Blend.blendHTML,e,f)});c.push({name:"imfile",value:sprintf(JS9.Blend.imfileHTML,f)});this.blendDivs||this.blendImageContainer.html("");
e=JS9.Image.prototype.expandMacro.call(a,JS9.Blend.imageHTML,c);$("<div>").addClass(d).addClass(l).attr("id",h).prop("imid",f).html(e).appendTo(this.blendImageContainer).on("mousedown touchstart",function(){a.displayImage();JS9.Blend.activeImage.call(b,a)});JS9.Blend.imageBlend.call(this,a,!1);JS9.Blend.displayBlend.call(this,a);this.blendDivs++;JS9.Blend.activeImage(a)}};
JS9.Blend.removeImage=function(a){return a?(a=JS9.Blend.imid(a),$("#"+a).remove(),this.blendDivs--,0===this.blendDivs&&this.blendImageContainer.html(JS9.Blend.nofileHTML),!0):!1};
JS9.Blend.init=function(a,b){var c=this;"div"===this.winType&&(this.width=this.divjq.attr("data-width"),this.width||(this.width=a||JS9.Blend.WIDTH),this.divjq.css("width",this.width),this.width=parseInt(this.divjq.css("width"),10),this.height=this.divjq.attr("data-height"),this.height||(this.height=b||JS9.Blend.HEIGHT),this.divjq.css("height",this.height),this.height=parseInt(this.divjq.css("height"),10));this.divjq.html("");this.blendDivs=0;this.divjq.addClass("JS9PluginScrolling");this.blendContainer=
$("<div>").addClass(JS9.Blend.BASE+"Container").attr("id",this.id+"BlendContainer").appendTo(this.divjq);this.blendHeader=$("<div>").addClass(JS9.Blend.BASE+"Header").attr("id",this.display.id+"Header").html(sprintf(JS9.Blend.blendModeHTML,this.display.id)).appendTo(this.blendContainer);this.blendImageContainer=$("<div>").addClass(JS9.Blend.BASE+"ImageContainer").attr("id",this.id+"BlendImageContainer").html(JS9.Blend.nofileHTML).appendTo(this.blendContainer);var d=JS9.getDynamicDisplayOr(this.display);
var f=d.blendMode;d.blendMode=!1;for(a=0;a<JS9.images.length;a++)b=JS9.images[a],b.display===d&&JS9.Blend.addImage.call(this,b);d.blendMode=f;d.image&&d.image.displayImage();this.divjq.find(".blendModeCheck").prop("checked",!!d.blendMode);this.blendImageContainer.sortable({start:function(a,b){c.oidx=b.item.index()},stop:function(a,b){a=b.item.index();c.display.moveImageInStack(c.oidx,a);c.display.image&&c.display.image.displayImage();delete c.oidx}})};
JS9.Blend.dysel=function(){var a=JS9.getDynamicDisplayOr("previous");if(a){var b=a.blendMode;a.blendMode=!1;a.image&&a.image.displayImage()}JS9.Blend.init.call(this);a&&(a.blendMode=b)};JS9.Blend.displayblend=function(a){a&&JS9.Blend.displayBlend.call(this,a)};JS9.Blend.imageblend=function(a){a&&JS9.Blend.imageBlend.call(this,a,!1)};JS9.Blend.imageload=function(a){var b=JS9.getDynamicDisplayOr(this.display);a&&a.display===b&&JS9.Blend.addImage.call(this,a)};
JS9.Blend.imagedisplay=function(a){JS9.Blend.activeImage.call(this,a)};JS9.Blend.imageclose=function(a){JS9.Blend.removeImage.call(this,a)};JS9.Blend.sessionload=function(a){a&&JS9.Blend.init.call(this)};
JS9.RegisterPlugin(JS9.Blend.CLASS,JS9.Blend.NAME,JS9.Blend.init,{menuItem:"Blending",dynamicSelect:!0,onplugindisplay:JS9.Blend.init,ondynamicselect:JS9.Blend.dysel,ondisplayblend:JS9.Blend.displayblend,onimageblend:JS9.Blend.imageblend,onimageload:JS9.Blend.imageload,onimagedisplay:JS9.Blend.imagedisplay,onimageclose:JS9.Blend.imageclose,onsessionload:JS9.Blend.sessionload,help:"help/blend.html",winTitle:"Image Blending",winResize:!0,winDims:[JS9.Blend.WIDTH,JS9.Blend.HEIGHT]});JS9.Blink={};
JS9.Blink.CLASS="JS9";JS9.Blink.NAME="Blink";JS9.Blink.WIDTH=512;JS9.Blink.HEIGHT=270;JS9.Blink.BASE=JS9.Blink.CLASS+JS9.Blink.NAME;JS9.Blink.rate=1E3;JS9.Blink.blinkModeHTML="When <b>Blink Images</b> is turned on, selected images will be displayed at the specified blink rate. You also can blink the selected images manually. The blink sequence can be changed by moving images around in the stack. <p>$mode $rate $manual";JS9.Blink.modeHTML='<input type="checkbox" id="active" name="blinkImages" value="active" onclick="javascript:JS9.Blink.xblinkmode(\'%s\', this)"><b>Blink Images</b>';
JS9.Blink.rateHTML='<select class="JS9Select" id="blinkRateSelect" onfocus="this.selectedIndex=0;" onchange="JS9.Blink.xrate(\'%s\',this)"><option selected disabled>blink rate</option><option value="0.1">0.1</option><option value="0.25">0.25</option><option value="0.5">0.5</option><option value="1.0">1.0</option><option value="2.0">2.0</option><option value="3.0">3.0</option><option value="4.0">4.0</option><option value="5.0">5.0</option><option value="6.0">6.0</option><option value="7.0">7.0</option><option value="8.0">8.0</option><option value="9.0">9.0</option><option value="10.0">10.0</option><option value="15.0">15.0</option><option value="20.0">20.0</option><option value="30.0">30.0</option></select>';
JS9.Blink.manualHTML='<input type="button" class="JS9Button2" id="manual" name="manualBlink" value="blink manually" onclick="javascript:JS9.Blink.xblink1(\'%s\', this)">';JS9.Blink.imageHTML="<span style='float: left'>$active </span><span id='blinkFile'>$imfile</span>";JS9.Blink.activeHTML='<input class="blinkActiveCheck" type="checkbox" id="active" name="active" value="active" onclick="javascript:JS9.Blink.xactive(\'%s\', \'%s\', this)">blink';JS9.Blink.imfileHTML="<b>%s</b>";
JS9.Blink.nofileHTML='<p><span id="blinkNoFile">[Images will appear here as they are loaded]</span>';JS9.Blink.start=function(a){var b,c=!1,d=a.pluginInstances.JS9Blink;if(d){for(b=d.idx;!c;){var f=JS9.images[d.idx];f.display===a&&f.tmp.blinkMode&&(f.displayImage("display"),c=!0);++d.idx>=JS9.images.length&&(d.idx=0);d.idx===b&&(c=!0)}a.blinkMode&&(a.pluginInstances.JS9Blink.tid=window.setTimeout(function(){JS9.Blink.start(a)},d.rate))}};
JS9.Blink.stop=function(a){var b=a.pluginInstances.JS9Blink;b&&(b.tid&&(window.clearTimeout(b.tid),delete b.tid),a.blinkMode=!1,b.idx=0)};JS9.Blink.xactive=function(a,b,c){a=JS9.lookupImage(b,a);c=c.checked;a&&(a.tmp.blinkMode=c)};JS9.Blink.xblinkmode=function(a,b){a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a));b=b.checked;a&&($(".blinkActive").prop("disabled",!b),b?(a.blinkMode=!0,JS9.Blink.start(a)):JS9.Blink.stop(a))};
JS9.Blink.xblink1=function(a,b){(b=(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a)))?a.pluginInstances.JS9Blink:null)&&a&&(JS9.images[b.idx]===a.image&&++b.idx>=JS9.images.length&&(b.idx=0),JS9.Blink.start(a))};JS9.Blink.xrate=function(a,b){var c=(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a)))?a.pluginInstances.JS9Blink:null;b=Math.floor(1E3*b.options[b.selectedIndex].value);c&&a&&!Number.isNaN(b)&&(c.rate=b)};
JS9.Blink.imid=function(a){return(a.display.id+"_"+a.id).replace(/[^A-Za-z0-9_]/g,"_")+"BlinkImage"};JS9.Blink.dispclass=function(a){return(JS9.Blink.BASE+"_"+a.display.id).replace(/[^A-Za-z0-9_]/g,"_")};JS9.Blink.activeImage=function(a){if(a){var b=JS9.Blink.imid(a);a=JS9.Blink.dispclass(a)+"_Image";$("."+a).removeClass(JS9.Blink.BASE+"ImageActive").addClass(JS9.Blink.BASE+"ImageInactive");$("#"+b).removeClass(JS9.Blink.BASE+"ImageInactive").addClass(JS9.Blink.BASE+"ImageActive")}};
JS9.Blink.addImage=function(a){var b=this,c=[],d=JS9.Blink.BASE+"Image";if(a){var f=a.id;var e=a.display.id;var h=JS9.Blink.imid(a);var l=JS9.Blink.dispclass(a)+"_Image";c.push({name:"imid",value:a.id});c.push({name:"active",value:sprintf(JS9.Blink.activeHTML,e,f)});c.push({name:"imfile",value:sprintf(JS9.Blink.imfileHTML,f)});this.blinkDivs||this.blinkImageContainer.html("");e=a.expandMacro(JS9.Blink.imageHTML,c);$("<div>").addClass(d).addClass(l).attr("id",h).prop("imid",f).html(e).appendTo(this.blinkImageContainer).on("mousedown touchstart",
function(){a.displayImage();JS9.Blink.activeImage.call(b,a)});this.blinkDivs++;a.tmp.blinkMode=!1;JS9.Blink.activeImage(a)}};JS9.Blink.removeImage=function(a){if(a){var b=JS9.Blink.imid(a);$("#"+b).remove();this.blinkDivs--;0===this.blinkDivs&&this.blinkImageContainer.html(JS9.Blink.nofileHTML);delete a.tmp.blinkMode;return!0}return!1};
JS9.Blink.init=function(){var a=this;var b=[];void 0===this.idx&&(this.idx=0);void 0===this.rate&&(this.rate=JS9.Blink.rate);this.divjq.html("");this.blinkDivs=0;this.divjq.addClass("JS9PluginScrolling");this.blinkContainer=$("<div>").addClass(JS9.Blink.BASE+"Container").attr("id",this.id+"BlinkContainer").css("overflow","auto").appendTo(this.divjq);var c=this.display.id;b.push({name:"mode",value:sprintf(JS9.Blink.modeHTML,c)});b.push({name:"manual",value:sprintf(JS9.Blink.manualHTML,c)});b.push({name:"rate",
value:sprintf(JS9.Blink.rateHTML,c)});b=JS9.Image.prototype.expandMacro.call(null,JS9.Blink.blinkModeHTML,b);this.blinkHeader=$("<div>").addClass(JS9.Blink.BASE+"Header").attr("id",c+"Header").html(b).appendTo(this.blinkContainer);this.blinkImageContainer=$("<div>").addClass(JS9.Blink.BASE+"ImageContainer").attr("id",this.id+"BlinkImageContainer").html(JS9.Blink.nofileHTML).appendTo(this.blinkContainer);var d=JS9.getDynamicDisplayOr(this.display);d.blinkMode=!1;for(c=0;c<JS9.images.length;c++)b=JS9.images[c],
b.display===d&&JS9.Blink.addImage.call(this,b);this.blinkImageContainer.sortable({start:function(b,c){a.oidx=c.item.index()},stop:function(b,c){b=c.item.index();a.display.moveImageInStack(a.oidx,b);a.display.image&&a.display.image.displayImage();delete a.oidx}})};JS9.Blink.dysel=function(){var a=JS9.getDynamicDisplayOr("previous");a&&JS9.Blink.stop(a);JS9.Blink.init.call(this)};
JS9.Blink.imageload=function(a){var b=JS9.getDynamicDisplayOr(this.display);a&&a.display===b&&JS9.Blink.addImage.call(this,a)};JS9.Blink.imagedisplay=function(a){JS9.Blink.activeImage.call(this,a)};JS9.Blink.imageclose=function(a){JS9.Blink.removeImage.call(this,a)};
JS9.RegisterPlugin(JS9.Blink.CLASS,JS9.Blink.NAME,JS9.Blink.init,{menuItem:"Blinking",dynamicSelect:!0,onplugindisplay:JS9.Blink.init,ondynamicselect:JS9.Blink.dysel,onimageload:JS9.Blink.imageload,onimagedisplay:JS9.Blink.imagedisplay,onimageclose:JS9.Blink.imageclose,help:"help/blink.html",winTitle:"Image Blinking",winResize:!0,winDims:[JS9.Blink.WIDTH,JS9.Blink.HEIGHT]});JS9.Cmaps={};JS9.Cmaps.CLASS="JS9";JS9.Cmaps.NAME="Cmaps";JS9.Cmaps.WIDTH=600;JS9.Cmaps.HEIGHT=270;
JS9.Cmaps.BASE=JS9.Cmaps.CLASS+JS9.Cmaps.NAME;JS9.Cmaps.DEFMODE="equidistant";JS9.Cmaps.DEFNMAP=3;JS9.Cmaps.DEFASSIGN=!0;JS9.Cmaps.DEFNAME="cmap";JS9.Cmaps.DEFTOL=Math.pow(8,2);JS9.Cmaps.DEFTIMEOUT=0;JS9.Cmaps.COLORCLASS="cmapsColorPicker";JS9.Cmaps.CMAPCLASS="cmapsSelect";JS9.Cmaps.CHECKCLASS="cmapsActiveCheck";
JS9.Cmaps.headerHTML='Select a color <input type="color" value="#FF0000" class="'+JS9.Cmaps.COLORCLASS+'"> or a <select class="'+JS9.Cmaps.CMAPCLASS+' JS9Select" onchange="JS9.Cmaps.xCmap(\'%s\',this)"></select> colormap to create <input type="number" onchange="JS9.Cmaps.xNslice(\'%s\',this)" value="'+JS9.Cmaps.DEFNMAP+'" min="1" max="36" size="3" style="width:40px;box-sizing: border-box;"> <select class="cmapsMode JS9Select" onchange="JS9.Cmaps.xMode(\'%s\',this)"> <option value="equidistant">equidistant</option><option value="analogous">analogous</option></select><p>slices of the <a href="https://en.wikipedia.org/wiki/Color_wheel" target="_blank">colorwheel</a>, the first <input type="number" onchange="JS9.Cmaps.xNmap(\'%s\',this)" value="'+
JS9.Cmaps.DEFNMAP+'" min="1" max="36" size="3" style="width:40px;box-sizing: border-box;"> of which will be used to create colormaps.<p><input type="checkbox" onchange="JS9.Cmaps.xAssignCmaps(\'%s\',this)" checked> assign the new colormaps to these images:';JS9.Cmaps.imageHTML="<span style='float: left'>$active</span> <span style='float: right'>$imfile</span>";JS9.Cmaps.activeHTML='<input class="'+JS9.Cmaps.CHECKCLASS+'" type="checkbox" id="active" name="active" value="active" onclick="javascript:JS9.Cmaps.xActive(\'%s\', \'%s\', this)"> ';
JS9.Cmaps.imfileHTML="<b>%s</b>";JS9.Cmaps.nofileHTML='<div class="JS9cmapsNoFile">[Colormap generation options will appear here after an image is loaded]</div>';JS9.Cmaps.equidistant=function(a,b,c){a=tinycolor(a).toHsl();var d=a.h,f=360/c,e=[];for(c=0;c<b;c++)a.h=(d+c*f)%360,e.push(tinycolor(a));return e};JS9.Cmaps.mkColors=function(a,b,c,d){if(b&&c&&d)switch(a||"equidistant"){case "analogous":return tinycolor(b).analogous(c,d);case "equidistant":return JS9.Cmaps.equidistant(tinycolor(b),c,d);default:return[tinycolor(b)]}};
JS9.Cmaps.assignCmaps=function(a){var b=0,c="."+JS9.Cmaps.BASE+"Image",d="."+JS9.Cmaps.CHECKCLASS;if(a.cmaps.names&&a.cmaps.names.length){var f=a.cmaps.that.cmapsImageContainer;if(f.length){var e=a.cmaps.names.length;f.find(c).each(function(c,f){c=$(f);f=c.prop("imid");f=JS9.lookupImage(f);c=c.find(d);f&&b<e&&c.prop("checked")&&(f.setColormap(a.cmaps.names[b++]),f.displayImage())})}}};
JS9.Cmaps.mkCmapsFromCmap=function(a,b,c,d,f){var e;var h=[];var l=[],g=[],k=function(a){return[a.r/255,a.g/255,a.b/255]};if(b&&c&&d){f=f||{};var m=f.mode||JS9.Cmaps.DEFMODE;var p=b.name;a.cmaps.names=[];switch(b.type){case "lut":for(e=0;e<c;e++)a.cmaps.names[e]=p+"_"+String(e+1),h[e]=[];for(e=0;e<b.colors.length;e++){p=sprintf("rgb (%s,%s,%s)",Math.floor(255*b.colors[e][0]+.5),Math.floor(255*b.colors[e][1]+.5),Math.floor(255*b.colors[e][2]+.5));var n=JS9.Cmaps.mkColors(m,p,c,d);for(p=0;p<c;p++)h[p].push(k(n[p].toRgb()))}for(e=
0;e<c;e++)(b=JS9.lookupColormap(a.cmaps.names[e],!1))?b.colors=h[e]:JS9.AddColormap(a.cmaps.names[e],h[e],{toplevel:!1});f.assign&&JS9.Cmaps.assignCmaps(a);break;case "sao":for(e=0;e<c;e++)a.cmaps.names[e]=b.name+"_"+String(e+1),l[e]=[[],[],[]];for(e=0;3>e;e++)for(p=0;p<b.vertices[e].length;p++)h=b.vertices[e][p][0],n=JS9.Colormap.prototype.mkColorCell.call(b,h*JS9.COLORSIZE),g.push({index:h,rgb:n});g.sort(function(a,b){return a.index>b.index?1:a.index<b.index?-1:0});for(e=g.length-2;0<=e;e--)g[e].index===
g[e+1].index&&g.splice(e+1,1);for(e=0;e<g.length;e++)for(p=sprintf("rgb (%s,%s,%s)",g[e].rgb[0],g[e].rgb[1],g[e].rgb[2]),n=JS9.Cmaps.mkColors(m,p,c,d),p=0;p<c;p++)b=k(n[p].toRgb()),l[p][0].push([g[e].index,b[0]]),l[p][1].push([g[e].index,b[1]]),l[p][2].push([g[e].index,b[2]]);for(e=0;e<c;e++)(b=JS9.lookupColormap(a.cmaps.names[e],!1))?b.vertices=l[e]:JS9.AddColormap(a.cmaps.names[e],l[e][0],l[e][1],l[e][2],{toplevel:!1});f.assign&&JS9.Cmaps.assignCmaps(a)}}};
JS9.Cmaps.mkCmapsFromColor=function(a,b,c,d,f){if(b&&c&&d){f=f||{};var e=f.mode||"equidistant";var h=a.id||JS9.Cmaps.DEFNAME;var l=void 0!==f.rgbtol?f.rgbtol:a.cmaps.tol;var g=tinycolor(b);var k=g.toRgb();if(Math.pow(Math.abs(k.r-a.cmaps.orgb.r),2)+Math.pow(Math.abs(k.g-a.cmaps.orgb.g),2)+Math.pow(Math.abs(k.b-a.cmaps.orgb.b),2)<l||a.cmaps.timeOutID)return 0;a.cmaps.timeOutID=window.setTimeout(function(){var b,l;a.cmaps.names=[];var n=JS9.Cmaps.mkColors(e,g,c,d);a.cmaps.orgb.r=k.r;a.cmaps.orgb.g=
k.g;a.cmaps.orgb.b=k.b;for(b=0;b<c;b++)if(k=n[b].toRgb(),a.cmaps.names[b]=h+"_"+String(b+1),l=JS9.lookupColormap(a.cmaps.names[b],!1))switch(l.type){case "lut":l.type="sao";l.vertices=[[[0,0],[1,k.r/255]],[[0,0],[1,k.g/255]],[[0,0],[1,k.b/255]]];break;case "sao":l.vertices=[[[0,0],[1,k.r/255]],[[0,0],[1,k.g/255]],[[0,0],[1,k.b/255]]]}else JS9.AddColormap(a.cmaps.names[b],[[0,0],[1,k.r/255]],[[0,0],[1,k.g/255]],[[0,0],[1,k.b/255]],{toplevel:!1});f.assign&&JS9.Cmaps.assignCmaps(a);a.cmaps.timeOutID=
null},JS9.Cmaps.DEFTIMEOUT)}};JS9.Cmaps.mkCmaps=function(a,b,c,d,f){var e;if(!b||!c||!d)return 0;(e=JS9.lookupColormap(b,!1))?JS9.Cmaps.mkCmapsFromCmap(a,e,c,d,f):JS9.Cmaps.mkCmapsFromColor(a,b,c,d,f)};JS9.Cmaps.xActive=function(a){(a=JS9.lookupDisplay(a))&&a.cmaps.assign&&JS9.Cmaps.assignCmaps(a)};
JS9.Cmaps.xMode=function(a,b){if(a=JS9.lookupDisplay(a))a.cmaps.mode=b.options[b.selectedIndex].value,JS9.Cmaps.mkCmaps(a,a.cmaps.lastCname,a.cmaps.nmap,a.cmaps.nslice,{mode:a.cmaps.mode,assign:a.cmaps.assign,rgbtol:0})};JS9.Cmaps.xNmap=function(a,b){if(a=JS9.lookupDisplay(a))a.cmaps.nmap=parseInt(b.value,10)||1,JS9.Cmaps.mkCmaps(a,a.cmaps.lastCname,a.cmaps.nmap,a.cmaps.nslice,{mode:a.cmaps.mode,assign:a.cmaps.assign,rgbtol:0})};
JS9.Cmaps.xNslice=function(a,b){if(a=JS9.lookupDisplay(a))a.cmaps.nslice=parseInt(b.value,10)||1,JS9.Cmaps.mkCmaps(a,a.cmaps.lastCname,a.cmaps.nmap,a.cmaps.nslice,{mode:a.cmaps.mode,assign:a.cmaps.assign,rgbtol:0})};JS9.Cmaps.xCmap=function(a,b){a=JS9.lookupDisplay(a);b=b.options[b.selectedIndex].value;a&&(JS9.Cmaps.mkCmaps(a,b,a.cmaps.nmap,a.cmaps.nslice,{mode:a.cmaps.mode,assign:a.cmaps.assign,rgbtol:0}),a.cmaps.lastCname=b)};
JS9.Cmaps.xAssignCmaps=function(a,b){if(a=JS9.lookupDisplay(a))a.cmaps.assign=$(b).prop("checked"),a.cmaps.assign&&JS9.Cmaps.assignCmaps(a)};JS9.Cmaps.imid=function(a){return(a.display.id+"_"+a.id).replace(/[^A-Za-z0-9_]/g,"_")+"CmapsImage"};JS9.Cmaps.dispclass=function(){return(JS9.Cmaps.BASE+"_"+this.display.id).replace(/[^A-Za-z0-9_]/g,"_")};
JS9.Cmaps.activeImage=function(a){if(a){a=JS9.Cmaps.imid.call(this,a);var b=JS9.Cmaps.dispclass.call(this)+"_Image";$("."+b).removeClass(JS9.Cmaps.BASE+"ImageActive").addClass(JS9.Cmaps.BASE+"ImageInactive");$("#"+a).removeClass(JS9.Cmaps.BASE+"ImageInactive").addClass(JS9.Cmaps.BASE+"ImageActive")}};
JS9.Cmaps.addImage=function(a){var b=this;var c=[];var d=JS9.Cmaps.BASE+"Image";if(a){var f=a.id;var e=this.display.id;var h=JS9.Cmaps.imid.call(this,a);var l=JS9.Cmaps.dispclass.call(this)+"_Image";c.push({name:"imid",value:f});c.push({name:"active",value:sprintf(JS9.Cmaps.activeHTML,e,f)});c.push({name:"imfile",value:sprintf(JS9.Cmaps.imfileHTML,f)});c=JS9.Image.prototype.expandMacro.call(a,JS9.Cmaps.imageHTML,c);$("<div>").addClass(d).addClass(l).addClass(JS9.Cmaps.BASE+"ImageInactive").prop("id",
h).prop("imid",f).html(c).appendTo(this.cmapsImageContainer).on("mousedown touchstart",function(){e===a.display.id&&(a.displayImage(),JS9.Cmaps.activeImage.call(b,a))});this.display.id===a.display.id&&JS9.Cmaps.activeImage.call(this,a)}};JS9.Cmaps.removeImage=function(a){return a?(a=JS9.Cmaps.imid.call(this,a),$("#"+a).remove(),!0):!1};
JS9.Cmaps.init=function(a,b){var c=this;var d="."+JS9.Cmaps.COLORCLASS;var f="."+JS9.Cmaps.CMAPCLASS,e=this.display;this.divjq.addClass("JS9PluginScrolling");"div"===this.winType&&(this.width=this.divjq.attr("data-width"),this.width||(this.width=a||JS9.Cmaps.WIDTH),this.divjq.css("width",this.width),this.width=parseInt(this.divjq.css("width"),10),this.height=this.divjq.attr("data-height"),this.height||(this.height=b||JS9.Cmaps.HEIGHT),this.divjq.css("height",this.height),this.height=parseInt(this.divjq.css("height"),
10));if(JS9.colormaps&&JS9.colormaps.length){e.cmaps||(e.cmaps={},e.cmaps.mode=JS9.Cmaps.DEFMODE,e.cmaps.nmap=JS9.Cmaps.DEFNMAP,e.cmaps.nslice=JS9.Cmaps.DEFNMAP,e.cmaps.assign=JS9.Cmaps.DEFASSIGN,e.cmaps.tol=JS9.Cmaps.DEFTOL,e.cmaps.lastCname=null,e.cmaps.names=[],e.cmaps.ims=[],e.cmaps.orgb={r:0,g:0,b:0},e.cmaps.that=this);this.divjq.html("");this.cmapsContainer=$("<div>").addClass(JS9.Cmaps.BASE+"Container").attr("id",this.id+"CMapsContainer").appendTo(this.divjq);a=this.display.id;a=sprintf(JS9.Cmaps.headerHTML,
a,a,a,a,a);this.cmapsHeader=$("<div>").addClass(JS9.Cmaps.BASE+"Header").attr("display",this.display.id).attr("id",this.display.id+"CMapsHeader").html(a).appendTo(this.cmapsContainer);this.cmapsImageContainer=$("<div>").addClass(JS9.Cmaps.BASE+"ImageContainer").attr("id",this.id+"CmapsImageContainer").appendTo(this.cmapsContainer);for(a=0;a<JS9.images.length;a++)JS9.Cmaps.addImage.call(this,JS9.images[a]);this.cmapsImageContainer.sortable({start:function(a,b){c.oidx=b.item.index()},stop:function(a,
b){a=b.item.index();c.display.moveImageInStack(c.oidx,a);c.display.image&&c.display.image.displayImage();delete c.oidx}});d=this.cmapsContainer.find(d);this.cmapsContainer.find(f).each(function(){var a;for(a=0;a<JS9.colormaps.length;a++){var b=JS9.colormaps[a].name;$(f).append($("<option>",{value:b,text:b}))}});e.cmaps.inited||(JS9.globalOpts.internalColorPicker&&$.fn.spectrum.inputTypeColorSupport()||(d.spectrum({showButtons:!1,showInput:!0,preferredFormat:"hex6"}),d.on("move.spectrum",function(a,
b){a=b.toHex();JS9.Cmaps.mkCmaps(e,a,e.cmaps.nmap,e.cmaps.nslice,{mode:e.cmaps.mode,assign:e.cmaps.assign});e.cmaps.lastCname=a}),d.on("change",function(a){a=tinycolor($(a.currentTarget).val()).toHex();JS9.Cmaps.mkCmaps(e,a,e.cmaps.nmap,e.cmaps.nslice,{mode:e.cmaps.mode,assign:e.cmaps.assign});e.cmaps.lastCname=a})),d.on("input",function(a){var b=a.target.value;$(a.target).parent().attr("display")===e.id&&(JS9.Cmaps.mkCmaps(e,b,e.cmaps.nmap,e.cmaps.nslice,{mode:e.cmaps.mode,assign:e.cmaps.assign}),
e.cmaps.lastCname=b)}),e.cmaps.inited=!0)}else this.divjq.html(JS9.Cmaps.nofileHTML)};JS9.Cmaps.imageload=function(a){var b;this.display.cmaps?JS9.Cmaps.addImage.call(this,a):JS9.Cmaps.init.call(this);for(b=0;b<JS9.displays.length;b++){var c=JS9.displays[b];c.image&&c.id!==a.display.id&&(c=c.pluginInstances.JS9Cmaps)&&c.isActive("onimageload")&&JS9.Cmaps.addImage.call(c,a)}};JS9.Cmaps.imagedisplay=function(a){JS9.Cmaps.activeImage.call(this,a)};
JS9.Cmaps.imageclose=function(a){var b;JS9.Cmaps.removeImage.call(this,a);for(b=0;b<JS9.displays.length;b++){var c=JS9.displays[b];c.image&&c.id!==a.display.id&&(c=c.pluginInstances.JS9Cmaps)&&c.isActive("onimageclose")&&JS9.Cmaps.removeImage.call(c,a)}};
JS9.RegisterPlugin(JS9.Cmaps.CLASS,JS9.Cmaps.NAME,JS9.Cmaps.init,{menuItem:"Colormaps",help:"help/cmaps.html",onimageload:JS9.Cmaps.imageload,onimagedisplay:JS9.Cmaps.imagedisplay,onimageclose:JS9.Cmaps.imageclose,winTitle:"Create Colormaps",winResize:!0,winDims:[JS9.Cmaps.WIDTH,JS9.Cmaps.HEIGHT]});JS9.Colorbar={};JS9.Colorbar.CLASS="JS9";JS9.Colorbar.NAME="Colorbar";JS9.Colorbar.WIDTH=512;JS9.Colorbar.HEIGHT=40;JS9.Colorbar.BASE=JS9.Colorbar.CLASS+JS9.Colorbar.NAME;JS9.Colorbar.SCALED=!1;
JS9.Colorbar.TICKS=10;JS9.Colorbar.COLORBARHEIGHT=16;JS9.Colorbar.MAXLABELSIZE=10;JS9.Colorbar.STATICSIZE=4;JS9.Colorbar.STATICPADDING=3;JS9.Colorbar.INFINITY=10;
JS9.Colorbar.display=function(a){var b=this,c,d,f,e;var h=[];var l=this.colorbarWidth;var g=this.colorbarHeight,k=this.ctx.getImageData(0,0,l,g),m=k.data,p=4*l,n=new Uint8Array(m.buffer,0,p),q=function(a,c,d,g){b.textctx.textAlign="center";b.textctx.beginPath();b.textctx.moveTo(a,c);b.textctx.lineWidth=1;b.textctx.lineTo(a,c+5);b.textctx.stroke();g&&b.textctx.fillText(d,a,c+15)};if(a.staticObj){for(c=e=f=0;c<a.staticObj.colors.length;c++){var r=a.staticObj.colors[c];r.min<f&&(f=-Infinity===r.max?
f-JS9.Colorbar.INFINITY:r.min);r.max>e&&(e=Infinity===r.max?e+JS9.Colorbar.INFINITY:r.max)}var v=(e-f)/l;for(d=c=0;c<l;c++,d+=4)r=Math.floor(c*v),r=JS9.lookupStaticColor(a,r),m[d]=r.red,m[d+1]=r.green,m[d+2]=r.blue,m[d+3]=r.alpha}else{var u=this.scaled?a.psColors:a.colorCells;if(!u||a.useOffScreenCanvas()){JS9.Colorbar.imageclear.call(this,a);return}v=u.length/l;for(d=c=0;c<l;c++,d+=4)r=Math.floor(c*v),m[d]=u[r][0],m[d+1]=u[r][1],m[d+2]=u[r][2],m[d+3]=255}for(c=1;c<g;c++)m.set(n,c*p);this.ctx.putImageData(k,
0,0);if(this.showTicks)if(this.textctx.clear(),a.staticObj&&a.staticObj.colors.length<this.ticks)for(f=JS9.floatPrecision(f,e),h=-99999,c=0;c<a.staticObj.colors.length;c++)r=a.staticObj.colors[c],l=JS9.floatFormattedString(r.min,f,0),d=Math.ceil(r.min/v)+1,e=0,Math.abs(d-h)<=JS9.Colorbar.STATICPADDING||l.length>=JS9.Colorbar.STATICSIZE&&0===c%2?r=!1:(h=d,r=!0),q(d,e,l,r);else{v=a.psInverse.length/this.ticks;f=JS9.floatPrecision(Math.min(a.params.scalemin,a.psInverse[0]),Math.max(a.params.scalemax,
a.psInverse[a.psInverse.length-1]));for(d=0;5>d;d++){r=!0;for(c=0;c<this.ticks;c++)e=a.psInverse[Math.floor(c*v)],h[c]=JS9.floatFormattedString(e,f,d);for(c=1;c<this.ticks;c++)h[c-1]===h[c]&&(r=!1);if(r)break}for(c=1;c<this.ticks;c++)1<c&&h[c]===h[c-1]||(d=c/this.ticks*this.width,e=0,r=h[c].length>=JS9.Colorbar.MAXLABELSIZE&&0===c%2?!1:!0,q(d,e,h[c],r))}};
JS9.Colorbar.init=function(a,b){var c=JS9.PIXEL_RATIO||1;this.showTicks=this.divjq.attr("data-showTicks");this.showTicks=void 0===this.showTicks?!0:"true"===this.showTicks?!0:!1;this.width=this.divjq.attr("data-width");this.width||(this.width=a||JS9.Colorbar.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=this.showTicks?b||JS9.Colorbar.HEIGHT:b||JS9.Colorbar.COLORBARHEIGHT);this.divjq.css("height",
this.height);this.height=parseInt(this.divjq.css("height"),10);this.colorbarWidth=this.width;this.colorbarHeight=parseInt(this.divjq.attr("data-colorbarHeight"),10);this.colorbarHeight||(this.colorbarHeight=JS9.Colorbar.COLORBARHEIGHT);this.colorbarHeight=Math.min(this.height,this.colorbarHeight);this.scaled=this.divjq.attr("data-scaled");this.scaled=void 0===this.scaled?JS9.Colorbar.SCALED:"true"===this.scaled?!0:!1;this.ticks=this.divjq.attr("data-ticks");this.ticks||(this.ticks=JS9.Colorbar.TICKS);
this.divjq.html("");this.colorbarContainer=$("<div>").addClass(JS9.Colorbar.BASE+"Container").attr("id",this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);this.colorbarjq=$("<canvas>").addClass(JS9.Colorbar.BASE+"Canvas").attr("id",this.id+"Canvas").attr("width",this.width-1).attr("height",this.colorbarHeight).appendTo(this.colorbarContainer);this.ctx=this.colorbarjq[0].getContext("2d");this.showTicks&&(this.textjq=$("<canvas>").addClass(JS9.Colorbar.BASE+
"TextCanvas").attr("id",this.id+"TextCanvas").attr("width",this.width*c).attr("height",(this.height-this.colorbarHeight)*c).css("width",this.width+"px").css("height",this.height-this.colorbarHeight+"px").appendTo(this.colorbarContainer),this.textctx=this.textjq[0].getContext("2d"),(this.colorbarFont=this.divjq.attr("data-colorbarFont"))?this.textctx.font=this.colorbarFont:JS9.Colorbar.COLORBARFONT&&(this.textctx.font=JS9.Colorbar.COLORBARFONT),this.textctx.setTransform(c,0,0,c,0,0));this.display.image&&
JS9.Colorbar.display.call(this,this.display.image)};JS9.Colorbar.imagedisplay=function(a){a&&JS9.Colorbar.display.call(this,a)};JS9.Colorbar.imageclear=function(a){a&&a===a.display.image&&(this.ctx&&this.ctx.clear(),this.textctx&&this.textctx.clear())};JS9.Colorbar.dynamic=function(a){var b;a&&(b=a.display.pluginInstances.JS9Colorbar)&&b.isDynamic&&JS9.Colorbar.imagedisplay.call(this,a)};
JS9.RegisterPlugin(JS9.Colorbar.CLASS,JS9.Colorbar.NAME,JS9.Colorbar.init,{menuItem:"Colorbar",dynamicSelect:!0,ondynamicselect:JS9.Colorbar.dynamic,onimagedisplay:JS9.Colorbar.imagedisplay,onimageclear:JS9.Colorbar.imageclear,onimageclose:JS9.Colorbar.imageclear,help:"help/colorbar.html",winTitle:"Colorbar",winDims:[JS9.Colorbar.WIDTH,JS9.Colorbar.HEIGHT]});JS9.Color={};JS9.Color.CLASS="JS9";JS9.Color.NAME="Color";JS9.Color.WIDTH=512;JS9.Color.HEIGHT=140;JS9.Color.BASE=JS9.Color.CLASS+JS9.Color.NAME;
JS9.Color.RUNMENU=!0;JS9.Color.colorHTML="<p><div class='JS9ColorLinegroup'>$cmaps1 $cmaps2 $cmaps $filters</div>\n<p>\n<div class='JS9ColorLinegroup'>$conbibtn $contrast $bias</div>\n<p>\n<div class='JS9ColorLinegroup'>$run $opacity $from $opfloor $opopacity $opoverlay $opmask</div>";JS9.Color.cmaps1HTML="<select class=\"JS9Select JS9Cmaps1 JS9ColorSelect JS9ColorCol1\" name=\"cmaps1\" onchange=\"JS9.Color.xsetcolor('%s', '%s', 'top', this)\">%s</select>";
JS9.Color.cmaps2HTML="<select class=\"JS9Select JS9Cmaps2 JS9ColorSelect JS9ColorCol2\" name=\"cmaps2\" onchange=\"JS9.Color.xsetcolor('%s', '%s', 'other', this)\">%s</select>";JS9.Color.cmapsHTML='<input type="button" class="JS9Button2 JS9ColorCmaps JS9ColorButton JS9ColorCol3" name="cmaps" value="Create cmaps" onclick="javascript:JS9.DisplayPlugin(\'JS9Cmaps\', {\'display\': \'%s\'})">';JS9.Color.filtersHTML='<input type="button" class="JS9Button2 JS9ColorFilters JS9ColorButton JS9ColorCol4" name="filters" value="Image filters" onclick="javascript:JS9.DisplayPlugin(\'JS9Filters\', {\'display\': \'%s\'})">';
JS9.Color.conbibtnHTML='<input type="button" class="JS9Button2 JS9ColorConBiBtn JS9ColorButton JS9ColorCol1" name="conbibtn" value="Contrast/bias →" onclick="javascript:JS9.Color.xconbi(\'%s\', \'%s\', this)">';JS9.Color.contrastHTML='<input type="text" class="JS9ColorContrast JS9ColorInput JS9ColorCol2 js9Input" name="contrast" value="%s" autocapitalize="off" autocorrect="off" placeholder="contrast">';JS9.Color.biasHTML='<input type="text" class="JS9ColorBias JS9ColorInput JS9ColorCol3 js9Input" name="bias" value="%s" autocapitalize="off" autocorrect="off" placeholder="bias">';
JS9.Color.runHTML='<input type="button" class="JS9Button2 JS9ColorRun JS9ColorButton JS9ColorCol1" name="run" value="Opacity →" onclick="javascript:JS9.Color.xopacity(\'%s\', \'%s\', this)">';JS9.Color.opacityHTML='<input type="text" class="JS9ColorOpacity JS9ColorInput JS9ColorCol2 js9Input" name="opacity" value="" autocapitalize="off" autocorrect="off">';JS9.Color.fromHTML='<select class="JS9Select JS9ColorFrom JS9ColorSelect JS9ColorCol3" name="from" onchange="JS9.Color.xfrom(\'%s\', \'%s\', this)">%s</select>';
JS9.Color.opfloorHTML='<input type="text" class="JS9ColorOpFloor JS9ColorInput JS9ColorCol4 js9Input" name="opfloor" value="%s" autocapitalize="off" autocorrect="off">';JS9.Color.opopacityHTML="<select class=\"JS9Select JS9ColorOpOpacity JS9ColorSelect JS9ColorCol4\" name=\"opopacity\" onchange=\"JS9.Color.xsetfile('%s', '%s', 'opacity', this)\">%s</select>";JS9.Color.opoverlayHTML="<select class=\"JS9Select JS9ColorOpOverlay JS9ColorSelect JS9ColorCol4\" name=\"opoverlay\" onchange=\"JS9.Color.xsetfile('%s', '%s', 'overlay', this)\">%s</select>";
JS9.Color.opmaskHTML="<select class=\"JS9Select JS9ColorOpMask JS9ColorSelect JS9ColorCol4\" name=\"opmask\" onchange=\"JS9.Color.xsetfile('%s', '%s', 'mask', this)\">%s</select>";JS9.Color.fmt=function(a,b){a+=.5*Math.pow(10,-(b+1));return a.toFixed(b)};
JS9.Color.xsetcolor=function(a,b,c,d){if(a=JS9.lookupImage(b,a))switch("object"===typeof d&&a.setColormap(d.value),c){case "top":"string"===typeof d&&$(".JS9Cmaps1 option").filter(function(a,b){return $(b).text().trim()===d}).prop("selected",!0);$(".JS9Cmaps2").prop("selectedIndex",0);break;case "other":"string"===typeof d&&$(".JS9Cmaps2 option").filter(function(a,b){return $(b).text().trim()===d}).prop("selected",!0),$(".JS9Cmaps1").prop("selectedIndex",0)}};
JS9.Color.xconbi=function(a,b,c){if(a=JS9.lookupImage(b,a))b=$(c).parent(),c=b.find("[name='contrast']").val(),b=b.find("[name='bias']").val(),JS9.isNumber(c)&&JS9.isNumber(b)&&a.setColormap(parseFloat(c),parseFloat(b))};
JS9.Color.xopacity=function(a,b,c){c=$(c).parent();var d=c.find("[name='from']").val(),f=JS9.lookupImage(b,a);if(f){var e=f.display.pluginInstances.JS9Color;switch(d){case "floor":e.lastfrom.match(/mask|global/)?a=String(f.params.flooropacity):(a=c.find("[name='opacity']").val(),void 0===a&&(a=String(f.params.flooropacity)));c=c.find("[name='opfloor']").val();a.match(/resetall/)?f.setOpacity("resetall"):!a||a.match(/reset/)?f.setOpacity("resetfloor"):JS9.isNumber(a)&&JS9.isNumber(c)&&f.setOpacity(parseFloat(c),
parseFloat(a));break;case "opacity":case "overlay":case "mask":a=c.find("[name='op"+d+"']").val();"none"!==a&&(b={mode:d},"mask"===d&&(e.lastfrom.match(/floor|global/)?c=String(f.mask.vopacity||0):(c=c.find("[name='opacity']").val(),void 0===c&&(c=String(f.mask.vopacity||0))),a&&JS9.isNumber(c)&&(b.opacity=parseFloat(c))),f.maskImage(a,b));break;default:e.lastfrom.match(/floor|mask/)?a=String(f.getOpacity().opacity):(a=c.find("[name='opacity']").val(),void 0===a&&(a=String(f.getOpacity().opacity))),
a.match(/resetall/)?f.setOpacity("resetall"):!a||a.match(/reset/)?f.setOpacity("reset"):JS9.isNumber(a)&&f.setOpacity(parseFloat(a))}JS9.Color.refrom.call(e,f);JS9.Color.reopacity.call(e,f)}};JS9.Color.xfrom=function(a,b,c){var d=$(c).parent();c=c.value;if(b=JS9.lookupImage(b,a))a=b.display.pluginInstances.JS9Color,JS9.Color.refrom.call(a,b),JS9.Color.reopacity.call(a,b),a.runmenu&&d.find("[name='run']").click(),a.lastfrom=c};
JS9.Color.xsetfile=function(a,b,c,d){var f=$(d).parent();if(b=JS9.lookupImage(b,a))if("none"===d.value)b.maskImage(!1);else{a={mode:c};switch(c){case "mask":c=f.find("[name='opacity']").val(),JS9.isNumber(c)&&(a.opacity=parseFloat(c))}b.maskImage(d.value,a)}};JS9.Color.reconbi=function(){var a=this.colorContainer;if(this.display.image){var b=this.display.image.getColormap();a.find("[name='contrast']").val(JS9.Color.fmt(b.contrast,4));a.find("[name='bias']").val(JS9.Color.fmt(b.bias,4))}};
JS9.Color.refrom=function(a){var b=this.colorContainer;var c=b.find("[name='from']").val()||"global";if(a=a||this.display.image)switch(c){case "global":b.find(".JS9ColorOpacity").css("display","block").attr("placeholder","global opacity");b.find(".JS9ColorOpFloor").css("display","none");b.find(".JS9ColorOpOpacity").css("display","none");b.find(".JS9ColorOpOverlay").css("display","none");b.find(".JS9ColorOpMask").css("display","none");break;case "floor":b.find(".JS9ColorOpacity").css("display","block").attr("placeholder",
"floor opacity");b.find(".JS9ColorOpFloor").css("display","block").attr("placeholder","floor value");b.find(".JS9ColorOpOpacity").css("display","none");b.find(".JS9ColorOpOverlay").css("display","none");b.find(".JS9ColorOpMask").css("display","none");break;case "opacity":b.find(".JS9ColorOpacity").css("display","none");b.find(".JS9ColorOpFloor").css("display","none");b.find(".JS9ColorOpOpacity").css("display","block");b.find(".JS9ColorOpOverlay").css("display","none");b.find(".JS9ColorOpMask").css("display",
"none");break;case "overlay":b.find(".JS9ColorOpacity").css("display","none");b.find(".JS9ColorOpFloor").css("display","none");b.find(".JS9ColorOpOpacity").css("display","none");b.find(".JS9ColorOpOverlay").css("display","block");b.find(".JS9ColorOpMask").css("display","none");break;case "mask":b.find(".JS9ColorOpacity").css("display","block").attr("placeholder","non-mask opacity"),b.find(".JS9ColorOpFloor").css("display","none"),b.find(".JS9ColorOpOpacity").css("display","none"),b.find(".JS9ColorOpOverlay").css("display",
"none"),b.find(".JS9ColorOpMask").css("display","block")}};JS9.Color.reopacity=function(a){var b=this.colorContainer;var c=b.find("[name='from']").val()||"global";if(a=a||this.display.image){switch(c){case "floor":c=a.getOpacity();a=c.flooropacity;(c=c.floorvalue)&&(c=JS9.Color.fmt(c,4));b.find("[name='opfloor']").val(c);break;case "opacity":case "overlay":return;case "mask":a=a.mask.vopacity||0;break;default:a=a.getOpacity().opacity}"number"===typeof a&&(a=JS9.Color.fmt(a,4));b.find("[name='opacity']").val(a)}};
JS9.Color.display=function(){var a=this.display.image;if(a&&a===this.lastimage){var b=a.display.pluginInstances.JS9Color;JS9.Color.refrom.call(b,a);JS9.Color.reopacity.call(b,a)}else JS9.Color.init.call(this)};JS9.Color.close=function(){JS9.Color.init.call(this,{mode:"clear"})};
JS9.Color.init=function(a){var b;var c=function(){var a,b="<option selected disabled>Top cmaps</option>";for(a=0;a<JS9.globalOpts.topColormaps.length;a++){var c=JS9.globalOpts.topColormaps[a];b+="<option>"+c+"</option>"}return b};var d=function(){var a,b="<option selected disabled>Other cmaps</option>";for(a=0;a<JS9.colormaps.length;a++){var c=JS9.colormaps[a].name;JS9.globalOpts.topColormaps.includes(c)||(b+="<option>"+c+"</option>")}return b};var f=function(a){var b="",c="",d="",g="",h="";if(a&&
a.mask.active&&a.mask.im)switch(a.mask.mode){case "mask":c="selected";break;case "opacity":b="selected";break;case "overlay":d="selected"}else a&&void 0!==a.params.flooropacity?g="selected":h="selected";return'<option disabled>mode:</option>\n\t <option value="global" '+h+'>default</option>\n\t <option value="floor" '+g+'>floor ≤ →</option>\n\t <option value="mask" '+c+'>mask →</option>\n\t <option value="opacity" '+b+'>opacity →</option>\n\t <option value="overlay" '+
d+">overlay →</option>"};var e=function(a){var b="";a&&(b=a.params.floorvalue||"");return b},h=function(a,b){var c="<option selected disabled>"+b+' files</option>\n\t <option value="none" selected>none</option>';for(b=0;b<JS9.images.length;b++){var d=JS9.images[b];if(d!==a&&d.raw.width===a.raw.width&&d.raw.height===a.raw.height){var g=a.mask.active&&a.mask.im===d?"selected":"";c+='<option value="'+d.id+'" '+g+">"+d.id+"</option>"}}return c};a=a||{};this.width=this.divjq.attr("data-width");
this.width||(this.width=JS9.Color.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.Color.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.runmenu=this.divjq.attr("data-runmenu");void 0===this.runmenu&&(this.runmenu=JS9.Color.RUNMENU);this.lastfrom="";this.divjq.html("");this.colorContainer=$("<div>").addClass(JS9.Color.BASE+"Container").attr("id",
this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);if((b=this.display.image)&&"clear"!==a.mode){var l=b.id;var g=b.display.id;a=[];c=sprintf(JS9.Color.cmaps1HTML,g,l,c());a.push({name:"cmaps1",value:c});c=sprintf(JS9.Color.cmaps2HTML,g,l,d());a.push({name:"cmaps2",value:c});c=sprintf(JS9.Color.cmapsHTML,g);a.push({name:"cmaps",value:c});c=sprintf(JS9.Color.filtersHTML,g);a.push({name:"filters",value:c});c=sprintf(JS9.Color.conbibtnHTML,g,l);a.push({name:"conbibtn",
value:c});c=sprintf(JS9.Color.contrastHTML,b.getColormap().contrast);a.push({name:"contrast",value:c});c=sprintf(JS9.Color.biasHTML,b.getColormap().bias);a.push({name:"bias",value:c});c=sprintf(JS9.Color.runHTML,g,l);a.push({name:"run",value:c});c=sprintf(JS9.Color.opacityHTML);a.push({name:"opacity",value:c});c=sprintf(JS9.Color.fromHTML,g,l,f(b));a.push({name:"from",value:c});c=sprintf(JS9.Color.opfloorHTML,e(b));a.push({name:"opfloor",value:c});c=sprintf(JS9.Color.opopacityHTML,g,l,h(b,"opacity"));
a.push({name:"opopacity",value:c});c=sprintf(JS9.Color.opoverlayHTML,g,l,h(b,"overlay"));a.push({name:"opoverlay",value:c});c=sprintf(JS9.Color.opmaskHTML,g,l,h(b,"mask"));a.push({name:"opmask",value:c});d=b.expandMacro(JS9.Color.colorHTML,a);this.lastimage=b}else d="<p><center>Color parameters will appear here.</center>";this.colorContainer.html(d);b&&(JS9.globalOpts.runOnCR&&(this.colorContainer.find("[name='contrast']").data("enterfunc","conbibtn"),this.colorContainer.find("[name='bias']").data("enterfunc",
"conbibtn"),this.colorContainer.find("[name='opacity']").data("enterfunc","run"),this.colorContainer.find("[name='opfloor']").data("enterfunc","run")),JS9.Color.reopacity.call(this,b),JS9.Color.refrom.call(this,b),d=b.getColormap(),d=d.colormap,f=JS9.globalOpts.topColormaps.includes(d)?"top":"other",JS9.Color.xsetcolor(b.display.id,b.id,f,d))};
JS9.RegisterPlugin(JS9.Color.CLASS,JS9.Color.NAME,JS9.Color.init,{menu:"color",menuItem:"Color Controls ...",onplugindisplay:JS9.Color.init,onsetcolormap:JS9.Color.init,onchangecontrastbias:JS9.Color.reconbi,onsetopacity:JS9.Color.reopacity,onimagedisplay:JS9.Color.display,onimageclose:JS9.Color.close,help:"help/colorcontrols.html",winTitle:"Color Controls",winDims:[JS9.Color.WIDTH,JS9.Color.HEIGHT]});JS9.Console={};JS9.Console.CLASS="JS9";JS9.Console.NAME="Console";JS9.Console.WIDTH=512;
JS9.Console.HEIGHT=300;JS9.Console.HTML="<table class='JS9CmdTable'><tr class='JS9Tr'><td><div id='JS9CmdPrompt' class='JS9CmdPrompt'>@@PR@@</div></td><td class='JS9CmdTd'><input type='text' class='JS9CmdIn' autocapitalize='off' autocorrect='off' autocomplete='off' value='' /></td></tr></table>";
JS9.Console.init=function(a,b){this.display.conMode=2;this.hist=[];this.histtemp=this.histpos=0;this.consoleConjq=$("<div>").addClass("JS9ConsoleContainer").appendTo(this.divjq);"light"!==this.winType&&(this.width=this.divjq.attr("data-width"),this.width||(this.width=a||JS9.CONWIDTH),this.divjq.css("width",this.width),this.width=parseInt(this.divjq.css("width"),10),this.height=this.divjq.attr("data-height"),this.height||(this.height=b||JS9.CONHEIGHT),this.divjq.css("height",this.height),this.height=
parseInt(this.divjq.css("height"),10),this.consoleConjq.css("width",this.width).css("height",this.height));this.consoleConjq.attr("tabindex","0");this.consoleConjq.on("keydown",this,function(a){return JS9.Console.keyDownCB(a)});JS9.Console.out.call(this,"Type 'help' for a list of commands","info");JS9.Console.inp.call(this)};
JS9.Console.inp=function(){this.consoleConjq.find(".JS9CmdIn:last").attr("readonly","readonly");this.consoleConjq.append(JS9.Console.HTML.replace(/@@PR@@/g,"js9>"));var a=this.consoleConjq.find(".JS9CmdIn:last");a.focus().attr("autocapitalize","off").attr("autocorrect","off").attr("autocomplete","off");JS9.jupyterFocus(a.parent());return this};
JS9.Console.out=function(a,b){switch(b.toLowerCase()){case "error":a="ERROR: "+a;b="Error";break;case "info":b="Info";break;case "out":b="Out";break;default:b="Out"}$("<div>").addClass("JS9Cmd"+b).html(a).appendTo(this.consoleConjq);return this};
JS9.Console.xeq=function(){var a,b,c=this.consoleConjq.find(".JS9CmdIn:last").val(),d=c.trim().split(/\s+/),f=[];if(!d[0])return this;var e=d[0];for(a=1;a<d.length;a++)d[a].match(/^"\s*"$/)||d[a].match(/^'\s*'$/)?f.push(""):f.push(d[a]);this.hist.length&&c===this.hist[this.hist.length-1]||this.hist.push(c);this.histpos=this.hist.length;try{if(b=JS9.lookupCommand(e))switch(b.getDisplayInfo(this.display),b.getWhich(f)){case "get":var h=b.get(f)||"";JS9.Console.out.call(this,h,"ok");break;case "set":(h=
b.set(f))&&JS9.Console.out.call(this,h,"ok");break;default:JS9.error("unknown cmd type for '"+e+"'")}else if(JS9.publics[e]){f.push({display:this.display});h=JS9.publics[e].apply(JS9.publics,$jscomp.arrayFromIterable(f))||"";if("object"===typeof h)if(h instanceof JS9.Display||h instanceof JS9.Image)h="";else try{h=JSON.stringify(h)}catch(l){h=""}"string"===typeof h&&"OK"!==h&&(h.match(/^ERROR:/)?JS9.error(h):JS9.Console.out.call(this,h,"ok"))}else h="unknown command '"+e+"'",0<f.length&&(h=h+" "+
f),JS9.error(h)}catch(l){JS9.Console.out.call(this,l.message,"error")}return this};
JS9.Console.keyDownCB=function(a){var b=a.data,c=a.which||a.keyCode;if(!JS9.specialKey(a)){a=b.consoleConjq.find(".JS9CmdIn:last");a.focus();if(b.hist.length&&(38===c||40===c)){b.hist[b.histpos]?b.hist[b.histpos]=a.val():b.histtemp=a.val();switch(c){case 38:b.histpos--;0>b.histpos&&(b.histpos=0);break;case 40:b.histpos++;b.histpos>b.hist.length&&(b.histpos=b.hist.length);break;default:JS9.error("internal keycode switch mixup")}b.hist[b.histpos]?a.val(b.hist[b.histpos]):a.val(b.histtemp)}13===c&&(JS9.globalOpts.alerts=
!1,JS9.Console.xeq.call(b),JS9.globalOpts.alerts=!0,JS9.Console.inp.call(b))}};JS9.RegisterPlugin("JS9","Console",JS9.Console.init,{menuItem:"Console",help:"help/console.html",winTitle:"Console",winResize:!0,winDims:[JS9.Console.WIDTH,JS9.Console.HEIGHT]});JS9.Cube={};JS9.Cube.CLASS="JS9";JS9.Cube.NAME="Cube";JS9.Cube.WIDTH=512;JS9.Cube.HEIGHT=240;JS9.Cube.BASE=JS9.Cube.CLASS+JS9.Cube.NAME;JS9.Cube.cubeHTML="<div class='JS9CubeLinegroup'>$header</div><p><div class='JS9CubeLinegroup'><span class='JS9CubeSpan' style='float: left'>$range $value $value2 $extname</span><span class='JS9CubeSpan' style='float: right'>$order</span></div><div class='JS9CubeLinegroup'><span class='JS9CubeSpan' style='float: left'>$first $next $prev $last</span><span class='JS9CubeSpan' style='float: right'>$blink $stop $rate</span></div><p><div class='JS9CubeLinegroup'>$header2</div><p><div class='JS9CubeLinegroup'><span class='JS9CubeSpan' style='float: left'>$load</span></div>";
JS9.Cube.headerHTML="Use the slider, text box, navigation or blink buttons to display a slice of a <b>FITS data cube</b>. Use the menu at the right to specify the slice axis.";JS9.Cube.rangeHTML='<span class="JS9CubeRangeLine">1<input type="range" min="%s" max="%s" value="%s" class="JS9CubeRange" onchange="JS9.Cube.xrange(\'%s\', \'%s\', this)">%s</span>';JS9.Cube.valueHTML='<input type="text" class="JS9CubeValue" min="%s" max="%s" value="%s" onchange="JS9.Cube.xvalue(\'%s\', \'%s\', this)" size="4">';
JS9.Cube.value2HTML='<input type="text" class="JS9CubeValue2" min="%s" max="%s" value="%s" onchange="JS9.Cube.xvalue2(\'%s\', \'%s\', this)" size="8">';JS9.Cube.firstHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="First" onclick="JS9.Cube.xfirst(\'%s\', \'%s\', this)">';JS9.Cube.nextHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="Next" onclick="JS9.Cube.xnext(\'%s\', \'%s\', this)">';JS9.Cube.prevHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="Prev" onclick="JS9.Cube.xprev(\'%s\',\'%s\', this)">';
JS9.Cube.lastHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="Last" onclick="JS9.Cube.xlast(\'%s\', \'%s\', this)">';JS9.Cube.blinkHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="Blink" onclick="JS9.Cube.xstart(\'%s\', \'%s\', this)">';JS9.Cube.stopHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="Stop" onclick="JS9.Cube.xstop(\'%s\', \'%s\', this)">';JS9.Cube.extnameHTML='<span class="JS9CubeRangeLine">%s</span>';JS9.Cube.orderHTML='<select class="JS9CubeOrder JS9Select" onchange="JS9.Cube.xorder(\'%s\', \'%s\', this)"><option value="$slice:*:*">$slice : * : *</option><option value="*:$slice:*">* : $slice : *</option><option value="*:*:$slice">* : * : $slice</option></select>';
JS9.Cube.rateHTML='<select class="JS9CubeRate JS9Select" onchange="JS9.Cube.xrate(\'%s\', \'%s\', this)"><option selected disabled>Rate</option><option value=".1">0.1 sec</option><option value=".25">0.25 sec</option><option value=".5">0.5 sec</option><option value="1" default>1 sec</option><option value="2">2 sec</option><option value="5">5 sec</option></select>';JS9.Cube.header2HTML="Or load each slice separately into JS9:";JS9.Cube.loadHTML='<input type="button" class="JS9CubeBtn JS9Button2" value="Load All" onclick="JS9.Cube.loadall(\'%s\',\'%s\', this)">';
JS9.Cube.pix2wcs=function(a){return(a-this.smin)*this.cdelt+this.crval};JS9.Cube.wcs2pix=function(a){return Math.floor((a-this.crval)/this.cdelt+this.smin)};
JS9.Cube.doSlice=function(a,b,c){var d,f=a.display.pluginInstances[JS9.Cube.BASE];if(!a.parentFile||!f.inProcess){var e=JS9.Cube.pix2wcs.call(f,b);for(d=0;d<c.length;d++){var h=c[d];switch(h.charAt(h.length-1)){case "2":f.divjq.find(c[d]).val(e);break;default:f.divjq.find(c[d]).val(b)}}h=a.expandMacro(f.slice,[{name:"slice",value:b}]);f.sval=b;f.inProcess=!0;a.displaySlice(h,{},function(){f.inProcess=!1})}};
JS9.Cube.xrange=function(a,b,c){if(a=JS9.lookupImage(b,a))c=parseInt(c.value,10),JS9.Cube.doSlice(a,c,[".JS9CubeValue",".JS9CubeValue2"])};JS9.Cube.xvalue=function(a,b,c){if(a=JS9.lookupImage(b,a))c=parseInt(c.value,10),JS9.Cube.doSlice(a,c,[".JS9CubeValue2",".JS9CubeRange"])};JS9.Cube.xvalue2=function(a,b,c){if(a=JS9.lookupImage(b,a))b=a.display.pluginInstances[JS9.Cube.BASE],c=JS9.Cube.wcs2pix.call(b,parseInt(c.value,10)),JS9.Cube.doSlice(a,c,[".JS9CubeValue",".JS9CubeRange"])};
JS9.Cube.xfirst=function(a,b,c){(a=JS9.lookupImage(b,a))&&JS9.Cube.doSlice(a,1,[".JS9CubeValue",".JS9CubeValue2",".JS9CubeRange"])};JS9.Cube.xnext=function(a,b,c){if(c=JS9.lookupImage(b,a)){b=c.raw.header;var d=c.display.pluginInstances[JS9.Cube.BASE];a=d.sval+1;d="NAXIS"+d.sidx;a>b[d]&&(a=1);JS9.Cube.doSlice(c,a,[".JS9CubeValue",".JS9CubeValue2",".JS9CubeRange"])}};
JS9.Cube.xprev=function(a,b,c){if(b=JS9.lookupImage(b,a)){a=b.raw.header;var d=b.display.pluginInstances[JS9.Cube.BASE];c=d.sval-1;1>c&&(c="NAXIS"+d.sidx,c=a[c]);JS9.Cube.doSlice(b,c,[".JS9CubeValue",".JS9CubeValue2",".JS9CubeRange"])}};JS9.Cube.xlast=function(a,b,c){if(a=JS9.lookupImage(b,a))b=a.raw.header,c=a.display.pluginInstances[JS9.Cube.BASE],c="NAXIS"+c.sidx,b=b[c],JS9.Cube.doSlice(a,b,[".JS9CubeValue",".JS9CubeValue2",".JS9CubeRange"])};
JS9.Cube.xorder=function(a,b,c){var d=JS9.lookupImage(b,a);if(d){b=d.raw.header;a=d.display.pluginInstances[JS9.Cube.BASE];a.slice=c.value;var f=a.slice.split(/[ ,:]/);for(c=0;c<f.length;c++)"*"!==f[c]&&(a.sidx=c+1,a.sval=1,a.smin=1,a.smax=b["NAXIS"+a.sidx]);$(".JS9CubeRange").prop("max",a.smax);JS9.Cube.doSlice(d,a.sval,[".JS9CubeValue",".JS9CubeValue2",".JS9CubeRange"])}};
JS9.Cube.blink=function(a,b,c,d){var f=JS9.lookupImage(b,a);if(f){d=d||0;var e=f.display.pluginInstances[JS9.Cube.BASE];!1===e.blinkMode?delete e.blinkMode:(JS9.Cube.xnext(a,b,c),JS9.isNull(e.blinkMode)&&(e.blinkMode=!0),JS9.Cube.tid=window.setTimeout(function(){d&&"error"===f.status.displaySection?delete e.blinkMode:JS9.Cube.blink(a,b,c,++d)},e.rate))}};JS9.Cube.xstart=function(a,b,c){var d;if(d=JS9.lookupImage(b,a))d=d.display.pluginInstances[JS9.Cube.BASE],d.blinkMode||JS9.Cube.blink(a,b,c)};
JS9.Cube.xstop=function(a,b,c){if(a=JS9.lookupImage(b,a))a=a.display.pluginInstances[JS9.Cube.BASE],a.inProcess=!1,a.blinkMode&&(a.tid&&(window.clearTimeout(a.tid),delete a.tid),a.blinkMode=!1)};JS9.Cube.xrate=function(a,b,c){if(a=JS9.lookupImage(b,a))a=a.display.pluginInstances[JS9.Cube.BASE],a.rate=Math.floor(1E3*parseFloat(c.value))};JS9.Cube.loadall=function(a,b,c){(a=JS9.lookupImage(b,a))&&a.displaySlice("all")};JS9.Cube.display=function(){this.lastimage!==this.display.image&&JS9.Cube.init.call(this)};
JS9.Cube.close=function(){JS9.Cube.init.call(this,{mode:"clear"})};
JS9.Cube.init=function(a){var b,c;a=a||{};this.width=this.divjq.attr("data-width");this.width||(this.width=JS9.Cube.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.Cube.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.cubeWidth=this.width;this.cubeHeight=parseInt(this.divjq.attr("data-cubeHeight"),10);this.cubeHeight||(this.cubeHeight=
JS9.Cube.CUBEHEIGHT);if((c=this.display.image)&&"clear"!==a.mode){var d=c.raw.header;a=c.id;var f=c.display.id;if(b=c.raw.hdu.slice){this.slice=b.replace(/[0-9][0-9]*/,"$slice");var e=b.split(/[ ,:]/);for(b=0;b<e.length;b++)"*"!==e[b]&&(this.sidx=b+1,this.smin=1,this.smax=d["NAXIS"+this.sidx],this.sval=parseInt(e[b],10))}else this.slice="*:*:$slice",this.smin=1,this.smax=d.NAXIS3,this.sidx=3,this.sval=1;JS9.notNull(d["CRPIX"+this.sidx])&&JS9.notNull(d["CRVAL"+this.sidx])&&JS9.notNull(d["CDELT"+this.sidx])?
(this.crpix=parseFloat(d["CRPIX"+this.sidx]),this.crval=parseFloat(d["CRVAL"+this.sidx]),this.cdelt=parseFloat(d["CDELT"+this.sidx])):(delete this.crpix,delete this.crval,delete this.cdelt);this.rate||(this.rate=1E3);JS9.notNull(this.tid)&&(window.clearTimeout(this.tid),delete this.tid);JS9.notNull(this.blinkMode)&&delete this.blinkMode;2<d.NAXIS?(b=[],b.push({name:"header",value:JS9.Cube.headerHTML}),b.push({name:"range",value:sprintf(JS9.Cube.rangeHTML,this.smin,this.smax,this.sval,f,a,this.smax)}),
b.push({name:"value",value:sprintf(JS9.Cube.valueHTML,this.smin,this.smax,this.sval,f,a)}),b.push({name:"value2",value:sprintf(JS9.Cube.value2HTML,JS9.Cube.pix2wcs.call(this,this.smin),JS9.Cube.pix2wcs.call(this,this.smax),JS9.Cube.pix2wcs.call(this,this.sval),f,a)}),b.push({name:"first",value:sprintf(JS9.Cube.firstHTML,f,a)}),b.push({name:"next",value:sprintf(JS9.Cube.nextHTML,f,a)}),b.push({name:"prev",value:sprintf(JS9.Cube.prevHTML,f,a)}),b.push({name:"last",value:sprintf(JS9.Cube.lastHTML,f,
a)}),b.push({name:"blink",value:sprintf(JS9.Cube.blinkHTML,f,a)}),b.push({name:"stop",value:sprintf(JS9.Cube.stopHTML,f,a)}),b.push({name:"order",value:sprintf(JS9.Cube.orderHTML,f,a)}),b.push({name:"rate",value:sprintf(JS9.Cube.rateHTML,f,a)}),b.push({name:"extname",value:sprintf(JS9.Cube.extnameHTML,d.EXTNAME||"")}),b.push({name:"header2",value:JS9.Cube.header2HTML}),b.push({name:"load",value:sprintf(JS9.Cube.loadHTML,f,a)}),a=c.expandMacro(JS9.Cube.cubeHTML,b)):a="<p><center>This image is not a FITS data cube.</center>";
this.lastimage=c}else a="<p><center>FITS cube processing will appear here.</center>";this.divjq.html("");this.cubeContainer=$("<div>").addClass(JS9.Cube.BASE+"Container").attr("id",this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);this.cubeContainer.html(a);this.divjq.find(".JS9CubeRange").prop("max",this.smax);this.divjq.find(".JS9CubeValue").prop("max",this.smax);this.divjq.find(".JS9CubeOrder").val(this.slice);this.crpix?$(".JS9CubeValue2").show():$(".JS9CubeValue2").hide()};
JS9.RegisterPlugin(JS9.Cube.CLASS,JS9.Cube.NAME,JS9.Cube.init,{menuItem:"Data Cube",onplugindisplay:JS9.Cube.init,onimageload:JS9.Cube.init,onimagedisplay:JS9.Cube.display,onimageclose:JS9.Cube.close,help:"help/cube.html",winTitle:"FITS Data Cubes",winDims:[JS9.Cube.WIDTH,JS9.Cube.HEIGHT]});JS9.Divs={};JS9.Divs.CLASS="JS9";JS9.Divs.NAME="Divs";JS9.Divs.WIDTH=400;JS9.Divs.HEIGHT=146;JS9.Divs.BASE=JS9.Divs.CLASS+JS9.Divs.NAME;JS9.Divs.headerHTML="JS9 plugin divs can be hidden or made visible below.";
JS9.Divs.divHTML="<span style='float: left'>$visible </span> <span class='JS9DivsSpan'>$div  </span>";JS9.Divs.nodivsHTML='<p><span class="JS9NoDivs">[No JS9 divs have been created for this display]</span>';JS9.Divs.visibleHTML='<input class="JS9DivsVisibleCheck" type="checkbox" id="visible" name="visible" value="visible" onclick="javascript:JS9.Divs.xvisible(\'%s\', \'%s\', this)">visible';JS9.Divs.divNameHTML="<b>%s</b>";
JS9.Divs.xvisible=function(a,b,c){if(a=JS9.lookupDisplay(a))if(b=a.pluginInstances[b])c=c.checked?"visible":"hidden",b.divjq.closest(".JS9PluginContainer").css("visibility",c)};
JS9.Divs.addDiv=function(a){var b=JS9.Divs.BASE+"Div";var c=[];a&&this.display.pluginInstances[a]&&(this.ndiv||this.divsDivContainer.html(""),c.push({name:"visible",value:sprintf(JS9.Divs.visibleHTML,this.display.id,a)}),c.push({name:"div",value:sprintf(JS9.Divs.divNameHTML,a)}),c=JS9.Image.prototype.expandMacro.call(null,JS9.Divs.divHTML,c),$("<div>").addClass(b).html(c).appendTo(this.divsDivContainer).find(".JS9DivsVisibleCheck").prop("checked","visible"===this.display.pluginInstances[a].divjq.css("visibility")),
this.ndiv++)};
JS9.Divs.init=function(a){var b;a=a||{};this.divjq.html("");this.ndiv=0;this.divjq.addClass("JS9PluginScrolling");this.divsContainer=$("<div>").addClass(JS9.Divs.BASE+"Container").attr("id",this.id+"DivsContainer").css("overflow","auto").appendTo(this.divjq);this.divsHeader=$("<div>").addClass(JS9.Divs.BASE+"Header").attr("id",this.display.id+"Header").html(JS9.Divs.headerHTML).appendTo(this.divsContainer);this.divsDivContainer=$("<div>").addClass(JS9.Divs.BASE+"DivContainer").attr("id",this.id+"DivsDivContainer").html(JS9.Divs.nodivsHTML).appendTo(this.divsContainer);
if("clear"!==a.mode){a=this.display.pluginInstances||{};var c=$jscomp.makeIterator(Object.keys(a));for(b=c.next();!b.done;b=c.next())b=b.value,"div"===a[b].winType&&JS9.Divs.addDiv.call(this,b)}};JS9.RegisterPlugin(JS9.Divs.CLASS,JS9.Divs.NAME,JS9.Divs.init,{menuItem:"Show/Hide Plugins",onplugindisplay:JS9.Divs.init,help:"help/divs.html",winTitle:"Show/Hide Plugins",winResize:!0,winDims:[JS9.Divs.WIDTH,JS9.Divs.HEIGHT]});JS9.Filters={};JS9.Filters.CLASS="JS9";JS9.Filters.NAME="Filters";
JS9.Filters.WIDTH=325;JS9.Filters.HEIGHT=520;JS9.Filters.BASE=JS9.Filters.CLASS+JS9.Filters.NAME;JS9.Filters.noargfilters={edge:{def:null},invert:{def:null},luminance:{def:null},median:{def:null},sobel:{def:null}};
JS9.Filters.argfilters={blur:{min:0,max:100,step:1,init:0,def:30},brighten:{min:1,max:100,step:1,init:0,def:10},darken:{min:0,max:1,step:.01,init:0,def:.66},duotone:{min:0,max:2,step:1,init:0,def:2},emboss:{min:0,max:100,step:1,init:0,def:100},gamma:{min:0,max:2,step:.01,init:0,def:.2},lighten:{min:1,max:2,step:.01,init:0,def:1.33},noise:{min:0,max:100,step:1,init:0,def:30},pixelate:{min:0,max:20,step:1,init:0,def:2},scatter:{min:0,max:10,step:1,init:0,def:5},sepia:{min:0,max:100,step:1,init:0,def:100},
sharpen:{min:0,max:100,step:1,init:0,def:20},solarize:{min:0,max:100,step:1,init:0,def:50}};JS9.Filters.headerHTML='\n<center>\n<div class="JS9FiltersLineheader">\n<span class="JS9FiltersHeader">\nImage Filters:<br>\nclick for default settings or use the sliders\n</span>\n</center>\n</div>\n';JS9.Filters.noargfilterHTML='\n<span class="JS9FiltersName JS9FiltersCol1">\n<input type="button" name="%sbutton" value="%s" class="JS9Button2 JS9FiltersButton" onclick="JS9.Filters.xfilter(this, \'%s\', \'%s\', \'%s\', %s)"></span>\n';
JS9.Filters.argfilterHTML='\n<span class="JS9FiltersName JS9FiltersCol1">\n<input type="button" name="%sbutton" value="%s" class="JS9Button2 JS9FiltersButton" onclick="JS9.Filters.xfilter(this, \'%s\', \'%s\', \'%s\', %s)"></span>\n<span class="JS9FiltersRange JS9FiltersCol2"><input type="range" min="%s" max="%s" step="%s" value="%s" name="%s" class="JS9FiltersRange" onchange="JS9.Filters.xgenfilter(\'%s\', \'%s\', \'%s\', this)"></span>\n<span class="JS9FiltersRangeVal">\n<input type="text" name="%sval" class="JS9FiltersValue JS9FiltersCol3" min="0" max="100" value="0" onchange="JS9.Filters.xgenval(\'%s\', \'%s\', \'%s\', this)"></span>\n';
JS9.Filters.undoHTML='\n<span class="JS9FiltersUndo JS9FiltersCol1">\n<input type="button" id="undo" name="undo" value="undo" class="JS9FiltersUndoButton JS9Button2" onclick="JS9.Filters.xundo(this, \'%s\', \'%s\')"></span>\n';JS9.Filters.resetHTML='\n<span class="JS9FiltersReset JS9FiltersCol3">\n<input type="button" id="reset" name="reset" value="reset" class="JS9FiltersResetButton JS9Button2" onclick="JS9.Filters.xreset(this, \'%s\', \'%s\')"></span>\n';
JS9.Filters.updateval=function(a,b,c){a&&0<$(a).length&&(b?($(a).closest("."+JS9.Filters.BASE+"Container").find("[name='"+b+"']").prop("value",c),$(a).closest("."+JS9.Filters.BASE+"Container").find("[name='"+b+"val']").prop("value",c),$(a).closest("."+JS9.Filters.BASE+"Container").find("[name='undo']").prop("value","undo "+b).css("width","100px")):$(a).closest("."+JS9.Filters.BASE+"Container").find("[name='undo']").prop("value","undo").css("width","70px"))};
JS9.Filters.xfilter=function(a,b,c,d,f){var e=f,h=JS9.lookupImage(c,b);if(h){b=h.display.pluginInstances[JS9.Filters.BASE];b.stack=b.stack||[];b.stack.length&&b.stack[b.stack.length-1].filter===d?(h.rgb.img.data.set(b.stack[b.stack.length-1].data),b.stack[b.stack.length-1].val=f):(c=new Uint8ClampedArray(h.rgb.img.data),b.stack.push({filter:d,val:f,data:c}));if(JS9.notNull(f)){switch(d){case "duotone":f=0===f?"r":1===f?"g":"b";break;case "darken":f=1-f}h.filterRGBImage(d,f)}else h.filterRGBImage(d);
JS9.Filters.updateval(a,d,e)}};JS9.Filters.xundo=function(a,b,c){var d;if(d=JS9.lookupImage(c,b))if(b=d.display.pluginInstances[JS9.Filters.BASE],b.stack&&b.stack.length&&(c=b.stack.pop(),d.rgb.img.data.set(c.data),d.displayImage("display"),JS9.Filters.updateval(a,c.filter,0)),b.stack&&b.stack.length)for(c=0;c<b.stack.length;c++){d=b.stack[c].filter;var f=b.stack[c].val;JS9.Filters.updateval(a,d,f)}else JS9.Filters.updateval(a,null,null)};
JS9.Filters.xreset=function(a,b,c){(a=JS9.lookupImage(c,b))&&a.filterRGBImage("reset")};JS9.Filters.xgenfilter=function(a,b,c,d){if(JS9.lookupImage(b,a)){var f=parseFloat(d.value);JS9.Filters.xfilter(d,a,b,c,f);$(d).closest("."+JS9.Filters.BASE+"Container").find("[name='"+c+"val']").prop("value",f)}};
JS9.Filters.xgenval=function(a,b,c,d){if(JS9.lookupImage(b,a)){var f=parseFloat(d.value);JS9.Filters.xfilter(d,a,b,c,f);$(d).closest("."+JS9.Filters.BASE+"Container").find("[name='"+c+"']").prop("value",f)}};JS9.Filters.reinit=function(){var a=this.display.pluginInstances[JS9.Filters.BASE];!this.inProcess&&a.stack&&a.stack.length&&(this.inProcess=!0,delete a.stack,JS9.Filters.init.call(this),this.inProcess=!1)};
JS9.Filters.display=function(){if(this.lastimage!==this.display.image){var a=this.display.pluginInstances[JS9.Filters.BASE];this.inProcess=!0;delete a.stack;JS9.Filters.init.call(this);this.inProcess=!1}};JS9.Filters.close=function(){JS9.Filters.init.call(this,{mode:"clear"})};
JS9.Filters.init=function(a){var b,c;a=a||{};this.width=this.divjq.attr("data-width");this.width||(this.width=JS9.Filters.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.Filters.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.divjq.html("");var d=JS9.Filters.headerHTML;delete this.stack;this.filtersContainer=$("<div>").addClass(JS9.Filters.BASE+
"Container").attr("id",this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);if((c=this.display.image)&&"clear"!==a.mode){var f=c.id;var e=c.display.id;a=[];d+="<div class='JS9FiltersLinegroup'> </div>";var h=$jscomp.makeIterator(Object.keys(JS9.Filters.argfilters));for(b=h.next();!b.done;b=h.next()){b=b.value;var l=JS9.Filters.argfilters[b];a.push({name:b,value:sprintf(JS9.Filters.argfilterHTML,b,b,e,f,b,l.def,l.min,l.max,l.step,l.init,b,e,f,b,b,e,f,b)});
d+="<div class='JS9FiltersLinegroup'>$"+b+"</div>"}h=$jscomp.makeIterator(Object.keys(JS9.Filters.noargfilters));for(b=h.next();!b.done;b=h.next())b=b.value,a.push({name:b,value:sprintf(JS9.Filters.noargfilterHTML,b,b,e,f,b,null,b,e,f,b,b,e,f,b)}),d+="<div class='JS9FiltersLinegroup'>$"+b+"</div>";d+="<div class='JS9FiltersLinegroup'> </div><div class='JS9FiltersLinegroup'>$undo $reset</div>";b=sprintf(JS9.Filters.undoHTML,e,f);a.push({name:"undo",value:b});b=sprintf(JS9.Filters.resetHTML,e,
f);a.push({name:"reset",value:b});d=c.expandMacro(d,a);this.lastimage=c}else d="<p><center>Image filters will appear here.</center>";this.filtersContainer.html(d)};
JS9.RegisterPlugin(JS9.Filters.CLASS,JS9.Filters.NAME,JS9.Filters.init,{menuItem:"Image Filters",onplugindisplay:JS9.Filters.init,onchangecontrastbias:JS9.Filters.reinit,onsetpan:JS9.Filters.reinit,onsetcolormap:JS9.Filters.reinit,onimagedisplay:JS9.Filters.display,onimageclose:JS9.Filters.close,help:"help/filters.html",winTitle:"Image Filters",winDims:[JS9.Filters.WIDTH,JS9.Filters.HEIGHT]});JS9.Imarith={};JS9.Imarith.CLASS="JS9";JS9.Imarith.NAME="Imarith";JS9.Imarith.WIDTH=512;
JS9.Imarith.HEIGHT=170;JS9.Imarith.BASE=JS9.Imarith.CLASS+JS9.Imarith.NAME;JS9.Imarith.imageHTML="<div class='JS9ImarithLinegroup'>Choose an op (add, subtract, multiply, divide, min, max) and an operand (number or image) and click Run. Reset will revert to the original data.</div><div class='JS9ImarithLinegroup'><span class='JS9ImarithSpan' style='float: left'><b>$imid</b> $op $arg1 $num</span></div><p><div class='JS9ImarithLinegroup'><span style='float: right'>$cancel $reset $run</span></div>";
JS9.Imarith.opHTML='<select class=JS9ImarithOp" onchange="JS9.Imarith.xop(\'%s\', \'%s\', this)"><option value="" selected disabled>op</option><option value="add">add</option><option value="sub">sub</option><option value="mul">mul</option><option value="div">div</option><option value="min">min</option><option value="max">max</option></select>';JS9.Imarith.arg1HTML='<select class="JS9Select JS9ImarithArg1" onchange="JS9.Imarith.xarg1(\'%s\', \'%s\', this)"><option val="" selected disabled>operand</option><option value="num">number →</option>%s</select>';
JS9.Imarith.numHTML='<input type="text" class="JS9ImarithNum" value="" onchange="JS9.Imarith.xnum(\'%s\', \'%s\', this)" size="10" placeholder="number">';JS9.Imarith.cancelHTML='<input type="button" class="JS9Button2 JS9ImarithBtn" value="Cancel" onclick="JS9.Imarith.xcancel(\'%s\', \'%s\', this)">';JS9.Imarith.resetHTML='<input type="button" class="JS9Button2 JS9ImarithBtn" value="Reset" onclick="JS9.Imarith.xreset(\'%s\', \'%s\', this)">';JS9.Imarith.runHTML='<input type="button" class="JS9RunButton JS9ImarithBtn" value="Run" onclick="JS9.Imarith.xrun(\'%s\', \'%s\', this)">';
JS9.Imarith.xop=function(a,b,c){c=c.options[c.selectedIndex].value;(a=JS9.lookupImage(b,a))&&c&&(a.display.pluginInstances.JS9Imarith.op=c)};JS9.Imarith.xarg1=function(a,b,c){a=JS9.lookupImage(b,a);c=c.options[c.selectedIndex].value;a&&c&&(a.display.pluginInstances.JS9Imarith.arg1=c,"num"===c?$(".JS9ImarithNum").css("visibility","visible"):$(".JS9ImarithNum").css("visibility","hidden"))};
JS9.Imarith.xnum=function(a,b,c){a=JS9.lookupImage(b,a);c=c.value;JS9.isNumber(c)?a.display.pluginInstances.JS9Imarith.num=parseFloat(c):c&&JS9.error("please enter a real number: "+c)};JS9.Imarith.xcancel=function(a,b,c){(a=JS9.lookupDisplay(a))&&(a=a.pluginInstances.JS9Imarith)&&a.winHandle&&a.winHandle.close()};JS9.Imarith.xreset=function(a,b,c){(a=JS9.lookupImage(b,a))&&a.imarithData("reset")};
JS9.Imarith.xrun=function(a,b,c){if(c=JS9.lookupImage(b,a))b=c.display.pluginInstances.JS9Imarith,b.op&&b.arg1||JS9.error("please select an operation and an operand"),"num"===b.arg1?(void 0===b.num&&JS9.error("please enter a real number for the operand"),a=b.num):a=b.arg1,c.imarithData(b.op,a)};JS9.Imarith.display=function(){this.lastimage!==this.display.image&&JS9.Imarith.init.call(this)};JS9.Imarith.close=function(){JS9.Imarith.init.call(this,{mode:"clear"})};
JS9.Imarith.init=function(a){var b,c;var d="";a=a||{};this.width=this.divjq.attr("data-width");this.width||(this.width=JS9.Imarith.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.Imarith.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.imarithWidth=this.width;this.imarithHeight=parseInt(this.divjq.attr("data-imarithHeight"),10);this.imarithHeight||
(this.imarithHeight=JS9.Imarith.IMARITHHEIGHT);delete this.arg1;delete this.op;delete this.num;if((c=this.display.image)&&"clear"!==a.mode){a=c.id;var f=c.display.id;this.lastim=c.id;for(b=0;b<JS9.images.length;b++){var e=JS9.images[b];e!==c&&(d+='<option value="'+e.id+'">'+e.id+"</option>")}b=[];b.push({name:"images",value:d});b.push({name:"imid",value:a});b.push({name:"op",value:sprintf(JS9.Imarith.opHTML,f,a)});b.push({name:"arg1",value:sprintf(JS9.Imarith.arg1HTML,f,a,d)});b.push({name:"num",
value:sprintf(JS9.Imarith.numHTML,f,a)});b.push({name:"cancel",value:sprintf(JS9.Imarith.cancelHTML,f,a)});b.push({name:"reset",value:sprintf(JS9.Imarith.resetHTML,f,a)});b.push({name:"run",value:sprintf(JS9.Imarith.runHTML,f,a)});d=JS9.Image.prototype.expandMacro.call(c,JS9.Imarith.imageHTML,b);this.lastimage=c}else d="<p><center>Image arithmetic will appear here.</center>";this.divjq.html("");this.imarithContainer=$("<div>").addClass(JS9.Imarith.BASE+"Container").attr("id",this.id+"Container").attr("width",
this.width).attr("height",this.height).appendTo(this.divjq);this.imarithContainer.html(d);this.imarithContainer.find(".JS9ImarithNum").css("visibility","hidden")};JS9.RegisterPlugin(JS9.Imarith.CLASS,JS9.Imarith.NAME,JS9.Imarith.init,{menuItem:"Imarith",onplugindisplay:JS9.Imarith.init,onimageload:JS9.Imarith.init,onimagedisplay:JS9.Imarith.display,onimageclose:JS9.Imarith.close,help:"help/imarith.html",winTitle:"Image Arithmetic",winDims:[JS9.Imarith.WIDTH,JS9.Imarith.HEIGHT]});JS9.Info={};
JS9.Info.CLASS="JS9";JS9.Info.NAME="Info";JS9.Info.WIDTH=325;JS9.Info.HEIGHT=250;JS9.Info.REGHEIGHT=75;
JS9.Info.opts={infoURL:"./params/info.html",infoObj:{file:'<tr><td><input type="text" class="column0" value="file" readonly="readonly"></td><td colspan="2"><input type="text" name="id" class="input2" value="" readonly="readonly" onclick="this.scrollLeft=this.scrollWidth;"></td></tr>',object:'<tr><td><input type="text" class="column0" value="object" readonly="readonly"></td><td colspan="2"><input type="text" name="object" class="input2" value="" readonly="readonly"></td></tr>',wcscen:'<tr><td><input type="text" class="column0" value="center" readonly="readonly"></td><td colspan="2"><input type="text" name="wcscen" class="input2" value="" readonly="readonly"></td></tr>',
wcsfov:'<tr><td><input type="text" class="column0" value="fov" readonly="readonly"></td><td colspan="2"><input type="text" name="wcsfovpix" class="input2" value="" readonly="readonly"></td></tr>',value:'<tr><td><input type="text" class="column0" value="value" readonly="readonly"></td><td colspan="2"><input type="text" name="val" class="input2" value="" readonly="readonly"></td></tr>',impos:'<tr><td><input type="text" class="column0" value="image" readonly="readonly"></td><td colspan="2"><input type="text" name="ipos" class="input2" value="" readonly="readonly"></td></tr>',
disppos:'<tr><td><input type="text" class="column0" value="display" readonly="readonly"></td><td colspan="2"><input type="text" name="dpos" class="input2" value="" readonly="readonly"></td></tr>',physpos:'<tr><td><input type="text" class="column0" value="physical" readonly="readonly"></td><td colspan="2"><input type="text" name="ppos" class="input2" value="" readonly="readonly"></td></tr>',wcspos:'<tr><td><input type="text" class="column0" value="wcs" name="wcssys" readonly="readonly"></td><td colspan="2"><input type="text" name="wcspos" class="input2" value="" readonly="readonly"></td></tr>',
regions:'<tr><td><input type="text" class="column0" value="regions" readonly="readonly"></td><td colspan="2"><textarea class="text2" name="regions" rows="4" value="" readonly="readonly"></textarea></td></tr>',progress:'<tr><td colspan="2"><div class="JS9Progress"><progress name="progress" class="JS9ProgressBar" value="0" max="100"></progress></div></td></tr>'}};
JS9.Info.init=function(){var a;if(this.display.image&&this.display.image===this.lastimage)switch(this.display.image.callingPlugin){case "onplugindisplay":case "onimagerefresh":case "onupdateprefs":break;default:return}var b=JS9.globalOpts.infoBox;var c=JS9.Info.opts.infoObj;var d='<table name="info" class="js9InfoTable">';for(a=0;a<b.length;a++){var f=b[a];if(!(f.match(/^wcspos/)&&JS9.globalOpts.infoBoxResize&&this.display.image)||0<this.display.image.raw.wcs)f.match(/^regions/)&&"lightwin"===JS9.globalOpts.regDisplay||
f in c&&(d+=c[f])}d+="</table>";this.infoConjq&&this.infoConjq.html("");this.width=this.divjq.attr("data-width");this.width||(this.width=JS9.Info.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.Info.HEIGHT,"lightwin"!==JS9.globalOpts.regDisplay&&(this.height+=JS9.Info.REGHEIGHT));this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.infoConjq=$("<div>").addClass("JS9Container").append(d).appendTo(this.divjq);
this.jq=this.infoConjq.find("[name='info']")};
JS9.Info.display=function(a,b,c,d){var f=this,e,h=this;this.display&&(h=this.display);var l=h.image;if(h.pluginInstances)var g=h.pluginInstances.JS9Info;if(!g||"active"!==g.status||c&&d)if(c){if(c===h){var k=h;c=null}else k=c instanceof jQuery?c:"object"===typeof c?$(c):$("#"+c);k.length||(k=h,c=null);this.lasttarget=c}else this.lasttarget=k=h;else k=g;if("progress"===a){if(k=k===g?g.jq:k.divjq,0<k.length)switch(k=k.find("[name='progress']"),typeof b){case "string":case "boolean":b?("indeterminate"===
b&&k.removeAttr("value"),k.parent().css("display","inline-block")):(k.parent().css("display","none"),k.attr("value",0));break;case "object":b[1]&&k.attr("max",b[1]),k.attr("value",b[0])}}else{if(k===g&&("regions"!==a||"lightwin"!==JS9.globalOpts.regDisplay)){switch(typeof b){case "string":var m=g.jq.find("[name='"+a+"']");0<m.length?m.val(b):JS9.globalOpts.fallbackDisplay&&(k=h);break;case "object":var p=$jscomp.makeIterator(Object.keys(b));for(e=p.next();!e.done;e=p.next())if(e=e.value,m=g.jq.find("[name='"+
e+"']"),0<m.length){switch(e){case "val":e=b.val3;break;default:e=b[e]}m.val(e)}}if(k!==h)return h}switch(a){case "regions":if("lightwin"===JS9.globalOpts.regDisplay){var n=h.id+"_regions";k=$("#"+n);if(k.length&&!k[0].isClosed)l=k.find(".JS9Message");else{if(b){$(JS9.lightOpts[JS9.LIGHTWIN].topid).arrive("#"+n,{fireOnAttributesModification:!0},function(){JS9.Info.display.call(f,a,b,c,d)});var q="Regions";l&&(q+=": "+l.id);q=q+" "+sprintf(JS9.IDFMT,this.id);JS9.lightWin(n,"inline","<div class='JS9Message'></div>",
q,JS9.lightOpts[JS9.LIGHTWIN].regWin0)}return}}else if(c)l=k;else{l=k.regionsArea;k.infoheight=k.infoArea.height()+4;k.regheight=Math.max(2*k.infoheight+10,k.infoheight+k.regionsArea.height()+10);var r=!h.image||h.image.iy>k.regheight?JS9.textColorOpts.inimage:JS9.textColorOpts.regions}n=";";break;default:c?l=k:(l=k.infoArea,k.infoheight=k.infoArea.height()+4,r=!h.image||h.image.iy>k.infoheight?JS9.textColorOpts.inimage:JS9.textColorOpts.info,n="")}switch(typeof b){case "string":q=b;break;case "object":e=
"vstr"+JS9.globalOpts.valposWidth,q=b[e]||b.vstrmedium||b.vstr||""}""!==n&&(k=q.split(n),2<k.length&&(n=new RegExp(n,"g"),q=q.replace(n,"<br>")));r&&l.css("color",r);l.html(q);return h}};JS9.Display.prototype.displayMessage=JS9.Info.display;JS9.Image.prototype.displayMessage=JS9.Info.display;JS9.Info.clear=function(a){var b=this;this.display&&(b=this.display);a?b.displayMessage(a,""):(b.displayMessage("info",""),b.displayMessage("regions",""),b.displayMessage("progress",!1));return b};
JS9.Display.prototype.clearMessage=JS9.Info.clear;JS9.Image.prototype.clearMessage=JS9.Info.clear;JS9.Info.pluginDisplay=function(a){a&&a.display&&(a.tmp&&(a.tmp.info_ovalpos=a.params.valpos),a.params.valpos=!0,this.display.lasttarget&&(a=this.display,a.displayMessage("info","",a.lasttarget,!0),a.displayMessage("regions","",a.lasttarget,!0),a.displayMessage("progress",!1,a.lasttarget,!0),delete a.lasttarget))};
JS9.Info.pluginClose=function(a){a&&a.display&&a.tmp&&void 0!==a.tmp.info_ovalpos&&(a.params.valpos=a.tmp.info_ovalpos)};JS9.mkPublic("DisplayMessage",function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];c=JS9.parsePublicArgs(b);(b=JS9.lookupDisplay(c.display))||JS9.error("invalid display for display message");c=b.displayMessage(c.argv[0],c.argv[1],c.argv[2]);c===b&&(c="OK");return c});
JS9.RegisterPlugin("JS9","Info",JS9.Info.init,{menuItem:"InfoBox",help:"help/info.html",dynamicSelect:!0,onplugindisplay:JS9.Info.pluginDisplay,onpluginclose:JS9.Info.pluginClose,onimagedisplay:JS9.Info.init,onimagerefresh:JS9.Info.init,onupdateprefs:JS9.Info.init,winTitle:"Info",winResize:!0,winDims:[JS9.Info.WIDTH,JS9.Info.HEIGHT]});JS9.Keyboard={};JS9.Keyboard.CLASS="JS9";JS9.Keyboard.NAME="Keyboard";JS9.Keyboard.WIDTH=450;JS9.Keyboard.HEIGHT=420;JS9.Keyboard.BASE=JS9.Keyboard.CLASS+JS9.Keyboard.NAME;
JS9.Keyboard.actionHTML="<div class='JS9KeyboardText'><button class='JS9Button JS9KeyboardButton' type='button' value='%s'>%s</button></div><div class='JS9KeyboardAction'>%s</div>";JS9.Keyboard.actionid=function(a,b){return(a+"_"+b).replace(/[^A-Za-z0-9_]/g,"_")};
JS9.Keyboard.addAction=function(a,b,c){var d=this;var f=JS9.Keyboard.actionid(b,c);b=sprintf(JS9.Keyboard.actionHTML,c,b,c);a=$("<div class='JS9KeyboardItem'>").attr("id",f).html(b).appendTo(a);a.find(".JS9KeyboardButton").on("click",function(a){var b=a.currentTarget.value,c=d.display.image;if(c&&b&&JS9.Keyboard.Actions[b])JS9.Keyboard.Actions[b](c,c.ipos,a)});return a};
JS9.Keyboard.arrowKey=function(a,b,c,d){a.pos.x+=c.x;a.pos.y+=c.y;a.ipos=a.displayToImagePos(a.pos);({}).hasOwnProperty.call(JS9,"MouseTouch")&&(a.valpos=null,JS9.MouseTouch.Actions["display value/position"](a,a.ipos,b));({}).hasOwnProperty.call(JS9,"Magnifier")&&!d&&JS9.Magnifier.display(a,a.ipos);JS9.globalOpts.regArrowCrosshair&&{}.hasOwnProperty.call(JS9,"Crosshair")&&(a.tmp.arrowCrosshair=!0,a.tmp.arrowCrosshairVisible=!0,d?d.pub&&(c="polygon"===d.pub.shape&&d.pub.pts&&1<d.pub.pts.length?JS9.centroidPolygon(d.pub.pts):
{x:d.pub.x,y:d.pub.y},JS9.Crosshair.display(a,c,b)):JS9.Crosshair.display(a,a.ipos,b),delete a.tmp.arrowCrosshair)};JS9.Keyboard.Actions={};JS9.Keyboard.Actions["open local file"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&(window.isElectron&&"object"===typeof c.data?d.displayLoadForm():JS9.OpenFileMenu({display:d}))};JS9.Keyboard.Actions["close image"]=function(a,b,c){a&&a.closeImage()};
JS9.Keyboard.Actions["new JS9 light window"]=function(a,b,c){var d;if(a)var f=a.display;else c&&"object"===typeof c.data&&(f=c.data);f&&(d={clone:f.id});JS9.LoadWindow(null,d,"light")};
JS9.Keyboard.Actions["copy wcs position to clipboard"]=function(a,b,c){if(a&&a.raw.wcs&&b)return b=JS9.pix2wcs(a.raw.wcs,b.x,b.y).trim(),JS9.globalOpts.copyWcsPosFormat&&(b=b.split(/\s+/),b=[{name:"ra",value:b[0]},{name:"dec",value:b[1]},{name:"sys",value:b[2]}],b=a.expandMacro(JS9.globalOpts.copyWcsPosFormat,b)),JS9.CopyToClipboard(b,a),b};
JS9.Keyboard.Actions["copy physical position to clipboard"]=function(a,b,c){if(a&&b)return b=a.imageToLogicalPos(b),b=sprintf("%f %f",b.x,b.y),JS9.CopyToClipboard(b,a),b};JS9.Keyboard.Actions["copy pixel value to clipboard"]=function(a,b,c){if(a&&b)return b=a.raw.data[Math.floor(b.y-.5)*a.raw.width+Math.floor(b.x-.5)],c=JS9.floatPrecision(a.params.scalemin,a.params.scalemax),b=JS9.floatFormattedString(b,c,3),JS9.CopyToClipboard(b,a),b};
JS9.Keyboard.Actions["copy value and position to clipboard"]=function(a,b,c){if(a&&b)return c=a.setParam("valpos",!0),b=a.updateValpos(b,!1),a.setParam("valpos",c),c="vstr"+JS9.globalOpts.valposWidth,b=b&&b[c]?b[c].replace(/ /g," "):" ",JS9.CopyToClipboard(b,a),b};JS9.Keyboard.Actions["edit selected region(s)"]=function(a,b,c){a&&(b=a.layers.regions)&&((b=b.canvas.getActiveObject())&&"activeSelection"!==b.type?a.displayRegionsForm(b):a.displayRegionsForm(null,{multi:!0}))};
JS9.Keyboard.Actions["add last region selected in regions menu"]=function(a,b,c){c={ireg:!0};var d=JS9.globalOpts.regMenuSelected||"circle";if(a)return c.x=b.x,c.y=b.y,a.addShapes("regions",d,c)};JS9.Keyboard.Actions["toggle selected region: source/background"]=function(a,b,c){if(a)return a.toggleRegionTags("selected","source","background")};JS9.Keyboard.Actions["toggle selected region: include/exclude"]=function(a,b,c){if(a)return a.toggleRegionTags("selected","include","exclude")};
JS9.Keyboard.Actions["tag selected region as 'source'"]=function(a,b,c){if(a)return JS9.Keyboard.editregion(a,"source","background")};JS9.Keyboard.Actions["tag selected region as 'background'"]=function(a,b,c){if(a)return JS9.Keyboard.editregion(a,"background","source")};JS9.Keyboard.Actions["tag selected region as 'include'"]=function(a,b,c){if(a)return JS9.Keyboard.editregion(a,"include","exclude")};
JS9.Keyboard.Actions["tag selected region as 'exclude'"]=function(a,b,c){if(a)return JS9.Keyboard.editregion(a,"exclude","include")};JS9.Keyboard.Actions["toggle full screen mode"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&(d.width===d.width0&&d.height===d.height0?d.resize("full",{center:!0}):d.resize("reset"))};JS9.Keyboard.Actions["reset zoom"]=function(a,b,c){a&&a.setZoom("1")};JS9.Keyboard.Actions["zoom in"]=function(a,b,c){a&&a.setZoom("*2")};
JS9.Keyboard.Actions["zoom out"]=function(a,b,c){a&&a.setZoom("/2")};JS9.Keyboard.Actions["display next image"]=function(a,b,c){a&&a.display.nextImage(1)};JS9.Keyboard.Actions["display previous image"]=function(a,b,c){a&&a.display.nextImage(-1)};JS9.Keyboard.Actions["open a local FITS file"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&JS9.OpenFileMenu({display:d})};JS9.Keyboard.Actions["save image as a FITS file"]=function(a,b,c){a&&a.saveFITS()};
JS9.Keyboard.Actions["save image as a PNG file"]=function(a,b,c){a&&a.savePNG()};JS9.Keyboard.Actions["save regions as a text file"]=function(a,b,c){a&&a.saveRegions()};
JS9.Keyboard.Actions["move region/position up"]=function(a,b,c){var d,f=JS9.globalOpts.arrowIncrement;c&&c.preventDefault();if(a){var e=a.layer||"regions";b=a.display.layers[e].canvas;(d=b.getActiveObject())&&!d.lockMovementY&&a.changeShapes(e,"selected",{deltay:f});JS9.Keyboard.arrowKey(a,c,{x:0,y:-1*f},d);b.fire("mouse:up");JS9.globalOpts.extendedPlugins&&a.xeqPlugins("keydown","onarrowkey",c)}};
JS9.Keyboard.Actions["move region/position down"]=function(a,b,c){var d,f=-JS9.globalOpts.arrowIncrement;c&&c.preventDefault();if(a){var e=a.layer||"regions";b=a.display.layers[e].canvas;(d=b.getActiveObject())&&!d.lockMovementY&&a.changeShapes(e,"selected",{deltay:f});JS9.Keyboard.arrowKey(a,c,{x:0,y:-1*f},d);b.fire("mouse:up");JS9.globalOpts.extendedPlugins&&a.xeqPlugins("keydown","onarrowkey",c)}};
JS9.Keyboard.Actions["move region/position left"]=function(a,b,c){var d,f=-JS9.globalOpts.arrowIncrement;c&&c.preventDefault();if(a){var e=a.layer||"regions";b=a.display.layers[e].canvas;(d=b.getActiveObject())&&!d.lockMovementX&&a.changeShapes(e,"selected",{deltax:f});JS9.Keyboard.arrowKey(a,c,{x:f,y:0},d);b.fire("mouse:up");JS9.globalOpts.extendedPlugins&&a.xeqPlugins("keydown","onarrowkey",c)}};
JS9.Keyboard.Actions["move region/position right"]=function(a,b,c){var d,f=JS9.globalOpts.arrowIncrement;c&&c.preventDefault();if(a){var e=a.layer||"regions";b=a.display.layers[e].canvas;(d=b.getActiveObject())&&!d.lockMovementX&&a.changeShapes(e,"selected",{deltax:f});JS9.Keyboard.arrowKey(a,c,{x:f,y:0},d);b.fire("mouse:up");JS9.globalOpts.extendedPlugins&&a.xeqPlugins("keydown","onarrowkey",c)}};
JS9.Keyboard.Actions["remove selected region"]=function(a,b,c){c&&c.preventDefault();a&&(c=a.layer||"regions",b=a.display.layers[c].canvas,a.removeShapes(c,"selected"),a.display.clearMessage(c),b.fire("mouse:up"))};JS9.Keyboard.Actions["raise region layer to top"]=function(a,b,c){c&&c.preventDefault();a&&a.activeShapeLayer("regions")};JS9.Keyboard.Actions["toggle active shape layers"]=function(a,b,c){c&&c.preventDefault();a&&a.toggleShapeLayers()};
JS9.Keyboard.Actions["send selected region to back"]=function(a,b,c){c&&c.preventDefault();a&&a.changeShapes("regions","selected",{send:"back"})};JS9.Keyboard.Actions["copy region(s) to clipboard"]=function(a,b,c){if(a)return b=a.listRegions(null,{mode:1}),JS9.CopyToClipboard(b,a),b};JS9.Keyboard.Actions["copy selected region(s) to clipboard"]=function(a,b,c){if(a)return b=a.listRegions("selected",{mode:1}),JS9.CopyToClipboard(b,a),b};
JS9.Keyboard.Actions["copy all regions to clipboard"]=function(a,b,c){if(a)return b=a.listRegions("all",{mode:1}),JS9.CopyToClipboard(b,a),b};JS9.Keyboard.Actions["paste regions from local clipboard"]=function(a,b,c){return JS9.Regions.pasteFromClipboard.call(a,!1)};JS9.Keyboard.Actions["paste regions to current position"]=function(a,b,c){return JS9.Regions.pasteFromClipboard.call(a,!0)};JS9.Keyboard.Actions["undo remove of region(s)"]=function(a,b,c){a&&a.unremoveRegions()};
JS9.Keyboard.Actions["select region"]=function(a,b,c){if(a){c=a.layers[a.layer||"regions"].canvas;var d=c.getObjects();for(b=0;b<d.length;b++){var f=d[b];if(f.containsPoint(a.pos)){c.setActiveObject(f);c.renderAll();break}}}};JS9.Keyboard.Actions["select all regions"]=function(a,b,c){a&&(a=a.layers[a.layer||"regions"].canvas,b=new fabric.ActiveSelection(a.getObjects(),{canvas:a}),a.setActiveObject(b),a.renderAll())};
JS9.Keyboard.Actions["unselect all regions"]=function(a,b,c){a&&(a=a.layers[a.layer||"regions"].canvas,a.getActiveObject()&&a.discardActiveObject(),a.renderAll())};JS9.Keyboard.Actions["refresh image"]=function(a,b,c){a&&(c&&c.preventDefault(),a.refreshImage())};JS9.Keyboard.Actions["display full image"]=function(a,b,c){a&&(c&&c.preventDefault(),a.displaySection("full"))};JS9.Keyboard.Actions["display selected cutouts"]=function(a,b,c){a&&(c&&c.preventDefault(),a.displaySection("selected"))};
JS9.Keyboard.Actions["toggle coordinate grid"]=function(a,b,c){JS9.Grid.toggle(a)};JS9.Keyboard.Actions["toggle crosshair"]=function(a,b,c){a&&(c&&c.preventDefault(),a.params.crosshair=!a.params.crosshair,a.params.crosshair||JS9.Crosshair.hide(a))};JS9.Keyboard.Actions["toggle mouse/touch plugin"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&d.displayPlugin("JS9MouseTouch")};
JS9.Keyboard.Actions["toggle keyboard actions plugin"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&d.displayPlugin("JS9Keyboard")};JS9.Keyboard.Actions["toggle preferences plugin"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&d.displayPlugin("JS9Preferences")};JS9.Keyboard.Actions["toggle shape layers plugin"]=function(a,b,c){if(a)var d=a.display;else c&&"object"===typeof c.data&&(d=c.data);d&&d.displayPlugin("JS9Layers")};
JS9.Keyboard.Actions["pan to mouse position"]=function(a,b,c){a&&a.setPan("mouse")};JS9.Keyboard.Actions["flip image around x axis"]=function(a){a&&a.setFlip("x")};JS9.Keyboard.Actions["flip image around y axis"]=function(a){a&&a.setFlip("y")};JS9.Keyboard.Actions["rotate image by 90 degrees"]=function(a){a&&a.setRot90(90)};JS9.Keyboard.Actions["rotate image by -90 degrees"]=function(a){a&&a.setRot90(-90)};
JS9.Keyboard.getAction=function(a,b){var c;(a=JS9.eventToCharStr(b))&&(c=JS9.globalOpts.keyboardActions[a]);return c};JS9.Keyboard.action=function(a,b,c,d){(d=d||JS9.Keyboard.getAction(a,c))&&JS9.Keyboard.Actions[d]&&(JS9.Keyboard.Actions[d](a,b,c),a&&JS9.globalOpts.extendedPlugins&&a.xeqPlugins("keydown","onkeyboardaction",c))};
JS9.Keyboard.editregion=function(a,b,c){var d,f;var e=a.getShapes("regions","selected");if(e.length){for(d=0;d<e.length;d++){var h=e[d].tags;for(f=0;f<h.length;f++){if(h[f]===b){b="";break}if(h[f]===c){h[f]=b;b="";break}}b&&h.push(b)}a.changeShapes("regions","selected",{tags:h})}};
JS9.Keyboard.init=function(){this.divjq.html("");this.divjq.addClass("JS9PluginScrolling");this.keyboardContainer=$("<div>").addClass(JS9.Keyboard.BASE+"Container").attr("id",this.id+"KeyboardContainer").appendTo(this.divjq);var a="<div class='"+JS9.Keyboard.BASE+"Header'><b>Keys and their actions (or click the buttons):</b></div><p>";this.keyboardHeadContainer=$("<div>").addClass(JS9.Keyboard.BASE+"Container").attr("id",this.id+"KeyboardHeadContainer").html(a).appendTo(this.keyboardContainer);this.keyboardActionContainer=
$("<div>").addClass(JS9.Keyboard.BASE+"ActionContainer").attr("id",this.id+"ActionContainer").html("").appendTo(this.keyboardContainer);var b=$jscomp.makeIterator(Object.keys(JS9.globalOpts.keyboardActions));for(a=b.next();!a.done;a=b.next()){var c=a.value;a=JS9.globalOpts.keyboardActions[c];JS9.Keyboard.addAction.call(this,this.keyboardActionContainer,c,a)}};
JS9.RegisterPlugin(JS9.Keyboard.CLASS,JS9.Keyboard.NAME,JS9.Keyboard.init,{menuItem:"Keyboard Actions",onplugindisplay:JS9.Keyboard.init,help:"help/keyboard.html",winTitle:"Keyboard Actions",winResize:!0,winDims:[JS9.Keyboard.WIDTH,JS9.Keyboard.HEIGHT]});JS9.Layers={};JS9.Layers.CLASS="JS9";JS9.Layers.NAME="Layers";JS9.Layers.WIDTH=460;JS9.Layers.HEIGHT=250;JS9.Layers.BASE=JS9.Layers.CLASS+JS9.Layers.NAME;JS9.Layers.headerHTML="Shape layers can be hidden or made visible below. The topmost visible layer in the stack is <b>active</b>: it responds to mouse and touch events. Move a layer to the top of the stack to make it active.";
JS9.Layers.layerHTML="<span style='float: left'>$visible $save $color</span> <span class='JS9LayersSpan'>$layer  </span>";JS9.Layers.nolayersHTML='<p><span class="JS9NoLayers">[Layers will appear here as they are created]</span>';JS9.Layers.visibleHTML='<input class="JS9LayersVisibleCheck" type="checkbox" id="visible" name="visible" value="visible" onclick="javascript:JS9.Layers.xvisible(\'%s\', \'%s\', \'%s\', this)">visible';JS9.Layers.saveBothHTML='<select class="JS9Select JS9LayersSaveBothSelect" onfocus="this.selectedIndex=0;" onchange="JS9.Layers.xsave(\'%s\', \'%s\', \'%s\', this)"><option selected disabled>save as ...</option><option value="catalog">catalog</option><option value="regions">regions</option><option value="svg">svg</option></select>';
JS9.Layers.saveRegionsHTML='<select class="JS9Select JS9LayersSaveSelect" onfocus="this.selectedIndex=0;" onchange="JS9.Layers.xsave(\'%s\', \'%s\', \'%s\', this)"><option selected disabled>save as ...</option><option value="regions">regions</option><option value="svg">svg</option></select>';JS9.Layers.colorHTML='<select class="JS9Select JS9LayersColorSelect" onfocus="this.selectedIndex=0;" onchange="JS9.Layers.xcolor(\'%s\', \'%s\', \'%s\', this)"><option selected disabled>color ...</option><option value="black">black</option><option value="white">white</option><option value="red">red</option><option value="magenta">magenta</option><option value="orange">orange</option><option value="yellow">yellow</option><option value="blue">blue</option><option value="cyan">cyan</option><option value="green">green</option><option value="lime">lime</option><option value="indigo">indigo</option><option value="violet">violet</option></select>';
JS9.Layers.layerNameHTML="<b>%s</b>";JS9.Layers.imid=function(a,b){return(a.display.id+"_"+a.id+"_"+b+"_").replace(/[^A-Za-z0-9_]/g,"_")+"Layer"};JS9.Layers.dispclass=function(a){return(JS9.Layers.BASE+"_"+a.display.id).replace(/[^A-Za-z0-9_]/g,"_")};
JS9.Layers.activeLayer=function(a,b){if(a){var c=b.layersLayerContainer.sortable("toArray");if(1!==c.length||c[0]){for(b=0;b<c.length;b++)c[b]=$("#"+c[b]).attr("layer");b=a.activeShapeLayer(c);b=JS9.Layers.imid(a,b);a=JS9.Layers.dispclass(a)+"_Layer";$("."+a).removeClass(JS9.Layers.BASE+"LayerActive").addClass(JS9.Layers.BASE+"LayerInactive");$("#"+b).removeClass(JS9.Layers.BASE+"LayerInactive").addClass(JS9.Layers.BASE+"LayerActive")}}};
JS9.Layers.xvisible=function(a,b,c,d){if(a=JS9.lookupImage(b,a))d=d.checked?!0:!1,a.showShapeLayer(c,d),c=a.display.pluginInstances[JS9.Layers.BASE],JS9.Layers.activeLayer(a,c,!0)};JS9.Layers.xsave=function(a,b,c,d){a=JS9.lookupImage(b,a);d=d.options[d.selectedIndex].value;a&&("catalog"===d?a.saveCatalog(null,c):"regions"===d?a.saveRegions(null,null,c):"svg"===d&&a.saveRegions(null,null,{layer:c,type:"svg"}))};
JS9.Layers.xcolor=function(a,b,c,d){a=JS9.lookupImage(b,a);b=d.options[d.selectedIndex].value;a&&b&&(a.changeShapes(c,"all",{color:b}),d.selectedIndex=0)};
JS9.Layers.addLayer=function(a,b){var c,d=JS9.Layers.BASE+"Layer";var f=[];if(a&&b&&a.layers[b]&&"main"===a.layers[b].dlayer.dtype){this.nlayer||this.layersLayerContainer.html("");var e=a.id;var h=a.display.id;var l=parseInt(a.display.layers[b].divjq.css("z-index"),10);var g=JS9.Layers.imid(a,b);var k=JS9.Layers.dispclass(a)+"_Layer";f.push({name:"imid",value:e});f.push({name:"visible",value:sprintf(JS9.Layers.visibleHTML,h,e,b)});a.layers[b].catalog?f.push({name:"save",value:sprintf(JS9.Layers.saveBothHTML,
h,e,b)}):f.push({name:"save",value:sprintf(JS9.Layers.saveRegionsHTML,h,e,b)});f.push({name:"color",value:sprintf(JS9.Layers.colorHTML,h,e,b)});h=1<JS9.DEBUG?b+" layer [zindex: "+l+"]":b+" layer";f.push({name:"layer",value:sprintf(JS9.Layers.layerNameHTML,h)});f=JS9.Image.prototype.expandMacro.call(a,JS9.Layers.layerHTML,f);var m=$("<div>").addClass(d).addClass(k).attr("id",g).attr("layer",b).prop("imid",e).html(f);this.nlayer?(this.layersLayerContainer.find("."+d).each(function(b,d){b=$(d);!c&&(d=
b.attr("layer"))&&(d=parseInt(a.display.layers[d].divjq.css("z-index"),10),Math.abs(l)>Math.abs(d)&&(m.insertBefore(b),c=!0))}),c||m.appendTo(this.layersLayerContainer)):m.appendTo(this.layersLayerContainer);m.find(".JS9LayersVisibleCheck").prop("checked",!!a.layers[b].show);this.nlayer++}};JS9.Layers.display=function(){this.lastimage!==this.display.image&&JS9.Layers.init.call(this)};JS9.Layers.close=function(){JS9.Layers.init.call(this,{mode:"clear"})};
JS9.Layers.init=function(a){var b=this,c;a=a||{};this.divjq.html("");this.nlayer=0;this.divjq.addClass("JS9PluginScrolling");this.layersContainer=$("<div>").addClass(JS9.Layers.BASE+"Container").attr("id",this.id+"LayersContainer").css("overflow","auto").appendTo(this.divjq);this.layersHeader=$("<div>").addClass(JS9.Layers.BASE+"Header").attr("id",this.display.id+"Header").html(JS9.Layers.headerHTML).appendTo(this.layersContainer);this.layersLayerContainer=$("<div>").addClass(JS9.Layers.BASE+"LayerContainer").attr("id",
this.id+"LayersLayerContainer").html(JS9.Layers.nolayersHTML).appendTo(this.layersContainer);if("clear"!==a.mode){if(this.display.image){var d=this.display.image;a=$jscomp.makeIterator(Object.keys(d.layers));for(c=a.next();!c.done;c=a.next())c=c.value,"crosshair"!==c&&"grid"!==c&&JS9.Layers.addLayer.call(this,d,c);this.lastimage=d}this.layersLayerContainer.sortable({start:function(a,b){},stop:function(a,c){JS9.Layers.activeLayer(d,b)}});JS9.Layers.activeLayer(d,this)}};
JS9.RegisterPlugin(JS9.Layers.CLASS,JS9.Layers.NAME,JS9.Layers.init,{menuItem:"Shape Layers",onplugindisplay:JS9.Layers.init,onshapelayercreate:JS9.Layers.init,onshapelayershow:JS9.Layers.init,onshapelayeractive:JS9.Layers.init,onshapelayerhide:JS9.Layers.init,onimageload:JS9.Layers.init,onimagedisplay:JS9.Layers.display,onimageclose:JS9.Layers.close,help:"help/layers.html",winTitle:"Shape Layers",winResize:!0,winDims:[JS9.Layers.WIDTH,JS9.Layers.HEIGHT]});JS9.Magnifier={};JS9.Magnifier.CLASS="JS9";
JS9.Magnifier.NAME="Magnifier";JS9.Magnifier.WIDTH=JS9.WIDTH/2;JS9.Magnifier.HEIGHT=JS9.HEIGHT/2;JS9.Magnifier.SWIDTH=250;JS9.Magnifier.SHEIGHT=250;JS9.Magnifier.opts={originX:"left",originY:"top",hasControls:!1,hasRotatingPoint:!1,hasBorders:!1,selectable:!1,zoom:4,canvas:{selection:!1},tagcolors:{defcolor:"#00FF00"}};
JS9.Magnifier.bcall=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d,f=$jscomp.makeIterator(b);var e=f.next().value;c=f.next().value;f=f.next().value;(e=$(e).closest("div[class^=JS9PluginToolbar]").data("displayid"))?d=JS9.getImage(e):JS9.error("can't find display for cmd: "+c);d||JS9.error("can't find image for cmd: "+c);switch(c){case "zoomMagnifier":3>b.length&&JS9.error("missing arg(s) for cmd: "+c);try{JS9.Magnifier.zoom(d,f)}catch(h){JS9.error("error calling zoomMagnifier()",
h)}}};JS9.Voyager||(JS9.Magnifier.HTML="<span><button type='button' class='JS9Button' onClick='JS9.Magnifier.bcall(this, \"zoomMagnifier\", \"x2\"); return false'>\u00d72</button><button type='button' class='JS9Button' onClick='JS9.Magnifier.bcall(this, \"zoomMagnifier\", \"/2\"); return false'>\u00d71/2</button><button type='button' class='JS9Button' onClick='JS9.Magnifier.bcall(this, \"zoomMagnifier\", \""+JS9.Magnifier.opts.zoom+"\"); return false'>["+JS9.Magnifier.opts.zoom+"]</button></span>");
JS9.Magnifier.init=function(a,b){this.width=this.divjq.attr("data-width");this.width||(this.width=a||JS9.Magnifier.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=b||JS9.Magnifier.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.canvas=document.createElement("canvas");this.canvasjq=$(this.canvas);this.canvasjq.addClass("JS9Magnifier");this.canvasjq.css("z-index",
JS9.ZINDEX);this.canvasjq.attr("width",this.width);this.canvasjq.attr("height",this.height);this.context=this.canvas.getContext("2d");JS9.ANTIALIAS||(this.context.imageSmoothingEnabled=!1);this.containerjq=$("<div>").addClass("JS9Container").append(this.canvasjq).appendTo(this.divjq);this.display.newShapeLayer("magnifier",JS9.Magnifier.opts,this.divjq)};
JS9.Magnifier.display=function(a,b){var c;if(a&&a.display.pluginInstances.JS9Magnifier&&"active"===a.display.pluginInstances.JS9Magnifier.status&&!(0<a.clickState||-1>a.clickState)){a.magnifier||(a.magnifier={zoom:JS9.Magnifier.opts.zoom,posx:0,posy:0});var d=a.display.pluginInstances.JS9Magnifier;var f=a.display.canvas;var e=a.magnifier.zoom;var h=Math.floor(d.width/e);var l=Math.floor(d.height/e);if(b){var g=a.imageToDisplayPos(b);b=g.x-h/2;var k=g.y-l/2;a.magnifier.posx=b;a.magnifier.posy=k}else b=
a.magnifier.posx,k=a.magnifier.posy;var m=c=0;var p=d.canvas.width;var n=d.canvas.height;0>b&&(h+=b,c-=b*e,p+=b*e,b=0);g=b+h-f.width;0<g&&(h-=g,p=h*e);0>k&&(l+=k,m-=k*e,n+=k*e,k=0);g=k+l-f.height;0<g&&(l-=g,n=l*e);d.context.clear();d.context.drawImage(f,b,k,h,l,c,m,p,n);JS9.globalOpts.magnifierRegions&&a.display.layers&&a.display.layers.regions&&(f=a.display.layers.regions.canvas.getElement(),b*=fabric.devicePixelRatio,k*=fabric.devicePixelRatio,h*=fabric.devicePixelRatio,l*=fabric.devicePixelRatio,
d.context.drawImage(f,b,k,h,l,c,m,p,n));a.magnifier.boxid||(a.magnifier.boxid=a.addShapes("magnifier","box"),$(d.canvas).css("background-color","black"));a.magnifier.ozoom!==e&&(a.changeShapes("magnifier",a.magnifier.boxid,{left:d.width/2-1,top:d.height/2-1,width:e,height:e}),a.magnifier.ozoom=a.magnifier.zoom)}};JS9.Magnifier.display2=function(a,b){window.setTimeout(function(){JS9.Magnifier.display(a,b)},0)};
JS9.Magnifier.zoom=function(a,b){if(a&&a.magnifier){var c=a.magnifier;var d=c.zoom;switch(b.charAt(0)){case "x":case "*":b=d*parseFloat(b.slice(1));break;case "/":b=d/parseFloat(b.slice(1));break;default:b=parseFloat(b)}if(!b||1>b)b=1;c.ozoom=c.zoom;c.zoom=b;JS9.Magnifier.display(a)}};
JS9.Magnifier.clear=function(a){var b=a.display.pluginInstances.JS9Magnifier;b&&a===a.display.image&&(b.context.clear(),a.removeShapes("magnifier","all"),a.magnifier.boxid=null,a.magnifier.ozoom=0,$(b.canvas).css("background-color","#E9E9E9"));return a};
JS9.RegisterPlugin(JS9.Magnifier.CLASS,JS9.Magnifier.NAME,JS9.Magnifier.init,{menuItem:"Magnifier",help:"help/magnifier.html",dynamicSelect:!0,toolbarSeparate:!1,toolbarHTML:JS9.Magnifier.HTML,onplugindisplay:JS9.Magnifier.display,onregionsmove:JS9.Magnifier.display,onregionschange:JS9.Magnifier.display2,onmousemove:JS9.Magnifier.display,onimagedisplay:JS9.Magnifier.display,onimageclose:JS9.Magnifier.clear,onimageclear:JS9.Magnifier.clear,winTitle:"Magnifier",winDims:[JS9.Magnifier.WIDTH,JS9.Magnifier.HEIGHT],
divArgs:[JS9.Magnifier.SWIDTH,JS9.Magnifier.SHEIGHT]});JS9.Mef={};JS9.Mef.CLASS="JS9";JS9.Mef.NAME="Mef";JS9.Mef.WIDTH=800;JS9.Mef.HEIGHT=240;JS9.Mef.BASE=JS9.Mef.CLASS+JS9.Mef.NAME;JS9.Mef.xseparate=function(a,b){a=JS9.lookupDisplay(a);b=b.checked;a&&(a.pluginInstances[JS9.Mef.BASE].separate=b)};JS9.Mef.xall=function(a,b){(a=JS9.lookupDisplay(a))&&a.image&&(a.pluginInstances[JS9.Mef.BASE].separate=!0,a.image.displayExtension("all"))};
JS9.Mef.imid=function(a,b,c){a=a.display.id+"_"+a.id;c&&(a=a.replace(/\[[a-zA-Z0-9][a-zA-Z0-9_]*\]/g,""));return a.replace(/[^A-Za-z0-9_]/g,"_")+"_MefExtension_"+b};JS9.Mef.activeExtension=function(a,b){if(a){var c=a.display.id+"_"+JS9.Mef.BASE;$("."+c+"Extension").removeClass(JS9.Mef.BASE+"ExtensionActive").addClass(JS9.Mef.BASE+"ExtensionInactive");a=JS9.Mef.imid(a,b,!0);$("."+a).removeClass(JS9.Mef.BASE+"ExtensionInactive").addClass(JS9.Mef.BASE+"ExtensionActive")}};
JS9.Mef.display=function(){this.lastimage!==this.display.image&&JS9.Mef.init.call(this)};JS9.Mef.close=function(){JS9.Mef.init.call(this,{mode:"clear"})};
JS9.Mef.init=function(a){var b=this,c,d,f,e,h,l,g=function(a,g,k){var m,p="",n=!0;switch(a.type){case "image":2>a.naxes.length&&(n=!1);break;case "table":case "ascii":for(m=0;m<a.cols.length;m++){var q=a.cols[m];if("X"===q.name||"x"===q.name)p+="x";if("Y"===q.name||"y"===q.name)p+="y"}"xy"!==p&&"yx"!==p&&(n=!1)}h=n?"<pre> "+g+"</pre>":"<pre> <span class='JS9MefStrike'><span>"+g+"</span></span></pre>";d=JS9.Mef.imid(c,k);f=JS9.Mef.imid(c,k,!0);l=c.display.id+"_"+JS9.Mef.BASE;
e=$("<div>").addClass(f).addClass(l+"Extension").addClass(JS9.Mef.BASE+"Extension").addClass(JS9.Mef.BASE+"ExtensionInactive").attr("id",d).html(h).appendTo(b.mefContainer);if(n)e.on("mousedown touchstart",function(){c.displayExtension(a.hdu,{separate:b.separate});JS9.Mef.activeExtension(c,a.hdu)})};a=a||{};this.divjq.addClass("JS9PluginScrolling");this.divjq.html("");this.mefContainer=$("<div>").addClass(JS9.Mef.BASE+"Container").attr("id",this.id+"MefContainer").appendTo(this.divjq);void 0===this.separate&&
(this.separate=!1);if((c=this.display.image)&&"clear"!==a.mode)if(c.hdus){this.lastimage=c;var k="<div class='"+JS9.Mef.BASE+"Header'><span><b>Click on a FITS HDU extension to display it:</b></span>";var m=JS9.Mef.imid(c,"Separate");k+=' <span><input type="checkbox" id="'+m+'" name="separate" value="separate" onclick="javascript:JS9.Mef.xseparate(\''+this.display.id+'\', this)"><b> as a separate image</b></span><span style="float: right"><input type="button" class="JS9Button2" id="'+
m+'" name="all" value="Display all images" onclick="javascript:JS9.Mef.xall(\''+this.display.id+"', this)\"></span></div>";this.mefContainer.html(k);for(a=0;a<c.hdus.length;a++){var p=c.hdus[a];k=JS9.hdus2Str([p]).trim();g(p,k,a)}$("#"+m).prop("checked",this.separate);void 0!==c.raw.hdu.fits.extnum&&JS9.Mef.activeExtension(c,c.raw.hdu.fits.extnum)}else this.mefContainer.html("<p><center>No FITS HDU extensions are present in this image.</center>");else this.mefContainer.html("<p><center>FITS HDU extensions will be displayed here.</center>")};
JS9.RegisterPlugin(JS9.Mef.CLASS,JS9.Mef.NAME,JS9.Mef.init,{menuItem:"Extensions",help:"help/mef.html",onplugindisplay:JS9.Mef.init,onimageload:JS9.Mef.init,onimagedisplay:JS9.Mef.display,onimageclose:JS9.Mef.close,winTitle:"Multi-Extension FITS",winResize:!0,winDims:[JS9.Mef.WIDTH,JS9.Mef.HEIGHT]});JS9.Menubar={};JS9.Menubar.CLASS="JS9";JS9.Menubar.NAME="Menubar";JS9.Menubar.WIDTH=JS9.WIDTH||512;JS9.Menubar.HEIGHT="auto";
JS9.Menubar.buttonOptsArr=[{name:"file",label:"File"},{name:"edit",label:"Edit"},{name:"view",label:"View"},{name:"zoom",label:"Zoom"},{name:"scale",label:"Scale"},{name:"color",label:"Color"},{name:"region",label:"Regions"},{name:"wcs",label:"WCS"},{name:"analysis",label:"Analysis"},{name:"help",label:"Help"}];
JS9.Menubar.keyMap={"open ...":"open local file","open local ...":"open local file","toggle: src/bkgd":"toggle selected region: source/background","crosshair for this image":"toggle crosshair","toggle: incl/excl":"toggle selected region: include/exclude","full image":"display full image","selected cutouts":"display selected cutouts","refreshed image":"refresh image","light window":"new JS9 light window","active shape layers":"toggle active shape layers","Keyboard Actions":"toggle keyboard actions plugin",
"Mouse/Touch":"toggle mouse/touch plugin",Preferences:"toggle preferences plugin","Shape Layers":"toggle shape layers plugin",copy:"copy region(s) to clipboard",edit:"edit selected region(s)","paste to current pos":"paste regions to current position","paste to original pos":"paste regions from local clipboard","undo remove":"undo remove of region(s)","to back":"send selected region to back","copy wcs pos":"copy wcs position to clipboard","copy value/pos":"copy value and position to clipboard","zoom 1":"reset zoom",
"zoom in":"zoom in","zoom out":"zoom out"};JS9.menuButtonOptsArr&&(JS9.Menubar.buttonOptsArr=JS9.menuButtonOptsArr);JS9.Menubar.EMPTYIMG="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODYuMTIgMTcxLjkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmVtcHR5PC90aXRsZT48cmVjdCBjbGFzcz0iY2xzLTEiIHdpZHRoPSIxODYuMTIiIGhlaWdodD0iMTcxLjkyIi8+PC9zdmc+";JS9.Menubar.missing={};
JS9.Menubar.menuImage=function(a){var b=a.split("/").reverse()[0];return JS9.Menubar.missing[a]||JS9.Menubar.missing[b]?JS9.Menubar.EMPTYIMG:JS9.inline&&JS9.inline[a]?JS9.inline[a]:JS9.allinone?JS9.Menubar.EMPTYIMG:"/"!==a.charAt(0)?JS9.InstallDir(a):a};
JS9.Menubar.getDisplays=function(a,b){var c,d=[];a=a||"any";b=b||"";if(0<=this.id.search(JS9.SUPERMENU)&&!b.match(/^super_/)){if("all"!==a&&this.selectedDisplay){if(0<=$.inArray(this.selectedDisplay,JS9.displays))return[this.selectedDisplay];this.selectedDislay=null}a=this.divjq.data("displays")||"*";b=a.split(",");if("*"===b[0])for(a=0;a<JS9.displays.length;a++)d.push(JS9.displays[a]);else for(a=0;a<b.length;a++)(c=JS9.lookupDisplay(b[a]))&&d.push(c)}else"*"===this.divjq.data("js9id")&&d.push(JS9.getDynamicDisplayOr(JS9.displays[0]));
d.length||d.push(this.display);return d};
JS9.Menubar.onclick=function(a){var b;"string"===typeof a&&"all"!==a&&(a=JS9.lookupDisplay(a));for(b=0;b<JS9.supermenus.length;b++){var c=JS9.supermenus[b];var d=JS9.Menubar.getDisplays.call(c,"all");if(0<=$.inArray(a,d)||"all"===a)JS9.bugs.webkit_resize?$(".JS9").find(".JS9Image").removeClass("JS9Highlight"):$(".JS9").removeClass("JS9Highlight"),a===c.selectedDisplay||"all"===a?c.selectedDisplay=null:(c.selectedDisplay=a,JS9.bugs.webkit_resize?$(a.divjq).find(".JS9Image").addClass("JS9Highlight"):$(a.divjq).addClass("JS9Highlight"))}};
JS9.Menubar.reset=function(a){JS9.Menubar.rkeyMap=null};
JS9.Menubar.createMenus=function(){var a=this,b=function(a,b,c){({}).hasOwnProperty.call(window,"Jupyter")?(b=a.$trigger.offset(),a.$menu.css({left:b.left+20,top:b.top+10})):a.$menu.position({my:"left top",at:JS9.globalOpts.menuPosition||"left bottom",of:a.$trigger,collision:"fit"})},c=function(){var b=a.display;JS9.bugs.hide_menu&&b.image&&b.image.displayImage("rgb")},d=function(a,b){var c;var d={name:a};var h=JS9.globalOpts.keyboardActions||{},e=JS9.Menubar.keyMap[a];if(!JS9.Menubar.rkeyMap){JS9.Menubar.rkeyMap=
{};var f=$jscomp.makeIterator(Object.keys(h));for(c=f.next();!c.done;c=f.next())c=c.value,JS9.Menubar.rkeyMap[h[c]]=c;JS9.Menubar.keyActions=$.extend(!0,{},h)}if(JS9.notNull(e)&&JS9.Menubar.rkeyMap)(c=JS9.Menubar.rkeyMap[e])&&(d={name:"<span>"+a+'<span class="JS9MenubarKeyAction"> '+c+"</span></span>",isHtmlName:!0});else if(b&&JS9.Menubar.rkeyMap)for(h=$jscomp.makeIterator(Object.keys(JS9.Menubar.rkeyMap)),c=h.next();!c.done;c=h.next())if(c=c.value,c===b&&(c=JS9.Menubar.rkeyMap[c]))d=
"<span>"+a+'<span class="JS9MenubarKeyAction"> '+c+"</span></span>",d={name:d,isHtmlName:!0};return d},f=function(b){var c=b.data;b.preventDefault();$("#"+c.name+"UserMenu"+a.id).contextMenu()},e=function(h){h&&h.name&&h.title&&h.options&&$.contextMenu({selector:"#"+h.name+"UserMenu"+a.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c={};for(b=0;b<h.options.length;b++){var k=h.options[b];var m=d(k.name,k.shortcut);k.image?(m="<div class='JS9MenubarUserImage' name='"+
k.name+"'><img src='"+k.image+"' name='"+h.name+"_"+k.name+"' alt='"+k.name+"' class='JS9MenubarUserImage JS9MenubarUserImageOption' > "+(m.name+"</div>"),c[k.name]={name:m,isHtmlName:!0}):c[k.name]=m}return{callback:function(b,c){JS9.Menubar.getDisplays.call(a).forEach(function(a){var d,g;for(d=0;d<h.options.length;d++)if(k=h.options[d],b===k.name&&(!1===k.requireImage||a.image))if("function"===typeof JS9.publics[k.cmd]){var m="function"===typeof k.args?k.args(a,a.image):JSON.parse(JSON.stringify(k.args||
[]));m.push({display:a});JS9.publics[k.cmd].apply(JS9.publics,$jscomp.arrayFromIterable(m));if(!1!==k.updateTitle)if(k.image&&h.updateTitle&&h.updateTitle.match(/(both|image)/))"both"===h.updateTitle?g="<div style='white-space:nowrap;'><img src='"+k.image+"' name='"+h.name+"' alt='"+k.name+"' class='JS9MenubarUserImage JS9MenubarUserImageTitle' > "+(k.name+"</div>"):"image"===h.updateTitle&&(g="<div style='white-space:nowrap;'><img src='"+k.image+"' name='"+h.name+"' alt='"+k.name+"' class='JS9MenubarUserImage JS9MenubarUserImageTitle' ></div>"),
$(c.selector).html(g);else if("function"===typeof h.updateTitle){try{var e=h.updateTitle(a.image,h.name,k.name)}catch(x){e=k.name||h.name}$(c.selector).text(e)}else h.updateTitle&&k.name&&$(c.selector).text(k.name)}else JS9.error("unknown func for user menubar: "+k.cmd)})},items:c}}})};$("#fileMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#fileMenu"+a.id).contextMenu()});$.contextMenu({selector:"#fileMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,itemClickEvent:JS9.globalOpts.menuClickEvent||
"click",build:function(){var b,c,g="",k=0,m={},e=JS9.Menubar.getDisplays.call(a)[0];var f=e.image;var q=JS9.images.length;for(c=b=0;b<q;b++){var r=JS9.images[b];r.display===e&&c++}if(!c||c>=JS9.globalOpts.imagesFileSubmenu)m.filetitle={name:"Files and Displays:",disabled:!0};if(c&&c<JS9.globalOpts.imagesFileSubmenu){m.imagestitle={name:"Images:",disabled:!0};var v=m}else c&&(m.images={name:"images ...",items:{imagestitle:{name:"display this image:",disabled:!0}}},v=m.images.items);for(b=0;b<q;b++)if(r=
JS9.images[b],r.display===e){var u=r.id;e.rgb.active&&(r===e.rgb.rim&&(u+=" (red)"),r===e.rgb.gim&&(u+=" (green)"),r===e.rgb.bim&&(u+=" (blue)"));v[u]=d(u);e.image&&e.image.id===r.id&&(v[u].icon=JS9.globalOpts.menuSelected)}c&&c<JS9.globalOpts.imagesFileSubmenu&&(m["sep"+k++]="------",m.filetitle={name:"Files and Displays:",disabled:!0});window.electron?m.openboth=d("open ..."):(m.openlocal=d("open local ..."),m.openremote=d("open remote ..."),{}.hasOwnProperty.call(window,"Jupyter")?m.openremote.disabled=
!0:m.openremote.disabled=!1);m.disps={name:"display ...",items:{dispstitle:{name:"display:",disabled:!0}}};m.disps.items.header=d("FITS header");m.disps.items.hdus=d("FITS HDUs");f||(m.disps.items.header.disabled=!0);f&&f.hdus||(m.disps.items.hdus.disabled=!0);m.disps.items.refresh=d("refreshed image");m.disps.items.full=d("full image");m.disps.items.cutout=d("selected cutouts");m.disps.items.pageid=d("page id");f&&f.raw&&f.raw.hdu&&f.raw.hdu.fits||(m.disps.items.refresh.disabled=!0,m.disps.items.full.disabled=
!0,m.disps.items.cutout.disabled=!0);m.moveto={name:"move ...",items:{movetotitle:{name:"move to this display:",disabled:!0}}};if(f){m.moveto.disabled=!1;for(b=0;b<JS9.displays.length;b++)0<$("#"+JS9.displays[b].id).length&&e!==JS9.displays[b]&&(u="moveto_"+JS9.displays[b].id,m.moveto.items[u]=d(JS9.displays[b].id));m.moveto.items.moveto_newdisp=d("a new display")}else m.moveto.disabled=!0;m.separates={name:"separate ...",items:{}};JS9.images.length||(m.separates.disabled=!0);m.separates.items.separate=
d("separate these images");f||(m.separates.items.separate.disabled=!0);m.separates.items.gather=d("gather all images here");f&&1===JS9.images.length&&(m.separates.items.gather.disabled=!0);m.saveas={name:"save ...",items:{saveastitle:{name:"save all data as:",disabled:!0},savefitsentire:d("FITS"),saveastitle2:{name:"save displayed data as:",disabled:!0},savefits:d("FITS"),savejpeg:d("JPEG"),savepng:d("PNG"),saveastitle3:{name:"save memory file as:",disabled:!0},savefitsvirtual:d("FITS")}};f?f.raw.hdu&&
f.raw.hdu.fits&&f.raw.hdu.fits.vfile||(m.saveas.items.savefitsvirtual.disabled=!0):m.saveas.disabled=!0;m.closes={name:"close ...",items:{closestitle:{name:"close:",disabled:!0}}};f||(m.closes.disabled=!0);m.closes.items.close=d("this image");m.closes.items.closeall=d("all images");m.closes.items.free=d("this image's memory");m.closes.items.removeproxy=d("proxy file");f&&f.raw&&f.raw.hdu&&f.raw.hdu.fits||(m.closes.items.free.disabled=!0);f&&f.proxyFile||(m.closes.items.removeproxy.disabled=!0);m.catalogs=
{name:"catalog ...",items:{}};f||(m.catalogs.disabled=!0);m.catalogs.items.loadcatalog=d("load ...");m.catalogs.items.savecatalog=d("save active");m.createmosaic={name:"mosaic ...",items:{createmosaictitle:{name:"create a mosaic using:",disabled:!0},mosaiccurrent:d("images in the current file"),mosaicdisplay:d("images in this display")}};f||(m.createmosaic.disabled=!0);m.sessions={name:"session ...",items:{}};m.sessions.items.loadsession=d("load ...");m.sessions.items.savesession={name:"save ...",
items:{savesessiontitle:{name:"include these images:",disabled:!0},savecurrent:d("the current image"),savedisplay:d("all images in this display")}};m.windows={name:"window ...",items:{windowstitle:{name:"create a new:",disabled:!0}}};m.windows.items.lite=d("light window");m.windows.items.xnew=d("separate window");window.electron&&(m.windows.items.xnew.disabled=!0);window.electron&&(m.electronHelper=d("connect to JS9 helper"),JS9.helper.connected&&(m.electronHelper.disabled=!0));if(a.issuper){c=JS9.Menubar.getDisplays.call(a,
"all");m.supermenu={name:"supermenu ...",items:{supertitle:{name:"target this display:",disabled:!0}}};for(r=b=0;b<c.length;b++)v=c[b],u=v.id,m.supermenu.items["super_"+u]=d(u),a.selectedDisplay===v&&(m.supermenu.items["super_"+u].icon=JS9.globalOpts.menuSelected,r++);m.supermenu.items.super_all=d("all displays");r||(m.supermenu.items.super_all.icon=JS9.globalOpts.menuSelected)}b=e.divjq.closest(".JS9GridContainer");if(!f||e.winid||0<b.length&&1<b.find(".JS9GridItem").length)m.removedisplay=d("remove this display");
m["sep"+k++]="------";m.print=d("print ...");f||(m.print.disabled=!0);window.electron&&(m.windowPrint=d("print window ..."),m.windowPDF=d("save window to pdf"),window.electron.app&&(m.saveScript=d("export messaging script")));for(b=0;b<JS9.plugins.length;b++)if(f=JS9.plugins[b],u=f.name,f.opts.menuItem&&"file"===f.opts.menu&&(r=e.pluginInstances[u],!r||r.winHandle))f.xclass!==g&&(m["sep"+k]="------",k+=1),g=f.xclass,m[u]=d(f.opts.menuItem),r&&"active"===r.status&&(m[u].icon=JS9.globalOpts.menuSelected);
return{callback:function(b,c){var d;JS9.Menubar.getDisplays.call(a,"any",b).forEach(function(c){if(!(0>$.inArray(c,JS9.displays))){if(c)var g=c.image;switch(b){case "refresh":g&&g.raw.hdu&&g.raw.hdu.fits&&g.refreshImage();break;case "full":g&&g.raw.hdu&&g.raw.hdu.fits&&g.displaySection("full");break;case "cutout":g&&g.raw.hdu&&g.raw.hdu.fits&&g.displaySection("selected");break;case "free":g&&g.raw.hdu&&g.raw.hdu.fits&&JS9.cleanupFITSFile(g.raw.hdu.fits,!0);break;case "close":g&&g.closeImage();break;
case "closeall":c&&JS9.CloseDisplay(c.id);break;case "removeproxy":g&&g.removeProxyFile();break;case "removedisplay":c&&JS9.RemoveDisplay(c.id);break;case "savecurrent":c&&g&&JS9.SaveSession({mode:"image"},{display:c});break;case "savedisplay":c&&JS9.SaveSession({mode:"display"},{display:c});break;case "loadsession":c&&JS9.OpenSessionMenu({display:c});break;case "loadcatalog":c&&JS9.OpenCatalogsMenu({display:c});break;case "savecatalog":g&&g.saveCatalog();break;case "mosaiccurrent":c&&g&&JS9.CreateMosaic("current",
{display:c});break;case "mosaicdisplay":c&&JS9.CreateMosaic("all",{display:c});break;case "header":g&&(g.raw.header?g.displayAnalysis("text",JS9.raw2FITS(g.raw,{addcr:!0}),{title:"FITS Header: "+g.id}):JS9.error("no FITS header for "+g.id));break;case "hdus":g&&(g.hdus?g.displayAnalysis("text",JS9.hdus2Str(g.hdus),{title:"FITS HDUs: "+g.id,winformat:"width=800px,height=200px,resize=1,scrolling=1"}):JS9.error("no FITS header for "+g.id));break;case "lite":JS9.LoadWindow(null,{clone:c.id},"light");
break;case "xnew":JS9.LoadWindow(null,null,"new");break;case "electronHelper":if(window.electron)try{window.electron.sendMsg("startHelper")}catch(y){}break;case "pageid":var k="<center><p>pageid: "+(JS9.helper.pageid||"none")+"</center>";c="JS9 page id"+sprintf(JS9.IDFMT,c.id);JS9.lightWin("fileid"+JS9.uniqueID(),"inline",k,c,JS9.lightOpts[JS9.LIGHTWIN].lineWin);break;case "openboth":c&&c.displayLoadForm();break;case "openlocal":c&&JS9.OpenFileMenu({display:c});break;case "openremote":c&&c.displayLoadForm({remote:!0});
break;case "savefits":case "savefitsvirtual":case "savefitsentire":g&&(k=g.id.replace(/\.png/i,".fits").replace(/\[.*\]/,"").replace(/\.gz$/i,"").replace(/\.bz2$/i,"").replace(/\s+/g,"_"),"savefits"===b?g.saveFITS(k,"display"):"savefitsvirtual"===b?g.raw.hdu&&g.raw.hdu.fits&&g.raw.hdu.fits.vfile?(k=g.raw.hdu.fits.vfile.replace(/^bz::/,"").replace(/^gz::/,""),g.saveFITS(k,"virtual")):JS9.error("no memory file available"):g.saveFITS(k));break;case "savepng":g&&(k=g.id.replace(/\.fit[s]?/i,".png").replace(/\[.*\]/,
"").replace(/\.gz$/i,"").replace(/\.bz2$/i,"").replace(/\s+/g,"_"),g.savePNG(k));break;case "savejpeg":g&&(k=g.id.replace(/\.fit[s]?/i,".jpeg").replace(/\.png$/i,".jpeg").replace(/\.gz$/i,"").replace(/\[.*\]/,""),g.saveJPEG(k));break;case "print":g&&g.print();break;case "windowPrint":window.electron&&JS9.WindowPrint();break;case "windowPDF":window.electron&&JS9.WindowToPDF();break;case "saveScript":window.electron&&window.electron.app&&JS9.SaveScript();break;case "separate":c&&c.separate();break;
case "gather":c&&(0<=a.id.search(JS9.SUPERMENU)&&!a.selectedDisplay&&JS9.error("gather requires a selected display"),c.gather());break;default:if(b.match(/^super_/))k=b.replace(/^super_/,""),JS9.Menubar.onclick.call(a,k);else if(b.match(/^moveto_/))k=b.replace(/^moveto_/,""),"newdisp"===k?c.separate({images:[g],firstinplace:!1}):g.moveToDisplay(k);else{for(k=0;k<JS9.plugins.length;k++)if(d=JS9.plugins[k],d.name===b){c.displayPlugin(d);return}for(k=0;k<JS9.images.length;k++){g=JS9.images[k];var h=
b.replace(/ *\((red|green|blue)\)/,"");if(c.id===g.display.id&&g.id===h){g.displayImage("all");g.refreshLayers();c.clearMessage();break}}}}}})},items:m}}});$("#editMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#editMenu"+a.id).contextMenu()});$.contextMenu({selector:"#editMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b=0,c={edittitle1:{name:"Regions:",disabled:!0}};c.configReg=d("edit");c.copyReg=d("copy");c.pastePos=d("paste to current pos");
c.pasteReg=d("paste to original pos");c.undoRemove=d("undo remove");c["sep"+b++]="------";c.edittitle2={name:"Position/Value:",disabled:!0};c.copyWCSPos=d("copy wcs pos");c.copyValPos=d("copy value/pos");return{callback:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(b){case "configReg":c&&(a=c.layers.regions)&&((a=a.canvas.getActiveObject())&&"activeSelection"!==a.type?c.displayRegionsForm(a):c.displayRegionsForm(null,{multi:!0}));
break;case "copyReg":c&&(c=c.listRegions(null,{mode:1}),JS9.CopyToClipboard(c));break;case "pasteReg":c&&JS9.Regions.pasteFromClipboard.call(c);break;case "pastePos":c&&JS9.Regions.pasteFromClipboard.call(c,!0);break;case "undoRemove":c&&c.unremoveRegions();break;case "copyWCSPos":if({}.hasOwnProperty.call(JS9,"Keyboard"))JS9.Keyboard.Actions["copy wcs position to clipboard"](c,c.ipos);break;case "copyValPos":if({}.hasOwnProperty.call(JS9,"Keyboard"))JS9.Keyboard.Actions["copy value and position to clipboard"](c,
c.ipos)}})},items:c}}});$("#viewMacMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#viewMacMenu"+a.id).contextMenu()});$.contextMenu({selector:"#viewMacMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c={edittitle1:{name:"View:",disabled:!0}};for(b=0;b<a.macmenus.length;b++){var d=a.macmenus[b];c[d.name]={name:d.title+" ..."}}return{callback:function(b){$("#"+b+"Menu"+a.id).contextMenu()},items:c}}});$("#viewMenu"+this.id).on("mousedown",function(b){b.preventDefault();
$("#viewMenu"+a.id).contextMenu()});$.contextMenu({selector:"#viewMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c="",g=0,k={},f=JS9.Menubar.getDisplays.call(a)[0],e=f.image,n=function(a,b){delete f.tmp.editingMenu;if(b.resize){var c=b.resize.split(/[\s,/]+/);switch(c.length){case 0:break;case 1:e?(b=e.wcs2imlen(c[0]),a.resize(b,b)):JS9.isNumber(c[0])&&(b=parseInt(c[0],10),a.resize(b,b));break;default:e&&e.wcs?(b=e.wcs2imlen(c[0]),c=e.wcs2imlen(c[1]),a.resize(b,
c)):JS9.isNumber(c[0])&&JS9.isNumber(c[1])&&(b=parseInt(c[0],10),c=parseInt(c[1],10),a.resize(b,c))}}};k["sep"+g++]={name:"Plugins:"};k["sep"+(g-1)].disabled=!0;for(b=0;b<JS9.plugins.length;b++){var q=JS9.plugins[b];var r=q.name;if(q.opts.menuItem&&"view"===q.opts.menu){var v=f.pluginInstances[r];if(!v||v.winHandle)q.xclass!==c&&(g+=1),c=q.xclass,k[r]=d(q.opts.menuItem),v&&"active"===v.status&&(k[r].icon=JS9.globalOpts.menuSelected)}}k["sep"+g++]="------";k.vdispstitle={name:"Display Options:",disabled:!0};
k.vdisps={name:"show ...",items:{vdispstitle:{name:"show options:",disabled:!0}}};k.vdisps.items.valpos={name:"value/position ...",items:{valpostitle:{name:"value/pos options:",disabled:!0},valpos:d("update value/pos"),valposcolor:{events:{keyup:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:delete f.tmp.editingMenu;c.valposcolor&&(JS9.textColorOpts.info=c.valposcolor,
a&&a.image&&a.image.updateValpos(a.image.ipos,!0));break;default:a.tmp.editingMenu=!0}})}},name:"value/pos color:",type:"text"},valposdisp:d("also show display coords")}};({}).hasOwnProperty.call(JS9,"Info")?f.image&&(f.image.params.valpos&&(k.vdisps.items.valpos.icon=JS9.globalOpts.menuSelected,k.vdisps.items.valpos.items.valpos.icon=JS9.globalOpts.menuSelected),JS9.globalOpts.valposDCoords&&(k.vdisps.items.valpos.items.valposdisp.icon=JS9.globalOpts.menuSelected)):k.vdisps.items.valpos.disabled=
!0;k.vdisps.items.toggleLayers=d("active shape layers");e&&!e.toggleLayers&&(k.vdisps.items.toggleLayers.icon=JS9.globalOpts.menuSelected);k.vdisps.items.xhair=d("crosshair for this image");({}).hasOwnProperty.call(JS9,"Crosshair")&&e?e&&e.params.crosshair&&(k.vdisps.items.xhair.icon=JS9.globalOpts.menuSelected):k.vdisps.items.xhair.disabled=!0;k.vdisps.items.xhairwcs=d("match wcs crosshairs");({}).hasOwnProperty.call(JS9,"Crosshair")?JS9.globalOpts.wcsCrosshair&&(k.vdisps.items.xhairwcs.icon=JS9.globalOpts.menuSelected):
k.vdisps.items.xhairwcs.disabled=!0;k.vdisps.items.toolbar=d("toolbar tooltips");({}).hasOwnProperty.call(JS9,"Toolbar")?JS9.GetToolbar("showTooltips")&&(k.vdisps.items.toolbar.icon=JS9.globalOpts.menuSelected):k.vdisps.items.toolbar.disabled=!0;JS9.allinone||(k.vdisps.items.logo=d("js9 logo"),JS9.globalOpts.logoDisplay&&(k.vdisps.items.logo.icon=JS9.globalOpts.menuSelected));k.vdisps.items.inherit=d("new images inherit current params");f.image&&f.image.params.inherit&&(k.vdisps.items.inherit.icon=
JS9.globalOpts.menuSelected);k.vdisps.items.rawlayer={name:"raw data sources ...",items:{}};if(e&&1<e.raws.length){k.vdisps.items.rawlayer.items.whichrawtitle={name:"current raw data:"};for(b=0;b<e.raws.length;b++)q="rawlayer_"+e.raws[b].id,k.vdisps.items.rawlayer.items[q]={name:e.raws[b].id},e.raw===e.raws[b]&&(k.vdisps.items.rawlayer.items[q].icon=JS9.globalOpts.menuSelected);k.vdisps.items.rawlayer.items["sep"+g++]="------";k.vdisps.items.rawlayer.items.rawlayer_remove=d("remove")}else k.vdisps.items.rawlayer.disabled=
!0;k.resizes={name:"resize ...",items:{resizestitle:{name:"resize the display:",disabled:!0}}};k.resizes.items.resize={events:{keyup:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:n(a,c);break;default:a.tmp.editingMenu=!0}})}},name:"change width/height:",type:"text"};k.resizes.items.imagesize=d("set to image size");k.resizes.items.fullsize=d("set size to full window");
k.resizes.items.resetsize=d("reset to original size");JS9.globalOpts.resize?e||(k.resizes.items.imagesize.disabled=!0):(k.resizes.items.resize.disabled=!0,k.resizes.items.fullsize.disabled=!0,k.resizes.items.imagesize.disabled=!0,k.resizes.items.resetsize.disabled=!0);return{callback:function(c){JS9.Menubar.getDisplays.call(a).forEach(function(a){var d=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(c){case "valpos":d&&d.toggleValpos();break;case "valposdisp":JS9.globalOpts.valposDCoords=!JS9.globalOpts.valposDCoords;
break;case "xhair":d&&d.toggleCrosshair();break;case "xhairwcs":d&&d.toggleWCSCrosshair();break;case "toolbar":a=!JS9.GetToolbar("showTooltips");JS9.SetToolbar("showTooltips",a);break;case "logo":JS9.globalOpts.logoDisplay=!JS9.globalOpts.logoDisplay;a=JS9.globalOpts.logoDisplay?"block":"none";for(d=0;d<JS9.displays.length;d++)JS9.displays[d].iconjq.css("display",a);break;case "toggleLayers":d&&d.toggleShapeLayers();break;case "inherit":d&&(d.params.inherit=!d.params.inherit);break;case "fullsize":a.resize("full",
{center:!0});break;case "imagesize":a.resize("image");break;case "resetsize":a.resize("reset");break;default:for(d=0;d<JS9.plugins.length;d++){var g=JS9.plugins[d];if(g.name===c){a.displayPlugin(g);return}}if(e&&c.match(/^rawlayer_/))if(a=c.replace(/^rawlayer_/,""),"remove"===a){if(e.raw.id!==JS9.RAWID0)for(b=0;b<e.raws.length;b++)e.raw===e.raws[b]&&e.rawDataLayer(e.raw.id,"remove")}else e.rawDataLayer(a)}})},events:{show:function(b){var c=a.display,d={};c&&(d.resize=sprintf("%d %d",c.width,c.height),
d.valposcolor=JS9.textColorOpts.info,$.contextMenu.setInputValues(b,d),JS9.jupyterFocus(".context-menu-item"))},hide:function(b){var c=a.display;c&&c.tmp.editingMenu&&(b=$.contextMenu.getInputValues(b),n(c,b))}},items:k}}});$("#zoomMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#zoomMenu"+a.id).contextMenu()});$.contextMenu({selector:"#zoomMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c="",g=0,k=JS9.Menubar.getDisplays.call(a)[0];var e=k.image;
var f=function(a,b){delete k.tmp.editingMenu;Number.isNaN(b.zoom)||a.setZoom(b.zoom)},n=function(a,b){delete k.tmp.editingMenu2;Number.isNaN(b.rotate)||a.setRotate(b.rotate)},q={zoomtitle:{name:"Zoom Factors:",disabled:!0}};for(b=JS9.imageOpts.topZooms;1<=b;b--){var r=Math.pow(2,-b);var v=Math.pow(2,b);var u="zoom"+r;v="zoom 1/"+v;q[u]=d(v);e&&e.rgb.sect.zoom===r&&(q[u].icon=JS9.globalOpts.menuSelected)}for(b=0;b<=JS9.imageOpts.topZooms;b++)r=Math.pow(2,b),u="zoom"+r,v="zoom "+r,q[u]=d(v),e&&e.rgb.sect.zoom===
r&&(q[u].icon=JS9.globalOpts.menuSelected);q.morezooms={name:"more zooms ...",items:{morezoomstitle:{name:"Zoom Factors:",disabled:!0}}};for(b=JS9.imageOpts.zooms;b>JS9.imageOpts.topZooms;b--)r=Math.pow(2,-b),v=Math.pow(2,b),u="zoom"+r,v="zoom 1/"+v,q.morezooms.items[u]=d(v),e&&e.rgb.sect.zoom===r&&(q.morezooms.items[u].icon=JS9.globalOpts.menuSelected);for(b=JS9.imageOpts.topZooms+1;b<=JS9.imageOpts.zooms;b++)r=Math.pow(2,b),u="zoom"+r,v="zoom "+r,q.morezooms.items[u]=d(v),e&&e.rgb.sect.zoom===r&&
(q.morezooms.items[u].icon=JS9.globalOpts.menuSelected);q.zoom={events:{keyup:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode,g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:g&&f(g,c);break;default:a.tmp.editingMenu=!0}})}},name:"numeric zoom:",type:"text"};q["sep"+g++]="------";q.zoomiotitle={name:"Zoom In/Out:",disabled:!0};q.zoomIn=d("zoom in");q.zoomOut=d("zoom out");q.zoomToFit=d("zoom to fit");
q["sep"+g++]="------";q.panzoomtitle={name:"Pand and Zoom:",disabled:!0};q.center=d("pan to center");q.alignpanzoom={name:"align pan/zoom ...",items:{alignpanzoomtitle:{name:"to this image:",disabled:!0}}};for(r=b=0;b<JS9.images.length;b++)!JS9.images[b].raw.wcs||e===JS9.images[b]&&0>a.id.search(JS9.SUPERMENU)||(u="alignpanzoom_"+JS9.images[b].id,q.alignpanzoom.items[u]={name:JS9.images[b].id},r++);0===r?q.alignpanzoom.items.notasks={name:"[none]",disabled:!0,events:{keyup:function(){}}}:q.alignpanzoom.disabled=
!1;q.reset=d("reset pan/zoom");q.pantoclick={name:"(pan to mouse: Meta-click)",disabled:!0};q["sep"+g++]="------";q.fliptitle={name:"Flip:",disabled:!0};q.flipX=d("x axis");e&&e.raw&&e.raw.hdu&&e.raw.hdu.fits||(q.flipX.disabled=!0);q.flipY=d("y axis");e&&e.raw&&e.raw.hdu&&e.raw.hdu.fits||(q.flipY.disabled=!0);q["sep"+g++]="------";q.rot90title={name:"Rotate:",disabled:!0};q.rot90_90=d("90 left");e&&e.raw&&e.raw.hdu&&e.raw.hdu.fits||(q.rot90_90.disabled=!0);q.rot90_270=d("90 right");e&&e.raw&&e.raw.hdu&&
e.raw.hdu.fits||(q.rot90_270.disabled=!0);q.rotate={events:{keyup:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode,g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:g&&n(g,c);break;default:a.tmp.editingMenu2=!0}})}},name:"rotation angle:",type:"text"};q["sep"+g++]="------";q.northisup=d("align: north is up");if(!(e&&e.raw&&e.raw.hdu&&e.raw.hdu.fits&&e.raw.wcs)||0>=e.raw.wcs)q.northisup.disabled=!0;q.resetall=
d("reset flip/rot90/rotate");q["sep"+g++]="------";for(b=0;b<JS9.plugins.length;b++)if(e=JS9.plugins[b],r=e.name,e.opts.menuItem&&"zoom"===e.opts.menu&&(u=k.pluginInstances[r],!u||u.winHandle))e.xclass!==c&&(g+=1),c=e.xclass,q[r]=d(e.opts.menuItem),u&&"active"===u.status&&(q[r].icon=JS9.globalOpts.menuSelected);return{callback:function(b){var c,d;JS9.Menubar.getDisplays.call(a).forEach(function(a){var g=a.image;if(!(0>$.inArray(a,JS9.displays))&&g)switch(b){case "zoomIn":g.setZoom("x2");break;case "zoomOut":g.setZoom("/2");
break;case "zoomToFit":g.setZoom("tofit");break;case "center":g.setPan();break;case "reset":g.setZoom("1");g.setPan();break;case "flipX":g.setFlip("x");break;case "flipY":g.setFlip("y");break;case "rot90_90":g.setRot90(90);break;case "rot90_270":g.setRot90(-90);break;case "northisup":g.setRot90("reset");g.setRotate("northisup");break;case "resetall":g.setFlip("reset");g.setRot90("reset");g.setRotate("reset");break;default:for(c=0;c<JS9.plugins.length;c++)if(d=JS9.plugins[c],d.name===b){a.displayPlugin(d);
return}b.match(/^zoom/)?g.setZoom(b.slice(4)):b.match(/^alignpanzoom_/)&&g.alignPanZoom(b.slice(13))}})},events:{show:function(b){var c=a.display.image,d={};c&&(d.zoom=JS9.floatToString(c.rgb.sect.zoom),d.rotate=JS9.floatToString(c.params.rotate||0));$.contextMenu.setInputValues(b,d);JS9.jupyterFocus(".context-menu-item")},hide:function(b){var c=a.display,d=c.image;if(d){if(c.tmp.editingMenu){var g=$.contextMenu.getInputValues(b);f(d,g)}c.tmp.editingMenu2&&(g=$.contextMenu.getInputValues(b),n(d,g))}}},
items:q}}});$("#scaleMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#scaleMenu"+a.id).contextMenu()});$.contextMenu({selector:"#scaleMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c,g="",e=0,f={},p=JS9.Menubar.getDisplays.call(a)[0],n=function(a,b){var c=a.params.scalemin,d=a.params.scalemax;delete p.tmp.editingMenu;JS9.isNumber(b.scalemin)&&(c=parseFloat(b.scalemin));JS9.isNumber(b.scalemax)&&(d=parseFloat(b.scalemax));a.setScale(c,d);a.displayImage("colors")};
var q=function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode,g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:g&&n(g,c);break;default:a.tmp.editingMenu=!0}})};f.scaletitle={name:"Scaling Algorithms:",disabled:!0};for(b=0;b<JS9.scales.length;b++){var r=c=JS9.scales[b];f[c]=d(r);p.image&&p.image.params.scale===c&&(f[c].icon=JS9.globalOpts.menuSelected)}f["sep"+e++]="------";f.dlims={name:"data limits ...",items:{title:{name:"set data limits to:",
disabled:!0},dataminmax:{name:"data min/max"},zscale:{name:"zscale z1/z2"},zmax:{name:"zscale z1/data max"}}};f.scalemin={events:{keyup:q},name:"low:",type:"text"};f.scalemax={events:{keyup:q},name:"high:",type:"text"};f["sep"+e++]="------";for(b=0;b<JS9.plugins.length;b++)if(c=JS9.plugins[b],r=c.name,c.opts.menuItem&&"scale"===c.opts.menu&&(q=p.pluginInstances[r],!q||q.winHandle))c.xclass!==g&&(e+=1),g=c.xclass,f[r]=d(c.opts.menuItem),q&&"active"===q.status&&(f[r].icon=JS9.globalOpts.menuSelected);
return{callback:function(b){var c,d;JS9.Menubar.getDisplays.call(a).forEach(function(a){var g=a.image;if(!(0>$.inArray(a,JS9.displays))&&g){for(c=0;c<JS9.plugins.length;c++)if(d=JS9.plugins[c],d.name===b){a.displayPlugin(d);return}g.setScale(b)}})},events:{show:function(b){var c=a.display.image,d={};c&&(d.scalemin=JS9.floatToString(c.params.scalemin),d.scalemax=JS9.floatToString(c.params.scalemax));$.contextMenu.setInputValues(b,d);JS9.jupyterFocus(".context-menu-item")},hide:function(b){var c=a.display,
d=c.image;d&&c.tmp.editingMenu&&(b=$.contextMenu.getInputValues(b),n(d,b))}},items:f}}});$("#colorMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#colorMenu"+a.id).contextMenu()});$.contextMenu({selector:"#colorMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c,g="",e=0,f={},p=JS9.Menubar.getDisplays.call(a)[0],n=function(a,b){delete p.tmp.editingMenu;b.contrast&&!Number.isNaN(b.contrast)&&(a.params.contrast=parseFloat(b.contrast));b.bias&&!Number.isNaN(b.bias)&&
(a.params.bias=parseFloat(b.bias));b.opacity.match(/reset/)||""===b.opacity.trim()?a.setOpacity("reset"):Number.isNaN(b.opacity)||a.setOpacity(parseFloat(b.opacity));a.displayImage("colors")};var q=function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode,g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:n(g,c);break;default:a.tmp.editingMenu=!0}})};f.cmaptitle={name:"Colormaps:",disabled:!0};for(b=0;b<JS9.globalOpts.topColormaps.length;b++){var r=
c=JS9.globalOpts.topColormaps[b];if(JS9.globalOpts.menuImages){var v=JS9.Menubar.menuImage("images/voyager/color_"+r+".png");r="<div class='JS9MenubarImage' name='"+r+"'><img src='"+v+"' name='color_"+r+"' class='JS9MenubarImage JS9MenubarImageOption' onerror='JS9.Menubar.missing[\"color_"+r+'.png"]=true; this.src="'+JS9.Menubar.EMPTYIMG+"\"' > "+(r+"</div>");f[c]={name:r,isHtmlName:!0}}else f[c]=d(r);p.image&&p.image.cmapObj.name===c&&(f[c].icon=JS9.globalOpts.menuSelected)}f.morecmaps=
{name:"more colormaps ...",items:{morecmapstitle:{name:"Colormaps:",disabled:!0}}};for(b=0;b<JS9.colormaps.length;b++)c=JS9.colormaps[b].name,JS9.globalOpts.topColormaps.includes(c)||(r=c,JS9.globalOpts.menuImages?(v=JS9.Menubar.menuImage("images/voyager/color_"+r+".png"),r="<div class='JS9MenubarImage' name='"+r+"'><img src='"+v+"' name='color_"+r+"' class='JS9MenubarImage JS9MenubarImageOption' onerror='JS9.Menubar.missing[\"color_"+r+'.png"]=true; this.src="'+JS9.Menubar.EMPTYIMG+"\"' > "+
(r+"</div>"),f.morecmaps.items[c]={name:r,isHtmlName:!0}):f.morecmaps.items[c]=d(r),p.image&&p.image.cmapObj.name===c&&(f.morecmaps.items[c].icon=JS9.globalOpts.menuSelected));f["sep"+e++]="------";f.imfilter=d("image filters ...");f["sep"+e++]="------";f.contrast={events:{keyup:q},name:"contrast:",type:"text"};f.bias={events:{keyup:q},name:"bias:",type:"text"};f.reset=d("reset contrast & bias");f["sep"+e++]="------";f.opacity={events:{keyup:q},name:"opacity:",type:"text"};f["sep"+e++]="------";f.loadcmap=
d("load ...");f.savecmap=d("save");f["sep"+e++]="------";f.invert=d("invert");p.image&&p.image.params.invert&&(f.invert.icon=JS9.globalOpts.menuSelected);f.rgb=d("rgb mode");p.rgb.active&&(f.rgb.icon=JS9.globalOpts.menuSelected);p.image&&p.image.offscreen&&!p.image.rgbFile&&(f.overlay=d("image overlay"),p.image.params.overlay&&(f.overlay.icon=JS9.globalOpts.menuSelected));f["sep"+e++]="------";for(b=0;b<JS9.plugins.length;b++)if(c=JS9.plugins[b],q=c.name,c.opts.menuItem&&"color"===c.opts.menu&&(r=
p.pluginInstances[q],!r||r.winHandle))c.xclass!==g&&(e+=1),g=c.xclass,f[q]=d(c.opts.menuItem),r&&"active"===r.status&&(f[q].icon=JS9.globalOpts.menuSelected);return{callback:function(b){var c,d;JS9.Menubar.getDisplays.call(a).forEach(function(a){var g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(b){case "loadcmap":JS9.OpenColormapMenu({display:a});break;case "savecmap":JS9.SaveColormap({display:a});break;case "imfilter":JS9.DisplayPlugin("JS9Filters",{display:a});break;default:for(c=0;c<JS9.plugins.length;c++)if(d=
JS9.plugins[c],d.name===b){a.displayPlugin(d);return}g&&g.setColormap(b)}})},events:{show:function(b){var c=a.display.image,d={};c&&(d.contrast=JS9.floatToString(c.params.contrast),d.bias=JS9.floatToString(c.params.bias),d.opacity=JS9.floatToString(c.params.opacity),d.sigma=JS9.floatToString(c.params.sigma));$.contextMenu.setInputValues(b,d);JS9.jupyterFocus(".context-menu-item")},hide:function(b){var c=a.display,d=c.image;d&&c.tmp.editingMenu&&(b=$.contextMenu.getInputValues(b),n(d,b))}},items:f}}});
$("#regionMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#regionMenu"+a.id).contextMenu()});$.contextMenu({selector:"#regionMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b,c=JS9.Menubar.getDisplays.call(a)[0].image,g={},e=function(a,b){switch(a){case "color":if("#"!==b.charAt(0)&&JS9.colorToHex(b)===b)return null;break;case "strokeWidth":if(!JS9.isNumber(b))return null;b=parseFloat(b);break;case "strokeDashArray":b=b.split(/[\s,]+/);if(!b||!b.length)return null;
2>b.length&&(b[1]="0");if(!JS9.isNumber(b[0])||!JS9.isNumber(b[1]))return null;b[0]=parseFloat(b[0]);b[1]=parseFloat(b[1])}return b};g.regiontitle={name:"Regions:",disabled:!0};if(JS9.globalOpts.menuImages)for(b=0;b<JS9.regions.length;b++){var f=JS9.regions[b];var p=JS9.Menubar.menuImage("images/voyager/regions_"+f+".svg");g[f]={name:"<div class='JS9MenubarImage' name='"+f+"'><img src='"+p+"' name='regions_"+f+"' class='JS9MenubarImage JS9MenubarImageOption' onerror='JS9.Menubar.missing[\"regions_"+
f+'.svg"]=true; this.src="'+JS9.Menubar.EMPTYIMG+"\"' > "+(f+"</div>"),isHtmlName:!0}}else for(b=0;b<JS9.regions.length;b++)f=JS9.regions[b],g[f]=d(f);g.sep1="------";g.createRegions=d("menu adds region @ center");JS9.globalOpts.regMenuCreate&&(g.createRegions.icon=JS9.globalOpts.menuSelected);b=$jscomp.makeIterator(Object.keys(JS9.globalOpts.keyboardActions));for(f=b.next();!f.done;f=b.next())f=f.value,"add last region selected in regions menu"===JS9.globalOpts.keyboardActions[f]&&(g.notCreateRegions=
{name:"('"+f+"' adds region @ mouse)",disabled:!0});g.sep1a="------";g.listRegions=d("list");g.loadRegions=d("load ...");g.saveRegions=d("save ...");g.copyto={name:"copy to ...",items:{copytotitle:{name:"choose image:",disabled:!0}}};g.removeRegions=d("remove");g.sep2="------";g.selectRegions=d("select all");g.unselectRegions=d("unselect all");g.selectedRegions=d("selected ...");g.sep3="------";g.onchange={name:"onchange ...",items:{listonchange:d("list on change"),xeqonchange:d("xeq on change")}};
c&&c.params.listonchange&&(g.onchange.items.listonchange.icon=JS9.globalOpts.menuSelected);c&&c.params.xeqonchange&&(g.onchange.items.xeqonchange.icon=JS9.globalOpts.menuSelected);if(c&&1<JS9.images.length){for(b=0;b<JS9.images.length;b++)c!==JS9.images[b]&&(f="copyto_"+JS9.images[b].id,g.copyto.items[f]=d(JS9.images[b].id));g.copyto.items.copyto_all=d("all images");g.copyto.disabled=!1}else g.copyto.disabled=!0;({}).hasOwnProperty.call(JS9,"Info")||(g.listRegions.disabled=!0);return{callback:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=
a.image;if(!(0>$.inArray(a,JS9.displays))&&c)switch(b){case "loadRegions":JS9.OpenRegionsMenu({display:a});break;case "listRegions":c.listRegions(null,{mode:2});break;case "createRegions":JS9.globalOpts.regMenuCreate=!JS9.globalOpts.regMenuCreate;break;case "removeRegions":c.removeShapes("regions",null);a.clearMessage("regions");break;case "saveRegions":if(a=c.layers.regions){a=a.canvas.getActiveObject();var d={type:"save"};a&&"activeSelection"!==a.type?c.displayRegionsForm(a,d):c.displayRegionsForm(null,
d)}break;case "selectRegions":if({}.hasOwnProperty.call(JS9,"Keyboard"))JS9.Keyboard.Actions["select all regions"](c,c.ipos);break;case "unselectRegions":if({}.hasOwnProperty.call(JS9,"Keyboard"))JS9.Keyboard.Actions["unselect all regions"](c,c.ipos);break;case "selectedRegions":if(a=c.layers.regions)(a=a.canvas.getActiveObject())&&"activeSelection"!==a.type?c.displayRegionsForm(a):c.displayRegionsForm(null,{multi:!0});break;case "xeqonchange":c.params.xeqonchange=!c.params.xeqonchange;break;case "listonchange":c.params.listonchange=
!c.params.listonchange;break;default:b.match(/^copyto_/)?(a=b.replace(/^copyto_/,""),c.copyRegions(a)):(JS9.globalOpts.regMenuSelected=b,JS9.globalOpts.regMenuCreate&&c.addShapes("regions",b,{ireg:!0}))}})},events:{show:function(a){$.contextMenu.setInputValues(a,{color:""});JS9.jupyterFocus(".context-menu-item")},hide:function(b){var c=a.display.image;if(c){var d=$.contextMenu.getInputValues(b);var g=void 0;b={};d=d||{};if(g){var f=g.substring(3);var k=d[g];f&&k&&c.tmp["editingReg"+g]&&(delete c.tmp["editingReg"+
g],k=e(f,k))&&(b[f]=k,c.changeShapes("regions","selected",b))}else{var h=$jscomp.makeIterator(Object.keys(d));for(g=h.next();!g.done;g=h.next())g=g.value,f=g.substring(3),k=d[g],f&&k&&c.tmp["editingReg"+g]&&(delete c.tmp["editingReg"+g],(k=e(f,k))&&(b[f]=k));Object.keys(b).length&&c.changeShapes("regions","selected",b)}}}},items:g}}});$("#wcsMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#wcsMenu"+a.id).contextMenu()});$.contextMenu({selector:"#wcsMenu"+this.id,zIndex:JS9.MENUZINDEX,
events:{hide:c},position:b,build:function(){var b,c,g=0,f=0,e=0,p={},n=JS9.Menubar.getDisplays.call(a)[0],q=n.image,r=function(a,b){delete n.tmp.editingMenu;JS9.isNumber(b.rot)&&a.rotateData(parseFloat(b.rot))};p.wcssystitle={name:"WCS Systems:",disabled:!0};var v=!q||q&&q.validWCS()?JS9.wcssyss:["image","physical"];for(b=0;b<v.length;b++){var u=c=v[b];p[c]=d(u);q&&q.params.wcssys===c&&(p[c].icon=JS9.globalOpts.menuSelected,e++)}e||(c=!q||q&&q.validWCS()?"native":"image",p[c].icon=JS9.globalOpts.menuSelected);
p["sep"+g++]="------";p.wcsutitle={name:"WCS Units:",disabled:!0};v=!q||q&&q.validWCS()?JS9.wcsunitss:["pixels"];for(b=0;b<v.length;b++)u=c=v[b],p[c]=d(u),q&&q.params.wcsunits===c&&(p[c].icon=JS9.globalOpts.menuSelected);p["sep"+g++]="------";p.altwcs={name:"alternate wcs",items:{altwcstitle:{name:"choose a wcs:",disabled:!0}}};if(q&&q.raw&&q.raw.altwcs){v=q.raw.altwcs;e=$jscomp.makeIterator(Object.keys(v));for(c=e.next();!c.done;c=e.next()){var t=c.value;c="altwcs_"+t;u=v[t].header.WCSNAME?v[t].header.WCSNAME+
" ("+t+")":t;p.altwcs.items[c]=d(u);q.raw.wcs===v[t].wcs&&(p.altwcs.items[c].icon=JS9.globalOpts.menuSelected);f++}2>f&&(p.altwcs.disabled=!0,p.altwcs.items.notasks={name:"[none]",disabled:!0,events:{keyup:function(){}}})}else p.altwcs.disabled=!0;p["sep"+g++]="------";p.reproject={name:"wcs reproject ...",items:{reprojtitle:{name:"this image, using the wcs from:",disabled:!0}}};for(f=b=0;b<JS9.images.length;b++)!JS9.images[b].raw.wcs||q===JS9.images[b]&&0>a.id.search(JS9.SUPERMENU)||(c="reproject_"+
JS9.images[b].id,p.reproject.items[c]={name:JS9.images[b].id},f++);0===f?p.reproject.items.notasks={name:"[none]",disabled:!0,events:{keyup:function(){}}}:(p.reproject.disabled=!1,p.reproject.items["sep"+g++]="------",p.reproject.items.reproject_all={name:"all images in this display, using this wcs"},p.reproject.items["sep"+g++]="------",p.reproject.items.reproject_wcsalign={name:"display wcs-aligned"},q&&q.params.wcsalign&&(p.reproject.items.reproject_wcsalign.icon=JS9.globalOpts.menuSelected));
p.reproject.items["sep"+g++]="------";p.reproject.items.rotatetitle={name:"by rotating this image:",disabled:!0};p.reproject.items.reproject_northup={name:"so north is up"};p.reproject.items.rot={events:{keyup:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode,g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:g&&r(g,c);break;default:a.tmp.editingMenu=!0}})}},name:"by this angle in deg:",type:"text"};q&&
q.raw&&q.raw.header&&q.raw.wcsinfo||(p.reproject.disabled=!0);p.reproject.items["sep"+g++]="------";p.reproject.items.reproject_revert={name:"revert"};return{callback:function(c){JS9.Menubar.getDisplays.call(a).forEach(function(a){var d=new RegExp(c),g=a.image;if(!(0>$.inArray(a,JS9.displays))&&g)if(c.match(/^altwcs_/))a=c.replace(/^altwcs_/,""),g.setWCS(a);else if(c.match(/^reproject_/))if("reproject_wcsalign"===c)g.params.wcsalign=!g.params.wcsalign,g.displayImage("display");else if("reproject_northup"===
c)g.rotateData("northisup");else if("reproject_revert"===c){if(g.raw.id!==JS9.RAWID0)for(b=0;b<g.raws.length;b++)g.raw===g.raws[b]&&g.rawDataLayer(g.raw.id,"remove")}else"reproject_all"===c?g.reprojectData("all"):(a=c.replace(/^reproject_/,""),g.reprojectData(a));else 0<=JS9.wcssyss.join("@").search(d)?(g.setWCSSys(c),g.updateShapes("regions","all","wcs")):0<=JS9.wcsunitss.join("@").search(d)?(g.setWCSUnits(c),g.updateShapes("regions","all","wcs")):JS9.error("unknown wcs sys/units: "+c)})},events:{show:function(b){var c=
{};a.display.image&&(c.rot="",$.contextMenu.setInputValues(b,c),JS9.jupyterFocus(".context-menu-item"))},hide:function(b){var c=a.display,d=c.image;d&&(b=$.contextMenu.getInputValues(b),c.tmp.editingMenu&&r(d,b))}},items:p}}});$("#analysisMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#analysisMenu"+a.id).contextMenu()});$.contextMenu({selector:"#analysisMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},position:b,build:function(){var b;var c="";var g=0,f=0,e={},p=JS9.Menubar.getDisplays.call(a)[0],
n=p.image,q=function(a,b){delete p.tmp.editingMenu;b.sigma=b.sigma||"0";"none"===b.sigma&&(b.sigma="0");try{a.params.sigma=parseFloat(b.sigma)}catch(z){a.params.sigma=0}a.gaussBlurData(a.params.sigma)},r=function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c=$.contextMenu.getInputValues(b.data),d=b.which||b.keyCode,g=a.image;if(!(0>$.inArray(a,JS9.displays)))switch(d){case 9:case 13:q(g,c);break;default:a.tmp.editingMenu=!0}})};for(b=0;b<JS9.plugins.length;b++){var v=JS9.plugins[b];
var u=v.name;if(v.opts.menuItem&&"analysis"===v.opts.menu){var t=p.pluginInstances[u];if(!t||t.winHandle)v.xclass!==c&&(0<g&&(e["sep"+g++]="------"),e["sep"+g++]={name:v.xclass+" Plugins:"},e["sep"+(g-1)].disabled=!0),c=v.xclass,e[u]={name:v.opts.menuItem},t&&"active"===t.status&&(e[u].icon=JS9.globalOpts.menuSelected),g++}}if(!JS9.allinone){0<g&&(e["sep"+g++]="------");e.localtitle={name:"Client-side Analysis:",disabled:!0};e.grid=d("Coordinate Grid");!n||!n.raw.wcs||0>=n.raw.wcs?e.grid.disabled=
!0:n.displayCoordGrid()&&(e.grid.icon=JS9.globalOpts.menuSelected);e.regcnts=d("Counts in Regions");e.radprof=d("Radial Profile");JS9.globalOpts.internalRegcnts&&n&&n.raw&&n.raw.hdu&&n.raw.hdu.vfile||(e.regcnts.disabled=!0,e.radprof.disabled=!0);n&&n.raw&&3===n.raw.header.NAXIS&&(e.cnts3d=d("3D Counts in Regions"),e.plot3d=d("3D Plot using Regions"),JS9.globalOpts.internalRegcnts&&n.raw.hdu&&n.raw.hdu.vfile||(e.cnts3d.disabled=!0,e.plot3d.disabled=!0));e.sigma={events:{keyup:r},name:"Blur, equivalent sigma:",
type:"text"};e["sep"+g++]="------";e.remotetitle={name:"Server-side Analysis:",disabled:!0};if(n&&n.analysisPackages)for(u=n.analysisPackages,v=0;v<u.length;v++)for(c=u[v],b=0;b<c.length;b++)n.validateAnalysis(c[b])&&(c[b].rtype&&c[b].rtype.match(/^---/)?(e["sep"+g++]="------",e[c[b].name]={name:c[b].title+":",disabled:!0}):(t=c[b].title,c[b].purl&&(t+=" ..."),e[c[b].name]={name:t},f++));!f&&(e.notasks={name:"[none]",disabled:!0,events:{keyup:function(){}}},JS9.globalOpts.loadProxy&&n&&n.raw&&n.raw.hdu&&
n.raw.hdu.vfile&&(e.upload={name:"upload FITS to make tasks available"},!JS9.helper.connected||"nodejs"!==JS9.helper.type&&"socket.io"!==JS9.helper.type))&&(e.upload.disabled=!0);e["sep"+g++]="------";e.sconfig={name:"server-side params ...",items:{}};e.sconfig.items.dpath=d("set data analysis path ...");!1===JS9.globalOpts.dataPathModify&&(e.sconfig.items.dpath.disabled=!0);e.sconfig.items.fpath=d("set this image file's path ...");if(!n||document.domain&&"localhost"!==document.domain)e.sconfig.items.fpath.disabled=
!0}return{callback:function(b){JS9.Menubar.getDisplays.call(a).forEach(function(a){var c,d=a.image;if(!(0>$.inArray(a,JS9.displays))){for(c=0;c<JS9.plugins.length;c++){var g=JS9.plugins[c];if(g.name===b){a.displayPlugin(g);return}}if(d)switch(b){case "regcnts":JS9.CountsInRegions("$sregions","$bregions",{lightwin:!0},{display:a.id});break;case "radprof":JS9.RadialProfile("$sregions","$bregions",{display:a.id});break;case "cnts3d":c=JS9.globalOpts.plot3d.cube;JS9.CountsInRegions("$sregions","$bregions",
{lightwin:!0,cmdswitches:"-c "+c},{display:a.id});break;case "plot3d":JS9.Plot3D("$sregions","$bregions",null,{display:a.id});break;case "dpath":$(JS9.lightOpts[JS9.LIGHTWIN].topid).arrive("#dataPathForm",{onceOnly:!0},function(){$("#dataPath").val(JS9.globalOpts.dataPath)});g=d.displayAnalysis("textline",JS9.InstallDir(JS9.analOpts.dpathURL),{title:"Data path for analysis"});$(g).data("dispid",a.id);$(g).data("imid",d.id);break;case "fpath":$(JS9.lightOpts[JS9.LIGHTWIN].topid).arrive("#filePathForm",
{onceOnly:!0},function(){$("#filePath").val(d.file)});g=d.displayAnalysis("textline",JS9.InstallDir(JS9.analOpts.fpathURL),{title:"File path for this image"});$(g).data("dispid",a.id);$(g).data("imid",d.id);break;case "grid":d.displayCoordGrid(!d.displayCoordGrid());break;case "upload":d.uploadFITSFile();break;default:if(c=d.lookupAnalysis(b))c.purl?(g=d.displayAnalysis("params",JS9.InstallDir(c.purl),{title:c.title+": "+d.fitsFile,winformat:c.pwin}),$(g).data("dispid",a.id).data("aname",c.name)):
d.runAnalysis(c.name)}}})},events:{show:function(b){var c=a.display.image,d={};c&&(d.sigma=JS9.floatToString(c.params.sigma));$.contextMenu.setInputValues(b,d);JS9.jupyterFocus(".context-menu-item")},hide:function(b){var c=a.display,d=c.image;d&&c.tmp.editingMenu&&(b=$.contextMenu.getInputValues(b),q(d,b))}},items:e}}});$("#helpMenu"+this.id).on("mousedown",function(b){b.preventDefault();$("#helpMenu"+a.id).contextMenu()});$.contextMenu({selector:"#helpMenu"+this.id,zIndex:JS9.MENUZINDEX,events:{hide:c},
position:b,build:function(){var a,b=1;var c="";var e={js9help:{name:"General help ...",items:{helptitle:{name:"General help:",disabled:!0}}}},f=$jscomp.makeIterator(Object.keys(JS9.helpOpts));for(a=f.next();!a.done;a=f.next()){a=a.value;var p=JS9.helpOpts[a];"JS9Help"===p.heading&&(c=p.type,e.js9help.items[a]={name:p.title})}e["sep"+b++]="------";e.pluginhelp={name:"JS9 plugins ...",items:{helptitle:{name:"JS9 plugins:",disabled:!0}}};f=$jscomp.makeIterator(Object.keys(JS9.helpOpts));for(a=f.next();!a.done;a=
f.next())a=a.value,p=JS9.helpOpts[a],"JS9"===p.heading&&(c=p.type,e.pluginhelp.items[a]={name:p.title.replace(/ \.\.\./,"")});f=$jscomp.makeIterator(Object.keys(JS9.helpOpts));for(a=f.next();!a.done;a=f.next())a=a.value,p=JS9.helpOpts[a],"JS9Help"!==p.heading&&"JS9"!==p.heading&&(""!==c&&p.type!==c&&(e["sep"+b++]="------",p.heading&&(c=p.heading+" plugins",e["sep"+b++]={name:c+" ...",items:{title:{name:c+":",disabled:!0}}})),c=p.type,e["sep"+(b-1)].items[a]={name:p.title});e["sep"+b++]="------";e.about=
d("About");return{callback:function(a){switch(a){case "about":alert(JS9.ABOUT);break;default:JS9.DisplayHelp(a)}},items:e}}});(function(){var b,c;if(JS9.globalOpts.userMenuBar)for(b=0;b<JS9.globalOpts.userMenuBar.length;b++)(c=JS9.globalOpts.userMenuBar[b])&&c.name&&c.title&&($("#"+c.name+"UserMenu"+a.id).on("mousedown",c,f),e(c))})()};
JS9.Menubar.init=function(a,b){var c;(this.issuper=0<=this.id.search(JS9.SUPERMENU))&&JS9.supermenus.push(this);this.style=this.divjq.attr("data-style")||JS9.globalOpts.menubarStyle||"classic";this.style=this.style.toLowerCase();this.width=this.divjq.attr("data-width");this.width||(this.width=a||JS9.Menubar.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.buttonClass=this.divjq.attr("data-buttonClass")||"JS9Button";
this.containerClass="JS9MenubarContainer";this.buttonClass.match(/-flat/)?this.containerClass+="-flat":this.buttonClass.match(/-border/)&&(this.containerClass+="-border");this.backgroundColor=this.divjq.attr("data-backgroundColor");this.height||(this.height=b||JS9.MENUHEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.usermenus="true"===this.divjq.attr("data-usermenus")||JS9.globalOpts.userMenus;b="<span id='JS9Menus_@@ID@@'>";for(a=0;a<JS9.globalOpts.menuBar.length;a++){var d=
JS9.globalOpts.menuBar[a];for(c=0;c<JS9.Menubar.buttonOptsArr.length;c++){var f=JS9.Menubar.buttonOptsArr[c].name;if(d===f){d=JS9.Menubar.buttonOptsArr[c].label;if(JS9.allinone&&"help"===f)break;if("#"===f[0])"classic"===this.syle&&(f=f.slice(1),"#"!==f[1]&&(b+="<button type='button' id='"+f+"Menu@@ID@@' class='"+this.buttonClass+"' disabled='disabled'>"+d+" </button>"));else if("classic"===this.style)b+="<button type='button' id='"+f+"Menu@@ID@@' class='"+this.buttonClass+"'>"+d+"</button>";else switch(f){case "file":case "edit":b+=
"<button type='button' id='"+f+"Menu@@ID@@' class='"+this.buttonClass+"'>"+d+"</button>";break;case "help":b+="<span style='float:right'><button type='button' id='"+f+"Menu@@ID@@' class='"+this.buttonClass+"'>"+d+"</button></span>";break;default:this.macmenus||(b+="<span style='position:relative;'><button type='button' id='viewMacMenu@@ID@@' class='"+this.buttonClass+"'>View</button>",this.macmenus=[]),"View"===d&&(d="Plugins"),b+="<button type='button' id='"+f+"Menu@@ID@@' class='"+this.buttonClass+
"' style='position:absolute;top:0px;left:0px;visibility:hidden;zindex:-1'></button>",this.macmenus.push({name:f,title:d})}break}}}this.macmenus&&(b+="</span>");if(this.usermenus&&JS9.globalOpts.userMenuBar)for(b+=JS9.globalOpts.userMenuDivider||"",a=0;a<JS9.globalOpts.userMenuBar.length;a++)(d=JS9.globalOpts.userMenuBar[a])&&d.name&&d.title&&d.options&&(f=d.imageTitle?"<div class='JS9MenubarUserImage'><img src='"+d.imageTitle+"' name='"+d.name+"' alt='"+d.title+"' class='JS9MenubarUserImage JS9MenubarUserImageTitle' ></div>":
d.title,b+="<button type='button' id='"+d.name+"UserMenu@@ID@@' class='"+this.buttonClass+"'>"+f+"</button>");this.display.menubar=this;this.html=(b+"<button type='button' id='hiddenRegionMenu@@ID@@'class='JS9Button' style='display:none'>R</button><button type='button' id='hiddenAnchorMenu@@ID@@'class='JS9Button' style='display:none'>R</button></span>").replace(/@@ID@@/g,this.id);this.menuConjq=$("<div>").addClass(this.containerClass).attr("width",this.width).attr("height",this.height).html(this.html).appendTo(this.divjq);
this.backgroundColor&&this.menuConjq.css("background",this.backgroundColor);JS9.Menubar.createMenus.call(this)};JS9.RegisterPlugin("JS9","Menubar",JS9.Menubar.init,{onupdateprefs:JS9.Menubar.reset,dynamicSelect:!0,winDims:[JS9.Menubar.WIDTH,JS9.Menubar.HEIGHT]});JS9.Panner={};JS9.Panner.CLASS="JS9";JS9.Panner.NAME="Panner";JS9.Panner.WIDTH=320;JS9.Panner.HEIGHT=320;JS9.Panner.SWIDTH=250;JS9.Panner.SHEIGHT=250;JS9.Panner.VSIZE=30;
JS9.Panner.NORTH={color:"#00FF00",text:"N",fontSize:12,fontFamily:"Helvetica",strokeWidth:1,strokeDashArray:[2,1]};JS9.Panner.EAST={color:"#FFFF00",text:"E",fontSize:12,fontFamily:"Helvetica",strokeWidth:1,strokeDashArray:[2,1]};JS9.Panner.opts={hasControls:!1,hasRotatingPoint:!1,hasBorders:!1,zoom:4,canvas:{selection:!0},tagcolors:{defcolor:"#00FF00"}};
JS9.Panner.bcall=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d=$jscomp.makeIterator(b);var f=d.next().value;c=d.next().value;d=d.next().value;if(f=$(f).closest("div[class^=JS9PluginToolbar]").data("displayid")){var e=JS9.getImage(JS9.getDynamicDisplayOr(f));var h=e.display.pluginInstances.JS9Panner}else JS9.error("can't find display for cmd: "+c);e||JS9.error("can't find image for cmd: "+c);switch(c){case "zoomPanner":3>b.length&&JS9.error("missing arg(s) for cmd: "+
c);try{JS9.Panner.zoom.call(h,e,d)}catch(l){JS9.error("error calling zoomPanner()",l)}break;case "panImage":try{e.setPan()}catch(l){JS9.error("error calling setPan()",l)}}};JS9.Voyager||(JS9.Panner.HTML="<span><button type='button' class='JS9Button' onClick='JS9.Panner.bcall(this, \"zoomPanner\", \"x2\"); return false'>\u00d72</button><button type='button' class='JS9Button' onClick='JS9.Panner.bcall(this, \"zoomPanner\", \"/2\"); return false'>\u00d71/2</button><button type='button' class='JS9Button' onClick='JS9.Panner.bcall(this, \"zoomPanner\", \"1\"); return false'>1</button><button type='button' class='JS9Button' onClick='JS9.Panner.bcall(this, \"panImage\"); return false'>center</button></span>");
JS9.Panner.init=function(a,b){this.width=this.divjq.attr("data-width");this.width||(this.width=a||JS9.Panner.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=b||JS9.Panner.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.canvas=document.createElement("canvas");this.canvasjq=$(this.canvas);this.canvasjq.addClass("JS9Panner");this.canvasjq.css("z-index",
JS9.ZINDEX);this.canvasjq.attr("width",this.width);this.canvasjq.attr("height",this.height);this.context=this.canvas.getContext("2d");JS9.ANTIALIAS||(this.context.imageSmoothingEnabled=!1,this.context.webkitImageSmoothingEnabled=!1,this.context.msImageSmoothingEnabled=!1);this.containerjq=$("<div>").addClass("JS9Container").append(this.canvasjq).appendTo(this.divjq);this.display.image&&JS9.Panner.disp.call(this,this.display.image)};
JS9.Panner.create=function(a){var b=this,c,d,f,e,h;if(!a||!a.raw||!a.useOffScreenCanvas()&&!a.colorData||!a.display.pluginInstances.JS9Panner)return null;a.panner||(a.panner={});a.panner.zoom||(a.panner.zoom=1);var l=a.display.pluginInstances.JS9Panner;var g=a.panner;var k=a.rgb.sect;var m=Math.min(a.raw.width,l.width);var p=Math.min(a.raw.height,l.height);g.xblock=a.raw.width/m;g.yblock=a.raw.height/p;g.xblock>g.yblock?(p=Math.floor(p/g.xblock*g.yblock+.5),g.yblock=g.xblock):g.yblock>g.xblock&&(m=
Math.floor(m/g.yblock*g.xblock+.5),g.xblock=g.yblock);l=a.display.context.createImageData(m,p);if(1===g.zoom){var n=g.xblock;var q=g.yblock;k=c=0}else n=g.xblock/g.zoom,q=g.yblock/g.zoom,c=Math.max(0,(k.x0+k.x1-m*n)/2),k=Math.max(0,(k.y0+k.y1-p*q)/2);g.x0=c;g.y0=k;g.img=l;g.ix=0;g.iy=0;if(a.useOffScreenCanvas())for(d=0;d<p;d++){var r=Math.floor(k+d*q)*a.offscreen.img.width;var v=d*m;for(g=0;g<m;g++){var u=Math.floor(c+g*n);u=4*(u+r);var t=4*(v+g);l.data[t]=a.offscreen.img.data[u];l.data[t+1]=a.offscreen.img.data[u+
1];l.data[t+2]=a.offscreen.img.data[u+2];l.data[t+3]=255}}else for(d=0;d<p;d++)for(r=Math.floor(k+(p-d-1)*q)*a.raw.width,v=d*m,g=0;g<m;g++)u=Math.floor(c+g*n),u=a.colorData[u+r],t=4*(v+g),a.psColors[u]&&(l.data[t]=a.psColors[u][0],l.data[t+1]=a.psColors[u][1],l.data[t+2]=a.psColors[u][2],l.data[t+3]=255);if(this.display.layers.panner)return this.display.image&&this.isDynamic&&(a.display.layers.panner||(a.display.layers.panner=this.display.layers.panner),this.display.image.layers.panner&&!a.layers.panner&&
(a.layers.panner=this.display.image.layers.panner)),a;var x=this.display.newShapeLayer("panner",JS9.Panner.opts,this.divjq);x.canvas.on("object:modified",function(a){var c;if(c=(c=JS9.getDynamicDisplayOr(b.display))&&c.image?c.image:b.display.image){var d=c.display.pluginInstances.JS9Panner;f=a.target.getCenterPoint();"x"===c.params.flip?f.x=d.width-f.x:"y"===c.params.flip?f.y=d.height-f.y:"xy"===c.params.flip&&(f.x=d.width-f.x,f.y=d.height-f.y);c.params.rot90&&(f=JS9.rotatePoint(f,c.params.rot90,
{x:d.width/2,y:d.height/2}));c.params.rotate&&(f=JS9.rotatePoint(f,c.params.rotate,{x:d.width/2,y:d.height/2}));e=(f.x-c.panner.ix)*c.panner.xblock/c.panner.zoom+c.panner.x0;h=(x.canvas.height-(f.y+c.panner.iy))*c.panner.yblock/c.panner.zoom+c.panner.y0;try{d.status="inactive",c.setPan(e,h)}catch(E){JS9.log("couldn't pan image",E)}finally{d.status="active"}}});return a};
JS9.Panner.disp=function(a){if(a&&a.display.pluginInstances.JS9Panner&&"active"===a.display.pluginInstances.JS9Panner.status&&JS9.Panner.create.call(this,a)){var b=a.raw.wcsinfo||{cdelt1:1,cdelt2:1,crot:0};var c=a.panner;var d=a.display.pluginInstances.JS9Panner;var f=a.rgb.sect;var e=d.width/2;var h=d.height/2;var l=d.context;if(c.img){c.img.width<d.width&&(c.ix=Math.floor((d.width-c.img.width)/2));c.img.height<d.height&&(c.iy=Math.floor((d.height-c.img.height)/2));JS9.Panner.clear.call(this,a);
l.save();if(a.params.transform){var g=a.params.transform;var k=d.width/2;var m=d.height/2;l.translate(k,m);l.transform(g[0][0],g[0][1],g[1][0],g[1][1],g[2][0],g[2][1]);l.translate(-k,-m)}l.drawImage(function(a,b){var c=a.display.pluginInstances.JS9Panner;if(!c.offscreenRGB){var d=document.createElement("canvas");a=d.getContext("2d");JS9.ANTIALIAS||(a.imageSmoothingEnabled=!1);c.offscreenRGB={canvas:d,context:a}}c.offscreenRGB.canvas.width=b.width;c.offscreenRGB.canvas.height=b.height;c.offscreenRGB.context.putImageData(b,
0,0);return c.offscreenRGB.canvas}(a,c.img),c.ix,c.iy);l.restore();l=c.zoom/c.xblock;var p=c.zoom/c.yblock;m=a.display.width*l/f.zoom;g=a.display.height*p/f.zoom;k=(f.x0-c.x0)*l+c.ix;c=d.height-((f.y1-c.y0)*p+c.iy);a.display.width!==f.width&&(k-=(a.display.width-f.width)*l/f.zoom/2);a.display.height!==f.height&&(c-=(a.display.height-f.height)*p/f.zoom/2);k+=m/2;c+=g/2;"x"===a.params.flip?k=d.width-k:"y"===a.params.flip?c=d.height-c:"xy"===a.params.flip&&(k=d.width-k,c=d.height-c);a.params.rot90&&
(f=JS9.rotatePoint({x:k,y:c},-a.params.rot90,{x:d.width/2,y:d.height/2}),k=f.x,c=f.y);a.params.rotate&&(f=JS9.rotatePoint({x:k,y:c},-a.params.rotate,{x:d.width/2,y:d.height/2}),k=f.x,c=f.y);m>=d.width&&(k=d.width/2,m=d.width+10);g>=d.height&&(c=d.height/2,g=d.height+10);d={left:k,top:c,width:m,height:g};a.panner.boxid?a.changeShapes("panner",a.panner.boxid,d):a.panner.boxid=a.addShapes("panner","box",d);a.panner.northid&&(a.removeShapes("panner",a.panner.northid),a.removeShapes("panner",a.panner.northidt));
a.panner.eastid&&(a.removeShapes("panner",a.panner.eastid),a.removeShapes("panner",a.panner.eastidt));if(!JS9.globalOpts.pannerDirections||!a.raw.wcs||0>=a.raw.wcs)return a;c=a.getNorthIsUp();d=c.angle;JS9.notNull(a.params.rot90)&&(d-=a.params.rot90);JS9.notNull(a.params.rotate)&&(d-=a.params.rotate);f=c.xflip?-1:1;k=c.yflip?-1:1;switch(a.params.flip){case "x":f*=-1;break;case "y":k*=-1;break;case "xy":f*=-1,k*=-1}c={x:e,y:h};k=0<=b.cdelt2?{x:e,y:h-JS9.Panner.VSIZE*k}:{x:e,y:h+JS9.Panner.VSIZE*k};
k=JS9.rotatePoint(k,d,c);c={color:JS9.Panner.NORTH.color,strokeWidth:JS9.Panner.NORTH.strokeWidth,strokeDashArray:JS9.Panner.NORTH.strokeDashArray,points:[c,k],changeable:!1,originX:"left",originY:"top",noLeftTop:!0};a.panner.northid=a.addShapes("panner","line",c);a.panner.northidt=a.addShapes("panner","text",{color:JS9.Panner.NORTH.color,text:JS9.Panner.NORTH.text,fontSize:JS9.Panner.NORTH.fontSize,fontFamily:JS9.Panner.NORTH.fontFamily,changeable:!1,left:k.x,top:k.y});c={x:e,y:h};e=0>b.cdelt1?{x:e-
JS9.Panner.VSIZE*f,y:h}:{x:e+JS9.Panner.VSIZE*f,y:h};e=JS9.rotatePoint(e,d,c);a.panner.eastid=a.addShapes("panner","line",{color:JS9.Panner.EAST.color,strokeWidth:JS9.Panner.EAST.strokeWidth,strokeDashArray:JS9.Panner.EAST.strokeDashArray,changeable:!1,points:[c,e],originX:"left",originY:"top",noLeftTop:!0});a.panner.eastidt=a.addShapes("panner","text",{color:JS9.Panner.EAST.color,text:JS9.Panner.EAST.text,fontSize:JS9.Panner.EAST.fontSize,fontFamily:JS9.Panner.EAST.fontFamily,changeable:!1,left:e.x,
top:e.y});return a}}};JS9.Panner.zoom=function(a,b){if(a&&a.panner&&a.display.pluginInstances.JS9Panner){var c=a.panner;var d=c.zoom;switch(b.charAt(0)){case "*":case "x":case "X":b=Math.min(Math.min(this.width,this.height),d*parseFloat(b.slice(1)));break;case "/":b=Math.max(1,d/parseFloat(b.slice(1)));break;default:b=parseFloat(b)}if(!b||1>b)b=1;c.zoom=b;JS9.Panner.disp.call(this,a);return a}};
JS9.Panner.dysel=function(a){var b;a&&(b=a.display.pluginInstances.JS9Panner)&&b.isDynamic&&JS9.Panner.disp.call(this,a)};JS9.Panner.clear=function(a){var b;if(a){var c=JS9.getDynamicDisplayOr(this.display);(b=a.display.pluginInstances.JS9Panner)&&a.display===c&&(b.context.clear(),a.removeShapes("panner","all"),a.panner.boxid=null);return a}};
JS9.RegisterPlugin(JS9.Panner.CLASS,JS9.Panner.NAME,JS9.Panner.init,{menuItem:"Panner",help:"help/panner.html",dynamicSelect:!0,toolbarSeparate:!1,toolbarHTML:JS9.Panner.HTML,ondynamicselect:JS9.Panner.dysel,onplugindisplay:JS9.Panner.disp,onimagedisplay:JS9.Panner.disp,onimageclose:JS9.Panner.clear,onimageclear:JS9.Panner.clear,onupdateprefs:JS9.Panner.disp,onsetwcssys:JS9.Panner.disp,winTitle:"Panner",winDims:[JS9.Panner.WIDTH,JS9.Panner.HEIGHT],divArgs:[JS9.Panner.SWIDTH,JS9.Panner.SHEIGHT]});
JS9.PanZoom={};JS9.PanZoom.CLASS="JS9";JS9.PanZoom.NAME="PanZoom";JS9.PanZoom.WIDTH=530;JS9.PanZoom.HEIGHT=110;JS9.PanZoom.BASE=JS9.PanZoom.CLASS+JS9.PanZoom.NAME;JS9.PanZoom.panzoomHTML="<p><div class='JS9PanZoomLinegroup'>$pan $zoom $flip $rot90 $rotate</div><p><div class='JS9PanZoomLinegroup'>$panto $pos1 $pos2 $wcssys $wcsunits</div>";JS9.PanZoom.panHTML='<select class="JS9Select JS9PanZoomSelect JS9PanZoomCol1" name="pan" onchange="JS9.PanZoom.xsetpan(\'%s\', \'%s\', this)">%s</select>';
JS9.PanZoom.zoomHTML='<select class="JS9Select JS9PanZoomSelect JS9PanZoomCol2" name="zoom" onchange="JS9.PanZoom.xsetzoom(\'%s\', \'%s\', this)">%s</select>';JS9.PanZoom.flipHTML='<select class="JS9Select JS9PanZoomSelect JS9PanZoomCol3" name="flip" onchange="JS9.PanZoom.xsetflip(\'%s\', \'%s\', this)">%s</select>';JS9.PanZoom.rot90HTML='<select class="JS9Select JS9PanZoomSelect JS9PanZoomCol4" name="rot90" onchange="JS9.PanZoom.xsetrot90(\'%s\', \'%s\', this)">%s</select>';
JS9.PanZoom.rotateHTML='<input type="text" class="JS9PanZoomInput JS9PanZoomCol5 js9Input" name="rotate" autocapitalize="off" autocorrect="off" onkeydown="JS9.PanZoom.xsetrot(\'%s\', \'%s\', this, event)" value="%s" placeholder="angle or reset">';JS9.PanZoom.pantoHTML='<input type="button" class="JS9Button2 JS9PanZoomButton JS9PanZoomCol1" name="panto" value="Pan to →" onclick="javascript:JS9.PanZoom.xpanto(\'%s\', \'%s\', this)">';JS9.PanZoom.pos1HTML='<input type="text" class="JS9PanZoomInput JS9PanZoomCol2 js9Input" name="pos1" value="%s" autocapitalize="off" autocorrect="off" placeholder="x position">';
JS9.PanZoom.pos2HTML='<input type="text" class="JS9PanZoomInput JS9PanZoomCol3 js9Input" name="pos2" value="%s" autocapitalize="off" autocorrect="off" placeholder="y position">';JS9.PanZoom.sysHTML='<select class="JS9Select JS9PanZoomSelect JS9PanZoomCol4" name="wcssys" onchange="JS9.PanZoom.xsetwcssys(\'%s\', \'%s\', this)">%s</select>';JS9.PanZoom.unitsHTML='<select class="JS9Select JS9PanZoomSelect JS9PanZoomCol5" name="wcsunits" onchange="JS9.PanZoom.xsetwcsunits(\'%s\', \'%s\', this)">%s</select>';
JS9.PanZoom.xsetpan=function(a,b,c){if(a=JS9.lookupImage(b,a))switch(c.value){case "center":a.setPan()}};JS9.PanZoom.xsetzoom=function(a,b,c){if(a=JS9.lookupImage(b,a))switch(c.value){case "in":case "out":case "to fit":c=a.parseZoom(c.value);JS9.isNumber(c)&&a.setZoom(c);break;default:c=c.value.split(/\s+/),2===c.length&&(c=c[1].split("/"),c=1===c.length?parseFloat(c[0]):1/parseFloat(c[1]),a.setZoom(c))}};
JS9.PanZoom.xsetflip=function(a,b,c){if(a=JS9.lookupImage(b,a))switch(c.value){case "x axis":a.setFlip("x");break;case "y axis":a.setFlip("y");break;case "reset":a.setFlip("reset")}};
JS9.PanZoom.xsetrot90=function(a,b,c){if(a=JS9.lookupImage(b,a))switch(c.value){case "90 left":a.setRot90(90);break;case "90 right":a.setRot90(-90);break;case "reset rotate":a.setRot90("reset");a.setRotate("reset");break;case "align: north is up":a.setRot90("reset");a.setRotate("northisup");break;case "reset flip/rot90/rotate":a.setFlip("reset"),a.setRot90("reset"),a.setRotate("reset")}return!1};
JS9.PanZoom.xsetrot=function(a,b,c,d){if((a=JS9.lookupImage(b,a))&&13===d.keyCode&&(c=$(c).val().trim()))if("reset"===c)a.setRotate("reset"),a.setRot90("reset");else{if(d=a.display.pluginInstances.JS9PanZoom)d.rot=c;a.setRotate(c);d&&d.divjq.find('input[name="rotate"]').focus().caretToEnd()}};
JS9.PanZoom.xpanto=function(a,b,c){if(a=JS9.lookupImage(b,a)){c=$(c).parent();var d=c.find("[name='wcssys']").val();b=c.find("[name='pos1']").val();var f=c.find("[name='pos2']").val();if(b&&f&&d){c=a.getWCSSys();a.setWCSSys(d);b=JS9.saostrtod(b);JS9.isHMS(d)&&(b*=15);f=JS9.saostrtod(f);switch(d){case "image":break;case "physical":d=a.logicalToImagePos({x:b,y:f});b=d.x;f=d.y;break;default:a.validWCS()&&(d=JS9.wcs2pix(a.raw.wcs,b,f).trim().split(/\s+/),b=parseFloat(d[0]),f=parseFloat(d[1]))}a.setPan(b,
f);a.setWCSSys(c)}}};JS9.PanZoom.xsetwcssys=function(a,b,c){var d=c.value;var f=JS9.lookupImage(b,a);if(f){var e=f.getWCSSys();var h=f.getWCSUnits();f.setWCSSys(d);f.tmp.wcssysPanZoom=d;d=JS9.PanZoom.getPos(f,"x");var l=JS9.PanZoom.getPos(f,"y");c=$(c).parent();c.find("[name='pos1']").val(d);c.find("[name='pos2']").val(l);f.getWCSUnits()!==(f.tmp.wcsunitsPanZoom||h)&&JS9.PanZoom.xsetwcsunits(a,b,{value:f.getWCSUnits()});f.setWCSSys(e);f.setWCSUnits(h)}};
JS9.PanZoom.xsetwcsunits=function(a,b,c){var d=c.value;var f=JS9.lookupImage(b,a);if(f){var e=f.getWCSUnits();var h=f.getWCSSys();f.setWCSUnits(d);f.tmp.wcsunitsPanZoom=d;d=JS9.PanZoom.getPos(f,"x");var l=JS9.PanZoom.getPos(f,"y");c=$(c).parent();c.find("[name='pos1']").val(d);c.find("[name='pos2']").val(l);f.getWCSSys()!==(f.tmp.wcssysPanZoom||h)&&JS9.PanZoom.xsetwcssys(a,b,{value:f.getWCSSys()});f.setWCSSys(h);f.setWCSUnits(e)}};
JS9.PanZoom.getPos=function(a,b){if(a){var c=a.getPan();var d=a.getWCSSys();var f=a.getWCSUnits();var e=a.tmp.wcssysPanZoom||d;var h=a.tmp.wcsunitsPanZoom||f;d!==e&&a.setWCSSys(e);f!==h&&a.setWCSUnits(h);switch(e){case "image":c=String(c[b]);break;case "physical":c=a.imageToLogicalPos(c);c=String(c[b]);break;default:a.validWCS()?(c=JS9.pix2wcs(a.raw.wcs,c.x,c.y).trim().split(/\s+/),c="x"===b?c[0]:c[1]):c=String(c[b])}d!==e&&a.setWCSSys(d);f!==h&&a.setWCSUnits(f)}return c};
JS9.PanZoom.reinit=function(){this.inProcess||(this.inProcess=!0,JS9.PanZoom.init.call(this),this.inProcess=!1)};JS9.PanZoom.display=function(){this.lastimage!==this.display.image&&(this.inProcess=!0,JS9.PanZoom.init.call(this),this.inProcess=!1)};JS9.PanZoom.close=function(){JS9.PanZoom.init.call(this,{mode:"clear"})};
JS9.PanZoom.init=function(a){var b=this,c;var d=function(){var a;var b="<option selected disabled>Zoom</option><option>in</option><option>out</option><option>to fit</option><option disabled>\u2500\u2500\u2500\u2500\u2500</option>";for(a=JS9.imageOpts.zooms;0<a;a--){var c=Math.pow(2,a);c="zoom 1/"+c;b+="<option>"+c+"</option>"}for(a=0;a<=JS9.imageOpts.zooms;a++)c=Math.pow(2,a),c="zoom "+c,b+="<option>"+c+"</option>";return b};var f=function(a){var c=0;a&&(c=JS9.globalOpts.rotateRelative&&b.rot&&"reset"!==
b.rot?b.rot:a.getRotate()||"0");return c},e=function(a){var b="<option selected disabled>WCS Systems</option>";if(a){var c=a.tmp.wcssysPanZoom||a.getWCSSys();var d=a.validWCS()?JS9.wcssyss:["image","physical"];for(a=0;a<d.length;a++)b=c===d[a]?b+("<option selected>"+d[a]+"</option>"):b+("<option>"+d[a]+"</option>")}return b},h=function(a){var b="<option selected disabled>WCS Units</option>";if(a){var c=a.tmp.wcsunitsPanZoom||a.getWCSUnits();var d=a.validWCS()?["degrees","sexagesimal","pixels"]:["pixels"];
for(a=0;a<d.length;a++)b=c===d[a]?b+("<option selected>"+d[a]+"</option>"):b+("<option>"+d[a]+"</option>")}return b};a=a||{};this.width=this.divjq.attr("data-width");this.width||(this.width=JS9.PanZoom.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.PanZoom.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.divjq.html("");this.lastTextWidth=
0;this.panzoomContainer=$("<div>").addClass(JS9.PanZoom.BASE+"Container").attr("id",this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);if((c=this.display.image)&&"clear"!==a.mode){var l=c.id;var g=c.display.id;var k=[];a=sprintf(JS9.PanZoom.panHTML,g,l,"<option selected disabled>Pan</option><option>center</option>");k.push({name:"pan",value:a});a=sprintf(JS9.PanZoom.zoomHTML,g,l,d());k.push({name:"zoom",value:a});a=sprintf(JS9.PanZoom.flipHTML,g,l,"<option selected disabled>Flip</option><option>x axis</option><option>y axis</option><option>reset</option>");
k.push({name:"flip",value:a});a=sprintf(JS9.PanZoom.rot90HTML,g,l,"<option selected disabled>Rotate</option><option>90 left</option><option>90 right</option><option>reset rotate</option><option disabled>\u2500\u2500\u2500\u2500\u2500</option><option>align: north is up</option><option>reset flip/rot90/rotate</option>");k.push({name:"rot90",value:a});a=sprintf(JS9.PanZoom.rotateHTML,g,l,f(c));k.push({name:"rotate",value:a});a=sprintf(JS9.PanZoom.pantoHTML,g,l);k.push({name:"panto",value:a});a=sprintf(JS9.PanZoom.pos1HTML,
JS9.PanZoom.getPos(c,"x"));k.push({name:"pos1",value:a});a=sprintf(JS9.PanZoom.pos2HTML,JS9.PanZoom.getPos(c,"y"));k.push({name:"pos2",value:a});a=sprintf(JS9.PanZoom.sysHTML,g,l,e(c));k.push({name:"wcssys",value:a});a=sprintf(JS9.PanZoom.unitsHTML,g,l,h(c));k.push({name:"wcsunits",value:a});d=c.expandMacro(JS9.PanZoom.panzoomHTML,k);this.lastimage=c}else d="<p><center>Pan/Zoom parameters will appear here.</center>";this.panzoomContainer.html(d);c&&JS9.globalOpts.runOnCR&&(this.panzoomContainer.find("[name='pos1']").data("enterfunc",
"panto"),this.panzoomContainer.find("[name='pos2']").data("enterfunc","panto"))};
JS9.RegisterPlugin(JS9.PanZoom.CLASS,JS9.PanZoom.NAME,JS9.PanZoom.init,{menu:"zoom",menuItem:"Pan/Zoom Controls ...",onplugindisplay:JS9.PanZoom.init,onsetpan:JS9.PanZoom.reinit,onsetzoom:JS9.PanZoom.reinit,onsetwcssys:JS9.PanZoom.reinit,onsetwcsunits:JS9.PanZoom.reinit,onimagedisplay:JS9.PanZoom.display,onimageclose:JS9.PanZoom.close,help:"help/zoomcontrols.html",winTitle:"Pan/Zoom Controls",winDims:[JS9.PanZoom.WIDTH,JS9.PanZoom.HEIGHT]});JS9.Prefs={};JS9.Prefs.CLASS="JS9";JS9.Prefs.NAME="Preferences";
JS9.Prefs.WIDTH=800;JS9.Prefs.HEIGHT=400;
JS9.Prefs.imagesSchema={title:"Image Preferences",description:"Preferences for each displayed image",properties:{colormap:{type:"string",helper:"default color map"},contrast:{type:"number",helper:"default color contrast"},bias:{type:"number",helper:"default color bias"},scale:{type:"string",helper:"default scale algorithm"},scaleclipping:{type:"string",helper:"'dataminmax' or 'zscale'"},zscalecontrast:{type:"number",helper:"default from ds9"},zscalesamples:{type:"number",helper:"default from ds9"},
zscaleline:{type:"number",helper:"default from ds9"},exp:{type:"number",helper:"default exp value for scaling"},wcssys:{type:"string",helper:"current WCS system"},wcsunits:{type:"string",helper:"current WCS units"},lcs:{type:"string",helper:"default logical coordinate system"},opacity:{type:"number",helper:"opacity for images (0.0 to 1.0)"},zoom:{type:"number",helper:"default zoom factor"},zooms:{type:"number",helper:"how many zooms in each direction?"},nancolor:{type:"string",helper:"6-digit #hex color for NaN values"},
overlay:{type:"boolean",helper:"display png/jpeg overlay?"},listonchange:{type:"boolean",helper:"list after a region change?"},whichonchange:{type:"string",helper:"list 'all' or 'selected'?"},valpos:{type:"boolean",helper:"display value/position?"},inherit:{type:"boolean",helper:"new images inherit current params?"},invert:{type:"boolean",helper:"by default, invert colormap?"},disable:{type:"mobject",helper:"array of core funcs to disable"}}};
JS9.Prefs.regionsSchema={title:"Region Preferences",description:"Preferences for each displayed region",type:"object",properties:{iradius:{type:"number",helper:"annulus: initial inner radius"},oradius:{type:"number",helper:"annulus: initial outer radius"},nannuli:{type:"number",helper:"annulus: initial number of annuli"},width:{type:"number",helper:"box: initial width"},height:{type:"number",helper:"box: initial height"},radius:{type:"number",helper:"circle: initial radius"},r1:{type:"number",helper:"ellipse: initial radius1"},
r2:{type:"number",helper:"ellipse: initial radius2"},angle:{type:"number",helper:"box, ellipse: initial angle in degrees"},polypoints:{type:"mobject",helper:"polygon: x,y relative positions"},linepoints:{type:"mobject",helper:"line: x,y relative positions"},ptshape:{type:"string",helper:"point shape: box, circle, ellipse, +, x"},ptsize:{type:"number",helper:"point: size"},tags:{type:"string",helper:"initial tags for a region"},strokeWidth:{type:"number",helper:"region stroke width"},ptStrokeWidth:{type:"number",
helper:"stroke width for points"},fontFamily:{type:"string",helper:"region font"},fontSize:{type:"string",helper:"region font size"},fontStyle:{type:"string",helper:"region font style"},fontWeight:{type:"string",helper:"region font weight"},textAlign:{type:"string",helper:"text alignment"}}};
JS9.Prefs.gridSchema={title:"Grid Preferences",description:"Preferences for wcs coordinate grids",type:"object",properties:{strokeWidth:{type:"number",helper:"grid stroke width"},lineColor:{type:"string",helper:"color of grid lines"},raLines:{type:"number",helper:"approx. number of RA grid lines"},raAngle:{type:"number",helper:"rotation for RA label"},raSkip:{type:"number",helper:"number of RA lines to skip"},decLines:{type:"number",helper:"approx. number of Dec grid lines"},decAngle:{type:"number",
helper:"rotation for Dec label"},decSkip:{type:"number",helper:"number of Dec lines to skip"},labelColor:{type:"string",helper:"color of text labels"},labelFontFamily:{type:"string",helper:"label font"},labelFontSize:{type:"string",helper:"label font size"},labelFontStyle:{type:"string",helper:"label font style"},labelFontWeight:{type:"string",helper:"label font weight"},labelRAOffx:{type:"number",helper:"x offset of RA labels"},labelRAOffy:{type:"number",helper:"y offset of RA labels"},labelDecOffx:{type:"number",
helper:"x offset of Dec labels"},labelDecOffy:{type:"number",helper:"y offset of Dec labels"},degPrec:{type:"number",helper:"precision for degree labels"},sexaPrec:{type:"number",helper:"precision for sexagesimal labels"},reduceDims:{type:"boolean",helper:"reduce lines of smaller image dim?"},stride:{type:"number",helper:"fineness of grid lines"},margin:{type:"number",helper:"edge margin for displaying a grid line"},labelMargin:{type:"number",helper:"edge margin for displaying a label"},cover:{type:"string",
helper:"grid lines cover: display or image"}}};
JS9.Prefs.fitsSchema={title:"FITS Preferences",description:"Preferences for processing FITS files",properties:{extlist:{type:"string",helper:"default binary table extensions"},xdim:{type:"string",helper:"x dim of image section from table"},ydim:{type:"string",helper:"y dim of image section from table"},bin:{type:"string",helper:"bin factor for tables"},ixdim:{type:"string",helper:"x dim of image section from image"},iydim:{type:"string",helper:"y dim of image section from table"},ibin:{type:"string",
helper:"bin factor for images"},binMode:{type:"string",helper:"'s' for summing, 'a' for averaging"},clear:{type:"string",helper:"clear image's virtual file memory"}}};
JS9.Prefs.catalogsSchema={title:"Catalogs Preferences",description:"Preferences for loading tab-delimited catalogs",properties:{ras:{type:"mobject",helper:"RA patterns to look for in table"},decs:{type:"mobject",helper:"Dec patterns to look for in table"},wcssys:{type:"string",helper:"wcs system of catalog"},shape:{type:"string",helper:"shape of objects"},color:{type:"string",helper:"color of objects"},width:{type:"number",helper:"width of box objects"},height:{type:"number",helper:"height of box objects"},
radius:{type:"number",helper:"radius of circle objects"},r1:{type:"number",helper:"r1 of ellipse objects"},r2:{type:"number",helper:"r2 of ellipse objects"},tooltip:{type:"string",helper:"tooltip format for objects"},skip:{type:"string",helper:"comment character in table"}}};
JS9.Prefs.globalsSchema={title:"Global Preferences",description:"Global preferences for all JS9 displays",properties:{topColormaps:{type:"mobject",helper:"array of top-level colormaps"},infoBox:{type:"mobject",helper:"array of infoBox items to display"},statusBar:{type:"string",helper:"format of statusbar display"},toolBar:{type:"mobject",helper:"array of toolbar tools to display"},separate:{type:"mobject",helper:"options when separating images"},mouseActions:{type:"mobject",helper:"array of mouse actions"},
touchActions:{type:"mobject",helper:"array of touch actions"},keyboardActions:{type:"mobject",helper:"object containing keyboard actions"},centerDivs:{type:"mobject",helper:"divs used when centering"},resizeDivs:{type:"mobject",helper:"divs used when resizing"},plot3d:{type:"mobject",helper:"options for 3D data cube plot"},syncOps:{type:"mobject",helper:"ops to sync between images"},wcsUnits:{type:"mobject",helper:"default units for WCS systems"},copyWcsPosFormat:{type:"string",helper:"format string using: $ra $dec $sys"},
fallbackDisplay:{type:"string",helper:"can messages fallback to display win?"},lightWinClose:{type:"string",helper:"ask,close,move when closing lightwin"},fits2fits:{type:"string",helper:"make rep file?: true,false,size>N"},dynamicSelect:{type:"string",helper:"select display: click, move, false"},panRefreshLimit:{type:"number",helper:"# of shapes to minimze refresh during pan"},regDisplay:{type:"string",helper:"show regions in 'lightwin' or 'display'"},regMenuCreate:{type:"boolean",helper:"region menu selections create regions?"},
regSyncTextColor:{type:"boolean",helper:"sync region text color with main color?"},regToClipboard:{type:"boolean",helper:"region mods to pseudo-clipboard?"},regListDCoords:{type:"boolean",helper:"list regions preserving dcoords? "},metaClickPan:{type:"boolean",helper:"meta-click pans to mouse position?"},mousetouchZoom:{type:"boolean",helper:"scroll/pinch to zoom?"},mousetouchLimit:{type:"boolean",helper:"limit zoom-out to the size of the image?"},clickToFocus:{type:"boolean",helper:"click display to focus?"},
valposDCoords:{type:"boolean",helper:"valpos shows display coords?"},toolbarTooltips:{type:"boolean",helper:"show tooltips in Toolbar plugin?"},updateTitlebar:{type:"boolean",helper:"update titlebar with image id?"},logoDisplay:{type:"boolean",helper:"show JS9 logo?"},reloadRefresh:{type:"boolean",helper:"does a reload refresh the data?"},reloadRefreshReg:{type:"boolean",helper:"reloading regions file removes prev?"},syncReciprocate:{type:"boolean",helper:"reciprocal image sync'ing?"},syncWCS:{type:"boolean",
helper:"sync using wcs (e.g. pan)?"},nextImageMask:{type:"boolean",helper:"nextImage() show image masks?"},panWithinDisplay:{type:"boolean",helper:"keep panned image within the display?"},pannerDirections:{type:"boolean",helper:"show direction vectors in panner?"},magnifierRegions:{type:"boolean",helper:"show regions in magnifier?"},xeqPlugins:{type:"boolean",helper:"execute plugin callbacks?"},extendedPlugins:{type:"boolean",helper:"execute extended plugins?"},intensivePlugins:{type:"boolean",helper:"execute intensive plugins?"},
svgBorder:{type:"boolean",helper:"add border when exporting SVG?"}}};JS9.Prefs.favoritesSchema={title:"Favorites Preferences",description:"Favorites for all JS9 displays",properties:{scales:{type:"mobject",helper:"array of favorite scales"},colormaps:{type:"mobject",helper:"array of favorite colormaps"},regions:{type:"mobject",helper:"array of favorite regions"},wcs:{type:"mobject",helper:"array of favorite wcs systems"}}};
JS9.Prefs.desktopSchema={title:"Desktop App Preferences",description:"Desktop app preferences will take effect on restart",properties:{webpage:{type:"string",helper:"web page to display"},width:{type:"number",helper:"width of desktop window"},height:{type:"number",helper:"height of desktop window"},hostfs:{type:"boolean",helper:"utilize host file system?"},debug:{type:"boolean",helper:"display Chrome debugger at startup?"}}};
JS9.Prefs.sources=[{name:"globals",schema:JS9.Prefs.globalsSchema},{name:"images",schema:JS9.Prefs.imagesSchema},{name:"fits",schema:JS9.Prefs.fitsSchema},{name:"regions",schema:JS9.Prefs.regionsSchema},{name:"grid",schema:JS9.Prefs.gridSchema},{name:"catalogs",schema:JS9.Prefs.catalogsSchema},{name:"favorites",schema:JS9.Prefs.favoritesSchema},{name:"desktop",schema:JS9.Prefs.desktopSchema}];
JS9.Prefs.regions=function(){var a=JS9.Prefs.sources;JS9.Prefs.sources=[{name:"regions",schema:JS9.Prefs.regionsSchema}];JS9.Prefs.init.call(this);JS9.Prefs.sources=a};
JS9.Prefs.init=function(){var a,b;var c=JS9.Prefs.sources;var d=this.id+"prefsTabs";var f="<div style='padding: 8px'><div id='"+(d+"' class='indentmenu'>\n<ul>");for(a=0;a<c.length;a++){var e=c[a];if("desktop"!==e.name||JS9.cmdlineOpts){var h=this.id+JS9.Prefs.CLASS+JS9.Prefs.NAME+e.name;f+=" <li><a href='#' rel='"+h+"Div'>"+e.name+"</a></li>\n"}}f+="</ul><br style='clear:left'></div></div><p>\n";for(a=0;a<c.length;a++)if(e=c[a],"desktop"!==e.name||JS9.cmdlineOpts){h=this.id+JS9.Prefs.CLASS+JS9.Prefs.NAME+
e.name;switch(e.name){case "images":e.data=JS9.imageOpts;break;case "regions":e.data=JS9.Regions.opts;break;case "grid":e.data=JS9.Grid.opts;break;case "fits":e.data={extlist:JS9.fits.options.extlist,xdim:JS9.fits.options.table.xdim,ydim:JS9.fits.options.table.ydim,bin:JS9.fits.options.table.bin,ixdim:JS9.fits.options.image.xdim,iydim:JS9.fits.options.image.ydim,ibin:JS9.fits.options.image.bin,binMode:JS9.globalOpts.binMode,clear:JS9.globalOpts.clearImageMemory};break;case "catalogs":e.data=JS9.globalOpts.catalogs;
break;case "globals":e.data=JS9.globalOpts;break;case "favorites":e.data=JS9.favorites;break;case "desktop":e.data=JS9.cmdlineOpts;break;default:JS9.error("unknown source for preferences: "+e.name)}f+="<div id='"+h+"Div' class='tabcontent'>";f+="<form id='"+h+"Form' class='js9AnalysisForm' style='overflow: hidden'>";f+="<center><b>"+e.schema.description+"</b></center><p>";h=e.schema.properties||{};var l=$jscomp.makeIterator(Object.keys(h));for(b=l.next();!b.done;b=l.next()){var g=b.value;var k=h[g];
var m=k.prompt||g+":";switch(k.type){case "boolean":b=e.data[g]?"checked":"";f+="<div class='linegroup'><span class='column_R1'><b>"+m+"</b></span><span class='column_R2'><input type='checkbox' name='"+g+"' value='true' "+b+"></span><span class='column_R4L'>"+k.helper+"</span></div>";break;default:b="object"===typeof e.data[g]?"mobject"===k.type?JSON.stringify(e.data[g],null,2):JSON.stringify(e.data[g]):JS9.isNull(e.data[g])?"":e.data[g],f="mobject"===k.type?f+("<div class='linegroup' style='height:64px'><span class='column_R1'><b>"+
m+"</b></span><span class='column_R2l'><textarea name='"+g+"' class='text_R' rows='5' style='overflow-x: hidden; resize: none'>"+b+"</textarea></span><span class='column_R4L'>"+k.helper+"</span></div>"):f+("<div class='linegroup'><span class='column_R1'><b>"+m+"</b></span><span class='column_R2l'><input type='text' name='"+g+"' class='text_R' value='"+b+"'></span><span class='column_R4L'>"+k.helper+"</span></div>")}}JS9.cmdlineOpts||(f+="<input id='"+this.id+"_applyPrefs' name='Apply' type='button' class='button' value='Apply' onclick='JS9.Prefs.applyForm.call(this);' style='margin: 8px'>");
({}).hasOwnProperty.call(window,"localStorage")&&JS9.globalOpts.localStorage&&(f+="<input id='"+this.id+"_savePrefs' name='Save' type='button' class='button' value='Save' onclick='JS9.Prefs.saveForm.call(this)' style='margin: 8px'>",f+="<input id='"+this.id+"_showPrefs' name='Show' type='button' class='button' value='Show Saved' onclick='JS9.Prefs.showForm.call(this)' style='margin: 8px'>",f+="<input id='delete' name='Delete' type='button' class='button' value='Delete Saved' onclick='JS9.Prefs.deleteForm.call(this)' style='margin: 8px'>");
"light"===this.winType&&(f+="<input id='"+this.id+"_closePrefs' name='Close' type='button' class='button' value='Close' onclick='const form = $(this).closest(\"form\"); const winid = form.data(\"winid\"); winid.close(); return false;' style='float: right; margin: 8px'>");f+="</form>";f+="</div>"}this.divjq.addClass("JS9PluginScrolling");this.divjq.html(f);for(a=0;a<c.length;a++)e=c[a],h=this.id+JS9.Prefs.CLASS+JS9.Prefs.NAME+e.name,$("#"+h+"Form").data("display",this.display),$("#"+h+"Form").data("source",
e),"light"===this.winType&&$("#"+h+"Form").data("winid",this.winHandle);this.tabs=new ddtabcontent(d);this.tabs.setpersist(!1);this.tabs.setselectedClassTarget("link");this.tabs.init()};JS9.Prefs.applyForm=function(){var a=$(this).closest("form");var b=a.data("display"),c=a.data("source"),d=a.data("winid");a=a.serializeArray().concat($("#"+a.attr("id")+" input[type=checkbox]:not(:checked)").map(function(a,b){return{name:b.name,value:"false"}}).get());JS9.Prefs.processForm(c,a,b,d);return!1};
JS9.Prefs.saveForm=function(){var a=$(this).closest("form").data("source"),b={cmd:"desktop",mode:"save"},c={};JS9.Prefs.applyForm.call(this);if("desktop"===a.name)return window.electron?window.setTimeout(function(){try{b.cmdlineOpts=JS9.cmdlineOpts,window.electron.sendMsg(b)}catch(l){JS9.error("could not save desktop form",l)}},JS9.TIMEOUT):JS9.error("desktop save is only available for the JS9 desktop app"),!1;try{var d=a.schema.properties||{};for(var f=$jscomp.makeIterator(Object.keys(d)),e=f.next();!e.done;e=
f.next()){var h=e.value;c[h]=a.data[h]}localStorage.setItem(a.name,JSON.stringify(c,null,2));JS9.userOpts[a.name]=localStorage.getItem(a.name)}catch(l){JS9.error("could not save prefs: "+a.name)}return!1};
JS9.Prefs.showForm=function(){var a=$(this).closest("form").data("source");if("desktop"===a.name)if(JS9.cmdlineOpts){var b=JSON.stringify(JS9.cmdlineOpts,null,4);b="<pre>"+b+"</pre>"}else b="<p><center>No saved prefs: "+a.name+"</center>";else{try{b=localStorage.getItem(a.name)}catch(c){}b=b&&"null"!==b?"<pre>"+b+"</pre>":"<p><center>No saved prefs: "+a.name+"</center>"}JS9.lightWin("savedPrefs"+JS9.uniqueID(),"inline",b,"Saved prefs: "+a.name,JS9.lightOpts[JS9.LIGHTWIN].textWin);return!1};
JS9.Prefs.deleteForm=function(){var a=$(this).closest("form").data("source"),b={cmd:"desktop",mode:"remove"};if("desktop"===a.name)return window.electron?window.setTimeout(function(){try{window.electron.sendMsg(b)}catch(c){JS9.error("could not save desktop form",c)}},JS9.TIMEOUT):JS9.error("desktop save is only available for the JS9 desktop app"),!1;try{localStorage.removeItem(a.name),delete JS9.userOpts[a.name]}catch(c){}return!1};
JS9.Prefs.processForm=function(a,b,c,d){var f,e,h=b.length;switch(a.name){case "images":var l=JS9.imageOpts;break;case "regions":l=JS9.Regions.opts;break;case "grid":l=JS9.Grid.opts;break;case "fits":l=JS9.fits.options;break;case "catalogs":l=JS9.globalOpts.catalogs;break;case "globals":l=JS9.globalOpts;break;case "favorites":l=JS9.favorites;break;case "desktop":l=JS9.cmdlineOpts;break;default:JS9.error("unknown source for preferences: "+a.name)}for(d=0;d<h;d++){var g=b[d].name;var k=b[d].value;"true"===
k&&(k=!0);"false"===k&&(k=!1);switch(typeof l[g]){case "number":k=parseFloat(k);break;case "object":try{k=JSON.parse(k)}catch(m){JS9.error("invalid JSON (see jsonlint.com): "+k,m)}}if(l[g]!==k&&String(l[g]).trim()!==String(k).trim())switch(a.name){case "images":l[g]=k;c&&c.image&&("disable"===g?c.image.params.disable=k:c.image.setParam(g,k));break;case "regions":l[g]=k;for(f=0;f<JS9.displays.length;f++)(e=JS9.displays[f].layers.regions)&&(e.opts[g]=k);break;case "fits":switch(g){case "xdim":l.table.xdim=
Math.floor(parseFloat(k));break;case "ydim":l.table.ydim=Math.floor(parseFloat(k));break;case "bin":l.table.bin=Math.floor(parseFloat(k));break;case "ixdim":l.image.xdim=Math.floor(parseFloat(k));break;case "iydim":l.image.ydim=Math.floor(parseFloat(k));break;case "ibin":l.image.bin=Math.floor(parseFloat(k));break;case "binMode":JS9.globalOpts.binMode=k;break;case "clear":JS9.globalOpts.clearImageMemory=k;break;default:l[g]=k}a.data[g]=k;break;case "catalogs":switch(g){case "skip":l[g]=k+"\n";break;
default:l[g]=k}break;case "globals":switch(g){case "toolBar":l[g]=k;JS9.SetToolbar("init");break;case "toolbarTooltips":l[g]=k;break;case "logoDisplay":l[g]=k;JS9.SetToolbar("init");g=k?"block":"none";for(f=0;f<JS9.displays.length;f++)JS9.displays[f].iconjq.css("display",g);break;case "separate":l[g]=k;break;default:l[g]=k}break;case "favorites":l[g]=k;break;case "desktop":l[g]=k;break;default:l[g]=k}}if(JS9.globalOpts.extendedPlugins)for(f=0;f<JS9.displays.length;f++)JS9.displays[f].image&&JS9.displays[f].image.xeqPlugins("image",
"onupdateprefs")};JS9.RegisterPlugin(JS9.Prefs.CLASS,JS9.Prefs.NAME,JS9.Prefs.init,{menu:"file",menuItem:"Preferences",help:"help/prefs.html",winTitle:"User Preferences",winResize:!0,winDims:[JS9.Prefs.WIDTH,JS9.Prefs.HEIGHT]});JS9.RegisterPlugin(JS9.Prefs.CLASS,JS9.Prefs.NAME+"_reg",JS9.Prefs.regions,{menu:"regions",menuItem:"prefs...",help:"help/prefs.html",winTitle:"User Preferences",winResize:!0,winDims:[JS9.Prefs.WIDTH,JS9.Prefs.HEIGHT]});JS9.ScaleLimits={};JS9.ScaleLimits.CLASS="JS9";
JS9.ScaleLimits.NAME="Scale";JS9.ScaleLimits.WIDTH=512;JS9.ScaleLimits.HEIGHT=400;JS9.ScaleLimits.WIDTHOFFSET=40;JS9.ScaleLimits.HEIGHTOFFSET=210;JS9.ScaleLimits.BASE=JS9.ScaleLimits.CLASS+JS9.ScaleLimits.NAME;JS9.ScaleLimits.XSCALE="linear";JS9.ScaleLimits.YSCALE="log";JS9.ScaleLimits.NDIST=512;JS9.ScaleLimits.TIMEOUT=250;JS9.ScaleLimits.CARET=4;JS9.ScaleLimits.XTEXTHEIGHT=14;JS9.ScaleLimits.XTEXTFONT="Ariel";JS9.ScaleLimits.XTEXTCOLOR="black";JS9.ScaleLimits.XTEXTFRAC=.75;
JS9.ScaleLimits.YTEXTFRAC=.15;JS9.ScaleLimits.PLOTCOLOR="#030AE4";JS9.ScaleLimits.XLOCOLOR="#FF0000";JS9.ScaleLimits.XHICOLOR="#00FF00";JS9.ScaleLimits.AXISFONT={size:12,family:"Ariel",color:"black"};JS9.ScaleLimits.AXISFANCY=!0;JS9.ScaleLimits.dataOpts={bars:{show:!0,align:"center",barWidth:.1},clickable:!0,hoverable:!0,data:[]};JS9.ScaleLimits.plotOpts={selection:{mode:"x"},grid:{hoverable:!0}};JS9.ScaleLimits.scalelimsHTML="<div class='JS9ScaleLinegroup'>$header</div><div class='JS9ScaleLinegroup'>$scales $limits $axes</div><p><div class='JS9ScaleLinegroup'>$plot</div><p><div class='JS9ScaleLinegroup'><span class='JS9ScaleSpan' style='float: left'> $lo $hi</span></div>";
JS9.ScaleLimits.headerHTML="Set clipping limits via the Data Limits menu, or by selecting part of the Pixel Distribution plot, or by changing the Low and/or High limit.";JS9.ScaleLimits.scalesHTML="<select class=\"JS9Select JS9ScaleSelect\" onchange=\"JS9.ScaleLimits.xsetscale('%s', '%s', this)\">%s</select>";JS9.ScaleLimits.limitsHTML='<select class="JS9Select JS9ScaleSelect" onchange="JS9.ScaleLimits.xsetlims(\'%s\', \'%s\', this)"><option selected disabled>Data Limits</option><option value="dataminmax">data min/max</option><option value="zscale_z1_z2">zscale z1/z2</option><option value="zscale_z1_datamax">zscale z1/max</option></select>';
JS9.ScaleLimits.axesHTML='<select class="JS9Select JS9ScaleSelect" onchange="JS9.ScaleLimits.xaxes(\'%s\', \'%s\', this)"><option selected disabled>Plot Axes</option><option disabled>x axis:</option><option value="xlinear">linear</option><option value="xlog">log</option><option disabled>y axis:</option><option value="ylinear">linear</option><option value="ylog">log</option></select>';JS9.ScaleLimits.plotHTML='<div><center>Pixel Distribution: %s</center></div><div class="JS9ScalePlot" style="width:%spx;height:%spx"></div>';
JS9.ScaleLimits.loHTML='Low: <input type="text" class="JS9ScaleValue" value=\'%s\' onchange="JS9.ScaleLimits.xsetlo(\'%s\', \'%s\', this)" size="16">';JS9.ScaleLimits.hiHTML='High: <input type="text" class="JS9ScaleValue" value=\'%s\' onchange="JS9.ScaleLimits.xsethi(\'%s\', \'%s\', this)" size="16">';JS9.ScaleLimits.xsetscale=function(a,b,c){(a=JS9.lookupImage(b,a))&&a.setScale(c.value)};
JS9.ScaleLimits.xsetlo=function(a,b,c){if(a=JS9.lookupImage(b,a))c=parseFloat(c.value),a.setScale(c,a.params.scalemax)};JS9.ScaleLimits.xsethi=function(a,b,c){if(a=JS9.lookupImage(b,a))c=parseFloat(c.value),a.setScale(a.params.scalemin,c)};
JS9.ScaleLimits.xsetlims=function(a,b,c){if(a=JS9.lookupImage(b,a))switch(c.value){case "dataminmax":a.setScale("dataminmax",a.raw.dmin,a.raw.dmax);break;case "zscale_z1_z2":a.setScale("zscale",a.params.z1,a.params.z2);break;case "zscale_z1_datamax":a.setScale("zmax",a.params.z1,a.raw.dmax)}};JS9.ScaleLimits.log10=function(a){return 0>=a?null:Math.log(a)/Math.LN10};
JS9.ScaleLimits.xaxes=function(a,b,c){if(b=JS9.lookupImage(b,a)){a=b.display.pluginInstances[JS9.ScaleLimits.BASE];if(!a||!a.plot)return;switch(c.value){case "xlinear":a.xscale="linear";JS9.ScaleLimits.doplot.call(a,b);break;case "xlog":a.xscale="log";JS9.ScaleLimits.doplot.call(a,b);break;case "ylinear":a.yscale="linear";JS9.ScaleLimits.doplot.call(a,b);break;case "ylog":a.yscale="log",JS9.ScaleLimits.doplot.call(a,b)}}$(c).val("Plot Axes").prop("selected",!0)};
JS9.ScaleLimits.getPixelDist=function(a,b){var c,d=[],f=a.raw.dmin,e=a.raw.dmax-a.raw.dmin,h=a.raw.width*a.raw.height;for(c=0;c<b;c++)d[c]=0;for(c=0;c<h;c++){var l=Math.floor((a.raw.data[c]-f)/e*b+.5);0<=l&&l<b&&(d[l]+=1)}return d};JS9.ScaleLimits.to10E=function(a){var b="\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079".split("");return JS9.ScaleLimits.AXISFANCY&&0<=a&&9>=a?"10"+b[a]:"10E"+String(a)};
JS9.ScaleLimits.doplot=function(a){var b=this,c,d=a.raw.dmin,f=a.raw.dmax-a.raw.dmin,e=$.extend(!0,{},JS9.ScaleLimits.dataOpts),h=$.extend(!0,{},JS9.ScaleLimits.plotOpts),l=function(a,b,c){var d=a.getCanvas().getContext("2d"),g=JS9.ScaleLimits.CARET;a=a.pointOffset({x:b,y:0});d.beginPath();d.moveTo(a.left,a.top);d.lineTo(a.left-g,a.top-2*g);d.lineTo(a.left+g,a.top-2*g);d.lineTo(a.left,a.top);d.fillStyle=c;d.fill()};this.plotComplete=!1;this.plotColor&&(e.color=this.plotColor);var g=JS9.ScaleLimits.getPixelDist(a,
this.ndist);for(c=0;c<this.ndist;c++)e.data[c]=[c,g[c]];h.xaxis=h.xaxis||{};h.xaxis.font=JS9.ScaleLimits.AXISFONT;if("linear"===this.xscale){h.xaxis.transform=null;h.xaxis.ticks=[];var k=10>f?1:50>f?5:250>f?10:500>f?50:2500>f?100:5E3>f?500:25E3>f?1E3:5E4>f?5E3:25E4>f?1E4:5E5>f?5E4:25E5>f?1E5:5E6>f?5E5:25E6>f?1E6:1E7;var m=Math.floor(f/k+.5)+1;for(c=0;c<m;c++){var p=c*k;var n=String(p);h.xaxis.ticks[c]=[(p-d)*this.ndist/f,n]}}else if("log"===this.xscale)for(h.xaxis.transform=JS9.ScaleLimits.log10,
h.xaxis.min=1,h.xaxis.ticks=[],m=JS9.ScaleLimits.log10(this.ndist)+1,c=0;c<m;c++)p=Math.floor((Math.pow(10,c)-d)*this.ndist/f),h.xaxis.ticks[c]=[p,JS9.ScaleLimits.to10E(c)];var q=(a.params.scalemin-d)/f*this.ndist;var r=(a.params.scalemax-d)/f*this.ndist;h.yaxis=h.yaxis||{};h.yaxis.font=JS9.ScaleLimits.AXISFONT;if("linear"===this.yscale)h.yaxis.transform=null,h.yaxis.ticks=null;else if("log"===this.yscale){h.yaxis.transform=JS9.ScaleLimits.log10;h.yaxis.min=1;h.yaxis.ticks=[];for(c=0;c<this.ndist;c++){if(void 0===
v||g[c]<v)var v=g[c];if(void 0===u||g[c]>u)var u=g[c]}m=JS9.ScaleLimits.log10(u-v+1);for(c=0;c<m;c++)h.yaxis.ticks[c]=[Math.pow(10,c),JS9.ScaleLimits.to10E(c)]}var t=this.divjq.find(".JS9ScalePlot");this.timeout&&(window.clearTimeout(this.timeout),this.timeout=null);t.off("plotselected");t.on("plotselected",function(c,g){c=g.xaxis.from;g=g.xaxis.to;"log"===b.xscale&&(c=Math.pow(10,c),g=Math.pow(10,g));c=c*f/b.ndist+d;g=g*f/b.ndist+d;a.setScale("user",c,g)});t.off("plothover");t.on("plothover",function(a,
c){a=c.x;if(b.plot&&b.plotComplete&&("log"===b.xscale&&(a=Math.pow(10,a)),a=a*f/b.ndist+d,Number.isFinite(a))){c=JS9.floatToString(a);a=b.plot.getCanvas().getContext("2d");a.save();a.textBaseline="top";a.font=JS9.ScaleLimits.XTEXTHEIGHT+"px "+JS9.ScaleLimits.XTEXTFONT;a.fillStyle=JS9.ScaleLimits.XTEXTCOLOR||"black";var g=a.measureText(c);var e=Math.max(b.lastTextWidth,g.width+2);var k=JS9.ScaleLimits.XTEXTHEIGHT+2;g=b.plotWidth*JS9.ScaleLimits.XTEXTFRAC;var h=b.plotHeight*JS9.ScaleLimits.YTEXTFRAC;
a.clearRect(g,h,e,k);a.fillText(c,g,h);a.restore();b.lastTextWidth=e}});this.timeout=window.setTimeout(function(){b.plot=$.plot(t,[e],h);b.timeout=null;l(b.plot,q,b.xlocolor);l(b.plot,r,b.xhicolor);b.plotComplete=!0},JS9.ScaleLimits.TIMEOUT)};JS9.ScaleLimits.display=function(){this.lastimage!==this.display.image&&JS9.ScaleLimits.init.call(this)};JS9.ScaleLimits.close=function(){JS9.ScaleLimits.init.call(this,{mode:"clear"})};
JS9.ScaleLimits.init=function(a){var b;var c=function(){var a,b="<option selected disabled>Scales</option>";for(a=0;a<JS9.scales.length;a++)b+="<option>"+JS9.scales[a]+"</option>";return b};a=a||{};this.width=this.divjq.attr("data-width");this.width||(this.width=JS9.ScaleLimits.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=JS9.ScaleLimits.HEIGHT);this.divjq.css("height",this.height);this.height=
parseInt(this.divjq.css("height"),10);this.plotWidth=this.plotWidth||this.divjq.attr("data-plotWidth");this.plotWidth||(this.plotWidth=this.width-JS9.ScaleLimits.WIDTHOFFSET);this.plotHeight=this.plotHeight||this.divjq.attr("data-plotHeight");this.plotHeight||(this.plotHeight=this.height-JS9.ScaleLimits.HEIGHTOFFSET);this.xscale=this.xscale||this.divjq.attr("data-xscale");this.xscale||(this.xscale=JS9.ScaleLimits.XSCALE);this.yscale=this.yscale||this.divjq.attr("data-yscale");this.yscale||(this.yscale=
JS9.ScaleLimits.YSCALE);this.plotColor=this.plotColor||this.divjq.attr("data-plotColor");this.plotColor||(this.plotColor=JS9.ScaleLimits.PLOTCOLOR);this.xlocolor=this.xlocolor||this.divjq.attr("data-xlocolor");this.xlocolor||(this.xlocolor=JS9.ScaleLimits.XLOCOLOR);this.xhicolor=this.xhicolor||this.divjq.attr("data-xhicolor");this.xhicolor||(this.xhicolor=JS9.ScaleLimits.XHICOLOR);this.ndist=this.divjq.attr("data-ndist");this.ndist||(this.ndist=JS9.ScaleLimits.NDIST);this.divjq.html("");this.lastTextWidth=
0;this.scalelimsContainer=$("<div>").addClass(JS9.ScaleLimits.BASE+"Container").attr("id",this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);if((b=this.display.image)&&"clear"!==a.mode){var d=b.id;var f=b.display.id;a=[];a.push({name:"header",value:JS9.ScaleLimits.headerHTML});a.push({name:"scales",value:sprintf(JS9.ScaleLimits.scalesHTML,f,d,c())});a.push({name:"limits",value:sprintf(JS9.ScaleLimits.limitsHTML,f,d)});a.push({name:"axes",value:sprintf(JS9.ScaleLimits.axesHTML,
f,d)});a.push({name:"plot",value:sprintf(JS9.ScaleLimits.plotHTML,d,this.plotWidth,this.plotHeight)});a.push({name:"lo",value:sprintf(JS9.ScaleLimits.loHTML,JS9.floatToString(b.params.scalemin),f,d)});a.push({name:"hi",value:sprintf(JS9.ScaleLimits.hiHTML,JS9.floatToString(b.params.scalemax),f,d)});c=b.expandMacro(JS9.ScaleLimits.scalelimsHTML,a);this.lastimage=b}else c="<p><center>Scale parameters will appear here.</center>";this.scalelimsContainer.html(c);b&&JS9.ScaleLimits.doplot.call(this,b)};
JS9.RegisterPlugin(JS9.ScaleLimits.CLASS,JS9.ScaleLimits.NAME,JS9.ScaleLimits.init,{menu:"scale",menuItem:"Scale Controls ...",onplugindisplay:JS9.ScaleLimits.init,onsetscale:JS9.ScaleLimits.init,onimagedisplay:JS9.ScaleLimits.display,onimageclose:JS9.ScaleLimits.close,help:"help/scalecontrols.html",winTitle:"Scale Controls",winDims:[JS9.ScaleLimits.WIDTH,JS9.ScaleLimits.HEIGHT]});JS9.Separate={};JS9.Separate.CLASS="JS9";JS9.Separate.NAME="Separate";JS9.Separate.WIDTH=512;JS9.Separate.HEIGHT=336;
JS9.Separate.BASE=JS9.Separate.CLASS+JS9.Separate.NAME;JS9.Separate.topHTML="$separate<p>$gather";JS9.Separate.separateHTML='<b>separate selected</b> images or <b>separate all</b> images into different displays. The topmost (selected) image remains in place, and the presence or absence of its menubar, toolbar, and colorbar will be replicated in the new displays:<p><div><input type="button" class="separateButton1 JS9Button2" name="separate" value="separate selected" onclick="javascript:JS9.Separate.separate.call(this, \'%s\', \'selected\');">;<input type="button" class="separateButton2 JS9Button2" name="separate" value="separate all" onclick="javascript:JS9.Separate.separate.call(this, \'%s\', \'all\');"><span style=\'float: right\'><select class="separateLayoutSelect JS9Select" onchange="JS9.Separate.xlayout.call(this, \'%s\')"><option selected disabled>layout</option><option value="auto">auto</option><option value="horizontal">horizontal</option><option value="vertical">vertical</option></select></span></div><p>';
JS9.Separate.gatherHTML='<b>gather selected</b> images or <b>gather all</b> images into this display:<p><div><input type="button" class="separateButton1 JS9Button2" name="gather" value="gather selected" onclick="javascript:JS9.Separate.gather.call(this, \'%s\', \'selected\');"><input type="button" class="separateButton2 JS9Button2" name="gather" value="gather all" onclick="javascript:JS9.Separate.gather.call(this, \'%s\', \'all\');"></div><p>';JS9.Separate.imageHTML="<span style='float: left'>$active </span><span id='separateFile'>$imfile</span>";
JS9.Separate.activeHTML='<input class="separateActiveCheck" type="checkbox" id="active" name="active" value="active" onclick="javascript:JS9.Separate.xactive.call(this, \'%s\')">select';JS9.Separate.imfileHTML="<b>%s</b>";JS9.Separate.nofileHTML='<p><span id="NoFile">[Images will appear here as they are loaded]</span>';JS9.Separate.xactive=function(a){a=JS9.lookupImage(a);var b=this.checked;a&&(a.tmp.separateMode=b)};
JS9.Separate.xlayout=function(a){(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a)))&&(a=a.pluginInstances.JS9Separate)&&0<=this.selectedIndex&&(a.separateLayout=this.options[this.selectedIndex].value)};
JS9.Separate.separate=function(a,b){var c,d={};if(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a))){(c=a.pluginInstances.JS9Separate)&&c.separateLayout&&(d.layout=c.separateLayout);switch(b){case "selected":var f=[];for(b=0;b<JS9.images.length;b++)c=JS9.images[b],c.tmp.separateMode&&f.push(c);if(!f.length)return;d.images=f}a.separate(d)}};
JS9.Separate.gather=function(a,b){var c={};if(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a))){switch(b){case "all":a.gather();break;case "selected":var d=[];for(b=0;b<JS9.images.length;b++){var f=JS9.images[b];f.tmp.separateMode&&d.push(f)}if(!d.length)return;c.images=d}a.gather(c)}};JS9.Separate.imid=function(a){return(a.display.id+"_"+a.id).replace(/[^A-Za-z0-9_]/g,"_")+"SeparateImage"};JS9.Separate.dispclass=function(a){return(JS9.Separate.BASE+"_"+a.display.id).replace(/[^A-Za-z0-9_]/g,"_")};
JS9.Separate.activeImage=function(a){if(a){var b=JS9.Separate.imid(a);a=JS9.Separate.dispclass(a)+"_Image";$("."+a).removeClass(JS9.Separate.BASE+"ImageActive").addClass(JS9.Separate.BASE+"ImageInactive");$("#"+b).removeClass(JS9.Separate.BASE+"ImageInactive").addClass(JS9.Separate.BASE+"ImageActive")}};
JS9.Separate.addImage=function(a){var b=[];var c=JS9.Separate.BASE+"Image";if(a){var d=a.id;var f=JS9.Separate.imid(a);var e=JS9.Separate.dispclass(a)+"_Image";b.push({name:"imid",value:a.id});b.push({name:"active",value:sprintf(JS9.Separate.activeHTML,d)});b.push({name:"imfile",value:sprintf(JS9.Separate.imfileHTML,d)});this.separateDivs||this.separateImageContainer.html("");b=JS9.Image.prototype.expandMacro.call(a,JS9.Separate.imageHTML,b);f=$("<div>").addClass(c).addClass(e).attr("id",f).prop("imid",
d).html(b).appendTo(this.separateImageContainer);f.on("mousedown touchstart",function(){a.displayImage();JS9.Separate.activeImage(a)});this.separateDivs++;f.find(".separateActiveCheck").prop("checked",!0===a.tmp.separateMode);JS9.Separate.activeImage(a)}};JS9.Separate.removeImage=function(a){if(a){var b=JS9.Separate.imid(a);$("#"+b).remove();this.separateDivs--;0===this.separateDivs&&this.separateImageContainer.html(JS9.Separate.nofileHTML);delete a.tmp.separateMode;return!0}return!1};
JS9.Separate.init=function(){var a=this;var b=[];this.divjq.html("");this.separateDivs=0;this.divjq.addClass("JS9PluginScrolling");this.separateContainer=$("<div>").addClass(JS9.Separate.BASE+"Container").attr("id",this.id+"SeparateContainer").css("overflow","auto").appendTo(this.divjq);var c=this.display.id;b.push({name:"separate",value:sprintf(JS9.Separate.separateHTML,c,c,c)});b.push({name:"gather",value:sprintf(JS9.Separate.gatherHTML,c,c)});b=JS9.Image.prototype.expandMacro.call(null,JS9.Separate.topHTML,
b);this.separateHeader=$("<div>").addClass(JS9.Separate.BASE+"Header").attr("id",c+"Header").html(b).appendTo(this.separateContainer);this.separateImageContainer=$("<div>").addClass(JS9.Separate.BASE+"ImageContainer").attr("id",this.id+"SeparateImageContainer").html(JS9.Separate.nofileHTML).appendTo(this.separateContainer);var d=JS9.getDynamicDisplayOr(this.display);for(c=0;c<JS9.images.length;c++)b=JS9.images[c],b.display===d&&JS9.Separate.addImage.call(this,b);this.separateImageContainer.sortable({start:function(b,
c){a.oidx=c.item.index()},stop:function(b,c){b=c.item.index();a.display.moveImageInStack(a.oidx,b);a.display.image&&a.display.image.displayImage();delete a.oidx}})};JS9.Separate.imageload=function(a){var b=JS9.getDynamicDisplayOr(this.display);a&&a.display===b&&JS9.Separate.addImage.call(this,a)};JS9.Separate.imagedisplay=function(a){JS9.Separate.activeImage.call(this,a)};JS9.Separate.imageclose=function(a){JS9.Separate.removeImage.call(this,a)};JS9.Separate.reinit=function(a){a&&JS9.Separate.init.call(this)};
JS9.RegisterPlugin(JS9.Separate.CLASS,JS9.Separate.NAME,JS9.Separate.init,{menuItem:"Separate/Gather",dynamicSelect:!0,onplugindisplay:JS9.Separate.init,ondynamicselect:JS9.Separate.reinit,ongatherdisplay:JS9.Separate.reinit,onimageload:JS9.Separate.imageload,onimagedisplay:JS9.Separate.imagedisplay,onimageclose:JS9.Separate.imageclose,help:"help/separate.html",winTitle:"Separate/Gather Images",winResize:!0,winDims:[JS9.Separate.WIDTH,JS9.Separate.HEIGHT]});JS9.Statusbar={};JS9.Statusbar.CLASS="JS9";
JS9.Statusbar.NAME="Statusbar";JS9.Statusbar.WIDTH=512;JS9.Statusbar.HEIGHT=32;JS9.Statusbar.COLORWIDTH=120;JS9.Statusbar.COLORHEIGHT=14;JS9.Statusbar.BASE=JS9.Statusbar.CLASS+JS9.Statusbar.NAME;JS9.Statusbar.mover=function(a){$(a).removeClass("JS9StatusbarItemNoHighlight JS9StatusbarItemHighlight2");$(a).addClass("JS9StatusbarItemHighlight")};JS9.Statusbar.mout=function(a){$(a).removeClass("JS9StatusbarItemHighlight JS9StatusbarItemHighlight2");$(a).addClass("JS9StatusbarItemNoHighlight")};
JS9.Statusbar.mdown=function(a){$(a).removeClass("JS9StatusbarItemNoHighlight JS9StatusbarItemHighlight");$(a).addClass("JS9StatusbarItemHighlight2")};
JS9.Statusbar.mup=function(a,b){var c;$(a).removeClass("JS9StatusbarItemNoHighlight JS9StatusbarItemHighlight2");$(a).addClass("JS9StatusbarItemHighlight");(a=$(a).attr("name"))&&(c=a.match(/file|image|edit|view|zoom|rot|flip|scale|color|regions|wcs|analysis|mag/i));if(c&&c[0])switch(c[0]){case "file":case "image":JS9.DisplayPlugin("FITSBinning",{display:b});break;case "flip":case "rot":case "mag":case "zoom":JS9.DisplayPlugin("JS9PanZoom",{display:b});break;case "scale":JS9.DisplayPlugin("JS9Scale",
{display:b});break;case "color":JS9.DisplayPlugin("JS9Color",{display:b})}};
JS9.Statusbar.display=function(a,b){var c,d="";var f=/;/;b=b||{};if(a&&JS9.globalOpts.statusBar){var e=JS9.globalOpts.statusBar;(c=a.display.pluginInstances.JS9Colorbar)&&c.isActive()&&!this.mycolorbar&&(e=e.replace(/\$colorbar;? */,""));c=e.replace(/\(/g," __OP__ ").replace(/\)/g," __CP__ ").replace(/\[/g," __OB__ ").replace(/\]/g," __CB__ ");c=a.expandMacro(c).replace(/ __OP__ /g,"(").replace(/ __CP__ /g,")").replace(/ __OB__ /g,"[").replace(/ __CB__ /g,"]");if(this.statusBar!==e||b.reinit){b=e.split(f);
var h=c.split(f);for(f=0;f<h.length;f++)c=("<div name='__dummy__' class='JS9StatusbarItem JS9StatusbarItemNoHighlight' onmousedown='JS9.Statusbar.mdown(this)' onmouseup='JS9.Statusbar.mup(this, \""+this.display.id+"\")' onmouseover='JS9.Statusbar.mover(this)' onmouseout='JS9.Statusbar.mout(this)'>"+h[f]+"</div>").replace(/\$img\(([^()]+)\)/g,"<img src='$1' name='$1' class='JS9StatusbarImageItem JS9StatusbarItemNoHighlight'>").replace(/\$colorbar/g,"<div name='JS9Colorbar' id='"+this.id.replace(/Statusbar/,
"Colorbar")+"' class='JS9Colorbar JS9StatusbarPluginItem' data-width=\""+this.colorwidth+'px" data-height="'+this.colorheight+'px" data-colorbarHeight="'+this.colorheight+'px" data-showTicks="false" ></div>').replace(/__dummy__/,b[f].replace(/\s+/,"_")),d+=c;this.statusContainer.html(d);e.match(/\$colorbar/)&&(JS9.AddDivs({display:a}),this.mycolorbar=this.display.pluginInstances.JS9Colorbar,a=JS9.globalOpts.resizeDivs.indexOf("JS9Colorbar"),0<=a&&JS9.globalOpts.resizeDivs.splice(a,1));this.statusBar=
e}else for(e=this.divjq.find(".JS9StatusbarItem"),h=c.split(f),f=0;f<e.length;f++)h[f].match(/\$colorbar/)?this.mycolorbar&&this.isDynamic&&JS9.Colorbar.display.call(this.mycolorbar,a):h[f].match(/\$img/)?(c=h[f].match(/\$img\((.*)\)/))&&c[1]&&("/"!==c[1].charAt(0)&&(c[1]=JS9.InstallDir(c[1])),$(e[f]).find("img").attr("src",c[1])):$(e[f]).html(h[f])}else if(this.statusBar)for(h=this.statusBar.split(f),e=this.divjq.find(".JS9StatusbarItem"),f=0;f<e.length;f++)h[f].match(/\$colorbar/)||$(e[f]).html("")};
JS9.Statusbar.init=function(a,b){this.width=this.divjq.attr("data-width");this.width||(this.width=a||JS9.Statusbar.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=b||JS9.Statusbar.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.colorwidth=parseInt(this.divjq.attr("data-colorbarWidth"),10)||JS9.Statusbar.COLORWIDTH+Math.max(this.display.width-
512,0);this.colorheight=parseInt(this.divjq.attr("data-colorbarHeight"),10)||JS9.Statusbar.COLORHEIGHT;this.divjq.html("");this.statusContainer=$("<div>").addClass(JS9.Statusbar.BASE+"Container").attr("id",this.id+"Container").attr("width",this.width).attr("height",this.height).appendTo(this.divjq);this.display.image&&JS9.Statusbar.display.call(this,this.display.image)};JS9.Statusbar.imagedisplay=function(a){a&&JS9.Statusbar.display.call(this,a)};
JS9.Statusbar.imageclear=function(a){JS9.Statusbar.display.call(this,null)};JS9.Statusbar.dynamic=function(a){var b;a&&(b=a.display.pluginInstances.JS9Statusbar)&&b.isDynamic&&JS9.Statusbar.imagedisplay.call(this,a)};
JS9.RegisterPlugin(JS9.Statusbar.CLASS,JS9.Statusbar.NAME,JS9.Statusbar.init,{menuItem:"Statusbar",dynamicSelect:!0,ondynamicselect:JS9.Statusbar.dynamic,onimagedisplay:JS9.Statusbar.imagedisplay,onimageclear:JS9.Statusbar.imageclear,onimageclose:JS9.Statusbar.imageclear,onsetwcssys:JS9.Statusbar.imagedisplay,onsetwcsunits:JS9.Statusbar.imagedisplay,help:"help/statusbar.html",winTitle:"Statusbar",winDims:[JS9.Statusbar.WIDTH,JS9.Statusbar.HEIGHT]});JS9.Sync={};JS9.Sync.CLASS="JS9";JS9.Sync.NAME="Sync";
JS9.Sync.getOps=function(a){var b,c,d=[];a=a||JS9.globalOpts.syncOps;if(!$.isArray(a))try{a=JSON.parse(a)}catch(e){a=[a]}for(c=b=0;b<a.length;b++){var f=a[b];switch(f){case "wcs":d[c++]="wcssys";d[c++]="wcunits";break;default:d[c++]=f}}return d};JS9.Sync.getIms=function(a){var b,c,d=[];a=a||JS9.images;if(!$.isArray(a))try{a=JSON.parse(a)}catch(e){a=[a]}for(c=b=0;b<a.length;b++){var f="string"===typeof a[b]?JS9.lookupImage(a[b]):a[b];!f||f.id===this.id&&f.display.id===this.display.id||(d[c++]=f)}return d};
JS9.Sync.sync=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d=$jscomp.makeIterator(b);var f=d.next().value;c=d.next().value;d=d.next().value;var e=[];this.syncs=this.syncs||{active:!0};d=d||{reciprocate:JS9.globalOpts.syncReciprocate};if("string"===typeof d)try{d=JSON.parse(d)}catch(p){JS9.error("can't parse sync opts: "+d,p)}if(1===b.length&&"boolean"===typeof f)this.syncs.active=f;else{var h=JS9.Sync.getOps.call(this,f);var l=JS9.Sync.getIms.call(this,c);var g=l.length;
if(d.reverse)for(delete d.reverse,b=0;b<g;b++)JS9.Sync.sync.call(l[b],h,[this]);else{for(b=0;b<h.length;b++){var k=h[b];this.syncs[k]=this.syncs[k]||[];c=this.syncs[k];for(f=0;f<g;f++){var m=l[f];0>$.inArray(m,c)&&(c.push(m),e.push({im:this,xim:m,xop:k,xarg:null}))}}if(d.reciprocate){JS9.Sync.reciprocating=!0;d.reciprocate=!1;b=0;for(m=this;b<g;b++)l.push(m),m=l.shift(),JS9.Sync.sync.call(m,h,l,d);delete JS9.Sync.reciprocating}JS9.notNull(d.syncwcs)?this.tmp.syncwcs=d.syncwcs:this.tmp.syncwcs=JS9.globalOpts.syncWCS;
JS9.Sync.reciprocating||(JS9.Sync.xeqSync.call(this,e),JS9.Sync.ready=!0)}}};
JS9.Sync.unsync=function(a,b,c){var d;if(this.syncs){c=c||{reciprocate:JS9.globalOpts.syncReciprocate};a=JS9.Sync.getOps.call(this,a);b=JS9.Sync.getIms.call(this,b);var f=b.length;if(c.reverse)for(delete c.reverse,d=0;d<f;d++)JS9.Sync.unsync.call(b[d],a,[this]);else{var e=$jscomp.makeIterator(Object.keys(this.syncs));for(d=e.next();!d.done;d=e.next()){var h=d.value;if(!(a&&0>$.inArray(h,a)))if(b){var l=this.syncs[h];for(d=l.length-1;0<=d;d--)0<=$.inArray(l[d],b)&&l.splice(d,1);l.length||delete this.syncs[h]}else delete this.syncs[h]}Object.keys(this.syncs).length||
delete this.syncs;if(c.reciprocate){JS9.Sync.reciprocating=!0;c.reciprocate=!1;d=0;for(e=this;d<f;d++)b.push(e),e=b.shift(),JS9.Sync.unsync.call(e,a,b,c);delete JS9.Sync.reciprocating}}}};
JS9.Sync.xeqSync=function(a){var b,c,d,f,e,h={},l=JS9.globalOpts.xeqPlugins,g=this.id+"_"+this.display.id,k=function(a,b){return a.data&&a.data.syncid&&b.data&&b.data.syncid?a.data.syncid===b.data.syncid:!1},m=function(a){var b=0,c=0,d="";var g=a.split("");for(a=0;a<g.length;a++)switch(g[a]){case "x":b++;break;case "y":c++}1===b%2&&(d+="x");1===c%2&&(d+="y");return d||""};if(!this.tmp.syncRunning){this.tmp.syncRunning=!0;try{for(b=0;b<a.length;b++){var p=a[b];"regions"===p.xop&&(a.splice(b,1),a.unshift(p))}for(b=
0;b<a.length;b++){p=a[b];var n=p.xim;if(n.syncs){if(n.tmp.syncRunning)continue;n.tmp.syncRunning=!0;n===n.display.image||h[n.display.id]||(h[n.display.id]=n.display.image)}try{switch(p.xop){case "alignment":n.alignPanZoom(this);break;case "colormap":n.setColormap(this.params.colormap);break;case "contrastbias":n.setColormap(this.params.contrast,this.params.bias);break;case "flip":if(this.params.flip!=n.params.flip){var q=m(this.params.flip+n.params.flip);n.setFlip(q)}break;case "pan":var r=this.getPan();
if(this.tmp.syncwcs&&this.validWCS()){var v=JS9.pix2wcs(this.raw.wcs,r.ox,r.oy);n.setPan({wcs:v})}else n.setPan(r.ox,r.oy);break;case "regions":var u=[];var t=null;if(p.xarg)u.push(p.xarg);else for(e||(e=this.getShapes("regions","all")),t=n.getShapes("regions","all"),c=0;c<e.length;c++){e[c].mode="add";for(d=0;d<t.length;d++)if(k(t[d],e[c])){e[c].mode="update";break}u.push(e[c])}for(c=0;c<u.length;c++){var x=$.extend(!0,{},u[c]);var A=x.data&&x.data.syncid?x.data.syncid:g+"_"+x.id;switch(x.mode){case "add":var z=
{doexport:!1,syncid:A};JS9.globalOpts.xeqPlugins=!1;this.changeShapes("regions",x.id,{data:z});JS9.globalOpts.xeqPlugins=l;var B=this.listRegions(x.id,{mode:1});n.addShapes("regions",B,{data:z});break;case "remove":t||(t=n.getShapes("regions","all"));for(d=0;d<t.length;d++){var E=t[d];(f=E.data)&&f.syncid&&f.syncid===A&&n.removeShapes("regions",A)}break;case "move":case "update":for(delete x.sizeScale,this.raw.wcsinfo&&n.raw.wcsinfo&&(n.raw.wcsinfo.cdelt1&&(x.sizeScale=this.raw.wcsinfo.cdelt1/n.raw.wcsinfo.cdelt1),
n.raw.wcsinfo.crot&&("box"===x.shape||"ellipse"===x.shape||"text"===x.shape&&!x.parent)&&(x.angle+=n.raw.wcsinfo.crot)),t||(t=n.getShapes("regions","all")),d=0;d<t.length;d++)E=t[d],(f=E.data)&&f.syncid&&f.syncid===A&&n.changeShapes("regions",A,x)}}break;case "rot90":if(this.params.rot90!=n.params.rot90){var w=this.params.rot90-n.params.rot90||0;switch(w){case 90:case -270:n.setRot90(90);break;case -90:case 270:n.setRot90(-90)}}break;case "rotate":this.params.rotate!=n.params.rotate&&(w=this.params.rotate-
n.params.rotate||0,n.setRotate(w));break;case "scale":n.setScale(this.params.scale);break;case "wcssys":n.setWCSSys(this.params.wcssys);break;case "wcsunits":n.setWCSUnits(this.params.wcsunits);break;case "zoom":n.setZoom(this.params.zoom)}}catch(F){}finally{delete n.tmp.syncRunning}}for(var y=$jscomp.makeIterator(Object.keys(h)),L=y.next();!L.done;L=y.next()){var K=L.value;h[K].displayImage()}}catch(F){}finally{this.displayImage(),delete this.tmp.syncRunning}}};
JS9.Sync.maybeSync=function(a,b){var c,d;if(JS9.Sync.ready&&this.syncs&&!this.tmp.syncRunning&&($.isArray(a)||(a=[a]),this.syncs.active))for(d=0;d<a.length;d++){var f=a[d];if($.isArray(this.syncs[f])&&this.syncs[f].length){var e=this.syncs[f];var h=[];for(c=0;c<e.length;c++)h.push({xim:e[c],xop:f,xarg:b});JS9.Sync.xeqSync.call(this,h)}}};JS9.Sync.init=function(){return this};JS9.Sync.setcolormap=function(a){a&&JS9.Sync.maybeSync.call(a,"colormap")};
JS9.Sync.changecontrastbias=function(a){a&&JS9.Sync.maybeSync.call(a,"contrastbias")};JS9.Sync.setflip=function(a){a&&JS9.Sync.maybeSync.call(a,["flip","alignment"])};JS9.Sync.setpan=function(a){a&&JS9.Sync.maybeSync.call(a,["pan","alignment"])};JS9.Sync.setrot90=function(a){a&&JS9.Sync.maybeSync.call(a,["rot90","alignment"])};JS9.Sync.setrotate=function(a){a&&JS9.Sync.maybeSync.call(a,["rotate","alignment"])};
JS9.Sync.regionschange=function(a,b){if(a)switch(b.mode){case "select":case "unselect":break;default:JS9.Sync.maybeSync.call(a,"regions",b)}};JS9.Sync.setscale=function(a){a&&JS9.Sync.maybeSync.call(a,"scale")};JS9.Sync.setwcssys=function(a){a&&JS9.Sync.maybeSync.call(a,"wcssys")};JS9.Sync.setwcsunits=function(a){a&&JS9.Sync.maybeSync.call(a,"wcsunits")};JS9.Sync.setzoom=function(a){a&&JS9.Sync.maybeSync.call(a,["zoom","alignment"])};
JS9.Sync.loadimage=function(a){var b;if(a)for(a=0;a<JS9.displays.length;a++)(b=JS9.displays[a].pluginInstances.JS9SyncUI)&&b.isActive()&&JS9.SyncUI.init.call(b)};JS9.Sync.closeimage=function(a){var b;if(a){for(b=0;b<JS9.images.length;b++)JS9.Sync.unsync.call(JS9.images[b],null,[a]);for(b=0;b<JS9.displays.length;b++)(a=JS9.displays[b].pluginInstances.JS9SyncUI)&&a.isActive()&&JS9.SyncUI.init.call(a)}};JS9.Image.prototype.syncImages=JS9.Sync.sync;JS9.mkPublic("SyncImages","syncImages");
JS9.Image.prototype.unsyncImages=JS9.Sync.unsync;JS9.mkPublic("UnsyncImages","unsyncImages");
JS9.RegisterPlugin(JS9.Sync.CLASS,JS9.Sync.NAME,JS9.Sync.init,{onsetcolormap:JS9.Sync.setcolormap,onsetflip:JS9.Sync.setflip,onsetpan:JS9.Sync.setpan,onregionschange:JS9.Sync.regionschange,onsetrot90:JS9.Sync.setrot90,onsetrotate:JS9.Sync.setrotate,onsetscale:JS9.Sync.setscale,onsetwcssys:JS9.Sync.setwcssys,onsetwcsunits:JS9.Sync.setwcsunits,onsetzoom:JS9.Sync.setzoom,onchangecontrastbias:JS9.Sync.changecontrastbias,onimageload:JS9.Sync.loadimage,onimageclose:JS9.Sync.closeimage,winDims:[0,0]});
JS9.SyncUI={};JS9.SyncUI.CLASS="JS9";JS9.SyncUI.NAME="SyncUI";JS9.SyncUI.WIDTH=512;JS9.SyncUI.HEIGHT=430;JS9.SyncUI.BASE=JS9.SyncUI.CLASS+JS9.SyncUI.NAME;JS9.SyncUI.HEADER="<div class='JS9SyncUIText'><br><b>%s:</b></div>";JS9.SyncUI.NCOL=3;JS9.SyncUI.COLWIDTH=175;JS9.SyncUI.headerHTML="Synchronize two or more images, so that when an operation is performed on one image, it also is performed on the other(s). Or sync once only.";JS9.SyncUI.opHTML="$opactive $opname";
JS9.SyncUI.opactiveHTML='<input class="JS9SyncUIOpCheck" type="checkbox" name="%s" value="active"">';JS9.SyncUI.opnameHTML="<b>%s</b>";JS9.SyncUI.imageHTML="$imactive $imfile";JS9.SyncUI.imactiveHTML='<input class="JS9SyncUIImCheck" type="checkbox" name="%s" value="active">';JS9.SyncUI.imfileHTML="<b>%s</b>";JS9.SyncUI.nofileHTML='<p><span class="JS9SyncUINoFile">[Images will appear here as they are loaded]</span>';JS9.SyncUI.optsHTML='<div class="JS9SyncUIOptsRow">$reciprocate $syncwcs</div>';
JS9.SyncUI.reciprocalHTML='<span class="JS9SyncUIOpts" style="position:absolute; left:%spx; top:0px"><input class="JS9SyncUIOptsCheck" type="checkbox" name="%s" value="active" onchange="javascript:JS9.SyncUI.xrecip(\'%s\', this)"> <b>%s</b></span>';JS9.SyncUI.syncwcsHTML='<span class="JS9SyncUIOpts" style="position:absolute; left:%spx; top:0px"><input class="JS9SyncUIOptsCheck" type="checkbox" name="%s" value="active" onchange="javascript:JS9.SyncUI.xsyncwcs(\'%s\', this)"> <b>%s</b></span>';
JS9.SyncUI.footerHTML='<div class="JS9SyncUIButtons" <p><span style="float:right;">$cancel $sync $once $unsync</span></div>';JS9.SyncUI.cancelHTML='<span class="JS9SyncUIButton"><input type="button" class="JS9Button2 JS9SyncUIButton" id="active" name="sync" value="Cancel" onclick="javascript:JS9.SyncUI.xcancel(\'%s\', this)" %s></span>';JS9.SyncUI.syncHTML='<span class="JS9SyncUIButton"><input type="button" class="JS9RunButton JS9SyncUIButton" id="active" name="sync" value="Sync Repeatedly" onclick="javascript:JS9.SyncUI.xsync(\'%s\', this)"></span>';
JS9.SyncUI.onceHTML='<span class="JS9SyncUIButton"><input type="button" class="JS9RunButton JS9SyncUIButton" id="active" name="once" value="Sync Once" onclick="javascript:JS9.SyncUI.xonce(\'%s\', this)"></span>';JS9.SyncUI.unsyncHTML='<span class="JS9SyncUIButton"><input type="button" class="JS9RunButton JS9SyncUIButton" id="active" name="unsync" value="Unsync" onclick="javascript:JS9.SyncUI.xunsync(\'%s\', this)"></span>';
JS9.SyncUI.getImsOpsOpts=function(a){a=a.closest(".JS9SyncUIContainer");var b=[],c=[],d={};a.length&&(a.find(".JS9SyncUIImCheck").each(function(a,b){a=$(b).prop("name");$(b).prop("checked")&&c.push(a)}),a.find(".JS9SyncUIOpCheck").each(function(a,c){a=$(c).prop("name");$(c).prop("checked")&&b.push(a)}),a.find(".JS9SyncUIOptsCheck").each(function(a,b){a=$(b).prop("name");b=$(b).prop("checked");d[a]=b}));return{ims:c,ops:b,opts:d}};
JS9.SyncUI.xcancel=function(a,b){(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a)))&&(a=a.pluginInstances.JS9SyncUI)&&a.winHandle&&a.winHandle.close()};JS9.SyncUI.xsync=function(a,b){a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a));if(a.image){a=a.image;var c=JS9.SyncUI.getImsOpsOpts($(b));b=c.ims;var d=c.ops;c=c.opts;b.length&&d.length&&a.syncImages(d,b,c);JS9.SyncUI.setCheckboxes(a)}};
JS9.SyncUI.xonce=function(a,b){a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a));if(a.image){a=a.image;var c=JS9.SyncUI.getImsOpsOpts($(b));b=c.ims;c=c.ops;b.length&&c.length&&(a.copyParams(c,b),JS9.SyncUI.setCheckboxes(a))}};JS9.SyncUI.xunsync=function(a,b){a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a));if(a.image){a=a.image;var c=JS9.SyncUI.getImsOpsOpts($(b));b=c.ims;var d=c.ops;c=c.opts;b.length&&d.length&&a.unsyncImages(d,b,c);JS9.SyncUI.setCheckboxes(a)}};
JS9.SyncUI.xrecip=function(a,b){if(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a)))a=a.pluginInstances.JS9SyncUI,a.syncReciprocate=$(b).is(":checked")};JS9.SyncUI.xsyncwcs=function(a,b){if(a=JS9.getDynamicDisplayOr(JS9.lookupDisplay(a)))a=a.pluginInstances.JS9SyncUI,a.syncWCS=$(b).is(":checked")};JS9.SyncUI.imid=function(a){return(a.display.id+"_"+a.id).replace(/[^A-Za-z0-9_]/g,"_")+"SyncImage"};
JS9.SyncUI.setCheckboxes=function(a){var b,c;if(a){var d=a.display.pluginInstances.JS9SyncUI;d.syncContainer.find(".JS9SyncUIOpCheck").prop("checked",!1);d.syncContainer.find(".JS9SyncUIImCheck").prop("checked",!1);d.syncContainer.find(".JS9SyncUIOptsCheck").prop("checked",!1);var f=JS9.globalOpts.syncOps;if(a.syncs)for(b=0;b<f.length;b++){var e=f[b];if($.isArray(a.syncs[e]))for(d.syncContainer.find(".JS9SyncUIOpCheck").filter("[name='"+e+"']").prop("checked",!0),c=0;c<a.syncs[e].length;c++)if(JS9.isImage(a.syncs[e][c])){var h=
a.syncs[e][c].id.replace(/\[.*\]/,"");d.syncContainer.find(".JS9SyncUIImCheck").filter("[name^='"+h+"']").prop("checked",!0)}}d.syncContainer.find(".JS9SyncUIOptsCheck").filter('[name="reciprocate"]').prop("checked",d.syncReciprocate);d.syncContainer.find(".JS9SyncUIOptsCheck").filter('[name="syncwcs"]').prop("checked",d.syncWCS)}};
JS9.SyncUI.addOp=function(a,b){var c=[],d=JS9.SyncUI.BASE+"Op";switch(a){case "contrastbias":var f="contrast/bias";break;case "wcs":f="wcs sys/units";break;default:f=a}c.push({name:"op",value:a});c.push({name:"opactive",value:sprintf(JS9.SyncUI.opactiveHTML,a)});c.push({name:"opname",value:sprintf(JS9.SyncUI.opnameHTML,f)});a=JS9.Image.prototype.expandMacro.call(null,JS9.SyncUI.opHTML,c);this.syncOpDivs++;return'<span class="JS9SyncUIOp" style="position:absolute; left:'+b*JS9.SyncUI.COLWIDTH+'px; top:0px" id="'+
d+'">'+a+"</span>"};JS9.SyncUI.addImage=function(a){var b=[],c=JS9.SyncUI.BASE+"ImageRow";if(a){var d=a.id;var f=JS9.SyncUI.imid(a);b.push({name:"imid",value:a.id});b.push({name:"imactive",value:sprintf(JS9.SyncUI.imactiveHTML,d)});b.push({name:"imfile",value:sprintf(JS9.SyncUI.imfileHTML,d)});a=a.expandMacro(JS9.SyncUI.imageHTML,b);this.syncImageDivs++;return'<div class="'+c+'" id="'+f+'">'+a+"</div>"}};
JS9.SyncUI.removeImage=function(a){return a?(a=JS9.SyncUI.imid(a),$("#"+a).remove(),this.syncImageDivs--,this.syncImageDivs||this.syncImageContainer.html(""),!0):!1};
JS9.SyncUI.init=function(){if(this.divjq&&this.divjq.is(":visible")){this.divjq.html("");this.syncImageDivs=this.syncOpDivs=0;this.divjq.addClass("JS9PluginScrolling");JS9.isNull(this.syncReciprocate)&&(this.syncReciprocate=JS9.globalOpts.syncReciprocate);JS9.isNull(this.syncWCS)&&(this.syncWCS=JS9.globalOpts.syncWCS);var a=this.display.id;if(this.display.image){this.lastim=this.display.image;var b=sprintf(JS9.SyncUI.HEADER,"Images that can be synced with "+this.lastim.id)}else this.lastim=null,b=
sprintf(JS9.SyncUI.HEADER,"Images that can be synced");this.syncContainer=$("<div>").addClass(JS9.SyncUI.BASE+"Container").attr("id",this.id+"SyncContainer").css("overflow","auto").appendTo(this.divjq);var c=JS9.Image.prototype.expandMacro.call(null,JS9.SyncUI.headerHTML);this.syncHeader=$("<div>").addClass(JS9.SyncUI.BASE+"Header").attr("id",a+"Header").html(c).appendTo(this.syncContainer);this.syncImageContainer=$("<div>").addClass(JS9.SyncUI.BASE+"ImageContainer").attr("id",this.id+"SyncImageContainer").html(b).appendTo(this.syncContainer);
b="";for(c=0;c<JS9.images.length;c++){var d=JS9.images[c];d!==this.display.image&&"closing"!==d.getStatus("close")&&(b+=JS9.SyncUI.addImage.call(this,d))}b=b||JS9.SyncUI.nofileHTML;this.syncImageContainer.append(b);this.syncOpContainer=$("<div>").addClass(JS9.SyncUI.BASE+"OpContainer").attr("id",this.id+"SyncOpContainer").html(sprintf(JS9.SyncUI.HEADER,"Operations that can be synced")).appendTo(this.syncContainer);var f=JS9.globalOpts.syncOps;var e=Math.floor((f.length+JS9.SyncUI.NCOL-1)/JS9.SyncUI.NCOL);
for(d=0;d<e;d++){b='<div class="'+JS9.SyncUI.BASE+'OpRow" id="'+this.id+'SyncOpRow">';for(c=0;c<JS9.SyncUI.NCOL;c++){var h=c*e+d;f[h]&&(h=f[h],b+=JS9.SyncUI.addOp.call(this,h,c))}b+="</div>";this.syncOpContainer.append(b)}c=sprintf(JS9.SyncUI.HEADER,"Sync options");this.syncOptsContainer=$("<div>").addClass(JS9.SyncUI.BASE+"OptsContainer").attr("id",this.id+"SyncOptsContainer").html(c).appendTo(this.syncContainer);c=[];c.push({name:"reciprocate",value:sprintf(JS9.SyncUI.reciprocalHTML,0*JS9.SyncUI.COLWIDTH,
"reciprocate",a,"reciprocal sync")});c.push({name:"syncwcs",value:sprintf(JS9.SyncUI.syncwcsHTML,1*JS9.SyncUI.COLWIDTH,"syncwcs",a,"sync using wcs")});c=JS9.Image.prototype.expandMacro.call(null,JS9.SyncUI.optsHTML,c);this.syncOpts=$("<div>").attr("id",a+"Opts").html(c).appendTo(this.syncOptsContainer);c=[];c.push({name:"cancel",value:sprintf(JS9.SyncUI.cancelHTML,a,this.winHandle?"":'style="display:none;"')});c.push({name:"sync",value:sprintf(JS9.SyncUI.syncHTML,a)});c.push({name:"once",value:sprintf(JS9.SyncUI.onceHTML,
a)});c.push({name:"unsync",value:sprintf(JS9.SyncUI.unsyncHTML,a)});c=JS9.Image.prototype.expandMacro.call(null,JS9.SyncUI.footerHTML,c);this.syncFooter=$("<div>").addClass(JS9.SyncUI.BASE+"Footer").attr("id",a+"Footer").html(c).appendTo(this.syncContainer);this.display.image&&JS9.SyncUI.setCheckboxes(this.display.image)}};JS9.SyncUI.reinit=function(a){JS9.SyncUI.init.call(this)};JS9.SyncUI.imageload=function(a){a&&JS9.SyncUI.init.call(this)};
JS9.SyncUI.imagedisplay=function(a){a&&a!==this.lastim&&JS9.SyncUI.init.call(this)};JS9.SyncUI.imageclose=function(a){var b;if(a){for(b=0;b<JS9.images.length;b++)JS9.SyncUI.unsync.call(JS9.images[b],null,[a]);JS9.SyncUI.init.call(this)}};
JS9.RegisterPlugin(JS9.SyncUI.CLASS,JS9.SyncUI.NAME,JS9.SyncUI.init,{menuItem:"Sync Images",onplugindisplay:JS9.SyncUI.reinit,onimagedisplay:JS9.SyncUI.imagedisplay,onimageload:JS9.SyncUI.imageload,onimageclose:JS9.SyncUI.imageclose,help:"help/syncui.html",winTitle:"Sync Images",winDims:[JS9.SyncUI.WIDTH,JS9.SyncUI.HEIGHT]});JS9.Toolbar={};JS9.Toolbar.CLASS="JS9";JS9.Toolbar.NAME="Toolbar";JS9.Toolbar.WIDTH=512;JS9.Toolbar.HEIGHT=36;JS9.Toolbar.BASE=JS9.Toolbar.CLASS+JS9.Toolbar.NAME;
JS9.Toolbar.IMAGEWIDTH=24;JS9.Toolbar.IMAGEHEIGHT=24;JS9.Toolbar.TOOLBARHEIGHT=36;JS9.Toolbar.TOOLTIPX=30;JS9.Toolbar.TOOLTIPY=50;JS9.Toolbar.TOOLTIPLX=30;JS9.Toolbar.TOOLTIPLY=82;
JS9.Toolbar.tools=[{name:"linear",tip:"linear scale",cmd:"SetScale",args:["linear"]},{name:"log",tip:"log scale",cmd:"SetScale",args:["log"]},{name:"histeq",tip:"histogram equalization",cmd:"SetScale",args:["histeq"]},{name:"power",tip:"power scale",cmd:"SetScale",args:["power"]},{name:"sqrt",tip:"square root scale",cmd:"SetScale",args:["sqrt"]},{name:"asinh",tip:"asinh scale",cmd:"SetScale",args:["asinh"]},{name:"sinh",tip:"sinh scale",cmd:"SetScale",args:["sinh"]},{name:"squared",tip:"squared scale",
cmd:"SetScale",args:["squared"]},{name:"annulus",tip:"annulus region",image:"images/voyager/regions_annulus.svg",cmd:"AddRegions",args:["annulus"]},{name:"box",tip:"box region",image:"images/voyager/regions_box.svg",cmd:"AddRegions",args:["box"]},{name:"circle",tip:"circle region",image:"images/voyager/regions_circle.svg",cmd:"AddRegions",args:["circle"]},{name:"ellipse",tip:"ellipse region",image:"images/voyager/regions_ellipse.svg",cmd:"AddRegions",args:["ellipse"]},{name:"line",tip:"line region",
image:"images/voyager/regions_line.svg",cmd:"AddRegions",args:["line"]},{name:"polygon",tip:"polygon region",image:"images/voyager/regions_polygon.svg",cmd:"AddRegions",args:["polygon"]},{name:"text",tip:"text region",image:"images/voyager/regions_text.svg",cmd:"AddRegions",args:["text"]},{name:"inc/excl",tip:"toggle selected region incl/excl",cmd:"ToggleRegionTags",args:["selected","include","exclude"]},{name:"src/bkg",tip:"toggle selected region src/bkg",cmd:"ToggleRegionTags",args:["selected",
"source","background"]},{name:"remove",tip:"remove selected region",cmd:"RemoveRegions",args:["selected"]},{name:"zoom+",image:"images/voyager/zoom_in.svg",tip:"zoom in",cmd:"SetZoom",args:["x2"]},{name:"zoom-",image:"images/voyager/zoom_out.svg",tip:"zoom out",cmd:"SetZoom",args:["/2"]},{name:"zoom1",tip:"zoom 1",image:"images/voyager/zoom_1.svg",cmd:"SetZoom",args:[1]},{name:"zoomtofit",tip:"zoom to fit",image:"images/voyager/zoom_tofit.svg",cmd:"SetZoom",args:["toFit"]},{name:"open",tip:"open local file dialog box",
cmd:"OpenFileMenu",args:[]},{name:"infobox",tip:"toggle infobox display",cmd:"DisplayPlugin",args:["JS9Info"]},{name:"magnifier",tip:"toggle magnifier display",cmd:"DisplayPlugin",args:["JS9Magnifier"]},{name:"panner",tip:"toggle panner display",cmd:"DisplayPlugin",args:["JS9Panner"]},{name:"prefs",tip:"toggle preferences display",cmd:"DisplayPlugin",args:["JS9Preferences"]}];
JS9.Toolbar.tooltip=function(a,b,c){if(b){a=$(c.currentTarget).position();this.tooltip.html(b);"light"===this.winType?(b=a.left+JS9.Toolbar.TOOLTIPLX,c=a.top-JS9.Toolbar.TOOLTIPLY):(b=a.left+JS9.Toolbar.TOOLTIPX,c=a.top-JS9.Toolbar.TOOLTIPY);var d=this.tooltip.width();b+d+20>this.width&&(b=a.left-d-20);this.tooltip.css({left:b,top:c,display:"inline-block"})}else this.tooltip.html("").css({left:-9999,display:"none"})};
JS9.Toolbar.addTool=function(a){var b=this;if(!a)return JS9.Toolbar.tools;if("$break"===a)$("<hr>").appendTo(this.activeToolbar);else{a.name&&a.cmd||JS9.error("invalid input to JS9.toolbar: "+JSON.stringify(a));var c=$("<div>").addClass(JS9.Toolbar.BASE+"ButtonDiv").appendTo(this.activeToolbar);if(a.image){var d=a.image;JS9.inline&&JS9.inline[d]?d=JS9.inline[d]:"/"!==d.charAt(0)&&(d=JS9.InstallDir(d));c=$("<input>").addClass(JS9.Toolbar.BASE+"ImageButton").attr("type","image").attr("src",d).attr("width",
JS9.Toolbar.IMAGEWIDTH).attr("height",JS9.Toolbar.IMAGEHEIGHT).attr("alt",a.name).appendTo(c)}else c=$("<input>").addClass(JS9.Toolbar.BASE+"ButtonButton").attr("type","button").attr("value",a.name).appendTo(c);c.on("click",function(){var c=b.display;if("function"===typeof JS9.publics[a.cmd]){var d=JSON.parse(JSON.stringify(a.args||[]));d.push({display:c});JS9.publics[a.cmd].apply(JS9.publics,$jscomp.arrayFromIterable(d))}else JS9.error("unknown JS9 func for toolbar: "+a.cmd)});JS9.globalOpts.toolbarTooltips&&
(c.on("mouseover",function(c){JS9.Toolbar.tooltip.call(b,a,a.tip||a.name,c)}),c.on("mouseout",function(c){JS9.Toolbar.tooltip.call(b,a,null,c)}));a.btn=c;return a}};
JS9.Toolbar.init=function(a,b){this.width=this.divjq.attr("data-width");this.width||(this.width=a||JS9.Toolbar.WIDTH);this.divjq.css("width",this.width);this.width=parseInt(this.divjq.css("width"),10);this.height=this.divjq.attr("data-height");this.height||(this.height=b||JS9.Toolbar.HEIGHT);this.divjq.css("height",this.height);this.height=parseInt(this.divjq.css("height"),10);this.divjq.html("");this.toolbarContainer=$("<div>").addClass(JS9.Toolbar.BASE+"Container").attr("id",this.id+"Container").appendTo(this.divjq);
this.activeToolbar=$("<div>").addClass(JS9.Toolbar.BASE+"Div").attr("id",this.id+"Toolbar").css("width",this.width).css("height",this.height).css("min-height",JS9.Toolbar.TOOLBARHEIGHT).appendTo(this.toolbarContainer);this.tooltip=$("<div>").attr("id","tooltip_"+this.id).addClass("JS9ToolbarTooltip").appendTo(this.divjq);for(b=0;b<JS9.globalOpts.toolBar.length;b++){var c=JS9.globalOpts.toolBar[b];for(a=0;a<JS9.Toolbar.tools.length;a++){var d=JS9.Toolbar.tools[a];c===d.name&&JS9.Toolbar.addTool.call(this,
d)}}JS9.Toolbar.addTool.call(this,"$break");for(a=0;a<JS9.Toolbar.tools.length;a++)d=JS9.Toolbar.tools[a],0>$.inArray(d.name,JS9.globalOpts.toolBar)&&JS9.Toolbar.addTool.call(this,d);return JS9.Toolbar.tools};JS9.mkPublic("GetToolbar",function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];return"showTooltips"===JS9.parsePublicArgs(b).argv[0]?JS9.globalOpts.toolbarTooltips:JS9.Toolbar.tools});
JS9.mkPublic("SetToolbar",function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d=JS9.parsePublicArgs(b);c=function(){var a;for(a=0;a<JS9.displays.length;a++){var b=JS9.displays[a];(b=b.pluginInstances.JS9Toolbar)&&JS9.Toolbar.init.call(b)}};b=d.argv[0];d=d.argv[1];if(b)if("init"===b)c();else if("showTooltips"===b)JS9.globalOpts.toolbarTooltips=!!d,c();else{if("string"===typeof b){try{b=JSON.parse(b)}catch(f){JS9.error("can't parse json for SetToolBar: "+b,f)}JS9.Toolbar.tools.push(b);
c()}else if($.isArray(b)){for(d=0;d<b.length;d++)JS9.Toolbar.tools.push(b[d]);c()}else"object"===typeof b&&(JS9.Toolbar.tools.push(b),c());return null}});JS9.RegisterPlugin(JS9.Toolbar.CLASS,JS9.Toolbar.NAME,JS9.Toolbar.init,{menuItem:"Toolbar",help:"help/toolbar.html",winTitle:"Toolbar",winDims:[JS9.Toolbar.WIDTH,JS9.Toolbar.HEIGHT]});
require=function e$jscomp$0(a,b,c){function f(h,g){if(!b[h]){if(!a[h]){var k="function"==typeof require&&require;if(!g&&k)return k(h,!0);if(e)return e(h,!0);g=Error("Cannot find module '"+h+"'");throw g.code="MODULE_NOT_FOUND",g;}g=b[h]={exports:{}};a[h][0].call(g.exports,function(b){var c=a[h][1][b];return f(c?c:b)},g,g.exports,e$jscomp$0,a,b,c)}return b[h].exports}for(var e="function"==typeof require&&require,h=0;h<c.length;h++)f(c[h]);return f}({"./imexam":[function(a,b,c){function d(a,b){var c=
Array.prototype.map.call(a,function(a,c){return[a,c,b[c]]});c.sort(function(a,b){return a[0]-b[0]});c.map(function(c,d){a[d]=c[0];b[d]=c[2]})}function f(a){switch(a.shape){case "annulus":a.width=2*a.radii[a.radii.length-1];a.height=2*a.radii[a.radii.length-1];break;case "circle":a.width=2*a.radius;a.height=2*a.radius;break;case "ellipse":a.width=2*a.r1;a.height=2*a.r2;break;case "polygon":case "line":var b,c=0,d=0,g=1E6,e=0,f=1E6,h=0;for(b=0;b<a.pts.length;b++)c+=a.pts[b].x,d+=a.pts[b].y,a.pts[b].x>
e&&(e=a.pts[b].x),a.pts[b].x<g&&(g=a.pts[b].x),a.pts[b].y>h&&(h=a.pts[b].y),a.pts[b].y<f&&(f=a.pts[b].y);a.x=c/a.pts.length;a.y=d/a.pts.length;"line"===a.shape&&2===a.pts.length?(a.width=Math.sqrt((a.pts[0].x-a.pts[1].x)*(a.pts[0].x-a.pts[1].x)+(a.pts[0].y-a.pts[1].y)*(a.pts[0].y-a.pts[1].y)),a.height=JS9.globalOpts.imexamLineHeight||1,a.angle=Math.atan2(a.pts[1].y-a.pts[0].y,a.pts[1].x-a.pts[0].x),a.angle=180*a.angle/Math.PI):(a.width=e-g,a.height=h-f);break;case "text":a.width=10,a.height=10}return l.mksection(a.x,
a.y,a.width,a.height)}var e=a("typed-array-function");e=e.extend(e,a("typed-array-ops"));e=e.extend(e,a("typed-numeric-uncmin"));e.rotate=a("typed-array-rotate");e.mask=a("./mask.js");a=a("./template");var h=e;e.zeros=function(a,b){var c,d=1,g=[];void 0===b&&(b=Float32Array);for(c=0;c<a.length;++c)g.push(Math.floor(a[c])),d*=g[c];return e.ndarray(new b(d),g)};e.fill=h(function(a,b){b.apply(void 0,[])});c.fixupDiv=function(a){"div"===a.winType&&(a.outerdivjq.find(".drag-handle").html(a.plugin.opts.winTitle),
a=a.outerdivjq.find(".JS9PluginToolbar-div"),a.css("cursor","default"),a.css("right",0))};var l={};e.maxvalue=e.sup;e.minvalue=e.inf;e.size=function(a){var b,c=1;for(b=0;b<a.length;b++)c*=a[b];return c};e.reshape=function(a,b){if(a.size!==e.size(b))throw Error("sizes not equil "+a.size+" != ",+e.size(b));return e.ndarray(a.data,b)};e.section=function(a,b){var c=b[0][0],d=b[0][1],g=b[1][0];b=b[1][1];return a.lo(g,c).hi(b-g,d-c)};e.print=function(a,b,c){var d;void 0===c&&(c=3);if(1===a.shape.length){var g=
"";for(b=0;b<a.shape[0];++b)g+=a.get(b).toFixed(c)+" ";console.log(g)}else{for(d=a.shape[0]-1;0<=d;--d){g="";for(b=0;b<a.shape[1];++b)g+=a.get(d,b).toFixed(c)+" ";console.log(g)}console.log("\n")}};e._hist=h(function(a,b,c,d){d=Math.floor((d-c)/b);var g=new Int32Array(d+1);isNaN(a)||g[Math.max(0,Math.min(d,Math.round((a-c)/b)))|0]++;return g});e.hist=function(a,b,c,d){var g={};void 0===c&&(c=e.minvalue(a));void 0===d&&(d=e.maxvalue(a));void 0===b&&(b=Math.max(1,(d-c)/250));g.raw=a;g.min=c;g.max=d;
g.width=b;a=e._hist(a,b,c,d);g.data=e.ndarray(a,[a.length]);return g};e.proj=function(a,b){var c,d={};d.n=a.shape[1===b?0:1];d.x=a.shape[b];d.sum=[];d.avg=[];d.med=[];var g=e.assign(e.zeros(a.shape),a);for(c=0;c<d.n;c++)a=0===b?e.section(g,[[c,c+1],[0,d.x]]):e.section(g,[[0,d.x],[c,c+1]]),d.sum[c]=e.sum(a),d.avg[c]=e.sum(a)/d.n,d.med[c]=e.median(a);return d};e.qcenter=h(function(a){var b=[],c=[],d=Number.MIN_VALUE,g;b[0]++;b[1]++;c[0]--;c[1]--;d<+a[-1][-1]+a[-1][0]+a[-1][1]+a[0][-1]+a[0][0]+a[0][1]+
a[1][-1]+a[1][0]+a[1][1]&&(g=[0,0]);return g});e._imcnts=h({consider:{c:!1}},function(a,b,c){a[c]+=b});e.imcnts=function(a,b,c){var d={};d.cnts=e.ndarray(e._imcnts(new Float32Array(c),a,b));d.area=e.hist(b,1,0,c-1).data;return d};e._centroid=h(function(a,b,c){var d=0,g=0,e=0,f=0,k=0;0<a&&0<b*b+c*c&&(d+=a,g+=0*a,f+=0*a,e+=0*a,k+=0*a);a={};a.sum=d;a.cenx=g/d;a.ceny=e/d;a.rmom=(f-g*g/d+k-e*e/d)/d;a.fwhm=0>=a.rmom?-1:2.354*Math.sqrt(a.rmom)/Math.sqrt(2);return a});e.centroid=function(a){return e._centroid(a,
a.shape[0],a.shape[1])};e.flatten=function(){var a=0,b;for(b=0;b<arguments.length;b++)a+=arguments[b].size;var c=e.zeros([a]),d=0;for(a=0;a<arguments.length;a++)b=arguments[a],e.assign(e.ndarray(c.data,b.shape,void 0,d),b),d+=b.size;return c};e.median=function(a){a=e.assign(e.zeros(a.shape),a);Array.prototype.sort.call(a.data,function(a,b){return a-b});return a.data[Math.round((a.size-1)/2)]};e.rms=h(function(a){var b=0,c=0;isNaN(a)||(b+=a,c+=a*a);var d=b/a.size;return Math.sqrt((c-2*d*b+a.size*d*
d)/(a.size-1))});e.rmsClipped=h(function(a,b,c){var d=0,g=0,e=0;!isNaN(a)&&(null===b||a>b)&&(null===c||a<c)&&(d++,g+=a,e+=a*a);a=g/d;return Math.sqrt((e-2*a*g+d*a*a)/(d-1))});e.meanClipped=h(function(a,b,c){var d=0,g=0;!isNaN(a)&&(null===b||a>b)&&(null===c||a<c)&&(d++,g+=a);return g/d});l.backgr=function(a,b){var c={};a=e.flatten(e.section(a,[[0,b],[0,a.shape[1]]]),e.section(a,[[a.shape[0]-b,a.shape[0]],[0,a.shape[1]]]),e.section(a,[[b,a.shape[0]-b],[0,b]]),e.section(a,[[b,a.shape[0]-b],[a.shape[1]-
b,a.shape[1]]]));c.noise=e.rms(a);c.value=e.median(a);return c};l.mksection=function(a,b,c,d){return[[Math.floor(a-c/2),Math.floor(a+c/2)],[Math.floor(b-d/2),Math.floor(b+d/2)]]};l._rproj=h(function(a,b,c,d,e){var g=new Float32Array(e);e=new Float32Array(e);var f=0;b=Math.sqrt((0-c)*(0-c)+(0-b)*(0-b));b<=Math.sqrt(d*d)&&!isNaN(a)&&(g[f]=b,e[f]=a,f++);return{rad:g.subarray(0,f),val:e.subarray(0,f),n:f}});l.rproj=function(a,b){var c=(a.shape[0]/2+a.shape[1]/2)/2;a=l._rproj(a,b[1],b[0],c,a.size);d(a.rad,
a.val);return{radi:e.ndarray(a.rad,[a.rad.length]),data:e.ndarray(a.val,[a.rad.length]),radius:c}};l._encen=h(function(a,b,c,d){var g=new Float32Array(d),e=0,f=0;b=0-b;c=0-c;c=b*b+c*c;0<a&&c<d*d&&(g[Math.round(Math.sqrt(c))]+=a,e+=a);for(a=0;a<d;a++)f+=g[a],g[a]=f/e;return g});l.encen=function(a,b){a=l._encen(a,b[1],b[0],Math.floor((a.shape[0]/2+a.shape[1]/2)/2));return e.ndarray(a,[a.length])};e.indexof=function(a,b){var c;for(c=0;c<a.shape[0]&&!(b<a.get(c));c++);return 0===c?0:c===a.shape[0]?a.shape[0]:
c+(b-a.get(c))/(a.get(c)-a.get(c-1))};e.gauss1d=function(a,b){var c=e.zeros(a.shape),d=b[0],g=b[1],f=b[2];e.fill(c,function(b){b=a.data[b]-0;return d*Math.pow(2.71828,-b*b/(2*g*g))+f});return c};e.gsfit1d=function(a,b,c){return h.uncmin(function(c){var d=e.gauss1d(a,c);e.sub(d,d,b);e.mul(d,d,d);e.fill(d,function(b){return d.get(b)/(a.get(b)*a.get(b))});c=e.sum(d);return Math.sqrt(c/a.shape[0])},c,1E-6).solution};c.getRegionData=function(a,b){var c=f(b);a=e.ndarray(a.raw.data,[a.raw.height,a.raw.width]);
b.angle&&0!==b.angle?(c=e.zeros([b.height,b.width]),e.rotate(c,a,b.angle/57.29577951,b.y,b.x)):c=e.section(a,c);return c};c.convolve1d=h(function(a,b,c){var d,g,e=Math.round(a.shape[0]/2);for(d=0;d<b.shape[0];d++)for(g=0;g<a.shape[0];g++){var f=d+g-e;0<=f&&f<b.shape[0]&&(c[d]+=a[g]*b[f])}});c.convolve2dSep=function(a,b,c){var d,g,e,f=b.shape[1],k=b.shape[0],h=a.shape[0],l=Math.floor(h/2);for(g=0;g<k;g++)for(d=0;d<f;d++)for(e=c[g][d]=0;e<h;e++){var m=d+e-l;0<m&&m<f&&(c[g][d]+=b[g][m]*a[e])}for(d=0;d<
f;d++)for(g=0;g<k;g++)for(e=0;e<h;e++)m=g+e-l,0<m&&m<k&&(c[g][d]+=b[g+e][d]*a[e])};c.reg2section=f;c.template=a;c.ndops=e;c.typed=e;c.imops=l},{"./mask.js":1,"./template":12,"typed-array-function":4,"typed-array-ops":5,"typed-array-rotate":8,"typed-numeric-uncmin":10}],1:[function(a,b,c){(function(){function b(a,b){var c;for(c=0;c<a.tags.length;c++)if(a.tags[c]===b)return!0;return!1}var f=a("./raster");c.hasTag=b;c.listRegions=function(a){var b,c,d=1,e=[];for(b=0;b<a.length;b++){var f=a[b];switch(f.shape){case "annulus":for(c=
0;c<f.radii.length;c++)0!==f.radii[c]&&(e[d-1]=$.extend($.extend({},f),{regno:d++,shape:"circle",radius:f.radii[c]}));break;default:e[d-1]=$.extend({regno:d++},f)}}return e};c.drawRegions=function(a,c,d){var g,e,h=["include","exclude"];for(g=0;2>g;g++)for(e=a.length-1;0<=e;e--){var l=a[e];if(b(l,h[g]))switch(l.shape){case "polygon":f.drawPolygon(c,d,l.pts,l.regno);break;case "circle":f.drawCircle(c,d,l.x,l.y,l.radius,l.regno);break;case "box":f.drawBox(c,d,l.x,l.y,l.width,l.height,l.angle,l.regno);
break;case "ellipse":f.drawEllipse(c,d,l.x,l.y,l.r1,l.r2,l.angle,l.regno)}}}})()},{"./raster":11}],2:[function(a,b,c){function d(a,b){return a[0]-b[0]}function f(){var a=this.stride,b=Array(a.length),c;for(c=0;c<b.length;++c)b[c]=[Math.abs(a[c]),c];b.sort(d);a=Array(b.length);for(c=0;c<a.length;++c)a[c]=b[c][1];return a}function e(a,b){var c=["View",b,"d",a].join("");0>b&&(c="View_Nil"+a);var d="generic"===a;if(-1===b)return b=new Function("function "+c+"(a){this.data=a;};var proto="+c+".prototype;proto.dtype='"+
a+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+c+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+c+"(a){return new "+c+"(a);}"),b();if(0===b)return b=new Function("TrivialArray","function "+c+"(a,d) {this.data = a;this.offset = d};var proto="+c+".prototype;proto.dtype='"+a+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+
c+"_copy() {return new "+c+"(this.data,this.offset)};proto.pick=function "+c+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+c+"_get(){return "+(d?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+c+"_set(v){return "+(d?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+c+"(a,b,c,d){return new "+c+"(a,d)}"),b(g[a][0]);var e=["'use strict'"];var k=h(b),m=k.map(function(a){return"i"+a}),u="this.offset+"+
k.map(function(a){return["this._stride",a,"*i",a].join("")}).join("+");e.push("function "+c+"(a,"+k.map(function(a){return"b"+a}).join(",")+","+k.map(function(a){return"c"+a}).join(",")+",d){this.data=a");for(var t=0;t<b;++t)e.push("this._shape"+t+"=b"+t+"|0");for(t=0;t<b;++t)e.push("this._stride"+t+"=c"+t+"|0");e.push("this.offset=d|0}","var proto="+c+".prototype","proto.dtype='"+a+"'","proto.dimension="+b);var x={stride:"VStride"+b+"d"+a,shape:"VShape"+b+"d"+a},A;for(A in x){var z=x[A];e.push("function "+
z+"(v) {this._v=v} var aproto="+z+".prototype","aproto.length="+b);var B=[];for(t=0;t<b;++t)B.push(["this._v._",A,t].join(""));e.push("aproto.toJSON=function "+z+"_toJSON(){return ["+B.join(",")+"]}","aproto.valueOf=aproto.toString=function "+z+"_toString(){return ["+B.join(",")+"].join()}");for(t=0;t<b;++t)e.push(["Object.defineProperty(aproto,",t,",{get:function(){return this._v._",A,t,"},set:function(v){return this._v._",A,t,"=v|0},enumerable:true})"].join(""));for(t=0;t<l.length;++t)l[t]in Array.prototype&&
e.push(["aproto.",l[t],"=Array.prototype.",l[t]].join(""));e.push(["Object.defineProperty(proto,'",A,"',{get:function ",z,"_get(){return new ",z,"(this)},set: function ",z,"_set(v){"].join(""));for(t=0;t<b;++t)e.push(["this._",A,t,"=v[",t,"]|0"].join(""));e.push("return v}})")}e.push(["Object.defineProperty(proto,'size',{get:function ",c,"_size(){return ",k.map(function(a){return["this._shape",a].join("")}).join("*"),"}})"].join(""));1===b?e.push("proto.order=[0]"):(e.push("Object.defineProperty(proto,'order',{get:"),
4>b?(e.push(["function ",c,"_order(){"].join("")),2===b?e.push("return (Math.abs(this._stride0)>Math.abs(this._stride1))?[1,0]:[0,1]}})"):3===b&&e.push("var s0=Math.abs(this._stride0),s1=Math.abs(this._stride1),s2=Math.abs(this._stride2);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):e.push("ORDER})"));e.push(["proto.set=function ",c,"_set(",m.join(","),",v){"].join(""));
d?e.push(["return this.data.set(",u,",v)}"].join("")):e.push(["return this.data[",u,"]=v}"].join(""));e.push(["proto.get=function ",c,"_get(",m.join(","),"){"].join(""));d?e.push(["return this.data.get(",u,")}"].join("")):e.push(["return this.data[",u,"]}"].join(""));e.push(["proto.index=function ",c,"_index(",m.join(),"){return ",u,"}"].join(""));e.push(["proto.hi=function ",c,"_hi(",m.join(","),"){return new ",c,"(this.data,",k.map(function(a){return["(typeof i",a,"!=='number'||i",a,"<0)?this._shape",
a,":i",a,"|0"].join("")}).join(","),",",k.map(function(a){return"this._stride"+a}).join(","),",this.offset)}"].join(""));t=k.map(function(a){return"a"+a+"=this._shape"+a});d=k.map(function(a){return"c"+a+"=this._stride"+a});e.push(["proto.lo=function ",c,"_lo(",m.join(","),"){var b=this.offset,d=0,",t.join(","),",",d.join(",")].join(""));for(t=0;t<b;++t)e.push(["if(typeof i",t,"==='number'&&i",t,">=0){d=i",t,"|0;b+=c",t,"*d;a",t,"-=d}"].join(""));e.push(["return new ",c,"(this.data,",k.map(function(a){return"a"+
a}).join(","),",",k.map(function(a){return"c"+a}).join(","),",b)}"].join(""));e.push(["proto.step=function ",c,"_step(",m.join(","),"){var ",k.map(function(a){return"a"+a+"=this._shape"+a}).join(","),",",k.map(function(a){return"b"+a+"=this._stride"+a}).join(","),",c=this.offset,d=0,ceil=Math.ceil"].join(""));for(t=0;t<b;++t)e.push(["if(typeof i",t,"==='number'){d=i",t,"|0;if(d<0){c+=b",t,"*(a",t,"-1);a",t,"=ceil(-a",t,"/d)}else{a",t,"=ceil(a",t,"/d)}b",t,"*=d}"].join(""));e.push(["return new ",c,
"(this.data,",k.map(function(a){return"a"+a}).join(","),",",k.map(function(a){return"b"+a}).join(","),",c)}"].join(""));d=Array(b);u=Array(b);for(t=0;t<b;++t)d[t]=["a[i",t,"]"].join(""),u[t]=["b[i",t,"]"].join("");e.push(["proto.transpose=function ",c,"_transpose(",m,"){",m.map(function(a,b){return a+"=("+a+"===undefined?"+b+":"+a+"|0)"}).join(";"),";var a=this.shape,b=this.stride;return new ",c,"(this.data,",d.join(","),",",u.join(","),",this.offset)}"].join(""));e.push(["proto.pick=function ",c,
"_pick(",m,"){var a=[],b=[],c=this.offset"].join(""));for(t=0;t<b;++t)e.push(["if(typeof i",t,"==='number'&&i",t,">=0){c=(c+this._stride",t,"*i",t,")|0}else{a.push(this._shape",t,");b.push(this._stride",t,")}"].join(""));e.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}");e.push(["return function construct_",c,"(data,shape,stride,offset){return new ",c,"(data,",k.map(function(a){return"shape["+a+"]"}).join(","),",",k.map(function(a){return"stride["+a+"]"}).join(","),",offset)}"].join(""));
b=new Function("CTOR_LIST","ORDER",e.join("\n"));return b(g[a],f)}var h=a("iota-array"),l="concat join slice toString indexOf lastIndexOf forEach every some filter map reduce reduceRight".split(" "),g={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],generic:[]};(function(){for(var a in g)g[a].push(e(a,-1))});b.exports=function(a,b,c,d){if(void 0===a){var f=g.array[0];return f([])}"number"===typeof a&&(a=[a]);void 0===b&&(b=[a.length]);f=b.length;
if(void 0===c){c=Array(f);for(var h=f-1,k=1;0<=h;--h)c[h]=k,k*=b[h]}if(void 0===d)for(h=d=0;h<f;++h)0>c[h]&&(d-=(b[h]-1)*c[h]);h=a instanceof Float64Array?"float64":a instanceof Float32Array?"float32":a instanceof Int32Array?"int32":a instanceof Uint32Array?"uint32":a instanceof Uint8Array?"uint8":a instanceof Uint16Array?"uint16":a instanceof Int16Array?"int16":a instanceof Int8Array?"int8":a instanceof Uint8ClampedArray?"uint8_clamped":a instanceof Array?"array":"generic";for(k=g[h];k.length<=f+
1;)k.push(e(h,k.length-1));f=k[f+1];return f(a,b,c,d)}},{"iota-array":3}],3:[function(a,b,c){b.exports=function(a){for(var b=Array(a),c=0;c<a;++c)b[c]=c;return b}},{}],4:[function(a,b,c){(function(){function c(a){if(a.shape)return a.shape;for(var b=[];"object"===typeof a;)b.push(a.length),a=a[0];return b}function f(a,b,c){void 0===b&&(b=0);void 0===c&&(c=0);var d=a[c],e=[];if(c===a.length-1){for(d-=2;0<=d;d-=2)e[d+1]=b,e[d]=b;-1===d&&(e[0]=b);return e}for(--d;0<=d;d--)e[d]=f(a,b,c+1);return e}function e(a,
b){for(var c="",d,e,g,f,h=0,k;h<a.length;){e=a.match(/[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)break;c+=a.substr(h,e.index);g=[];h=e.index+e[0].length;for(k=!0;k&&h<a.length;){for(;" "===a[h];)h++;switch(a[h]){case "[":d=1;f=h+1;for(h++;d;)"]"===a[h]&&(1===d&&g.push(a.substring(f,h)),d--),"["===a[h]&&d++,h++;break;case ".":f=h;for(h++;" "===a[h];)h++;for(;null!==a[h].match(/[ a-zA-Z0-9_]/);)h++;g.push(a.substring(f,h));break;default:k=!1}}c+=b(e[0],g);a=a.substr(h);h=0}return c+a.substr(h)}function h(){function a(b){return e(b,
function(b,c){var e;"index"===b&&(L=!0);for(e=0;e<c.length;e++)c[e]=a(c[e]);e=m[b];var g;if(void 0!==e&&"object"===typeof e)if(1<=c.length&&".length"===c[c.length-1].trim()&&(c[0]=".shape",c[1]=c.length-1,c.length=2),1<=c.length&&"."===c[0][0])if(2<=c.length&&".shape"===c[0].trim())if(e.data)b=b+".shape["+c[1]+"]";else{var f="[0]";c=c[1];if(1>c)c="";else{for(g="";0<c;)c&1&&(g+=f),c>>=1,f+=f;c=g}b=b+c+".length"}else b+=c[0].trim();else{if(e.data){var h=e.dimension;if(0!==c.length&&c.length<e.dimension){b+=
".data.subarray";var k="()";g=c.length}else b+=".data",k="[]",g=e.dimension;var l=" + "}else h=e.shape.length,l="][",f="",k="[]";var n=y.slice(6-h);if(!(void 0!==z.loops&&!0!==z.loops||0!==c.length&&h!==c.length))for(d=0;d<h;d++)void 0===c[d]&&(c[d]=n[d]),void 0===w[d]&&(w[d]=0),w[d]=Math.max(w[d],e.shape[d]);if(e.data){for(d=0;d<g;d++)1!==e.stride[d]&&(c[d]="("+c[d]+")*"+e.stride[d]);f=0!==e.offset?e.offset+" + ":""}b=c.length?b+k[0]+f+c.join(l)+k[1]+" ":b}else{for(d=0;d<c.length;d++)b="."===c[d][0]?
b+c[d].trim():b+("["+c[d].trim()+"]");b+=" "}return b})}var b=arguments,d,h,k,l,m={};if(void 0===this.cache){this.text=l="string"===typeof this.func?this.func:this.func.toString();l=l.match(/function [A-Za-z0-9_]*\(([^()]*)\)[^{]*\{([\S\s]*)\}[\S\s]*/);this.args=k=l[1].split(",").map(function(a){return a.trim()});this.post=this.prep="";var p=l[2].split(/\/\/ ----+/);1<p.length?(this.prep=p[0],this.post=p[2],this.body=p[1]):this.body=p[0];if(""===this.post||void 0===this.post)this.post="\nreturn "+
k[0]+";"}k=this.args;l=this.text;var z=this.opts;void 0===z&&(z={});l="";for(d=h=0;d<k.length;d++)null!==b[d]&&void 0!==b[d]&&"object"===typeof b[d]&&(void 0===z.consider||"object"===typeof z.consider&&!1!==z.consider[k[d]])?(m[k[d]]=b[d],b[d].shape||(b[d].shape=c(b[d])),h=Math.max(b[d].shape.length,h),l=b[d].data?l+(" "+b[d].dtype+" "+b[d].offset+" "+b[d].stride):l+" O"):l+=" X";l=h+l;if(this.cache&&(h=this.cache[l]))return h;var B=this.prep;p=this.body;var E=this.post,w=[],y="iW iV iU iZ iY iX".split(" "),
L=!1;p=a(p);var K=y.slice(6-w.length),F=y.slice(6-w.length).reverse();w.reverse();var H="\n",D="\n",I="",J="";if(void 0===z.loops||!0===z.loops){H+="\tvar index = ["+f([w.length],0).join(",")+"];\n";H+="\tvar start = ["+f([w.length],0).join(",")+"];\n";H+="\tvar end = ["+f([w.length],0).join(",")+"];\n\n";for(d=0;d<w.length;d++)for(h=0;h<k.length;h++)if(m[k[h]]&&void 0!==b[h]&&"object"===typeof b[h]){H+="\tend["+d+"] = "+k[h]+".shape["+d+"];\n";break}H+="\n";for(d=0;d<w.length;d++)D+="\tvar "+K[d]+
"start = start["+d+"];\n",D+="\tvar "+K[d]+"end = end["+d+"];\n";D+="\n";for(d=0;d<w.length;d++)L&&(I="index["+(w.length-d-1)+"] = 0;\n",J="\tindex["+(w.length-d-1)+"]++\n"),p=I+"for ( var "+F[d]+" = "+F[d]+"start; "+F[d]+" < "+F[d]+"end; "+F[d]+"++ ) {\n\t"+p+"\n"+J+"\n }"}h="// Array optimized funciton\n// "+(l+"\nreturn function (")+(k.join(",")+") {\n'use strict';\n\n"+H+B+D+p+E+"\n}");g.debug&&console.log(h);void 0===this.cache&&(this.cache={});h=(new Function(h))();return this.cache[l]=
h}function l(){return h.apply(this,arguments).apply(g,arguments)}function g(a,b){void 0===b&&(b=a,a=void 0);a={func:b,opts:a};b=l.bind(a);b.baked=h.bind(a);return b}var k=a("ndarray-nobuffer"),m={int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,float32:Float32Array,float64:Float64Array},p=g(function(a){return 1*a});b.exports=g;b.exports.ndarray=k;b.exports.section=function(a,b){var c=b[0][0],d=b[0][1],e=b[1][0];b=b[1][1];return a.lo(e,c).hi(b-
e,d-c)};b.exports.extend=function(a){var b,c;for(b=1;b<arguments.length;b++)for(c in arguments[b])arguments[b].hasOwnProperty(c)&&(a[c]=arguments[b][c]);return a};b.exports.array=function(a,b,c){var d;"number"!==typeof c&&(c=0);b&&b.dtype&&(b=b.dtype);"string"===typeof b&&(b=m[b]);if("function"===typeof b){var e=p(a);b=k(new b(e),a);for(d=0;d<e;d++)b.data[d]=c}else b=f(a,c);b.shape=a;return b};b.exports.clone=function(a){return g.assign(g.array(g.dim(a),a),a)};b.exports.print=function(a,b,c){var d;
void 0===c&&(c=3);if(1===a.shape.length){var e="";for(b=0;b<a.shape[0];++b)e+=a.get(b).toFixed(c)+" ";console.log(e)}else{for(d=a.shape[0]-1;0<=d;--d){e="";for(b=0;b<a.shape[1];++b)e+=a.get(d,b).toFixed(c)+" ";console.log(e)}console.log("\n")}};b.exports.iota=function(a,b){void 0===b&&(b=a,a=0);var c,d=[];for(c=0;c<b;c++)d[c]=a,a+=1;return d};b.exports.rep=f;b.exports.dim=c;b.exports.epsilon=2.220446049250313E-16})()},{"ndarray-nobuffer":2}],5:[function(a,b,c){(function(){function c(a){var b,c,d;
return function(e,g,f){void 0===f&&(b=l.dim(e),c=l.dim(g),d=b.length>c.length?b:c,f=g,g=e,e=l.array(d,g));return a(e,g,f)}}function f(a){return function(b,c){void 0===c&&(c=b,b=l.array(l.dim(c),c));return a(b,c)}}function e(a){return function(b,d,e){return void 0===e?c(a.baked(b,d,e)):a.baked(b,d,e)}}function h(a){return function(b,c){return void 0===c?f(a.baked(b,c)):a.baked(b,c)}}var l=a("typed-array-function"),g={};b.exports=g;var k={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",
lshift:"<<",rshift:">>",rrshift:">>>"};for(n in k)if(k.hasOwnProperty(n)){var m=k[n];g[n+"3"]=l("function (a, b, c) { a = b "+m+" c; }");g[n+"_mask"]=l("function (a, b, c, m) { if ( m ) { a = b "+m+" c; } }");g[n+"eq"]=l("function (a, b ) { a "+m+"= b; } ");g[n+"eq_mask"]=l("function (a, b , m) { if ( m ) { a "+m+"= b; } }");g[n]=c(g[n+"3"]);g[n].baked=e(g[n+"3"]);g[n+"s"]=g[n];g[n+"seq"]=g[n+"eq"]}k={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",
geq:">="};for(n in k)k.hasOwnProperty(n)&&(m=k[n],g[n+"3"]=l("function (a, b, c) { a = b "+m+" c; }"),g[n+"_mask"]=l("function (a, b, c, m) { if ( m ) { a = b "+m+" c; } }"),g[n+"eq"]=l("function (a, b ) { a = a "+m+" b; } "),g[n+"eq_mask"]=l("function (a, b , m) { if ( m ) { a = a "+m+" b; } }"),g[n]=c(g[n+"3"]),g[n].baked=e(g[n+"3"]),g[n+"s"]=g[n],g[n+"seq"]=g[n+"eq"]);k={not:"!",bnot:"~",neg:"-",recip:"1.0/"};for(n in k)k.hasOwnProperty(n)&&(m=k[n],g[n+"2"]=l("function (a, b ) { a = "+
m+" b; }"),g[n+"_mask"]=l("function (a, b , m) { if ( m ) { a = "+m+" b; } }"),g[n+"eq"]=l("function (a ) { a = "+m+" a; }"),g[n+"eq_mask"]=l("function (a , m) { if ( m ) { a = "+m+" a; } }"),g[n]=f(g[n+"2"]),g[n].baked=h(g[n+"2"]));var p="Math.abs Math.exp Math.floor Math.log Math.round Math.sqrt Math.acos Math.asin Math.atan Math.ceil Math.cos Math.sin Math.tan isFinite isNaN".split(" ");for(k=0;k<p.length;k++){m=p[k];var n=m.split(".");n=2==n.length?n[1]:n[0];g[n+"2"]=
l("function (a, b ) { a = "+m+"(b); }");g[n+"_mask"]=l("function (a, b , m) { if ( m ) { a = "+m+"(b); } }");g[n+"eq"]=l("function (a ) { a = "+m+"(a); }");g[n+"eq_mask"]=l("function (a , m) { if ( m ) { a = "+m+"(a); } }");g[n]=f(g[n+"2"]);g[n].baked=h(g[n+"2"])}p=["max","min"];for(k=0;k<p.length;k++)n=m=p[k],g[n+"3"]=l("function (a, b, c) { a = Math."+m+"(b, c); }"),g[n+"_mask"]=l("function (a, b, c, m) { if ( m ) { a = Math."+m+"(b, c); } }"),
g[n]=c(g[n+"3"]),g[n].baked=e(g[n+"3"]),g[n+"s"]=g[n],g[n+"seq"]=g[n];p=["atan2","pow"];for(k=0;k<p.length;k++)n=m=p[k],g[n+"3"]=l("function (a, b, c) { a = Math."+m+"(b, c); }"),g[n+"_mask"]=l("function (a, b, c, m) { if ( m ) { a = Math."+m+"(b, c); } }"),g[n]=c(g[n+"3"]),g[n].baked=e(g[n+"3"]),g[n+"s"]=g[n],g[n+"seq"]=g[n];g.assign=l(function(a,b){});g.equals=l(function(a,b){if(a!==b)return!1});g.any=l(function(a){if(a)return!0});g.all=l(function(a){if(!a)return!1});g.random=l(function(a){});
g.sum=l(function(a){return 0+a});g.prod=l(function(a){return 1*a});g.inf=l(function(a){var b=Infinity;a<b&&(b=a);return b});g.sup=l(function(a){var b=-Infinity;a>b&&(b=a);return b});g.norm2Squared=l(function(a){return a*a});g.norm2=function(a){return Math.sqrt(g.norm2Squared(a))}})()},{"typed-array-function":4}],6:[function(a,b,c){function d(a,b){var c=Math.floor(b);b-=c;var d=0<=c+1&&c+1<a.shape[0],e=0<=c&&c<a.shape[0]?+a.get(c):0;a=d?+a.get(c+1):0;return(1-b)*e+b*a}function f(a,b,c){var d=Math.floor(b);
b-=d;var e=0<=d&&d<a.shape[0],g=0<=d+1&&d+1<a.shape[0],f=Math.floor(c);c-=f;var h=0<=f&&f<a.shape[1],k=0<=f+1&&f+1<a.shape[1],l=e&&h?a.get(d,f):0;e=e&&k?a.get(d,f+1):0;h=g&&h?a.get(d+1,f):0;a=g&&k?a.get(d+1,f+1):0;return(1-c)*((1-b)*l+b*h)+c*((1-b)*e+b*a)}function e(a,b,c,d){var e=Math.floor(b);b-=e;var f=0<=e&&e<a.shape[0],g=0<=e+1&&e+1<a.shape[0],h=Math.floor(c);c-=h;var k=0<=h&&h<a.shape[1],l=0<=h+1&&h+1<a.shape[1],m=Math.floor(d);d-=m;var x=0<=m&&m<a.shape[2],A=0<=m+1&&m+1<a.shape[2],z=f&&k&&
x?a.get(e,h,m):0,B=f&&l&&x?a.get(e,h+1,m):0,E=g&&k&&x?a.get(e+1,h,m):0;x=g&&l&&x?a.get(e+1,h+1,m):0;var w=f&&k&&A?a.get(e,h,m+1):0;f=f&&l&&A?a.get(e,h+1,m+1):0;k=g&&k&&A?a.get(e+1,h,m+1):0;a=g&&l&&A?a.get(e+1,h+1,m+1):0;return(1-d)*((1-c)*((1-b)*z+b*E)+c*((1-b)*B+b*x))+d*((1-c)*((1-b)*w+b*k)+c*((1-b)*f+b*a))}function h(a){var b=a.shape.length|0,c=Array(b),d=Array(b),e=Array(b),f=Array(b),h;for(h=0;h<b;++h){var l=+arguments[h+1];c[h]=Math.floor(l);d[h]=l-c[h];e[h]=0<=c[h]&&c[h]<a.shape[h];f[h]=0<=
c[h]+1&&c[h]+1<a.shape[h]}l=0;var v;h=0;a:for(;h<1<<b;++h){var u=1;var t=a.offset;for(v=0;v<b;++v)if(h&1<<v){if(!f[v])continue a;u*=d[v];t+=a.stride[v]*(c[v]+1)}else{if(!e[v])continue a;u*=1-d[v];t+=a.stride[v]*c[v]}l+=u*a.data[t]}return l}b.exports=function(a,b,c,m){switch(a.shape.length){case 0:return 0;case 1:return d(a,b);case 2:return f(a,b,c);case 3:return e(a,b,c,m);default:return h.apply(void 0,arguments)}};b.exports.d1=d;b.exports.d2=f;b.exports.d3=e},{}],7:[function(a,b,c){var d=a("ndarray-linear-interpolate");
a=a("typed-array-function");var f=a(function(a,b,c){a=a.shape.slice(0);b(a,[0,0,0]);c.apply(void 0,a)}),e=a(function(a,b,c,d){a=[0];b(a,[0]);c(d,a[0])}),h=a(function(a,b,c,d){a=[0,0];b(a,[0,0]);c(d,a[0],a[1])}),l=a(function(a,b,c,d){a=[0,0,0];b(a,[0,0,0]);c(d,a[0],a[1],a[2])});b.exports=function(a,b,c){switch(b.shape.length){case 1:e(a,c,d.d1,b);break;case 2:h(a,c,d.d2,b);break;case 3:l(a,c,d.d3,b);break;default:f(a,c,d.bind(void 0,b))}return a}},{"ndarray-linear-interpolate":6,"typed-array-function":4}],
8:[function(a,b,c){var d=a("typed-array-warp");b.exports=function(a,b,c,l,g,k,m){var e=Math.cos(c),f=Math.sin(-c);l=l||b.shape[0]/2;g=g||b.shape[1]/2;k=k||a.shape[0]/2;m=m||a.shape[1]/2;var h=l-e*k+f*m,r=g-f*k-e*m;d(a,b,function(a,b){a[0]=e*b[0]-f*b[1]+h;a[1]=f*b[0]+e*b[1]+r});return a}},{"typed-array-warp":7}],9:[function(a,b,c){var d=a("typed-array-function");d.dot=function(a,b){var c=d.dim,e=c(a),f=c(b);switch(1E3*c(a).length+c(b).length){case 2002:return d.dotMM(d.array([e[0],f[1]],a.dtype),a,
b);case 2001:return d.dotMV(a,b);case 1002:return d.dotVM(a,b);case 1001:return d.dotVV(a,b);case 1E3:return d.mulVS(a,b);case 1:return d.mulSV(a,b);case 0:return a*b;default:throw Error("numeric.dot only works on vectors and matrices");}};d.dotVV=function(a,b){var c=a.length;var d=a[c-1]*b[c-1];for(c-=2;1<=c;c-=2){var e=c-1;d+=a[c]*b[c]+a[e]*b[e]}0===c&&(d+=a[0]*b[0]);return d};d.dotMV=function(a,b){var c=a.length;var d=this.array([c],a.dtype),e=this.dotVV;for(--c;0<=c;c--)d[c]=e(a[c],b);return d};
d.dotVM=function(a,b){var c;var e=a.length;var f=b[0].length;var k=d.array([f],a.dtype);for(c=f-1;0<=c;c--){var m=a[e-1]*b[e-1][c];for(f=e-2;1<=f;f-=2){var p=f-1;m+=a[f]*b[f][c]+a[p]*b[p][c]}0===f&&(m+=a[0]*b[0][c]);k[c]=m}return k};d.dotMM=function(a,b,c){var d,e,f,h=a.shape[1],p=c.length;for(d=b.length-1;0<=d;d--){var n=a[d];var q=b[d];for(f=h-1;0<=f;f--){var r=q[p-1]*c[p-1][f];for(e=p-2;1<=e;e-=2){var v=e-1;r+=q[e]*c[e][f]+q[v]*c[v][f]}0===e&&(r+=q[0]*c[0][f]);n[f]=r}}};d.diag=function(a){var b,
c,d=a.length,f=this.array([d,d],a.dtype);for(b=d-1;0<=b;b--){var k=f[b];var m=b+2;for(c=d-1;c>=m;c-=2)k[c]=0,k[c-1]=0;c>b&&(k[c]=0);k[b]=a[b];for(c=b-1;1<=c;c-=2)k[c]=0,k[c-1]=0;0===c&&(k[0]=0)}return f};d.identity=function(a,b){return this.diag(this.array([a],b,1))};d.tensorXX=function(a,b,c){var d=c.length,e,f;for(e=b.length-1;0<=e;e--){var h=a[e];var p=b[e];for(f=d-1;3<=f;--f)h[f]=p*c[f],--f,h[f]=p*c[f],--f,h[f]=p*c[f],--f,h[f]=p*c[f];for(;0<=f;)h[f]=p*c[f],--f}};d.tensorXX=d({loops:!1},d.tensorXX);
d.tensor=function(a,b){if("number"===typeof a||"number"===typeof b)return d.mul(a,b);var c=d.dim(a),e=d.dim(b);if(1!==c.length||1!==e.length)throw Error("numeric: tensor product is only defined for vectors");return d.tensorXX(d.array([c[0],e[0]],a.dtype),a,b)};d.dotVV=d({loops:!1},d.dotVV);d.dotVM=d({loops:!1},d.dotVM);d.dotMV=d({loops:!1},d.dotMV);d.dotMM=d({loops:!1},d.dotMM);d.diag=d({loops:!1},d.diag)},{"typed-array-function":4}],10:[function(a,b,c){var d=a("typed-array-function");d=d.extend(d,
a("typed-array-ops"));d=d.extend(d,a("typed-matrix-ops"));c.gradient=function(a,b){var c=b.length,e=a(b);if(isNaN(e))throw Error("gradient: f(x) is a NaN!");var f,k=d.clone(b),m=Array(c),p=Math.max,n=Math.abs,q=Math.min,r=0;for(f=0;f<c;f++)for(var v=p(1E-6*e,1E-8);;){++r;if(20<r)throw Error("Numerical gradient fails");k[f]=b[f]+v;var u=a(k);k[f]=b[f]-v;var t=a(k);k[f]=b[f];if(isNaN(u)||isNaN(t))v/=16;else{m[f]=(u-t)/(2*v);var x=b[f]-v;var A=b[f];var z=b[f]+v;var B=(u-e)/v;var E=(e-t)/v;u=p(n(m[f]),
n(e),n(u),n(t),n(x),n(A),n(z),1E-8);B=q(p(n(B-m[f]),n(E-m[f]),n(B-E))/u,v/u);if(.001<B)v/=16;else break}}return m};c.uncmin=function(a,b,h,l,g,k,m){var e=c.gradient;"undefined"===typeof m&&(m={});"undefined"===typeof h&&(h=1E-8);"undefined"===typeof l&&(l=function(b){return e(a,b)});"undefined"===typeof g&&(g=1E3);b=d.clone(b);var f=b.length,q=a(b);if(isNaN(q))throw Error("uncmin: f(x0) is a NaN!");var r=Math.max,v=d.norm2;h=r(h,d.epsilon);var u;m=m.Hinv||d.identity(f);f=d.dot;r=d.sub;var t=d.add,
x=d.tensor,A=d.div,z=d.mul,B=d.all,E=d.isFinite,w=d.neg,y=0,L,K="";for(u=l(b);y<g;){if("function"===typeof k&&k(y,b,q,u,m)){K="Callback returned true";break}if(!B(E(u))){K="Gradient has Infinity or NaN";break}var F=w(f(m,u));if(!B(E(F))){K="Search direction has Infinity or NaN";break}var H=v(F);if(H<h){K="Newton step smaller than tol";break}var D=1;var I=f(u,F);for(L=b;y<g&&!(D*H<h);){var J=z(F,D);L=t(b,J);var Q=a(L);if(Q-q>=.1*D*I||isNaN(Q))D*=.5,++y;else break}if(D*H<h){K="Line search step size smaller than tol";
break}if(y===g){K="maxit reached during line search";break}I=l(L);b=r(I,u);u=f(b,J);q=f(m,b);m=r(t(m,z((u+f(b,q))/(u*u),x(J,J))),A(t(x(q,J),x(J,q)),u));b=L;q=Q;u=I;++y}return{solution:b,f:q,gradient:u,invHessian:m,iterations:y,message:K}}},{"typed-array-function":4,"typed-array-ops":5,"typed-matrix-ops":9}],11:[function(a,b,c){(function(){function a(a,b,c,d,e,f){if(b>d){var g=b;b=d;d=g;var h=a;a=c;c=h}b=Math.floor(b)+1;d=Math.floor(d);h=a;a=(c-a)/(d-b);e=Math.round(b-e);for(g=b;g<=d;g++)b=Math.floor(h)+
1,f[e].minx>b&&(f[e].minx=b),f[e].maxx<b&&(f[e].maxx=b),h+=a,e++}function b(b,c,d,e,f){var g,h=d[0].y-1,k=d[0].y-1;for(g=1;g<d.length;g++)d[g].y-1<h&&(h=d[g].y-1),d[g].y-1>k&&(k=d[g].y-1);var l=k-h;k=[];for(g=0;g<=l+1;g++)k.push({minx:1E6,maxx:-1E6});for(g=0;g<d.length-1;g++)a(d[g].x-1,d[g].y-1,d[g+1].x-1,d[g+1].y-1,h,k);a(d[g].x-1,d[g].y-1,d[0].x-1,d[0].y-1,h,k);for(g=0;g<k.length;g++){d=b;var m=Math.floor(k[g].minx);l=Math.floor(k[g].maxx);var p=e;0>m&&(m=0);l>c&&(l=c);var x=m+Math.floor(g+h)*c;
switch(f){case void 0:case "set":for(;m<l;m++)d[x++]=p;break;case "add":for(;m<l;m++)d[x++]+=p}}}function e(a,b,c){var d,e=[];b*=Math.PI/180;var f=Math.sin(b),g=Math.cos(b);for(d=0;d<a.length;d++){b=c.x+((a[d].x-c.x)*g-(a[d].y-c.y)*f);var h=c.y+((a[d].x-c.x)*f+(a[d].y-c.y)*g);e.push({x:b,y:h})}return e}function h(a,b,c,d){var e,f=[];for(e=0;e<2*Math.PI;e+=.01){var g=a+c*Math.cos(e);var h=b+d*Math.sin(e);f.push({x:g,y:h})}return f}c.drawPolygon=function(a,c,d,e,f){b(a,c,d,e,f)};c.drawCircle=function(a,
c,d,e,f,n,q){b(a,c,h(d,e,f,f),n,q)};c.drawEllipse=function(a,c,d,f,p,n,q,r,v){b(a,c,e(h(d,f,p,n),q,{x:d,y:f}),r,v)};c.drawBox=function(a,c,d,f,h,n,q,r,v){b(a,c,e([{x:d-h/2,y:f-n/2},{x:d-h/2,y:f+n/2},{x:d+h/2,y:f+n/2},{x:d+h/2,y:f-n/2}],q,{x:d,y:f}),r,v)}})()},{}],12:[function(a,b,c){function d(a,b){var c,d="";for(c=0;c<b;c++)d+=a;return d}b.exports=function(a,b){return a.replace(/\{([a-zA-Z0-9_.%]*)\}/g,function(a,c){var e;a=b;c=c.split("%");var f=1>=c.length?"%s":c[1];c=c[0];c=c.split(".");for(e=
0;e<c.length;e++)if(a.hasOwnProperty(c[e]))a=a[c[e]];else return"";c=f.substring(f.length-1);f=f.substring(0,f.length-1);f=f.split(".");e=f[0]|0;f=f[1]|0;switch(c){case "s":a=a.toString();break;case "f":a=a.toFixed(f);break;case "d":a=a.toFixed(0)}0!==e&&e>a.length&&(a=0<e?d(" ",e-a.length)+a:a+d(" ",e-a.length));return a})}},{}]},{},[]);
(function(){var a=require("./imexam");JS9.RegisterPlugin("ImExam","EncEnergy",function(){a.fixupDiv(this);$(this.div).append("<p style='padding: 20px 0px 0px 20px; margin: 0px'>create, click, move, or resize a region to see encircled energy<br>")},{menu:"analysis",menuItem:"Encircled Energy",winTitle:"Encircled Energy",help:"imexam/imexam.html#enener",dynamicSelect:!0,toolbarSeparate:!0,onregionschange:function(b,c){var d=this.div;c=a.getRegionData(b,c);var f=a.imops.backgr(c,4).value;b=a.ndops.assign(a.ndops.zeros(c.shape),
c);a.ndops.subs(b,c,f);c=a.ndops.qcenter(b);c=a.ndops.centroid(b,c);b=a.imops.encen(b,[c.ceny,c.cenx]);c={};c.ee80=a.ndops.indexof(b,.8);c.ee50=a.ndops.indexof(b,.5);f=[];var e;for(e=0;e<b.shape[0];e++)f[e]=[e,b.get(e)];$(d).empty();$.plot(d,[f],{selection:{mode:"xy"}});$(d).append(a.template(" \t\t\t\t\t\t \t<div style='position:absolute;right: 10px;bottom:50px'>\t\t <table>\t\t\t\t\t\t\t\t\t <tr><td>ee50</td><td align=right>{ee50%.2f}</td><tr>\t\t <tr><td>ee80</td><td align=right>{ee80%.2f}</td><tr>\t </table>\t\t\t\t\t\t\t\t</div>",
c))},winDims:[250,250]})})();
(function(){function a(a,b,c){var d=new RegExp(c,"g"),e="";for(c=0;c<b;c++)e+=a.replace(d,c);return e}function b(a,b){var d=c.ndops.ndarray(a.raw.data,[a.raw.height,a.raw.width]),f=0,l=0,g=$(this.div).find(".pxtabl")[0];g["cell"+l+"."+f].value="col\\row";l=0;for(f=1;10>f;f++){var k=b.x+f-5;g["cell"+l+"."+f].value=0<k&&k<=a.raw.width?k.toFixed(0):""}f=0;for(l=1;10>l;l++){var m=b.y+l-5;g["cell"+(10-l)+"."+f].value=0<m&&m<=a.raw.height?m.toFixed(0):""}for(l=1;10>l;l++)for(f=1;10>f;f++)k=b.x+f-5-.5|0,
m=b.y+l-5-.5|0,g["cell"+(10-l)+"."+f].value=0<=k&&k<a.raw.width&&0<=m&&m<a.raw.height?d.get(m,k).toPrecision(4):""}var c=require("./imexam");JS9.RegisterPlugin("ImExam","PxTabl",function(){c.fixupDiv(this);$(this.div).html("<form class=pxtabl><table cellpadding=0 cellspacing=0>"+(a("<tr>"+a("<td ><input class='col%x row%y' type=entry size=6 name=cell%y.%x value=0></td>",10,"%x")+"</tr>\n",10,"%y")+"</table></form>"));$(this.div).find(".row5").css("background","lightblue");$(this.div).find(".col5").css("background",
"lightblue");$(this.div).find(":input").css("font-size","11")},{menu:"view",menuItem:"Pixel Table",winTitle:"Pixel Table",winResize:!0,toolbarSeparate:!0,onmousemove:b,onarrowkey:b,winDims:[625,240]})})();
(function(){var a=require("./imexam");JS9.RegisterPlugin("ImExam","RadialProj",function(){a.fixupDiv(this);$(this.div).append("<p style='padding: 20px 0px 0px 20px; margin: 0px'>create, click, move, or resize a region to see radial projection<br>")},{menu:"analysis",menuItem:"Radial Proj",winTitle:"Radial Proj",help:"imexam/imexam.html#r_proj",dynamicSelect:!0,toolbarSeparate:!0,onregionschange:function(b,c){var d=this.div;b=a.getRegionData(b,c);c=a.ndops.maxvalue(b);var f=a.imops.backgr(b,4).value,
e=a.ndops.assign(a.ndops.zeros(b.shape),b);a.ndops.subs(e,b,f);var h=a.ndops.qcenter(e);e=a.ndops.centroid(e,h);var l=a.imops.rproj(b,[e.ceny,e.cenx]);b=a.ndops.gsfit1d(l.radi,l.data,[c,e.fwhm/2.355,f]);c={a:b[0],b:0,c:b[1],d:b[2]};f=[];e=[];for(h=0;h<l.radi.shape[0];h++)f[h]=[l.radi.get(h),l.data.get(h)];l.samp=a.ndops.zeros([d.offsetWidth/2]);a.ndops.fill(l.samp,function(a){return l.radius*a/(d.offsetWidth/2)});l.modl=a.ndops.gauss1d(l.samp,b);for(h=0;h<l.modl.shape[0];h++)e[h]=[l.samp.get(h),l.modl.get(h)];
$(d).empty();$.plot(d,[{data:f,points:{radius:1,show:!0}},{data:e}],{zoomStack:!0,selection:{mode:"xy"}});$(d).append(a.template("<div style='position:absolute;right: 10px;top:30px'> <table> <tr><td>peak </td><td align=right>{a%.2f}</td><tr> <tr><td>sigma </td><td align=right>{c%.2f}</td><tr> <tr><td>bias </td><td align=right>{d%.2f}</td><tr> </table> </div>",
c))},winDims:[250,250]})})();
(function(){function a(a,d,f){f=d.getAxes();d=f.xaxis.options.min;var c=f.xaxis.options.max,h=$(a).data("hist").raw;f=b.ndops.rmsClipped(h,d,c);d=b.ndops.meanClipped(h,d,c);$(a).find(".annotation").empty();$(a).append(b.template("<div class='annotation' style='position:absolute;right: 10px;top:30px'> <table> <tr><td>rms </td><td align=right>{rms%.2f}</td><tr> <tr><td>mean </td><td align=right>{mean%.2f}</td><tr> </table> </div>",{rms:f,
mean:d}))}var b=require("./imexam");JS9.RegisterPlugin("ImExam","Histogram",function(){b.fixupDiv(this);$(this.div).append("<p style='padding: 20px 0px 0px 20px; margin: 0px'>create, click, move, or resize a region to see histogram<br>")},{menu:"analysis",menuItem:"Histogram",winTitle:"Histogram",help:"imexam/imexam.html#rghist",dynamicSelect:!0,toolbarSeparate:!0,toolbarHTML:" ",onregionschange:function(c,d){var f=this.div;c=b.getRegionData(c,d);c=b.ndops.hist(c);c.sum=b.ndops.sum(c.data);$(f).data("hist",
c);d=0;var e=.001*c.sum,h=0,l;$(f).empty();var g=[];for(l=0;l<c.data.shape[0];l++)if(d+=c.data.get(l),d>e&&d<c.sum-e){var k=c.data.get(l);g[h]=[l*c.width+c.min,k];h++}c=$.plot(f,[g],{zoomStack:!0,zoomFunc:a,selection:{mode:"x"}});a(f,c,void 0)},winDims:[250,250]})})();
(function(){function a(a,d){var c=b.reg2section(d),e=b.getRegionData(a,d),h=b.ndops.assign(b.ndops.zeros(e.shape),e),l=b.ndops.assign(b.ndops.zeros(e.shape),e),g={};if(!a||!d)return null;g.reg=d;g.min=b.ndops.minvalue(e);g.max=b.ndops.maxvalue(e);g.bkgd=b.imops.backgr(e,4);b.ndops.subs(h,e,g.bkgd.value);g.bscnts=b.ndops.centroid(h,b.ndops.qcenter(h));g.bscnts.cenx+=c[0][0];g.bscnts.ceny+=c[1][0];g.totcnts=b.ndops.centroid(l,b.ndops.qcenter(l));g.totcnts.cenx+=c[0][0];g.totcnts.ceny+=c[1][0];return g}
var b=require("./imexam");JS9.Image.prototype.getRegionStats=function(b){return a(this,b)};JS9.mkPublic("GetRegionStats","getRegionStats");JS9.RegisterPlugin("ImExam","RegionStats",function(){b.fixupDiv(this);$(this.div).append("<p style='padding: 20px 0px 0px 20px; margin: 0px'>create, click, move, or resize a region to see stats<br>")},{menu:"analysis",winTitle:"Region Stats",menuItem:"Region Stats",help:"imexam/imexam.html#rgstat",dynamicSelect:!0,toolbarSeparate:!0,onregionschange:function(c,
d){$(this.div).html(b.template(" <table width=100% style='padding-right: 6px; padding-left: 0px'> <tr><td align=right>position x</td> <td align=right>{reg.x%.2f} </td> <td align=right>y</td> <td align=right>{reg.y%.2f} </td></tr> <tr><td align=right>box width</td> <td align=right>{reg.width%.2f} </td> <td align=right>height</td> <td align=right>{reg.height%.2f} </td></tr> <tr><td align=right>min</td> <td align=right>{min%.2f} </td> <td align=right>max</td> <td align=right>{max%.2f} </td></tr> <tr><td align=right>totcounts</td> <td align=right colspan=3>{totcnts.sum%.2f}</tr> <tr><td align=right>bscounts</td> <td align=right colspan=3>{bscnts.sum%.2f}</tr> <tr><td align=right>bkgd</td> <td align=right>{bkgd.value%.2f} </td> <td align=right>noise</td> <td align=right>{bkgd.noise%.2f} </td></tr> <tr><td align=right>centroid x</td> <td align=right>{bscnts.cenx%.2f} </td> <td align=right>y</td> <td align=right>{bscnts.ceny%.2f} </td></tr> <tr><td align=right>FWHM</td> <td align=right>{bscnts.fwhm%.2f} </td> <td align=right></td> <td align=right>{bscnts.rms%.2f} </td></tr> </table>",
a(c,d)))},winDims:[250,250]})})();
(function(){function a(b,f){if(void 0===b){var d=f.div;var h=f.proj;var l=f.menu;var g=f.chek}else d=this.div,l=this.outerdivjq.find(".proj_menu")[0],g=this.outerdivjq.find(".proj_chek")[0],h=c.ndops.proj(c.getRegionData(b,f),this.plugin.opts.xyproj),$(l).change(function(b){a(void 0,{div:d,proj:h,menu:l,chek:g})}),$(g).change(function(b){a(void 0,{div:d,proj:h,menu:l,chek:g})});b=[];f=l.options[l.selectedIndex].value;$(d).empty();if("sum"===f)var k=h.sum;"avg"===f&&(k=h.avg);"med"===f&&(k=h.med);
for(f=0;f<k.length;f++)b[f]=[f,k[f]];$.plot(d,[b],{zoomStack:!0,selection:{mode:"xy"}})}function b(){c.fixupDiv(this);$(this.div).append("<p style='padding: 20px 0px 0px 20px; margin: 0px'>create, click, move, or resize a region to see projection<br>")}var c=require("./imexam");JS9.RegisterPlugin("ImExam","XProj",b,{menu:"analysis",menuItem:"X Projection",winTitle:"X Projection",help:"imexam/imexam.html#xyproj",dynamicSelect:!0,toolbarSeparate:!0,toolbarHTML:" \t\t\t<div style='float:right; margin:10px'> <select class='proj_menu JS9Select'>\t <option>sum</option> <option>avg</option> <option>med</option> \t\t </select>\t\t\t\t\t\t</div>",
onregionschange:a,winDims:[250,250],xyproj:0});JS9.RegisterPlugin("ImExam","YProj",b,{menu:"analysis",menuItem:"Y Projection",winTitle:"Y Projection",help:"imexam/imexam.html#xyproj",dynamicSelect:!0,toolbarSeparate:!0,toolbarHTML:" \t\t\t<div style='float:right; margin:10px'> <select class='proj_menu JS9Select'>\t <option>sum</option> <option>avg</option> <option>med</option> \t\t </select>\t\t\t\t\t\t</div>",
onregionschange:a,winDims:[250,250],xyproj:1})})();
(function e$jscomp$0(a,b,c){function f(h,g){if(!b[h]){if(!a[h]){var k="function"==typeof require&&require;if(!g&&k)return k(h,!0);if(e)return e(h,!0);g=Error("Cannot find module '"+h+"'");throw g.code="MODULE_NOT_FOUND",g;}g=b[h]={exports:{}};a[h][0].call(g.exports,function(b){var c=a[h][1][b];return f(c?c:b)},g,g.exports,e$jscomp$0,a,b,c)}return b[h].exports}for(var e="function"==typeof require&&require,h=0;h<c.length;h++)f(c[h]);return f})({1:[function(a,b,c){(function(){function b(a,b){var d=c.ndops.zeros(b.shape),
e=c.ndops.minvalue(b),f=c.ndops.maxvalue(b)-e,h=$(a).data("surfplot");d.getNumberOfRows=function(){return this.shape[1]};d.getNumberOfColumns=function(){return this.shape[0]};d.getFormattedValue=function(a,b){return this.get(b,a).toString()};void 0===h&&(a.innerHTML="",h=new greg.ross.visualisation.SurfacePlot(a),$(a).data("surfplot",h));var p=[],n=d.getNumberOfRows(),q=d.getNumberOfColumns(),r=0,v=a.offsetHeight;a=a.offsetWidth;var u,t;for(u=0;u<n;u++)for(t=0;t<q;t++){var x=b.get(t,u);d.set(t,u,
(x-e)/(2.25*f));void 0!==x&&(p[r]="x:"+u+", y:"+t+" = "+x.toFixed(2));r++}h.draw(d,{xPos:0,yPos:0,width:a,height:v,colourGradient:[{red:0,green:0,blue:255},{red:0,green:255,blue:255},{red:0,green:255,blue:0},{red:255,green:255,blue:0},{red:255,green:0,blue:0}],fillPolygons:!0,tooltips:p,xTitle:"X",yTitle:"Y",zTitle:"Z",restrictXRotation:!1})}var c=a("./imexam");a("./JSSurfacePlot-V1.7/javascript/SurfacePlot");a("./JSSurfacePlot-V1.7/javascript/ColourGradient");JS9.RegisterPlugin("ImExam","3dPlot",
function(){c.fixupDiv(this);$(this.div).append("<p style='padding: 20px 0px 0px 20px; margin: 0px'>create, click, move, or resize a region to see 3d plot<br>")},{menu:"analysis",menuItem:"3dPlot",winTitle:"3dPlot",help:"imexam/imexam.html#3dplot",dynamicSelect:!0,toolbarSeparate:!0,onregionschange:function(a,d){b(this.div,c.getRegionData(a,d))},winDims:[250,250]})})()},{"./JSSurfacePlot-V1.7/javascript/ColourGradient":2,"./JSSurfacePlot-V1.7/javascript/SurfacePlot":3,"./imexam":void 0}],2:[function(a,
b,c){greg.ross.visualisation.ColourGradient=function(a,b,c){function d(a,b,c){return b==c?0:(a-b)/(c-b)}this.getColour=function(e){if(isNaN(e)||e<a||e>b||1==c.length)return{red:c[0].red,green:c[0].green,blue:c[0].blue};var f=d(e,a,b);e=c.length;var h=1/(e-1);var l=parseInt(f/h+"");l=l>=e-1?e-2:l;var p=c[l],n=c[l+1];p.red*p.red+p.green*p.green+p.blue*p.blue>n.red*n.red+n.green*n.green+n.blue*n.blue?e=n:(e=p,p=n);f=e==n?1-d(f,l*h,(l+1)*h):d(f,l*h,(l+1)*h);l=[f*(p.red-e.red),f*(p.green-e.green),f*(p.blue-
e.blue)];f=e.red+l[0];h=e.green+l[1];e=e.blue+l[2];f=parseInt(f);h=parseInt(h);e=parseInt(e);return{red:f,green:h,blue:e}}}},{}],3:[function(a,b,c){(function(a){a=a.split(".");for(var b=window,c=a.length,d=0;d<c;d++)"undefined"==typeof b[a[d]]&&(b[a[d]]={}),b=b[a[d]]})("greg.ross.visualisation");greg.ross.visualisation.SurfacePlot=function(a){this.containerElement=a};greg.ross.visualisation.SurfacePlot.prototype.draw=function(a,b){var c=b.xPos,d=b.yPos,f=b.width,g=b.height,k=b.colourGradient,m=b.fillPolygons,
p=b.tooltips,n=b.xTitle,q=b.yTitle,r=b.zTitle;b=b.restrictXRotation;void 0==this.surfacePlot&&(this.surfacePlot=new greg.ross.visualisation.JSSurfacePlot(c,d,f,g,k,this.containerElement,p,m,n,q,r,b));this.surfacePlot.redraw(a)};greg.ross.visualisation.JSSurfacePlot=function(a,b,c,h,l,g,k,m,p,n,q,r){function d(){Y.hide()}function e(a){w.clearRect(0,0,C.width,C.height);w.fillStyle="#000";w.fillRect(0,0,C.width,C.height);this.data=a;a=c-40;O.init();O.rotate(K,0,L);O.scale(y);O.translate(a/2+20,a/3*2+
20,0);Q=new greg.ross.visualisation.Point3D(a/2+20,a/2+20,-1E3);var b=new greg.ross.visualisation.Point3D(-.5,.5,0),d=new greg.ross.visualisation.Point3D(.5,.5,0),e=new greg.ross.visualisation.Point3D(-.5,-.5,0);a=new greg.ross.visualisation.Point3D(-.5,.5,1);b=O.ChangeObjectPoint(b);d=O.ChangeObjectPoint(d);e=O.ChangeObjectPoint(e);var g=O.ChangeObjectPoint(a);a=[];var h=new greg.ross.visualisation.Polygon(Q,!0);h.addPoint(b);h.addPoint(d);h.calculateCentroid();h.calculateDistance();a[a.length]=
h;d=new greg.ross.visualisation.Polygon(Q,!0);d.addPoint(b);d.addPoint(e);d.calculateCentroid();d.calculateDistance();a[a.length]=d;d=new greg.ross.visualisation.Polygon(Q,!0);d.addPoint(b);d.addPoint(g);d.calculateCentroid();d.calculateDistance();a[a.length]=d;d=D;b=[];for(e=h=0;e<I-1;e++)for(g=0;g<J-1;g++){var k=new greg.ross.visualisation.Polygon(Q,!1),l=O.ChangeObjectPoint(d[g+e*J]),r=O.ChangeObjectPoint(d[g+e*J+J]),t=O.ChangeObjectPoint(d[g+e*J+J+1]),u=O.ChangeObjectPoint(d[g+e*J+1]);k.addPoint(l);
k.addPoint(r);k.addPoint(t);k.addPoint(u);k.calculateCentroid();k.calculateDistance();b[h]=k;h++}for(i=0;i<a.length;i++)b[b.length]=a[i];b.sort(greg.ross.visualisation.PolygonComaparator);w.lineWidth=1;w.strokeStyle="#888";w.lineJoin="round";for(i=0;i<b.length;i++)h=b[i],h.isAnAxis()?(d=h.getPoint(0),e=h.getPoint(1),w.beginPath(),w.moveTo(d.ax,d.ay),w.lineTo(e.ax,e.ay),w.stroke()):(d=h.getPoint(0),e=h.getPoint(1),g=h.getPoint(2),h=h.getPoint(3),k=V.getColour((1*d.lz+1*e.lz+1*g.lz+1*h.lz)/4),w.fillStyle=
"rgb("+k.red+","+k.green+","+k.blue+")",w.beginPath(),w.moveTo(d.ax,d.ay),w.lineTo(e.ax,e.ay),w.lineTo(g.ax,g.ay),w.lineTo(h.ax,h.ay),w.lineTo(d.ax,d.ay),m?w.fill():w.stroke());w.stroke();f()&&(b=new greg.ross.visualisation.Point3D(0,.5,0),d=new greg.ross.visualisation.Point3D(-.5,0,0),e=new greg.ross.visualisation.Point3D(-.5,.5,.5),b=O.ChangeObjectPoint(b),d=O.ChangeObjectPoint(d),e=O.ChangeObjectPoint(e),g=a[0],h=a[1],a=a[2],w.fillStyle="#fff",g.distanceFromCamera>h.distanceFromCamera&&w.fillText(p,
b.ax,b.ay),g.distanceFromCamera<h.distanceFromCamera&&w.fillText(n,d.ax,d.ay),g.distanceFromCamera<a.distanceFromCamera&&w.fillText(q,e.ax,e.ay))}function f(){if(F)return H;F=!0;return H=!!document.createElement("canvas").getContext}function x(a){a:{if(3<parseInt(navigator.appVersion)){var b="Netscape"==navigator.appName?a:event;if(b="Netscape"==navigator.appName&&4==parseInt(navigator.appVersion)?"1"==(a.modifiers+32).toString(2).substring(3,6).charAt(0):b.shiftKey){b=!0;break a}}b=!1}b?(N=!0,X=
B(a)):(M=!0,W=B(a))}function A(a){M?S=R:N&&(T=R);N=M=!1}function z(a){a=B(a);if(M)d(),R=new greg.ross.visualisation.Point(greg.ross.visualisation.JSSurfacePlot.DEFAULT_Z_ANGLE,greg.ross.visualisation.JSSurfacePlot.DEFAULT_X_ANGLE),null==S&&(S=new greg.ross.visualisation.Point(greg.ross.visualisation.JSSurfacePlot.DEFAULT_Z_ANGLE,greg.ross.visualisation.JSSurfacePlot.DEFAULT_X_ANGLE)),null!=W&&(R=new greg.ross.visualisation.Point(S.x+(W.x-a.x),S.y+(W.y-a.y))),L=R.x%360,K=R.y%360,r&&(0>K?K=0:90<K&&
(K=90)),U=null,e(data);else if(N)d(),R=new greg.ross.visualisation.Point(0,greg.ross.visualisation.JSSurfacePlot.DEFAULT_SCALE/greg.ross.visualisation.JSSurfacePlot.SCALE_FACTOR),null==T&&(T=new greg.ross.visualisation.Point(0,greg.ross.visualisation.JSSurfacePlot.DEFAULT_SCALE/greg.ross.visualisation.JSSurfacePlot.SCALE_FACTOR)),null!=X&&(R=new greg.ross.visualisation.Point(T.x+(X.x-a.x),T.y+(X.y-a.y))),y=R.y*greg.ross.visualisation.JSSurfacePlot.SCALE_FACTOR,y<greg.ross.visualisation.JSSurfacePlot.MIN_SCALE?
y=greg.ross.visualisation.JSSurfacePlot.MIN_SCALE+1:y>greg.ross.visualisation.JSSurfacePlot.MAX_SCALE&&(y=greg.ross.visualisation.JSSurfacePlot.MAX_SCALE-1),R.y=y/greg.ross.visualisation.JSSurfacePlot.SCALE_FACTOR,U=null,e(data);else{U=null;for(var b=Number.MAX_VALUE,c=0;c<D.length;c++){var f=D[c];var g=f.ax;f=f.ay;g=Math.sqrt((g-a.x)*(g-a.x)+(f-a.y)*(f-a.y));g<b&&(b=g,U=c)}if(16<b){d();return}new greg.ross.visualisation.Point(a.x,a.y);Y.show(k[U],200)}return!1}function B(a){var b=-1;"Microsoft Internet Explorer"==
navigator.appName&&null!=/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(navigator.userAgent)&&(b=parseFloat(RegExp.$1));if(-1<b)if(a=window.event,1==a.srcElement.getAttribute("Stroked")){if(null==P||null==G)return}else P=a.offsetX,G=a.offsetY;else if(a.layerX||0==a.layerX)P=a.layerX,G=a.layerY;else if(a.offsetX||0==a.offsetX)P=a.offsetX,G=a.offsetY;else if(a.touches[0].pageX||0==a.touches[0].pageX)P=a.touches[0].pageX,G=a.touches[0].pageY;return new greg.ross.visualisation.Point(P,G)}this.targetDiv;var E=function(){var a=
0;do a++;while(document.getElementById("surfacePlot"+a));return"surfacePlot"+a}(),w=null,y=greg.ross.visualisation.JSSurfacePlot.DEFAULT_SCALE,L=greg.ross.visualisation.JSSurfacePlot.DEFAULT_Z_ANGLE,K=greg.ross.visualisation.JSSurfacePlot.DEFAULT_X_ANGLE;this.data=null;var F=!1,H=!0,D=null,I,J,Q,V,M=!1,N=!1,P=null,G=null,R=new greg.ross.visualisation.Point(0,0),S=null,T=null,W=new greg.ross.visualisation.Point(0,0),X=new greg.ross.visualisation.Point(0,0),U=null;new greg.ross.visualisation.Tooltip(!0);
new greg.ross.visualisation.Tooltip(!0);new greg.ross.visualisation.Tooltip(!0);var Y=new greg.ross.visualisation.Tooltip(!1);this.redraw=function(a){I=1*a.getNumberOfRows();J=1*a.getNumberOfColumns();for(var b=Number.MAX_VALUE,c=Number.MIN_VALUE,d=0;d<I;d++)for(var f=0;f<J;f++){var g=1*a.getFormattedValue(d,f);g<b&&(b=g);g>c&&(c=g)}V=new greg.ross.visualisation.ColourGradient(b,c,l?l:[{red:0,green:0,blue:255},{red:0,green:255,blue:255},{red:0,green:255,blue:0},{red:255,green:255,blue:0},{red:255,
green:0,blue:0}]);b=1/(I-1);c=1/(J-1);var h;D=[];var k=0;d=0;for(g=-.5;d<I;d++,g+=b)for(f=0,h=.5;f<J;f++,h-=c)D[k]=new greg.ross.visualisation.Point3D(g,h,a.getFormattedValue(d,f)),k++;e(a)};var O=new greg.ross.visualisation.Th3dtran;(function(){this.targetDiv=document.createElement("div");this.targetDiv.id=E;this.targetDiv.className="surfaceplot";this.targetDiv.style.background="#ffffff";this.targetDiv.style.position="absolute";g?(this.targetDiv.style.position="relative",g.appendChild(this.targetDiv)):
document.body.appendChild(this.targetDiv);this.targetDiv.style.left=a+"px";this.targetDiv.style.top=b+"px"})();if(targetDiv){var C=document.createElement("canvas");f()||(G_vmlCanvasManager.initElement(C),C.style.width=c,C.style.height=h);C.className="surfacePlotCanvas";C.setAttribute("width",c);C.setAttribute("height",h);C.style.left="0px";C.style.top="0px";targetDiv.appendChild(C);w=C.getContext("2d");w.font="bold 18px sans-serif";w.clearRect(0,0,C.width,C.height);w.fillStyle="#000";w.fillRect(0,
0,C.width,C.height);w.beginPath();w.rect(0,0,C.width,C.height);w.strokeStyle="#888";w.stroke();C.onmousemove=z;C.onmouseout=d;C.onmousedown=x;C.onmouseup=A;C.addEventListener("touchstart",x,!1);C.addEventListener("touchmove",z,!1);C.addEventListener("touchend",A,!1);C.addEventListener("touchcancel",d,!1)}};greg.ross.visualisation.Matrix3d=function(){this.matrix=[];this.numCols=this.numRows=4;this.init=function(){this.matrix=[];for(var a=0;a<this.numRows;a++)this.matrix[a]=[]};this.getMatrix=function(){return this.matrix};
this.matrixReset=function(){for(var a=0;a<this.numRows;a++)for(var b=0;b<this.numCols;b++)this.matrix[a][b]=0};this.matrixIdentity=function(){this.matrixReset();this.matrix[0][0]=this.matrix[1][1]=this.matrix[2][2]=this.matrix[3][3]=1};this.matrixCopy=function(a){var b=new greg.ross.visualisation.Matrix3d,c,d;for(c=0;c<this.numRows;c++)for(d=0;d<this.numCols;d++)b.getMatrix()[c][d]=this.matrix[c][0]*a.getMatrix()[0][d]+this.matrix[c][1]*a.getMatrix()[1][d]+this.matrix[c][2]*a.getMatrix()[2][d]+this.matrix[c][3]*
a.getMatrix()[3][d];for(c=0;c<this.numRows;c++)this.matrix[c][0]=b.getMatrix()[c][0],this.matrix[c][1]=b.getMatrix()[c][1],this.matrix[c][2]=b.getMatrix()[c][2],this.matrix[c][3]=b.getMatrix()[c][3]};this.matrixMult=function(a,b){var c=new greg.ross.visualisation.Matrix3d,d,f;for(d=0;d<this.numRows;d++)for(f=0;f<this.numCols;f++)c.getMatrix()[d][f]=b.getMatrix()[d][0]*a.getMatrix()[0][f]+b.getMatrix()[d][1]*a.getMatrix()[1][f]+b.getMatrix()[d][2]*a.getMatrix()[2][f]+b.getMatrix()[d][3]*a.getMatrix()[3][f];
for(d=0;d<this.numRows;d++)a.getMatrix()[d][0]=c.getMatrix()[d][0],a.getMatrix()[d][1]=c.getMatrix()[d][1],a.getMatrix()[d][2]=c.getMatrix()[d][2],a.getMatrix()[d][3]=c.getMatrix()[d][3]};this.init()};greg.ross.visualisation.Point3D=function(a,b,c){this.displayValue="";this.lx;this.ly;this.lz;this.lt;this.wx;this.wy;this.wz;this.wt;this.ax;this.ay;this.az;this.at;this.dist;this.initPoint=function(){this.lx=this.ly=this.lz=this.ax=this.ay=this.az=this.at=this.wx=this.wy=this.wz=0;this.lt=this.wt=1};
this.init=function(a,b,c){this.initPoint();this.lx=a;this.ly=b;this.lz=c;this.ax=this.lx;this.ay=this.ly;this.az=this.lz};this.init(a,b,c)};greg.ross.visualisation.Polygon=function(a,b){this.points=[];this.cameraPosition=a;this.isAxis=b;this.distanceFromCamera=this.centroid=null;this.isAnAxis=function(){return this.isAxis};this.addPoint=function(a){this.points[this.points.length]=a};this.distance=function(){return this.distance2(this.cameraPosition,this.centroid)};this.calculateDistance=function(){this.distanceFromCamera=
this.distance()};this.calculateCentroid=function(){for(var a=0,b=0,c=0,d=1*this.points.length,f=0;f<d;f++)a+=this.points[f].ax,b+=this.points[f].ay,c+=this.points[f].az;this.centroid=new greg.ross.visualisation.Point3D(a/d,b/d,c/d)};this.distance2=function(a,b){return(a.ax-b.ax)*(a.ax-b.ax)+(a.ay-b.ay)*(a.ay-b.ay)+(a.az-b.az)*(a.az-b.az)};this.getPoint=function(a){return this.points[a]}};greg.ross.visualisation.PolygonComaparator=function(a,b){a=a.distanceFromCamera-b.distanceFromCamera;if(0!=a){if(0>
a)return-1;if(0<a)return 1}return 0};greg.ross.visualisation.Th3dtran=function(){this.matrix;this.rMat;this.rMatrix;this.objectMatrix;this.local=!0;this.init=function(){this.matrix=new greg.ross.visualisation.Matrix3d;this.rMat=new greg.ross.visualisation.Matrix3d;this.rMatrix=new greg.ross.visualisation.Matrix3d;this.objectMatrix=new greg.ross.visualisation.Matrix3d;this.initMatrix()};this.initMatrix=function(){this.matrix.matrixIdentity();this.objectMatrix.matrixIdentity()};this.translate=function(a,
b,c){this.rMat.matrixIdentity();this.rMat.getMatrix()[3][0]=a;this.rMat.getMatrix()[3][1]=b;this.rMat.getMatrix()[3][2]=c;this.local?this.objectMatrix.matrixCopy(this.rMat):this.matrix.matrixCopy(this.rMat)};this.rotate=function(a,b,c){a*=Math.PI/180;b*=Math.PI/180;c*=Math.PI/180;this.rMatrix.matrixIdentity();this.rMat.matrixIdentity();this.rMat.getMatrix()[1][1]=Math.cos(a);this.rMat.getMatrix()[1][2]=Math.sin(a);this.rMat.getMatrix()[2][1]=-Math.sin(a);this.rMat.getMatrix()[2][2]=Math.cos(a);this.rMatrix.matrixMult(this.rMatrix,
this.rMat);this.rMat.matrixIdentity();this.rMat.getMatrix()[0][0]=Math.cos(b);this.rMat.getMatrix()[0][2]=-Math.sin(b);this.rMat.getMatrix()[2][0]=Math.sin(b);this.rMat.getMatrix()[2][2]=Math.cos(b);this.rMat.matrixMult(this.rMatrix,this.rMat);this.rMat.matrixIdentity();this.rMat.getMatrix()[0][0]=Math.cos(c);this.rMat.getMatrix()[0][1]=Math.sin(c);this.rMat.getMatrix()[1][0]=-Math.sin(c);this.rMat.getMatrix()[1][1]=Math.cos(c);this.rMat.matrixMult(this.rMatrix,this.rMat);this.local?this.objectMatrix.matrixCopy(this.rMatrix):
this.matrix.matrixCopy(this.rMatrix)};this.scale=function(a){this.rMat.matrixIdentity();this.rMat.getMatrix()[0][0]=a;this.rMat.getMatrix()[1][1]=a;this.rMat.getMatrix()[2][2]=a;this.local?this.objectMatrix.matrixCopy(this.rMat):this.matrix.matrixCopy(this.rMat)};this.changeLocalObject=function(a){a.wx=a.ax*this.matrix.getMatrix()[0][0]+a.ay*this.matrix.getMatrix()[1][0]+a.az*this.matrix.getMatrix()[2][0]+this.matrix.getMatrix()[3][0];a.wy=a.ax*this.matrix.getMatrix()[0][1]+a.ay*this.matrix.getMatrix()[1][1]+
a.az*this.matrix.getMatrix()[2][1]+this.matrix.getMatrix()[3][1];a.wz=a.ax*this.matrix.getMatrix()[0][2]+a.ay*this.matrix.getMatrix()[1][2]+a.az*this.matrix.getMatrix()[2][2]+this.matrix.getMatrix()[3][2];return a};this.ChangeObjectPoint=function(a){a.ax=a.lx*this.objectMatrix.getMatrix()[0][0]+a.ly*this.objectMatrix.getMatrix()[1][0]+a.lz*this.objectMatrix.getMatrix()[2][0]+this.objectMatrix.getMatrix()[3][0];a.ay=a.lx*this.objectMatrix.getMatrix()[0][1]+a.ly*this.objectMatrix.getMatrix()[1][1]+
a.lz*this.objectMatrix.getMatrix()[2][1]+this.objectMatrix.getMatrix()[3][1];a.az=a.lx*this.objectMatrix.getMatrix()[0][2]+a.ly*this.objectMatrix.getMatrix()[1][2]+a.lz*this.objectMatrix.getMatrix()[2][2]+this.objectMatrix.getMatrix()[3][2];return a};this.init()};greg.ross.visualisation.Point=function(a,b){this.x=a;this.y=b};greg.ross.visualisation.Tooltip=function(a){function b(a){var b=c;if(95!=b&&1==a||0!=b&&-1==a){var e=10;10>95-b&&1==a?e=95-b:10>c&&-1==a&&(e=b);c=b+e*a;d.style.opacity=.01*c;
d.style.filter="alpha(opacity="+c+")"}else clearInterval(d.timer),-1==a&&(d.style.display="none")}var c=0,d,l,g,k,m,p=document.all?!0:!1;this.show=function(c,e){null==d&&(d=document.createElement("div"),d.style.color="#fff",d.style.position="absolute",d.style.display="block",l=document.createElement("div"),l.style.display="block",l.style.height="5px",l.style.marginleft="5px",l.style.overflow="hidden",g=document.createElement("div"),k=document.createElement("div"),d.appendChild(l),d.appendChild(g),
d.appendChild(k),document.body.appendChild(d),p?d.style.opacity=1:(d.style.opacity=0,d.style.filter="alpha(opacity=0)"));a||(document.onmousemove=this.pos);d.style.display="block";g.innerHTML='<span style="font-weight:bold; font-family: arial;">'+c+"</span>";d.style.width=e?e+"px":"auto";!e&&p&&(l.style.display="none",k.style.display="none",d.style.width=d.offsetWidth,l.style.display="block",k.style.display="block");300<d.offsetWidth&&(d.style.width="300px");m=parseInt(d.offsetHeight)+3;p||(clearInterval(d.timer),
d.timer=setInterval(function(){b(1)},20))};this.setPos=function(a){d.style.top=a.y+"px";d.style.left=a.x+"px"};this.pos=function(a){var b=p?event.clientX+document.documentElement.scrollLeft:a.pageX;d.style.top=(p?event.clientY+document.documentElement.scrollTop:a.pageY)-m+"px";d.style.left=b+3+"px"};this.hide=function(){null!=d&&(p?d.style.display="none":(clearInterval(d.timer),d.timer=setInterval(function(){b(-1)},20)))}};greg.ross.visualisation.JSSurfacePlot.DEFAULT_X_ANGLE=47;greg.ross.visualisation.JSSurfacePlot.DEFAULT_Z_ANGLE=
47;greg.ross.visualisation.JSSurfacePlot.DATA_DOT_SIZE=3;greg.ross.visualisation.JSSurfacePlot.DEFAULT_SCALE=350;greg.ross.visualisation.JSSurfacePlot.MIN_SCALE=50;greg.ross.visualisation.JSSurfacePlot.MAX_SCALE=1100;greg.ross.visualisation.JSSurfacePlot.SCALE_FACTOR=1.4},{}]},{},[1]);
(function e$jscomp$0(a,b,c){function f(h,g){if(!b[h]){if(!a[h]){var k="function"==typeof require&&require;if(!g&&k)return k(h,!0);if(e)return e(h,!0);g=Error("Cannot find module '"+h+"'");throw g.code="MODULE_NOT_FOUND",g;}g=b[h]={exports:{}};a[h][0].call(g.exports,function(b){var c=a[h][1][b];return f(c?c:b)},g,g.exports,e$jscomp$0,a,b,c)}return b[h].exports}for(var e="function"==typeof require&&require,h=0;h<c.length;h++)f(c[h]);return f})({1:[function(a,b,c){(function(){var b=a("./imexam");c.bin1d=
b.typed(function(a,c){var d=b.typed.clone(a.shape).map(function(a){return a/c+.5|0});d=b.typed.array(a.type,d);d[0/c|0]+=a;return d});var f=b.typed(function(a,b,c){b[0/c|0][0/c|0]+=a;return b});c.bin2d=function(a,c){var d=b.typed.clone(a.shape).map(function(a){return a/c+.5|0});d=b.typed.array(d,a);return f(a,d,c)};c.smooth_gaussian2d=function(a,c){var d=b.typed.array(a.shape,"float32"),e=b.typed.array(a.shape,"float32"),f=[];for(h=0;10>h;h++)f[h]=1*Math.pow(2.71828,-h*h/(2*c*c));var h,p;for(h=0;h<
f.length&&!(.001>f[h]);h++);f.length=h-1;c=b.typed.clone(f);f=f.reverse();for(h=1;h<c.length;h++)f[f.length]=c[h];f.shape[0]=f.length;f=b.typed.div(f,b.typed.sum(f));var n=a.shape[1],q=a.shape[0],r=f.shape[0];for(c=0;c<q;c++)for(h=0;h<n;h++)for(p=-r/2|0;p<r/2|0;p++)0<=h+p&&h+p<q&&(d.data[c*n+h]+=f[p+r/2|0]*a.data[c*n+h+p]);for(c=0;c<q;c++)for(h=0;h<n;h++)for(p=-r/2|0;p<r/2|0;p++)0<=c+p&&c+p<q&&(e.data[c*n+h]+=f[p+r/2|0]*d.data[(c+p)*n+h]);return e}})()},{"./imexam":void 0}],2:[function(a,b,c){a=function(){var a=
function(a,b){var c=a.x-b.x;a=a.y-b.y;return 1E-20>c*c+a*a},b=function(a){for(var b=a.head,c;b;)c=b.next,b.next=b.prev,b=b.prev=c;c=a.head;a.head=a.tail;a.tail=c},c=function(a){this.count=0;this.level=a;this.s=null;this.count=0};c.prototype.remove_seq=function(a){a.prev?a.prev.next=a.next:this.s=a.next;a.next&&(a.next.prev=a.prev);--this.count};c.prototype.addSegment=function(c,d){var f=this.s,e=null,g=null,h=!1,l=!1;if(1E5<this.count++)throw Error("Too many calls to coutour AddSegment");for(;f&&
(null==e&&(a(c,f.head.p)?(e=f,h=!0):a(c,f.tail.p)&&(e=f)),null==g&&(a(d,f.head.p)?(g=f,l=!0):a(d,f.tail.p)&&(g=f)),null==g||null==e);)f=f.next;switch((null!=e?1:0)|(null!=g?2:0)){case 0:e={p:c,prev:null};d={p:d,next:null};e.next=d;d.prev=e;e={head:e,tail:d,next:this.s,prev:null,closed:!1};this.s&&(this.s.prev=e);this.s=e;++this.count;break;case 1:d={p:d};h?(d.next=e.head,d.prev=null,e.head.prev=d,e.head=d):(d.next=null,d.prev=e.tail,e.tail.next=d,e.tail=d);break;case 2:d={p:c};l?(d.next=g.head,d.prev=
null,g.head.prev=d,g.head=d):(d.next=null,d.prev=g.tail,g.tail.next=d,g.tail=d);break;case 3:if(e===g)d={p:e.tail.p,next:e.head,prev:null},e.head.prev=d,e.head=d,e.closed=!0;else switch((h?1:0)|(l?2:0)){case 0:b(e);case 1:g.tail.next=e.head;e.head.prev=g.tail;g.tail=e.tail;this.remove_seq(e);break;case 3:b(e);case 2:e.tail.next=g.head,g.head.prev=e.tail,e.tail=g.tail,this.remove_seq(g)}}};var h=function(a){if(a)this.drawContour=a;else{var b=this;b.contours={};this.drawContour=function(a,d,e,f,g,h){var k=
b.contours[h];k||(k=b.contours[h]=new c(g));k.addSegment({x:d,y:a},{x:f,y:e})};this.contourList=function(){var a=[],c=b.contours,d;for(d in c)for(var e=c[d].s,f=c[d].level;e;){var g=e.head,h=[];h.level=f;for(h.k=d;g&&g.p;)h.push(g.p),g=g.next;a.push(h);e=e.next}a.sort(function(a,b){return b.k-a.k});return a}}this.h=Array(5);this.sh=Array(5);this.xh=Array(5);this.yh=Array(5)};h.prototype.contour=function(a,b,c,d,e,f,h,r,v){var g=this.h,k=this.sh,l=this.xh,m=this.yh,p=this.drawContour;this.contours=
{};for(var n=function(a,b){return(g[b]*l[a]-g[a]*l[b])/(g[b]-g[a])},q=function(a,b){return(g[b]*m[a]-g[a]*m[b])/(g[b]-g[a])},w,y,L,K,F=0,H=0,D=0,I=0,J=[0,1,1,0],Q=[0,0,1,1],V=[[[0,0,8],[0,2,5],[7,6,9]],[[0,3,4],[1,3,1],[4,3,0]],[[9,6,7],[5,2,0],[8,0,0]]],M=e-1;M>=d;M--)for(var N=b;N<=c-1;N++)if(w=Math.min(a.get(N,M),a.get(N,M+1)),y=Math.min(a.get(N+1,M),a.get(N+1,M+1)),e=Math.min(w,y),w=Math.max(a.get(N,M),a.get(N,M+1)),y=Math.max(a.get(N+1,M),a.get(N+1,M+1)),K=Math.max(w,y),K>=v[0]&&e<=v[r-1])for(var P=
0;P<r;P++)if(v[P]>=e&&v[P]<=K){for(var G=4;0<=G;G--)0<G?(g[G]=a.get(N+J[G-1],M+Q[G-1])-v[P],l[G]=f[N+J[G-1]],m[G]=h[M+Q[G-1]]):(g[0]=.25*(g[1]+g[2]+g[3]+g[4]),l[0]=.5*(f[N]+f[N+1]),m[0]=.5*(h[M]+h[M+1])),k[G]=0<g[G]?1:0>g[G]?-1:0;for(G=1;4>=G;G++)if(w=G,y=4!=G?G+1:1,L=V[k[w]+1][k[0]+1][k[y]+1],0!=L){switch(L){case 1:F=l[w];D=m[w];H=l[0];I=m[0];break;case 2:F=l[0];D=m[0];H=l[y];I=m[y];break;case 3:F=l[y];D=m[y];H=l[w];I=m[w];break;case 4:F=l[w];D=m[w];H=n(0,y);I=q(0,y);break;case 5:F=l[0];D=m[0];H=
n(y,w);I=q(y,w);break;case 6:F=l[y];D=m[y];H=n(w,0);I=q(w,0);break;case 7:F=n(w,0);D=q(w,0);H=n(0,y);I=q(0,y);break;case 8:F=n(0,y);D=q(0,y);H=n(y,w);I=q(y,w);break;case 9:F=n(y,w),D=q(y,w),H=n(w,0),I=q(w,0)}p(F,D,H,I,v[P],P)}}};return h}();"undefined"!==typeof c&&(c.Conrec=a)},{}],3:[function(a,b,c){(function(){function a(a,b,c,d,g,k,m,p,n){for(var e=d,f=g,h=k,l=1,t=0>e||e>=a-1||0>f&&f>=b-1,x,A,z,B,E,w,y;!t;){x=0;A=m[f*a+e];z=m[f*a+e+1];B=m[(f+1)*a+e+1];E=m[(f+1)*a+e];if(l)switch(l=0,k){case 0:w=
(c-A)/(z-A)+e;y=f;break;case 1:w=e+1;y=(c-z)/(B-z)+f;break;case 2:w=(c-B)/(E-B)+e;y=f+1;break;case 3:w=e,y=(c-A)/(E-A)+f}else{0==k&&(p[f*a+e]=1);do switch(4==++k&&(k=0),k){case 0:A>=c&&c>z&&(x=1,w=(c-A)/(z-A)+e,y=f,f--);break;case 1:z>=c&&c>B&&(x=1,w=e+1,y=(c-z)/(B-z)+f,e++);break;case 2:B>=c&&c>E&&(x=1,w=(c-E)/(B-E)+e,y=f+1,f++);break;case 3:E>=c&&c>A&&(x=1,w=e,y=(c-A)/(E-A)+f,e--)}while(!x);4===++k&&(k=0);4===++k&&(k=0);e==d&&f==g&&k==h&&(t=1);if(0>e||e>=a-1||0>f||f>=b-1)t=1}n(w+.5,y+.5,c);t&&n(0,
0,void 0)}}b.exports=function(b,c,d,l,g){var e,f=new Uint8Array(c*d),h,n;for(e=0;e<b.length;e++){var q=b[e];for(h=0;h<c*d;h++)f[h]=0;for(h=n=0;h<c-1;h++)l[n*c+h]<q&&q<=l[n*c+h+1]&&a(c,d,q,h,n,0,l,f,g);for(n=0;n<d-1;n++)l[n*c+h]<q&&q<=l[(n+1)*c+h]&&a(c,d,q,h-1,n,1,l,f,g);for(h--;0<=h;h--)l[n*c+h+1]<q&&q<=l[n*c+h]&&a(c,d,q,h,n-1,2,l,f,g);h=0;for(n--;0<=n;n--)l[(n+1)*c+h]<q&&q<=l[n*c+h]&&a(c,d,q,h,n,3,l,f,g);for(n=1;n<d-1;n++)for(h=0;h<c-1;h++)!f[n*c+h]&&l[n*c+h]<q&&q<=l[n*c+h+1]&&a(c,d,q,h,n,0,l,f,
g)}}})()},{}],4:[function(a,b,c){(function(){function b(a,b){var c=JS9.GetImage({display:b});a=$(a).find(".contour-form")[0];var d=h.ndops.ndarray(c.raw.data,[c.raw.height,c.raw.width]);b=a.level.value;var e=$(a).find("#binning").val(),f=$(a).find("#smooth").val(),m=$(a).find("input[type=radio]:checked").val();"none"===e?e=1:d=k.bin2d(d,parseInt(e));var p=JSON.parse("["+b.trim().split(/\s+/).join(",")+"]").map(function(a){return a*e*e});"none"!==f&&(d=k.smooth_gaussian2d(d,parseFloat(f)));var x;JS9.waiting(!0);
setTimeout(function(){try{if("better"===m){var a=new l.Conrec;try{var b=h.ndops.iota(0,d.shape[0]-1).map(function(a){return a*e+(e-1)/2+1}),f=h.ndops.iota(0,d.shape[1]-1).map(function(a){return a*e+(e-1)/2+1});a.contour(d,0,d.shape[0]-1,0,d.shape[1]-1,b,f,p.length,p)}catch(w){alert("Too many coutour segments: Check your coutour levels.\n\nAre you trying to coutour the background levels of an image?");return}x=a.contourList().map(function(a){return{shape:"polygon",pts:a}})}else{var k=[];x=[];x.push({shape:"polygon",
pts:k});g(p,d.shape[0],d.shape[1],d.data,function(a,b,c){void 0===c?(k=[],x.push({shape:"polygon",pts:k})):k.push({x:a*e+.5,y:b*e+.5})});--x.length}JS9.NewShapeLayer("contour",JS9.Catalogs.opts,{display:c});JS9.RemoveShapes("contour",{display:c});JS9.AddShapes("contour",x,{color:"yellow"},{display:c})}finally{JS9.waiting(!1)}},200)}function c(a,b){if(b=JS9.GetImage({display:b}))a=$(a).find(".contour-form")[0],b=h.ndops.ndarray(b.raw.data,[b.raw.width,b.raw.height]),a.min.value=h.ndops.minvalue(b).toFixed(2),
a.max.value=h.ndops.maxvalue(b).toFixed(2)}function e(a,b){if(JS9.GetImage({display:b})){a=$(a).find(".contour-form")[0];var c=Number(a.nlevel.value);b=h.ndops.ndarray(h.ndops.iota(1,c));var d=Number(a.min.value),e=Number(a.max.value);h.ndops.divs(b,b,c+1);h.ndops.muls(b,b,e-d);h.ndops.adds(b,b,d);d=[];for(c=0;c<b.shape[0];c++)d.push(b.data[c].toFixed(2));a.level.value=d.join("\n")}}var h=a("./imexam"),l=a("./conrec"),g=a("./contfv"),k=a("./bin");JS9.RegisterPlugin("ImExam","Contours",function(){var a=
JS9.GetImage({display:this.display}),d=this.div;d.innerHTML='<form class="contour-form js9Form">\t\t\t\t\t\t\t\t <table style="border-collapse: separate; border-spacing: 10px 5px;"><tr>\t<td>Num:</td>\t\t\t\t<td><input type=text name=nlevel value=5 size="10" style="text-align:right;"></td>\t\t\t\t\t\t\t<td><input type=button value="Draw contours" class="drw-contour JS9Button2"></td></tr>\t\t <tr>\t<td>Min:</td>\t\t\t\t\t\t\t\t\t\t\t\t<td><input type=text name=min size="10" style="text-align:right;"></td>\t\t\t\t\t\t\t\t<td><input type=button value="Reset min/max" class="get-min-max JS9Button2"></td></tr>\t\t <tr>\t<td>Max:</td>\t\t\t\t\t\t\t\t\t\t\t\t<td><input type=text name=max size="10" style="text-align:right;"></td></tr>\t\t\t\t\t <tr>\t<td valign=top>Levels:</td>\t\t\t\t\t\t\t\t \t\t<td rowspan=5><textarea rows=12 cols="10" name=level class="contour-levels" style="text-align:right;">\t\t\t\t </textarea>\t\t\t\t\t\t\t\t\t\t\t\t<td valign=top><input type=button value="Make levels" class="make-levels JS9Button2"></td>\t\t\t </tr>\t\t\t\t\t\t\t\t\t\t\t\t <tr><td></td><td valign=top>\t\t\t\t\t\t\t\t\t\t\t\tBinning: \t\t\t\t\t\t\t\t<select id=binning name=binpix class=JS9Select>\t\t\t\t\t\t\t\t<option>none</option>\t\t\t\t\t\t\t\t\t\t\t<option>2</option>\t\t\t\t\t\t\t\t\t\t\t<option>3</option>\t\t\t\t\t\t\t\t\t\t\t<option>4</option>\t\t\t\t\t\t\t\t\t\t\t<option>5</option>\t\t\t\t\t\t\t\t\t\t\t<option>6</option>\t\t\t\t\t\t\t\t\t\t\t<option>7</option>\t\t\t\t\t\t\t\t\t\t\t<option>8</option>\t\t\t\t\t\t\t\t\t\t\t</select>\t\t\t\t\t\t\t\t\t\t\t\tpix\t\t\t\t\t\t\t\t\t\t\t\t</td>\t\t\t\t\t\t\t\t\t\t\t\t </tr>\t\t\t\t\t\t\t\t\t\t\t\t <tr><td></td><td valign=top>\t\t\t\t\t\t\t\t\t\t\t\tSmoothing: \t\t\t\t\t\t\t\t\t\t\t<select id=smooth name=smopix class=JS9Select>\t\t\t\t\t\t\t\t<option>none</option>\t\t\t\t\t\t\t\t\t\t\t<option value=0.75 selected>3</option>\t\t\t\t\t\t\t\t\t<option value=1.00>5</option>\t\t\t\t\t\t\t\t\t\t<option value=1.25>7</option>\t\t\t\t\t\t\t\t\t\t</select>\t\t\t\t\t\t\t\t\t\t\t\tpix\t\t\t\t\t\t\t\t\t\t\t\t</td>\t\t\t\t\t\t\t\t\t\t\t\t </tr>\t\t\t\t\t\t\t\t\t\t\t\t <tr><td></td><td valign=top>\t\t\t\t\t\t\t\t\t\t\t\tQuality: \t\t\t\t\t\t\t\t\t\t\t\t<input type=radio name=quality value=faster checked>faster\t\t\t\t\t\t<input type=radio name=quality value=better>better\t\t\t\t\t\t</td>\t\t\t\t\t\t\t\t\t\t\t\t </tr>\t\t\t\t\t\t\t\t\t\t\t </table>\t\t\t\t\t\t\t\t\t\t\t\t <p>\t\t\t\t\t\t\t\t\t\t\t\t\t </form>';
var f=this.display;$(d).find(".drw-contour").on("mouseup",function(){b(d,f)});$(d).find(".get-min-max").on("mouseup",function(){c(d,f)});$(d).find(".make-levels").on("mouseup",function(){e(d,f)});void 0!==a&&(c(d,f),e(d,f));h.fixupDiv(this)},{menu:"view",winTitle:"Contours",menuItem:"Contours",help:"imexam/contours.html",toolbarSeparate:!0,winDims:[400,300]})})()},{"./bin":1,"./conrec":2,"./contfv":3,"./imexam":void 0}]},{},[4]);