-
Notifications
You must be signed in to change notification settings - Fork 33
/
glift.js
357 lines (356 loc) · 190 KB
/
glift.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
/*
Glift: A Responsive Javascript library for the game Go.
@copyright Josh Hoak
@license MIT License (see LICENSE.txt)
@version 1.1.0
--------------------------------------
*/
var $jscomp={scope:{}};window.goog||(window.goog={},window.goog.provide=function(){},window.goog.require=function(){},window.goog.scope=function(a){a()});var glift={};(function(a){var b=a.glift||{};a&&(a.glift=b)})(window);glift.global={version:"1.1.0",debugMode:!1,performanceDebugLevel:"NONE",perf:{first:null,last:null,lastMajor:null},instanceRegistry:{},activeInstanceId:null,disabledZoom:!1,addedCssClasses:!1};glift.init=function(a,b){if(!glift.platform.supportsSvg())throw glift.dom.elem(b).html('Your browser does not support Glift, this Go viewer, due to lack of SVG support. Please upgrade or try one of <a href="http://browsehappy.com/">these</a>'),Error('Your browser does not support Glift, this Go viewer, due to lack of SVG support. Please upgrade or try one of <a href="http://browsehappy.com/">these</a>');if(!glift.global.disabledZoom&&a&&glift.platform.isMobile()){for(var c=document.getElementsByTagName("meta"),
d=0,e=c.length;d<e;d++){var f=c[d]?c[d].getAttribute("name"):null;f&&"viewport"===f.toLowerCase()&&glift.dom.elem(c[d]).remove()}c=document.head;if(null==c)throw Error("document.head was null, but it must not be null for disable zoom to work.");c=glift.dom.elem(c);d=glift.dom.elem(document.createElement("meta")).setAttr("name","viewport").setAttr("content","width=device-width, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no");c.prepend(d);glift.global.disabledZoom=!0}glift.global.addedCssClasses||
(c=document.createElement("style"),c.type="text/css",c.innerHTML=".glift-fullscreen-no-scroll { overflow: hidden; }\n.glift-comment-box {}",document.getElementsByTagName("head")[0].appendChild(c),glift.global.addedCssClasses=!0)};glift.util={assertDef:function(a,b){if(void 0===a||null===a)throw Error("Param not defined! "+(b||""));return a},logz:function(a){console.log(a);return null},typeOf:function(a){var b=typeof a;"object"===b&&(a?a instanceof Array&&(b="array"):b="null");return b},inBounds:function(a,b){return a<b&&0<=a},outBounds:function(a,b){return a>=b||0>a},intersection:function(a,b){var c={},d;for(d in a)void 0!==b[d]&&(c[d]=1);return c},getKeyWithDefault:function(a,b,c){void 0===a[b]&&(a[b]=c);return a[b]},sizeOf:function(a){var b=
0,c;for(c in a)b+=1;return b},setMethods:function(a,b){for(var c in b)a[c]=b[c].bind(a);return a},beget:function(a){var b=function(){};b.prototype=a;return new b},simpleClone:function(a){if("array"!==glift.util.typeOf(a)&&"object"!==glift.util.typeOf(a))return a;if(a instanceof Date){var b=new Date;b.setTime(a.getTime());return b}if("array"===glift.util.typeOf(a)){for(var b=[],c=0,d=a.length;c<d;c++)b[c]=glift.util.simpleClone(a[c]);return b}if("object"===glift.util.typeOf(a)){b={};for(c in a)a.hasOwnProperty(c)&&
(b[c]=glift.util.simpleClone(a[c]));return b}throw Error("Unable to copy obj! Its type isn't supported.");}};glift.util.debugl=function(a){glift.debugOn&&glift.util.log(a)};glift.util.log=function(a){"array"!==glift.util.typeOf(a)&&"object"!==glift.util.typeOf(a)||JSON.stringify(a);void 0!==console&&void 0!==console.log&&console.log(a)};glift.array={remove:function(a,b){var c=a.indexOf(b);-1<c&&a.splice(c,1);return a},replace:function(a,b,c){b=a.indexOf(b);-1<b&&(a[b]=c);return a}};glift.util.colors={isLegalColor:function(a){return a===glift.enums.states.BLACK||a===glift.enums.states.WHITE||a===glift.enums.states.EMPTY},oppositeColor:function(a){return a===glift.enums.states.BLACK?glift.enums.states.WHITE:a===glift.enums.states.WHITE?glift.enums.states.BLACK:a}};glift.enums={toCamelCase:function(a){return a.toLowerCase().replace(/_(.)?/g,function(a,c){return c?c.toUpperCase():""})}};glift.enums.states={BLACK:"BLACK",WHITE:"WHITE",EMPTY:"EMPTY"};glift.enums.boardAlignments={TOP:"TOP",RIGHT:"RIGHT",CENTER:"CENTER"};glift.enums.directions={LEFT:"LEFT",RIGHT:"RIGHT",TOP:"TOP",BOTTOM:"BOTTOM"};
glift.enums.boardRegions={LEFT:"LEFT",RIGHT:"RIGHT",TOP:"TOP",BOTTOM:"BOTTOM",TOP_LEFT:"TOP_LEFT",TOP_RIGHT:"TOP_RIGHT",BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT",ALL:"ALL",AUTO:"AUTO",MINIMAL:"MINIMAL"};glift.enums.controllerMessages={CONTINUE:"CONTINUE",DONE:"DONE",FAILURE:"FAILURE"};
glift.enums.marks={CIRCLE:"CIRCLE",SQUARE:"SQUARE",TRIANGLE:"TRIANGLE",XMARK:"XMARK",STONE_MARKER:"STONE_MARKER",LABEL:"LABEL",LABEL_ALPHA:"LABEL_ALPHA",LABEL_NUMERIC:"LABEL_NUMERIC",VARIATION_MARKER:"VARIATION_MARKER",CORRECT_VARIATION:"CORRECT_VARIATION"};glift.enums.problemResults={CORRECT:"CORRECT",INCORRECT:"INCORRECT",INDETERMINATE:"INDETERMINATE",FAILURE:"FAILURE"};glift.enums.displayDataTypes={PARTIAL:"PARTIAL",FULL:"FULL"};
glift.enums.svgElements={SVG:"svg",BOARD:"board",BOARD_COORD_LABELS:"board_coord_labels",INTERSECTIONS_CONTAINER:"intersections",BOARD_LINE:"board_line",BOARD_LINE_CONTAINER:"board_line_container",BUTTON:"button",BUTTON_CONTAINER:"button_container",FULL_BOARD_BUTTON:"full_board_button",MARK:"mark",TEMP_MARK_GROUP:"temp_mark_group",MARK_CONTAINER:"mark_container",GLIFT_ELEMENT:"glift_element",STARPOINT:"starpoint",STARPOINT_CONTAINER:"starpoint_container",STONE:"stone",STONE_CONTAINER:"stone_container",
STONE_SHADOW:"stone_shadow",STONE_SHADOW_CONTAINER:"stone_shadow_container",GUIDE_LINE:"guide_line",ICON:"icon",ICON_CONTAINER:"icon_container",TEMP_ICON:"temp_icon",TEMP_TEXT:"temp_text",TEMP_ICON_CONTAINER:"temp_icon_container"};glift.enums.showVariations={ALWAYS:"ALWAYS",NEVER:"NEVER",MORE_THAN_ONE:"MORE_THAN_ONE"};
glift.enums.widgetTypes={CORRECT_VARIATIONS_PROBLEM:"CORRECT_VARIATIONS_PROBLEM",EXAMPLE:"EXAMPLE",GAME_VIEWER:"GAME_VIEWER",REDUCED_GAME_VIEWER:"REDUCED_GAME_VIEWER",STANDARD_PROBLEM:"STANDARD_PROBLEM",BOARD_EDITOR:"BOARD_EDITOR"};glift.enums.boardComponents={BOARD:"BOARD",COMMENT_BOX:"COMMENT_BOX",EXTRA_ICONBAR:"EXTRA_ICONBAR",ICONBAR:"ICONBAR",STATUS_BAR:"STATUS_BAR"};glift.enums.dubug={NONE:"NONE",INFO:"INFO"};
glift.enums.rotations={NO_ROTATION:"NO_ROTATION",CLOCKWISE_90:"CLOCKWISE_90",CLOCKWISE_180:"CLOCKWISE_180",CLOCKWISE_270:"CLOCKWISE_270"};(function(){glift.errors={};glift.errors.ParseError=function(a){this.name="ParseError";this.message=a||""};glift.errors.ParseError.prototype=Error()})();glift.util.IdGenerator_=function(a){this.seed=a||0};glift.util.IdGenerator_.prototype={next:function(){var a=this.seed+"";this.seed+=1;return a}};glift.util.idGenerator=new glift.util.IdGenerator_(0);glift.keyMappings={specialChars:{BACKSPACE:8,ESCAPE:27,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40},_codeToNameKeyDown:void 0,nameToCode:function(a){return 1!==a.length?/[A-Z](_[A-Z]+)*/.test(a)?glift.keyMappings.specialChars[a]||null:null:a.charCodeAt(0)},codeToName:function(a){if(!glift.keyMappings._codeToNameKeyDown){var b={},c;for(c in glift.keyMappings.specialChars)b[glift.keyMappings.specialChars[c]]=c;glift.keyMappings._codeToNameKeyDown=b}return glift.keyMappings._codeToNameKeyDown[a]?
glift.keyMappings._codeToNameKeyDown[a]:String.fromCharCode(a)||null},_keyBindingMap:{},registerKeyAction:function(a,b,c){var d=glift.keyMappings._keyBindingMap;if(!glift.keyMappings.nameToCode(b))throw Error("Unknown key name: "+b);d[a]||(d[a]={});a&&b&&c&&(d[a][b]=c)},unregisterInstance:function(a){glift.keyMappings._keyBindingMap[a]&&delete glift.keyMappings._keyBindingMap[a]},getFuncOrIcon:function(a,b){var c=glift.keyMappings._keyBindingMap;return a&&b&&c[a]&&c[a][b]?c[a][b]:null},_initializedListener:!1,
initKeybindingListener:function(){if(!glift.keyMappings._initializedListener){var a=document.body;a.addEventListener("keydown",glift.keyMappings._keyHandlerFunc);a.addEventListener("keypress",glift.keyMappings._keyHandlerFunc);glift.keyMappings._initializedListener=!0}},_keyHandlerFunc:function(a){var b=glift.keyMappings.codeToName(a.which);if("keydown"!==a.type||/[A-Z_]+/.test(b)){var c=glift.global.activeInstanceId,d=glift.keyMappings.getFuncOrIcon(c,b);if(d&&(c=glift.global.instanceRegistry[c])&&
(b=c.getCurrentWidget())){var e=glift.util.typeOf(d);if("function"===e)d(b),c.isFullscreen()&&(a.preventDefault?a.preventDefault():a.returnValue=!1);else if("string"===e){d=d.split(".");if("iconActions"!==d[0]&&"stoneActions"!==d[0])throw Error("Unexpected action namespace: "+d[0]);for(var e=b[d[0]],f=1;f<d.length;f++)e=e[d[f]];e(a,b);c.isFullscreen()&&(a.preventDefault?a.preventDefault():a.returnValue=!1)}}}}};glift.math={isEven:function(a){return 0==a%2?!0:!1},getRandomInt:function(a,b){return Math.floor(Math.random()*(b-a+1))+a},mostlyEqual:function(a,b,c){return Math.abs(a-b)<c}};glift.obj={flatMerge:function(a,b){var c={};if("object"!==glift.util.typeOf(a))return c;for(var d in a)c[d]=a[d];for(var e=1;2<=arguments.length&&e<arguments.length;e++){var f=arguments[e];if("object"===glift.util.typeOf(f))for(d in f)c[d]=f[d]}return c},isEmpty:function(a){for(var b in a)return!1;return!0}};glift.util.perfLog=function(a){if(void 0!==glift.global.performanceDebugLevel&&"NONE"!==glift.global.performanceDebugLevel){var b=glift.util.perfTime(),c=glift.global.perf.last;console.log("Since Major Record: "+(b-glift.global.perf.lastMajor+"ms. "+a));"FINE"===glift.global.performanceDebugLevel&&console.log(" Since Last Record: "+(b-c+"ms. "+a));glift.global.perf.last=b}};
glift.util.majorPerfLog=function(a){if(void 0!==glift.global.performanceDebugLevel&&"NONE"!==glift.global.performanceDebugLevel){var b=glift.util.perfTime();glift.util.perfLog(a);glift.global.perf.lastMajor=b}};glift.util.perfDone=function(){if(void 0!==glift.global.performanceDebugLevel&&"NONE"!==glift.global.performanceDebugLevel){var a=glift.util.perfTime(),b=glift.global.perf.first;console.log("---Performance Test Complete---");console.log("Since Beginning: "+(a-b)+"ms.")}};
glift.util.perfInit=function(){if(void 0!==glift.global.performanceDebugLevel&&"NONE"!==glift.global.performanceDebugLevel){var a=glift.util.perfTime();glift.global.perf={first:a,last:a,lastMajor:a}}};glift.util.perfTime=function(){return(new Date).getTime()};glift.platform={_isIOS:null,isIOS:function(){if(null!==glift.platform._isIOS)return glift.platform._isIOS;glift.platform._isIOS=/iPhone|iPad|iPod/i.test(navigator.userAgent);return glift.platform._isIOS},_isAndroid:null,isAndroid:function(){if(null!==glift.platform._isAndroid)return glift.platform._isAndroid;glift.platform._isAndroid=/Android/i.test(navigator.userAgent);return glift.platform._isAndroid},_isWinPhone:null,isWinPhone:function(){if(null!==glift.platform._isWinPhone)return glift.platform._isWinPhone;
glift.platform._isWinPhone=/Windows Phone/i.test(navigator.userAgent);return glift.platform._isWinPhone},isMobile:function(){return glift.platform.isAndroid()||glift.platform.isIOS()||glift.platform.isWinPhone()},_supportsSvg:null,supportsSvg:function(){if(null!==glift.platform._supportsSvg)return glift.platform._supportsSvg;glift.platform._supportsSvg=document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1");return glift.platform._supportsSvg}};glift.util.point=function(a,b){return new glift.Point(a,b)};glift.util.coordToString=function(a,b){return a+","+b};glift.util.pointFromString=function(a){try{var b=a.split(","),c=parseInt(b[0],10),d=parseInt(b[1],10);return glift.util.point(c,d)}catch(e){throw"Parsing Error! Couldn't parse a point from: "+a;}};
glift.util.pointArrFromSgfProp=function(a){if(2===a.length)return[glift.util.pointFromSgfCoord(a)];if(2<a.length){var b=a.split(":");if(2!==b.length)throw Error("Expected two points: TopLeft and BottomRight for point rectangle. Instead found: "+a);a=[];var c=glift.util.pointFromSgfCoord(b[0]),b=glift.util.pointFromSgfCoord(b[1]);if(b.x()<c.x()||b.y()<b.y())throw Error("Invalid point rectangle: tl: "+c.toString()+", br: "+b.toString());for(var b=b.translate(-c.x(),-c.y()),d=0;d<=b.y();d++)for(var e=
0;e<=b.x();e++){var f=c.x()+e,g=c.y()+d;a.push(glift.util.point(f,g))}return a}throw Error("Unknown pointformat for property data: "+a);};glift.util.pointFromSgfCoord=function(a){if(2!==a.length)throw"Unknown SGF Coord length: "+a.length+"for property "+a;return glift.util.point(a.charCodeAt(0)-97,a.charCodeAt(1)-97)};glift.Point=function(a,b){this.x_=a;this.y_=b};
glift.Point.prototype={x:function(){return this.x_},y:function(){return this.y_},equals:function(a){return this.x_===a.x()&&this.y_===a.y()},clone:function(){return glift.util.point(this.x(),this.y())},toSgfCoord:function(){return String.fromCharCode(this.x()+97)+String.fromCharCode(this.y()+97)},toString:function(){return glift.util.coordToString(this.x(),this.y())},translate:function(a,b){return glift.util.point(this.x()+a,this.y()+b)},rotate:function(a,b){var c=glift.enums.rotations;if(0>a||void 0===
b||b===c.NO_ROTATION)return this;var d=glift.util.point,e=(a-1)/2,f=d(this.x()-e,e-this.y());if(glift.util.outBounds(this.x(),a)||glift.util.outBounds(this.x(),a))throw Error("rotating a point outside the bounds: "+this.toString());var g=f;b===c.CLOCKWISE_90?g=d(f.y(),-f.x()):b===c.CLOCKWISE_180?g=d(-f.x(),-f.y()):b===c.CLOCKWISE_270&&(g=d(-f.y(),f.x()));return d(e+g.x(),-g.y()+e)},antirotate:function(a,b){var c=glift.enums.rotations;return b===c.CLOCKWISE_90?this.rotate(a,c.CLOCKWISE_270):b===c.CLOCKWISE_180?
this.rotate(a,c.CLOCKWISE_180):b===c.CLOCKWISE_270?this.rotate(a,c.CLOCKWISE_90):this.rotate(a,b)},log:function(){glift.util.logz(this.toString())}};glift.util.regions={getComponents:function(a){var b=glift.enums.boardRegions,c={};a===b.TOP_LEFT?(c[b.TOP]=1,c[b.LEFT]=1):a===b.TOP_RIGHT?(c[b.TOP]=1,c[b.RIGHT]=1):a===b.BOTTOM_LEFT?(c[b.BOTTOM]=1,c[b.LEFT]=1):a===b.BOTTOM_RIGHT?(c[b.BOTTOM]=1,c[b.RIGHT]=1):a==b.TOP?c[b.TOP]=1:a==b.BOTTOM?c[b.BOTTOM]=1:a==b.LEFT?c[b.LEFT]=1:a==b.RIGHT&&(c[b.RIGHT]=1);return c}};glift.dom={elem:function(a){var b=glift.util.typeOf(a);return"string"===b?(b=document.getElementById(a),null===b?null:new glift.dom.Element(b,a)):"object"===b&&a.nodeType&&1===a.nodeType?new glift.dom.Element(a):null},newDiv:function(a){var b=glift.dom.elem(document.createElement("div"));b.setAttr("id",a);return b},convertText:function(a,b,c){a=glift.dom.sanitize(a);b&&(a=glift.markdown.render(a));var d=glift.dom.newElem("div");d.setAttr("class",glift.dom.classes.commentBox);if(b)d.html(a);else for(a=
a.split("\n"),b=0;b<a.length;b++){var e=a[b],f={margin:0,padding:0,"min-height":"1em"};if(c)for(var g in c)f[g]=c[g];f=glift.dom.newElem("p").css(f);f.html(e);d.append(f)}return d},absBboxDiv:function(a,b){var c=this.newDiv(b),d={position:"absolute",margin:"0px",padding:"0px",top:a.top()+"px",left:a.left()+"px",width:a.width()+"px",height:a.height()+"px",MozBoxSizing:"border-box",boxSizing:"border-box"};c.css(d);return c},newElem:function(a){if(!a||"string"!==glift.util.typeOf(a))throw Error("Type must be a string. was: ["+
a+"]");return glift.dom.elem(document.createElement(a))}};glift.dom.Element=function(a,b){this.el=a;this.id=b||null};
glift.dom.Element.prototype={prepend:function(a){if(a.constructor===this.constructor)this.el.insertBefore(a.el,this.el.firstChild);else throw Error("Could not append unknown element: "+a);return this},append:function(a){if(a.constructor===this.constructor)this.el.appendChild(a.el);else throw Error("Could not append unknown element: "+a);return this},appendText:function(a){a&&(a=this.el.ownerDocument.createTextNode(a),this.el.appendChild(a));return this},setAttr:function(a,b){this.el.setAttribute(a,
b);"id"===a&&"string"===glift.util.typeOf(b)&&(this.id=b);return this},attr:function(a){return this.el.getAttribute(a)},setAttrObj:function(a){for(var b in a)this.el.setAttribute(b,a[b])},attrs:function(){for(var a={},b=0;b<this.el.attributes.length;b++){var c=this.el.attributes[b];a[c.nodeName]=c.value}return a},css:function(a){for(var b in a){var c=b.replace(/-(.)?/g,function(a,b){return b?b.toUpperCase():""});this.el.style[c]=a[b]}return this},addClass:function(a){this.el.className=this.el.className?
this.el.className+(" "+a):a;return this},removeClass:function(a){this.el.className=this.el.className.replace(new RegExp("(?:^|\\s)"+a+"(?!\\S)","g"),"")},height:function(){return this.el.clientHeight},width:function(){return this.el.clientWidth},on:function(a,b){b.bind(this);this.el.addEventListener(a,b)},html:function(a){if(void 0!==a)this.el.innerHTML=a;else return this.el.innerHTML},remove:function(){var a=this.el.parentNode;a&&a.removeChild(this.el)},empty:function(){for(var a=this.el;a.firstChild;)a.removeChild(a.firstChild)},
offset:function(){var a={top:0,left:0},b=this.el&&this.el.ownerDocument,c=b.documentElement,b=b.defaultView;"undefined"!==glift.util.typeOf(this.el.getBoundingClientRect)&&(a=this.el.getBoundingClientRect());return{top:a.top+b.pageYOffset-c.clientTop,left:a.left+b.pageXOffset-c.clientLeft}},boundingClientRect:function(){return this.el.getBoundingClientRect()}};glift.dom.clasess={};glift.dom.classes={commentBox:"glift-comment-box"};glift.dom._sanitizeWhitelist={br:!0,b:!0,strong:!0,i:!0,u:!0,em:!0,h1:!0,h2:!0,h3:!0};glift.dom._escapeMap={"&":"&",'"':""","'":"'","/":"/"};
glift.dom.sanitize=function(a){for(var b=[],c=[],d=glift.dom._sanitizeWhitelist,e=1,f=0,g=0,h=a.length;g<h;g++){var k=a.charAt(g);"<"===k?(e=2,f++,1<f&&c.push("<")):">"===k?(f--,0>f?(e=1,f=0,b.push(">")):0<f?c.push(">"):0===f&&(e=1,k=c.join(""),c=[],k in d?b.push("<"+k+">"):"/"===k.charAt(0)&&k.substring(1,k.length)in d?b.push("<"+k+">"):b.push("<"+k+">"))):2===e?c.push(k):(k in glift.dom._escapeMap&&(k=glift.dom._escapeMap[k]),b.push(k))}return b.join("")};glift.dom.ux={onlyInnerVertScroll:function(a,b){a.on("mousewheel",function(c){var d=a.el,e=c.deltaY,f=d.scrollTop,g=d.scrollHeight,h=b.height(),k=0<e,l=f+h;!k&&0>e+f?(d.scrollTop=0,c.stopPropagation(),c.preventDefault(),c.returnValue=!1):k>g-l&&(d.scrollTop=g-h,c.stopPropagation(),c.preventDefault(),c.returnValue=!1);return this})},setNotSelectable:function(a){glift.dom.elem(a).css({webkitTouchCallout:"none",webkitUserSelect:"none",MozUserSelect:"moz-none",msUserSelect:"none","user-select":"none",
webkitHighlight:"none",webkitTapHighlightColor:"rgba(0,0,0,0)",cursor:"default"})}};glift.ajax={get:function(a,b){var c=new XMLHttpRequest;c.onreadystatechange=function(){4===c.readyState&&(200===c.status||304===c.status?b(c.responseText):console.log("("+c.status+") Error retrieving "+a))};c.onerror=function(){throw Error(c.responseText);};c.open("GET",a,!0);c.send()}};glift.themes={registered:{},get:function(a){var b=glift.themes.registered;if(!a in b)throw Error("No theme available for theme with name: "+a);return(a=a in b?b[a]:null)?glift.themes.deepCopy({},a,glift.themes.baseTemplate):a},deepCopy:function(a,b,c){for(var d in c){var e=glift.util.typeOf(c[d]),f=c;void 0!==b[d]&&(f=b);switch(e){case "object":a[d]=glift.themes.deepCopy({},b[d]||{},c[d]);break;case "array":for(var e={},f=[],g=c[d].concat(b[d]||[]),h=0;h<g.length;h++){var k=g[h];k in e||(f.push(k),
e[k]=1)}a[d]=k;break;default:a[d]=f[d]}}return a},has:function(a){return a in glift.themes.registered},setGoBoardBackground:function(a,b){if(a)a.board.imagefill=b;else throw"Yikes! Not a theme: cannot set background image.";}};glift.themes.baseTemplate={board:{fill:"#f5be7e",stroke:"#000000","stroke-width":1},starPoints:{sizeFraction:.15,fill:"black"},lines:{stroke:"black","stroke-width":.5},boardCoordLabels:{fill:"black",stroke:"black",opacity:"0.6","font-family":"sans-serif","font-size":"0.6"},stones:{shadows:{stroke:"none",fill:"none"},marks:{"font-family":"sans-serif","font-size":"0.7"},EMPTY:{fill:"blue",opacity:0,marks:{fill:"black",stroke:"black",VARIATION_MARKER:{stroke:"#A22",fill:"#A22"},CORRECT_VARIATION:{stroke:"#22D",
fill:"#22D"}}},BLACK:{fill:"black",opacity:1,"stroke-width":1,stroke:"black",marks:{fill:"white",stroke:"white",STONE_MARKER:{fill:"#CCF",opacity:.6}}},BLACK_HOVER:{fill:"black",opacity:.5},WHITE:{stroke:"black",fill:"white",opacity:1,"stroke-width":1,marks:{fill:"black",stroke:"black",STONE_MARKER:{fill:"#33F",opacity:.6}}},WHITE_HOVER:{fill:"white",stroke:"black",opacity:.5}},icons:{vertMargin:5,horzMargin:5,DEFAULT:{fill:"#000",stroke:"black"},DEFAULT_HOVER:{fill:"#AAA",stroke:"#AAA"},tooltips:{padding:"5px",
background:"#555",color:"#EEE",webkitBorderRadius:"10px",MozBorderRadius:"10px","border-radius":"10px"},tooltipTimeout:1200},statusBar:{fullscreen:{"background-color":"#FFF"},gameInfo:{textDiv:{"background-color":"rgba(0,0,0,0.75)","border-radius":"25px"},text:{fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif',color:"#FFF"},textBody:{"margin-bottom":"0.5em"},textTitle:{"margin-bottom":"1em"}},icons:{vertMargin:4,horzMargin:5,DEFAULT:{fill:"#000",stroke:"#000",opacity:1},DEFAULT_HOVER:{fill:"#AAA",
stroke:"#AAA"},tooltips:{padding:"5px",background:"#555",color:"#EEE",webkitBorderRadius:"10px",MozBorderRadius:"10px",borderRadius:"10px"},tooltipTimeout:1200}},commentBox:{css:{background:"none",padding:"10px",margin:"0px"}},defs:{}};glift.themes.registered={};glift.themes.registered.COLORFUL={board:{fill:"#f5be7e"},commentBox:{css:{background:"#CCF",border:"1px solid"}},icons:{DEFAULT:{fill:"blue",stroke:"none"},DEFAULT_HOVER:{fill:"red",stroke:"none"}}};glift.themes.registered.DEFAULT={};glift.themes.registered.DEPTH={stones:{shadows:{stroke:"none",fill:"#777"},WHITE:{stroke:"white",fill:"white"},WHITE_HOVER:{fill:"white",stroke:"white",opacity:.5}}};glift.themes.registered.MOODY={board:{fill:"#777"},stones:{WHITE:{stroke:"white",fill:"white"},WHITE_HOVER:{fill:"white",stroke:"white",opacity:.5}},commentBox:{css:{background:"none",border:""}}};glift.themes.registered.TEXTBOOK={board:{fill:"#FFF"},commentBox:{css:{background:"#FFF"}}};glift.themes.registered.TRANSPARENT={board:{fill:"none"},commentBox:{css:{background:"none",border:""}}};$jscomp.scope.merge=function(a,b){for(var c=1,d,e;c<arguments.length;c++)for(e in d=arguments[c],d)Object.prototype.hasOwnProperty.call(d,e)&&(a[e]=d[e]);return a};$jscomp.scope.replace=function(a,b){var c=a.source,d=b||"";return function f(a,b){if(!a)return new RegExp(c,d);b=b.source||b;b=b.replace(/(^|[^\[])\^/g,"$1");c=c.replace(a,b);return f}};
$jscomp.scope.unescape=function(a){return a.replace(/&([#\w]+);/g,function(a,c){c=c.toLowerCase();return"colon"===c?":":"#"===c.charAt(0)?"x"===c.charAt(1)?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""})};$jscomp.scope.escape=function(a,b){return a};
$jscomp.scope.marked=function(a,b,c){var d,e;if(c||"function"===typeof b){c||(d=b,e=void 0);e=(0,$jscomp.scope.merge)({},glift.marked.defaults,b||{});var f=e.highlight,g,h;b=0;try{g=glift.marked.Lexer.lex(a,e)}catch(l){return d(l)}h=g.length;var k=function(a){if(a)return e.highlight=f,d(a);var b;try{b=glift.marked.Parser.parse(g,e)}catch(c){a=c}e.highlight=f;return a?d(a):d(null,b)};if(!f||3>f.length)return k();delete e.highlight;if(!h)return k();for(;b<g.length;b++)(function(a){return"code"!==a.type?
--h||k():f(a.text,a.lang,function(b,c){if(b)return k(b);if(null==c||c===a.text)return--h||k();a.text=c;a.escaped=!0;--h||k()})})(g[b])}else try{return b&&(e=(0,$jscomp.scope.merge)({},glift.marked.defaults,b)),glift.marked.Parser.parse(glift.marked.Lexer.lex(a,e),e)}catch(l){l.message+="\nPlease report this to https://github.com/kashomon/glift.";if((b||glift.marked.defaults).silent)return"<p>An error occured:</p><pre>"+(0,$jscomp.scope.escape)(l.message+"",!0)+"</pre>";throw l;}};glift.marked=$jscomp.scope.marked;
glift.marked.parse=$jscomp.scope.marked;$jscomp.scope.noop=function(){};$jscomp.scope.noop.exec=$jscomp.scope.noop;
$jscomp.scope.Blocker=function(){this.newline=/^\n+/;this.code=/^( {4}[^\n]+\n*)+/;this.fences=$jscomp.scope.noop;this.hr=/^( *[-*_]){3,} *(?:\n+|$)/;this.heading=/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/;this.nptable=$jscomp.scope.noop;this.lheading=/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/;this.blockquote=/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/;this.list=/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/;this.html=/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/;
this.def=/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/;this.table=$jscomp.scope.noop;this.paragraph=/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/;this.text=/^[^\n]+/;this.bullet=/(?:[*+-]|\d+\.)/;this.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;this.item=(0,$jscomp.scope.replace)(this.item,"gm")(/bull/g,this.bullet)();this.list=(0,$jscomp.scope.replace)(this.list)(/bull/g,this.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+this.def.source+
")")();this.blockquote=(0,$jscomp.scope.replace)(this.blockquote)("def",this.def)();this._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";this.html=(0,$jscomp.scope.replace)(this.html)("comment",/\x3c!--[\s\S]*?--\x3e/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,this._tag)();this.paragraph=(0,$jscomp.scope.replace)(this.paragraph)("hr",
this.hr)("heading",this.heading)("lheading",this.lheading)("blockquote",this.blockquote)("tag","<"+this._tag)("def",this.def)();this.normal=(0,$jscomp.scope.merge)({},this);this.gfm=(0,$jscomp.scope.merge)({},this.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});this.gfm.paragraph=(0,$jscomp.scope.replace)(this.paragraph)("(?!","(?!"+this.gfm.fences.source.replace("\\1","\\2")+"|"+this.list.source.replace("\\1","\\3")+"|")();this.tables=(0,$jscomp.scope.merge)({},
this.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/})};$jscomp.scope.block=new $jscomp.scope.Blocker;glift.marked.Lexer=function(a){this.tokens=[];this.tokens.links={};this.options=a||glift.marked.defaults;this.rules=$jscomp.scope.block.normal;this.options.gfm&&(this.rules=this.options.tables?$jscomp.scope.block.tables:$jscomp.scope.block.gfm)};glift.marked.Lexer.rules=$jscomp.scope.block;
glift.marked.Lexer.lex=function(a,b){return(new glift.marked.Lexer(b)).lex(a)};glift.marked.lexer=glift.marked.Lexer.lex;glift.marked.Lexer.prototype.lex=function(a){a=a.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(a,!0)};
glift.marked.Lexer.prototype.token=function(a,b,c){a=a.replace(/^ +$/gm,"");for(var d,e,f,g,h,k,l;a;){if(f=this.rules.newline.exec(a))a=a.substring(f[0].length),1<f[0].length&&this.tokens.push({type:"space"});if(f=this.rules.code.exec(a))a=a.substring(f[0].length),f=f[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?f:f.replace(/\n+$/,"")});else if(f=this.rules.fences.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"code",lang:f[2],text:f[3]});else if(f=
this.rules.heading.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"heading",depth:f[1].length,text:f[2]});else if(b&&(f=this.rules.nptable.exec(a))){a=a.substring(f[0].length);h={type:"table",header:f[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:f[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:f[3].replace(/\n$/,"").split("\n")};for(k=0;k<h.align.length;k++)/^ *-+: *$/.test(h.align[k])?h.align[k]="right":/^ *:-+: *$/.test(h.align[k])?h.align[k]="center":/^ *:-+ *$/.test(h.align[k])?
h.align[k]="left":h.align[k]=null;for(k=0;k<h.cells.length;k++)h.cells[k]=h.cells[k].split(/ *\| */);this.tokens.push(h)}else if(f=this.rules.lheading.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"heading",depth:"="===f[2]?1:2,text:f[1]});else if(f=this.rules.hr.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"hr"});else if(f=this.rules.blockquote.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"blockquote_start"}),f=f[0].replace(/^ *> ?/gm,""),this.token(f,b,!0),
this.tokens.push({type:"blockquote_end"});else if(f=this.rules.list.exec(a)){a=a.substring(f[0].length);g=f[2];this.tokens.push({type:"list_start",ordered:1<g.length});f=f[0].match(this.rules.item);d=!1;l=f.length;for(k=0;k<l;k++)h=f[k],e=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(e-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+e+"}","gm"),"")),this.options.smartLists&&k!==l-1&&(e=$jscomp.scope.block.bullet.exec(f[k+1])[0],g===e||1<
g.length&&1<e.length||(a=f.slice(k+1).join("\n")+a,k=l-1)),e=d||/\n\n(?!\s*$)/.test(h),k!==l-1&&(d="\n"===h.charAt(h.length-1),e||(e=d)),this.tokens.push({type:e?"loose_item_start":"list_item_start"}),this.token(h,!1,c),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(f=this.rules.html.exec(a))a=a.substring(f[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===f[1]||"script"===f[1]||"style"===f[1],text:f[0]});else if(!c&&b&&(f=
this.rules.def.exec(a)))a=a.substring(f[0].length),this.tokens.links[f[1].toLowerCase()]={href:f[2],title:f[3]};else if(b&&(f=this.rules.table.exec(a))){a=a.substring(f[0].length);h={type:"table",header:f[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:f[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:f[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(k=0;k<h.align.length;k++)/^ *-+: *$/.test(h.align[k])?h.align[k]="right":/^ *:-+: *$/.test(h.align[k])?h.align[k]="center":/^ *:-+ *$/.test(h.align[k])?
h.align[k]="left":h.align[k]=null;for(k=0;k<h.cells.length;k++)h.cells[k]=h.cells[k].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(h)}else if(b&&(f=this.rules.paragraph.exec(a)))a=a.substring(f[0].length),this.tokens.push({type:"paragraph",text:"\n"===f[1].charAt(f[1].length-1)?f[1].slice(0,-1):f[1]});else if(f=this.rules.text.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"text",text:f[0]});else if(a)throw Error("Infinite loop on byte: "+a.charCodeAt(0));}return this.tokens};
$jscomp.scope.inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:$jscomp.scope.noop,tag:/^\x3c!--[\s\S]*?--\x3e|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:$jscomp.scope.noop,
text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};$jscomp.scope.inline._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;$jscomp.scope.inline._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;$jscomp.scope.inline.link=(0,$jscomp.scope.replace)($jscomp.scope.inline.link)("inside",$jscomp.scope.inline._inside)("href",$jscomp.scope.inline._href)();$jscomp.scope.inline.reflink=(0,$jscomp.scope.replace)($jscomp.scope.inline.reflink)("inside",$jscomp.scope.inline._inside)();
$jscomp.scope.inline.normal=(0,$jscomp.scope.merge)({},$jscomp.scope.inline);$jscomp.scope.inline.pedantic=(0,$jscomp.scope.merge)({},$jscomp.scope.inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});
$jscomp.scope.inline.gfm=(0,$jscomp.scope.merge)({},$jscomp.scope.inline.normal,{escape:(0,$jscomp.scope.replace)($jscomp.scope.inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:(0,$jscomp.scope.replace)($jscomp.scope.inline.text)("]|","~]|")("|","|https?://|")()});
$jscomp.scope.inline.breaks=(0,$jscomp.scope.merge)({},$jscomp.scope.inline.gfm,{br:(0,$jscomp.scope.replace)($jscomp.scope.inline.br)("{2,}","*")(),text:(0,$jscomp.scope.replace)($jscomp.scope.inline.gfm.text)("{2,}","*")()});
glift.marked.InlineLexer=function(a,b){this.options=b||glift.marked.defaults;this.links=a;this.rules=$jscomp.scope.inline.normal;this.renderer=this.options.renderer||new glift.marked.Renderer;this.renderer.options=this.options;if(!this.links)throw Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?$jscomp.scope.inline.breaks:$jscomp.scope.inline.gfm:this.options.pedantic&&(this.rules=$jscomp.scope.inline.pedantic)};glift.marked.InlineLexer.rules=$jscomp.scope.inline;
glift.marked.InlineLexer.output=function(a,b,c){return(new glift.marked.InlineLexer(b,c)).output(a)};glift.marked.inlineLexer=glift.marked.InlineLexer.output;
glift.marked.InlineLexer.prototype.output=function(a){for(var b="",c,d;a;)if(d=this.rules.escape.exec(a))a=a.substring(d[0].length),b+=d[1];else if(d=this.rules.autolink.exec(a))a=a.substring(d[0].length),"@"===d[2]?(c=":"===d[1].charAt(6)?this.mangle(d[1].substring(7)):this.mangle(d[1]),d=this.mangle("mailto:")+c):d=c=(0,$jscomp.scope.escape)(d[1]),b+=this.renderer.link(d,null,c);else if(!this.inLink&&(d=this.rules.url.exec(a)))a=a.substring(d[0].length),d=c=(0,$jscomp.scope.escape)(d[1]),b+=this.renderer.link(d,
null,c);else if(d=this.rules.tag.exec(a))!this.inLink&&/^<a /i.test(d[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(d[0])&&(this.inLink=!1),a=a.substring(d[0].length),b+=this.options.sanitize?(0,$jscomp.scope.escape)(d[0]):d[0];else if(d=this.rules.link.exec(a))a=a.substring(d[0].length),this.inLink=!0,b+=this.outputLink(d,{href:d[2],title:d[3]}),this.inLink=!1;else if((d=this.rules.reflink.exec(a))||(d=this.rules.nolink.exec(a)))a=a.substring(d[0].length),c=(d[2]||d[1]).replace(/\s+/g," "),(c=this.links[c.toLowerCase()])&&
c.href?(this.inLink=!0,b+=this.outputLink(d,c),this.inLink=!1):(b+=d[0].charAt(0),a=d[0].substring(1)+a);else if(d=this.rules.strong.exec(a))a=a.substring(d[0].length),b+=this.renderer.strong(this.output(d[2]||d[1]));else if(d=this.rules.em.exec(a))a=a.substring(d[0].length),b+=this.renderer.em(this.output(d[2]||d[1]));else if(d=this.rules.code.exec(a))a=a.substring(d[0].length),b+=this.renderer.codespan((0,$jscomp.scope.escape)(d[2],!0));else if(d=this.rules.br.exec(a))a=a.substring(d[0].length),
b+=this.renderer.br();else if(d=this.rules.del.exec(a))a=a.substring(d[0].length),b+=this.renderer.del(this.output(d[1]));else if(d=this.rules.text.exec(a))a=a.substring(d[0].length),b+=(0,$jscomp.scope.escape)(this.smartypants(d[0]));else if(a)throw Error("Infinite loop on byte: "+a.charCodeAt(0));return b};
glift.marked.InlineLexer.prototype.outputLink=function(a,b){var c=(0,$jscomp.scope.escape)(b.href),d=b.title?(0,$jscomp.scope.escape)(b.title):null;return"!"!==a[0].charAt(0)?this.renderer.link(c,d,this.output(a[1])):this.renderer.image(c,d,(0,$jscomp.scope.escape)(a[1]))};
glift.marked.InlineLexer.prototype.smartypants=function(a){return this.options.smartypants?a.replace(/--/g,"\u2014").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201c").replace(/"/g,"\u201d").replace(/\.{3}/g,"\u2026"):a};glift.marked.InlineLexer.prototype.mangle=function(a){for(var b="",c=a.length,d=0,e;d<c;d++)e=a.charCodeAt(d),.5<Math.random()&&(e="x"+e.toString(16)),b+="&#"+e+";";return b};
glift.marked.Renderer=function(a){this.options=a||{}};glift.marked.Renderer.prototype.code=function(a,b,c){if(this.options.highlight){var d=this.options.highlight(a,b);null!=d&&d!==a&&(c=!0,a=d)}return b?'<pre><code class="'+this.options.langPrefix+(0,$jscomp.scope.escape)(b,!0)+'">'+(c?a:(0,$jscomp.scope.escape)(a,!0))+"\n</code></pre>\n":"<pre><code>"+(c?a:(0,$jscomp.scope.escape)(a,!0))+"\n</code></pre>"};glift.marked.Renderer.prototype.blockquote=function(a){return"<blockquote>\n"+a+"</blockquote>\n"};
glift.marked.Renderer.prototype.html=function(a){return a};glift.marked.Renderer.prototype.heading=function(a,b,c){return"<h"+b+' id="'+this.options.headerPrefix+c.toLowerCase().replace(/[^\w]+/g,"-")+'">'+a+"</h"+b+">\n"};glift.marked.Renderer.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"};glift.marked.Renderer.prototype.list=function(a,b){var c=b?"ol":"ul";return"<"+c+">\n"+a+"</"+c+">\n"};glift.marked.Renderer.prototype.listitem=function(a){return"<li>"+a+"</li>\n"};
glift.marked.Renderer.prototype.paragraph=function(a){return"<p>"+a+"</p>\n"};glift.marked.Renderer.prototype.table=function(a,b){return"<table>\n<thead>\n"+a+"</thead>\n<tbody>\n"+b+"</tbody>\n</table>\n"};glift.marked.Renderer.prototype.tablerow=function(a){return"<tr>\n"+a+"</tr>\n"};glift.marked.Renderer.prototype.tablecell=function(a,b){var c=b.header?"th":"td";return(b.align?"<"+c+' style="text-align:'+b.align+'">':"<"+c+">")+a+"</"+c+">\n"};
glift.marked.Renderer.prototype.strong=function(a){return"<strong>"+a+"</strong>"};glift.marked.Renderer.prototype.em=function(a){return"<em>"+a+"</em>"};glift.marked.Renderer.prototype.codespan=function(a){return"<code>"+a+"</code>"};glift.marked.Renderer.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"};glift.marked.Renderer.prototype.del=function(a){return"<del>"+a+"</del>"};
glift.marked.Renderer.prototype.link=function(a,b,c){if(this.options.sanitize){try{var d=decodeURIComponent((0,$jscomp.scope.unescape)(a)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(0===d.indexOf("javascript:")||0===d.indexOf("vbscript:"))return""}a='<a href="'+a+'"';b&&(a+=' title="'+b+'"');return a+(">"+c+"</a>")};glift.marked.Renderer.prototype.image=function(a,b,c){a='<img src="'+a+'" alt="'+c+'"';b&&(a+=' title="'+b+'"');return a+=this.options.xhtml?"/>":">"};
glift.marked.Parser=function(a){this.tokens=[];this.token=null;this.options=a||glift.marked.defaults;this.options.renderer=this.options.renderer||new glift.marked.Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options};glift.marked.Parser.parse=function(a,b){return(new glift.marked.Parser(b)).parse(a)};glift.marked.parse=glift.marked.Parser.parse;
glift.marked.Parser.prototype.parse=function(a){this.inline=new glift.marked.InlineLexer(a.links,this.options);this.tokens=a.reverse();for(a="";this.next();)a+=this.tok();return a};glift.marked.Parser.prototype.next=function(){return this.token=this.tokens.pop()};glift.marked.Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};glift.marked.Parser.prototype.parseText=function(){for(var a=this.token.text;"text"===this.peek().type;)a+="\n"+this.next().text;return this.inline.output(a)};
glift.marked.Parser.prototype.tok=function(){switch(this.token.type){case "space":return"";case "hr":return this.renderer.hr();case "heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case "code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case "table":var a="",b="",c,d,e,f;e="";for(c=0;c<this.token.header.length;c++)e+=this.renderer.tablecell(this.inline.output(this.token.header[c]),{header:!0,align:this.token.align[c]});
a+=this.renderer.tablerow(e);for(c=0;c<this.token.cells.length;c++){d=this.token.cells[c];e="";for(f=0;f<d.length;f++)e+=this.renderer.tablecell(this.inline.output(d[f]),{header:!1,align:this.token.align[f]});b+=this.renderer.tablerow(e)}return this.renderer.table(a,b);case "blockquote_start":for(b="";"blockquote_end"!==this.next().type;)b+=this.tok();return this.renderer.blockquote(b);case "list_start":b="";for(a=this.token.ordered;"list_end"!==this.next().type;)b+=this.tok();return this.renderer.list(b,
a);case "list_item_start":for(b="";"list_item_end"!==this.next().type;)b+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(b);case "loose_item_start":for(b="";"list_item_end"!==this.next().type;)b+=this.tok();return this.renderer.listitem(b);case "html":return b=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text),this.renderer.html(b);case "paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case "text":return this.renderer.paragraph(this.parseText())}};
glift.marked.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new glift.marked.Renderer,xhtml:!1};glift.marked.setOptions=function(a){(0,$jscomp.scope.merge)(glift.marked.defaults,a);return glift.marked.parse};glift.marked.options=glift.marked.setOptions;glift.markdown={renderAst:function(a){a=glift.marked.lexer(a);return new glift.markdown.Ast(a)},render:function(a){return glift.marked(a)}};glift.markdown.Ast=function(a){this.tree=a};glift.markdown.Ast.prototype={headers:function(){for(var a=[],b=0;b<this.tree.length;b++){var c=this.tree[b];"heading"===c.type&&a.push(c)}return a}};glift.displays={create:function(a,b,c,d,e,f,g){glift.util.majorPerfLog("Before environment creation");a=glift.displays.environment.get(a,b,d,e,g);glift.util.majorPerfLog("After environment creation");return glift.displays.board.create(a,c,f)},bboxFromDiv:function(a){a=glift.dom.elem(a);return glift.orientation.bbox.fromSides(glift.util.point(0,0),a.width(),a.height())}};glift.displays.boardPoints=function(a,b,c){for(var d=a.spacing,e=d/2,f=a.bbox,g=a.leftExt*d,h=a.rightExt*d,k=f.left()+g,l=a.topExt*d,m=a.botExt*d,f=f.top()+l,n=a.pointTopLeft.x(),p=a.pointTopLeft.y(),q={},r=[],u=0;u<=a.yPoints;u++)for(var v=0;v<=a.xPoints;v++){var t=k+v*d,x=f+u*d,w=glift.util.point(n+v,p+u),t=glift.util.point(t,x);if(c){if(0!==u&&u!==a.yPoints||0!==v&&v!==a.xPoints)0===u||u===a.yPoints?(0===u?t=t.translate(0,-1*l):u===a.yPoints&&(t=t.translate(0,m)),r.push({label:"ABCDEFGHJKLMNOPQRSTUVWXYZ".charAt(w.x()-
1),coordPt:t})):0===v||v===a.xPoints?(0===v?t=t.translate(-1*g,0):v===a.xPoints&&(t=t.translate(h,0)),r.push({label:Math.abs(w.y()-b)+1,coordPt:t})):(w=w.translate(-1,-1),q[w.toString()]={intPt:w,coordPt:t,bbox:glift.orientation.bbox.fromPts(glift.util.point(t.x()-e,t.y()-e),glift.util.point(t.x()+e,t.y()+e))})}else q[w.toString()]={intPt:w,coordPt:t,bbox:glift.orientation.bbox.fromPts(glift.util.point(t.x()-e,t.y()-e),glift.util.point(t.x()+e,t.y()+e))}}return new glift.displays.BoardPoints(q,d,
b,r)};glift.displays.BoardPoints=function(a,b,c,d){this.points=a;this.spacing=b;this.radius=b/2;this.numIntersections=c;this.edgeCoordLabels=d;this.dataCache=void 0};
glift.displays.BoardPoints.prototype={getCoord:function(a){return this.points[a.toString()]},forEach:function(a){for(var b in this.points)a(this.points[b])},data:function(){if(void 0!==this.dataCache)return this.dataCache;var a=[];this.forEach(function(b){a.push(b)});return this.dataCache=a},hasCoord:function(a){return void 0!==this.points[a.toString()]},starPoints:function(){for(var a=glift.util.point,b={9:[[2,6],[4]],13:[[3,9],[6]],19:[[3,9,15]]}[this.numIntersections]||[],c=[],d=0;d<b.length;d++)for(var e=
b[d],f=0;f<e.length;f++)for(var g=0;g<e.length;g++){var h=a(e[f],e[g]);this.hasCoord(h)&&c.push(h)}return c}};glift.displays.cropbox={EXT:.5,DEFAULT_EXTENSION:0,OVERFLOW:1.5,getFromRegion:function(a,b,c){a=glift.orientation.cropbox.get(a,b);b=(c=c||!1)?b+2:b;var d=a.bbox.top(),e=a.bbox.bottom(),f=a.bbox.left();a=a.bbox.right();c&&(e+=2,a+=2);a=new glift.orientation.Cropbox(glift.orientation.bbox.fromPts(glift.util.point(f,d),glift.util.point(a,e)),b);return new glift.displays.DisplayCropBox(a)}};glift.displays.DisplayCropBox=function(a){this.cbox_=a};
glift.displays.DisplayCropBox.prototype={cbox:function(){return this.cbox_},bbox:function(){return this.cbox_.bbox},maxBoardSize:function(){return this.cbox_.size},topExt:function(){return this.cbox_.hasRaggedTop()?glift.displays.cropbox.EXT:0},botExt:function(){return this.cbox_.hasRaggedBottom()?glift.displays.cropbox.EXT:0},leftExt:function(){return this.cbox_.hasRaggedLeft()?glift.displays.cropbox.EXT:0},rightExt:function(){return this.cbox_.hasRaggedRight()?glift.displays.cropbox.EXT:0},xPoints:function(){return this.cbox().bbox.width()},
yPoints:function(){return this.cbox().bbox.height()},widthMod:function(){var a=glift.displays.cropbox.OVERFLOW;return this.cbox().bbox.width()+this.leftExt()+ +this.rightExt()+a},heightMod:function(){var a=glift.displays.cropbox.OVERFLOW;return this.cbox().bbox.height()+this.topExt()+ +this.botExt()+a}};glift.displays.environment={get:function(a,b,c,d,e){if(!a)throw Error("No DivId Specified!");a&&!b&&(b=glift.displays.bboxFromDiv(a));if(!b)throw Error("No Bounding Box defined for display environment!");return new glift.displays.GuiEnvironment(a,b,c,d,e)}};
glift.displays.GuiEnvironment=function(a,b,c,d,e){this.divId=a;this.bbox=b;this.divHeight=b.height();this.divWidth=b.width();this.boardRegion=c;this.intersections=d;this.drawBoardCoords=e;this.cropbox=glift.displays.cropbox.getFromRegion(this.boardRegion,this.intersections,this.drawBoardCoords);this.boardPoints=this.goBoardLineBox=this.goBoardBox=this.divBox=null};
glift.displays.GuiEnvironment.prototype={init:function(){var a=this.divHeight,b=this.divWidth,c=this.cropbox,a=glift.orientation.bbox.fromPts(glift.util.point(0,0),glift.util.point(b,a)),b=glift.displays.getResizedBox(a,c),c=glift.displays.getLineBox(b,c),d=glift.displays.boardPoints(c,this.intersections,this.drawBoardCoords);this.divBox=a;this.goBoardBox=b;this.goBoardLineBox=c;this.boardPoints=d;return this}};glift.displays.ids={generator:function(a){return new glift.displays.ids.Generator(a)},element:function(a,b,c){a=a+"_"+b;return void 0!==c?void 0!==c.x?a+"_"+c.x()+"_"+c.y():a+"_"+c.toString():a}};
glift.displays.ids.Generator=function(a){this.divId=a;this._eid=glift.displays.ids.element;this._enum=glift.enums.svgElements;this._svg=this._eid(this.divId,this._enum.SVG);this._board=this._eid(this.divId,this._enum.BOARD);this._boardCoordLabelGroup=this._eid(this.divId,this._enum.BOARD_COORD_LABELS);this._stoneGroup=this._eid(this.divId,this._enum.STONE_CONTAINER);this._stoneShadowGroup=this._eid(this.divId,this._enum.STONE_SHADOW_CONTAINER);this._starpointGroup=this._eid(this.divId,this._enum.STARPOINT_CONTAINER);
this._buttonGroup=this._eid(this.divId,this._enum.BUTTON_CONTAINER);this._boardButton=this._eid(this.divId,this._enum.FULL_BOARD_BUTTON);this._lineGroup=this._eid(this.divId,this._enum.BOARD_LINE_CONTAINER);this._markGroup=this._eid(this.divId,this._enum.MARK_CONTAINER);this._iconGroup=this._eid(this.divId,this._enum.ICON_CONTAINER);this._intersectionsGroup=this._eid(this.divId,this._enum.BOARD);this._eid(this.divId,this._enum.INTERSECTIONS_CONTAINER);this._tempMarkGroup=this._eid(this.divId,this._enum.TEMP_MARK_GROUP)};
glift.displays.ids.Generator.prototype={svg:function(){return this._svg},board:function(){return this._board},boardCoordLabelGroup:function(){return this._boardCoordLabelGroup},intersections:function(){return this._intersectionsGroup},stoneGroup:function(){return this._stoneGroup},stone:function(a){return this._eid(this.divId,this._enum.STONE,a)},stoneShadowGroup:function(){return this._stoneShadowGroup},stoneShadow:function(a){return this._eid(this.divId,this._enum.STONE_SHADOW,a)},starpointGroup:function(){return this._starpointGroup},
starpoint:function(a){return this._eid(this.divId,this._enum.STARPOINT,a)},buttonGroup:function(){return this._buttonGroup},button:function(a){return this._eid(this.divId,this._enum.BUTTON,a)},fullBoardButton:function(){return this._boardButton},lineGroup:function(){return this._lineGroup},line:function(a){return this._eid(this.divId,this._enum.BOARD_LINE,a)},markGroup:function(){return this._markGroup},mark:function(a){return this._eid(this.divId,this._enum.MARK,a)},tempMarkGroup:function(){return this._tempMarkGroup},
guideLine:function(){return this._eid(this.divId,this._enum.GUIDE_LINE)},iconGroup:function(){return this._iconGroup},icon:function(a){return this._eid(this.divId,this._enum.ICON,a)},tempIconGroup:function(a){return this._eid(this.divId,this._enum.TEMP_ICON_CONTAINER,a)},tempIcon:function(a){return this._eid(this.divId,this._enum.TEMP_ICON,a)},tempIconText:function(a){return this._eid(this.divId,this._enum.TEMP_TEXT,a)}};glift.displays.getLineBox=function(a,b){var c=glift.displays.cropbox.OVERFLOW/2,d=a.width()/b.widthMod(),e=a.height()/b.heightMod(),f=e*c,g=d*c,e=e*(b.heightMod()-c),c=d*(b.widthMod()-c),h=a.topLeft().x(),k=a.topLeft().y(),f=glift.orientation.bbox.fromPts(glift.util.point(g+h,f+k),glift.util.point(c+h,e+k));return new glift.displays.LineBox(f,d,b)};
glift.displays.LineBox=function(a,b,c){this.bbox=a;this.spacing=b;this.topExt=c.topExt();this.botExt=c.botExt();this.leftExt=c.leftExt();this.rightExt=c.rightExt();this.pointTopLeft=c.cbox().bbox.topLeft();this.xPoints=c.xPoints();this.yPoints=c.yPoints()};glift.displays.getResizedBox=function(a,b,c){var d=glift.enums.boardAlignments;c=c||d.CENTER;var e=glift.util,f=glift.displays.getCropDimensions(a.width(),a.height(),b),g=f.width,h=f.height,k=a.width()-g,l=a.height()-h,m=c===d.RIGHT?k:k/2,n=c===d.TOP?0:l/2,p=a.topLeft().x()+m,q=a.topLeft().y()+n;a=glift.orientation.bbox.fromSides(e.point(p,q),g,h);glift.global.debugMode&&(a._debugInfo=function(){return{newDims:f,newWidth:g,newHeight:h,xDiff:k,yDiff:l,xDelta:m,yDelta:n,newLeft:p,newTop:q}});return a};
glift.displays.getCropDimensions=function(a,b,c){var d=b/a;c=c.heightMod()/c.widthMod();var e=b,f=a;d>c?e=a*c:d<c&&(f=b/c);return{height:e,width:f}};glift.displays.board={};glift.displays.board.create=function(a,b,c){return(new glift.displays.board.Display(a,b,c)).draw()};glift.displays.board.Display=function(a,b,c){this.environment_=a;this.theme_=b;this.rotation_=c||glift.enums.rotations.NO_ROTATION;this.intersections_=this.svg_=null;this.flattened_=glift.flattener.emptyFlattened(this.numIntersections())};
glift.displays.board.Display.prototype={boardPoints:function(){return this.environment_.boardPoints},boardRegion:function(){return this.environment_.boardRegion},divId:function(){return this.environment_.divId},numIntersections:function(){return this.environment_.intersections},intersections:function(){return this.intersections_},rotation:function(){return this.rotation_},drawBoardCoords:function(){return this.environment_.drawBoardCoords},width:function(){return this.environment_.goBoardBox.width()},
height:function(){return this.environment_.goBoardBox.height()},init:function(){this.svg_||(this.destroy(),this.svg_=glift.displays.svg.svg({height:"100%",width:"100%",position:"float",top:0,id:this.divId()+"_svgboard"}));this.environment_.init();return this},draw:function(){this.init();var a=glift.displays.board,b=this.environment_,c=b.boardPoints,d=this.theme_,e=this.svg_,f=this.divId(),g=glift.displays.svg,h=glift.displays.ids.generator(f);a.boardBase(e,h,b.goBoardBox,d);a.initBlurFilter(f,e);
b=g.group().setId(h.intersections());e.append(b);a.boardLabels(b,h,c,d);a.lines(b,h,c,d);a.starpoints(b,h,c,d);a.shadows(b,h,c,d);a.stones(b,h,c,d);a.markContainer(b,h);a.buttons(b,h,c);this.intersections_=new glift.displays.board.Intersections(f,b,c,d,this.rotation());glift.util.majorPerfLog("After display object creation");this.flush();glift.util.majorPerfLog("After flushing to display");return this},updateBoard:function(a){this.intersections().clearMarks();for(var b=this.flattened_.board().diff(a.board()),
c=glift.enums.marks,d=glift.flattener.symbolStoneToState,e=glift.flattener.symbolMarkToMark,f=0;f<b.length;f++){var g=b[f];if(g.newValue.stone()!==g.prevValue.stone()){var h=g.newValue.stone();this.intersections().setStoneColor(g.boardPt,d[h])}if(g.newValue.mark()!==g.prevValue.mark()&&0!==g.newValue.mark()){var h=g.newValue.mark(),h=e[h],k=void 0;if(h===c.LABEL||h===c.VARIATION_MARKER||h===c.CORRECT_VARIATION)k=g.newValue.textLabel();this.intersections().addMarkPt(g.boardPt,h,k)}}this.flattened_=
a;return this},flush:function(){this.svg_.attachToParent(this.divId());return this},destroy:function(){glift.dom.elem(this.divId()).empty();this.svg_=null;this.flattened_=glift.flattener.emptyFlattened(this.numIntersections());this.intersections_=null;return this}};glift.displays.board.boardLabels=function(a,b,c,d){if(null===c)throw Error("boardPoints null: Gui Environment obj not initialized");var e=glift.displays.svg;b=e.group().setId(b.boardCoordLabelGroup());a.append(b);a=c.edgeCoordLabels;for(var f=0,g=a.length;f<g;f++){var h=a[f];b.append(e.text().setText(h.label).setAttr("fill",d.boardCoordLabels.fill).setAttr("stroke",d.boardCoordLabels.stroke).setAttr("opacity",d.boardCoordLabels.opacity).setAttr("text-anchor","middle").setAttr("dy",".33em").setAttr("x",
h.coordPt.x()).setAttr("y",h.coordPt.y()).setAttr("font-family",d.boardCoordLabels["font-family"]).setAttr("font-size",c.spacing*d.boardCoordLabels["font-size"]))}};glift.displays.board.buttons=function(a,b,c){var d=glift.displays.svg,e=d.group().setId(b.buttonGroup());a.append(e);a=c.data();var f=a[0],g=a[a.length-1];a={tl:f,br:g,spacing:c.spacing};e.append(d.rect().setData(a).setAttr("x",f.coordPt.x()-c.radius).setAttr("y",f.coordPt.y()-c.radius).setAttr("width",g.coordPt.x()-f.coordPt.x()+c.spacing).setAttr("height",g.coordPt.y()-f.coordPt.y()+c.spacing).setAttr("opacity",0).setAttr("fill","red").setAttr("stroke","red").setAttr("stone_color","EMPTY").setId(b.fullBoardButton()))};glift.displays.board.Intersections=function(a,b,c,d,e){this.divId=a;this.svg=b;this.theme=d;this.rotation=e;this.boardPoints=c;this.idGen=glift.displays.ids.generator(this.divId);this.lastHoverPoint=null;this.events={};this.markPts=[]};
glift.displays.board.Intersections.prototype={setStoneColor:function(a,b){a=a.rotate(this.boardPoints.numIntersections,this.rotation);if(void 0===this.theme.stones[b])throw"Unknown color key ["+b+"]";var c=this.svg.child(this.idGen.stoneGroup()).child(this.idGen.stone(a));if(void 0!==c){var d=this.theme.stones[b];c.setAttr("fill",d.fill).setAttr("stroke",d.stroke||1).setAttr("stone_color",b).setAttr("opacity",d.opacity);c=this.svg.child(this.idGen.stoneShadowGroup());void 0!==c&&(c=c.child(this.idGen.stoneShadow(a)),
1===d.opacity?c.setAttr("opacity",1):c.setAttr("opacity",0))}this._flushStone(a);return this},_flushStone:function(a){var b=this.svg.child(this.idGen.stoneGroup()).child(this.idGen.stone(a));b&&(glift.dom.elem(b.id()).setAttrObj(b.attrObj()),b=this.svg.child(this.idGen.stoneShadowGroup()),void 0!==b&&(a=b.child(this.idGen.stoneShadow(a)),glift.dom.elem(a.id()).setAttrObj(a.attrObj())));return this},addMarkPt:function(a,b,c){a=a.rotate(this.boardPoints.numIntersections,this.rotation);var d=this.svg.child(this.idGen.markGroup());
return this._addMarkInternal(d,a,b,c)},hasMark:function(a){a=a.rotate(this.boardPoints.numIntersections,this.rotation);return this.svg.child(this.idGen.markGroup()).child(this.idGen.mark(a))?!0:!1},addTempMark:function(a,b,c){a=a.rotate(this.boardPoints.numIntersections,this.rotation);var d=this.svg.child(this.idGen.tempMarkGroup());return this._addMarkInternal(d,a,b,c)},clearTempMarks:function(){this.clearMarks(this.svg.child(this.idGen.tempMarkGroup()));return this},_addMarkInternal:function(a,
b,c,d){this._reqClearForMark(b,c)&&this._clearForMark(b);var e=this.svg.child(this.idGen.stoneGroup()).child(this.idGen.stone(b));if(e){var e=e.attr("stone_color"),f=this.theme.stones;glift.displays.board.addMark(a,this.idGen,this.boardPoints,f[e].marks,f,b,c,d);this._flushMark(b,c,a)}return this},_reqClearForMark:function(a,b){var c=glift.enums.marks,d=this.svg.child(this.idGen.stoneGroup()).child(this.idGen.stone(a));return d?"EMPTY"===d.attr("stone_color")&&(b===c.LABEL||b===c.VARIATION_MARKER||
b===c.CORRECT_VARIATION||b===c.LABEL_NUMERIC||b===c.LABEL_ALPHA):!1},_clearForMark:function(a){var b=this.svg.child(this.idGen.starpointGroup()).child(this.idGen.starpoint(a));b&&b.setAttr("opacity",0);this.svg.child(this.idGen.lineGroup()).child(this.idGen.line(a)).setAttr("opacity",0);return this},_flushMark:function(a,b,c){var d=this.svg,e=this.idGen;this._reqClearForMark(a,b)&&((b=d.child(e.starpointGroup()).child(e.starpoint(a)))&&glift.dom.elem(b.id()).setAttr("opacity",b.attr("opacity")),d=
d.child(e.lineGroup()).child(e.line(a)),glift.dom.elem(d.id()).setAttr("opacity",d.attr("opacity")));c.child(e.mark(a)).attachToParent(c.id());this.markPts.push(a);return this},clearMarks:function(a){a=a||this.svg.child(this.idGen.markGroup());for(var b=this.idGen,c=a.children(),d=0,e=c.length;d<e;d++){var f=c[d].data(),g=this.svg.child(b.starpointGroup()).child(b.starpoint(f));g&&g.setAttr("opacity",1).updateAttrInDom("opacity");(f=this.svg.child(b.lineGroup()).child(b.line(f)))&&f.setAttr("opacity",
1).updateAttrInDom("opacity")}a.emptyChildren();glift.dom.elem(a.id()).empty();return this},addGuideLines:function(a){var b=glift.displays.svg,c=this.svg.child(this.idGen.markGroup());c.rmChild(this.idGen.guideLine());a=this.boardPoints.getCoord(a);var d=this.boardPoints;c.append(b.path().setAttr("d",glift.displays.board.intersectionLine(a,8*d.radius,d.numIntersections)).setAttr("stroke-width",3).setAttr("stroke","blue").setId(this.idGen.guideLine()))},clearGuideLines:function(){this.svg.child(this.idGen.markGroup()).rmChild(this.idGen.guideLine());
return this},setGroupAttr:function(a,b){var c=this.svg.child(a);if(void 0!==c)for(var c=c.children(),d=0,e=c.length;d<e;d++)for(var f in b)c[d].setAttr(f,b[f]);return this},clearStones:function(){var a={opacity:0,stone_color:"EMPTY"},b={opacity:0};this.setGroupAttr(this.idGen.stoneGroup(),a).setGroupAttr(this.idGen.stoneShadowGroup(),b);for(var c=this.svg.child(this.idGen.stoneGroup()).children(),d=0,e=c.length;d<e;d++)glift.dom.elem(c[d].id()).setAttrObj(a);if(d=this.svg.child(this.idGen.stoneShadowGroup()))for(a=
d.children(),d=0,e=a.length;d<e;d++)glift.dom.elem(a[d].id()).setAttrObj(b);return this},clearAll:function(){this.clearMarks().clearStones();return this},setEvent:function(a,b){var c=this,d=this.svg.child(this.idGen.buttonGroup()).child(this.idGen.fullBoardButton()).id();glift.dom.elem(d).on(a,function(a){var d=c._buttonEventPt(a);d&&b(a,d)});return this},setHover:function(a,b){var c=this,d=this.svg.child(this.idGen.buttonGroup()).child(this.idGen.fullBoardButton()).id();glift.dom.elem(d).on("mousemove",
function(d){var f=c.lastHoverPoint,g=c._buttonEventPt(d);g&&f&&!f.equals(g)?(b(d,f),a(d,g)):!f&&g&&a(d,g);c.lastHoverPoint=g});glift.dom.elem(d).on("mouseout",function(a){var d=c.lastHoverPoint;c.lastHoverPoint=null;d&&b(a,d)})},_buttonEventPt:function(a){var b=this.svg.child(this.idGen.buttonGroup()).child(this.idGen.fullBoardButton()).data(),c=this.boardPoints.numIntersections,d=glift.dom.elem(this.idGen.fullBoardButton()).offset(),e=b.tl.intPt.x(),f=a.pageX;a.changedTouches&&a.changedTouches[0]&&
(f=a.changedTouches[0].pageX);f=Math.floor((f-d.left)/b.spacing)+e;f<e?f=e:f>c-1&&(f=c-1);var e=b.tl.intPt.y(),g=a.pageY;a.changedTouches&&a.changedTouches[0]&&(g=a.changedTouches[0].pageY);a=Math.floor((g-d.top)/b.spacing)+e;a<e?a=e:a>c-1&&(a=c-1);c=glift.util.point(f,a);this.rotation!=glift.enums.rotations.NO_ROTATION&&(c=c.antirotate(this.boardPoints.numIntersections,this.rotation));return c}};glift.displays.board.lines=function(a,b,c,d){if(null===c)throw Error("boardPoints null: Gui Environment obj not initialized");var e=glift.displays.svg,f=e.group().setId(b.lineGroup());a.append(f);a=c.data();for(var g=0,h=a.length;g<h;g++){var k=a[g];f.append(e.path().setAttr("d",glift.displays.board.intersectionLine(k,c.radius,c.numIntersections)).setAttr("stroke",d.lines.stroke).setAttr("stroke-width",d.lines["stroke-width"]).setAttr("stroke-linecap","round").setId(b.line(k.intPt)))}};
glift.displays.board.intersectionLine=function(a,b,c){var d=c-1;c=a.coordPt;var e=a.intPt;a=glift.displays.svg.pathutils;var f=0===e.y()?c.y():c.y()-b,g=e.y()===d?c.y():c.y()+b,h=0===e.x()?c.x():c.x()-b;b=e.x()===d?c.x():c.x()+b;return a.move(c.x(),f)+" "+a.lineAbs(c.x(),g)+" "+a.move(h,c.y())+" "+a.lineAbs(b,c.y())};glift.displays.board.markContainer=function(a,b){a.append(glift.displays.svg.group().setId(b.markGroup()));a.append(glift.displays.svg.group().setId(b.tempMarkGroup()))};
glift.displays.board.addMark=function(a,b,c,d,e,f,g,h){var k=glift.displays.svg.pathutils,l=glift.displays.svg,m=glift.enums.marks,n=c.getCoord(f).coordPt;b=b.mark(f);var p=c.radius/8;g===m.LABEL||g===m.VARIATION_MARKER||g===m.CORRECT_VARIATION||g===m.LABEL_ALPHA||g===m.LABEL_NUMERIC?(g===m.VARIATION_MARKER?d=d.VARIATION_MARKER:g===m.CORRECT_VARIATION&&(d=d.CORRECT_VARIATION),a.append(l.text().setText(h).setData(f).setAttr("fill",d.fill).setAttr("stroke",d.stroke).setAttr("text-anchor","middle").setAttr("dy",
".33em").setAttr("x",n.x()).setAttr("y",n.y()).setAttr("font-family",e.marks["font-family"]).setAttr("font-size",c.spacing*e.marks["font-size"]).setId(b))):g===m.SQUARE?(c=c.radius/1.41421356237,k=c-p,a.append(l.rect().setData(f).setAttr("x",n.x()-k).setAttr("y",n.y()-k).setAttr("width",2*k).setAttr("height",2*k).setAttr("fill","none").setAttr("stroke-width",2).setAttr("stroke",d.stroke).setId(b))):g===m.XMARK?(c=c.radius/1.41421356237,h=c-p,c=n.translate(-1*h,-1*h),e=n.translate(h,-1*h),g=n.translate(-1*
h,h),h=n.translate(h,h),a.append(l.path().setData(f).setAttr("d",k.movePt(n)+" "+k.lineAbsPt(c)+" "+k.movePt(n)+" "+k.lineAbsPt(e)+" "+k.movePt(n)+" "+k.lineAbsPt(g)+" "+k.movePt(n)+" "+k.lineAbsPt(h)).setAttr("stroke-width",2).setAttr("stroke",d.stroke).setId(b))):g===m.CIRCLE?a.append(l.circle().setData(f).setAttr("cx",n.x()).setAttr("cy",n.y()).setAttr("r",c.radius/2).setAttr("fill","none").setAttr("stroke-width",2).setAttr("stroke",d.stroke).setId(b)):g===m.STONE_MARKER?a.append(l.circle().setData(f).setAttr("cx",
n.x()).setAttr("cy",n.y()).setAttr("r",c.radius/3).setAttr("opacity",d.STONE_MARKER.opacity).setAttr("fill",d.STONE_MARKER.fill).setId(b)):g===m.TRIANGLE&&(g=c.radius-c.radius/5,c=n.translate(.866025403785*g,.5*g),e=n.translate(-.866025403785*g,.5*g),n=n.translate(0,-1*g),a.append(l.path().setData(f).setAttr("fill","none").setAttr("d",k.movePt(n)+" "+k.lineAbsPt(e)+" "+k.lineAbsPt(c)+" "+k.lineAbsPt(n)).setAttr("stroke-width",2).setAttr("stroke",d.stroke).setId(b)));return this};glift.displays.board.starpoints=function(a,b,c,d){var e=glift.displays.svg,f=e.group().setId(b.starpointGroup());a.append(f);a=d.starPoints.sizeFraction*c.spacing;for(var g=c.starPoints(),h=0,k=g.length;h<k;h++){var l=g[h],m=c.getCoord(l).coordPt;f.append(e.circle().setAttr("cx",m.x()).setAttr("cy",m.y()).setAttr("r",a).setAttr("fill",d.starPoints.fill).setAttr("opacity",1).setId(b.starpoint(l)))}};glift.displays.board.stones=function(a,b,c,d){d=glift.displays.svg;var e=d.group().setId(b.stoneGroup());a.append(e);a=c.data();for(var f=0,g=a.length;f<g;f++){var h=a[f];e.append(d.circle().setAttr("cx",h.coordPt.x()).setAttr("cy",h.coordPt.y()).setAttr("r",c.radius-.4).setAttr("opacity",0).setAttr("stone_color","EMPTY").setAttr("fill","blue").setAttr("class",glift.enums.svgElements.STONE).setId(b.stone(h.intPt)))}};
glift.displays.board.shadows=function(a,b,c,d){if(void 0===d.stones.shadows)return{};var e=glift.displays.svg,f=e.group().setId(b.stoneShadowGroup());a.append(f);a=c.data();for(var g=0,h=a.length;g<h;g++){var k=a[g];f.append(e.circle().setAttr("cx",k.coordPt.x()+c.radius/7).setAttr("cy",k.coordPt.y()+c.radius/7).setAttr("r",c.radius-.4).setAttr("opacity",0).setAttr("fill",d.stones.shadows.fill).setAttr("class",glift.enums.svgElements.STONE_SHADOW).setId(b.stoneShadow(k.intPt)))}};glift.displays.commentbox={};glift.displays.commentbox.create=function(a,b,c,d){if(!c)throw Error("Theme must be defined. was: "+c);return(new glift.displays.commentbox.CommentBox(a,b,c,d||!1)).draw()};glift.displays.commentbox.CommentBox=function(a,b,c,d){this.divId=a;this.bbox=glift.orientation.bbox.fromPts(glift.util.point(0,0),glift.util.point(b.width(),b.height()));this.theme=c;this.useMarkdown=d;this.el=void 0};
glift.displays.commentbox.CommentBox.prototype={draw:function(){this.el=glift.dom.elem(this.divId);if(null===this.el)throw Error("Could not find element with ID "+this.divId);this.el.css(glift.obj.flatMerge({"overflow-y":"auto",MozBoxSizing:"border-box",boxSizing:"border-box"},this.theme.commentBox.css));this.el.addClass("glift-comment-box");return this},setText:function(a){this.el.empty();this.el.append(glift.dom.convertText(a,this.useMarkdown))},clearText:function(){this.el.empty()},destroy:function(){this.el.remove()}};glift.displays.gui={};glift.displays.gui.Transform=function(a,b,c){this.scale=a;this.xMove=b||0;this.yMove=c||0};glift.displays.gui.MultiCenter=function(a,b,c){this.transforms=a;this.bboxes=b;this.unfit=c};glift.displays.gui.SingleCenter=function(a,b){this.transform=a;this.bbox=b};glift.displays.gui.rowCenterSimple=function(a,b,c,d,e){return glift.displays.gui.linearCentering_(a,b,c,d,e,0,"h")};glift.displays.gui.columnCenterSimple=function(a,b,c,d,e){return glift.displays.gui.linearCentering_(a,b,c,d,e,0,"v")};
glift.displays.gui.linearCentering_=function(a,b,c,d,e,f,g){var h=a.width()-2*d,k=a.height()-2*c,l=[],m=[];e=e||0;f=f||0;g="v"===g||"h"===g?g:"h";var n=function(a,b){return"h"===b?a.width():a.height()},p=n(a,g);f=0>=f?1E7:f;e=0>=e?0:e;for(var q=0,r=0;r<b.length;r++){var u=k>h?h/b[r].width():k/b[r].height(),v=new glift.displays.gui.Transform(u),u=b[r].scale(u);l.push(v);m.push(u);q+=n(u,g);r<b.length-1&&(q+=e)}for(b=[];p<q;)r=m.pop(),l.pop(),q-=n(r,g),q-=e,b.push(r);v="h"===g?h-q:k-q;r=e=u=v/(l.length+
1);u>f&&(e=f,r=(v-e*(l.length-1))/2);d=a.left()+d;a=a.top()+c;"h"===g?d+=r:a+=r;c=[];for(r=0;r<m.length;r++)u=m[r],v=l[r],f=a-u.top(),h=d-u.left(),v.xMove=h,v.yMove=f,c.push(u.translate(h,f)),"h"===g?d+=u.width()+e:a+=u.height()+e;return new glift.displays.gui.MultiCenter(l,c,b)};
glift.displays.gui.centerWithin=function(a,b,c,d){var e=a.width()-2*d,f=a.height()-2*c,g=1,g=f/e>b.height()/b.width()?e/b.width():f/b.width();b=b.scale(g);d=a.left()+d;b.width()<e&&(d+=(e-b.width())/2);a=a.top()+c;b.height()<f&&(a+=(f-b.height())/2);f=new glift.displays.gui.Transform(g,d-b.left(),a-b.top());b=b.translate(f.xMove,f.yMove);return new glift.displays.gui.SingleCenter(f,b)};glift.displays.icons={};glift.displays.icons.bar=function(a){return new glift.displays.icons.IconBar(a)};
glift.displays.icons.IconBar=function(a){if(!a.theme)throw Error("Theme undefined in iconbar");if(!a.divId)throw Error("Must define an options 'divId' as an option");this.divId=a.divId;this.position=a.positioning;this.divBbox=glift.orientation.bbox.fromPts(glift.util.point(0,0),glift.util.point(this.position.width(),this.position.height()));this.theme=a.theme;this.parentBbox=a.parentBbox;this.icons=glift.displays.icons.wrapIcons(a.icons);this.allDivIds=a.allDivIds;this.allPositioning=a.allPositioning;
this.nameMapping={};this.vertMargin=this.theme.icons.vertMargin;this.horzMargin=this.theme.icons.horzMargin;this.svg=void 0;this.idGen=glift.displays.ids.generator(this.divId);this.tooltipId=this.tooltipTimer=void 0;this.initIconIds_();this.initNameMapping_()};
glift.displays.icons.IconBar.prototype={initNameMapping_:function(){this.forEachIcon(function(a){this.nameMapping[a.iconName]=a}.bind(this))},initIconIds_:function(){this.forEachIcon(function(a){a.setElementId(this.idGen.icon(a.iconName))}.bind(this))},draw:function(){this.destroy();var a=glift.displays.svg,b=this.divBbox;this.bbox=b;this.svg=a.svg().setAttr("width","100%").setAttr("height","100%");glift.displays.icons.rowCenterWrapped(b,this.icons,this.vertMargin,this.horzMargin);this._createIcons();
this._createIconButtons();this.flush();return this},_createIcons:function(){var a=glift.displays.svg,b=a.group().setId(this.idGen.iconGroup());this.svg.append(b);this.svg.append(a.group().setId(this.idGen.tempIconGroup()));for(var c=0,d=this.icons.length;c<d;c++){var e=this.icons[c],e=a.path().setId(e.elementId).setAttr("d",e.iconStr).setAttr("transform",e.transformString()),f;for(f in this.theme.icons.DEFAULT)e.setAttr(f,this.theme.icons.DEFAULT[f]);b.append(e)}},_createIconButtons:function(){var a=
glift.displays.svg,b=a.group().setId(this.idGen.buttonGroup());this.svg.append(b);for(var c=0,d=this.icons.length;c<d;c++){var e=this.icons[c];b.append(a.rect().setData(e.iconName).setAttr("x",e.bbox.topLeft().x()).setAttr("y",e.bbox.topLeft().y()).setAttr("width",e.bbox.width()).setAttr("height",e.bbox.height()).setAttr("fill","blue").setAttr("opacity",0).setId(this.idGen.button(e.iconName)))}},flush:function(){this.svg.attachToParent(this.divId);var a=this.getIcon("multiopen");void 0!==a&&this.setCenteredTempIcon("multiopen",
a.getActive(),"black")},setCenteredTempIcon:function(a,b,c,d,e){var f=glift.displays.svg;e=e||2;d=d||2;a=this.getIcon(a);b="string"===glift.util.typeOf(b)?glift.displays.icons.wrappedIcon(b):b.rewrapIcon();var g=this.idGen.tempIcon(a.iconName);glift.dom.elem(g)&&glift.dom.elem(g).remove();b=a.subboxIcon?a.centerWithinSubbox(b,d,e):a.centerWithinIcon(b,d,e);this.svg.child(this.idGen.tempIconGroup()).appendAndAttach(f.path().setId(g).setAttr("d",b.iconStr).setAttr("fill",c).setAttr("transform",b.transformString()));
return this},addTempText:function(a,b,c,d){var e=glift.displays.svg,f=this.getIcon(a),g=f.bbox;f.subboxIcon&&(g=f.subboxIcon.bbox);d=d||.5;d*=g.width();this.idGen.tempIconText(a);this.clearTempText(a);a=e.text().setId(this.idGen.tempIconText(a)).setText(b).setAttr("class","tempIcon").setAttr("font-family","sans-serif").setAttr("font-size",d+"px").setAttr("x",g.center().x()).setAttr("y",g.center().y()).setAttr("dy",".33em").setAttr("style","text-anchor: middle; vertical-align: middle;").setAttr("lengthAdjust",
"spacing");for(var h in c)a.setAttr(h,c[h]);this.svg.child(this.idGen.tempIconGroup()).appendAndAttach(a);return this},clearTempText:function(a){a=this.idGen.tempIconText(a);this.svg.rmChild(a);(a=glift.dom.elem(a))&&a.remove()},createIconSelector:function(a,b){},destroyIconSelector:function(){},destroyTempIcons:function(){this.svg.child(this.idGen.tempIconGroup()).emptyChildrenAndUpdate();return this},buttonId:function(a){return this.idGen.button(a)},initIconActions:function(a,b){this.forEachIcon(function(c){var d=
c.iconName;if(b.hasOwnProperty(c.iconName)){var e={};glift.platform.isMobile()?e.touchend=b[d].click:e.click=b[d].click;glift.platform.isMobile()||(e.mouseover=b[d].mouseover||function(a,b,c){a=glift.dom.elem(c.elementId);b=b.iconBar.theme.icons;for(var d in b.DEFAULT_HOVER)a.setAttr(d,b.DEFAULT_HOVER[d])},e.mouseout=b[d].mouseout||function(a,b,c){if(a=glift.dom.elem(c.elementId)){b=b.iconBar.theme.icons;for(var d in b.DEFAULT)a.setAttr(d,b.DEFAULT[d])}});for(var f in e)this._initOneIconAction(a,
c,f,e[f]);b[d].tooltip&&!glift.platform.isMobile()&&this._initializeTooltip(c,b[d].tooltip)}}.bind(this))},_initOneIconAction:function(a,b,c,d){var e=this.idGen.button(b.iconName);glift.dom.elem(e).on(c,function(e){"click"===c&&this.tooltipTimer&&(clearTimeout(this.tooltipTimer),this.tooltipTimer=null);this.tooltipId&&(glift.dom.elem(this.tooltipId)&&glift.dom.elem(this.tooltipId).remove(),this.tooltipId=null);a.manager.setActive();d(e,a,b,this)}.bind(this))},_initializeTooltip:function(a,b){var c=
this.divId+"_tooltip",d=this.idGen.button(a.iconName);glift.dom.elem(d).on("mouseover",function(d){d=function(){var d=glift.dom.newDiv(c);d.appendText(b);var e={position:"absolute",top:-1.2*a.bbox.height()+"px","z-index":2,boxSizing:"border-box"},h;for(h in this.theme.icons.tooltips)e[h]=this.theme.icons.tooltips[h];d.css(e);if(e=glift.dom.elem(this.divId))e.append(d),this.tooltipId=c;this.tooltipTimer=null}.bind(this);this.tooltipTimer=setTimeout(d,this.theme.icons.tooltipTimeout)}.bind(this));glift.dom.elem(d).on("mouseout",
function(a){null!=this.tooltipTimer&&clearTimeout(this.tooltipTimer);this.tooltipTimer=null;glift.dom.elem(c)&&glift.dom.elem(c).remove()}.bind(this))},hasIcon:function(a){return void 0!==this.nameMapping[a]},getIcon:function(a){var b=glift.util.typeOf(a);if("string"===b)return this.nameMapping[a];if("number"===b)return this.icons[a]},forEachIcon:function(a){for(var b=0,c=this.icons.length;b<c;b++)a(this.icons[b])},redraw:function(){this.destroy();this.draw()},destroy:function(){this.divId&&glift.dom.elem(this.divId)&&
glift.dom.elem(this.divId).empty();this.tooltipTimer&&(clearTimeout(this.tooltipTimer),this.tooltipTimer=null);this.bbox=void 0;return this}};glift.displays.icons.CenterDir={H:"h",V:"v"};glift.displays.icons.rowCenterWrapped=function(a,b,c,d,e){return glift.displays.icons._centerWrapped(a,b,c,d,e||0,glift.displays.icons.CenterDir.H)};glift.displays.icons.columnCenterWrapped=function(a,b,c,d,e){return glift.displays.icons._centerWrapped(a,b,c,d,e||0,glift.displays.icons.CenterDir.V)};
glift.displays.icons._centerWrapped=function(a,b,c,d,e,f){var g=[];f!==glift.displays.icons.CenterDir.H&&f!==glift.displays.icons.CenterDir.V&&(f=glift.displays.icons.CenterDir.H);for(var h=0;h<b.length;h++)g.push(b[h].bbox);a=(f===glift.displays.icons.CenterDir.H?glift.displays.gui.rowCenterSimple(a,g,c,d,e):glift.displays.gui.columnCenterSimple(a,g,c,d,e)).transforms;for(h=0;h<a.length&&h<b.length;h++)b[h].performTransform(a[h]);return a};glift.displays.icons.iconSelector=function(a,b,c){return(new glift.displays.icons.IconSelector(a,b,c)).draw()};glift.displays.icons.IconSelector=function(a,b,c){this.iconBarId=b;this.parentDivId=a;this.icon=c;this.baseId="iconSelector_"+a;this.wrapperDivId=this.baseId+"_wrapper";this.displayedIcons=void 0;this.columnIdList=[];this.svgColumnList=[];this.iconList=[]};
glift.displays.icons.IconSelector.prototype={draw:function(){this.destroy();var a=glift.displays.svg,b=glift.displays.bboxFromDiv(this.parentDivId),c=glift.dom.elem(this.iconBarId).boundingClientRect().left,d=glift.displays.bboxFromDiv(this.iconBarId),e=this.icon.bbox;e.height();for(var f=b.height()-d.height(),g=[],h=0;h<this.icon.associatedIcons.length;h++)g.push(this.icon.associatedIcons[h].rewrapIcon());var k=glift.dom.newDiv(this.wrapperDivId);k.css({position:"absolute",height:b.height()+"px",
width:b.width()+"px"});glift.dom.elem(this.parentDivId).append(k);for(b=0;0<g.length;){this.iconList.push([]);h=this.baseId+"_column_"+b;this.columnIdList.push(h);var l=glift.dom.newDiv(h);l.css({bottom:d.height()+"px",height:f+"px",left:c+b*e.width()+"px",width:e.width()+"px",position:"absolute"});k.append(l);var l=glift.displays.bboxFromDiv(h),m=glift.displays.icons.columnCenterWrapped(l,g,5,5),l=h+"_svg",n=a.svg().setId(h+"_svg").setAttr("height","100%").setAttr("width","100%"),h=glift.displays.ids.generator(h),
p=a.group().setId(h.iconGroup());n.append(p);h=0;for(m=m.length;h<m;h++){var q=g.shift();q.setElementId(l+"_"+q.iconName);this.iconList[b].push(q);p.append(a.path().setId(q.elementId).setAttr("d",q.iconStr).setAttr("fill","black").setAttr("transform",q.transformString()))}this.svgColumnList.push(n);b++}this._createIconButtons();this._setBackgroundEvent();for(h=0;h<this.svgColumnList.length;h++)this.svgColumnList[h].attachToParent(this.columnIdList[h]);return this},_createIconButtons:function(){for(var a=
glift.displays.svg,b=0;b<this.iconList.length;b++){var c=this.svgColumnList[b],d=glift.displays.ids.generator(this.columnIdList[b]),e=this.iconList[b],f=a.group().setId(d.buttonGroup());c.append(f);for(c=0;c<e.length;c++){var g=e[c];f.append(a.rect().setData(g.iconName).setAttr("x",g.bbox.topLeft().x()).setAttr("y",g.bbox.topLeft().y()).setAttr("width",g.bbox.width()).setAttr("height",g.bbox.height()).setAttr("fill","blue").setAttr("opacity",0).setId(d.button(g.iconName)))}}},_setBackgroundEvent:function(){glift.dom.elem(this.wrapperDivId).on("click",
function(a){this.remove()});return this},setIconEvents:function(a,b){for(var c=0;c<this.iconList.length;c++)for(var d=glift.displays.ids.generator(this.columnIdList[c]),e=0;e<this.iconList[c].length;e++){var f=this.iconList[c][e],g=d.button(f.iconName);this._setOneEvent(a,g,f,b)}return this},_setOneEvent:function(a,b,c,d){glift.dom.elem(b).on(a,function(a){d(a,c)});return this},destroy:function(){glift.dom.elem(this.wrapperDivId)&&glift.dom.elem(this.wrapperDivId).remove();return this}};glift.displays.icons.svg={cross:{string:"M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z",bbox:{x:8.116,y:7.585,x2:24.778,y2:24.248,width:16.662,height:16.663}},check:{string:"M2.379,14.729 5.208,11.899 12.958,19.648 25.877,6.733 28.707,9.561 12.958,25.308z",bbox:{x:2.379,y:6.733,x2:28.707,y2:25.308,width:26.328,height:18.575}},refresh:{string:"M24.083,15.5c-0.009,4.739-3.844,8.574-8.583,8.583c-4.741-0.009-8.577-3.844-8.585-8.583c0.008-4.741,3.844-8.577,8.585-8.585c1.913,0,3.665,0.629,5.09,1.686l-1.782,1.783l8.429,2.256l-2.26-8.427l-1.89,1.89c-2.072-1.677-4.717-2.688-7.587-2.688C8.826,3.418,3.418,8.826,3.416,15.5C3.418,22.175,8.826,27.583,15.5,27.583S27.583,22.175,27.583,15.5H24.083z",
bbox:{x:3.416,y:3.415,x2:27.583,y2:27.583,width:24.167,height:24.168}},undo:{string:"M12.981,9.073V6.817l-12.106,6.99l12.106,6.99v-2.422c3.285-0.002,9.052,0.28,9.052,2.269c0,2.78-6.023,4.263-6.023,4.263v2.132c0,0,13.53,0.463,13.53-9.823C29.54,9.134,17.952,8.831,12.981,9.073z",bbox:{x:.875,y:6.817,x2:29.54,y2:27.042158,width:28.665,height:20.225158}},"chevron-right":{string:"M10.129,22.186 16.316,15.999 10.129,9.812 13.665,6.276 23.389,15.999 13.665,25.725z",bbox:{x:10.129,y:6.276,x2:23.389,y2:25.725,
width:13.26,height:19.449}},"chevron-left":{string:"M21.871,9.814 15.684,16.001 21.871,22.188 18.335,25.725 8.612,16.001 18.335,6.276z",bbox:{x:8.612,y:6.276,x2:21.871,y2:25.725,width:13.259,height:19.449}},"problem-explanation":{string:"M256,90c91.74,0,166,74.244,166,166c0,91.741-74.245,166-166,166c-91.741,0-166-74.245-166-166 C90,164.259,164.244,90,256,90 M256,50C142.229,50,50,142.229,50,256s92.229,206,206,206s206-92.229,206-206S369.771,50,256,50 L256,50z M258.025,379.511c-14.546,0-26.343-11.797-26.343-26.349c0-14.543,11.797-26.336,26.343-26.336 c14.549,0,26.342,11.793,26.342,26.336C284.367,367.714,272.574,379.511,258.025,379.511z M278.735,301.646v4.739 c0,0-39.494,0-43.423,0v-4.739c0-13.408,1.956-30.61,17.523-45.565c15.569-14.958,35.024-27.312,35.024-45.996 c0-20.655-14.335-31.581-32.409-31.581c-30.116,0-32.085,31.234-32.827,38.112H180.39c1.125-32.57,14.891-78.127,75.315-78.127 c52.363,0,75.905,35.07,75.905,67.957C331.61,258.793,278.735,267.886,278.735,301.646z",
bbox:{x:50,y:50,x2:462,y2:462,width:412,height:412}},play:{string:"m 58.250001,41.61219 0,40 34.69375,-20.03045 z",bbox:{x:58.250001,y:41.61219,x2:92.94375099999999,y2:81.61219,width:34.693749999999994,height:40}},unplay:{string:"m 74.987245,22.583592 0,39.978487 L 40,42.362183 z",bbox:{x:40,y:22.583592,x2:74.987245,y2:62.562079,width:34.987245,height:39.978487}},arrowup:{string:"M23.963,20.834L17.5,9.64c-0.825-1.429-2.175-1.429-3,0L8.037,20.834c-0.825,1.429-0.15,2.598,1.5,2.598h12.926C24.113,23.432,24.788,22.263,23.963,20.834z",
bbox:{x:7.684895,y:8.56825,x2:24.315105,y2:23.432,width:16.630209,height:14.86375}},arrowright:{string:"M11.166,23.963L22.359,17.5c1.43-0.824,1.43-2.175,0-3L11.166,8.037c-1.429-0.826-2.598-0.15-2.598,1.5v12.926C8.568,24.113,9.737,24.789,11.166,23.963z",bbox:{x:8.568,y:7.684457,x2:23.4315,y2:24.315543,width:14.8635,height:16.631086}},arrowleft:{string:"M20.834,8.037L9.641,14.5c-1.43,0.824-1.43,2.175,0,3l11.193,6.463c1.429,0.826,2.598,0.15,2.598-1.5V9.537C23.432,7.887,22.263,7.211,20.834,8.037z",bbox:{x:8.5685,
y:7.684457,x2:23.432,y2:24.315543,width:14.8635,height:16.631086}},detour:{string:"M29.342,15.5l-7.556-4.363v2.614H18.75c-1.441-0.004-2.423,1.002-2.875,1.784c-0.735,1.222-1.056,2.561-1.441,3.522c-0.135,0.361-0.278,0.655-0.376,0.817c-1.626,0-0.998,0-2.768,0c-0.213-0.398-0.571-1.557-0.923-2.692c-0.237-0.676-0.5-1.381-1.013-2.071C8.878,14.43,7.89,13.726,6.75,13.75H2.812v3.499c0,0,0.358,0,1.031,0h2.741c0.008,0.013,0.018,0.028,0.029,0.046c0.291,0.401,0.634,1.663,1.031,2.888c0.218,0.623,0.455,1.262,0.92,1.897c0.417,0.614,1.319,1.293,2.383,1.293H11c2.25,0,1.249,0,3.374,0c0.696,0.01,1.371-0.286,1.809-0.657c1.439-1.338,1.608-2.886,2.13-4.127c0.218-0.608,0.453-1.115,0.605-1.314c0.006-0.01,0.012-0.018,0.018-0.025h2.85v2.614L29.342,15.5zM10.173,14.539c0.568,0.76,0.874,1.559,1.137,2.311c0.04,0.128,0.082,0.264,0.125,0.399h2.58c0.246-0.697,0.553-1.479,1.005-2.228c0.252-0.438,0.621-0.887,1.08-1.272H9.43C9.735,14.003,9.99,14.277,10.173,14.539z",
bbox:{x:2.812,y:11.137,x2:29.342,y2:23.37325,width:26.53,height:12.23625}},checkbox:{string:"M26,27.5H6c-0.829,0-1.5-0.672-1.5-1.5V6c0-0.829,0.671-1.5,1.5-1.5h20c0.828,0,1.5,0.671,1.5,1.5v20C27.5,26.828,26.828,27.5,26,27.5zM7.5,24.5h17v-17h-17V24.5z",bbox:{x:4.5,y:4.5,x2:27.5,y2:27.5,width:23,height:23}},edit:{string:"M27.87,7.863L23.024,4.82l-7.889,12.566l4.842,3.04L27.87,7.863zM14.395,21.25l-0.107,2.855l2.527-1.337l2.349-1.24l-4.672-2.936L14.395,21.25zM29.163,3.239l-2.532-1.591c-0.638-0.401-1.479-0.208-1.882,0.43l-0.998,1.588l4.842,3.042l0.999-1.586C29.992,4.481,29.802,3.639,29.163,3.239zM25.198,27.062c0,0.275-0.225,0.5-0.5,0.5h-19c-0.276,0-0.5-0.225-0.5-0.5v-19c0-0.276,0.224-0.5,0.5-0.5h13.244l1.884-3H5.698c-1.93,0-3.5,1.57-3.5,3.5v19c0,1.93,1.57,3.5,3.5,3.5h19c1.93,0,3.5-1.57,3.5-3.5V11.097l-3,4.776V27.062z",
bbox:{x:2.198,y:1.4388,x2:29.80125,y2:30.562,width:27.60325,height:29.12316}},"jump-left-arrow":{string:"M 179.229,182.397 V 127.433 L 50,256.445 179.229,385.455 v -54.964 h 96.773 V 182.397 h -96.773 z m 123.385,0 h 47.184 V 330.491 H 302.614 V 182.397 z m 73.794,0 h 35.388 V 330.491 H 376.408 V 182.397 z m 62,0 H 462 V 330.491 H 438.408 V 182.397 z",bbox:{x:50,y:127.433,x2:462,y2:385.455,width:412,height:258.022}},"jump-right-arrow":{string:"M332.771,182.397v-54.964L462,256.445l-129.229,129.01v-54.964h-96.773V182.397H332.771z M209.386,182.397h-47.184v148.094h47.184V182.397z M135.592,182.397h-35.388v148.094h35.388V182.397z M73.592,182.397H50v148.094 h23.592V182.397z",
bbox:{x:50,y:127.433,x2:462,y2:385.455,width:412,height:258.022}},"undo-problem-move":{string:"m 256,50 c 113.771,0 206,92.229 206,206 0,113.771 -92.229,206 -206,206 C 142.229,462 50,369.771 50,256 50,142.229 142.229,50 256,50 z m 58.399,329.6 V 132.4 L 135.6,256.001 314.399,379.6 z",bbox:{x:50,y:50,x2:462,y2:462,width:412,height:412}},"game-info":{string:"M256,90.002c91.74,0,166,74.241,166,165.998c0,91.739-74.245,165.998-166,165.998 c-91.738,0-166-74.242-166-165.998C90,164.259,164.243,90.002,256,90.002 M256,50.002C142.229,50.002,50,142.228,50,256 c0,113.769,92.229,205.998,206,205.998c113.77,0,206-92.229,206-205.998C462,142.228,369.77,50.002,256,50.002L256,50.002z M252.566,371.808c-28.21,9.913-51.466-1.455-46.801-28.547c4.667-27.098,31.436-85.109,35.255-96.079 c3.816-10.97-3.502-13.977-11.346-9.513c-4.524,2.61-11.248,7.841-17.02,12.925c-1.601-3.223-3.852-6.906-5.542-10.433 c9.419-9.439,25.164-22.094,43.803-26.681c22.27-5.497,59.492,3.29,43.494,45.858c-11.424,30.34-19.503,51.276-24.594,66.868 c-5.088,15.598,0.955,18.868,9.863,12.791c6.959-4.751,14.372-11.214,19.806-16.226c2.515,4.086,3.319,5.389,5.806,10.084 C295.857,342.524,271.182,365.151,252.566,371.808z M311.016,184.127c-12.795,10.891-31.76,10.655-42.37-0.532 c-10.607-11.181-8.837-29.076,3.955-39.969c12.794-10.89,31.763-10.654,42.37,0.525 C325.577,155.337,323.809,173.231,311.016,184.127z",
bbox:{x:50,y:50.002,x2:462,y2:461.998,width:412,height:411.996}},"old-move-indicator":{string:"M256,50C142.23,50,50,142.23,50,256s92.23,206,206,206s206-92.23,206-206S369.77,50,256,50z M256.001,124.6c72.568,0,131.399,58.829,131.399,131.401c0,72.568-58.831,131.398-131.399,131.398 c-72.572,0-131.401-58.83-131.401-131.398C124.6,183.429,183.429,124.6,256.001,124.6z M70,256 c0-49.682,19.348-96.391,54.479-131.521S206.318,70,256,70v34.6c-83.482,0.001-151.4,67.918-151.4,151.401 c0,41.807,17.035,79.709,44.526,107.134l-24.269,24.757c-0.125-0.125-0.254-0.245-0.379-0.37C89.348,352.391,70,305.682,70,256z",
bbox:{x:50,y:50,x2:462,y2:462,width:412,height:412}},"move-indicator":{string:"M 121.40625 65.5625 C 120.45721 65.5625 119.6875 66.18524 119.6875 66.96875 L 119.6875 68.0625 C 119.6875 68.846 120.45721 69.46875 121.40625 69.46875 L 178.5625 69.46875 C 179.51154 69.46875 180.28125 68.846 180.28125 68.0625 L 180.28125 66.96875 C 180.28125 66.18524 179.51154 65.5625 178.5625 65.5625 L 121.40625 65.5625 z M 121.40625 103.4375 C 120.45721 103.4375 119.6875 104.06024 119.6875 104.84375 L 119.6875 105.9375 C 119.6875 106.721 120.45721 107.375 121.40625 107.375 L 178.5625 107.375 C 179.51154 107.375 180.28125 106.721 180.28125 105.9375 L 180.28125 104.84375 C 180.28125 104.06024 179.51154 103.4375 178.5625 103.4375 L 121.40625 103.4375 z",
bbox:{x:119.6875,y:65.5625,x2:180.28125,y2:107.375,width:60.59375,height:41.8125}},fullscreen:{string:"M25.545,23.328,17.918,15.623,25.534,8.007,27.391,9.864,29.649,1.436,21.222,3.694,23.058,5.53,15.455,13.134,7.942,5.543,9.809,3.696,1.393,1.394,3.608,9.833,5.456,8.005,12.98,15.608,5.465,23.123,3.609,21.268,1.351,29.695,9.779,27.438,7.941,25.6,15.443,18.098,23.057,25.791,21.19,27.638,29.606,29.939,27.393,21.5z",bbox:{x:1.351,y:1.394,x2:29.649,y2:29.939,width:28.298,height:28.545}},unfullscreen:{string:"M25.083,18.895l-8.428-2.259l2.258,8.428l1.838-1.837l7.053,7.053l2.476-2.476l-7.053-7.053L25.083,18.895zM5.542,11.731l8.428,2.258l-2.258-8.428L9.874,7.398L3.196,0.72L0.72,3.196l6.678,6.678L5.542,11.731zM7.589,20.935l-6.87,6.869l2.476,2.476l6.869-6.869l1.858,1.857l2.258-8.428l-8.428,2.258L7.589,20.935zM23.412,10.064l6.867-6.87l-2.476-2.476l-6.868,6.869l-1.856-1.856l-2.258,8.428l8.428-2.259L23.412,10.064z",
bbox:{x:.719,y:.718,x2:30.28,y2:30.28,width:29.561,height:29.562}},"widget-page":{string:"M170.166,421.825V156.714H409.5c0,0,0,133.5,0,165.25c0,50.953-70.109,33.833-70.109,33.833 s16.609,66.028-32,66.028C275.328,421.825,288.508,421.825,170.166,421.825z M449.5,320.417V116.714H130.166v345.111H308 C376.165,461.825,449.5,381.819,449.5,320.417z M97.5,420.942V85.333h311V50.175h-346v370.768H97.5z",bbox:{x:62.5,y:50.175,x2:449.5,y2:461.825,width:387,height:411.65},subboxName:"widget-page-inside"},"widget-page-inside":{string:"m 169.51387,157.63164 240.08073,0 0,263.09167 -240.08073,0 z",
bbox:{x:169.51387,y:157.63164,x2:409.5946,y2:420.72331,width:240.08073000000002,height:263.09167}},multiopen:{string:"m 130,73.862183 6.5,-13 6.5,13 z M 70.709141,37.871643 c -5.658849,0 -10.21875,4.412745 -10.21875,9.90625 l 0,43.3125 c 0,5.493505 4.559901,9.906247 10.21875,9.906247 l 44.624999,0 c 5.65885,0 10.21875,-4.412742 10.21875,-9.906247 l 0,-43.3125 c 0,-5.493505 -4.5599,-9.90625 -10.21875,-9.90625 l -44.624999,0 z m 2.0625,3.125 40.468749,0 c 5.12994,0 9.25,3.959703 9.25,8.90625 l 0,39 c 0,4.946547 -4.12006,8.9375 -9.25,8.9375 l -40.468749,0 c -5.129943,0 -9.25,-3.990953 -9.25,-8.9375 l 0,-39 c 0,-4.946547 4.120057,-8.90625 9.25,-8.90625 z",
bbox:{x:60.490391,y:37.871643,x2:143,y2:100.99664,width:82.509609,height:63.124997},subboxName:"multiopen-boxonly-inside"},"multiopen-boxonly":{string:"m 71.1875,38.25 c -5.658849,0 -10.21875,4.412745 -10.21875,9.90625 l 0,43.3125 c 0,5.493505 4.559901,9.90625 10.21875,9.90625 l 44.625,0 c 5.65885,0 10.21875,-4.412745 10.21875,-9.90625 l 0,-43.3125 c 0,-5.493505 -4.5599,-9.90625 -10.21875,-9.90625 l -44.625,0 z m 2.0625,3.125 40.46875,0 c 5.12994,0 9.25,3.959703 9.25,8.90625 l 0,39 c 0,4.946547 -4.12006,8.9375 -9.25,8.9375 l -40.46875,0 c -5.129943,0 -9.25,-3.990953 -9.25,-8.9375 l 0,-39 C 64,45.334703 68.120057,41.375 73.25,41.375 z",
bbox:{x:60.96875,y:38.25,x2:126.03125,y2:101.375,width:65.0625,height:63.125},subboxName:"multiopen-boxonly-inside"},"multiopen-boxonly-inside":{string:"m 73.259825,41.362183 40.445075,0 c 5.12994,0 9.25982,3.982238 9.25982,8.928785 l 0,38.999149 c 0,4.946547 -4.12988,8.928786 -9.25982,8.928786 l -40.445075,0 C 68.129882,98.218903 64,94.236664 64,89.290117 l 0,-38.999149 c 0,-4.946547 4.129882,-8.928785 9.259825,-8.928785 z",bbox:{x:64,y:41.362183,x2:122.96472,y2:98.218903,width:58.96472,height:56.85672}},
twostones:{string:"m 42.894737,29.335869 c 0,6.540213 -5.301891,11.842106 -11.842105,11.842106 -6.540214,0 -11.842105,-5.301893 -11.842105,-11.842106 0,-6.540214 5.301891,-11.842105 11.842105,-11.842105 6.540214,0 11.842105,5.301891 11.842105,11.842105 z M 31.052632,16.309553 c -7.194236,0 -13.026316,5.83208 -13.026316,13.026316 0,7.194233 5.83208,13.026314 13.026316,13.026314 3.733917,0 7.098575,-1.575815 9.473684,-4.092928 2.375029,2.516206 5.740532,4.092928 9.473684,4.092928 7.194235,0 13.026316,-5.832081 13.026316,-13.026314 0,-7.194236 -5.832081,-13.026316 -13.026316,-13.026316 -3.733152,0 -7.098655,1.56932 -9.473684,4.085526 -2.374906,-2.51483 -5.741698,-4.085526 -9.473684,-4.085526 z",
bbox:{x:18.026316,y:16.309553,x2:63.026316,y2:42.362183,width:45,height:26.05263}},bstone:{string:"m 105.05587,69.988831 a 23.738585,23.738585 0 1 1 -47.477171,0 23.738585,23.738585 0 1 1 47.477171,0 z",bbox:{x:57.578699,y:46.2148296,x2:105.05587,y2:93.7628323,width:47.477171,height:47.548002735}},wstone:{string:"M 107.5 37.375 C 81.266474 37.375 60 58.641474 60 84.875 C 60 111.10853 81.266474 132.375 107.5 132.375 C 133.73353 132.375 155 111.10853 155 84.875 C 155 58.641474 133.73353 37.375 107.5 37.375 z M 107.5 42.375 C 130.9721 42.375 150 61.402898 150 84.875 C 150 108.3471 130.9721 127.375 107.5 127.375 C 84.027898 127.375 65 108.3471 65 84.875 C 65 61.402898 84.027898 42.375 107.5 42.375 z",
bbox:{x:60,y:37.375,x2:155,y2:132.375,width:95,height:95}},bstone_a:{string:"M 107.5 37.375 C 81.266474 37.375 60 58.641474 60 84.875 C 60 111.10853 81.266474 132.375 107.5 132.375 C 133.73353 132.375 155 111.10853 155 84.875 C 155 58.641474 133.73353 37.375 107.5 37.375 z M 102.78125 52.53125 L 111.96875 52.53125 L 134.75 112.375 L 126.34375 112.375 L 120.90625 97 L 93.90625 97 L 88.46875 112.375 L 79.9375 112.375 L 102.78125 52.53125 z M 107.34375 60.5 L 96.375 90.28125 L 118.375 90.28125 L 107.34375 60.5 z",
bbox:{x:60,y:37.375,x2:155,y2:132.375,width:95,height:95}},bstone_1:{string:"M 107.5 37.375 C 81.266474 37.375 60 58.641474 60 84.875 C 60 111.10853 81.266474 132.375 107.5 132.375 C 133.73353 132.375 155 111.10853 155 84.875 C 155 58.641474 133.73353 37.375 107.5 37.375 z M 106.96875 52.4375 L 116.21875 52.4375 L 116.21875 112.21875 L 104.8125 112.21875 L 104.8125 69.21875 C 100.64371 73.116859 95.751353 75.975961 90.09375 77.84375 L 90.09375 67.5 C 93.071433 66.525528 96.289216 64.675791 99.78125 61.96875 C 103.27325 59.23474 105.66937 56.064927 106.96875 52.4375 z",
bbox:{x:60,y:37.375,x2:155,y2:132.375,width:95,height:95}},bstone_triangle:{string:"M 107.5 37.375 C 81.266474 37.375 60 58.641474 60 84.875 C 60 111.10853 81.266474 132.375 107.5 132.375 C 133.73353 132.375 155 111.10853 155 84.875 C 155 58.641474 133.73353 37.375 107.5 37.375 z M 107.8125 45.875 L 143.28125 107.3125 L 72.375 107.3125 L 107.8125 45.875 z M 107.78125 54.53125 L 80.3125 102.15625 L 135.28125 102.15625 L 107.78125 54.53125 z",bbox:{x:60,y:37.375,x2:155,y2:132.375,width:95,height:95}},
bstone_square:{string:"M 107.5 37.375 C 81.266474 37.375 60 58.641474 60 84.875 C 60 111.10853 81.266474 132.375 107.5 132.375 C 133.73353 132.375 155 111.10853 155 84.875 C 155 58.641474 133.73353 37.375 107.5 37.375 z M 76.0625 53.40625 L 139.21875 53.40625 L 139.21875 116.5625 L 76.0625 116.5625 L 76.0625 53.40625 z M 80.15625 57.59375 L 80.15625 112.34375 L 134.875 112.34375 L 134.875 57.59375 L 80.15625 57.59375 z",bbox:{x:60,y:37.375,x2:155,y2:132.375,width:95,height:95}},eraser:{string:"M 115 32.375 L 70.21875 87.40625 L 95.15625 112.375 L 140 57.375 L 115 32.375 z M 115 38.25 L 135 57.375 L 95 107.375 L 75 87.375 L 115 38.25 z",
bbox:{x:70.21875,y:37.375,x2:140,y2:112.375,width:69.78125,height:80}},"nostone-xmark":{string:"M462,256c0,113.771-92.229,206-206,206S50,369.771,50,256S142.229,50,256,50S462,142.229,462,256z M422,256c0-91.755-74.258-166-166-166c-91.755,0-166,74.259-166,166c0,91.755,74.258,166,166,166C347.755,422,422,347.741,422,256z M325.329,362.49l-67.327-67.324l-67.329,67.332l-36.164-36.186l67.314-67.322l-67.321-67.317l36.185-36.164l67.31,67.301 l67.3-67.309l36.193,36.17l-67.312,67.315l67.32,67.31L325.329,362.49z",
bbox:{x:50,y:50,x2:462,y2:462,width:412,height:412}},simpletriangleup:{string:"M256,77.599 L462,434.4 L50,434.4Z",bbox:{x:50,y:77.599,x2:462,y2:434.4,width:412,height:356.801}},simpletriangledown:{string:"M256,434.4 L462,77.599 L50,77.599Z",bbox:{x:50,y:77.599,x2:462,y2:434.4,width:412,height:356.801}}};glift.displays.icons.wrappedIcon=function(a){return new glift.displays.icons.WrappedIcon(a)};glift.displays.icons.wrapIcons=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];if("string"===glift.util.typeOf(d))b.push(glift.displays.icons.wrappedIcon(d));else if("array"===glift.util.typeOf(d)){for(var e=glift.displays.icons.wrappedIcon("multiopen"),f=0;f<d.length;f++)e.addAssociatedIcon(d[f]);b.push(e)}}return b};
glift.displays.icons.validateIcon=function(a){if(void 0===a||void 0===glift.displays.icons.svg[a])throw Error("Icon unknown: ["+a+"]");return a};
glift.displays.icons.WrappedIcon=function(a){this.iconName=glift.displays.icons.validateIcon(a);a=glift.displays.icons.svg[a];this.iconStr=a.string;this.originalBbox=glift.orientation.bbox.fromPts(glift.util.point(a.bbox.x,a.bbox.y),glift.util.point(a.bbox.x2,a.bbox.y2));this.associatedIcons=[];this.activeAssociated=0;this.bbox=this.originalBbox;this.subboxIcon=this.elementId=this.transformObj=void 0;void 0!==a.subboxName&&this.setSubboxIcon(a.subboxName)};
glift.displays.icons.WrappedIcon.prototype={addAssociatedIcon:function(a){a=glift.displays.icons.wrappedIcon(a);this.associatedIcons.push(a);return a},_addAssociatedWrapped:function(a){if(void 0===a.originalBbox)throw"Wrapped icon not actually a wrapped icon: "+a;this.associatedIcons.push(a);return a},clearAssociatedIcons:function(){var a=this.associatedIcons;this.associatedIcons=[];return a},getAssociated:function(a){a=a||this.activeAssociated;return this.associatedIcons[a]},getActive:function(){return this.associatedIcons[this.activeAssociated]},
setActive:function(a){for(var b=0,c=this.associatedIcons.length;b<c;b++)this.associatedIcons[b].iconName===a&&(this.activeAssociated=b);return this},setElementId:function(a){this.elementId=a;return this},setSubboxIcon:function(a){return this.subboxIcon=glift.displays.icons.wrappedIcon(a)},centerWithinSubbox:function(a,b,c){if(void 0===this.subboxIcon)throw"No subbox defined, so cannot centerWithin.";b=glift.displays.gui.centerWithin(this.subboxIcon.bbox,a.bbox,b,c);a.performTransform(b.transform);
return a},centerWithinIcon:function(a,b,c){b=glift.displays.gui.centerWithin(this.bbox,a.bbox,b,c);a.performTransform(b.transform);return a},performTransform:function(a){a.scale&&(this.bbox=this.bbox.scale(a.scale));a.xMove&&a.yMove&&(this.bbox=this.bbox.translate(a.xMove,a.yMove));void 0!==this.subboxIcon&&this.subboxIcon.performTransform(a);this.transformObj=a;return this},resetTransform:function(){this.bbox=this.originalBbox;this.transformObj=void 0;return this},transformString:function(){return void 0!=
this.transformObj?"translate("+this.transformObj.xMove+","+this.transformObj.yMove+") scale("+this.transformObj.scale+")":""},rewrapIcon:function(){return glift.displays.icons.wrappedIcon(this.iconName)}};glift.displays.svg={};glift.displays.board.boardBase=function(a,b,c,d){if(null===c)throw Error("goBox null: Gui Environment obj not initialized");d.board.imagefill&&a.append(glift.displays.svg.image().setAttr("x",c.topLeft().x()).setAttr("y",c.topLeft().y()).setAttr("width",c.width()).setAttr("height",c.height()).setAttr("xlink:href",d.board.imagefill).setAttr("preserveAspectRatio","none"));a.append(glift.displays.svg.rect().setAttr("x",c.topLeft().x()+"px").setAttr("y",c.topLeft().y()+"px").setAttr("width",c.width()+
"px").setAttr("height",c.height()+"px").setAttr("height",c.height()+"px").setAttr("fill",d.board.imagefill?"none":d.board.fill).setAttr("stroke",d.board.stroke).setAttr("stroke-width",d.board["stroke-width"]).setId(b.board()))};glift.displays.board.initBlurFilter=function(a,b){};glift.displays.svg.pathutils={move:function(a,b){return"M"+a+" "+b},movePt:function(a){return glift.displays.svg.pathutils.move(a.x(),a.y())},lineRel:function(a,b){return"l"+a+" "+b},lineRelPt:function(a){return glift.displays.svg.pathutils.lineRel(a.x(),a.y())},lineAbs:function(a,b){return"L"+a+" "+b},lineAbsPt:function(a){return glift.displays.svg.pathutils.lineAbs(a.x(),a.y())}};glift.displays.svg.createObj=function(a,b){return new glift.displays.svg.SvgObj(a,b)};glift.displays.svg.svg=function(a){return(new glift.displays.svg.SvgObj("svg",a)).setAttr("version","1.1").setAttr("xmlns","http://www.w3.org/2000/svg")};glift.displays.svg.circle=function(a){return new glift.displays.svg.SvgObj("circle",a)};glift.displays.svg.path=function(a){return new glift.displays.svg.SvgObj("path",a)};glift.displays.svg.rect=function(a){return new glift.displays.svg.SvgObj("rect",a)};
glift.displays.svg.image=function(a){return new glift.displays.svg.SvgObj("image",a)};glift.displays.svg.text=function(a){return new glift.displays.svg.SvgObj("text",a)};glift.displays.svg.group=function(){return new glift.displays.svg.SvgObj("g")};glift.displays.svg.SvgObj=function(a,b){this.type_=a;this.attrMap_=b||{};this.children_=[];this.idMap_={};this.text_="";this.data_=null};
glift.displays.svg.SvgObj.prototype={attachToParent:function(a){(a=document.getElementById(a))&&a.appendChild(this.asElement())},removeFromDom:function(){if(this.id()){var a=document.getElementById(this.idOrThrow());a&&a.parentNode.removeChild(a)}return this},asElement:function(){var a=document.createElementNS("http://www.w3.org/2000/svg",this.type_),b;for(b in this.attrMap_)"xlink:href"===b?a.setAttributeNS("http://www.w3.org/1999/xlink","href",this.attrMap_[b]):a.setAttribute(b,this.attrMap_[b]);
"text"===this.type_&&(b=document.createTextNode(this.text_),a.appendChild(b));b=0;for(var c=this.children_.length;b<c;b++)a.appendChild(this.children_[b].asElement());return a},render:function(){var a="<"+this.type_,b;for(b in this.attrMap_)a+=" "+b+'="'+this.attrMap_[b]+'"';a+=">"+this.text_;if(0<this.children_.length){a=[a];b=0;for(var c=this.children_.length;b<c;b++)a.push(this.children_[b].render());a.push("</"+this.type_+">");a=a.join("\n")}else a+="</"+this.type_+">";return a},attr:function(a){return this.attrMap_[a]},
setAttr:function(a,b){this.attrMap_[a]=b;return this},id:function(){return this.attrMap_.id||null},idOrThrow:function(){if(null==this.id())throw Error("ID was null; expected to be non-null");return this.id()},setId:function(a){a&&(this.attrMap_.id=a);return this},attrObj:function(){return this.attrMap_},setAttrObj:function(a){if("object"!==glift.util.typeOf(a))throw Error("Attr obj must be of type object");this.attrMap_=a;return this},updateAttrInDom:function(a){var b=this.id();if(b){if((b=document.getElementById(b))&&
a&&this.attr(a)){var c=this.attr(a);b.setAttribute(a,c)}}else throw Error("No ID present: could not update the dom:"+b);return this},data:function(a){return this.data_},setData:function(a){this.data_=a;return this},text:function(a){return this.text_},setText:function(a){this.text_=a;return this},child:function(a){return this.idMap_[a]},rmChild:function(a){delete this.idMap_[a];return this},children:function(){return this.children_},emptyChildren:function(){this.children_=[];return this},emptyChildrenAndUpdate:function(){this.emptyChildren();
for(var a=document.getElementById(this.idOrThrow());a&&a.firstChild;)a.removeChild(a.firstChild);return this},append:function(a){void 0!==a.id()&&(this.idMap_[a.id()]=a);this.children_.push(a);return this},appendNew:function(a,b){var c=glift.displays.svg.createObj(a,b);return this.append(c)},appendAndAttach:function(a){this.append(a);this.id()&&a.attachToParent(this.idOrThrow());return this},copyNoChildren:function(){var a={},b;for(b in this.attrMap_)a[b]=this.attrMap_[b];return glift.displays.svg.createObj(this.type_,
a)}};glift.displays.statusbar={create:function(a){return new glift.displays.statusbar.StatusBar(a.iconBarPrototype,a.theme,a.widget,a.allPositioning)}};glift.displays.statusbar.StatusBar=function(a,b,c,d){this.iconBar=a;this.theme=b;this.widget=c;this.positioning=d;this.totalPages=c.manager.sgfCollection.length;this.pageIndex=c.manager.sgfColIndex+1};
glift.displays.statusbar.StatusBar.prototype={draw:function(){this.iconBar.draw();this.setPageNumber(this.pageIndex,this.totalPages);return this},setMoveNumber:function(a){if(this.iconBar.hasIcon("move-indicator")){var b=this.theme.statusBar.icons.DEFAULT.fill;this.iconBar.addTempText("move-indicator",(a||"0")+"",{fill:b,stroke:b},null)}},setPageNumber:function(a,b){if(this.iconBar.hasIcon("widget-page")){var c=this.theme.statusBar.icons.DEFAULT.fill;this.iconBar.addTempText("widget-page",(a||"0")+
"",{fill:c,stroke:c},.85)}}};glift.displays.statusbar.StatusBar.prototype.fullscreen=function(){var a=this.widget,b=a.wrapperDivId+"_fullscreen",c=glift.dom.newDiv(b),d=a.getCurrentState(),e=a.manager,f=document.body;if(null==f)throw Error("document.body was null, but it must not be null for fullscreen to work");var f=glift.dom.elem(f),g=glift.obj.flatMerge({position:"absolute",top:"0px",bottom:"0px",left:"0px",right:"0px",margin:"0px",padding:"0px","z-index":11E4},this.theme.statusBar.fullscreen);c.css(g);f.addClass("glift-fullscreen-no-scroll").append(c);
e.prevScrollTop=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop||null;window.scrollTo(0,0);e.fullscreenDivId=b;a.destroy();a.wrapperDivId=b;a.draw();a.applyState(d);e.enableFullscreenAutoResize()};
glift.displays.statusbar.StatusBar.prototype.unfullscreen=function(){if(this.widget.manager.isFullscreen()){var a=this.widget,b=glift.dom.elem(a.wrapperDivId),c=a.getCurrentState(),d=a.manager,e=glift.dom.elem(document.body);a.destroy();b.remove();a.wrapperDivId=a.manager.divId;window.scrollTo(0,d.prevScrollTop||0);e.removeClass("glift-fullscreen-no-scroll");d.fullscreenDivId=null;d.prevScrollTop=null;a.draw();a.applyState(c);a.manager.disableFullscreenAutoResize()}};glift.displays.statusbar.StatusBar.prototype.gameInfo=function(a,b){var c=glift.displays.statusbar.infoWindow(this.widget.wrapperDivId,this.positioning.fullWidgetBbox(),this.theme.statusBar.gameInfo,this.widget.manager.id);a=[{displayName:"Captured White Stones",value:b.WHITE},{displayName:"Captured Black Stones",value:b.BLACK}].concat(a);for(var d=[],e=0;e<a.length;e++){var f=a[e];d.push("<strong>"+f.displayName+": </strong>"+f.value)}e=this.theme.statusBar.gameInfo;c.textDiv.append(glift.dom.newElem("h3").appendText("Game Info").css(glift.obj.flatMerge(e.textTitle,
e.text))).append(glift.dom.convertText(d.join("\n"),!1,glift.obj.flatMerge(e.textBody,e.text))).css({padding:"10px"});c.finish()};glift.displays.statusbar.infoWindow=function(a,b,c,d){var e=a+"_info_window_wrapper",f=glift.dom.elem(a),g=glift.dom.absBboxDiv(b,e);g.css({"z-index":100});a=glift.dom.newDiv(a+"_info_window_textdiv");b=glift.obj.flatMerge({position:"relative",margin:"0px",padding:"0px","overflow-y":"auto",height:b.height()+"px",width:b.width()+"px",MozBoxSizing:"border-box",boxSizing:"border-box"},c.textDiv);a.css(b);var h=function(){g.remove()};if(glift.platform.isMobile())a.on("touchend",h);else a.on("click",h);
var k=glift.keyMappings.getFuncOrIcon(d,"ESCAPE");glift.keyMappings.registerKeyAction(d,"ESCAPE",function(){h();k&&glift.keyMappings.registerKeyAction(d,"ESCAPE",k)});return new glift.displays.statusbar.InfoWindow(f,g,a)};glift.displays.statusbar.InfoWindow=function(a,b,c){this.wrapperDiv_=a;this.baseStatusDiv_=b;this.textDiv=c};glift.displays.statusbar.InfoWindow.prototype={finish:function(){this.baseStatusDiv_.append(this.textDiv);this.wrapperDiv_.prepend(this.baseStatusDiv_)}};glift.displays.position={};glift.displays.position.WidgetBoxes=function(){this._second=this._first=null};
glift.displays.position.WidgetBoxes.prototype={setFirst:function(a){this._first=a},setSecond:function(a){this._second=a},first:function(){return this._first},second:function(a){return this._second},getBbox:function(a){return this._first&&this._first.mapping[a]?this._first.mapping[a]:this._second&&this._second.mapping[a]?this._second.mapping[a]:null},mustGetBbox:function(a){var b=this.getBbox(a);if(null==b)throw Error("Column was null for component: "+a);return b},map:function(a){if("function"===glift.util.typeOf(a)){var b=
function(a,b){for(var e=a.ordering,f=0;f<e.length;f++){var g=e[f];b(g,a.mapping[g])}}.bind(this);this._first&&b(this._first,a.bind(this));this._second&&b(this._second,a.bind(this))}},fullWidgetBbox:function(){var a=null,b=null,c=null,d=null;this.map(function(e,f){null===a?(a=f.top(),b=f.left(),c=f.bottom(),d=f.right()):(f.top()<a&&(a=f.top()),f.left()<b&&(b=f.left()),f.bottom()>c&&(c=f.bottom()),f.right()>d&&(d=f.right()))});return null!==a&&null!==b&&null!==c&&null!==d?glift.orientation.bbox.fromPts(glift.util.point(b,
a),glift.util.point(d,c)):null}};glift.displays.position.WidgetColumn=function(){this.mapping={};this.ordering=[]};
glift.displays.position.WidgetColumn.prototype={setComponent:function(a,b){if(!glift.enums.boardComponents[a])throw Error("Unknown component: "+a);this.mapping[a]=b;return this},getBbox:function(a){return this.mapping[a]||null},mustGetBbox:function(a){var b=this.getBbox(a);if(null==b)throw Error("Bbox was null for component: "+a);return b},setOrderingFromRatioArray:function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];d&&d.component&&b.push(d.component)}this.ordering=b;return this},orderFn:function(a){for(var b=
0;b<this.ordering.length;b++)a(this.ordering[b])}};glift.displays.position.positioner=function(a,b,c,d,e,f){if(!a)throw Error("No Div box. ["+a+"]");if(!b||!glift.enums.boardRegions[b])throw Error("Invalid Board Region. ["+b+"]");if(!c)throw Error("No intersections. ["+c+"]");if(!e)throw Error("No one col splits. ["+e+"]");if(!f)throw Error("No two col splits. ["+f+"]");return new glift.displays.position.WidgetPositioner(a,b,c,d,e,f)};
glift.displays.position.WidgetPositioner=function(a,b,c,d,e,f){this.divBox=a;this.boardRegion=b;this.ints=c;this.compsToUse=d;this.oneColSplits=e;this.twoColSplits=f;this.componentSet=this._getComponentSet();this.cropbox=glift.displays.cropbox.getFromRegion(b,c)};
glift.displays.position.WidgetPositioner.prototype={calcWidgetPositioning:function(){return this.useHorzOrientation()?this.calcHorzPositioning():this.calcVertPositioning()},useHorzOrientation:function(){var a=this.divBox,b=this.boardRegion,c=this.componentSet,d=glift.enums.boardComponents,a=a.height()/a.width(),e={TOP:!0,BOTTOM:!0};return c[d.COMMENT_BOX]&&c[d.BOARD]?.45>a&&e[b]?!0:.8>a&&!e[b]?!0:!1:!1},calcVertPositioning:function(){var a=this.recalcSplits(this.oneColSplits).first,b=new glift.displays.position.WidgetBoxes;
b.setFirst(this.calculateColumn(a,this.divBox,glift.enums.boardAlignments.TOP,0));return b},calcHorzPositioning:function(){var a=this.recalcSplits(this.twoColSplits),b=this.splitDivBoxHoriz(),c=new glift.displays.position.WidgetBoxes;c.setFirst(this.calculateColumn(a.first,b[0],glift.enums.boardAlignments.RIGHT,0));c.setSecond(this.calculateColumn(a.second,b[1],null,c.first().getBbox(c.first().ordering[0]).top()));return c},calculateColumn:function(a,b,c,d){var e=d||0,f=new glift.displays.position.WidgetColumn,
g=glift.enums.boardComponents;d=[b];var h=this._extractRatios(a);f.setOrderingFromRatioArray(a);1<h.length&&(d=b.hSplit(h.slice(0,h.length-1)));for(var k={},h=0;h<a.length;h++)k[a[h].component]=d[h];var l=null;k.BOARD&&(l=glift.displays.getResizedBox(k.BOARD,this.cropbox,c),f.setComponent(g.BOARD,l));var m=l?l.width():b.width(),n=l?l.left():b.left();f.orderFn(function(a){if(a===g.BOARD)e+=l.height();else{var b=k[a],b=glift.orientation.bbox.fromSides(glift.util.point(n,e),m,b.height());f.setComponent(a,
b);e+=b.height()}}.bind(this));return f},recalcSplits:function(a){var b={},c=this.componentSet,d;for(d in a){for(var e=a[d],f=[],g=0,h=0;h<e.length;h++){var k=e[h];c[k.component]&&(f.push({component:k.component,ratio:k.ratio}),g+=k.ratio)}for(h=0;h<f.length;h++)k=f[h],k.ratio/=g;b[d]=f}return b},splitDivBoxHoriz:function(){var a=glift.displays.getResizedBox(this.divBox,this.cropbox,glift.enums.boardAlignments.RIGHT),b=.5*a.width(),c=.75*a.width(),d=this.divBox.width()-a.width(),e=.75;d<b?e=.5:d>=
b&&d<c&&(e=d/a.width());b=e*a.width();a=a.width()/(b+a.width());a=this.divBox.vSplit([a]);b=glift.displays.getResizedBox(a[0],this.cropbox,glift.enums.boardAlignments.RIGHT);c=glift.orientation.bbox.fromPts(glift.util.point(a[1].topLeft().x(),b.topLeft().y()),glift.util.point(a[1].botRight().x(),b.botRight().y()));a[1].width()>.75*b.width()&&(c=c.vSplit([.75*b.width()/c.width()])[0]);a[1]=c;return a},_getComponentSet:function(){for(var a={},b=0;b<this.compsToUse.length;b++)a[this.compsToUse[b]]=!0;
return a},_extractRatios:function(a){for(var b=[],c=0;c<a.length;c++)b.push(a[c].ratio);return b}};glift.rules={};glift.rules.prop={AB:"AB",AE:"AE",AN:"AN",AP:"AP",AR:"AR",AS:"AS",AW:"AW",B:"B",BL:"BL",BM:"BM",BR:"BR",BS:"BS",BT:"BT",C:"C",CA:"CA",CH:"CH",CP:"CP",CR:"CR",DD:"DD",DM:"DM",DO:"DO",DT:"DT",EL:"EL",EV:"EV",EX:"EX",FF:"FF",FG:"FG",GB:"GB",GC:"GC",GM:"GM",GN:"GN",GW:"GW",HA:"HA",HO:"HO",ID:"ID",IP:"IP",IT:"IT",IY:"IY",KM:"KM",KO:"KO",L:"L",LB:"LB",LN:"LN",LT:"LT",M:"M",MA:"MA",MN:"MN",N:"N",OB:"OB",OH:"OH",OM:"OM",ON:"ON",OP:"OP",OT:"OT",OV:"OV",OW:"OW",PB:"PB",PC:"PC",PL:"PL",PM:"PM",PW:"PW",RE:"RE",
RG:"RG",RO:"RO",RU:"RU",SC:"SC",SE:"SE",SI:"SI",SL:"SL",SO:"SO",SQ:"SQ",ST:"ST",SU:"SU",SZ:"SZ",TB:"TB",TC:"TC",TE:"TE",TM:"TM",TR:"TR",TW:"TW",UC:"UC",US:"US",V:"V",VW:"VW",W:"W",WL:"WL",WR:"WR",WS:"WS",WT:"WT",MU:"MU"};glift.rules.autonumber=function(a){var b=/\d+/,c=/0\d/;a.recurseFromRoot(function(a){if(a.properties().getComment()){for(var e=a.properties().getAllValues(glift.rules.prop.LB),f={},g=0;e&&g<e.length;g++){var h=e[g].split(":");b.test(h[1])||(f[h[0]]=h[1])}for(var g=glift.rules.treepath.findNextMovesPath(a),h=g.movetree,k=glift.rules.goban.getFromMoveTree(h).goban,e=a.onMainline()?h.node().getNodeNum()+1:h.movesToMainline()+1,k=glift.rules.treepath.applyNextMoves(h,k,g.nextMoves),g=h=0,k=k.stones;g<
k.length;g++){var l=k[g];l.collision||(l=l.point.toSgfCoord(),f[l]=e+h,h++)}var e=[],m;for(m in f)g=f[m]+"",2<g.length&&(h=g.substring(g.length-2,g.length),"00"!==h&&(g=h),2===g.length&&c.test(g)&&(g=g.charAt(g.length-1))),e.push(m+":"+g);0===e.length?a.properties().remove(glift.rules.prop.LB):a.properties().set(glift.rules.prop.LB,e);glift.rules.removeCollidingLabels(a,f)}})};
glift.rules.removeCollidingLabels=function(a,b){for(var c=["TR","SQ"],d=0;d<c.length;d++){var e=c[d];if(a.properties().contains(e)){for(var f=a.properties().getAllValues(e),g=[],h=0;h<f.length;h++){var k=f[h];b[k]||g.push(k)}0===g.length?a.properties().remove(e):a.properties().set(e,g)}}};
glift.rules.clearnumbers=function(a){var b=/\d+/;a.recurseFromRoot(function(a){if(a.properties().contains(glift.rules.prop.LB)){for(var d=a.properties().getAllValues(glift.rules.prop.LB),e=[],f=0;d&&f<d.length;f++){var g=d[f].split(":");b.test(g[1])||e.push(d[f])}0===e.length?a.properties().remove(glift.rules.prop.LB):a.properties().set(glift.rules.prop.LB,e)}})};glift.rules.goban={getInstance:function(a){return new glift.rules.Goban(a||19)},getFromMoveTree:function(a,b){var c=b||a.treepathToHere(),d=new glift.rules.Goban(a.getIntersections()),e=a.getTreeFromRoot(),f=[];d.loadStonesFromMovetree(e);for(var g=0;g<c.length&&0<e.node().numChildren();g++)e.moveDown(c[g]),f.push(d.loadStonesFromMovetree(e));return{goban:d,captures:f}}};
glift.rules.Goban=function(a){if(!a||0>=a)throw Error("Invalid Intersections. Was: "+a);this.ints_=a;this.stones_=glift.rules.initStones_(a);this.koPoint_=null};
glift.rules.Goban.prototype={intersections:function(){return this.ints_},setKo:function(a){a&&this.inBounds_(a)&&(this.koPoint_=a)},clearKo:function(){this.koPoint_=null},getKo:function(){return this.koPoint_},placeable:function(a){return this.inBounds_(a)&&this.getStone(a)===glift.enums.states.EMPTY},getStone:function(a){return this.stones_[a.y()][a.x()]},getAllPlacedStones:function(){for(var a=[],b=0;b<this.intersections();b++)for(var c=0;c<this.intersections();c++){var d=this.getStone(glift.util.point(c,
b));d!==glift.enums.states.BLACK&&d!==glift.enums.states.WHITE||a.push({point:glift.util.point(c,b),color:d})}return a},clearStone:function(a){this.clearKo();this.setColor_(glift.enums.states.EMPTY,a)},clearSome:function(a){for(var b=0;b<a.length;b++)this.clearStone(a[b])},testAddStone:function(a,b){var c=this.getKo(),d=this.addStone(a,b);null!==c&&this.setKo(c);if(d.successful){this.clearStone(a);for(var c=glift.util.colors.oppositeColor(b),e=0;e<d.captures.length;e++)this.setColor_(c,d.captures[e])}return d.successful},
addStone:function(a,b){if(!glift.util.colors.isLegalColor(b))throw"Unknown color: "+b;if(this.outBounds_(a)||!this.placeable(a))return new glift.rules.StoneResult(!1);this.setColor_(b,a);var c=this.findCapturedGroups_(a,b);if(0===c.length){var d=this.findConnected_(a,b);if(0===d.liberties)return this.clearStone(a),new glift.rules.StoneResult(!1)}this.clearKo();for(var e=[],f=0;f<c.length;f++)for(var d=c[f],g=0;g<d.group.length;g++){var h=d.group[g].point;e.push(h);this.clearStone(h)}return 1===e.length&&
(d=glift.util.colors.oppositeColor(b),c=e[0],this.setColor_(d,c),d=this.findCapturedGroups_(c,d),this.clearStone(c),1===d.length&&(d=d[0],1===d.group.length&&d.group[0].point.equals(a)))?(this.setKo(c),new glift.rules.StoneResult(!0,e,c)):new glift.rules.StoneResult(!0,e)},loadStonesFromMovetree:function(a){for(var b=[glift.enums.states.BLACK,glift.enums.states.WHITE],c={BLACK:[],WHITE:[]},d=0;d<b.length;d++)for(var e=b[d],f=a.properties().getPlacementsAsPoints(e),g=0,h=f.length;g<h;g++)this.loadStone_({point:f[g],
color:e},c);this.loadStone_(a.properties().getMove(),c);return c},setColor_:function(a,b){this.stones_[b.y()][b.x()]=a},outBounds_:function(a){return glift.util.outBounds(a.x(),this.intersections())||glift.util.outBounds(a.y(),this.intersections())},inBounds_:function(a){return glift.util.inBounds(a.x(),this.intersections())&&glift.util.inBounds(a.y(),this.intersections())},cardinals_:{left:glift.util.point(-1,0),right:glift.util.point(1,0),up:glift.util.point(0,-1),down:glift.util.point(0,1)},neighbors_:function(a){var b=
glift.util.point,c=[],d;for(d in this.cardinals_){var e=this.cardinals_[d],e=b(a.x()+e.x(),a.y()+e.y());this.inBounds_(e)&&c.push(e)}return c},findConnected_:function(a,b){for(var c=new glift.rules.ConnectedGroup(b),d=[a];0<d.length;){var e=d.pop();if(!c.hasSeen(e)){var f=this.getStone(e);if(f===b){c.addStone(e,b);for(var e=this.neighbors_(e),g=0;g<e.length;g++)d.push(e[g])}f===glift.enums.states.EMPTY&&c.addLiberty()}}return c},findCapturedGroups_:function(a,b){for(var c=glift.util.colors.oppositeColor(b),
d=[],e=this.neighbors_(a),f=0;f<e.length;f++){for(var g=e[f],h=!1,k=0;k<d.length;k++){var l=d[k];if(l.hasSeen(g)){h=!0;break}}h||(l=this.findConnected_(g,c),l.group.length&&d.push(l))}c=[];for(f=0;f<d.length;f++)l=d[f],0===l.liberties&&c.push(l);return c},loadStone_:function(a,b){if(a&&void 0!==a.point){var c=this.addStone(a.point,a.color);if(c.successful)for(var d=glift.util.colors.oppositeColor(a.color),e=0;e<c.captures.length;e++)b[d].push(c.captures[e])}}};
glift.rules.initStones_=function(a){for(var b=[],c=0;c<a;c++){for(var d=[],e=0;e<a;e++)d[e]=glift.enums.states.EMPTY;b[c]=d}return b};glift.rules.ConnectedGroup=function(a){this.color=a;this.liberties=0;this.seen={};this.group=[]};
glift.rules.ConnectedGroup.prototype={hasSeen:function(a){return this.seen[a.toString()]},addStone:function(a,b){this.seen[a.toString()]||this.color!==b||(this.seen[a.toString()]=!0,this.group.push({point:a,color:b}));return this},addLiberty:function(){this.liberties+=1;return this}};glift.rules.StoneResult=function(a,b,c){this.successful=a;this.captures=b||[];this.koPt=c||null};glift.rules.movenode=function(a,b,c,d){return new glift.rules.MoveNode(a,b,c,d)};glift.rules.MoveNode=function(a,b,c,d){this._properties=a||glift.rules.properties();this.children=b||[];this._nodeId=c||{nodeNum:0,varNum:0};this._parentNode=d;this._mainline=!1};
glift.rules.MoveNode.prototype={properties:function(){return this._properties},_setNodeId:function(a,b){this._nodeId={nodeNum:a,varNum:b};return this},getNodeNum:function(){return this._nodeId.nodeNum},getVarNum:function(){return this._nodeId.varNum},numChildren:function(){return this.children.length},getIntersection:function(){for(var a=["B","W"],b=0;b<a.length;b++){var c=a[b];if(void 0!=this._properties.propMap[c])return this._properties.propMap[c]}},addChild:function(){this.children.push(glift.rules.movenode(glift.rules.properties(),
[],{nodeNum:this.getNodeNum()+1,varNum:this.numChildren()},this));return this},getChild:function(a){return 0<this.children.length?this.children[a||0]:null},getParent:function(){return this._parentNode?this._parentNode:null},renumber:function(){numberMoves(this,this._nodeId.nodeNum,this._nodeId.varNum);return this}};var numberMoves=function(a,b,c){a._setNodeId(b,c);for(c=0;c<a.children.length;c++)numberMoves(a.children[c],b+1,c);return a};glift.rules.movetree={getInstance:function(a){var b=new glift.rules.MoveTree(glift.rules.movenode());void 0!==a&&b._setIntersections(a);return b},getFromSgf:function(a,b,c){b=b||[];var d=d||glift.parse.parseType.SGF;if("string"===glift.util.typeOf(b)||"number"===glift.util.typeOf(b))b=glift.rules.treepath.parsePath(b);if(void 0===a||""===a)return glift.rules.movetree.getInstance(19);glift.util.majorPerfLog("Before SGF parsing in movetree");a=glift.parse.fromString(a,d);a=a.getTreeFromRoot(b);glift.util.majorPerfLog("After SGF parsing in movetree");
return a},searchMoveTreeDFS:function(a,b){b(a);for(var c=0;c<a.node().numChildren();c++){var d=a.newTreeRef();glift.rules.movetree.searchMoveTreeDFS(d.moveDown(c),b)}},initRootProperties:function(a){var b=a.getTreeFromRoot().properties(),c=glift.rules.prop;b.contains(c.GM)||b.add(c.GM,"1");b.contains(c.FF)||b.add(c.FF,"4");b.contains(c.CA)||b.add(c.CA,"UTF-8");b.contains(c.AP)||b.add(c.AP,"Glift:"+glift.global.version);b.contains(c.KM)||b.add(c.KM,"0.00");b.contains(c.RU)||b.add(c.RU,"Japanese");
b.contains(c.SZ)||b.add(c.SZ,"19");b.contains(c.PB)||b.add(c.PB,"Black");b.contains(c.PW)||b.add(c.PW,"White");return a}};glift.rules.MoveTree=function(a,b,c){this.rootNode_=a;this.currentNode_=b||a;this.markedMainline_=!1;this.metadata_=c||null};
glift.rules.MoveTree.prototype={node:function(){return this.currentNode_},properties:function(){return this.node().properties()},metadata:function(){return this.metadata_},setMetdata:function(a){this.metadata_=a;return this},moveDown:function(a){a=a||0;void 0!==this.node().getChild(a)&&(this.currentNode_=this.node().getChild(a));return this},moveUp:function(){var a=this.currentNode_.getParent();a&&(this.currentNode_=a);return this},getCurrentPlayer:function(){var a=glift.enums.states,b={W:"WHITE",
B:"BLACK"},c=this.currentNode_;if(this.properties().contains(glift.rules.prop.PL))return b[this.properties().getOneValue(glift.rules.prop.PL)];for(b=c.properties().getMove();!b;){c=c.getParent();if(!c)return a.BLACK;b=c.properties().getMove()}return b?b.color===a.BLACK?a.WHITE:a.BLACK:a.BLACK},newTreeRef:function(){return new glift.rules.MoveTree(this.rootNode_,this.currentNode_,this.metadata_)},getFromNode:function(a){return new glift.rules.MoveTree(a,a,this.metadata_)},getTreeFromRoot:function(a){var b=
this.getFromNode(this.rootNode_);if(a&&"array"===glift.util.typeOf(a))for(var c=0,d=a.length;c<d&&0<b.node().numChildren();c++)b.moveDown(a[c]);return b},addNode:function(){this.node().addChild();this.moveDown(this.node().numChildren()-1);return this},deleteNode:function(){throw"Unfinished";},findNextMove:function(a,b){for(var c=this.node().children,d=glift.sgf.colorToToken(b),e={},f=0;f<c.length;f++){var g=c[f];g.properties().contains(d)&&""!=g.properties().getOneValue(d)&&(e[g.properties().getAsPoint(d).toString()]=
g.getVarNum())}return void 0!==e[a.toString()]?e[a.toString()]:null},getIntersections:function(){var a=this.getTreeFromRoot(),b=glift.rules.prop;return a.properties().contains(b.SZ)?parseInt(a.properties().getAllValues(b.SZ),10):19},getLastMove:function(){return this.properties().getMove()},movesToMainline:function(){for(var a=this.newTreeRef(),b=0;!a.onMainline()&&a.node().getParent();b++)a.moveUp();return b},getMainlineNode:function(){for(var a=this.newTreeRef();!a.onMainline();)a.moveUp();return a.node()},
nextMoves:function(){for(var a=this.node(),b=[],c=0;c<a.numChildren();c++){var d=a.getChild(c).properties().getMove();d&&b.push(d)}return b},onMainline:function(){if(!this.markedMainline_){var a=this.getTreeFromRoot();for(a.node()._mainline=!0;0<a.node().numChildren();)a.moveDown(),a.node()._mainline=!0;this.markedMainline_=!0}return this.node()._mainline},rebase:function(){for(var a=this.treepathToHere(),b=this.getTreeFromRoot(),c=this.getCurrentPlayer(),d=glift.rules.movetree.getInstance(),e={BLACK:"AB",
WHITE:"AW"},f=0;f<=a.length;f++){var g=b.properties().getAllStones(),h;for(h in g)for(var k=g[h],l=e[h],m=0;m<k.length;m++){var n=k[m].point;n&&l&&d.properties().add(l,n.toSgfCoord())}f<a.length&&b.moveDown(a[f])}var p=function(a,b){for(var c in a.properties().propMap)(0!==b.getNodeNum()||"AB"!==c&&"AW"!==c)&&b.properties().set(c,glift.util.simpleClone(a.properties().getAllValues(c)));for(c=0;c<a.children.length;c++){var d=a.getChild(c),e=b.addChild().getChild(c);p(d,e)}};p(b.node(),d.node());a={BLACK:"B",
WHITE:"W"};d.getCurrentPlayer()!==c&&d.properties().add(glift.rules.prop.PL,a[c]);return d},recurse:function(a){glift.rules.movetree.searchMoveTreeDFS(this,a)},recurseFromRoot:function(a){glift.rules.movetree.searchMoveTreeDFS(this.getTreeFromRoot(),a)},toSgf:function(){return this._toSgfBuffer(this.getTreeFromRoot().node(),[]).join("")},treepathToHere:function(){for(var a=[],b=this.newTreeRef();b.node().getParent();)a.push(b.node().getVarNum()),b.moveUp();return a.reverse()},_setIntersections:function(a){var b=
this.getTreeFromRoot(),c=glift.rules.prop;b.properties().contains(c.SZ)||this.properties().add(c.SZ,a+"");return this},_toSgfBuffer:function(a,b){a.getParent()&&b.push("\n");(!a.getParent()||1<a.getParent().numChildren())&&b.push("(");b.push(";");for(var c in a.properties().propMap){var d=a.properties().getAllValues(c),e=c;if(0<d.length)for(var f=0;f<d.length;f++)var g=a.properties().escape(d[f]),e=e+("["+g+"]");else e+="[]";b.push(e)}f=0;for(c=a.numChildren();f<c;f++)this._toSgfBuffer(a.getChild(f),
b);(!a.getParent()||1<a.getParent().numChildren())&&b.push(")");return b}};glift.rules.problems={isCorrectPosition:function(a,b){var c=glift.enums.problemResults;if(a.properties().matches(b))return c.CORRECT;for(var d=glift.rules.treepath.flattenMoveTree(a),e={},f=0;f<d.length;f++){for(var g=d[f],h=a.getFromNode(a.node()),k=!1,l=0;l<g.length;l++)h.moveDown(g[l]),h.properties().matches(b)&&(k=!0);k?e[c.CORRECT]=!0:e[c.INCORRECT]=!0}return e[c.CORRECT]&&!e[c.INCORRECT]?a.properties().matches(b)?c.CORRECT:c.INDETERMINATE:e[c.CORRECT]&&e[c.INCORRECT]?c.INDETERMINATE:c.INCORRECT},
correctNextMoves:function(a,b){for(var c=a.nextMoves(),d=glift.enums.problemResults.INCORRECT,e=[],f=0;f<c.length;f++)a.moveDown(f),glift.rules.problems.isCorrectPosition(a,b)!==d&&e.push(c[f]),a.moveUp();return e}};glift.rules.properties=function(a){return new glift.rules.Properties(a)};glift.rules.propertiesWithPts={CR:!0,LB:!0,MA:!0,SQ:!0,TR:!0,B:!0,W:!0,AW:!0,AB:!0,AE:!0,AR:!0,DD:!0,LN:!0,TB:!0,TW:!0};glift.rules.Properties=function(a){this.propMap=a||{}};
glift.rules.Properties.prototype={add:function(a,b){if(!glift.rules.prop[a])return glift.util.logz("Warning! The property ["+a+"] is not valid and is not recognized in the SGF spec. Thus, this property will be ignored"),this;var c=glift.util.typeOf(b);if("string"!==c&&"array"!==c)throw Error('Unsupported type "'+c+'" for prop '+a);if("array"===c)for(var c=0,d=b.length;c<d;c++)b[c]=this.unescape(b[c]);else if("string"===c)b=[this.unescape(b)];else throw Error("Unexpected type "+glift.util.typeOf(b)+
" for prop "+a);for(var d=/^[a-z][a-z]:[a-z][a-z]$/,e=[],c=0;c<b.length;c++)if(d.test(b[c]))for(var f=glift.util.pointArrFromSgfProp(b[c]),g=0;g<f.length;g++)e.push(f[g].toSgfCoord());else e.push(b[c]);this.contains(a)?this.propMap[a]=this.getAllValues(a).concat(e):this.propMap[a]=e;return this},getAllValues:function(a){return void 0===glift.rules.prop[a]?null:this.propMap[a]?this.propMap[a].slice():null},getOneValue:function(a,b){var c=b||0,d=this.getAllValues(a);return d&&1<=d.length?d[c]:null},
getAsPoint:function(a,b){var c=this.getOneValue(a,b);return c?glift.util.pointFromSgfCoord(c):null},rotate:function(a,b,c){if(glift.rules.propertiesWithPts[a]&&glift.enums.rotations[c]&&c!==glift.enums.rotations.NO_ROTATION){var d=/([a-z][a-z])/g;a===glift.rules.prop.LB&&(d=/([a-z][a-z])(?=:)/g);for(var e=this.getAllValues(a),f=0;f<e.length;f++)e[f]=e[f].replace(d,function(a){return glift.util.pointFromSgfCoord(a).rotate(b,c).toSgfCoord()});this.propMap[a]=e}},contains:function(a){return a in this.propMap},
hasValue:function(a,b){if(!this.contains(a))return!1;for(var c=this.getAllValues(a),d=0;d<c.length;d++)if(c[d]===b)return!0;return!1},remove:function(a){if(this.contains(a)){var b=this.getAllValues(a);delete this.propMap[a];return b}return null},removeOneValue:function(a,b){if(this.contains(a)){for(var c=this.getAllValues(a),d=-1,e=0,f=c.length;e<f;e++)if(c[e]===b){d=e;break}-1!==d&&(c.splice(d,1),this.set(a,c))}else return null},set:function(a,b){if(void 0!==a&&void 0!==b)if("string"===glift.util.typeOf(b))this.propMap[a]=
[this.unescape(b)];else if("array"===glift.util.typeOf(b)){for(var c=0;c<b.length;c++){if("string"!==glift.util.typeOf(b[c]))throw Error("When setting via an array, all values must be strings. was ["+glift.util.typeOf(b[c])+"], for value "+b[c]);b[c]=this.unescape(b[c])}this.propMap[a]=b}return this},getPlacementsAsPoints:function(a){if(a===glift.enums.states.BLACK)a=glift.rules.prop.AB;else if(a===glift.enums.states.WHITE)a=glift.rules.prop.AW;else return[];return this.contains(a)?glift.sgf.allSgfCoordsToPoints(this.getAllValues(a)):
[]},getComment:function(){return this.contains(glift.rules.prop.C)?this.getOneValue(glift.rules.prop.C):null},getMove:function(){var a=glift.enums.states.BLACK,b=glift.enums.states.WHITE;return this.contains(glift.rules.prop.B)?""===this.getOneValue(glift.rules.prop.B)?{color:a}:{color:a,point:this.getAsPoint(glift.rules.prop.B)||void 0}:this.contains(glift.rules.prop.W)?""===this.getOneValue(glift.rules.prop.W)?{color:b}:{color:b,point:this.getAsPoint(glift.rules.prop.W)||void 0}:null},matches:function(a){for(var b in a)if(this.contains(b)){var c=
a[b];if(0===c.length)return!0;for(var d=this.getAllValues(b),e=0,f=d.length;e<f;e++)for(var g=0,h=c.length;g<h;g++)if(-1!==d[e].indexOf(c[g]))return!0}return!1},getAllStones:function(){var a=glift.enums.states,b={},c=a.BLACK,d=a.WHITE;b.WHITE=[];b.BLACK=[];for(var e=this.getPlacementsAsPoints(a.BLACK),a=this.getPlacementsAsPoints(a.WHITE),f=0;f<e.length;f++)b.BLACK.push({point:e[f],color:c});for(f=0;f<a.length;f++)b.WHITE.push({point:a[f],color:d});(c=this.getMove())&&c.point&&b[c.color].push(c);
return b},getAllMarks:function(){var a={CR:glift.enums.marks.CIRCLE,LB:glift.enums.marks.LABEL,MA:glift.enums.marks.XMARK,SQ:glift.enums.marks.SQUARE,TR:glift.enums.marks.TRIANGLE},b={},c;for(c in a){var d=a[c];if(this.contains(c)){for(var e=this.getAllValues(c),f=[],g=0;g<e.length;g++)if(c===glift.rules.prop.LB)f.push(glift.sgf.convertFromLabelData(e[g]));else for(var h=glift.util.pointArrFromSgfProp(e[g]),k=0;k<h.length;k++)f.push({point:h[k]});b[d]=f}}return b},getAllDisplayPts:function(){var a=
this.getAllMarks(),b=this.getAllStones(),c={},d;for(d in a)c[d]=a[d];for(d in b)c[d]=b[d];return c},getGameInfo:function(){var a=[],b={PW:"White Player",PB:"Black Player",RE:"Result",AN:"Commenter",SO:"Source",RU:"Ruleset",KM:"Komi",GN:"Game Name",EV:"Event",RO:"Round",PC:"Place Name",DT:"Date"},c;for(c in b)if(this.contains(c)){var d={prop:c,displayName:b[c],value:this.getOneValue(c)};c===glift.rules.prop.PW&&this.contains(glift.rules.prop.WR)?d.value+=" ["+this.getOneValue(glift.rules.prop.WR)+
"]":c===glift.rules.prop.PB&&this.contains(glift.rules.prop.BR)?d.value+=" ["+this.getOneValue(glift.rules.prop.BR)+"]":c===glift.rules.prop.KM&&(d.value=parseFloat(this.getOneValue(c))+""||"0");a.push(d)}return a},escape:function(a){return a.toString().replace(/]/g,"\\]")},unescape:function(a){return a.toString().replace(/\\]/g,"]")}};glift.rules.treepath={parsePath:function(a){if(void 0===a)return[];if("number"===glift.util.typeOf(a))a=""+a;else{if("array"===glift.util.typeOf(a))return a;if("string"!==glift.util.typeOf(a))return[]}if("+"===a)return glift.rules.treepath.toEnd_();var b=[],c=0;a=a.split("-");for(var d=0;d<a.length;d++){for(var e=a[d].split("."),f=parseInt(e[0],10),g=0;g<f-c;g++)b.push(0);if(/\+/.test(e[0])){if(1!==e.length||d!==a.length-1)throw Error("Improper use of + at "+e[0]+": The + character can only occur at the end.");
b=b.concat(glift.rules.treepath.toEnd_());break}c=f;for(g=1;g<e.length;g++){f=e[g];if("+"===f.charAt(f.length-1))return f=f.slice(0,f.length-1),b.push(parseInt(f,10)),b=b.concat(glift.rules.treepath.toEnd_());b.push(parseInt(f,10));c++}}return b},parseFragment:function(a){a||(a=[]);var b=glift.util.typeOf(a);if("array"===b)return a;if("string"!==b)throw Error("When parsing fragments, type should be string. was: "+b);a=a.split(".");for(var b=[],c=0;c<a.length;c++){var d=a[c];"+"===d.charAt(d.length-
1)?(d=d.slice(0,d.length-1),b.push(parseInt(d,10)),b=b.concat(glift.rules.treepath.toEnd_())):b.push(parseInt(d,10))}return b},toFragmentString:function(a){return"array"!==glift.util.typeOf(a)?a.toString():a.join(".")},toInitPathString:function(a){for(var b=[],c=!0,d=0;d<a.length;d++){var e=a[d];0===e?c&&d===a.length-1?b.push(d+1):c||b.push(e):0<e&&(c&&(c=!1,b.push(d)),b.push(e))}return b.join(".")},storedToEnd_:null,toEnd_:function(){if(null!=glift.rules.treepath.storedToEnd_)return glift.rules.treepath.storedToEnd_;
for(var a=[],b=0;500>b;b++)a.push(0);glift.rules.treepath.storedToEnd_=a;return glift.rules.treepath.storedToEnd_},findNextMovesPath:function(a,b,c,d){b=b||a.treepathToHere();d=!1===d?!1:!0;a=a.getTreeFromRoot(b);c=c||1E3;b=[];for(var e=a.onMainline(),f=0;a.node().getParent()&&f<c;f++){var g=a.node().getVarNum();b.push(g);a.moveUp();if(d&&a.properties().getOneValue(glift.rules.prop.C))break;if(!e&&a.onMainline())break}b.reverse();return{movetree:a,treepath:a.treepathToHere(),nextMoves:b}},applyNextMoves:function(a,
b,c){var d=glift.enums.states;a=a.newTreeRef();for(var e=[],f={},g=0;g<c.length;g++){a.moveDown(c[g]);var h=a.properties().getMove();if(h&&h.point&&h.color){var k=h.point.toString();b.getStone(h.point)!==d.EMPTY?h.collision=null:void 0!==f[k]&&(h.collision=f[k]);e.push(h);f[k]=g}}return{movetree:a,stones:e}},flattenMoveTree:function(a){var b=[];a=a.newTreeRef();for(var c=0;c<a.node().numChildren();c++){a.moveDown(c);var d=glift.rules.treepath._flattenMoveTree(a,[]);a.moveUp();for(var e=0;e<d.length;e++)b.push(d[e])}return b},
_flattenMoveTree:function(a,b){void 0===b&&(b=[]);b.push(a.node().getVarNum());for(var c=[],d=0;d<a.node().numChildren();d++){a.moveDown(d);var e=glift.rules.treepath._flattenMoveTree(a,b.slice()),c=c.concat(e);a.moveUp()}0==c.length&&c.push(b);return c}};glift.sgf={colorToToken:function(a){if(a===glift.enums.states.WHITE)return"W";if(a===glift.enums.states.BLACK)return"B";throw"Unknown color-to-token conversion for: "+a;},colorToPlacement:function(a){if(a===glift.enums.states.WHITE)return"AW";if(a===glift.enums.states.BLACK)return"AB";throw"Unknown color-to-token conversion for: "+a;},markToProperty:function(a){var b=glift.rules.prop;return{LABEL_ALPHA:b.LB,LABEL_NUMERIC:b.LB,LABEL:b.LB,XMARK:b.MA,SQUARE:b.SQ,CIRCLE:b.CR,TRIANGLE:b.TR}[a]||null},
propertyToMark:function(a){var b=glift.enums.marks;return{LB:b.LABEL,MA:b.XMARK,SQ:b.SQUARE,CR:b.CIRCLE,TR:b.TRIANGLE}[a]||null},allSgfCoordsToPoints:function(a){var b=[];if(!a)return b;for(var c=0;c<a.length;c++)b.push(glift.util.pointFromSgfCoord(a[c]));return b},convertFromLabelData:function(a){a=a.split(":");return{point:glift.util.pointFromSgfCoord(a[0]),value:a[1]}},convertFromLabelArray:function(a){for(var b=[],c=0;c<a.length;c++)b.push(glift.sgf.convertFromLabelData(a[c]));return b}};glift.parse={parseType:{SGF:"SGF",TYGEM:"TYGEM",PANDANET:"PANDANET"},fromFileName:function(a,b){var c=glift.parse.parseType,d=c.SGF;-1<b.indexOf(".sgf")?d=c.SGF:-1<b.indexOf(".gib")&&(d=c.TYGEM);return glift.parse.fromString(a,d)},fromString:function(a,b){var c=b||glift.parse.parseType.SGF;c===glift.parse.parseType.PANDANET&&(c=glift.parse.parseType.SGF);c=glift.enums.toCamelCase(c);c=(0,glift.parse[c])(a);return glift.rules.movetree.initRootProperties(c)}};glift.parse.sgfMetadataProperty="GC";
glift.parse.sgf=function(a){var b=/\s|\n/,c=/[A-Z]/,d=/[a-z]/,e=0,f=glift.rules.movetree.getInstance(),g=[],h=[],k=[],l="",m="",n=0,p=0,q=0,r=function(a){glift.parse.sgfParseError(n,p,m,a,!1)},u=function(){var a=g.join("");g=[];return a},v=function(){if(0<l.length){if(glift.parse.sgfMetadataProperty&&l===glift.parse.sgfMetadataProperty&&!f.node().getParent())try{var a=h[0].replace(/\\]/g,"]"),b=JSON.parse(a);"object"===glift.util.typeOf(b)&&f.setMetdata(b)}catch(c){glift.util.logz("For property: "+l+
" unable to parse : "+h+" as JSON for SGF metadata")}f.properties().add(l,h);h=[];l=""}};(function(){for(var t=0;t<a.length;t++){p++;m=a.charAt(t);if("\n"===m&&(n++,p=0,3!==e))continue;switch(e){case 0:"("===m?(k.push(f.node().getNodeNum()),q++,e=1):b.test(m)||r("Unexpected character. Expected first non-whitespace char to be [(]");break;case 1:";"===m?e=4:b.test(m)||r("Unexpected character. Expected char to be [;]");break;case 2:c.test(m)?g.push(m):d.test(m)||("["===m?(l=u(),void 0===glift.rules.prop[l]&&
glift.parse.sgfParseError(n,p,m,"Unknown property: "+l,!0),e=3):b.test(m)?r("Unexpected whitespace in property name"):r("Unexpected character in property name"));break;case 3:"]"===m&&"\\"===g[g.length-1]?g.push(m):"]"===m?(h.push(u()),e=4):g.push(m);break;case 4:if(c.test(m))v(),g.push(m),e=2;else if("["===m)0<l.length?e=3:r("Unexpected token. Orphan property data.");else if("("===m)q++,v(),k.push(f.node().getNodeNum());else if(")"===m){q--;v();if(0===k.length){for(;0!==f.node().getNodeNum();)f.moveUp();
return f}for(var x=k.pop();f.node().getNodeNum()!==x;)f.moveUp();0===q&&(e=5)}else";"===m?(v(),f.addNode()):b.test(m)||r("Unknown token");break;case 5:b.test(m)||glift.parse.sgfParseError(n,p,m,"Garbage after finishing the SGF.",!0);break;default:r("Fatal Error: Unknown State!")}}0!==f.node().getNodeNum()&&r("Expected to end up at start.")})();return f};
glift.parse.sgfParseError=function(a,b,c,d,e){a="SGF Parsing "+(e?"Warning":"Error")+": At line ["+a+"], column ["+b+"], char ["+c+"], "+d;if(e)glift.util.logz(a);else throw Error(a);};glift.parse.tygem=function(a){var b={1:"B",2:"W"},c=glift.rules.movetree.getInstance();a=a.split("\n");for(var d=function(a,b,c,d){b=b.substring(b.indexOf(a)+a.length+1,b.length-2);/\\$/.test(b)&&(b=b.substring(0,b.length-1));d.properties().add(c,b)},e=1,f=0,g=a.length;f<g;f++){var h=a[f],k=h.substring(0,2);if("\\["===k)k=h.indexOf("="),k=h.substring(2,k),"GAMEWHITENAME"===k?d("GAMEWHITENAME",h,"PW",c):"GAMEBLACKNAME"===k&&d("GAMEBLACKNAME",h,"PB",c);else if("ST"===k){2!==e&&(e=2);var l=h.split(" "),
h=b[l[3]],k=parseInt(l[4],10),l=parseInt(l[5],10);c.addNode().properties().add(h,glift.util.point(k,l).toSgfCoord())}}return c.getTreeFromRoot()};glift.controllers={};glift.controllers.base=function(){return new glift.controllers.BaseController};glift.controllers.BaseController=function(){this.sgfString="";this.rawInitialPosition=[];this.problemConditions={};this.parseType=glift.parse.parseType.SGF;this.showVariations_=this.nextMovesPath_=void 0;this.markLastMove_=!1;this.treepath=[];this.movetree=glift.rules.movetree.getInstance();this.goban=glift.rules.goban.getInstance(1);this.captureHistory=[]};
glift.controllers.BaseController.prototype={initOptions:function(a){if(void 0===a)throw"Options is undefined! Can't create controller";this.sgfString=a.sgfString||"";a.nextMovesPath&&(this.nextMovesPath_=glift.rules.treepath.parseFragment(a.nextMovesPath));this.rawInitialPosition=a.initialPosition||[];this.parseType=a.parseType||glift.parse.parseType.SGF;this.problemConditions=a.problemConditions||{};this.showVariations_=a.showVariations||void 0;this.markLastMove_=a.markLastMove||!1;this.initialize();
return this},initialize:function(a){var b=glift.rules;this.treepath=b.treepath.parsePath(a||this.rawInitialPosition);this.movetree=b.movetree.getFromSgf(this.sgfString,this.treepath,this.parseType);a=b.goban.getFromMoveTree(this.movetree,this.treepath);this.goban=a.goban;this.captureHistory=a.captures;this.extraOptions();return this},extraOptions:function(a){},addStone:function(a,b){throw"Not Implemented";},flattenedState:function(){return glift.flattener.flatten(this.movetree,{goban:this.goban,showNextVariationsType:this.showVariations_,
markLastMove:this.markLastMove_,nextMovesTreepath:this.nextMovesPath_})},recordCaptures:function(a){this.captureHistory.push(a);return this},currentMoveNumber:function(){return this.movetree.node().getNodeNum()},nextVariationNumber:function(){return this.treepath[this.currentMoveNumber()]||0},setNextVariation:function(a){this.treepath=this.treepath.slice(0,this.currentMoveNumber());this.treepath.push(a%this.movetree.node().numChildren());return this},pathToCurrentPosition:function(){return this.movetree.treepathToHere()},
getGameInfo:function(){return this.movetree.getTreeFromRoot().properties().getGameInfo()},getCaptures:function(){return 0===this.captureHistory.length?{BLACK:[],WHITE:[]}:this.captureHistory[this.currentMoveNumber()-1]},getCaptureCount:function(){for(var a={BLACK:0,WHITE:0},b=0;b<this.captureHistory.length;b++){var c=this.captureHistory[b],d;for(d in c)a[d]+=c[d].length}return a},canAddStone:function(a,b){return this.goban.placeable(a)},getCurrentPlayer:function(){return this.movetree.getCurrentPlayer()},
currentSgf:function(){return this.movetree.toSgf()},originalSgf:function(){return this.sgfString},getIntersections:function(){return this.movetree.getIntersections()},getQuadCropFromBeginning:function(){return glift.orientation.getQuadCropFromMovetree(this.movetree)},getCorrectNextMoves:function(){return glift.rules.problems.correctNextMoves(this.movetree,this.problemConditions)},nextMove:function(a){if(void 0===this.treepath[this.currentMoveNumber()]||void 0!==a&&this.nextVariationNumber()!==a)if(a=
void 0===a?0:a,0<=a&&a<=this.movetree.nextMoves().length-1)this.setNextVariation(a),this.movetree.moveDown(a);else return null;else this.movetree.moveDown(this.nextVariationNumber());a=this.goban.loadStonesFromMovetree(this.movetree);this.recordCaptures(a);return this.flattenedState()},prevMove:function(){if(0===this.currentMoveNumber())return null;var a=this.getCaptures(),b=this.movetree.properties().getAllStones();this.captureHistory=this.captureHistory.slice(0,this.currentMoveNumber()-1);this.unloadStonesFromGoban_(b,
a);this.movetree.moveUp();return this.flattenedState()},toBeginning:function(){this.movetree=this.movetree.getTreeFromRoot();this.goban=glift.rules.goban.getFromMoveTree(this.movetree,[]).goban;this.captureHistory=[];return this.flattenedState()},toEnd:function(){for(;this.nextMove(););return this.flattenedState()},unloadStonesFromGoban_:function(a,b){for(var c in a)for(var d=c,e=a[d],d=0;d<e.length;d++){var f=e[d];f.point&&this.goban.clearStone(f.point)}for(c in b)for(d=c,e=b[d],f=0;f<e.length;f++)this.goban.addStone(e[f],
d)}};glift.controllers.boardEditor=function(a){var b=glift.controllers,c=glift.util.beget(b.base());glift.util.setMethods(c,b.BoardEditor.prototype);c.initOptions(a);return c};glift.controllers.BoardEditor=function(){};
glift.controllers.BoardEditor.prototype={extraOptions:function(){this._initLabelTrackers()},_initLabelTrackers:function(){var a=glift.enums.marks,b={},c={};this._ptTolabelMap={};for(var d=0;100>d;d++)b[d+1]=!0;for(d=0;26>d;d++){var e=""+String.fromCharCode(65+d);c[e]=!0}for(var e=[a.CIRCLE,a.LABEL,a.SQUARE,a.TRIANGLE,a.XMARK],f=/^[A-Z]$/,g=/^\d*$/,d=0;d<e.length;d++){var h=e[d],k=glift.sgf.markToProperty(h);if(k=this.movetree.properties().getAllValues(k))for(var l=0;l<k.length;l++){var m=k[l].split(":"),
n={mark:h},p=null;1<m.length&&(p=m[1],n.data=p,f.test(p)?n.mark=a.LABEL_ALPHA:g.test(p)&&(p=parseInt(p,10),n.mark=a.LABEL_NUMERIC));m=glift.util.pointFromSgfCoord(m[0]);this._ptTolabelMap[m.toString()]=n;b[p]&&delete b[p];c[p]&&delete c[p]}}this._alphaLabels=this._convertLabelMap(c);this._numericLabels=this._convertLabelMap(b)},_convertLabelMap:function(a){var b=[],c=/^\d+$/,d;for(d in a)c.test(d)?b.push(parseInt(d,10)):b.push(d);0<b.length&&"number"===glift.util.typeOf(b[0])?(b.sort(function(a,b){return a-
b}),b.reverse()):b.sort().reverse();return b},currentAlphaMark:function(){return 0<this._alphaLabels.length?this._alphaLabels[this._alphaLabels.length-1]:null},currentNumericMark:function(){return 0<this._numericLabels.length?this._numericLabels[this._numericLabels.length-1]+"":null},getMark:function(a){return this._ptTolabelMap[a.toString()]||null},_useCurrentAlphaMark:function(){var a=this._alphaLabels.pop();return a?a:null},_useCurrentNumericMark:function(){var a=this._numericLabels.pop()+"";return a?
a:null},isSupportedMark:function(a){return{LABEL_ALPHA:!0,LABEL_NUMERIC:!0,SQUARE:!0,TRIANGLE:!0}[a]||!1},addMark:function(a,b){var c=glift.enums.marks,d=this.movetree.node().properties();if(!this.isSupportedMark(b))return null;if(this.getMark(a))return this.removeMark(a);var e={mark:b},f=null;b===c.LABEL_NUMERIC?(f=this._useCurrentNumericMark(),e.data=f):b===c.LABEL_ALPHA&&(f=this._useCurrentAlphaMark(),e.data=f);c=glift.sgf.markToProperty(b);f&&b?d.add(c,a.toSgfCoord()+":"+f):b&&d.add(c,a.toSgfCoord());
this._ptTolabelMap[a.toString()]=e;return this.flattenedState()},removeMark:function(a){var b=glift.enums.marks,c=this.getMark(a);if(!c)return null;delete this._ptTolabelMap[a.toString()];var d=glift.sgf.markToProperty(c.mark);c.mark===b.LABEL_NUMERIC?(this._numericLabels.push(parseInt(c.data,10)),this._numericLabels.sort(function(a,b){return a-b}).reverse(),this.movetree.properties().removeOneValue(d,a.toSgfCoord()+":"+c.data)):c.mark===b.LABEL_ALPHA?(this._alphaLabels.push(c.data),this.movetree.properties().removeOneValue(d,
a.toSgfCoord()+":"+c.data),this._alphaLabels.sort().reverse()):this.movetree.properties().removeOneValue(d,a.toSgfCoord());return this.flattenedState()},addStone:function(a,b){if(!this.canAddStone(a,b))return null;this.goban.addStone(a,b);this.movetree.addNode();this.movetree.properties().add(glift.sgf.colorToToken(b),a.toSgfCoord());return this.flattenedState()},addPlacement:function(a,b){var c=glift.sgf.colorToPlacement(b),d=glift.util.colors.oppositeColor(b),e=glift.sgf.colorToPlacement(d),f=this.goban.addStone(a,
b);if(f.successful){this.movetree.properties().add(c,a.toSgfCoord());for(c=0;c<f.captures.length;c++)this.movetree.properties().removeOneValue(e,f.captures[c].toSgfCoord());e={};e[d]=f.captures;return glift.bridge.intersections.nextBoardData(this.movetree,e)}return this.flattenedState()},pass:function(){throw Error("Not implemented");},clearStone:function(){throw Error("Not implemented");}};glift.controllers.gameViewer=function(a){var b=glift.controllers,c=glift.util.beget(b.base()),b=glift.util.setMethods(c,b.GameViewerMethods);b.initOptions(a);return b};
glift.controllers.GameViewerMethods={extraOptions:function(){},addStone:function(a,b){var c=this._possibleNextMoves(),d=a.toString()+"-"+b;return void 0===c[d]?null:this.nextMove(c[d])},previousCommentOrBranch:function(a){var b=null,c=0;do{var b=this.prevMove(),d=this.movetree.properties().getOneValue("C"),e=this.movetree.node().numChildren();c++;if(a&&c===a)break}while(b&&!d&&1>=e);this.setNextVariation(0);return this.flattenedState()},nextCommentOrBranch:function(a){var b=null,c=0;do{var b=this.nextMove(),
d=this.movetree.properties().getOneValue("C"),e=this.movetree.node().numChildren();c++;if(a&&c===a)break}while(b&&!d&&1>=e);return this.flattenedState()},moveUpVariations:function(){return this.setNextVariation((this.nextVariationNumber()+1)%this.movetree.node().numChildren())},moveDownVariations:function(){return this.setNextVariation((this.nextVariationNumber()-1+ +this.movetree.node().numChildren())%this.movetree.node().numChildren())},_possibleNextMoves:function(){for(var a={},b=this.movetree.nextMoves(),
c=0;c<b.length;c++){var d=b[c];a[(void 0!==d.point?d.point.toString():"PASS")+"-"+d.color]=c}return a}};glift.controllers.staticProblem=function(a){var b=glift.util.beget(glift.controllers.base());glift.util.setMethods(b,glift.controllers.StaticProblem.prototype);b.initOptions(a);return b};glift.controllers.StaticProblem=function(){};
glift.controllers.StaticProblem.prototype={extraOptions:function(){0!==this.movetree.node().getNodeNum()&&(this.movetree=this.movetree.rebase(),this.treepath=[],this.captureHistory=[],this.initialPosition=[],this.sgfString=this.movetree.toSgf())},reload:function(){this.initialize()},addStone:function(a,b){var c=glift.enums.problemResults,d=c.CORRECT,e=c.INCORRECT,f=c.INDETERMINATE,c=c.FAILURE;if(!this.goban.placeable(a)||!this.goban.testAddStone(a,b))return d=this.flattenedState(),d.setProblemResult(c),
d;c=this.movetree.findNextMove(a,b);null===c&&(this.movetree.addNode(),this.movetree.properties().add(glift.sgf.colorToToken(b),a.toSgfCoord()),this.movetree.moveUp(),c=this.movetree.node().numChildren()-1);var c=this.nextMove(c),g=glift.rules.problems.isCorrectPosition(this.movetree,this.problemConditions);if(g===d)return c.setProblemResult(g),c;if(g===d||g===e||g===f)return this.nextMove(0),c=this.flattenedState(),c.setProblemResult(g),c;throw"Unexpected result output: "+g;},correctnessStatus:function(){return glift.rules.problems.isCorrectPosition(this.movetree,
this.problemConditions)}};glift.bridge={setDisplayState:function(a,b,c,d){glift.util.majorPerfLog("Set display state");b.intersections().clearMarks();a.displayDataType===glift.enums.displayDataTypes.FULL&&b.intersections().clearAll();for(var e in a.stones)for(var f=0;f<a.stones[e].length;f++){var g=a.stones[e][f];b.intersections().setStoneColor(g,e)}var h={};glift.bridge.shouldShowNextMoves(a,c)&&(h=glift.bridge.variationMapping(a.nextMoves));var k={};e=glift.enums.marks;for(var l in a.marks)for(f=0;f<a.marks[l].length;f++){var g=
a.marks[l][f],m=(g.point?g.point:g).toString();k[m]=!0;if(l===e.LABEL)if(h[m]&&glift.bridge.shouldShowNextMoves(a,c)){var n=glift.bridge.markSelectedNext(a,g.point,g.value);b.intersections().addMarkPt(g.point,e.VARIATION_MARKER,n);delete h[m]}else b.intersections().addMarkPt(g.point,e.LABEL,g.value);else b.intersections().addMarkPt(g,l)}f=1;c=glift.bridge.variationMapping(a.correctNextMoves);for(var p in h)g=h[p],n=glift.bridge.markSelectedNext(a,g,f),g in c?b.intersections().addMarkPt(g,e.CORRECT_VARIATION,
n):b.intersections().addMarkPt(g,e.VARIATION_MARKER,n),f+=1;a.lastMove&&a.lastMove.point&&d&&!k[a.lastMove.point.toString()]&&(a=a.lastMove,b.intersections().addMarkPt(a.point,e.STONE_MARKER));glift.util.majorPerfLog("Finish display state")},markSelectedNext:function(a,b,c){a.selectedNextMove&&b.equals(a.selectedNextMove.point)&&(c+=".");return c},shouldShowNextMoves:function(a,b){return a.nextMoves&&(1<a.nextMoves.length&&b===glift.enums.showVariations.MORE_THAN_ONE||1<=a.nextMoves.length&&b===glift.enums.showVariations.ALWAYS)},
variationMapping:function(a){for(var b={},c=0;c<a.length;c++){var d=a[c];void 0!==d.point&&(b[d.point.toString()]=d.point)}return b}};glift.bridge.intersections={propertiesToMarks:{CR:glift.enums.marks.CIRCLE,LB:glift.enums.marks.LABEL,MA:glift.enums.marks.XMARK,SQ:glift.enums.marks.SQUARE,TR:glift.enums.marks.TRIANGLE},basePropertyData:function(a,b,c){var d={stones:{WHITE:[],BLACK:[],EMPTY:[]},marks:{},comment:null,lastMove:null,nextMoves:[],selectedNextMove:null,correctNextMoves:[],captures:[],displayDataType:glift.enums.displayDataTypes.PARTIAL};d.comment=a.properties().getComment();d.lastMove=a.getLastMove();d.marks=glift.bridge.intersections.getCurrentMarks(a);
d.nextMoves=a.nextMoves();d.selectedNextMove=c?d.nextMoves[c]:null;d.correctNextMoves=void 0!==b?glift.rules.problems.correctNextMoves(a,b):[];return d},getFullBoardData:function(a,b,c,d){a=glift.bridge.intersections.basePropertyData(a,c,d);a.displayDataType=glift.enums.displayDataTypes.FULL;b=b.getAllPlacedStones();for(c=0;c<b.length;c++)d=b[c],a.stones[d.color].push(d.point);return a},nextBoardData:function(a,b,c,d){c=glift.bridge.intersections.basePropertyData(a,c,d);a=a.properties().getAllStones();
c.stones={};for(var e in a){d=a[e];c.stones[e]=[];for(var f=0;f<d.length;f++)c.stones[e].push(d[f].point)}c.stones.EMPTY=[];for(e in b)for(f=0;f<b[e].length;f++)c.stones.EMPTY.push(b[e][f]);return c},previousBoardData:function(a,b,c,d,e){a=glift.bridge.intersections.basePropertyData(a,d,e);a.stones=c;a.stones.EMPTY=[];for(var f in b)for(c=0;c<b[f].length;c++)a.stones.EMPTY.push(b[f][c].point);return a},getCurrentMarks:function(a){var b={},c;for(c in glift.bridge.intersections.propertiesToMarks){var d=
glift.bridge.intersections.propertiesToMarks[c];if(a.properties().contains(c)){for(var e=[],f=a.properties().getAllValues(c),g=0;g<f.length;g++)if(c===glift.rules.prop.LB)e.push(glift.sgf.convertFromLabelData(f[g]));else{var h=glift.util.pointArrFromSgfProp(f[g]);1===h.length?e.push(h[0]):e=e.concat(h)}b[d]=e}}return b}};glift.orientation={};glift.orientation.bbox={fromPts:function(a,b){return new glift.orientation.BoundingBox(a,b)},fromSides:function(a,b,c){return new glift.orientation.BoundingBox(a,glift.util.point(a.x()+b,a.y()+c))}};glift.orientation.BoundingBox=function(a,b){if(a.x()>b.x()||a.y()>b.y())throw Error("Topleft point must be less than the bottom right point. tl:"+a.toString()+"; br:"+b.toString());this._topLeftPt=a;this._botRightPt=b};
glift.orientation.BoundingBox.prototype={topLeft:function(){return this._topLeftPt},botRight:function(){return this._botRightPt},topRight:function(){return glift.util.point(this.right(),this.top())},botLeft:function(){return glift.util.point(this.left(),this.bottom())},width:function(){return this.botRight().x()-this.topLeft().x()},height:function(){return this.botRight().y()-this.topLeft().y()},top:function(){return this.topLeft().y()},left:function(){return this.topLeft().x()},bottom:function(){return this.botRight().y()},
right:function(){return this.botRight().x()},center:function(){return glift.util.point(Math.abs((this.botRight().x()-this.topLeft().x())/2)+this.topLeft().x(),Math.abs((this.botRight().y()-this.topLeft().y())/2)+this.topLeft().y())},contains:function(a){return a.x()>=this.topLeft().x()&&a.x()<=this.botRight().x()&&a.y()>=this.topLeft().y()&&a.y()<=this.botRight().y()},covers:function(a){return this.contains(a.topLeft())&&this.contains(a.botRight())},intersect:function(a){if(!(a.contains(this.topLeft())||
a.contains(this.topRight())||a.contains(this.botLeft())||a.contains(this.botRight())||this.contains(a.topLeft())||this.contains(a.topRight())||this.contains(a.botLeft())||this.contains(a.botRight())))return null;var b=Math.max(this.top(),a.top()),c=Math.max(this.left(),a.left()),d=Math.min(this.bottom(),a.bottom());a=Math.min(this.right(),a.right());return glift.orientation.bbox.fromPts(glift.util.point(c,b),glift.util.point(a,d))},expandToContain:function(a){var b=this.topLeft().x(),c=this.topLeft().y(),
d=this.botRight().x(),e=this.botRight().y();a.x()<b&&(b=a.x());a.y()<c&&(c=a.y());a.x()>d&&(d=a.x());a.y()>e&&(e=a.y());return glift.orientation.bbox.fromPts(glift.util.point(b,c),glift.util.point(d,e))},equals:function(a){return a.topLeft()&&this.topLeft().equals(a.topLeft())&&a.botRight()&&this.botRight().equals(a.botRight())},scale:function(a){var b=this.height()*a,c=this.width()*a;a=glift.util.point(this.topLeft().x()*a,this.topLeft().y()*a);return glift.orientation.bbox.fromSides(a,c,b)},toString:function(){return"("+
this.topLeft().toString()+"),("+this.botRight().toString()+")"},translate:function(a,b){return glift.orientation.bbox.fromPts(glift.util.point(this.topLeft().x()+a,this.topLeft().y()+b),glift.util.point(this.botRight().x()+a,this.botRight().y()+b))},hSplit:function(a){return this._splitBox("h",a)},vSplit:function(a){return this._splitBox("v",a)},_splitBox:function(a,b){if("array"!==glift.util.typeOf(b))throw"bboxSplits must be specified as an array. Was: "+glift.util.typeOf(b);if("h"!==a&&"v"!==a)throw"What!? The only splits allowed are 'v' or 'h'. You supplied: "+
a;for(var c=0,d=0;d<b.length;d++)c+=b[d];if(1<=c)throw"The box splits must sum to less than 1, but instead summed to: "+c;b.push(1-c);for(var c=0,e=[],f=this.topLeft().clone(),d=0;d<b.length;d++){var c=d===b.length-1?1:c+b[d],g="h"===a?this.botRight().x():this.topLeft().x()+this.width()*c,h="h"===a?this.topLeft().y()+this.height()*c:this.botRight().y(),g=glift.util.point(g,h);e.push(glift.orientation.bbox.fromPts(f,g));g="h"===a?f.x():this.topLeft().x()+this.width()*c;f="h"===a?this.topLeft().y()+
this.height()*c:f.y();f=glift.util.point(g,f)}return e}};glift.orientation.Cropbox=function(a,b){this.bbox=a;this.size=b;if(this.bbox.width()>this.size-1)throw Error("BBox width cannot be bigger than the size:"+this.bbox.width()+" -- "+(this.size-1));if(this.bbox.height()>this.size-1)throw Error("BBox height cannot be bigger than the size:"+this.bbox.height()+" -- "+(this.size-1));};
glift.orientation.Cropbox.prototype={hasRaggedTop:function(){return 0<this.bbox.topLeft().y()},hasRaggedLeft:function(){return 0<this.bbox.topLeft().x()},hasRaggedBottom:function(){return this.bbox.botRight().y()<this.size-1},hasRaggedRight:function(){return this.bbox.botRight().x()<this.size-1}};
glift.orientation.cropbox={get:function(a,b){var c=glift.util.point,d=glift.enums.boardRegions,e=b-1,f=Math.ceil(e/2),g=0,h=0,k=e,l=e;a=a||d.ALL;if(19>b)return new glift.orientation.Cropbox(glift.orientation.bbox.fromPts(c(0,0),c(e,e)),b);switch(a){case d.ALL:break;case d.LEFT:l=f+1;break;case d.RIGHT:h=f-1;break;case d.TOP:k=f+1;break;case d.BOTTOM:g=f-1;break;case d.TOP_LEFT:k=f+1;l=f+2;break;case d.TOP_RIGHT:k=f+1;h=f-2;break;case d.BOTTOM_LEFT:g=f-1;l=f+2;break;case d.BOTTOM_RIGHT:g=f-1;h=f-2;
break;default:throw Error("Unknown board region: "+a);}c=glift.orientation.bbox.fromPts;d=glift.util.point;return new glift.orientation.Cropbox(c(d(h,g),d(l,k)),b)}};glift.orientation.getQuadCropFromMovetree=function(a,b){var c=glift.enums.boardRegions;if(19>a.getIntersections())return c.ALL;for(var c=glift.orientation.minimalBoundingBox(a,b),d=glift.orientation.getCropboxMapping_(),e=0;e<d.length;e++){var f=d[e];if(f.bbox.covers(c))return f.result}throw Error("None of the boxes cover the minimal bbox!! This should never happen");};glift.orientation.cropboxMappingCache_=null;
glift.orientation.getCropboxMapping_=function(){var a=glift.enums.boardRegions,b=function(a){return glift.orientation.cropbox.get(a,19)};if(null==glift.orientation.cropboxMappingCache_){for(var c=[{bbox:b(a.TOP_LEFT).bbox.intersect(b(a.BOTTOM_RIGHT).bbox),result:a.ALL},{bbox:b(a.TOP_LEFT).bbox.intersect(b(a.TOP_RIGHT).bbox),result:a.TOP},{bbox:b(a.TOP_LEFT).bbox.intersect(b(a.BOTTOM_LEFT).bbox),result:a.LEFT},{bbox:b(a.BOTTOM_RIGHT).bbox.intersect(b(a.TOP_RIGHT).bbox),result:a.RIGHT},{bbox:b(a.BOTTOM_RIGHT).bbox.intersect(b(a.BOTTOM_LEFT).bbox),
result:a.BOTTOM}],a=[a.TOP_LEFT,a.TOP_RIGHT,a.BOTTOM_LEFT,a.BOTTOM_RIGHT,a.TOP,a.BOTTOM,a.LEFT,a.RIGHT,a.ALL],d=0;d<a.length;d++){var e=a[d];c.push({bbox:b(e).bbox,result:e})}glift.orientation.cropboxMappingCache_=c}return glift.orientation.cropboxMappingCache_};glift.orientation.minimalBoundingBox=function(a,b){var c=glift.util.point,d=glift.orientation.bbox.fromPts,e=a.getIntersections()-1,f=void 0;b&&"string"===glift.util.typeOf(b)?f=glift.rules.treepath.parseFragment(b):b&&"array"===glift.util.typeOf(b)&&(f=b);f=glift.orientation.getDisplayPts_(a,f);if(0===f.length)return d(c(0,0),c(e,e));c=d(f[0],f[0]);for(d=1;d<f.length;d++)e=f[d],c.contains(e)||(c=c.expandToContain(e));return c};
glift.orientation.getDisplayPts_=function(a,b){a=a.newTreeRef();var c=[],d=function(a){for(var b in a)for(var d=a[b],e=0;e<d.length;e++)d[e].point&&c.push(d[e].point)};if(!b)a.recurseFromRoot(function(a){d(a.properties().getAllStones())});else if(b){for(var e=0;e<b.length;e++)a.moveDown(b[e]),d(a.properties().getAllStones());0===b.length&&d(a.properties().getAllStones());d(a.properties().getAllMarks())}return c};glift.orientation.findCanonicalRotation=function(a,b){var c=glift.enums.boardRegions,d=glift.enums.rotations,e={TOP_LEFT:0,BOTTOM_LEFT:90,BOTTOM_RIGHT:180,TOP_RIGHT:270},f={TOP:0,LEFT:90,BOTTOM:180,RIGHT:270};b||(b={corner:c.TOP_RIGHT,side:c.TOP});c=glift.orientation.getQuadCropFromMovetree(a);if(void 0!==e[c]||void 0!==f[c]){var g=0,h=0;void 0!==e[c]&&(g=e[c],h=e[b.corner]);void 0!==f[c]&&(g=f[c],h=f[b.side]);e=(360+g-h)%360;return 0===e?d.NO_ROTATION:"CLOCKWISE_"+e}return d.NO_ROTATION};glift.flattener={};
glift.flattener.flatten=function(a,b){var c=a.newTreeRef(),d=b||{},e=d.goban||glift.rules.goban.getFromMoveTree(c.getTreeFromRoot(),c.treepathToHere()).goban,f=d.showNextVariationsType||glift.enums.showVariations.NEVER,g=glift.rules.treepath.parseFragment(d.nextMovesTreepath||""),h=d.startingMoveNum||null;null===h&&(h=glift.flattener.findStartingMoveNum_(c,g));var k=glift.flattener.getBoardRegion_(c,g,d),l=glift.orientation.cropbox.get(k,c.getIntersections()),k=c.node().getNodeNum(),m=c.getMainlineNode().getNodeNum(),
n=c.getMainlineNode().properties().getMove(),p=null,q=c.getMainlineNode().getChild(0);q&&(p=q.properties().getMove());c.node().getNodeNum();var r=glift.rules.treepath.applyNextMoves(c,e,g),q=glift.flattener.stoneMap_(e,r.stones),c=r.movetree,u=h+g.length-1;u<h&&(u=h);var v=glift.flattener.getCorrectNextMoves_(c,d.problemConditions),t=glift.flattener.markMap_(c),x=glift.enums.showVariations;(f===x.ALWAYS||f===x.MORE_THAN_ONE&&1<c.node().numChildren())&&glift.flattener.updateLabelsWithVariations_(c,
t);f=glift.flattener.createStoneLabels_(r.stones,q,t,h);glift.flattener.markLastMove_(t,c.getLastMove(),d.markLastMove);d=glift.flattener.board.create(l,q,t);l=c.properties().getComment()||"";g||e.getKo();return new glift.flattener.Flattened({board:d,collisions:f,comment:l,isOnMainPath:c.onMainline(),baseMoveNum:k,startingMoveNum:h,endMoveNum:u,mainlineMoveNum:m,mainlineMove:n,nextMainlineMove:p,stoneMap:q,markMap:t,ko:e.getKo(),correctNextMoves:v,problemResult:null})};
glift.flattener.getBoardRegion_=function(a,b,c){var d=c.boardRegion||glift.enums.boardRegions.ALL;c.autoBoxCropOnNextMoves&&(d=glift.orientation.getQuadCropFromMovetree(a,b));d===glift.enums.boardRegions.AUTO&&(d=glift.orientation.getQuadCropFromMovetree(a));if(a=c.regionRestrictions||null){if("array"!==glift.util.typeOf(a))throw Error("Invalid type for options.regionRestrictions: Must be array; was: "+glift.util.typeOf(a));for(b=0;b<a.length;b++)if(-1<d.indexOf(a[b]))return a[b];return glift.enums.boardRegions.ALL}return d};
glift.flattener.stoneMap_=function(a,b){for(var c={},d=a.getAllPlacedStones(),e=0;e<d.length;e++){var f=d[e];c[f.point.toString()]=f}for(e=0;e<b.length;e++)f=b[e],d={point:f.point,color:f.color},f=d.point.toString(),c[f]||(c[f]=d);return c};
glift.flattener.markMap_=function(a){var b={marks:{},labels:{}},c=glift.flattener.symbols,c={CR:c.CIRCLE,LB:c.TEXTLABEL,MA:c.XMARK,SQ:c.SQUARE,TR:c.TRIANGLE},d;for(d in c){var e=c[d];if(a.properties().contains(d))for(var f=a.properties().getAllValues(d),g=0;g<f.length;g++)if(d===glift.rules.prop.LB){var h=glift.sgf.convertFromLabelData(f[g]),k=h.point.toString();b.marks[k]=e;b.labels[k]=h.value}else for(h=glift.util.pointArrFromSgfProp(f[g]),k=0;k<h.length;k++)b.marks[h[k].toString()]=e}return b};
glift.flattener.findStartingMoveNum_=function(a,b){a=a.newTreeRef();if(a.onMainline())return 0<b.length&&0<b[0]?1:a.node().getNodeNum()+1;for(var c=1;!a.onMainline();)c++,a.moveUp();return c};glift.flattener.getCorrectNextMoves_=function(a,b){var c={};if(b)for(var d=glift.rules.problems.correctNextMoves(a,b),e=0;e<d.length;e++){var f=d[e];f.point&&(c[f.point.toString()]=f)}return c};
glift.flattener.updateLabelsWithVariations_=function(a,b){for(var c=0;c<a.node().numChildren();c++){var d=a.node().getChild(c).properties().getMove();d&&d.point&&(d=d.point.toString(),void 0===b.labels[d]&&(b.labels[d]=""+(c+1)),b.marks[d]=glift.flattener.symbols.NEXTVARIATION)}};
glift.flattener.createStoneLabels_=function(a,b,c,d){if(!a||0===a.length)return[];var e=0,f=glift.flattener.symbols,g=[],h=/[0-9]/,k;for(k in c.labels)h.test(c.labels[k])&&(delete c.labels[k],delete c.marks[k]);for(h=0;h<a.length;h++){var l=a[h];k=l.point.toString();var m=h+d,n=b[k],p=void 0;n&&n.color&&(p=n.color);l.hasOwnProperty("collision")?(m={color:l.color,mvnum:m,label:void 0,collisionStoneColor:p},c.labels[k]?m.label=c.labels[k]:"number"===glift.util.typeOf(l.collision)?m.label=l.collision+
d+"":(l="abcdefghijklmnopqrstuvwxyz".charAt(e),e++,m.label=l,c.marks[k]=f.TEXTLABEL,c.labels[k]=l),g.push(m)):(c.marks[k]=f.TEXTLABEL,c.labels[k]=m+"")}return g};glift.flattener.markLastMove_=function(a,b,c){b&&b.point&&(b=b.point.toString(),!a.marks[b]&&c&&(a.marks[b]=glift.flattener.symbols.LASTMOVE))};glift.flattener.board={create:function(a,b,c){for(var d=glift.util.point,e=[],f=a.bbox,g=f.top();g<=f.bottom();g++){for(var h=[],k=f.left();k<=f.right();k++){var l=d(k,g),m=l.toString(),n=b[m];h.push(glift.flattener.intersection.create(l,n?n.color:glift.enums.states.EMPTY,c.marks[m],c.labels[m],a.size))}e.push(h)}return new glift.flattener.Board(e,f,a.size)}};glift.flattener.Board=function(a,b,c){this.boardArray_=a;this.bbox_=b;this.maxBoardSize_=c};
glift.flattener.Board.prototype={getIntBoardPt:function(a,b){var c="number"===glift.util.typeOf(a)&&"number"===glift.util.typeOf(b)?glift.util.point(a,b):a;return this.getInt(this.boardPtToPt(c))},getInt:function(a,b){var c="number"===glift.util.typeOf(a)&&"number"===glift.util.typeOf(b)?glift.util.point(a,b):a,d=this.boardArray_[c.y()];return d?d[c.x()]||null:null},ptToBoardPt:function(a){return a.translate(this.bbox_.left(),this.bbox_.top())},boardPtToPt:function(a){return a.translate(-this.bbox_.left(),
-this.bbox_.top())},boardArray:function(){return this.boardArray_},maxBoardSize:function(){return this.maxBoardSize_},height:function(){return this.boardArray_.length},width:function(){return this.boardArray_[0].length},transform:function(a){for(var b=[],c=0;c<this.boardArray_.length;c++){for(var d=[],e=0;e<this.boardArray_[0].length;e++)d.push(a(this.boardArray_[c][e],e,c));b.push(d)}return new glift.flattener.Board(b,this.bbox_,this.maxBoardSize_)},diff:function(a){if(!(a&&a.boardArray_&&a.bbox_&&
a.maxBoardSize_))throw Error("Diff board not defined or not a flattener board");if(this.height()!==a.height()||this.width()!==a.width())throw Error("Boards do not have the same dimensions. This: h:"+this.height()+" w:"+this.width()+" That: h:"+a.height()+" w:"+a.width());for(var b=[],c=0;c<this.boardArray_.length;c++)for(var d=this.boardArray_[c],e=a.boardArray_[c],f=0;f<d.length;f++){var g=d[f],h=e[f];if(!h)break;var k=!1,k=g.equals&&"function"===typeof g.equals?g.equals(h):g===h;k||(k=new glift.Point(f,
c),b.push(new glift.flattener.BoardDiffPt(g,h,k,this.ptToBoardPt(k))))}return b}};glift.flattener.BoardDiffPt=function(a,b,c,d){this.prevValue=a;this.newValue=b;this.colRowPt=c;this.boardPt=d};glift.flattener.emptyFlattenedCache_={};glift.flattener.emptyFlattened=function(a){if(glift.flattener.emptyFlattenedCache_[a])return glift.flattener.emptyFlattenedCache_[a];var b=glift.rules.movetree.getInstance(a),b=glift.flattener.flatten(b);return glift.flattener.emptyFlattenedCache_[a]=b};
glift.flattener.Flattened=function(a){this.board_=a.board;this.collisions_=a.collisions;this.comment_=a.comment;this.isOnMainPath_=a.isOnMainPath;this.baseMoveNum_=a.baseMoveNum;this.startMoveNum_=a.startingMoveNum;this.endMoveNum_=a.endMoveNum;this.mainlineMoveNum_=a.mainlineMoveNum;this.mainlineMove_=a.mainlineMove;this.nextMainlineMove_=a.nextMainlineMove;this.stoneMap_=a.stoneMap;this.markMap_=a.markMap;this.ko_=a.ko;this.correctNextMoves_=a.correctNextMoves;this.problemResult_=a.problemResult};
glift.flattener.Flattened.prototype={board:function(){return this.board_},comment:function(){return this.comment_},ko:function(){return this.ko_},collisions:function(){return this.collisions_},isOnMainPath:function(){return this.isOnMainPath_},baseMoveNum:function(){return this.baseMoveNum_},startingMoveNum:function(){return this.startMoveNum_},endingMoveNum:function(){return this.endMoveNum_},mainlineMoveNum:function(){return this.mainlineMoveNum_},nextMainlineMoveNum:function(){return this.mainlineMoveNum()+
1},mainlineMove:function(){return this.mainlineMove_},nextMainlineMove:function(){return this.nextMainlineMove_},stoneMap:function(){return this.stoneMap_},labels:function(){return this.markMap_.labels},marks:function(){return this.markMap_.marks},setProblemResult:function(a){this.problemResult_=a},problemResult:function(){return this.problemResult_},autoTruncateLabel:function(a){var b=a;if("number"!==typeof a)if("string"===typeof a&&/\d+/.test(a))b=parseInt(a,10);else return a;a=this.endingMoveNum()-
this.startingMoveNum();100<b&&100>a&&0!==b%100&&(b%=100);return b+""}};glift.flattener.intersection={create:function(a,b,c,d,e){var f=glift.flattener.symbols,g=new glift.flattener.Intersection(a);if(0>a.x()||0>a.y()||a.x()>=e||a.y()>=e)throw Error("Pt ("+a.x()+","+a.y()+") is out of bounds.");var h=e-1,k=f.EMPTY,k=0===a.x()&&0===a.y()?f.TL_CORNER:0===a.x()&&a.y()===h?f.BL_CORNER:a.x()===h&&0===a.y()?f.TR_CORNER:a.x()===h&&a.y()===h?f.BR_CORNER:0===a.y()?f.TOP_EDGE:0===a.x()?f.LEFT_EDGE:a.x()===h?f.RIGHT_EDGE:a.y()===h?f.BOT_EDGE:this.isStarpoint_(a,e)?f.CENTER_STARPOINT:
f.CENTER;g.setBase(k);b===glift.enums.states.BLACK?g.setStone(f.BSTONE):b===glift.enums.states.WHITE&&g.setStone(f.WSTONE);void 0!==c&&g.setMark(c);void 0!==d&&g.setTextLabel(d);return g},_starPointSets:{9:[{4:!0}],13:[{3:!0,9:!0},{6:!0}],19:[{3:!0,9:!0,15:!0}]},isStarpoint_:function(a,b){for(var c=glift.flattener.intersection._starPointSets[b],d=0;d<c.length;d++){var e=c[d];if(e[a.x()]&&e[a.y()])return!0}return!1}};
glift.flattener.Intersection=function(a){var b=glift.flattener.symbols.EMPTY;this.pt_=a;this.markLayer_=this.stoneLayer_=this.baseLayer_=b;this.textLabel_=null};
glift.flattener.Intersection.prototype={validateSymbol_:function(a,b){if(!glift.flattener.symbolStr(a))throw Error("Symbol Val: "+a+" is not a defined symbol.");var c=glift.flattener.symbolStr(a);if(!{base:{EMPTY:!0,TL_CORNER:!0,TR_CORNER:!0,BL_CORNER:!0,BR_CORNER:!0,TOP_EDGE:!0,BOT_EDGE:!0,LEFT_EDGE:!0,RIGHT_EDGE:!0,CENTER:!0,CENTER_STARPOINT:!0},stone:{EMPTY:!0,BSTONE:!0,WSTONE:!0},mark:{EMPTY:!0,TRIANGLE:!0,SQUARE:!0,CIRCLE:!0,XMARK:!0,TEXTLABEL:!0,LASTMOVE:!0,NEXTVARIATION:!0}}[b][c])throw Error("Incorrect layer for: "+
c+","+a+". Layer was "+b);return a},equals:function(a){return null==a?!1:this.pt_.equals(a.pt_)&&this.baseLayer_===a.baseLayer_&&this.stoneLayer_===a.stoneLayer_&&this.markLayer_===a.markLayer_&&this.textLabel_===a.textLabel_},base:function(){return this.baseLayer_},stone:function(){return this.stoneLayer_},mark:function(){return this.markLayer_},textLabel:function(){return this.textLabel_},setBase:function(a){this.baseLayer_=this.validateSymbol_(a,"base");return this},setStone:function(a){this.stoneLayer_=
this.validateSymbol_(a,"stone");return this},setMark:function(a){this.markLayer_=this.validateSymbol_(a,"mark");return this},setTextLabel:function(a){this.textLabel_=a+"";return this},clearTextLabel:function(){this.textLabel_=null;return this}};glift.flattener.symbols={EMPTY:0,TL_CORNER:2,TR_CORNER:3,BL_CORNER:4,BR_CORNER:5,TOP_EDGE:6,BOT_EDGE:7,LEFT_EDGE:8,RIGHT_EDGE:9,CENTER:10,CENTER_STARPOINT:11,BSTONE:20,WSTONE:21,TRIANGLE:30,SQUARE:31,CIRCLE:32,XMARK:33,TEXTLABEL:34,LASTMOVE:35,NEXTVARIATION:36};glift.flattener.symbolStoneToState={0:glift.enums.states.EMPTY,20:glift.enums.states.BLACK,21:glift.enums.states.WHITE};
glift.flattener.symbolMarkToMark={30:glift.enums.marks.TRIANGLE,31:glift.enums.marks.SQUARE,32:glift.enums.marks.CIRCLE,33:glift.enums.marks.XMARK,34:glift.enums.marks.LABEL,35:glift.enums.marks.STONE_MARKER,36:glift.enums.marks.VARIATION_MARKER};glift.flattener.reverseSymbol_=null;glift.flattener.symbolStr=function(a){if(null==glift.flattener.reverseSymbol_){var b={},c=glift.flattener.symbols,d;for(d in glift.flattener.symbols)b[c[d]]=d;glift.flattener.reverseSymbol_=b}return glift.flattener.reverseSymbol_[a]};glift.widgets={};glift.widgets.BaseWidget=function(a,b,c,d,e,f,g){this.wrapperDivId=a;this.internalWrapperDivId=a+"-internal-wrapper";this.sgfOptions=b;this.displayOptions=c;this.iconActions=d;this.stoneActions=e;this.manager=f;this.externalHooks=g;this.totalCorrectAnswers=this.numCorrectAnswers=this.correctNextSet=this.correctness=this.initialPlayerColor=this.initialMoveNumber=this.iconBar=this.commentBox=this.statusBar=this.display=this.boardRegion=this.controller=void 0};
glift.widgets.BaseWidget.prototype={draw:function(){this.controller=this.sgfOptions.controllerFunc(this.sgfOptions);this.initialMoveNumber=this.controller.currentMoveNumber();this.initialPlayerColor=this.controller.getCurrentPlayer();glift.util.majorPerfLog("Created controller");var a=this.controller.getIntersections(),b=this.sgfOptions.boardRegion===glift.enums.boardRegions.AUTO?this.controller.getQuadCropFromBeginning():this.sgfOptions.boardRegion;glift.util.majorPerfLog("Calculated board regions");
this.createInternalWrapperDiv_();var c=glift.displays.bboxFromDiv(this.internalWrapperDivId);if(0===c.width()||0===c.height())throw Error("Div for Glift has has invalid dimensions. Bounding box had width: "+c.width()+", height: "+c.height());var d=glift.displays.position.positioner(c,b,a,this.getUiComponents_(this.sgfOptions),this.displayOptions.oneColumnSplits,this.displayOptions.twoColumnSplits).calcWidgetPositioning(),e=this.createDivsForPositioning_(d,this.internalWrapperDivId);glift.util.majorPerfLog("Created divs");
var f=glift.themes.get(this.displayOptions.theme);this.displayOptions.goBoardBackground&&glift.themes.setGoBoardBackground(f,this.displayOptions.goBoardBackground);this.display=glift.displays.create(e[glift.enums.boardComponents.BOARD],d.mustGetBbox(glift.enums.boardComponents.BOARD),f,b,a,this.sgfOptions.rotation,this.displayOptions.drawBoardCoords);glift.util.majorPerfLog("Finish creating display");e[glift.enums.boardComponents.COMMENT_BOX]&&(this.commentBox=glift.displays.commentbox.create(e[glift.enums.boardComponents.COMMENT_BOX],
d.mustGetBbox(glift.enums.boardComponents.COMMENT_BOX),f,this.displayOptions.useMarkdown));glift.util.majorPerfLog("CommentBox");e[glift.enums.boardComponents.ICONBAR]&&(a=glift.util.simpleClone(this.sgfOptions.icons||[]),this.manager.hasNextSgf()&&a.push(this.displayOptions.nextSgfIcon),this.manager.hasPrevSgf()&&a.unshift(this.displayOptions.previousSgfIcon),this.iconBar=glift.displays.icons.bar({divId:e[glift.enums.boardComponents.ICONBAR],positioning:d.mustGetBbox(glift.enums.boardComponents.ICONBAR),
icons:a,parentBbox:c,theme:f,allDivIds:e,allPositioning:d}).draw());glift.util.majorPerfLog("IconBar");e.ICONBAR&&this.iconBar.initIconActions(this,this.iconActions);e[glift.enums.boardComponents.STATUS_BAR]&&(a=glift.util.simpleClone(this.sgfOptions.statusBarIcons),this.manager.fullscreenDivId&&glift.array.replace(a,"fullscreen","unfullscreen"),1<this.manager.sgfCollection.length&&a.splice(0,0,"widget-page"),c=glift.displays.icons.bar({divId:e[glift.enums.boardComponents.STATUS_BAR],positioning:d.mustGetBbox(glift.enums.boardComponents.STATUS_BAR),
icons:a,parentBbox:c,theme:f,allDivIds:e,allPositioning:d}),this.statusBar=glift.displays.statusbar.create({iconBarPrototype:c,theme:f,allPositioning:d,widget:this}).draw());glift.util.majorPerfLog("StatusBar");e.STATUS_BAR&&this.statusBar.iconBar.initIconActions(this,this.iconActions);glift.util.majorPerfLog("Before stone event creation");this.initStoneActions_(this.stoneActions);this.initKeyHandlers_();glift.util.majorPerfLog("After stone event creation");this.initProblemData_();this.applyBoardData(this.controller.flattenedState());
return this},getUiComponents_:function(a){var b=a.uiComponents,b=b.slice(0,b.length),c=function(a,b){var c=a.indexOf(b);-1<c&&a.splice(c,1)},d=glift.enums.boardComponents;a.disableStatusBar&&c(b,d.STATUS_BAR);a.disableBoard&&c(b,d.BOARD);a.disableCommentBox&&c(b,d.COMMENT_BOX);a.disableIconBar&&c(b,d.ICONBAR);return b},createInternalWrapperDiv_:function(){var a=glift.dom.newDiv(this.internalWrapperDivId);a.css({height:"100%",width:"100%",position:"relative"});glift.dom.elem(this.wrapperDivId).append(a)},
createDivsForPositioning_:function(a,b){var c={};a.map(function(a,e){var f=b+"_internal_div_"+glift.util.idGenerator.next(),g=glift.dom.newDiv(f),h={top:e.top()+"px",left:e.left()+"px",width:e.width()+"px",height:e.height()+"px",position:"absolute",cursor:"default"};g.css(h);glift.dom.elem(b).append(g);glift.dom.ux.setNotSelectable(f);c[a]=f});return c},initStoneActions_:function(a){var b,c;b=a.mouseover;c=a.mouseout;a=this.sgfOptions.stoneClick;this.sgfOptions.stoneMouseover&&(b=this.sgfOptions.stoneMouseover);
this.sgfOptions.stoneMouseout&&(c=this.sgfOptions.stoneMouseout);var d=function(a){return function(b,c){this.manager.setActive();a(b,this,c)}.bind(this)}.bind(this);b&&c&&!glift.platform.isMobile()&&this.display.intersections().setHover(d(b),d(c));a&&(b="click",glift.platform.isMobile()&&(b="touchend"),this.display.intersections().setEvent(b,d(a)))},initKeyHandlers_:function(){if(this.displayOptions.enableKeyboardShortcuts){var a=glift.util.simpleClone(this.sgfOptions.keyMappings);this.manager.fullscreenDivId&&
(a.ESCAPE="iconActions.unfullscreen.click");for(var b in a)glift.keyMappings.registerKeyAction(this.manager.id,b,a[b]);glift.keyMappings.initKeybindingListener()}},initProblemData_:function(){if(this.sgfOptions.widgetType===glift.enums.widgetTypes.CORRECT_VARIATIONS_PROBLEM){var a=this.controller.getCorrectNextMoves();this.correctNextSet=this.correctNextSet||{};this.numCorrectAnswers=this.numCorrectAnswers||0;this.totalCorrectAnswers=this.totalCorrectAnswers||this.sgfOptions.totalCorrectVariationsOverride||
a.length;this.iconBar.addTempText("multiopen-boxonly",this.numCorrectAnswers+"/"+this.totalCorrectAnswers,{fill:"black",stroke:"black"})}},hooks:function(){return this.externalHooks},applyBoardData:function(a){a&&(this.setCommentBox(a.comment()),this.statusBar&&this.statusBar.setMoveNumber(a.baseMoveNum()),this.display.updateBoard(a))},setCommentBox:function(a){void 0!==this.commentBox&&(a?this.commentBox.setText(a):this.commentBox.clearText());return this},reload:function(){void 0!==this.correctness&&
(this.totalCorrectAnswers=this.numCorrectAnswers=this.correctNextSet=void 0);this.redraw()},getCurrentState:function(){return{currentTreepath:this.controller.pathToCurrentPosition()}},applyState:function(a){var b=glift.enums.widgetTypes;if(this.sgfOptions.widgetType===b.REDUCED_GAME_VIEWER||this.sgfOptions.widgetType===b.GAME_VIEWER)this.controller.initialize(a.currentTreepath),this.applyBoardData(this.controller.flattenedState())},redraw:function(){this.destroy();var a=this.getCurrentState();this.draw();
this.applyState(a)},destroy:function(){glift.keyMappings.unregisterInstance(this.manager.id);glift.dom.elem(this.wrapperDivId)&&glift.dom.elem(this.wrapperDivId).empty();this.display=this.correctness=void 0}};glift.widgets.WidgetManager=function(a){this.id=a.divId+"-glift-"+glift.util.idGenerator.next();glift.global.instanceRegistry[this.id]=this;!glift.global.activeInstanceId&&this.setActive();this.divId=a.divId;this.oldWindowResize=this.prevScrollTop=this.fullscreenDivId=null;this.sgfCollection=[];this.sgfCollectionUrl=null;this.initSgfCollection_(a);this.sgfCache=a.sgfMapping;this.sgfColIndex=a.initialIndex;this.allowWrapAround=a.allowWrapAround;this.sgfDefaults=a.sgfDefaults;this.displayOptions=a.display;
this.iconActions=a.iconActions;this.stoneActions=a.stoneActions;this.loadColInBack=a.loadCollectionInBackground;this.initBackgroundLoading=!1;this.temporaryWidget=this.currentWidget=void 0;this.metadata=a.metadata;this.hooks=a.hooks};
glift.widgets.WidgetManager.prototype={draw:function(){var a=function(){!this.initBackgroundLoading&&this.loadColInBack&&(this.initBackgroundLoading=!0,this.backgroundLoad());var a=this.getCurrentSgfObj();this.loadSgfString(a,function(a){this.destroy();this.currentWidget=this.createWidget(a).draw()}.bind(this))}.bind(this);0===this.sgfCollection.length&&this.sgfCollectionUrl?glift.ajax.get(this.sgfCollectionUrl,function(b){this.sgfCollection=JSON.parse(b);a()}.bind(this)):a();return this},redraw:function(){this.getCurrentWidget()&&
this.getCurrentWidget().redraw()},setActive:function(){glift.global.activeInstanceId=this.id},getCurrentWidget:function(){return this.temporaryWidget?this.temporaryWidget:this.currentWidget},initSgfCollection_:function(a){if("array"===glift.util.typeOf(a.sgfCollection)){for(var b=a.sgfCollection,c=0;c<b.length;c++)this.sgfCollection.push(b[c]);if(a.sgf&&0<a.sgfCollection.length)throw Error("Illegal options configuration: you cannot define both sgf and sgfCollection");a.sgf&&0===a.sgfCollection.length?
this.sgfCollection.push(a.sgf):a.sgf||0!==this.sgfCollection.length||(this.sgfCollection=[{}])}else"string"===glift.util.typeOf(a.sgfCollection)&&(this.sgfCollectionUrl=a.sgfCollection)},getCurrentSgfObj:function(){return this.getSgfObj(this.sgfColIndex)},hasNextSgf:function(){return this.sgfCollection.length&&0<=this.sgfColIndex&&this.sgfColIndex<this.sgfCollection.length-1?!0:this.sgfCollection.length&&this.sgfColIndex===this.sgfCollection.length-1&&this.allowWrapAround?!0:!1},hasPrevSgf:function(){return this.sgfCollection.length&&
0<this.sgfColIndex&&this.sgfColIndex<=this.sgfCollection.length-1?!0:this.sgfCollection.length&&0===this.sgfColIndex&&this.allowWrapAround?!0:!1},getSgfObj:function(a){if(0>a||a>this.sgfCollection.length)throw Error("Index ["+a+" ] out of bounds. List size was "+this.sgfCollection.length);a=this.sgfCollection[a];if("string"===glift.util.typeOf(a)){var b={};/^\s*\(;/.test(a)?b.sgfString=a:b.url=a;a=b}return this.sgfDefaults.createSgfObj(a)},loadSgfString:function(a,b){var c=a.alias,d=a.url;c&&this.sgfCache[c]?
(a.sgfString=this.sgfCache[c],b(a)):d&&this.sgfCache[d]?(a.sgfString=this.sgfCache[d],b(a)):a.url?this.loadSgfWithAjax(a.url,a,b):(a.alias&&a.sgfString&&(this.sgfCache[a.alias]=a.sgfString),b(a))},loadSgfStringSync:function(a){var b=a.alias,c=a.url;b&&this.sgfCache[b]?a.sgfString=this.sgfCache[b]:c&&this.sgfCache[c]&&(a.sgfString=this.sgfCache[c]);return a},getDivId:function(){return this.fullscreenDivId?this.fullscreenDivId:this.divId},createWidget:function(a){return new glift.widgets.BaseWidget(this.getDivId(),
a,this.displayOptions,this.iconActions,this.stoneActions,this,this.hooks)},createTemporaryWidget:function(a){this.currentWidget&&this.currentWidget.destroy();a=this.sgfDefaults.createSgfObj(a);this.temporaryWidget=this.createWidget(a).draw()},returnToOriginalWidget:function(){this.temporaryWidget&&this.temporaryWidget.destroy();this.temporaryWidget=void 0;this.currentWidget.draw()},nextSgfInternal_:function(a){1< !this.sgfCollection.length||(this.allowWrapAround?this.sgfColIndex=(this.sgfColIndex+
a+this.sgfCollection.length)%this.sgfCollection.length:(this.sgfColIndex+=a,0>this.sgfColIndex?this.sgfColIndex=0:this.sgfColIndex>=this.sgfCollection.length&&(this.sgfColIndex=this.sgfCollection.length-1)),this.draw())},nextSgf:function(){this.nextSgfInternal_(1)},prevSgf:function(){this.nextSgfInternal_(-1)},loadSgfWithAjax:function(a,b,c){glift.ajax.get(a,function(d){this.sgfCache[a]=d;b.sgfString=d;c(b)}.bind(this))},backgroundLoad:function(){var a=function(b){if(b<this.sgfCollection.length){var c=
this.getSgfObj(b);this.loadSgfString(c,function(){setTimeout(function(){a(b+1)}.bind(this),250)})}}.bind(this);a(this.sgfColIndex+1)},isFullscreen:function(){return!!this.fullscreenDivId},enableFullscreenAutoResize:function(){window.onresize&&(this.oldWindowResize=window.onresize);window.onresize=function(){this.redraw()}.bind(this)},disableFullscreenAutoResize:function(){window.onresize=this.oldWindowResize;this.oldWindowResize=null},destroy:function(){this.currentWidget&&this.currentWidget.destroy();
this.currentWidget=void 0;this.temporaryWidget&&this.temporaryWidget.destroy();this.temporaryWidget=void 0;return this}};glift.api={create:function(a){glift.util.perfInit();a=glift.api.createNoDraw(a);glift.init(a.displayOptions.disableZoomForMobile,a.divId);glift.util.majorPerfLog("Finish creating manager");a.draw();glift.util.majorPerfLog("Finish drawing manager");glift.util.perfDone();return a},createNoDraw:function(a){a=new glift.api.Options(a);return new glift.widgets.WidgetManager(a)}};glift.create=glift.api.create;glift.api.DisplayOptions=function(a){a=a||{};this.goBoardBackground=a.goBoardBackground||"";this.theme=a.theme||"DEFAULT";this.drawBoardCoords=!!a.drawBoardCoords||!1;this.oneColumnSplits=a.oneColumnSplits||{first:[{component:"STATUS_BAR",ratio:.06},{component:"BOARD",ratio:.67},{component:"COMMENT_BOX",ratio:.18},{component:"ICONBAR",ratio:.09}]};this.twoColumnSplits=a.twoColumnSplits||{first:[{component:"BOARD",ratio:1}],second:[{component:"STATUS_BAR",ratio:.07},{component:"COMMENT_BOX",ratio:.83},
{component:"ICONBAR",ratio:.1}]};this.previousSgfIcon=a.previousSgfIcon||"chevron-left";this.nextSgfIcon=a.nextSgfIcon||"chevron-right";this.disableZoomForMobile=!!a.disableZoomForMobile||!1;this.enableKeyboardShortcuts=void 0!==a.enableKeyboardShortcuts?!!a.enableKeyboardShortcuts:!0;this.useMarkdown=!!a.useMarkdown||!1};glift.api.HookOptions=function(a){a=a||{};this.getNextSgf=a.getNextSgf||void 0;this.problemCorrect=a.problemCorrect||void 0;this.problemIncorrect=a.problemIncorrect||void 0};glift.api.iconActionDefaults={start:{click:function(a,b,c,d){b.applyBoardData(b.controller.toBeginning())},tooltip:"Go to the beginning"},end:{click:function(a,b,c,d){b.applyBoardData(b.controller.toEnd())},tooltip:"Go to the end"},arrowright:{click:function(a,b,c,d){b.applyBoardData(b.controller.nextMove())},tooltip:"Next move"},arrowleft:{click:function(a,b,c,d){b.applyBoardData(b.controller.prevMove())},tooltip:"Previous move"},"chevron-right":{click:function(a,b,c,d){b.manager.nextSgf()},tooltip:"Next panel"},
"chevron-left":{click:function(a,b,c,d){b.manager.prevSgf()},tooltip:"Previous panel"},refresh:{click:function(a,b,c,d){b.reload()},tooltip:"Try the problem again"},"undo-problem-move":{click:function(a,b,c,d){b.controller.movetree.node().getNodeNum()<=b.initialMoveNumber||(b.initialPlayerColor===b.controller.getCurrentPlayer()&&b.applyBoardData(b.controller.prevMove()),b.applyBoardData(b.controller.prevMove()),b.initialMoveNumber===b.controller.movetree.node().getNodeNum()?b.reload():(a=glift.enums.problemResults,
c=b.controller.correctnessStatus(),b.iconBar.destroyTempIcons(),c===a.CORRECT?(b.iconBar.setCenteredTempIcon("multiopen-boxonly","check","#0CC"),b.correctness=a.CORRECT):c===a.INCORRECT&&(b.iconBar.destroyTempIcons(),b.iconBar.setCenteredTempIcon("multiopen-boxonly","cross","red"),b.correctness=a.INCORRECT)))},tooltip:"Undo last move attempt"},undo:{click:function(a,b,c,d){b.manager.returnToOriginalWidget()},tooltip:"Return to the parent widget"},"jump-left-arrow":{click:function(a,b,c,d){b.applyBoardData(b.controller.previousCommentOrBranch(20))},
tooltip:"Previous branch or comment"},"jump-right-arrow":{click:function(a,b,c,d){b.applyBoardData(b.controller.nextCommentOrBranch(20))},tooltip:"Previous branch or comment"},"problem-explanation":{click:function(a,b,c,d){a=b.manager;b={widgetType:glift.enums.widgetTypes.GAME_VIEWER,initialPosition:b.controller.initialPosition,sgfString:b.controller.originalSgf(),showVariations:glift.enums.showVariations.ALWAYS,problemConditions:glift.util.simpleClone(b.sgfOptions.problemConditions),icons:["jump-left-arrow",
"jump-right-arrow","arrowleft","arrowright","undo"],rotation:b.sgfOptions.rotation,boardRegion:b.sgfOptions.boardRegion};a.createTemporaryWidget(b)},tooltip:"Explore the solution"},multiopen:{click:function(a,b,c,d){glift.displays.icons.iconSelector(b.wrapperDivId,d.divId,c).setIconEvents("click",function(a,b){var c=d.getIcon("multiopen");c.setActive(b.iconName);d.setCenteredTempIcon("multiopen",c.getActive(),"black")})}},"multiopen-boxonly":{mouseover:function(){},mouseout:function(){},click:function(){},
tooltip:"Shows if the problem is solved"},"game-info":{click:function(a,b,c,d){b.statusBar&&b.statusBar.gameInfo(b.controller.getGameInfo(),b.controller.getCaptureCount())},tooltip:"Show the game info"},"move-indicator":{click:function(){},mouseover:function(){},mouseout:function(){},tooltip:"Shows the current move number"},fullscreen:{click:function(a,b,c,d){b.statusBar&&b.statusBar.fullscreen()},tooltip:"Expand display to fill entire screen."},unfullscreen:{click:function(a,b,c,d){a.preventDefault&&
a.preventDefault();a.stopPropagation&&a.stopPropagation();b.statusBar&&b.statusBar.unfullscreen()},tooltip:"Return display original size."},"settings-wrench":{click:function(){},tooltip:"Show Glift Settings"}};glift.api.Options=function(a){a=a||{};this.sgf=a.sgf||void 0;this.sgfDefaults=new glift.api.SgfOptions(a.sgfDefaults);this.divId=a.divId||"glift_display";this.sgfCollection=a.sgfCollection||[];this.sgfMapping=a.sgfMapping||{};this.initialIndex=a.initialIndex||0;this.allowWrapAround=!!a.allowWrapAround||!1;this.loadCollectionInBackground=void 0!==a.loadCollectionInBackground?!!a.loadCollectionInBackground:!0;this.metadata=a.metadata||void 0;this.hooks=new glift.api.HookOptions(a.hooks);this.display=
new glift.api.DisplayOptions(a.display);this.stoneActions=new glift.api.StoneActions(a.stoneActions);this.iconActions=a.iconActions||{};for(var b in glift.api.iconActionDefaults)this.iconActions[b]||(this.iconActions[b]=glift.api.iconActionDefaults[b])};glift.api.SgfOptions=function(a){a=a||{};this.sgfString=void 0!==a.sgfString?a.sgfString:void 0;this.url=void 0!==a.url?a.url:void 0;this.alias=void 0!==a.alias?a.alias:void 0;this.parseType=a.parseType||glift.parse.parseType.SGF;this.widgetType=a.widgetType||glift.enums.widgetTypes.GAME_VIEWER;this.initialPosition=a.initialPosition||"";this.nextMovesPath=a.nextMovesPath||"";this.boardRegion=a.boardRegion||glift.enums.boardRegions.AUTO;this.rotation=a.rotation||glift.enums.rotations.NO_ROTATION;this.uiComponents=
a.uiComponents||[glift.enums.boardComponents.BOARD,glift.enums.boardComponents.COMMENT_BOX,glift.enums.boardComponents.STATUS_BAR,glift.enums.boardComponents.ICONBAR];this.disableStatusBar=!!a.disableStatusBar||!1;this.disableBoard=!!a.disableBoard||!1;this.disableCommentBox=!!a.disableCommentBox||!1;this.disableIconBar=!!a.disableIconBar||!1;this.metadata=a.metadata||void 0;this.correctVariationsResetTime=void 0!==a.correctVariationsResetTime?a.correctVariationsResetTime:750;this.totalCorrectVariationsOverride=
a.totalCorrectVariationsOverride||void 0;this.statusBarIcons=a.statusBarIcons||void 0;this.flattenerExperiment=a.flattenerExperiment||!1;this.keyMappings=a.keyMappings||{ARROW_LEFT:"iconActions.chevron-left.click",ARROW_RIGHT:"iconActions.chevron-right.click"};this.problemConditions=a.problemConditions||{GB:[],C:["Correct","is correct","is the correct"]};this.showVariations=a.showVariations||glift.enums.showVariations.MORE_THAN_ONE;this.markLastMove=void 0!==a.markLastMove?a.markLastMove:!0;this.controllerFunc=
a.controllerFunc||void 0;this.icons=a.icons||void 0;this.stoneClick=a.stoneClick||void 0;this.stoneMouseover=a.stoneMouseover||void 0;this.stoneMouseout=a.stoneMouseout||void 0};
glift.api.SgfOptions.prototype={createSgfObj:function(a){if("object"!==glift.util.typeOf(a))throw Error("SGF must be of type object, was: "+glift.util.typeOf(a)+", for "+a);var b=glift.api.widgetopt[a.widgetType||this.widgetType],c;for(c in b)a[c]||void 0===b[c]||(a[c]=glift.util.simpleClone(b[c]));for(c in this)a[c]||void 0===this[c]||"createSgfObj"===c||(a[c]=this[c]);return new glift.api.SgfOptions(a)}};glift.api.StoneActions=function(a){a=a||{};this.mouseover=a.mouseover||function(a,c,d){a={BLACK:"BLACK_HOVER",WHITE:"WHITE_HOVER"};var e=c.controller.getCurrentPlayer();c.controller.canAddStone(d,e)&&c.display.intersections().setStoneColor(d,a[e])};this.mouseout=a.mouseout||function(a,c,d){a=c.controller.getCurrentPlayer();c.controller.canAddStone(d,a)&&c.display&&c.display.intersections().setStoneColor(d,"EMPTY")};this.touchend=a.touchend||function(a,c,d){a.preventDefault&&a.preventDefault();a.stopPropagation&&
a.stopPropagation();c.sgfOptions.stoneClick(a,c,d)}};glift.api.widgetopt={};(function(){glift.api.widgetopt[glift.enums.widgetTypes.BOARD_EDITOR]={_markMap:{bstone_a:glift.enums.marks.LABEL_ALPHA,bstone_1:glift.enums.marks.LABEL_NUMERIC,bstone_square:glift.enums.marks.SQUARE,bstone_triangle:glift.enums.marks.TRIANGLE},_placementMap:{bstone:glift.enums.states.BLACK,wstone:glift.enums.states.WHITE},markLastMove:void 0,keyMappings:void 0,problemConditions:{},controllerFunc:glift.controllers.boardEditor,icons:["start","end","arrowleft","arrowright","twostones bstone wstone bstone_a bstone_1 bstone_triangle bstone_square nostone-xmark".split(" ")],
showVariations:glift.enums.showVariations.ALWAYS,statusBarIcons:["game-info","move-indicator","fullscreen"],stoneClick:function(a,b,c){b.display.intersections().clearTempMarks();a=glift.widgets.options.BOARD_EDITOR._placementMap;var d=glift.widgets.options.BOARD_EDITOR._markMap,e=b.iconBar.getIcon("multiopen").getActive().iconName,f=b.controller.getCurrentPlayer();a[e]?(c=b.controller.addPlacement(c,a[e]),b.applyBoardData(c)):d[e]?(c=b.controller.addMark(c,d[e]))&&b.applyBoardData(c):"twostones"===
e&&(c=b.controller.addStone(c,f))&&b.applyBoardData(c)},stoneMouseover:function(a,b,c){var d=glift.enums.marks,e=glift.widgets.options.BOARD_EDITOR._markMap,f=glift.widgets.options.BOARD_EDITOR._placementMap,g={BLACK:"BLACK_HOVER",WHITE:"WHITE_HOVER"},h=b.controller.getCurrentPlayer();a=b.display.intersections();var k=b.iconBar.getIcon("multiopen").getActive().iconName;void 0!==f[k]?(d=f[k],b.controller.canAddStone(c,h)&&a.setStoneColor(c,g[d])):"twostones"===k?(d=b.controller.getCurrentPlayer(),
b.controller.canAddStone(c,h)&&a.setStoneColor(c,g[d])):e[k]&&!a.hasMark(c)&&(g=e[k],g===d.LABEL_NUMERIC?a.addTempMark(c,g,b.controller.currentNumericMark()):g===d.LABEL_ALPHA?a.addTempMark(c,g,b.controller.currentAlphaMark()):a.addTempMark(c,g))},stoneMouseout:function(a,b,c){var d=b.controller.getCurrentPlayer(),d=b.iconBar.getIcon("multiopen").getActive().iconName;a=b.display.intersections();if("twostones"===d||"bstone"===d||"wstone"===d)d=b.controller.getCurrentPlayer(),b.controller.canAddStone(c,
d)&&a.setStoneColor(c,"EMPTY");a.clearTempMarks()}}})();glift.api.widgetopt[glift.enums.widgetTypes.CORRECT_VARIATIONS_PROBLEM]={markLastMove:void 0,keyMappings:void 0,problemConditions:void 0,controllerFunc:glift.controllers.staticProblem,icons:["refresh","problem-explanation","multiopen-boxonly"],showVariations:glift.enums.showVariations.NEVER,statusBarIcons:["fullscreen"],stoneClick:function(a,b,c){a=b.controller.getCurrentPlayer();a=b.controller.addStone(c,a);var d=glift.enums.problemResults;if(a.problemResult()!==d.FAILURE){var e=b.hooks();b.applyBoardData(a);
void 0===b.correctness&&(a.problemResult()===d.CORRECT?(b.iconBar.destroyTempIcons(),void 0===b.correctNextSet[c.toString()]&&(b.correctNextSet[c.toString()]=!0,b.numCorrectAnswers++,b.numCorrectAnswers===b.totalCorrectAnswers?(b.correctness=d.CORRECT,b.iconBar.addTempText("multiopen-boxonly",b.numCorrectAnswers+"/"+b.totalCorrectAnswers,{fill:"#0CC",stroke:"#0CC"}),e.problemCorrect&&e.problemCorrect()):(b.iconBar.addTempText("multiopen-boxonly",b.numCorrectAnswers+"/"+b.totalCorrectAnswers,{fill:"#000",
stroke:"#000"}),setTimeout(function(){b.controller.initialize();b.applyBoardData(b.controller.flattenedState())},b.sgfOptions.correctVariationsResetTime)))):a.problemResult()==d.INCORRECT&&(b.iconBar.destroyTempIcons(),b.iconBar.setCenteredTempIcon("multiopen-boxonly","cross","red"),b.iconBar.clearTempText("multiopen-boxonly"),b.correctness=d.INCORRECT,e.problemIncorrect&&e.problemIncorrect()))}},stoneMouseover:void 0,stoneMouseout:void 0};glift.api.widgetopt[glift.enums.widgetTypes.EXAMPLE]={markLastMove:void 0,keyMappings:void 0,problemConditions:{},controllerFunc:glift.controllers.gameViewer,icons:[],showVariations:glift.enums.showVariations.NEVER,statusBarIcons:["fullscreen"],stoneClick:function(a,b,c){},stoneMouseover:function(){},stoneMouseout:function(){}};glift.api.widgetopt[glift.enums.widgetTypes.GAME_VIEWER]={markLastMove:!0,keyMappings:{ARROW_LEFT:"iconActions.arrowleft.click",ARROW_RIGHT:"iconActions.arrowright.click",",":"iconActions.arrowleft.click",".":"iconActions.arrowright.click","<":"iconActions.jump-left-arrow.click",">":"iconActions.jump-right-arrow.click","]":function(a){a.controller.moveUpVariations();a.applyBoardData(a.controller.flattenedState())},"[":function(a){a.controller.moveDownVariations();a.applyBoardData(a.controller.flattenedState())}},
problemConditions:{},controllerFunc:glift.controllers.gameViewer,icons:["jump-left-arrow","jump-right-arrow","arrowleft","arrowright"],showVariations:glift.enums.showVariations.MORE_THAN_ONE,statusBarIcons:["game-info","move-indicator","fullscreen"],stoneClick:function(a,b,c){a=b.controller.getCurrentPlayer();c=b.controller.addStone(c,a);b.applyBoardData(c)},stoneMouseover:void 0,stoneMouseout:void 0};glift.api.widgetopt[glift.enums.widgetTypes.REDUCED_GAME_VIEWER]={markLastMove:void 0,keyMappings:void 0,problemConditions:{},controllerFunc:glift.controllers.gameViewer,icons:["arrowleft","arrowright"],showVariations:glift.enums.showVariations.MORE_THAN_ONE,statusBarIcons:["game-info","move-indicator","fullscreen"],stoneClick:function(a,b,c){a=b.controller.getCurrentPlayer();c=b.controller.addStone(c,a);b.applyBoardData(c)},stoneMouseover:void 0,stoneMouseout:void 0};glift.api.widgetopt[glift.enums.widgetTypes.STANDARD_PROBLEM]={markLastMove:void 0,keyMappings:void 0,problemConditions:void 0,controllerFunc:glift.controllers.staticProblem,icons:["undo-problem-move","problem-explanation","multiopen-boxonly"],showVariations:glift.enums.showVariations.NEVER,statusBarIcons:["fullscreen"],stoneClick:function(a,b,c){a=b.hooks();var d=b.controller.getCurrentPlayer(),e=b.controller.addStone(c,d),f=glift.enums.problemResults;e.problemResult()!==f.FAILURE&&(b.applyBoardData(e),
e.problemResult()===f.CORRECT?(b.iconBar.setCenteredTempIcon("multiopen-boxonly","check","#0CC"),b.correctness=f.CORRECT,a.problemCorrect&&a.problemCorrect(c,d)):e.problemResult()===f.INCORRECT&&(b.iconBar.destroyTempIcons(),b.iconBar.setCenteredTempIcon("multiopen-boxonly","cross","red"),b.correctness=f.INCORRECT,a.problemIncorrect&&a.problemIncorrect(c,d)))},stoneMouseover:void 0,stoneMouseout:void 0};