!function(g,I){"object"==typeof exports&&"undefined"!=typeof module?I(exports):"function"==typeof define&&define.amd?define(["exports"],I):I((g="undefined"!=typeof globalThis?globalThis:g||self).ranui={})}(this,(function(g){"use strict";var I=Object.defineProperty,C=(g,C,A)=>((g,C,A)=>C in g?I(g,C,{enumerable:!0,configurable:!0,writable:!0,value:A}):g[C]=A)(g,"symbol"!=typeof C?C+"":C,A);function A(g,I){for(var C=0;CA[I]})}}return Object.freeze(Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}))}const i=(g,I="text/xml")=>{if(window.DOMParser)return(new window.DOMParser).parseFromString(g,I).documentElement;if(void 0!==window.ActiveXObject){const I=new window.ActiveXObject("Microsoft.XMLDOM");return I.async="false",I.loadXML(g),I}};var e=Object.defineProperty,t=(g,I,C)=>((g,I,C)=>I in g?e(g,I,{enumerable:!0,configurable:!0,writable:!0,value:C}):g[I]=C)(g,"symbol"!=typeof I?I+"":I,C);const l=()=>{},s=()=>{if("undefined"!=typeof window){const g=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(g)?"ipad":/android/.test(g)?"android":/iphone/.test(g)?"iphone":"pc"}return"pc"},o="undefined"!=typeof window,c=()=>{if(!o)return!1;const g=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(g)},d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class a{constructor(g,I){t(this,"highOrder"),t(this,"lowOrder"),this.highOrder=g,this.lowOrder=I}}function n(g){return g<10?`0${g}`:g}function r(g){let I=new Date;return g&&(I=new Date(g)),I.format=(g="YYYY-MM-DD HH:mm:ss")=>{const C=I.getFullYear(),A=n(I.getMonth()+1),i=n(I.getDate()),e=n(I.getHours()),t=n(I.getMinutes()),l=n(I.getSeconds());return g.replace(/Y+/gi,`${C}`).replace(/M+/g,`${A}`).replace(/D+/gi,`${i}`).replace(/H+/gi,`${e}`).replace(/m+/g,`${t}`).replace(/S+/gi,`${l}`)},I}new a(d[0],3609767458),new a(d[1],602891725),new a(d[2],3964484399),new a(d[3],2173295548),new a(d[4],4081628472),new a(d[5],3053834265),new a(d[6],2937671579),new a(d[7],3664609560),new a(d[8],2734883394),new a(d[9],1164996542),new a(d[10],1323610764),new a(d[11],3590304994),new a(d[12],4068182383),new a(d[13],991336113),new a(d[14],633803317),new a(d[15],3479774868),new a(d[16],2666613458),new a(d[17],944711139),new a(d[18],2341262773),new a(d[19],2007800933),new a(d[20],1495990901),new a(d[21],1856431235),new a(d[22],3175218132),new a(d[23],2198950837),new a(d[24],3999719339),new a(d[25],766784016),new a(d[26],2566594879),new a(d[27],3203337956),new a(d[28],1034457026),new a(d[29],2466948901),new a(d[30],3758326383),new a(d[31],168717936),new a(d[32],1188179964),new a(d[33],1546045734),new a(d[34],1522805485),new a(d[35],2643833823),new a(d[36],2343527390),new a(d[37],1014477480),new a(d[38],1206759142),new a(d[39],344077627),new a(d[40],1290863460),new a(d[41],3158454273),new a(d[42],3505952657),new a(d[43],106217008),new a(d[44],3606008344),new a(d[45],1432725776),new a(d[46],1467031594),new a(d[47],851169720),new a(d[48],3100823752),new a(d[49],1363258195),new a(d[50],3750685593),new a(d[51],3785050280),new a(d[52],3318307427),new a(d[53],3812723403),new a(d[54],2003034995),new a(d[55],3602036899),new a(d[56],1575990012),new a(d[57],1125592928),new a(d[58],2716904306),new a(d[59],442776044),new a(d[60],593698344),new a(d[61],3733110249),new a(d[62],2999351573),new a(d[63],3815920427),new a(3391569614,3928383900),new a(3515267271,566280711),new a(3940187606,3454069534),new a(4118630271,4000239992),new a(116418474,1914138554),new a(174292421,2731055270),new a(289380356,3203993006),new a(460393269,320620315),new a(685471733,587496836),new a(852142971,1086792851),new a(1017036298,365543100),new a(1126000580,2618297676),new a(1288033470,3409855158),new a(1501505948,4234509866),new a(1607167915,987167468),new a(1816402316,1246189591),new a(0,1),new a(0,32898),new a(2147483648,32906),new a(2147483648,2147516416),new a(0,32907),new a(0,2147483649),new a(2147483648,2147516545),new a(2147483648,32777),new a(0,138),new a(0,136),new a(0,2147516425),new a(0,2147483658),new a(0,2147516555),new a(2147483648,139),new a(2147483648,32905),new a(2147483648,32771),new a(2147483648,32770),new a(2147483648,128),new a(0,32778),new a(2147483648,2147483658),new a(2147483648,2147516545),new a(2147483648,32896),new a(0,2147483649),new a(2147483648,2147516424);const m=g=>{if(0===g)return"00:00";if(!g)return"";const I=Math.trunc(g/3600),C=Math.trunc(g%3600/60),A=n(Math.trunc(g-3600*I-60*C));return 0===I?`${n(C)}:${A}`:`${n(I)}:${n(C)}:${A}`},h=g=>{const I=g.backingStorePixelRatio||g.webkitBackingStorePixelRatio||g.mozBackingStorePixelRatio||g.msBackingStorePixelRatio||g.oBackingStorePixelRatio||1;return(o&&window.devicePixelRatio||1)/I},Z=(g,I)=>{if("undefined"==typeof document)return;const C=g.classList;C.contains(I)||C.add(I)},b=(g,I)=>{if("undefined"==typeof document)return;const C=g.classList;C.contains(I)&&C.remove(I)},G=g=>{if("undefined"==typeof document)return;const I=document.createDocumentFragment();return g.forEach((g=>I.appendChild(g))),I},u=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"];class p{constructor(g,I){t(this,"listener"),t(this,"element"),t(this,"create",((g,I)=>u.includes(g)?document.createElementNS("http://www.w3.org/2000/svg",g,I):document.createElement(g,I))),t(this,"setAttribute",((g,I)=>(this.element.setAttribute(g,I),this))),t(this,"removeAttribute",(g=>(this.element.removeAttribute(g),this))),t(this,"append",(g=>(this.element.appendChild(g),this))),t(this,"remove",(g=>(this.element.removeChild(g),this))),t(this,"setTextContent",(g=>(this.element.textContent=g,this))),t(this,"setStyle",((g,I)=>(this.element.style.setProperty(g,I),this))),t(this,"addElementByType",((g,I)=>{g instanceof p&&I.appendChild(g.element),g instanceof HTMLElement&&I.appendChild(g)})),t(this,"addChild",(g=>{if(Array.isArray(g)){const I=document.createDocumentFragment();g.forEach((g=>{this.addElementByType(g,I)})),this.element.appendChild(I)}else this.addElementByType(g,this.element);return this})),t(this,"listen",((g,I,C)=>{let A=this.listener.get(g);A||(A=new Map,this.listener.set(g,A));const i=A.get(I.name);return i===I&&console.warn(`${i.name} listener has been added to ${g} event, please remove it first.`),this.element.addEventListener(g,I,C),A.set(I.name,I),this})),t(this,"clearListener",((g,I,C)=>{this.element.removeEventListener(g,I,C);const A=this.listener.get(g);return A?A.delete(I.name):console.warn(`No ${g} event listener has been added.`),this})),t(this,"clearAllListener",(()=>{for(const[g,I]of this.listener){for(const[C,A]of I)this.element.removeEventListener(g,A),I.delete(C);this.listener.delete(g)}return this})),this.element=this.create(g,I),this.listener=new Map}}const w=(g,I)=>new p(g,I),W=()=>{let g;return function(I,C=300){return function(...A){g&&(clearTimeout(g),g=void 0);const i=this;g||(g=setTimeout((()=>{I.apply(i,A),clearTimeout(g),g=void 0}),C))}}},B=new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]);(function(g){const I=new Map;for(const[C,A]of g)I.set(A.toLowerCase(),C)})(B),function(g){const I=[];for(const[C,A]of g)I.push(C)}(B);const y=(g="")=>{if(0===g.length)return 0;if(g.endsWith("%")){const I=Number(g.replace("%",""));return I>1?I/100:I}return Number(g)},V=(g,I=0,C=1)=>Math.min(C,Math.max(I,g)),X=class{constructor(){t(this,"getDecimalLength",(g=>{const[I,C]=g.toString().split(".");return C?C.length:0})),t(this,"amend",((g,I=15)=>parseFloat(Number(g).toPrecision(I)))),t(this,"power",((g,I)=>Math.pow(10,Math.max(this.getDecimalLength(g),this.getDecimalLength(I)))))}};t(X,"handleMethod",((g,I)=>{const C=new X,{power:A,amend:i}=C,e=A(g,I),t=i(g*e),l=i(I*e);return g=>{switch(g){case"+":return(t+l)/e;case"-":return(t-l)/e;case"*":return t*l/(e*e);case"/":return t/l}}})),t(X,"add",((g,I)=>X.handleMethod(g,I)("+"))),t(X,"divide",((g,I)=>X.handleMethod(g,I)("/"))),t(X,"multiply",((g,I)=>X.handleMethod(g,I)("*"))),t(X,"subtract",((g,I)=>X.handleMethod(g,I)("-")));const Y="NEW_LISTENER";class R{constructor(){t(this,"_events"),t(this,"tap",((g,I)=>{this._events[g]&&g!==Symbol.for(Y)&&this.call(Symbol.for(Y),g);const C=this._events[g]||[];return"function"==typeof I?C.push({name:g,callback:I}):C.push(I),this._events[g]=C,this})),t(this,"call",((g,...I)=>{(this._events[g]||[]).forEach((g=>{const{callback:C}=g;C(...I)}))})),t(this,"callSync",(async(g,...I)=>{const C=this._events[g]||[];for(const A of C){const{callback:g}=A;await g(...I)}})),t(this,"once",((g,I)=>{let C;if("function"==typeof I)C={name:g,callback:(...A)=>{I(...A),this.off(g,C)},initialCallback:I};else{const{callback:A}=I;C={name:g,callback:(...I)=>{A(...I),this.off(g,C)},initialCallback:A}}return this.tap(g,C),this})),t(this,"off",((g,I)=>{const C=(this._events[g]||[]).filter((g=>{if("function"==typeof I)return g.callback!==I&&g.initialCallback!==I;{const{callback:C}=I;return g.callback!==C&&g.initialCallback!==C}}));return this._events[g]=C,this})),this._events={}}}const N=[!1,"false",null,void 0],H=g=>{const I=g.hasAttribute("disabled"),C=g.getAttribute("disabled");return!(!I||N.includes(C))};function K(g=""){return class{constructor(I=g){C(this,"message"),this.message=I}}}const f=()=>"undefined"!=typeof document?HTMLElement:null,F=(g,I)=>{const C={value:g,subscribers:new Set,comparator:null==I?void 0:I.equals},{subscriber:A}=I||{};A&&Array.isArray(A)&&A.forEach((g=>{"function"!=typeof g||C.subscribers.has(g)||C.subscribers.add(g)}));const i=g=>{C.value!==g&&(C.value=g,C.subscribers.forEach((I=>I(g))))};return[()=>C.value,g=>{const{comparator:I}=C;if(I instanceof Function)return!I(C.value,g)&&i(g);void 0===I?C.value!==g&&i(g):!I&&i(g)}]};let M=class extends(f()){constructor(){super(),C(this,"_btn"),C(this,"_btnContent"),C(this,"_iconElement"),C(this,"_slot"),C(this,"_shadowDom"),C(this,"debounceTimeId"),C(this,"setIcon",(()=>{if(this.icon){const{width:g,height:I}=this._slot.getBoundingClientRect(),C=Math.min(g,I);this._iconElement?this._iconElement.setAttribute("name",this.icon):(this._iconElement=document.createElement("r-icon"),this._iconElement.setAttribute("name",this.icon),this._iconElement.setAttribute("color","currentColor"),this._iconElement.setAttribute("class","icon"),this._slot.insertAdjacentElement("beforebegin",this._iconElement)),this.iconSize?this._iconElement.setAttribute("size",this.iconSize):this._iconElement.setAttribute("size",""+(C-5))}})),C(this,"mousedown",(g=>{if("pc"===s()&&(!this.disabled||"false"===this.disabled)){this.debounceMouseEvent();const{left:I,top:C}=this.getBoundingClientRect();this._btn.style.setProperty("--ran-x",g.clientX-I+"px"),this._btn.style.setProperty("--ran-y",g.clientY-C+"px")}})),C(this,"mouseup",(g=>{"pc"===s()&&(this.debounceTimeId||(this.debounceTimeId=setTimeout((()=>{this._btn.style.removeProperty("--ran-x"),this._btn.style.removeProperty("--ran-y"),this.debounceMouseEvent()}),600)))})),C(this,"debounceMouseEvent",(()=>{clearTimeout(this.debounceTimeId),this.debounceTimeId=void 0})),C(this,"handlerExternalCss",(()=>{if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}})),this._slot=document.createElement("slot"),this._btnContent=document.createElement("div"),this._btn=document.createElement("div"),this._btn.setAttribute("class","ran-btn"),this._btn.setAttribute("part","ran-btn"),this._btnContent.setAttribute("class","ran-btn-content"),this._btnContent.setAttribute("part","ran-btn-content"),this._btnContent.appendChild(this._slot),this._slot.setAttribute("class","slot");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-btn-position, relative);display:var(--ran-btn-display, inline-block);background-image:var(--ran-btn-background-image, none);box-shadow:var(--ran-btn-box-shadow, 0 2px #00000004);cursor:var(--ran-btn-cursor, pointer);-webkit-user-select:var(--ran-btn-user-select, none);user-select:var(--ran-btn-user-select, none);touch-action:var(--ran-btn-touch-action, manipulation);overflow:var(--ran-btn-overflow, hidden);pointer-events:var(--ran-btn-pointer-events, auto)}:host .ran-btn{position:var(--ran-btn-contain-position, relative);display:var(--ran-btn-contain-display, inline-block);background-image:var(--ran-btn-contain-background-image, none);cursor:var(--ran-btn-contain-cursor, pointer);transition:var(--ran-btn-contain-transition, all .3s cubic-bezier(.645, .045, .355, 1));-webkit-user-select:var(--ran-btn-contain-user-select, none);user-select:var(--ran-btn-contain-user-select, none);touch-action:var(--ran-btn-contain-touch-action, manipulation);background:var(--ran-btn-contain-background, #fff)}:host,:host(:active),:host(:focus){outline:0;-webkit-tap-highlight-color:transparent}:host .ran-btn,:host(:active) .ran-btn,:host(:focus) .ran-btn{outline:var(--ran-btn-contain-outline, 0)}:host([type="primary"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, #1890ff);border-color:var(--ran-btn-content-border-color, #1890ff);color:var(--ran-btn-content-color, #fff)}:host([type="primary"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}@media (min-width: 1024px){:host(:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-hover-border-color, #1890ff);color:var(--ran-btn-content-hover-color, #1890ff)}:host([type="primary"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, #40a9ff);color:var(--ran-btn-content-hover-color, #fff)}:host([type="warning"]:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, #ff4d4f);background-color:var(--ran-btn-content-warning-background-color, #ff4d4f);color:var(--ran-btn-content-warning-color, #fff)}}:host([type="warning"]) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, #ff4d4f);background-color:var(--ran-btn-content-warning-background-color, #ff4d4f);color:var(--ran-btn-content-warning-color, #fff)}:host([type="warning"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="text"]) .ran-btn-content{border:var(--ran-btn-content-text-border, none)}:host([disabled]){cursor:var(--ran-btn-disabled-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-pointer-events, all);opacity:var(--ran-btn-disabled-opacity, .6)}:host([disabled]) .ran-btn{cursor:var(--ran-btn-disabled-container-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-container-pointer-events, all);opacity:var(--ran-btn-disabled-container-opacity, .6)}:host(:not([disabled]):active) .ran-btn:after{transform:var(--ran-btn-after-transform, translate(-50%, -50%) scale(0));opacity:var(--ran-btn-after-opacity, .3);transition:var(--ran-btn-after-transition, 0s)}@media (min-width: 1024px){:host(:not([disabled],[effect])) .ran-btn:after{content:"";display:block;position:absolute;width:100%;height:100%;left:var(--ran-x, 0);top:var(--ran-y, 0);pointer-events:none;background-image:radial-gradient(circle,#1890ff 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:translate(-50%,-50%) scale(10);opacity:0;transition:transform .3s,opacity .8s}}:host .slot{display:var(--ran-btn-slot-display, block)}.ran-btn-content{display:var(--ran-btn-content-display, flex);justify-content:var(--ran-btn-content-display, space-between);align-items:var(--ran-btn-content-align-items, center);padding:var(--ran-btn-content-padding, 4px 15px);border:var(--ran-btn-content-border, 1px solid transparent);border-radius:var(--ran-btn-content-border-radius, 2px);border-color:var(--ran-btn-content-border-color, #d9d9d9);color:var(--ran-btn-content-color, #000000d9);line-height:var(--ran-btn-content-line-height, 22px);font-size:var(--ran-btn-content-font-size, 14px);font-weight:var(--ran-btn-content-font-weight, 400);white-space:var(--ran-btn-content-white-space, nowrap);text-align:var(--ran-btn-content-text-align, center)}.ran-btn-content .icon{margin-right:var(--ran-btn-icon-margin-right, 2px)}',g.appendChild(I),this._shadowDom=g,this._btn.appendChild(this._btnContent),g.appendChild(this._btn)}static get observedAttributes(){return["disabled","icon","effect","iconSize","sheet"]}get sheet(){return this.getAttribute("sheet")||""}set sheet(g){this.setAttribute("sheet",g||"")}get disabled(){return H(this)}set disabled(g){g&&"false"!==g?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled"))}get iconSize(){return this.getAttribute("iconSize")||""}set iconSize(g){g&&"false"!==g?(this.setAttribute("iconSize",g),this.setIcon()):this.removeAttribute("iconSize")}get icon(){return this.getAttribute("icon")||""}set icon(g){g&&"false"!==g?(this.setAttribute("icon",g),this.setIcon()):this.removeAttribute("icon")}get effect(){return this.getAttribute("effect")||""}set effect(g){N.includes(g)||!g?this.removeAttribute("effect"):this.setAttribute("effect",g)}connectedCallback(){this._btn.addEventListener("mousedown",this.mousedown),this._btn.addEventListener("mouseup",this.mouseup),this.handlerExternalCss(),this.setIcon(),this.setAttribute("role","button"),this.setAttribute("tabindex","0")}disconnectCallback(){this._btn.removeEventListener("mousedown",this.mousedown),this._btn.removeEventListener("mouseup",this.mouseup)}attributeChangedCallback(g,I,C){"disabled"===g&&this._btnContent&&(C&&"false"!==C?this._btnContent.removeAttribute("disabled"):this._btnContent.setAttribute("disabled","")),"icon"===g&&this._btnContent&&I!==C&&this.setIcon(),"iconSize"===g&&this._btnContent&&I!==C&&this._btnContent.setAttribute("iconSize",C),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}};const S="undefined"==typeof document||customElements.get("r-button")?K("document is undefined or r-button is exist"):(customElements.define("r-button",M),M),J=Object.freeze(Object.defineProperty({__proto__:null,Button:M,default:S},Symbol.toStringTag,{value:"Module"})),k=(g,I,C)=>{const A=g[I];return A?"function"==typeof A?A():Promise.resolve(A):new Promise(((g,A)=>{("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(A.bind(null,new Error("Unknown variable dynamic import: "+I+(I.split("/").length!==C?". Note that variables only represent file names one level deep.":""))))}))},D="http://www.w3.org/1999/xlink",v="xlink:href";const L=function(){if("undefined"!=typeof window&&!customElements.get("r-icon")){class g extends HTMLElement{constructor(){super(),C(this,"_icon"),C(this,"_div"),C(this,"loadLocal",(()=>new Promise(((g,I)=>{k(Object.assign({"../../assets/icons/add-user.svg":()=>Promise.resolve().then((()=>dI)),"../../assets/icons/arrow-down.svg":()=>Promise.resolve().then((()=>aI)),"../../assets/icons/book.svg":()=>Promise.resolve().then((()=>nI)),"../../assets/icons/check-circle-fill.svg":()=>Promise.resolve().then((()=>rI)),"../../assets/icons/check-circle.svg":()=>Promise.resolve().then((()=>mI)),"../../assets/icons/close-circle-fill.svg":()=>Promise.resolve().then((()=>hI)),"../../assets/icons/close-circle.svg":()=>Promise.resolve().then((()=>ZI)),"../../assets/icons/close.svg":()=>Promise.resolve().then((()=>bI)),"../../assets/icons/drop.svg":()=>Promise.resolve().then((()=>GI)),"../../assets/icons/eye-close.svg":()=>Promise.resolve().then((()=>uI)),"../../assets/icons/eye.svg":()=>Promise.resolve().then((()=>pI)),"../../assets/icons/home.svg":()=>Promise.resolve().then((()=>wI)),"../../assets/icons/info-circle-fill.svg":()=>Promise.resolve().then((()=>WI)),"../../assets/icons/info-circle.svg":()=>Promise.resolve().then((()=>BI)),"../../assets/icons/loading-scene.svg":()=>Promise.resolve().then((()=>yI)),"../../assets/icons/loading.svg":()=>Promise.resolve().then((()=>VI)),"../../assets/icons/lock.svg":()=>Promise.resolve().then((()=>XI)),"../../assets/icons/message.svg":()=>Promise.resolve().then((()=>YI)),"../../assets/icons/power-off.svg":()=>Promise.resolve().then((()=>RI)),"../../assets/icons/preview.svg":()=>Promise.resolve().then((()=>NI)),"../../assets/icons/setting.svg":()=>Promise.resolve().then((()=>HI)),"../../assets/icons/sprite.svg":()=>Promise.resolve().then((()=>fI)),"../../assets/icons/team.svg":()=>Promise.resolve().then((()=>FI)),"../../assets/icons/unlock.svg":()=>Promise.resolve().then((()=>MI)),"../../assets/icons/user.svg":()=>Promise.resolve().then((()=>SI)),"../../assets/icons/warning-circle-fill.svg":()=>Promise.resolve().then((()=>JI)),"../../assets/icons/warning-circle.svg":()=>Promise.resolve().then((()=>kI))}),`../../assets/icons/${this.name}.svg`,5).then((C=>{if(C&&C.default&&C.default._identification){const{data:I}=C.default;this._icon&&this._div.removeChild(this._icon),this._icon=i(I,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),g())}else this.loadNs(),I(`\n couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)})).catch((g=>{this.loadNs()}))})))),C(this,"loadNs",(()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const g=document.createElementNS(D,"use");g.setAttributeNS(D,v,`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(g),this._div.appendChild(this._icon)})),C(this,"setIcon",(async()=>{this.name&&this.loadLocal()})),C(this,"setSize",(()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))})),C(this,"setColor",(()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))})),C(this,"setSpin",(()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)})),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-icon-host-display, inline-flex)}:host([spin]){animation-name:var(--ran-icon-host-spin-animation-name, rotate);animation-duration:var(--ran-icon-host-spin-animation-name, 1.4s);animation-timing-function:linear;animation-iteration-count:var(--ran-icon-host-spin-animation-name, infinite)}.ran-icon{display:var(--ran-icon-display, flex);align-items:var(--ran-icon-align-items, center);justify-content:var(--ran-icon-justify-content, center)}@keyframes rotate{to{transform:var(--ran-icon-keyframes-to-transform, rotate(360deg))}}",g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(g){g&&this.setAttribute("name",g)}get size(){return this.getAttribute("size")}set size(g){g&&this.setAttribute("size",g)}get color(){return this.getAttribute("color")}set color(g){g&&this.setAttribute("color",g)}get spin(){return this.getAttribute("spin")}set spin(g){null!=g&&this.setAttribute("spin",g)}connectedCallback(){this.setIcon()}attributeChangedCallback(g,I,C){C!==I&&("name"===g&&this.setIcon(),"size"===g&&this.setSize(),"color"===g&&this.setColor(),"spin"===g&&this.setSpin())}}customElements.define("r-icon",g)}if("undefined"!=typeof window&&!customElements.get("ra-icon")){class g extends HTMLElement{constructor(){super(),C(this,"_icon"),C(this,"_div"),C(this,"loadLocal",(()=>new Promise(((g,I)=>{k(Object.assign({"../../assets/icons/add-user.svg":()=>Promise.resolve().then((()=>dI)),"../../assets/icons/arrow-down.svg":()=>Promise.resolve().then((()=>aI)),"../../assets/icons/book.svg":()=>Promise.resolve().then((()=>nI)),"../../assets/icons/check-circle-fill.svg":()=>Promise.resolve().then((()=>rI)),"../../assets/icons/check-circle.svg":()=>Promise.resolve().then((()=>mI)),"../../assets/icons/close-circle-fill.svg":()=>Promise.resolve().then((()=>hI)),"../../assets/icons/close-circle.svg":()=>Promise.resolve().then((()=>ZI)),"../../assets/icons/close.svg":()=>Promise.resolve().then((()=>bI)),"../../assets/icons/drop.svg":()=>Promise.resolve().then((()=>GI)),"../../assets/icons/eye-close.svg":()=>Promise.resolve().then((()=>uI)),"../../assets/icons/eye.svg":()=>Promise.resolve().then((()=>pI)),"../../assets/icons/home.svg":()=>Promise.resolve().then((()=>wI)),"../../assets/icons/info-circle-fill.svg":()=>Promise.resolve().then((()=>WI)),"../../assets/icons/info-circle.svg":()=>Promise.resolve().then((()=>BI)),"../../assets/icons/loading-scene.svg":()=>Promise.resolve().then((()=>yI)),"../../assets/icons/loading.svg":()=>Promise.resolve().then((()=>VI)),"../../assets/icons/lock.svg":()=>Promise.resolve().then((()=>XI)),"../../assets/icons/message.svg":()=>Promise.resolve().then((()=>YI)),"../../assets/icons/power-off.svg":()=>Promise.resolve().then((()=>RI)),"../../assets/icons/preview.svg":()=>Promise.resolve().then((()=>NI)),"../../assets/icons/setting.svg":()=>Promise.resolve().then((()=>HI)),"../../assets/icons/sprite.svg":()=>Promise.resolve().then((()=>fI)),"../../assets/icons/team.svg":()=>Promise.resolve().then((()=>FI)),"../../assets/icons/unlock.svg":()=>Promise.resolve().then((()=>MI)),"../../assets/icons/user.svg":()=>Promise.resolve().then((()=>SI)),"../../assets/icons/warning-circle-fill.svg":()=>Promise.resolve().then((()=>JI)),"../../assets/icons/warning-circle.svg":()=>Promise.resolve().then((()=>kI))}),`../../assets/icons/${this.name}.svg`,5).then((C=>{if(C&&C.default&&C.default._identification){const{data:I}=C.default;this._icon&&this._div.removeChild(this._icon),this._icon=i(I,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),g())}else this.loadNs(),I(`\n couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)})).catch((g=>{this.loadNs()}))})))),C(this,"loadNs",(()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const g=document.createElementNS(D,"use");g.setAttributeNS(D,v,`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(g),this._div.appendChild(this._icon)})),C(this,"setIcon",(async()=>{this.name&&this.loadLocal()})),C(this,"setSize",(()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))})),C(this,"setColor",(()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))})),C(this,"setSpin",(()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)})),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon")}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(g){g&&this.setAttribute("name",g)}get size(){return this.getAttribute("size")}set size(g){g&&this.setAttribute("size",g)}get color(){return this.getAttribute("color")}set color(g){g&&this.setAttribute("color",g)}get spin(){return this.getAttribute("spin")}set spin(g){null!=g&&this.setAttribute("spin",g)}connectedCallback(){this.appendChild(this._div),this.setIcon()}attributeChangedCallback(g,I,C){C!==I&&("name"===g&&this.setIcon(),"size"===g&&this.setSize(),"color"===g&&this.setColor(),"spin"===g&&this.setSpin())}}customElements.define("ra-icon",g)}}(),z=Object.freeze(Object.defineProperty({__proto__:null,default:L},Symbol.toStringTag,{value:"Module"}));const T=function(){if("undefined"!=typeof window&&!customElements.get("r-img")){class g extends HTMLElement{constructor(){super(),C(this,"_image"),C(this,"_container"),this._container=document.createElement("div"),this._container.setAttribute("class","ran-image");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",g.appendChild(I),g.appendChild(this._container)}static get observedAttributes(){return["fallback"]}get fallback(){return this.getAttribute("fallback")||"\n data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8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bEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==\n"}set fallback(g){g?this.setAttribute("fallback",g):this.removeAttribute("fallback")}listenFallback(g,I){"fallback"===g&&this._image&&(I?this._image.setAttribute("fallback",I):this._image.removeAttribute("fallback"))}connectedCallback(){const g=this.getAttribute("src")||"";this._image=new Image,this._image.src=g,this._image.addEventListener("error",(()=>{this._image&&this.fallback&&(this._image.src=this.fallback)})),this._image.addEventListener("load",(()=>{this._image&&this._container.appendChild(this._image)}))}attributeChangedCallback(g,I,C){this.listenFallback(g,C)}}customElements.define("r-img",g)}}(),x=Object.freeze(Object.defineProperty({__proto__:null,default:T},Symbol.toStringTag,{value:"Module"}));let U=class extends(f()){constructor(){super(),C(this,"_input"),C(this,"_label"),C(this,"_inputContent"),C(this,"_icon"),C(this,"customInput",(g=>{g.stopPropagation(),g.preventDefault();const{target:I,data:C=""}=g;this.value=(null==I?void 0:I.value)||C||"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))})),C(this,"customChange",(()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))})),C(this,"listenPlaceholder",((g,I)=>{"placeholder"===g&&this._inputContent&&(null!=I?this._inputContent.setAttribute("placeholder",I):this._inputContent.removeAttribute("placeholder"))})),C(this,"listenLabel",((g,I)=>{"label"===g&&this._inputContent&&(null!=I?this._label?this._label.innerHTML=I:(this._label=document.createElement("label"),this._label.innerHTML=I,this._label.setAttribute("class","ran-input-label"),this._label.setAttribute("part","ran-input-label"),this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))})),C(this,"listenType",((g,I)=>{"type"===g&&this._inputContent&&(I?this._inputContent.setAttribute("type",I):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))})),C(this,"listenStatus",((g,I)=>{"status"===g&&this._input&&(I?this._input.setAttribute("status",I):this._input.removeAttribute("status"))})),C(this,"listenDisabled",((g,I)=>{"disabled"===g&&this._input&&(N.includes(I)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))})),C(this,"listenIcon",((g,I,C)=>{"icon"===g&&I&&I!==C&&(this.removeAttribute("label"),this.setAttribute("icon",I),this.dealIcon())})),C(this,"dealIcon",(()=>{if(!this._icon){this._icon=document.createElement("ra-icon");const{width:g,height:I}=this._inputContent.getBoundingClientRect(),C=Math.min(g,I);this._icon.setAttribute("size",`${C}`),this._inputContent.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)})),C(this,"listenEvent",((g,I,C)=>{this.listenPlaceholder(g,C),this.listenLabel(g,C),this.listenStatus(g,C),this.listenDisabled(g,C),this.listenIcon(g,C,I),"value"===g&&I!==C&&(this._inputContent.value=C,this._input.setAttribute("value",C))}));const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-input{position:var(--ran-input-position, relative);display:var(--ran-input-display, flex);width:var(--ran-input-width, calc(100% - 16px) );height:var(--ran-input-height, calc(100% - 4px) );min-width:0;padding:var(--ran-input-padding, 2px 8px);color:#000000d9;font-size:var(--ran-input-font-size, 12px);line-height:var(--ran-input-line-height, 1.5715);background-color:var(--ran-input-background-color, #fff);background-image:var(--ran-input-background-image, none);border:var(--ran-input-border, 1px solid #d9d9d9);border-radius:var(--ran-input-border-radius, 2px);transition:var(--ran-input-transition, all .3s)}.ran-input .ran-icon{display:var(--ran-input-icon-display, flex);align-items:var(--ran-input-icon-align-items, center);justify-content:var(--ran-input-icon-justify-content, center)}.ran-input:active{border-color:var(--ran-input-active-border-color, #40a9ff);box-shadow:var(--ran-input-active-box-shadow, 0 0 0 2px rgba(24, 144, 255, .2));border-right-width:var(--ran-input-active-border-right-width, 1px);outline:var(--ran-input-active-outline, 0)}.ran-input:hover{border-color:var(--ran-input-hover-border-color, #40a9ff);border-right-width:var(--ran-input-hover-border-right-width, 1px)}.ran-input>.ran-input-content:hover~.ran-input-label{color:var(--ran-input-label-hover-color, #40a9ff)}.ran-input[value]>.ran-input-label{transform:var(--ran-input-label-value-transform, translateY( calc(-50% - .43em) ) scale(.8));color:var(--ran-input-label-value-color, #00000040)}.ran-input[status=error]{border-color:var(--ran-input-status-error-border-color, #ff4d4f)}.ran-input[status=error]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-error-color, #ff4d4f)}.ran-input[status=warning]{border-color:var(--ran-input-status-warning-border-color, #ff7875)}.ran-input[status=warning]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-warning-color, #ff7875)}.ran-input[disabled]{color:var(--ran-input-disabled-color, #00000040);background-color:var(--ran-input-disabled-background-color, #f5f5f5);border-color:var(--ran-input-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-disabled-box-shadow, none);cursor:var(--ran-input-disabled-cursor, not-allowed);opacity:var(--ran-input-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content{color:var(--ran-input-content-disabled-color, #00000040);background-color:var(--ran-input-content-disabled-background-color, #f5f5f5);border-color:var(--ran-input-content-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-content-disabled-box-shadow, none);cursor:var(--ran-input-content-disabled-cursor, not-allowed);opacity:var(--ran-input-content-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-disabled-color, #00000040);background-color:var(--ran-input-label-disabled-background-color, #f5f5f5)}.ran-input[disabled]>.ran-input-label{color:#999;border-color:var(--ran-input-label-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-label-disabled-box-shadow, none);cursor:var(--ran-input-label-disabled-cursor, not-allowed)}.ran-input-content{writing-mode:var(--ran-input-content-writing-mode, horizontal-tb);text-rendering:var(--ran-input-content-text-rendering, auto);letter-spacing:var(--ran-input-content-letter-spacing, normal);word-spacing:var(--ran-input-content-word-spacing, normal);text-transform:var(--ran-input-content-text-transform, none);text-indent:var(--ran-input-content-text-indent, 0px);text-shadow:var(--ran-input-content-text-shadow, none);text-align:var(--ran-input-content-text-align, start);cursor:var(--ran-input-content-cursor, text);touch-action:var(--ran-input-content-touch-action, manipulation);-webkit-appearance:var(--ran-input-content--webkit-appearance, none);text-overflow:var(--ran-input-content-text-overflow, ellipsis);box-sizing:var(--ran-input-content-box-sizing, border-box);margin:var(--ran-input-content-margin, 0);font-variant:var(--ran-input-content-font-variant, tabular-nums);list-style:var(--ran-input-content-list-style, none);font-feature-settings:var(--ran-input-content-font-feature-settings, "tnum");position:var(--ran-input-content-position, relative);border:var(--ran-input-content-border, none);width:var(--ran-input-content-width, 100%);min-width:var(--ran-input-content-min-width, 0);color:var(--ran-input-content-color, #000000d9);font-size:var(--ran-input-content-font-size, 14px);line-height:var(--ran-input-content-line-height, 1.48);background-color:var(--ran-input-content-background-color, #fff);background-image:var(--ran-input-content-background-image, none);transition:var(--ran-input-content-transition, all .3s);outline:var(--ran-input-content-outline, none)}.ran-input-content:focus,.ran-input-content:hover{border:var(--ran-input-content-hover-border, none);outline:var(--ran-input-content-hover-outline, 0)}.ran-input-content::placeholder{color:var(--ran-input-content-placeholder-color, #999)}.ran-input-content:placeholder-shown~.ran-input-label{transform:var(--ran-input-content-placeholder-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content:focus~.ran-input-label{transform:var(--ran-input-content-focus-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-input-label{pointer-events:var(--ran-input-label-pointer-events, none);position:var(--ran-input-label-position, absolute);font-size:var(--ran-input-label-font-size, 14px);left:var(--ran-input-label-left, 8px);transition:var(--ran-input-label-transition, transform .3s, color .3s, background-color .3s, backdrop-filter .3s);transform-origin:var(--ran-input-label-transform-origin, left);padding:var(--ran-input-label-padding, 0 .2em);color:var(--ran-input-label-color, #999);background:var(--ran-input-label-background, #fff);opacity:var(--ran-input-label-opacity, .9)}',g.appendChild(I),this._input=document.createElement("div"),this._input.setAttribute("class","ran-input"),this._input.setAttribute("part","ran-input"),this._inputContent=document.createElement("input"),this._inputContent.setAttribute("class","ran-input-content"),this._inputContent.setAttribute("part","ran-input-content"),this._input.appendChild(this._inputContent),g.appendChild(this._input)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","prefix","suffix","allowclear","count","maxlength","showcount","onPressEnter","variant","minrows","maxrows"]}get value(){return this.getAttribute("value")||""}set value(g){!H(this)&&g?(this.setAttribute("value",g),this._input.setAttribute("value",g)):(this.removeAttribute("value"),this._input.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(g){g?this.setAttribute("placeholder",g):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")||""}set required(g){g&&"false"!==g?this.setAttribute("required",""):this.removeAttribute("required")}get disabled(){return`${H(this)}`}set disabled(g){N.includes(g)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(g){this.setAttribute("label",g)}get status(){return this.getAttribute("status")||""}set status(g){g?(this.setAttribute("status",g),this._input.setAttribute("status",g)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(g){this.setAttribute("name",g)}get min(){return this.getAttribute("min")||""}set min(g){"number"===this.type&&this.setAttribute("min",g)}get max(){return this.getAttribute("max")||""}set max(g){"number"===this.type&&this.setAttribute("max",g)}get step(){return this.getAttribute("step")||""}set step(g){"number"===this.type&&this.setAttribute("step",g)}get icon(){return this.getAttribute("icon")||""}set icon(g){g?this.setAttribute("icon",g):this.removeAttribute("icon")}get prefix(){return this.getAttribute("prefix")||""}set prefix(g){g?this.setAttribute("prefix",g):this.removeAttribute("prefix")}get suffix(){return this.getAttribute("suffix")||""}set suffix(g){g?this.setAttribute("suffix",g):this.removeAttribute("suffix")}get type(){return this.getAttribute("type")||""}set type(g){g?this.setAttribute("type",g):this.removeAttribute("type")}connectedCallback(){this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this.status&&this._input.setAttribute("status",this.status),H(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this._inputContent.addEventListener("input",this.customInput),"complete"===document.readyState&&this.dealIcon()}disconnectCallback(){this._inputContent.removeEventListener("input",this.customInput)}attributeChangedCallback(g,I,C){this.listenEvent(g,I,C)}};const j="undefined"==typeof window||customElements.get("r-input")?K("document is undefined or r-input is exist"):(customElements.define("r-input",U),U),Q=Object.freeze(Object.defineProperty({__proto__:null,Input:U,default:j},Symbol.toStringTag,{value:"Module"})),O='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host([type="toast"]) .ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}:host([type="toast"]) .ran-message-notice-content{display:inline-block;padding:10px 16px;background:#000000b3;border-radius:7px;pointer-events:all}:host([type="toast"]) .ran-message-notice-content-info{align-items:center;display:flex}:host([type="toast"]) .ran-message-notice-content-info span{margin:0;padding:0;font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";z-index:1010;width:100%;pointer-events:none;color:#fff}.ran-message-notice{padding:var(--ran-message-notice-padding, 8px);text-align:var(--ran-message-notice-text-align, center);max-width:var(--ran-message-notice-max-width, 90%);margin:var(--ran-message-notice-margin, 0 auto);word-break:var(--ran-message-notice-word-break, break-all)}.ran-message-notice-content{display:var(--ran-message-notice-content-display, inline-block);padding:var(--ran-message-notice-content-padding, 10px 16px);background:var(--ran-message-notice-content-background, #fff);border-radius:var(--ran-message-notice-content-border-radius, 8px);box-shadow:var(--ran-message-notice-content-box-shadow, 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d);pointer-events:var(--ran-message-notice-content-pointer-events, all)}.ran-message-notice-content-info{align-items:var(--ran-message-notice-content-info-align-items, center);display:var(--ran-message-notice-content-info-display, flex)}.ran-message-notice-content-info span{margin:var(--ran-message-notice-content-info-span-margin, 0);padding:var(--ran-message-notice-content-info-span-padding, 0);color:var(--ran-message-notice-content-info-span-color, #000000d9);font-size:var(--ran-message-notice-content-info-span-font-size, 14px);font-variant:var(--ran-message-notice-content-info-span-font-variant, tabular-nums);list-style:var(--ran-message-notice-content-info-span-list-style, none);font-feature-settings:var(--ran-message-notice-content-info-span-font-feature-settings, "tnum");z-index:var(--ran-message-notice-content-info-span-z-index, 1010);width:var(--ran-message-notice-content-info-span-width, 100%);pointer-events:var(--ran-message-notice-content-info-span-pointer-events, none)}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:var(--ran-message-box-sizing, border-box);margin:var(--ran-message-margin, 0);padding:var(--ran-message-padding, 0);color:var(--ran-message-color, #000000d9);font-size:var(--ran-message-font-size, 14px);font-variant:var(--ran-message-font-variant, tabular-nums);line-height:var(--ran-message-line-height, 1.5715);list-style:var(--ran-message-ist-style, none);font-feature-settings:var(--ran-message-font-feature-settings, "tnum");position:var(--ran-message-position, fixed);top:var(--ran-message-top, 8px);left:var(--ran-message-left, 0);z-index:var(--ran-message-z-index, 1010);width:var(--ran-message-width, 100%);pointer-events:var(--ran-message-pointer-events, none)}.ranui-message .message-in{animation-name:var(--ran-message-in-animation-name, MessageMoveIn);animation-duration:var(--ran-message-in-animation-duration, .3s);animation-timing-function:var(--ran-message-in-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}.ranui-message .message-leave{animation-name:var(--ran-message-leave-animation-name, MessageMoveOut);animation-duration:var(--ran-message-leave-animation-duration, .3s);animation-timing-function:var(--ran-message-leave-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}',E=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),P=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#1890ff"],["toast","rgba(0, 0, 0, 0.7)"]]);const _=function(){if("undefined"!=typeof window&&!customElements.get("r-message")){class g extends HTMLElement{constructor(){super(),C(this,"_info"),C(this,"_notice"),C(this,"_content"),C(this,"_icon"),C(this,"_span"),C(this,"timeId"),C(this,"close"),C(this,"setIcon",(g=>{var I,C,A,i;const e=E.get(g),t=P.get(g);e&&(null==(I=this._icon)||I.setAttribute("name",e),null==(C=this._icon)||C.style.setProperty("margin-right","8px"),null==(A=this._icon)||A.setAttribute("size","18"),t&&(null==(i=this._icon)||i.setAttribute("color",t)))})),this._notice=document.createElement("div"),this._notice.setAttribute("class","ran-message-notice"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-message-notice-content"),this._info=document.createElement("div"),this._info.setAttribute("class","ran-message-notice-content-info"),this._icon=document.createElement("r-icon"),this._span=document.createElement("span"),this._info.appendChild(this._icon),this._info.appendChild(this._span),this._content.appendChild(this._info),this._notice.appendChild(this._content);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=O,g.appendChild(I),g.appendChild(this._notice)}static get observedAttributes(){return["type","content"]}get type(){return this.getAttribute("type")}set type(g){g&&this.setAttribute("type",g)}get content(){return this.getAttribute("content")}set content(g){g&&this.setAttribute("content",g)}attributeChangedCallback(g,I,C){"content"===g&&I!==C&&(this._span.textContent=C),"type"===g&&I!==C&&this.setIcon(C)}}customElements.define("r-message",g);const I=document.createElement("div"),A=w("style").setTextContent(O),i=document.createElement("div");i.setAttribute("class","ranui-message"),document.body.appendChild(I),I.appendChild(A.element),I.appendChild(i);const e=I=>C=>{const A=new g;A.setAttribute("class","message"),A.timeId&&clearTimeout(A.timeId),A.setAttribute("type",I);let e,t=3e3;if(!C)return;"string"==typeof C?A.setAttribute("content",C):(A.setAttribute("content",C.content),e=C.close,t=C.duration||3e3);const l=setTimeout((()=>{A.classList.remove("message-in"),A.classList.add("message-leave"),clearTimeout(l)}),t-300);A.timeId=setTimeout((()=>{A.classList.remove("message-leave"),i.removeChild(A),e&&e()}),t),i.appendChild(A),A.classList.add("message-in"),setTimeout((()=>{A.classList.remove("message-in")}),300)};return{info:e("info"),success:e("success"),error:e("error"),warning:e("warning"),toast:e("toast")}}return{}}();"undefined"!=typeof window&&_&&(window.message=_,window.ranui||(window.ranui={}),window.ranui.message=_);const q=Object.freeze(Object.defineProperty({__proto__:null,default:_},Symbol.toStringTag,{value:"Module"})),$='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.r-preview-slot{display:block}:host{cursor:pointer}.r-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;font-size:16px}.r-preview-mask .r-preview-options{width:100%;pointer-events:auto;display:flex;flex-flow:row-reverse nowrap;align-items:center;justify-content:space-between}.r-preview-mask .r-preview-options-close{margin:14px;border:none;cursor:pointer;transition:all .3s;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:center;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main{width:100%;height:100%;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet{font-size:13px;line-height:normal;-webkit-user-select:none;user-select:none;-moz-user-select:none;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;box-sizing:content-box;background:#fff;-webkit-font-smoothing:antialiased}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sheet{position:relative;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-table{vertical-align:bottom}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip{font-family:inherit;position:absolute;padding:5px 10px;color:#fff;border-radius:1px;background:#000;font-size:12px;z-index:201}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip:before{pointer-events:none;position:absolute;left:calc(50% - 4px);top:-4px;content:"";width:8px;height:8px;background:inherit;-webkit-transform:rotate(45deg);transform:rotate(45deg);z-index:1;box-shadow:1px 1px 3px -1px #0000004d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette{padding:5px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:2;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td{margin:0;cursor:pointer;border:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td:hover{border-color:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette{padding:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:0;background:#fff;table-layout:fixed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table td{margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{width:30px;height:30px;cursor:pointer;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;left:0;top:-3px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown{position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{position:absolute;z-index:200;background:#fff;box-shadow:1px 2px 5px 2px #33333326}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer{position:absolute;z-index:11}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal{cursor:row-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;left:0;bottom:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical{cursor:col-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar{position:absolute;bottom:0;right:0;background-color:#f4f5f8;opacity:.9;z-index:12}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal{right:15px;overflow-x:scroll;overflow-y:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal>div{height:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical{bottom:15px;overflow-x:hidden;overflow-y:scroll}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical>div{width:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer{position:absolute;left:0;top:0;z-index:10}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{position:absolute;overflow:hidden;pointer-events:none;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector{box-sizing:content-box;position:absolute;overflow:hidden;pointer-events:none;top:0;left:0;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input{position:absolute;z-index:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input input{padding:0;width:0;border:none!important}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-area{position:absolute;border:2px solid #4b89ff;background:#4b89ff1a;z-index:5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{position:absolute;background:transparent;z-index:100}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed rgba(0,0,0,.45)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;position:absolute;cursor:crosshair;font-size:0;height:5px;width:5px;right:-5px;bottom:-5px;border:2px solid #ffffff;background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor{z-index:20}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area{position:absolute;text-align:left;border:2px solid #4b89ff;line-height:0;z-index:100;pointer-events:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;border:none;padding:0 3px;outline:none;resize:none;text-align:start;overflow-y:hidden;font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;color:inherit;white-space:normal;word-wrap:break-word;line-height:22px;margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area .textline{overflow:hidden;visibility:hidden;position:fixed;top:0;left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item{-webkit-user-select:none;user-select:none;background:0;border:1px solid transparent;outline:none;height:26px;color:#000000e6;line-height:26px;list-style:none;padding:2px 10px;cursor:default;text-align:left;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.active{background:#0000000d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.divider{height:0;padding:0;margin:5px 0;border:none;border-bottom:1px solid rgba(0,0,0,.1)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state{padding-left:35px!important;position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state:before{content:"";position:absolute;width:10px;height:10px;left:12px;top:calc(50% - 5px);background:#00000014;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state.checked:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state.checked:before{background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox{position:relative;display:inline-block;backface-visibility:hidden;outline:0;vertical-align:baseline;font-style:normal;font-size:1rem;line-height:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox>input{position:absolute;top:0;left:0;opacity:0!important;outline:0;z-index:-1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-contextmenu,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter{position:absolute;box-shadow:1px 2px 5px 2px #33333326;background:#fff;z-index:100;width:260px;pointer-events:auto;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest{width:200px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter{border:1px solid #e9e9e9;font-size:12px;margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-header{padding:.5em .75em;background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{height:40px;padding:0 30px;text-align:left;background:#f5f6f7;display:flex}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{position:relative;border-top:1px solid #e0e2e4}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar .x-spreadsheet-menu>li{line-height:40px;height:40px;padding-top:0;padding-bottom:0;vertical-align:middle;border-right:1px solid #e8eaed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu{list-style:none;margin:0;padding:0;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li{float:left;line-height:1.25em;padding:.785em 1em;margin:0;vertical-align:middle;text-align:left;font-weight:400;color:#80868b;white-space:nowrap;cursor:pointer;transition:all .3s;font-weight:700}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li.active{background-color:#fff;color:#000000a6}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print{position:absolute;left:0;top:0;z-index:100;width:100%;height:100%;display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar{background:#424242;height:60px;line-height:60px;padding:0 30px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-title{color:#fff;font-weight:700;font-size:1.2em;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content{display:flex;flex:auto;flex-direction:row;background:#d0d0d0;height:calc(100% - 60px)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-sider{flex:0 0 300px;width:300px;border-left:2px solid #ccc;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-content{flex:auto;overflow-x:auto;overflow-y:scroll;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card-wraper{margin:40px 20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card{background:#fff;margin:auto;page-break-before:auto;page-break-after:always;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar{color:#000000a6;background:#fff;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header{font-weight:700;line-height:30px;text-align:center;width:100%;float:left;background:#f9fafb}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-left{padding-left:5px;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a{padding:3px 0;margin-right:2px;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td{width:14.28571429%;min-width:32px;text-align:center;font-weight:700;line-height:30px;padding:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active:hover{background:#ecf6fd;color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-datepicker{box-shadow:2px 2px 5px #0003;position:absolute;left:0;top:calc(100% + 5px);z-index:10;width:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons{display:flex;justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button{display:inline-block;border-radius:3px;line-height:1em;min-height:1em;white-space:nowrap;text-align:center;cursor:pointer;font-size:1em;font-weight:700;padding:.75em 1em;color:#0009;background:#e0e1e2;text-decoration:none;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;outline:none;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;transition:all .1s linear}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button:hover{background-color:#c0c1c2;color:#000c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input{font-size:1em;position:relative;font-weight:400;display:inline-flex;color:#000000de}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input{z-index:1;margin:0;max-width:100%;flex:1 0 auto;outline:0;-webkit-tap-highlight-color:rgba(255,255,255,0);text-align:left;line-height:30px;height:30px;padding:0 8px;background:#fff;border:1px solid #e9e9e9;border-radius:3px;transition:box-shadow .1s ease,border-color .1s ease;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select{position:relative;display:inline-block;background:#fff;border:1px solid #e9e9e9;border-radius:2px;cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;min-width:60px;width:auto;height:30px;line-height:30px;padding:0 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields{display:flex;flex-direction:row;flex-wrap:wrap}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 1 auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field .label{display:inline-block;margin:0 10px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field{display:block;vertical-align:middle;margin-left:10px;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field:first-child{margin-left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error .x-spreadsheet-form-select,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error input{border-color:#f04134}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer{display:none;position:absolute;top:0!important;left:0!important;width:100%;height:100%;text-align:center;vertical-align:middle;background-color:#0009;opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.5s;animation-duration:.5s;transition:background-color .5s linear;-webkit-user-select:none;user-select:none;z-index:1000}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer.active{display:block;opacity:1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset{border:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset label{display:block;margin-bottom:.5em;font-size:1em;color:#666}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset select{font-size:1.1em;width:100%;background-color:#fff;border:none;border-bottom:2px solid #ddd;padding:.5em .85em;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{font-size:13px;position:fixed;z-index:1001;text-align:left;line-height:1.25em;min-width:360px;color:#000000de;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;border-radius:4px;border:1px solid rgba(0,0,0,.1);background-color:#fff;background-clip:padding-box;box-shadow:#0003 0 2px 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{background-color:#ffffffd9}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{font-weight:600;background-clip:padding-box;background-color:#ffffffd9;border-bottom:1px solid rgba(0,0,0,.05);border-radius:4px 4px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{color:#f2711c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header{border-bottom:1px solid #e0e2e4;background:#00000014;font-size:1.0785em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-content,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-content{padding:.75em 1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu li:first-child{display:none}.r-preview-mask .r-preview-contain .r-preview-context .docx-wrapper{background:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section{width:100%;height:690px;position:relative;border:1px solid #333;background-color:#efefef;text-align:center;border-radius:10px;box-shadow:1px 1px 3px #aaa;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.block{position:absolute;top:0;left:0;width:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.content{display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-up{justify-content:flex-start}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-mid{justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-down{justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-left{align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-mid{align-items:center;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-right{align-items:flex-end;text-align:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-left{justify-content:flex-start;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-center{justify-content:flex-start;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-right{justify-content:flex-start;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-left{justify-content:center;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-center{justify-content:center;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-right{justify-content:center;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-left{justify-content:flex-end;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-center{justify-content:flex-end;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-right{justify-content:flex-end;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main li.slide{margin:10px 0;font-size:18px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main div.footer{text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section td{border:1px solid black}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section svg.drawing{position:absolute;overflow:visible}',gg="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Ig="application/vnd.ms-excel",{warning:Cg=l}=_;const Ag=async function(){if("undefined"!=typeof document&&!customElements.get("r-preview")){const{renderPptx:g}=await Promise.resolve().then((()=>tC)),{renderDocx:I}=await Promise.resolve().then((()=>ii)),{renderPdf:A}=await Promise.resolve().then((()=>ti)),{renderExcel:i}=await Promise.resolve().then((()=>Yo)),e=(g,I)=>{if("undefined"==typeof XMLHttpRequest)throw new Error("XMLHttpRequest is not defined");return"undefined"==typeof document?Promise.reject("document is not defined"):new Promise((function(C,A){const i=new XMLHttpRequest;i.open(I.method||"GET",g,!0),i.responseType=I.responseType||"arraybuffer",i.onload=function(){if(200===i.status){const g={success:!0,data:i.response,message:""};I.onLoad&&I.onLoad(g),C(g)}else{const g={success:!1,data:i.status,message:`The request status is${i.status}`};I.onError&&I.onError(g),A(g)}},i.onerror=function(g){const C={success:!1,data:g,message:""};I.onError&&I.onError(C),A(C)},i.onprogress=g=>{I.onProgress&&I.onProgress(g)},i.withCredentials=I.withCredentials||!1,I.headers&&Object.keys(I.headers).forEach((function(g){(null==I?void 0:I.headers)&&i.setRequestHeader(g,I.headers[g])})),i.send(I.body)}))},t=new Map([["application/pdf",A],["application/vnd.openxmlformats-officedocument.presentationml.presentation",(I,C)=>{const{dom:A,onError:i,onLoad:e}=C;return new Promise(((C,t)=>{const l=new FileReader;l.readAsArrayBuffer(I),l.onload=()=>{var I;if(l.result&&A){const t={pptx:l.result,resultElement:A,onError:i,onLoad:e};null==(I=g(t))||I.then((()=>{C()}))}},l.onerror=g=>{t(g)},l.onabort=g=>{t(g)}}))}],["application/vnd.openxmlformats-officedocument.wordprocessingml.document",(g,C)=>{const{dom:A,onError:i,onLoad:e}=C;return Promise.resolve().then((()=>I({buffer:g,bodyContainer:A}))).then((()=>{e&&e({success:!0,message:""})})).catch((g=>{i&&i({success:!0,data:g,message:""})}))}],[gg,i],[Ig,i]]);class l extends HTMLElement{constructor(){super(),C(this,"_loadingText"),C(this,"preview"),C(this,"previewContext"),C(this,"_slot"),C(this,"_div"),C(this,"_loadingElement"),C(this,"createLoading",(()=>{this._loadingElement=document.createElement("div"),this._loadingElement.setAttribute("class","r-preview-loading");const g=document.createElement("r-icon");return g.setAttribute("name","loading"),g.setAttribute("size","100"),g.setAttribute("color","#1E90FF"),g.setAttribute("spin",""),this._loadingText=document.createElement("div"),this._loadingElement.appendChild(g),this._loadingText.setAttribute("class","r-preview-loading-text"),this._loadingElement.appendChild(this._loadingText),this._loadingElement})),C(this,"onProgress",(g=>{const I=g.loaded/g.total*100,C=Math.min(99,I).toFixed(2)+"%";this._loadingText&&this._loadingElement&&(this._loadingText.innerText=`Loading ${C}`,I>=100&&setTimeout((()=>{this._loadingText.innerText="Loading..."}),300))})),C(this,"onError",(()=>{var g;null==(g=this.preview)||g.removeChild(this._loadingElement)})),C(this,"onLoad",(()=>{var g;null==(g=this.preview)||g.removeChild(this._loadingElement)})),C(this,"handleFile",(async g=>{try{if("string"==typeof g){const{success:I,data:C,message:A}=await e(g,{onProgress:this.onProgress,onError:this.onError,responseType:"blob"});if(I&&C){g=new File([C],C.name,{type:C.type});const{type:I}=g,A=t.get(I);if(A&&this.previewContext){this.previewContext.style.setProperty("width","100%");A(g,{dom:this.previewContext,onError:this.onError,onLoad:this.onLoad})}}else Cg(A)}}catch(I){}})),C(this,"closePreview",(()=>{this.preview&&(document.body.removeChild(this.preview),this.preview=void 0)})),C(this,"showPreview",(()=>{var g;if(this.src){if(this.preview)this.preview.style.display="block";else{this.preview=document.createElement("div"),this.preview.setAttribute("class","r-preview-mask"),this.preview.setAttribute("id","r-preview-mask");const I=document.createElement("div");if(I.setAttribute("class","r-preview-options"),"false"!==this.closeable){const g=document.createElement("r-icon");g.setAttribute("class","r-preview-options-close"),g.setAttribute("name","close-circle-fill"),g.setAttribute("size","40"),g.addEventListener("click",this.closePreview),I.appendChild(g)}const C=document.createElement("div");C.setAttribute("class","r-preview-contain"),this.previewContext=document.createElement("div"),this.previewContext.setAttribute("class","r-preview-context"),C.appendChild(this.previewContext),this.preview.appendChild(I),null==(g=this.preview)||g.appendChild(C),this._loadingElement=this.createLoading(),this.preview.appendChild(this._loadingElement),document.body.appendChild(this.preview)}this.handleFile(this.src)}})),this._div=document.createElement("div"),this.preview=document.getElementById("r-preview-mask"),this._slot=document.createElement("slot"),this._div.appendChild(this._slot),this._slot.setAttribute("class","r-preview-slot"),this._div.setAttribute("class","r-preview");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=$,g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["src","closeable"]}get label(){return this.getAttribute("label")}set label(g){g&&this.setAttribute("label",g)}get src(){return this.getAttribute("src")}set src(g){g&&this.setAttribute("src",g)}get closeable(){return this.getAttribute("closeable")}set closeable(g){g&&this.setAttribute("closeable",g)}connectedCallback(){this.preview=document.getElementById("r-preview-mask"),this.addEventListener("click",this.showPreview)}disconnectedCallback(){this.removeEventListener("click",this.showPreview)}attributeChangedCallback(g,I,C){C!==I&&"src"===g&&C&&(this.setAttribute("src",C),this.showPreview())}}if("undefined"!=typeof document&&!customElements.get("r-preview")){customElements.define("r-preview",l);const g=w("style").setTextContent($);document.body.appendChild(g.element)}}}(),ig=Object.freeze(Object.defineProperty({__proto__:null,default:Ag},Symbol.toStringTag,{value:"Module"}));const eg=function(){if("undefined"!=typeof window&&!customElements.get("r-skeleton")){class g extends HTMLElement{constructor(){super(),C(this,"_div"),this._div=document.createElement("div"),this._div.setAttribute("class","ran-skeleton");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:#0000000f;border-radius:4px}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,#0000000f 25%,#00000026 37%,#0000000f 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""}',g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["disabled"]}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(g,I,C){}}window.customElements.define("r-skeleton",g)}}(),tg=Object.freeze(Object.defineProperty({__proto__:null,default:eg},Symbol.toStringTag,{value:"Module"}));const lg=function(){if("undefined"!=typeof window&&!customElements.get("r-tab")){class g extends HTMLElement{constructor(){super(),C(this,"_div"),C(this,"parent"),C(this,"initAttribute",(()=>{var g,I,C;this.parent=this.parentNode,this.key&&(null==(g=this.parent)||g.updateAttribute(this.key,"icon",this.icon)),this.key&&(null==(I=this.parent)||I.updateAttribute(this.key,"iconSize",this.iconSize)),this.key&&(null==(C=this.parent)||C.updateAttribute(this.key,"effect",this.effect))})),this._div=document.createElement("slot");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize"]}get label(){return this.getAttribute("label")||""}set label(g){this.setAttribute("label",g)}get icon(){return this.getAttribute("icon")}set icon(g){g&&"false"!==g?this.setAttribute("icon",g):this.removeAttribute("icon")}get iconSize(){return this.getAttribute("iconSize")}set iconSize(g){g&&"false"!==g?this.setAttribute("iconSize",g):this.removeAttribute("iconSize")}get key(){return this.getAttribute("r-key")}set key(g){g?this.setAttribute("r-key",g):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(g){g&&"false"!==g?this.setAttribute("disabled",g):this.removeAttribute("disabled")}get effect(){return this.getAttribute("effect")}set effect(g){g&&"false"!==g?this.setAttribute("effect",g):this.removeAttribute("effect")}onClick(g){}connectedCallback(){this._div.addEventListener("click",this.onClick),document.addEventListener("DOMContentLoaded",this.initAttribute)}disconnectCallback(){document.removeEventListener("DOMContentLoaded",this.initAttribute)}attributeChangedCallback(g,I,C){var A,i,e,t,l;I!==C&&this.key&&(null==(A=this.parent)?void 0:A.updateAttribute)&&("icon"===g&&(null==(i=this.parent)||i.updateAttribute(this.key,"icon",C)),"iconSize"===g&&(null==(e=this.parent)||e.updateAttribute(this.key,"iconSize",C)),"effect"===g&&(null==(t=this.parent)||t.updateAttribute(this.key,"effect",C)),"disabled"===g&&(null==(l=this.parent)||l.updateAttribute(this.key,"disabled",C)))}}return customElements.define("r-tab",g),g}}(),sg=Object.freeze(Object.defineProperty({__proto__:null,default:lg},Symbol.toStringTag,{value:"Module"}));const og=function(){if("undefined"!=typeof window&&!customElements.get("r-tabs")){class g extends HTMLElement{constructor(){super(),C(this,"_container"),C(this,"_header"),C(this,"_nav"),C(this,"_line"),C(this,"_content"),C(this,"_wrap"),C(this,"_slot"),C(this,"tabHeaderKeyMapIndex"),C(this,"initTabHeaderKeyMapIndex",((g,I)=>{if(this.tabHeaderKeyMapIndex[g])throw new Error("tab 组件的 key 值存在重复,或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[g]=I})),C(this,"initTabLineAlignCenter",(()=>{const{length:g}=this._nav.children;let I=0;for(let C=0;C{const{length:g}=this._nav.children;let I=0;for(let C=0;C{if(g){const I=this.tabHeaderKeyMapIndex[g],C=this._nav.children[I],{width:A=0}=C.getBoundingClientRect();this._line.style.setProperty("width",`${A}px`);let i=0;for(let g=0;g{if(g){const I=this.tabHeaderKeyMapIndex[g];this._wrap.style.setProperty("transform",`translateX(${-100*I}%)`)}})),C(this,"clickTabHead",(g=>{const I=g.target,C=I.getAttribute("r-key");!H(I)&&C&&(this.setAttribute("active",C),this.setTabLine(C),this.setTabContent(C),((g,I)=>{const C=g.querySelectorAll(`.${I}`);C.length>0&&C.forEach((g=>g.classList.remove(I)))})(this._nav,"active"),Z(I,"active"))})),C(this,"updateAttribute",((g,I,C="")=>{var A,i;const e=this.tabHeaderKeyMapIndex[g];g&&C&&this._nav.children[e]?null==(A=this._nav.children[e])||A.setAttribute(I,C):null==(i=this._nav.children[e])||i.removeAttribute(I)})),C(this,"initActive",(()=>{const g=[...this._nav.children],I=g.filter((g=>!H(g)));let C;if(null!=this.active&&(C=I.find((g=>g.getAttribute("r-key")===this.active)),null==C||C.setAttribute("r-key",this.active)),C||(C=I.shift()),!C)return;const A=g.findIndex((g=>g===C)),i=(null==C?void 0:C.getAttribute("r-key"))||`${A}`;null!=i&&(this.setAttribute("active",`${i}`),Z(C,"active"),this.setTabContent(i),setTimeout((()=>{this.setTabLine(i)}),200))})),C(this,"listenSlotChange",(()=>{this._slot.assignedElements().forEach(((g,I)=>{const C=this.createTabHeader(g,I);this._nav.appendChild(C),C.addEventListener("click",this.clickTabHead)})),this.initActive(),this.align&&("center"===this.align&&this.initTabLineAlignCenter(),"end"===this.align&&this.initTabLineAlignEnd())})),C(this,"initTab",(()=>{this._slot.addEventListener("slotchange",this.listenSlotChange)})),C(this,"unloadTab",(()=>{this._slot.removeEventListener("slotchange",this.listenSlotChange)})),this._container=document.createElement("div"),this._container.setAttribute("class","ran-tab"),this._header=document.createElement("div"),this._header.setAttribute("class","ran-tab-header"),this._nav=document.createElement("div"),this._nav.setAttribute("class","ran-tab-header-nav"),this._line=document.createElement("div"),this._line.setAttribute("class","ran-tab-header-line"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-tab-content"),this._wrap=document.createElement("div"),this._wrap.setAttribute("class","ran-tab-content-wrap"),this._slot=document.createElement("slot"),this._wrap.appendChild(this._slot),this._content.appendChild(this._wrap),this._header.appendChild(G([this._nav,this._line])),this._container.appendChild(G([this._header,this._content])),this.tabHeaderKeyMapIndex={};const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--active-color, #1890ff)}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--line-color, #1890ff);border:solid 1px transparent;border-color:var(--border-color, rgba(0, 0, 0, .2)) var(--border-color, rgba(0, 0, 0, .2)) transparent;border-radius:var(--border-radius, .25em) var(--border-radius, .25em) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--border-color, rgba(0, 0, 0, .2))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}',g.appendChild(I),g.appendChild(this._container)}static get observedAttributes(){return["active","forceRender","type","align","effect"]}get align(){return this.getAttribute("align")||"start"}set align(g){this.setAttribute("align",g)}set type(g){this.setAttribute("type",g)}get type(){return this.getAttribute("type")||"flat"}get active(){return this.getAttribute("active")}set active(g){g?(this.setAttribute("active",g),this.setTabLine(g),this.setTabContent(g)):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(g){g&&"false"!==g?this.setAttribute("effect",g):this.removeAttribute("effect")}createTabHeader(g,I){const C=g.getAttribute("label")||"",A=g.getAttribute("icon")||"",i=g.getAttribute("iconSize")||"",e=g.getAttribute("r-key")||`${I}`,t=g.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(e,I);const l=document.createElement("r-button");return l.setAttribute("class","tab-header-nav-item"),l.setAttribute("type",t),A&&l.setAttribute("icon",A),i&&l.setAttribute("iconSize",i),H(g)&&l.setAttribute("disabled",""),l.setAttribute("r-key",e),this.effect&&(g.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),g.setAttribute("r-key",e),l.innerHTML=C,l}connectedCallback(){this.initTab()}disconnectCallback(){this.unloadTab()}attributeChangedCallback(g,I,C){if(I!==C){if(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),"align"===g&&("center"===C&&this.initTabLineAlignCenter(),"end"===C&&this.initTabLineAlignEnd()),"effect"===g){[...this._nav.children].forEach((g=>{this.effect&&"false"!==this.effect?g.setAttribute("effect",C):g.removeAttribute("effect")}))}"active"===g&&this.setAttribute(g,C)}}}return customElements.define("r-tabs",g),g}}(),cg=Object.freeze(Object.defineProperty({__proto__:null,default:og},Symbol.toStringTag,{value:"Module"})),dg="#e6e6e6",ag="#e6e6e6",ng="rgba(255,121,35,0.60)",rg="rgba(255,121,35,0.60)";const mg=function(){if("undefined"==typeof document||customElements.get("r-radar"))return K("document is undefined or r-radar is exist");{class g extends HTMLElement{constructor(){super(),C(this,"mData"),C(this,"mCount"),C(this,"mW"),C(this,"mCenter"),C(this,"mRadius"),C(this,"mAngle"),C(this,"abilityRadarChartContainer"),C(this,"abilityRadarChart"),C(this,"_iconElement"),C(this,"_shadowDom"),this.abilityRadarChartContainer=document.createElement("div"),this.abilityRadarChartContainer.setAttribute("class","ran-radar"),this.abilityRadarChart=document.createElement("canvas"),this.abilityRadarChart.style.setProperty("width","100%"),this.abilityRadarChart.style.setProperty("height","100%"),this.abilityRadarChartContainer.appendChild(this.abilityRadarChart);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-radar{position:var(--ran-radar-position, relative);width:var(--ran-radar-width, 100%);height:var(--ran-radar-height, 100%);display:var(--ran-radar-display, block)}",g.appendChild(I),this._shadowDom=g,g.appendChild(this.abilityRadarChartContainer)}static get observedAttributes(){return["abilitys","colorPolygon","colorLine","fillColor","strokeColor"]}get abilitys(){const g=this.getAttribute("abilitys");if("string"==typeof g)try{return JSON.parse(g)}catch(I){return g}return g}set abilitys(g){"string"==typeof g?this.setAttribute("abilitys",g||""):this.setAttribute("abilitys",JSON.stringify(g)||"")}get colorPolygon(){return this.getAttribute("colorPolygon")||dg}set colorPolygon(g){this.setAttribute("colorPolygon",g||dg)}get colorLine(){return this.getAttribute("colorLine")||ag}set colorLine(g){this.setAttribute("colorLine",g||ag)}get fillColor(){return this.getAttribute("fillColor")||ng}set fillColor(g){this.setAttribute("fillColor",g||ng)}get strokeColor(){return this.getAttribute("strokeColor")||rg}set strokeColor(g){this.setAttribute("strokeColor",g||rg)}refreshData(){var g;const I=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!I)return;const C=h(I),A=this.abilityRadarChartContainer.clientWidth*C,i=this.abilityRadarChartContainer.clientHeight*C;this.abilityRadarChart.width=A,this.abilityRadarChart.height=i,this.mW=A,this.mData=this.abilitys,this.mCount=(null==(g=this.mData)?void 0:g.length)||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*C,this.mAngle=2*Math.PI/this.mCount,this.drawPolygon(I),this.drawSide(I),this.drawLines(I),this.drawText(I),this.drawRegion(I),this.drawCircle(I)}drawSide(g){if(!(this.mRadius&&this.mCount&&this.mCenter&&this.mAngle))return;g.save(),g.strokeStyle=this.colorLine;const I=this.mRadius;for(let C=0;C=0&&this.mAngle*l=Math.PI/2&&this.mAngle*l=Math.PI&&this.mAngle*l<3*Math.PI/2?this.drawButton(g,c,s-44*e,o-24*e,44*e,24*e,12*e,this.mData[l].abilityName,d,a,n):this.drawButton(g,c,s-44*e,o,44*e,24*e,12*e,this.mData[l].abilityName,d,a,n)}g.restore()}drawButton(g,I,C,A,i,e,t,l,s,o,c){g.beginPath();const d=h(g);g.fillStyle=I,g.moveTo(C+t,A),g.lineTo(C+i-t,A),g.arc(C+i-t,A+t,t,3*Math.PI/2,2*Math.PI),g.lineTo(C+i,A+e-t),g.arc(C+i-t,A+e-t,t,Math.PI,Math.PI/2),g.lineTo(C+t,A+e),g.arc(C+t,A+e-t,t,Math.PI/2,Math.PI),g.lineTo(C,A+t),g.arc(C+t,A+t,t,Math.PI,3*Math.PI/2),g.fill(),g.closePath(),g.beginPath(),g.fillStyle=s,g.font=`${c||12*d}px ${o}`,g.textAlign="center",g.textBaseline="middle",g.fillText(l,C+i/2,A+e/2)}drawRegion(g){if(!(this.mRadius&&this.mCount&&this.mCenter&&this.mAngle&&this.mData))return;const I=h(g);g.save(),g.beginPath();for(let C=0;Cg.length)&&(I=g.length);for(var C=0,A=new Array(I);C=g.length?{done:!0}:{done:!1,value:g[A++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(g){var I=function(g,I){if("object"!=typeof g||null===g)return g;var C=g[Symbol.toPrimitive];if(void 0!==C){var A=C.call(g,"string");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(g);return"symbol"==typeof I?I:String(I)}var h,Z,b,G,u,p={exports:{}};h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Z=/^(?=([^\/?#]*))\1([^]*)$/,b=/(?:\/|^)\.(?=\/)/g,G=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,p.exports=u={buildAbsoluteURL:function(g,I,C){if(C=C||{},g=g.trim(),!(I=I.trim())){if(!C.alwaysNormalize)return g;var A=u.parseURL(g);if(!A)throw new Error("Error trying to parse base URL.");return A.path=u.normalizePath(A.path),u.buildURLFromParts(A)}var i=u.parseURL(I);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return C.alwaysNormalize?(i.path=u.normalizePath(i.path),u.buildURLFromParts(i)):I;var e=u.parseURL(g);if(!e)throw new Error("Error trying to parse base URL.");if(!e.netLoc&&e.path&&"/"!==e.path[0]){var t=Z.exec(e.path);e.netLoc=t[1],e.path=t[2]}e.netLoc&&!e.path&&(e.path="/");var l={scheme:e.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(l.netLoc=e.netLoc,"/"!==i.path[0]))if(i.path){var s=e.path,o=s.substring(0,s.lastIndexOf("/")+1)+i.path;l.path=u.normalizePath(o)}else l.path=e.path,i.params||(l.params=e.params,i.query||(l.query=e.query));return null===l.path&&(l.path=C.alwaysNormalize?u.normalizePath(i.path):i.path),u.buildURLFromParts(l)},parseURL:function(g){var I=h.exec(g);return I?{scheme:I[1]||"",netLoc:I[2]||"",path:I[3]||"",params:I[4]||"",query:I[5]||"",fragment:I[6]||""}:null},normalizePath:function(g){for(g=g.split("").reverse().join("").replace(b,"");g.length!==(g=g.replace(G,"")).length;);return g.split("").reverse().join("")},buildURLFromParts:function(g){return g.scheme+g.netLoc+g.path+g.params+g.query+g.fragment}};var w=p.exports,W=Number.isFinite||function(g){return"number"==typeof g&&isFinite(g)},B=function(g){return g.MEDIA_ATTACHING="hlsMediaAttaching",g.MEDIA_ATTACHED="hlsMediaAttached",g.MEDIA_DETACHING="hlsMediaDetaching",g.MEDIA_DETACHED="hlsMediaDetached",g.BUFFER_RESET="hlsBufferReset",g.BUFFER_CODECS="hlsBufferCodecs",g.BUFFER_CREATED="hlsBufferCreated",g.BUFFER_APPENDING="hlsBufferAppending",g.BUFFER_APPENDED="hlsBufferAppended",g.BUFFER_EOS="hlsBufferEos",g.BUFFER_FLUSHING="hlsBufferFlushing",g.BUFFER_FLUSHED="hlsBufferFlushed",g.MANIFEST_LOADING="hlsManifestLoading",g.MANIFEST_LOADED="hlsManifestLoaded",g.MANIFEST_PARSED="hlsManifestParsed",g.LEVEL_SWITCHING="hlsLevelSwitching",g.LEVEL_SWITCHED="hlsLevelSwitched",g.LEVEL_LOADING="hlsLevelLoading",g.LEVEL_LOADED="hlsLevelLoaded",g.LEVEL_UPDATED="hlsLevelUpdated",g.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",g.LEVELS_UPDATED="hlsLevelsUpdated",g.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",g.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",g.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",g.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",g.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",g.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",g.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",g.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",g.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",g.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",g.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",g.CUES_PARSED="hlsCuesParsed",g.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",g.INIT_PTS_FOUND="hlsInitPtsFound",g.FRAG_LOADING="hlsFragLoading",g.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",g.FRAG_LOADED="hlsFragLoaded",g.FRAG_DECRYPTED="hlsFragDecrypted",g.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",g.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",g.FRAG_PARSING_METADATA="hlsFragParsingMetadata",g.FRAG_PARSED="hlsFragParsed",g.FRAG_BUFFERED="hlsFragBuffered",g.FRAG_CHANGED="hlsFragChanged",g.FPS_DROP="hlsFpsDrop",g.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",g.ERROR="hlsError",g.DESTROYING="hlsDestroying",g.KEY_LOADING="hlsKeyLoading",g.KEY_LOADED="hlsKeyLoaded",g.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",g.BACK_BUFFER_REACHED="hlsBackBufferReached",g}({}),y=function(g){return g.NETWORK_ERROR="networkError",g.MEDIA_ERROR="mediaError",g.KEY_SYSTEM_ERROR="keySystemError",g.MUX_ERROR="muxError",g.OTHER_ERROR="otherError",g}({}),V=function(g){return g.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",g.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",g.KEY_SYSTEM_NO_SESSION="keySystemNoSession",g.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",g.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",g.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",g.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",g.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",g.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",g.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",g.MANIFEST_LOAD_ERROR="manifestLoadError",g.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",g.MANIFEST_PARSING_ERROR="manifestParsingError",g.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",g.LEVEL_EMPTY_ERROR="levelEmptyError",g.LEVEL_LOAD_ERROR="levelLoadError",g.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",g.LEVEL_PARSING_ERROR="levelParsingError",g.LEVEL_SWITCH_ERROR="levelSwitchError",g.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",g.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",g.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",g.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",g.FRAG_LOAD_ERROR="fragLoadError",g.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",g.FRAG_DECRYPT_ERROR="fragDecryptError",g.FRAG_PARSING_ERROR="fragParsingError",g.FRAG_GAP="fragGap",g.REMUX_ALLOC_ERROR="remuxAllocError",g.KEY_LOAD_ERROR="keyLoadError",g.KEY_LOAD_TIMEOUT="keyLoadTimeOut",g.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",g.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",g.BUFFER_APPEND_ERROR="bufferAppendError",g.BUFFER_APPENDING_ERROR="bufferAppendingError",g.BUFFER_STALLED_ERROR="bufferStalledError",g.BUFFER_FULL_ERROR="bufferFullError",g.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",g.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",g.INTERNAL_EXCEPTION="internalException",g.INTERNAL_ABORTED="aborted",g.UNKNOWN="unknown",g}({}),X=function(){},Y={trace:X,debug:X,log:X,warn:X,info:X,error:X},R=Y;function N(g,I){if(self.console&&!0===g||"object"==typeof g){!function(g){for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A"):X}(I)}))}(g,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+I+'" in hls.js version 1.4.12')}catch(C){R=Y}}else R=Y}var H=R,K=/^(\d+)x(\d+)$/,f=/(.+?)=(".*?"|.*?)(?:,|$)/g,F=function(){function g(I){for(var C in"string"==typeof I&&(I=g.parseAttrList(I)),I)I.hasOwnProperty(C)&&("X-"===C.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(C)),this[C]=I[C])}var I=g.prototype;return I.decimalInteger=function(g){var I=parseInt(this[g],10);return I>Number.MAX_SAFE_INTEGER?1/0:I},I.hexadecimalInteger=function(g){if(this[g]){var I=(this[g]||"0x").slice(2);I=(1&I.length?"0":"")+I;for(var C=new Uint8Array(I.length/2),A=0;ANumber.MAX_SAFE_INTEGER?1/0:I},I.decimalFloatingPoint=function(g){return parseFloat(this[g])},I.optionalFloat=function(g,I){var C=this[g];return C?parseFloat(C):I},I.enumeratedString=function(g){return this[g]},I.bool=function(g){return"YES"===this[g]},I.decimalResolution=function(g){var I=K.exec(this[g]);if(null!==I)return{width:parseInt(I[1],10),height:parseInt(I[2],10)}},g.parseAttrList=function(g){var I,C={};for(f.lastIndex=0;null!==(I=f.exec(g));){var A=I[2];0===A.indexOf('"')&&A.lastIndexOf('"')===A.length-1&&(A=A.slice(1,-1)),C[I[1].trim()]=A}return C},g}();function M(g){return"SCTE35-OUT"===g||"SCTE35-IN"===g}var S=function(){function g(g,I){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,I){var C=I.attr;for(var A in C)if(Object.prototype.hasOwnProperty.call(g,A)&&g[A]!==C[A]){H.warn('DATERANGE tag attribute: "'+A+'" does not match for tags with ID: "'+g.ID+'"'),this._badValueForSameId=A;break}g=l(new F({}),C,g)}if(this.attr=g,this._startDate=new Date(g["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);W(i.getTime())&&(this._endDate=i)}}return e(g,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var g=this.duration;return null!==g?new Date(this._startDate.getTime()+1e3*g):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var g=this.attr.decimalFloatingPoint("DURATION");if(W(g))return g}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&W(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),g}(),J=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},k="audio",D="video",v="audiovideo",L=function(){function g(g){var I;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((I={})[k]=null,I[D]=null,I[v]=null,I),this.baseurl=g}return g.prototype.setByteRange=function(g,I){var C=g.split("@",2),A=[];1===C.length?A[0]=I?I.byteRangeEndOffset:0:A[0]=parseInt(C[1]),A[1]=parseInt(C[0])+A[0],this._byteRange=A},e(g,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=w.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),g}(),z=function(g){function I(I,C){var A;return(A=g.call(this,C)||this)._decryptdata=null,A.rawProgramDateTime=null,A.programDateTime=null,A.tagList=[],A.duration=0,A.sn=0,A.levelkeys=void 0,A.type=void 0,A.loader=null,A.keyLoader=null,A.level=-1,A.cc=0,A.startPTS=void 0,A.endPTS=void 0,A.startDTS=void 0,A.endDTS=void 0,A.start=0,A.deltaPTS=void 0,A.maxStartPTS=void 0,A.minEndPTS=void 0,A.stats=new J,A.urlId=0,A.data=void 0,A.bitrateTest=!1,A.title=null,A.initSegment=null,A.endList=void 0,A.gap=void 0,A.type=I,A}s(I,g);var C=I.prototype;return C.setKeyFormat=function(g){if(this.levelkeys){var I=this.levelkeys[g];I&&!this._decryptdata&&(this._decryptdata=I.getDecryptData(this.sn))}},C.abortRequests=function(){var g,I;null==(g=this.loader)||g.abort(),null==(I=this.keyLoader)||I.abort()},C.setElementaryStreamInfo=function(g,I,C,A,i,e){void 0===e&&(e=!1);var t=this.elementaryStreams,l=t[g];l?(l.startPTS=Math.min(l.startPTS,I),l.endPTS=Math.max(l.endPTS,C),l.startDTS=Math.min(l.startDTS,A),l.endDTS=Math.max(l.endDTS,i)):t[g]={startPTS:I,endPTS:C,startDTS:A,endDTS:i,partial:e}},C.clearElementaryStreamInfo=function(){var g=this.elementaryStreams;g[k]=null,g[D]=null,g[v]=null},e(I,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var g=this.levelkeys.identity;if(g)this._decryptdata=g.getDecryptData(this.sn);else{var I=Object.keys(this.levelkeys);if(1===I.length)return this._decryptdata=this.levelkeys[I[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!W(this.programDateTime))return null;var g=W(this.duration)?this.duration:0;return this.programDateTime+1e3*g}},{key:"encrypted",get:function(){var g;if(null!=(g=this._decryptdata)&&g.encrypted)return!0;if(this.levelkeys){var I=Object.keys(this.levelkeys),C=I.length;if(C>1||1===C&&this.levelkeys[I[0]].encrypted)return!0}return!1}}]),I}(L),T=function(g){function I(I,C,A,i,e){var t;(t=g.call(this,A)||this).fragOffset=0,t.duration=0,t.gap=!1,t.independent=!1,t.relurl=void 0,t.fragment=void 0,t.index=void 0,t.stats=new J,t.duration=I.decimalFloatingPoint("DURATION"),t.gap=I.bool("GAP"),t.independent=I.bool("INDEPENDENT"),t.relurl=I.enumeratedString("URI"),t.fragment=C,t.index=i;var l=I.enumeratedString("BYTERANGE");return l&&t.setByteRange(l,e),e&&(t.fragOffset=e.fragOffset+e.duration),t}return s(I,g),e(I,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),I}(L),x=function(){function g(g){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=g}return g.prototype.reloaded=function(g){if(!g)return this.advanced=!0,void(this.updated=!0);var I=this.lastPartSn-g.lastPartSn,C=this.lastPartIndex-g.lastPartIndex;this.updated=this.endSN!==g.endSN||!!C||!!I||!this.live,this.advanced=this.endSN>g.endSN||I>0||0===I&&C>0,this.updated||this.advanced?this.misses=Math.floor(.6*g.misses):this.misses=g.misses+1,this.availabilityDelay=g.availabilityDelay},e(g,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&W(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var g=this.driftEndTime-this.driftStartTime;return g>0?1e3*(this.driftEnd-this.driftStart)/g:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var g;return null!=(g=this.partList)&&g.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var g;return null!=(g=this.fragments)&&g.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var g;return null!=(g=this.partList)&&g.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var g;return null!=(g=this.partList)&&g.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),g}();function U(g){return Uint8Array.from(atob(g),(function(g){return g.charCodeAt(0)}))}function j(g){return Uint8Array.from(unescape(encodeURIComponent(g)),(function(g){return g.charCodeAt(0)}))}var Q={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},O="org.w3.clearkey",E="com.apple.streamingkeydelivery",P="com.microsoft.playready",_="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function q(g){switch(g){case E:return Q.FAIRPLAY;case P:return Q.PLAYREADY;case _:return Q.WIDEVINE;case O:return Q.CLEARKEY}}var $="edef8ba979d64acea3c827dcd51d21ed";function gg(g){switch(g){case Q.FAIRPLAY:return E;case Q.PLAYREADY:return P;case Q.WIDEVINE:return _;case Q.CLEARKEY:return O}}function Ig(g){var I=g.drmSystems,C=g.widevineLicenseUrl,A=I?[Q.FAIRPLAY,Q.WIDEVINE,Q.PLAYREADY,Q.CLEARKEY].filter((function(g){return!!I[g]})):[];return!A[Q.WIDEVINE]&&C&&A.push(Q.WIDEVINE),A}var Cg="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Ag(g,I,C){return Uint8Array.prototype.slice?g.slice(I,C):new Uint8Array(Array.prototype.slice.call(g,I,C))}var ig,eg=function(g,I){return I+10<=g.length&&73===g[I]&&68===g[I+1]&&51===g[I+2]&&g[I+3]<255&&g[I+4]<255&&g[I+6]<128&&g[I+7]<128&&g[I+8]<128&&g[I+9]<128},tg=function(g,I){return I+10<=g.length&&51===g[I]&&68===g[I+1]&&73===g[I+2]&&g[I+3]<255&&g[I+4]<255&&g[I+6]<128&&g[I+7]<128&&g[I+8]<128&&g[I+9]<128},lg=function(g,I){for(var C=I,A=0;eg(g,I);)A+=10,A+=sg(g,I+6),tg(g,I+10)&&(A+=10),I+=A;if(A>0)return g.subarray(C,C+A)},sg=function(g,I){var C=0;return C=(127&g[I])<<21,C|=(127&g[I+1])<<14,(C|=(127&g[I+2])<<7)|127&g[I+3]},og=function(g,I){return eg(g,I)&&sg(g,I+6)+10<=g.length-I},cg=function(g){return g&&"PRIV"===g.key&&"com.apple.streaming.transportStreamTimestamp"===g.info},dg=function(g){var I=String.fromCharCode(g[0],g[1],g[2],g[3]),C=sg(g,4);return{type:I,size:C,data:g.subarray(10,10+C)}},ag=function(g){for(var I=0,C=[];eg(g,I);){for(var A=sg(g,I+6),i=(I+=10)+A;I+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(e);break;case 12:case 13:t=g[c++],o+=String.fromCharCode((31&e)<<6|63&t);break;case 14:t=g[c++],l=g[c++],o+=String.fromCharCode((15&e)<<12|(63&t)<<6|63&l)}}return o};var Gg=function(g){for(var I="",C=0;C>24,g[I+1]=C>>16&255,g[I+2]=C>>8&255,g[I+3]=255&C}function Yg(g,I){var C=[];if(!I.length)return C;for(var A=g.byteLength,i=0;i1?i+e:A;if(Wg(g.subarray(i+4,i+8))===I[0])if(1===I.length)C.push(g.subarray(i+8,t));else{var l=Yg(g.subarray(i+8,t),I.slice(1));l.length&&pg.apply(C,l)}i=t}return C}function Rg(g){var I=[],C=g[0],A=8,i=yg(g,A);A+=4,A+=0===C?8:16,A+=2;var e=g.length+0,t=Bg(g,A);A+=2;for(var l=0;l>>31)return H.warn("SIDX has hierarchical references (not supported)"),null;var d=yg(g,s);s+=4,I.push({referenceSize:c,subsegmentDuration:d,info:{duration:d/i,start:e,end:e+c-1}}),e+=c,A=s+=4}return{earliestPresentationTime:0,timescale:i,version:C,referencesCount:t,references:I}}function Ng(g){for(var I=[],C=Yg(g,["moov","trak"]),A=0;A>1&63;return 39===C||40===C}return 6==(31&I)}function Sg(g,I,C,A){var i=Jg(g),e=0;e+=I;for(var t=0,l=0,s=!1,o=0;e=i.length)break;t+=o=i[e++]}while(255===o);l=0;do{if(e>=i.length)break;l+=o=i[e++]}while(255===o);var c=i.length-e;if(!s&&4===t&&e16){for(var G=[],u=0;u<16;u++){var p=i[e++].toString(16);G.push(1==p.length?"0"+p:p),3!==u&&5!==u&&7!==u&&9!==u||G.push("-")}for(var w=l-16,W=new Uint8Array(w),B=0;Bc)break}}function Jg(g){for(var I=g.byteLength,C=[],A=1;A>8*(15-C)&255;return I}(I);return new g(this.method,this.uri,"identity",this.keyFormatVersions,C)}var A,i,e=function(g){var I,C,A=g.split(":"),i=null;if("data"===A[0]&&2===A.length){var e=A[1].split(";"),t=e[e.length-1].split(",");if(2===t.length){var l="base64"===t[0],s=t[1];l?(e.splice(-1,1),i=U(s)):(I=j(s).subarray(0,16),(C=new Uint8Array(16)).set(I,16-I.length),i=C)}}return i}(this.uri);if(e)switch(this.keyFormat){case _:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case P:var t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(g,I,C){if(16!==g.byteLength)throw new RangeError("Invalid system id");var A,i;A=new Uint8Array,i=new Uint8Array;var e=new Uint8Array(4);return C&&C.byteLength>0&&new DataView(e.buffer).setUint32(0,C.byteLength,!1),function(g){for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(g,4),t=0,e=8;t2){var C=I.shift()+".";return(C+=parseInt(I.shift()).toString(16))+("000"+parseInt(I.shift()).toString(16)).slice(-4)}return g},g.resolve=function(g,I){return w.buildAbsoluteURL(I,g,{alwaysNormalize:!0})},g.isMediaPlaylist=function(g){return qg.test(g)},g.parseMasterPlaylist=function(I,C){var A,i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Lg(I)},e=[];for(Pg.lastIndex=0;null!=(A=Pg.exec(I));)if(A[1]){var t,l=new F(A[1]);zg(i,l,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var s=Tg(i,A[2]),o={attrs:l,bitrate:l.decimalInteger("AVERAGE-BANDWIDTH")||l.decimalInteger("BANDWIDTH"),name:l.NAME,url:g.resolve(s,C)},c=l.decimalResolution("RESOLUTION");c&&(o.width=c.width,o.height=c.height),iI((l.CODECS||"").split(/[ ,]+/).filter((function(g){return g})),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=g.convertAVC1ToAVCOTI(o.videoCodec)),null!=(t=o.unknownCodecs)&&t.length||e.push(o),i.levels.push(o)}else if(A[3]){var d=A[3],a=A[4];switch(d){case"SESSION-DATA":var n=new F(a);zg(i,n,["DATA-ID","LANGUAGE","VALUE","URI"]);var r=n["DATA-ID"];r&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[r]=n);break;case"SESSION-KEY":var m=CI(a,C,i);m.encrypted&&m.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(m)):H.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+a+'"');break;case"DEFINE":var h=new F(a);zg(i,h,["NAME","VALUE","QUERYPARAM"]),xg(i,h,C);break;case"CONTENT-STEERING":var Z=new F(a);zg(i,Z,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:g.resolve(Z["SERVER-URI"],C),pathwayId:Z["PATHWAY-ID"]||"."};break;case"START":i.startTimeOffset=AI(a)}}var b=e.length>0&&e.length0&&U.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),c.holdBack=U.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var j=new F(X);c.partTarget=j.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=c.partList;Q||(Q=c.partList=[]);var O=r>0?Q[Q.length-1]:void 0,E=r++,P=new F(X);zg(c,P,["BYTERANGE","URI"]);var _=new T(P,b,I,E,O);Q.push(_),b.duration+=_.duration;break;case"PRELOAD-HINT":var q=new F(X);zg(c,q,["URI"]),c.preloadHint=q;break;case"RENDITION-REPORT":var $=new F(X);zg(c,$,["URI"]),c.renditionReports=c.renditionReports||[],c.renditionReports.push($);break;default:H.warn("line parsed but not handled: "+t)}}}Z&&!Z.relurl?(d.pop(),m-=Z.duration,c.partList&&(c.fragmentHint=Z)):c.partList&&(tI(b,Z),b.cc=h,c.fragmentHint=b,o&&sI(b,o,c));var gg=d.length,Ig=d[0],Cg=d[gg-1];if((m+=c.skippedSegments*c.targetduration)>0&&gg&&Cg){c.averagetargetduration=m/gg;var Ag=Cg.sn;c.endSN="initSegment"!==Ag?Ag:0,c.live||(Cg.endList=!0),Ig&&(c.startCC=Ig.cc)}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(m+=c.fragmentHint.duration),c.totalduration=m,c.endCC=h,G>0&&function(g,I){for(var C=g[I],A=I;A--;){var i=g[A];if(!i)return;i.programDateTime=C.programDateTime-1e3*i.duration,C=i}}(d,G),c},g}();function CI(g,I,C){var A,i,e=new F(g);zg(C,e,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var t=null!=(A=e.METHOD)?A:"",l=e.URI,s=e.hexadecimalInteger("IV"),o=e.KEYFORMATVERSIONS,c=null!=(i=e.KEYFORMAT)?i:"identity";l&&e.IV&&!s&&H.error("Invalid IV: "+e.IV);var d=l?II.resolve(l,I):"",a=(o||"1").split("/").map(Number).filter(Number.isFinite);return new Dg(t,d,c,a,s)}function AI(g){var I=new F(g).decimalFloatingPoint("TIME-OFFSET");return W(I)?I:null}function iI(g,I){["video","audio","text"].forEach((function(C){var A=g.filter((function(g){return I=g,!!(A=Qg[C])&&!0===A[I.slice(0,4)];var I,A}));if(A.length){var i=A.filter((function(g){return 0===g.lastIndexOf("avc1",0)||0===g.lastIndexOf("mp4a",0)}));I[C+"Codec"]=i.length>0?i[0]:A[0],g=g.filter((function(g){return-1===A.indexOf(g)}))}})),I.unknownCodecs=g}function eI(g,I,C){var A=I[C];A&&(g[C]=A)}function tI(g,I){g.rawProgramDateTime?g.programDateTime=Date.parse(g.rawProgramDateTime):null!=I&&I.programDateTime&&(g.programDateTime=I.endProgramDateTime),W(g.programDateTime)||(g.programDateTime=null,g.rawProgramDateTime=null)}function lI(g,I,C,A){g.relurl=I.URI,I.BYTERANGE&&g.setByteRange(I.BYTERANGE),g.level=C,g.sn="initSegment",A&&(g.levelkeys=A),g.initSegment=null}function sI(g,I,C){g.levelkeys=I;var A=C.encryptedFragments;A.length&&A[A.length-1].levelkeys===I||!Object.keys(I).some((function(g){return I[g].isCommonEncryption}))||A.push(g)}var oI="manifest",cI="level",dI="audioTrack",aI="subtitleTrack",nI="main",rI="audio",mI="subtitle";function hI(g){switch(g.type){case dI:return rI;case aI:return mI;default:return nI}}function ZI(g,I){var C=g.url;return void 0!==C&&0!==C.indexOf("data:")||(C=I.url),C}var bI=function(){function g(g){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=g,this.registerListeners()}var I=g.prototype;return I.startLoad=function(g){},I.stopLoad=function(){this.destroyInternalLoaders()},I.registerListeners=function(){var g=this.hls;g.on(B.MANIFEST_LOADING,this.onManifestLoading,this),g.on(B.LEVEL_LOADING,this.onLevelLoading,this),g.on(B.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),g.on(B.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},I.unregisterListeners=function(){var g=this.hls;g.off(B.MANIFEST_LOADING,this.onManifestLoading,this),g.off(B.LEVEL_LOADING,this.onLevelLoading,this),g.off(B.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),g.off(B.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},I.createInternalLoader=function(g){var I=this.hls.config,C=I.pLoader,A=I.loader,i=new(C||A)(I);return this.loaders[g.type]=i,i},I.getInternalLoader=function(g){return this.loaders[g.type]},I.resetInternalLoader=function(g){this.loaders[g]&&delete this.loaders[g]},I.destroyInternalLoaders=function(){for(var g in this.loaders){var I=this.loaders[g];I&&I.destroy(),this.resetInternalLoader(g)}},I.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},I.onManifestLoading=function(g,I){var C=I.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:oI,url:C,deliveryDirectives:null})},I.onLevelLoading=function(g,I){var C=I.id,A=I.level,i=I.url,e=I.deliveryDirectives;this.load({id:C,level:A,responseType:"text",type:cI,url:i,deliveryDirectives:e})},I.onAudioTrackLoading=function(g,I){var C=I.id,A=I.groupId,i=I.url,e=I.deliveryDirectives;this.load({id:C,groupId:A,level:null,responseType:"text",type:dI,url:i,deliveryDirectives:e})},I.onSubtitleTrackLoading=function(g,I){var C=I.id,A=I.groupId,i=I.url,e=I.deliveryDirectives;this.load({id:C,groupId:A,level:null,responseType:"text",type:aI,url:i,deliveryDirectives:e})},I.load=function(g){var I,C,A,i=this,e=this.hls.config,t=this.getInternalLoader(g);if(t){var s=t.context;if(s&&s.url===g.url)return void H.trace("[playlist-loader]: playlist request ongoing");H.log("[playlist-loader]: aborting previous loader for type: "+g.type),t.abort()}if(C=g.type===oI?e.manifestLoadPolicy.default:l({},e.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),t=this.createInternalLoader(g),null!=(I=g.deliveryDirectives)&&I.part&&(g.type===cI&&null!==g.level?A=this.hls.levels[g.level].details:g.type===dI&&null!==g.id?A=this.hls.audioTracks[g.id].details:g.type===aI&&null!==g.id&&(A=this.hls.subtitleTracks[g.id].details),A)){var o=A.partTarget,c=A.targetduration;if(o&&c){var d=1e3*Math.max(3*o,.8*c);C=l({},C,{maxTimeToFirstByteMs:Math.min(d,C.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,C.maxTimeToFirstByteMs)})}}var a=C.errorRetry||C.timeoutRetry||{},n={loadPolicy:C,timeout:C.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},r={onSuccess:function(g,I,C,A){var e=i.getInternalLoader(C);i.resetInternalLoader(C.type);var t=g.data;0===t.indexOf("#EXTM3U")?(I.parsing.start=performance.now(),II.isMediaPlaylist(t)?i.handleTrackOrLevelPlaylist(g,I,C,A||null,e):i.handleMasterPlaylist(g,I,C,A)):i.handleManifestParsingError(g,C,new Error("no EXTM3U delimiter"),A||null,I)},onError:function(g,I,C,A){i.handleNetworkError(I,C,!1,g,A)},onTimeout:function(g,I,C){i.handleNetworkError(I,C,!0,void 0,g)}};t.load(g,n,r)},I.handleMasterPlaylist=function(g,I,C,A){var i=this.hls,e=g.data,t=ZI(g,C),l=II.parseMasterPlaylist(e,t);if(l.playlistParsingError)this.handleManifestParsingError(g,C,l.playlistParsingError,A,I);else{var s=l.contentSteering,o=l.levels,c=l.sessionData,d=l.sessionKeys,a=l.startTimeOffset,n=l.variableList;this.variableList=n;var r=II.parseMasterPlaylistMedia(e,t,l),m=r.AUDIO,h=void 0===m?[]:m,Z=r.SUBTITLES,b=r["CLOSED-CAPTIONS"];h.length&&(h.some((function(g){return!g.url}))||!o[0].audioCodec||o[0].attrs.AUDIO||(H.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),h.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new F({}),bitrate:0,url:""}))),i.trigger(B.MANIFEST_LOADED,{levels:o,audioTracks:h,subtitles:Z,captions:b,contentSteering:s,url:t,stats:I,networkDetails:A,sessionData:c,sessionKeys:d,startTimeOffset:a,variableList:n})}},I.handleTrackOrLevelPlaylist=function(g,I,C,A,i){var e=this.hls,t=C.id,l=C.level,s=C.type,o=ZI(g,C),c=W(t)?t:0,d=W(l)?l:c,a=hI(C),n=II.parseLevelPlaylist(g.data,o,d,a,c,this.variableList);if(s===oI){var r={attrs:new F({}),bitrate:0,details:n,name:"",url:o};e.trigger(B.MANIFEST_LOADED,{levels:[r],audioTracks:[],url:o,stats:I,networkDetails:A,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}I.parsing.end=performance.now(),C.levelDetails=n,this.handlePlaylistLoaded(n,g,I,C,A,i)},I.handleManifestParsingError=function(g,I,C,A,i){this.hls.trigger(B.ERROR,{type:y.NETWORK_ERROR,details:V.MANIFEST_PARSING_ERROR,fatal:I.type===oI,url:g.url,err:C,error:C,reason:C.message,response:g,context:I,networkDetails:A,stats:i})},I.handleNetworkError=function(g,I,C,i,e){void 0===C&&(C=!1);var t="A network "+(C?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+g.type;g.type===cI?t+=": "+g.level+" id: "+g.id:g.type!==dI&&g.type!==aI||(t+=" id: "+g.id+' group-id: "'+g.groupId+'"');var l=new Error(t);H.warn("[playlist-loader]: "+t);var s=V.UNKNOWN,o=!1,c=this.getInternalLoader(g);switch(g.type){case oI:s=C?V.MANIFEST_LOAD_TIMEOUT:V.MANIFEST_LOAD_ERROR,o=!0;break;case cI:s=C?V.LEVEL_LOAD_TIMEOUT:V.LEVEL_LOAD_ERROR,o=!1;break;case dI:s=C?V.AUDIO_TRACK_LOAD_TIMEOUT:V.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case aI:s=C?V.SUBTITLE_TRACK_LOAD_TIMEOUT:V.SUBTITLE_LOAD_ERROR,o=!1}c&&this.resetInternalLoader(g.type);var d={type:y.NETWORK_ERROR,details:s,fatal:o,url:g.url,loader:c,context:g,error:l,networkDetails:I,stats:e};if(i){var a=(null==I?void 0:I.url)||g.url;d.response=A({url:a,data:void 0},i)}this.hls.trigger(B.ERROR,d)},I.handlePlaylistLoaded=function(g,I,C,A,i,e){var t=this.hls,l=A.type,s=A.level,o=A.id,c=A.groupId,d=A.deliveryDirectives,a=ZI(I,A),n=hI(A),r="number"==typeof A.level&&n===nI?s:void 0;if(g.fragments.length){g.targetduration||(g.playlistParsingError=new Error("Missing Target Duration"));var m=g.playlistParsingError;if(m)t.trigger(B.ERROR,{type:y.NETWORK_ERROR,details:V.LEVEL_PARSING_ERROR,fatal:!1,url:a,error:m,reason:m.message,response:I,context:A,level:r,parent:n,networkDetails:i,stats:C});else switch(g.live&&e&&(e.getCacheAge&&(g.ageHeader=e.getCacheAge()||0),e.getCacheAge&&!isNaN(g.ageHeader)||(g.ageHeader=0)),l){case oI:case cI:t.trigger(B.LEVEL_LOADED,{details:g,level:r||0,id:o||0,stats:C,networkDetails:i,deliveryDirectives:d});break;case dI:t.trigger(B.AUDIO_TRACK_LOADED,{details:g,id:o||0,groupId:c||"",stats:C,networkDetails:i,deliveryDirectives:d});break;case aI:t.trigger(B.SUBTITLE_TRACK_LOADED,{details:g,id:o||0,groupId:c||"",stats:C,networkDetails:i,deliveryDirectives:d})}}else{var h=new Error("No Segments found in Playlist");t.trigger(B.ERROR,{type:y.NETWORK_ERROR,details:V.LEVEL_EMPTY_ERROR,fatal:!1,url:a,error:h,reason:h.message,response:I,context:A,level:r,parent:n,networkDetails:i,stats:C})}},g}();function GI(g,I){var C;try{C=new Event("addtrack")}catch(A){(C=document.createEvent("Event")).initEvent("addtrack",!1,!1)}C.track=g,I.dispatchEvent(C)}function uI(g,I){var C=g.mode;if("disabled"===C&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(I.id))try{if(g.addCue(I),!g.cues.getCueById(I.id))throw new Error("addCue is failed for: "+I)}catch(i){H.debug("[texttrack-utils]: "+i);try{var A=new self.TextTrackCue(I.startTime,I.endTime,I.text);A.id=I.id,g.addCue(A)}catch(e){H.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===C&&(g.mode=C)}function pI(g){var I=g.mode;if("disabled"===I&&(g.mode="hidden"),g.cues)for(var C=g.cues.length;C--;)g.removeCue(g.cues[C]);"disabled"===I&&(g.mode=I)}function wI(g,I,C,A){var i=g.mode;if("disabled"===i&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var e=function(g,I,C){var A=[],i=function(g,I){if(Ig[C].endTime)return-1;for(var A=0,i=C;A<=i;){var e=Math.floor((i+A)/2);if(Ig[e].startTime&&A-1)for(var e=i,t=g.length;e=I&&l.endTime<=C)A.push(l);else if(l.startTime>C)return A}return A}(g.cues,I,C),t=0;tVI&&(d=VI),d-c<=0&&(d=c+.25);for(var a=0;aI.startDate&&g.push(A),g}),[]).sort((function(g,I){return g.startDate.getTime()-I.startDate.getTime()}))[0];r&&(c=XI(r.startDate,a),s=!0)}for(var h,Z,b=Object.keys(I.attr),G=0;G.05&&this.forwardBufferLength>1){var o=Math.min(2,Math.max(1,e)),c=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;g.playbackRate=Math.min(o,Math.max(1,c))}else 1!==g.playbackRate&&0!==g.playbackRate&&(g.playbackRate=1)}}}}},I.estimateLiveEdge=function(){var g=this.levelDetails;return null===g?null:g.edge+g.age},I.computeLatency=function(){var g=this.estimateLiveEdge();return null===g?null:g-this.currentTime},e(g,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var g=this.config,I=this.levelDetails;return void 0!==g.liveMaxLatencyDuration?g.liveMaxLatencyDuration:I?g.liveMaxLatencyDurationCount*I.targetduration:0}},{key:"targetLatency",get:function(){var g=this.levelDetails;if(null===g)return null;var I=g.holdBack,C=g.partHoldBack,A=g.targetduration,i=this.config,e=i.liveSyncDuration,t=i.liveSyncDurationCount,l=i.lowLatencyMode,s=this.hls.userConfig,o=l&&C||I;(s.liveSyncDuration||s.liveSyncDurationCount||0===o)&&(o=void 0!==e?e:t*A);var c=A;return o+Math.min(1*this.stallCount,c)}},{key:"liveSyncPosition",get:function(){var g=this.estimateLiveEdge(),I=this.targetLatency,C=this.levelDetails;if(null===g||null===I||null===C)return null;var A=C.edge,i=g-I-this.edgeStalled,e=A-C.totalduration,t=A-(this.config.lowLatencyMode&&C.partTarget||C.targetduration);return Math.min(Math.max(e,i),t)}},{key:"drift",get:function(){var g=this.levelDetails;return null===g?1:g.drift}},{key:"edgeStalled",get:function(){var g=this.levelDetails;if(null===g)return 0;var I=3*(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.max(g.age-I,0)}},{key:"forwardBufferLength",get:function(){var g=this.media,I=this.levelDetails;if(!g||!I)return 0;var C=g.buffered.length;return(C?g.buffered.end(C-1):I.edge)-this.currentTime}}]),g}(),NI=["NONE","TYPE-0","TYPE-1",null],HI=function(){function g(g,I,C){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=g,this.part=I,this.skip=C}return g.prototype.addDirectives=function(g){var I=new self.URL(g);return void 0!==this.msn&&I.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&I.searchParams.set("_HLS_part",this.part.toString()),this.skip&&I.searchParams.set("_HLS_skip",this.skip),I.href},g}(),KI=function(){function g(g){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[g.url],this._attrs=[g.attrs],this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter((function(g){return g})).join(",").replace(/\.[^.,]+/g,"")}return g.prototype.addFallback=function(g){this.url.push(g.url),this._attrs.push(g.attrs)},e(g,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(g){var I=g%this.url.length;this._urlId!==I&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=I)}},{key:"audioGroupId",get:function(){var g;return null==(g=this.audioGroupIds)?void 0:g[this.urlId]}},{key:"textGroupId",get:function(){var g;return null==(g=this.textGroupIds)?void 0:g[this.urlId]}}]),g}();function fI(g,I){var C=I.startPTS;if(W(C)){var A,i=0;I.sn>g.sn?(i=C-g.start,A=g):(i=g.start-C,A=I),A.duration!==i&&(A.duration=i)}else I.sn>g.sn?g.cc===I.cc&&g.minEndPTS?I.start=g.start+(g.minEndPTS-g.start):I.start=g.start+g.duration:I.start=Math.max(g.start-I.duration,0)}function FI(g,I,C,A,i,e){A-C<=0&&(H.warn("Fragment should have a positive duration",I),A=C+I.duration,e=i+I.duration);var t=C,l=A,s=I.startPTS,o=I.endPTS;if(W(s)){var c=Math.abs(s-C);W(I.deltaPTS)?I.deltaPTS=Math.max(c,I.deltaPTS):I.deltaPTS=c,t=Math.max(C,s),C=Math.min(C,s),i=Math.min(i,I.startDTS),l=Math.min(A,o),A=Math.max(A,o),e=Math.max(e,I.endDTS)}var d=C-I.start;0!==I.start&&(I.start=C),I.duration=A-I.start,I.startPTS=C,I.maxStartPTS=t,I.startDTS=i,I.endPTS=A,I.minEndPTS=l,I.endDTS=e;var a,n=I.sn;if(!g||ng.endSN)return 0;var r=n-g.startSN,m=g.fragments;for(m[r]=I,a=r;a>0;a--)fI(m[a],m[a-1]);for(a=r;a=A.length||SI(I,A[C].start)}function SI(g,I){if(I){for(var C=g.fragments,A=g.skippedSegments;A499)||!!C);var i}var xI=function(g,I){for(var C=0,A=g.length-1,i=null,e=null;C<=A;){var t=I(e=g[i=(C+A)/2|0]);if(t>0)C=i+1;else{if(!(t<0))return e;A=i-1}}return null};function UI(g,I,C,A){void 0===C&&(C=0),void 0===A&&(A=0);var i=null;if(g?i=I[g.sn-I[0].sn+1]||null:0===C&&0===I[0].start&&(i=I[0]),i&&0===jI(C,A,i))return i;var e=xI(I,jI.bind(null,C,A));return!e||e===g&&i?i:e}function jI(g,I,C){if(void 0===g&&(g=0),void 0===I&&(I=0),C.start<=g&&C.start+C.duration>g)return 0;var A=Math.min(I,C.duration+(C.deltaPTS?C.deltaPTS:0));return C.start+C.duration-A<=g?1:C.start-A>g&&C.start?-1:0}function QI(g,I,C){var A=1e3*Math.min(I,C.duration+(C.deltaPTS?C.deltaPTS:0));return(C.endProgramDateTime||0)-A>g}var OI,EI=function(){function g(g){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=g,this.log=H.log.bind(H,"[info]:"),this.warn=H.warn.bind(H,"[warning]:"),this.error=H.error.bind(H,"[error]:"),this.registerListeners()}var I=g.prototype;return I.registerListeners=function(){var g=this.hls;g.on(B.ERROR,this.onError,this),g.on(B.MANIFEST_LOADING,this.onManifestLoading,this),g.on(B.LEVEL_UPDATED,this.onLevelUpdated,this)},I.unregisterListeners=function(){var g=this.hls;g&&(g.off(B.ERROR,this.onError,this),g.off(B.ERROR,this.onErrorOut,this),g.off(B.MANIFEST_LOADING,this.onManifestLoading,this),g.off(B.LEVEL_UPDATED,this.onLevelUpdated,this))},I.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},I.startLoad=function(g){this.playlistError=0},I.stopLoad=function(){},I.getVariantLevelIndex=function(g){return(null==g?void 0:g.type)===nI?g.level:this.hls.loadLevel},I.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},I.onLevelUpdated=function(){this.playlistError=0},I.onError=function(g,I){var C,A;if(!I.fatal){var i=this.hls,e=I.context;switch(I.details){case V.FRAG_LOAD_ERROR:case V.FRAG_LOAD_TIMEOUT:case V.KEY_LOAD_ERROR:case V.KEY_LOAD_TIMEOUT:return void(I.errorAction=this.getFragRetryOrSwitchAction(I));case V.FRAG_PARSING_ERROR:if(null!=(C=I.frag)&&C.gap)return void(I.errorAction={action:0,flags:0});case V.FRAG_GAP:case V.FRAG_DECRYPT_ERROR:return I.errorAction=this.getFragRetryOrSwitchAction(I),void(I.errorAction.action=2);case V.LEVEL_EMPTY_ERROR:case V.LEVEL_PARSING_ERROR:var t,l,s=I.parent===nI?I.level:i.loadLevel;return void(I.details===V.LEVEL_EMPTY_ERROR&&null!=(t=I.context)&&null!=(l=t.levelDetails)&&l.live?I.errorAction=this.getPlaylistRetryOrSwitchAction(I,s):(I.levelRetry=!1,I.errorAction=this.getLevelSwitchAction(I,s)));case V.LEVEL_LOAD_ERROR:case V.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==e?void 0:e.level)&&(I.errorAction=this.getPlaylistRetryOrSwitchAction(I,e.level)));case V.AUDIO_TRACK_LOAD_ERROR:case V.AUDIO_TRACK_LOAD_TIMEOUT:case V.SUBTITLE_LOAD_ERROR:case V.SUBTITLE_TRACK_LOAD_TIMEOUT:if(e){var o=i.levels[i.loadLevel];if(o&&(e.type===dI&&e.groupId===o.audioGroupId||e.type===aI&&e.groupId===o.textGroupId))return I.errorAction=this.getPlaylistRetryOrSwitchAction(I,i.loadLevel),I.errorAction.action=2,void(I.errorAction.flags=1)}return;case V.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=i.levels[i.loadLevel],d=null==c?void 0:c.attrs["HDCP-LEVEL"];return void(d&&(I.errorAction={action:2,flags:2,hdcpLevel:d}));case V.BUFFER_ADD_CODEC_ERROR:case V.REMUX_ALLOC_ERROR:return void(I.errorAction=this.getLevelSwitchAction(I,null!=(A=I.level)?A:i.loadLevel));case V.INTERNAL_EXCEPTION:case V.BUFFER_APPENDING_ERROR:case V.BUFFER_APPEND_ERROR:case V.BUFFER_FULL_ERROR:case V.LEVEL_SWITCH_ERROR:case V.BUFFER_STALLED_ERROR:case V.BUFFER_SEEK_OVER_HOLE:case V.BUFFER_NUDGE_ON_STALL:return void(I.errorAction={action:0,flags:0})}if(I.type===y.KEY_SYSTEM_ERROR){var a=this.getVariantLevelIndex(I.frag);return I.levelRetry=!1,void(I.errorAction=this.getLevelSwitchAction(I,a))}}},I.getPlaylistRetryOrSwitchAction=function(g,I){var C,A=vI(this.hls.config.playlistLoadPolicy,g),i=this.playlistError++,e=null==(C=g.response)?void 0:C.code;if(TI(A,i,DI(g),e))return{action:5,flags:0,retryConfig:A,retryCount:i};var t=this.getLevelSwitchAction(g,I);return A&&(t.retryConfig=A,t.retryCount=i),t},I.getFragRetryOrSwitchAction=function(g){var I=this.hls,C=this.getVariantLevelIndex(g.frag),A=I.levels[C],i=I.config,e=i.fragLoadPolicy,t=i.keyLoadPolicy,l=vI(g.details.startsWith("key")?t:e,g),s=I.levels.reduce((function(g,I){return g+I.fragmentError}),0);if(A){var o;g.details!==V.FRAG_GAP&&A.fragmentError++;var c=null==(o=g.response)?void 0:o.code;if(TI(l,s,DI(g),c))return{action:5,flags:0,retryConfig:l,retryCount:s}}var d=this.getLevelSwitchAction(g,C);return l&&(d.retryConfig=l,d.retryCount=s),d},I.getLevelSwitchAction=function(g,I){var C=this.hls;null==I&&(I=C.loadLevel);var A=this.hls.levels[I];if(A&&(A.loadError++,C.autoLevelEnabled)){for(var i,e,t=-1,l=C.levels,s=C.loadLevel,o=C.minAutoLevel,c=C.maxAutoLevel,d=null==(i=g.frag)?void 0:i.type,a=null!=(e=g.context)?e:{},n=a.type,r=a.groupId,m=l.length;m--;){var h=(m+s)%l.length;if(h!==s&&h>=o&&h<=c&&0===l[h].loadError){var Z=l[h];if(g.details===V.FRAG_GAP&&g.frag){var b=l[h].details;if(b){var G=UI(g.frag,b.fragments,g.frag.start);if(null!=G&&G.gap)continue}}else{if(n===dI&&r===Z.audioGroupId||n===aI&&r===Z.textGroupId)continue;if(d===rI&&A.audioGroupId===Z.audioGroupId||d===mI&&A.textGroupId===Z.textGroupId)continue}t=h;break}}if(t>-1&&C.loadLevel!==t)return g.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:t}}return{action:2,flags:1}},I.onErrorOut=function(g,I){var C;switch(null==(C=I.errorAction)?void 0:C.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(I),I.errorAction.resolved||I.details===V.FRAG_GAP||(I.fatal=!0)}I.fatal&&this.hls.stopLoad()},I.sendAlternateToPenaltyBox=function(g){var I=this.hls,C=g.errorAction;if(C){var A=C.flags,i=C.hdcpLevel,e=C.nextAutoLevel;switch(A){case 0:this.switchLevel(g,e);break;case 1:C.resolved||(C.resolved=this.redundantFailover(g));break;case 2:i&&(I.maxHdcpLevel=NI[NI.indexOf(i)-1],C.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+I.maxHdcpLevel+'" or lower')}C.resolved||this.switchLevel(g,e)}},I.switchLevel=function(g,I){void 0!==I&&g.errorAction&&(this.warn("switching to level "+I+" after "+g.details),this.hls.nextAutoLevel=I,g.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},I.redundantFailover=function(g){var I=this,C=this.hls,A=this.penalizedRenditions,i=g.parent===nI?g.level:C.loadLevel,e=C.levels[i],t=e.url.length,l=g.frag?g.frag.urlId:e.urlId;e.urlId!==l||g.frag&&!e.details||this.penalizeRendition(e,g);for(var s=function(){var s=(l+o)%t,c=A[s];if(!c||function(g,I,C){if(performance.now()-g.lastErrorPerfMs>3e5)return!0;var A=g.details;if(I.details===V.FRAG_GAP&&A&&I.frag){var i=I.frag.start,e=UI(null,A.fragments,i);if(e&&!e.gap)return!0}if(C&&g.errors.length3*A.targetduration)return!0}return!1}(c,g,A[l]))return I.warn("Switching to Redundant Stream "+(s+1)+"/"+t+': "'+e.url[s]+'" after '+g.details),I.playlistError=0,C.levels.forEach((function(g){g.urlId=s})),C.nextLoadLevel=i,{v:!0}},o=1;o=0&&c>I.partTarget&&(o+=1)}return new HI(s,o>=0?o:void 0,"")}}},I.loadPlaylist=function(g){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},I.shouldLoadPlaylist=function(g){return this.canLoad&&!!g&&!!g.url&&(!g.details||g.details.live)},I.shouldReloadPlaylist=function(g){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(g)},I.playlistLoaded=function(g,I,C){var A=this,i=I.details,e=I.stats,t=self.performance.now(),s=e.loading.first?Math.max(0,t-e.loading.first):0;if(i.advancedDateTime=Date.now()-s,i.live||null!=C&&C.live){if(i.reloaded(C),C&&this.log("live playlist "+g+" "+(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),C&&i.fragments.length>0&&function(g,I){for(var C=null,A=g.fragments,i=A.length-1;i>=0;i--){var e=A[i].initSegment;if(e){C=e;break}}g.fragmentHint&&delete g.fragmentHint.endPTS;var t,s,o,c,d,a=0;if(function(g,I,C){for(var A=I.skippedSegments,i=Math.max(g.startSN,I.startSN)-I.startSN,e=(g.fragmentHint?1:0)+(A?I.endSN:Math.min(g.endSN,I.endSN))-I.startSN,t=I.startSN-g.startSN,l=I.fragmentHint?I.fragments.concat(I.fragmentHint):I.fragments,s=g.fragmentHint?g.fragments.concat(g.fragmentHint):g.fragments,o=i;o<=e;o++){var c=s[t+o],d=l[o];A&&!d&&o0){if(C&&G>C.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+C.tuneInGoal+" to: "+G+" with playlist age: "+i.age),G=0;else{var u=Math.floor(G/i.targetduration);c+=u,void 0!==d&&(d+=Math.round(G%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+Z.toFixed(2)+"s goal: "+G+" skip sn "+u+" to part "+d)}i.tuneInGoal=G}if(o=this.getDeliveryDirectives(i,I.deliveryDirectives,c,d),a||!h)return void this.loadPlaylist(o)}else(i.canBlockReload||i.canSkipUntil)&&(o=this.getDeliveryDirectives(i,I.deliveryDirectives,c,d));var p=this.hls.mainForwardBufferInfo,w=p?p.end-p.len:0,B=function(g,I){void 0===I&&(I=1/0);var C=1e3*g.targetduration;if(g.updated){var A=g.fragments;if(A.length&&4*C>I){var i=1e3*A[A.length-1].duration;ithis.requestScheduled+B&&(this.requestScheduled=e.loading.start),void 0!==c&&i.canBlockReload?this.requestScheduled=e.loading.first+B-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+B=o.maxNumRetry)return!1;if(A&&null!=(d=g.context)&&d.deliveryDirectives)this.warn("Retrying playlist loading "+(s+1)+"/"+o.maxNumRetry+' after "'+C+'" without delivery-directives'),this.loadPlaylist();else{var a=LI(o,s);this.timer=self.setTimeout((function(){return I.loadPlaylist()}),a),this.warn("Retrying playlist loading "+(s+1)+"/"+o.maxNumRetry+' after "'+C+'" in '+a+"ms")}g.levelRetry=!0,i.resolved=!0}return c},g}(),_I=function(g){function I(I,C){var A;return(A=g.call(this,I,"[level-controller]")||this)._levels=[],A._firstLevel=-1,A._startLevel=void 0,A.currentLevel=null,A.currentLevelIndex=-1,A.manualLevelIndex=-1,A.steering=void 0,A.onParsedComplete=void 0,A.steering=C,A._registerListeners(),A}s(I,g);var C=I.prototype;return C._registerListeners=function(){var g=this.hls;g.on(B.MANIFEST_LOADING,this.onManifestLoading,this),g.on(B.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(B.LEVEL_LOADED,this.onLevelLoaded,this),g.on(B.LEVELS_UPDATED,this.onLevelsUpdated,this),g.on(B.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.on(B.FRAG_LOADED,this.onFragLoaded,this),g.on(B.ERROR,this.onError,this)},C._unregisterListeners=function(){var g=this.hls;g.off(B.MANIFEST_LOADING,this.onManifestLoading,this),g.off(B.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(B.LEVEL_LOADED,this.onLevelLoaded,this),g.off(B.LEVELS_UPDATED,this.onLevelsUpdated,this),g.off(B.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.off(B.FRAG_LOADED,this.onFragLoaded,this),g.off(B.ERROR,this.onError,this)},C.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),g.prototype.destroy.call(this)},C.startLoad=function(){this._levels.forEach((function(g){g.loadError=0,g.fragmentError=0})),g.prototype.startLoad.call(this)},C.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},C.onManifestLoading=function(g,I){this.resetLevels()},C.onManifestLoaded=function(g,I){var C,A=[],i={};I.levels.forEach((function(g){var I,e=g.attrs;-1!==(null==(I=g.audioCodec)?void 0:I.indexOf("mp4a.40.34"))&&(OI||(OI=/chrome|firefox/i.test(navigator.userAgent)),OI&&(g.audioCodec=void 0));var t=e.AUDIO,l=e.CODECS,s=e["FRAME-RATE"],o=e["PATHWAY-ID"],c=e.RESOLUTION,d=e.SUBTITLES,a=(o||".")+"-"+g.bitrate+"-"+c+"-"+s+"-"+l;(C=i[a])?C.addFallback(g):(C=new KI(g),i[a]=C,A.push(C)),qI(C,"audio",t),qI(C,"text",d)})),this.filterAndSortMediaOptions(A,I)},C.filterAndSortMediaOptions=function(g,I){var C=this,A=[],i=[],e=!1,t=!1,l=!1,s=g.filter((function(g){var I=g.audioCodec,C=g.videoCodec,A=g.width,i=g.height,s=g.unknownCodecs;return e||(e=!(!A||!i)),t||(t=!!C),l||(l=!!I),!(null!=s&&s.length)&&(!I||Eg(I,"audio"))&&(!C||Eg(C,"video"))}));if((e||t)&&l&&(s=s.filter((function(g){var I=g.videoCodec,C=g.width,A=g.height;return!!I||!(!C||!A)}))),0!==s.length){I.audioTracks&&$I(A=I.audioTracks.filter((function(g){return!g.audioCodec||Eg(g.audioCodec,"audio")}))),I.subtitles&&$I(i=I.subtitles);var o=s.slice(0);s.sort((function(g,I){return g.attrs["HDCP-LEVEL"]!==I.attrs["HDCP-LEVEL"]?(g.attrs["HDCP-LEVEL"]||"")>(I.attrs["HDCP-LEVEL"]||"")?1:-1:g.bitrate!==I.bitrate?g.bitrate-I.bitrate:g.attrs["FRAME-RATE"]!==I.attrs["FRAME-RATE"]?g.attrs.decimalFloatingPoint("FRAME-RATE")-I.attrs.decimalFloatingPoint("FRAME-RATE"):g.attrs.SCORE!==I.attrs.SCORE?g.attrs.decimalFloatingPoint("SCORE")-I.attrs.decimalFloatingPoint("SCORE"):e&&g.height!==I.height?g.height-I.height:0}));var c=o[0];if(this.steering&&(s=this.steering.filterParsedLevels(s)).length!==o.length)for(var d=0;d1&&void 0!==I?(i.url=i.url.filter(A),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(A)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(A)),i.urlId=0,!0):(C.steering&&C.steering.removeLevel(i),!1))}));this.hls.trigger(B.LEVELS_UPDATED,{levels:i})},C.onLevelsUpdated=function(g,I){var C=I.levels;C.forEach((function(g,I){var C=g.details;null!=C&&C.fragments&&C.fragments.forEach((function(g){g.level=I}))})),this._levels=C},e(I,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(g){var I=this._levels;if(0!==I.length){if(g<0||g>=I.length){var C=new Error("invalid level idx"),A=g<0;if(this.hls.trigger(B.ERROR,{type:y.OTHER_ERROR,details:V.LEVEL_SWITCH_ERROR,level:g,fatal:A,error:C,reason:C.message}),A)return;g=Math.min(g,I.length-1)}var i=this.currentLevelIndex,e=this.currentLevel,t=e?e.attrs["PATHWAY-ID"]:void 0,s=I[g],o=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=g,this.currentLevel=s,i!==g||!s.details||!e||t!==o){this.log("Switching to level "+g+(o?" with Pathway "+o:"")+" from level "+i+(t?" with Pathway "+t:""));var c=l({},s,{level:g,maxBitrate:s.maxBitrate,attrs:s.attrs,uri:s.uri,urlId:s.urlId});delete c._attrs,delete c._urlId,this.hls.trigger(B.LEVEL_SWITCHING,c);var d=s.details;if(!d||d.live){var a=this.switchParams(s.uri,null==e?void 0:e.details);this.loadPlaylist(a)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(g){this.manualLevelIndex=g,void 0===this._startLevel&&(this._startLevel=g),-1!==g&&(this.level=g)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(g){this._firstLevel=g}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var g=this.hls.config.startLevel;return void 0!==g?g:this._firstLevel}return this._startLevel},set:function(g){this._startLevel=g}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(g){this.level=g,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=g)}}]),I}(PI);function qI(g,I,C){C&&("audio"===I?(g.audioGroupIds||(g.audioGroupIds=[]),g.audioGroupIds[g.url.length-1]=C):"text"===I&&(g.textGroupIds||(g.textGroupIds=[]),g.textGroupIds[g.url.length-1]=C))}function $I(g){var I={};g.forEach((function(g){var C=g.groupId||"";g.id=I[C]=I[C]||0,I[C]++}))}var gC="NOT_LOADED",IC="APPENDING",CC="PARTIAL",AC="OK",iC=function(){function g(g){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=g,this._registerListeners()}var I=g.prototype;return I._registerListeners=function(){var g=this.hls;g.on(B.BUFFER_APPENDED,this.onBufferAppended,this),g.on(B.FRAG_BUFFERED,this.onFragBuffered,this),g.on(B.FRAG_LOADED,this.onFragLoaded,this)},I._unregisterListeners=function(){var g=this.hls;g.off(B.BUFFER_APPENDED,this.onBufferAppended,this),g.off(B.FRAG_BUFFERED,this.onFragBuffered,this),g.off(B.FRAG_LOADED,this.onFragLoaded,this)},I.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},I.getAppendedFrag=function(g,I){var C=this.activePartLists[I];if(C)for(var A=C.length;A--;){var i=C[A];if(!i)break;var e=i.end;if(i.start<=g&&null!==e&&g<=e)return i}return this.getBufferedFrag(g,I)},I.getBufferedFrag=function(g,I){for(var C=this.fragments,A=Object.keys(C),i=A.length;i--;){var e=C[A[i]];if((null==e?void 0:e.body.type)===I&&e.buffered){var t=e.body;if(t.start<=g&&g<=t.end)return t}}return null},I.detectEvictedFragments=function(g,I,C,A){var i=this;this.timeRanges&&(this.timeRanges[g]=I);var e=(null==A?void 0:A.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(A){var t=i.fragments[A];if(t&&!(e>=t.body.sn))if(t.buffered||t.loaded){var l=t.range[g];l&&l.time.some((function(g){var C=!i.isTimeBuffered(g.startPTS,g.endPTS,I);return C&&i.removeFragment(t.body),C}))}else t.body.type===C&&i.removeFragment(t.body)}))},I.detectPartialFragments=function(g){var I=this,C=this.timeRanges,A=g.frag,i=g.part;if(C&&"initSegment"!==A.sn){var e=tC(A),t=this.fragments[e];if(!(!t||t.buffered&&A.gap)){var l=!A.relurl;Object.keys(C).forEach((function(g){var e=A.elementaryStreams[g];if(e){var s=C[g],o=l||!0===e.partial;t.range[g]=I.getBufferedTimes(A,i,o,s)}})),t.loaded=null,Object.keys(t.range).length?(t.buffered=!0,(t.body.endList=A.endList||t.body.endList)&&(this.endListFragments[t.body.type]=t),eC(t)||this.removeParts(A.sn-1,A.type)):this.removeFragment(t.body)}}},I.removeParts=function(g,I){var C=this.activePartLists[I];C&&(this.activePartLists[I]=C.filter((function(I){return I.fragment.sn>=g})))},I.fragBuffered=function(g,I){var C=tC(g),A=this.fragments[C];!A&&I&&(A=this.fragments[C]={body:g,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},g.gap&&(this.hasGaps=!0)),A&&(A.loaded=null,A.buffered=!0)},I.getBufferedTimes=function(g,I,C,A){for(var i={time:[],partial:C},e=g.start,t=g.end,l=g.minEndPTS||t,s=g.maxStartPTS||e,o=0;o=c&&l<=d){i.time.push({startPTS:Math.max(e,A.start(o)),endPTS:Math.min(t,A.end(o))});break}if(ec)i.partial=!0,i.time.push({startPTS:Math.max(e,A.start(o)),endPTS:Math.min(t,A.end(o))});else if(t<=c)break}return i},I.getPartialFragment=function(g){var I,C,A,i=null,e=0,t=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(s){var o=l[s];o&&eC(o)&&(C=o.body.start-t,A=o.body.end+t,g>=C&&g<=A&&(I=Math.min(g-C,A-g),e<=I&&(i=o.body,e=I)))})),i},I.isEndListAppended=function(g){var I=this.endListFragments[g];return void 0!==I&&(I.buffered||eC(I))},I.getState=function(g){var I=tC(g),C=this.fragments[I];return C?C.buffered?eC(C)?CC:AC:IC:gC},I.isTimeBuffered=function(g,I,C){for(var A,i,e=0;e=A&&I<=i)return!0;if(I<=A)return!1}return!1},I.onFragLoaded=function(g,I){var C=I.frag,A=I.part;if("initSegment"!==C.sn&&!C.bitrateTest){var i=A?null:I,e=tC(C);this.fragments[e]={body:C,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}},I.onBufferAppended=function(g,I){var C=this,A=I.frag,i=I.part,e=I.timeRanges;if("initSegment"!==A.sn){var t=A.type;if(i){var l=this.activePartLists[t];l||(this.activePartLists[t]=l=[]),l.push(i)}this.timeRanges=e,Object.keys(e).forEach((function(g){var I=e[g];C.detectEvictedFragments(g,I,t,i)}))}},I.onFragBuffered=function(g,I){this.detectPartialFragments(I)},I.hasFragment=function(g){var I=tC(g);return!!this.fragments[I]},I.hasParts=function(g){var I;return!(null==(I=this.activePartLists[g])||!I.length)},I.removeFragmentsInRange=function(g,I,C,A,i){var e=this;A&&!this.hasGaps||Object.keys(this.fragments).forEach((function(t){var l=e.fragments[t];if(l){var s=l.body;s.type!==C||A&&!s.gap||s.startg&&(l.buffered||i)&&e.removeFragment(s)}}))},I.removeFragment=function(g){var I=tC(g);g.stats.loaded=0,g.clearElementaryStreamInfo();var C=this.activePartLists[g.type];if(C){var A=g.sn;this.activePartLists[g.type]=C.filter((function(g){return g.fragment.sn!==A}))}delete this.fragments[I],g.endList&&delete this.endListFragments[g.type]},I.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},g}();function eC(g){var I,C,A;return g.buffered&&(g.body.gap||(null==(I=g.range.video)?void 0:I.partial)||(null==(C=g.range.audio)?void 0:C.partial)||(null==(A=g.range.audiovideo)?void 0:A.partial))}function tC(g){return g.type+"_"+g.level+"_"+g.urlId+"_"+g.sn}var lC=Math.pow(2,17),sC=function(){function g(g){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=g}var I=g.prototype;return I.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},I.abort=function(){this.loader&&this.loader.abort()},I.load=function(g,I){var C=this,i=g.url;if(!i)return Promise.reject(new dC({type:y.NETWORK_ERROR,details:V.FRAG_LOAD_ERROR,fatal:!1,frag:g,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var e=this.config,t=e.fLoader,l=e.loader;return new Promise((function(s,o){if(C.loader&&C.loader.destroy(),g.gap){if(g.tagList.some((function(g){return"GAP"===g[0]})))return void o(cC(g));g.gap=!1}var c=C.loader=g.loader=t?new t(e):new l(e),d=oC(g),a=zI(e.fragLoadPolicy.default),n={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===g.sn?1/0:lC};g.stats=c.stats,c.load(d,n,{onSuccess:function(I,A,i,e){C.resetLoader(g,c);var t=I.data;i.resetIV&&g.decryptdata&&(g.decryptdata.iv=new Uint8Array(t.slice(0,16)),t=t.slice(16)),s({frag:g,part:null,payload:t,networkDetails:e})},onError:function(I,e,t,l){C.resetLoader(g,c),o(new dC({type:y.NETWORK_ERROR,details:V.FRAG_LOAD_ERROR,fatal:!1,frag:g,response:A({url:i,data:void 0},I),error:new Error("HTTP Error "+I.code+" "+I.text),networkDetails:t,stats:l}))},onAbort:function(I,A,i){C.resetLoader(g,c),o(new dC({type:y.NETWORK_ERROR,details:V.INTERNAL_ABORTED,fatal:!1,frag:g,error:new Error("Aborted"),networkDetails:i,stats:I}))},onTimeout:function(I,A,i){C.resetLoader(g,c),o(new dC({type:y.NETWORK_ERROR,details:V.FRAG_LOAD_TIMEOUT,fatal:!1,frag:g,error:new Error("Timeout after "+n.timeout+"ms"),networkDetails:i,stats:I}))},onProgress:function(C,A,i,e){I&&I({frag:g,part:null,payload:i,networkDetails:e})}})}))},I.loadPart=function(g,I,C){var i=this;this.abort();var e=this.config,t=e.fLoader,l=e.loader;return new Promise((function(s,o){if(i.loader&&i.loader.destroy(),g.gap||I.gap)o(cC(g,I));else{var c=i.loader=g.loader=t?new t(e):new l(e),d=oC(g,I),a=zI(e.fragLoadPolicy.default),n={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:lC};I.stats=c.stats,c.load(d,n,{onSuccess:function(A,e,t,l){i.resetLoader(g,c),i.updateStatsFromPart(g,I);var o={frag:g,part:I,payload:A.data,networkDetails:l};C(o),s(o)},onError:function(C,e,t,l){i.resetLoader(g,c),o(new dC({type:y.NETWORK_ERROR,details:V.FRAG_LOAD_ERROR,fatal:!1,frag:g,part:I,response:A({url:d.url,data:void 0},C),error:new Error("HTTP Error "+C.code+" "+C.text),networkDetails:t,stats:l}))},onAbort:function(C,A,e){g.stats.aborted=I.stats.aborted,i.resetLoader(g,c),o(new dC({type:y.NETWORK_ERROR,details:V.INTERNAL_ABORTED,fatal:!1,frag:g,part:I,error:new Error("Aborted"),networkDetails:e,stats:C}))},onTimeout:function(C,A,e){i.resetLoader(g,c),o(new dC({type:y.NETWORK_ERROR,details:V.FRAG_LOAD_TIMEOUT,fatal:!1,frag:g,part:I,error:new Error("Timeout after "+n.timeout+"ms"),networkDetails:e,stats:C}))}})}}))},I.updateStatsFromPart=function(g,I){var C=g.stats,A=I.stats,i=A.total;if(C.loaded+=A.loaded,i){var e=Math.round(g.duration/I.duration),t=Math.min(Math.round(C.loaded/i),e),l=(e-t)*Math.round(C.loaded/t);C.total=C.loaded+l}else C.total=Math.max(C.loaded,C.total);var s=C.loading,o=A.loading;s.start?s.first+=o.first-o.start:(s.start=o.start,s.first=o.first),s.end=o.end},I.resetLoader=function(g,I){g.loader=null,this.loader===I&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),I.destroy()},g}();function oC(g,I){void 0===I&&(I=null);var C=I||g,A={frag:g,part:I,responseType:"arraybuffer",url:C.url,headers:{},rangeStart:0,rangeEnd:0},i=C.byteRangeStartOffset,e=C.byteRangeEndOffset;if(W(i)&&W(e)){var t,l=i,s=e;if("initSegment"===g.sn&&"AES-128"===(null==(t=g.decryptdata)?void 0:t.method)){var o=e-i;o%16&&(s=e+(16-o%16)),0!==i&&(A.resetIV=!0,l=i-16)}A.rangeStart=l,A.rangeEnd=s}return A}function cC(g,I){var C=new Error("GAP "+(g.gap?"tag":"attribute")+" found"),A={type:y.MEDIA_ERROR,details:V.FRAG_GAP,fatal:!1,frag:g,error:C,networkDetails:null};return I&&(A.part=I),(I||g).stats.aborted=!0,new dC(A)}var dC=function(g){function I(I){var C;return(C=g.call(this,I.error.message)||this).data=void 0,C.data=I,C}return s(I,g),I}(a(Error)),aC=function(){function g(g){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=g}var I=g.prototype;return I.abort=function(g){for(var I in this.keyUriToKeyInfo){var C=this.keyUriToKeyInfo[I].loader;if(C){if(g&&g!==C.context.frag.type)return;C.abort()}}},I.detach=function(){for(var g in this.keyUriToKeyInfo){var I=this.keyUriToKeyInfo[g];(I.mediaKeySessionContext||I.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[g]}},I.destroy=function(){for(var g in this.detach(),this.keyUriToKeyInfo){var I=this.keyUriToKeyInfo[g].loader;I&&I.destroy()}this.keyUriToKeyInfo={}},I.createKeyLoadError=function(g,I,C,A,i){return void 0===I&&(I=V.KEY_LOAD_ERROR),new dC({type:y.NETWORK_ERROR,details:I,fatal:!1,frag:g,response:i,error:C,networkDetails:A})},I.loadClear=function(g,I){var C=this;if(this.emeController&&this.config.emeEnabled)for(var A=g.sn,i=g.cc,e=function(){var g=I[t];if(i<=g.cc&&("initSegment"===A||"initSegment"===g.sn||A1&&this.tickImmediate(),this._tickCallCount=0)},I.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},I.doTick=function(){},g}(),rC={length:0,start:function(){return 0},end:function(){return 0}},mC=function(){function g(){}return g.isBuffered=function(I,C){try{if(I)for(var A=g.getBuffered(I),i=0;i=A.start(i)&&C<=A.end(i))return!0}catch(e){}return!1},g.bufferInfo=function(I,C,A){try{if(I){var i,e=g.getBuffered(I),t=[];for(i=0;it&&(A[e-1].end=g[i].end):A.push(g[i])}else A.push(g[i])}else A=g;for(var l,s=0,o=I,c=I,d=0;d=a&&I>>8^255&h^99,g[n]=h,I[h]=n;var Z=a[n],b=a[Z],G=a[b],u=257*a[h]^16843008*h;A[n]=u<<24|u>>>8,i[n]=u<<16|u>>>16,e[n]=u<<8|u>>>24,t[n]=u,u=16843009*G^65537*b^257*Z^16843008*n,s[h]=u<<24|u>>>8,o[h]=u<<16|u>>>16,c[h]=u<<8|u>>>24,d[h]=u,n?(n=Z^a[a[a[G^Z]]],r^=a[a[r]]):n=r=1}},I.expandKey=function(g){for(var I=this.uint8ArrayToUint32Array_(g),C=!0,A=0;At.end){var c=e>o;(e0&&e&&e.key&&e.iv&&"AES-128"===e.method){var t=self.performance.now();return C.decrypter.decrypt(new Uint8Array(i),e.key.buffer,e.iv.buffer).catch((function(I){throw A.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_DECRYPT_ERROR,fatal:!1,error:I,reason:I.message,frag:g}),I})).then((function(C){var i=self.performance.now();return A.trigger(B.FRAG_DECRYPTED,{frag:g,payload:C,stats:{tstart:t,tdecrypt:i}}),I.payload=C,I}))}return I})).then((function(A){var i=C.fragCurrent,e=C.hls;if(!C.levels)throw new Error("init load aborted, missing levels");var t=g.stats;C.state=VC,I.fragmentError=0,g.data=new Uint8Array(A.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),A.frag===i&&e.trigger(B.FRAG_BUFFERED,{stats:t,frag:i,part:null,id:g.type}),C.tick()})).catch((function(I){C.state!==yC&&C.state!==FC&&(C.warn(I),C.resetFragmentLoading(g))}))},C.fragContextChanged=function(g){var I=this.fragCurrent;return!g||!I||g.level!==I.level||g.sn!==I.sn||g.urlId!==I.urlId},C.fragBufferedComplete=function(g,I){var C,A,i,e,t=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(I?" part: "+I.index:"")+" of "+(this.playlistType===nI?"level":"track")+" "+g.level+" (frag:["+(null!=(C=g.startPTS)?C:NaN).toFixed(3)+"-"+(null!=(A=g.endPTS)?A:NaN).toFixed(3)+"] > buffer:"+(t?function(g){for(var I="",C=g.length,A=0;Ag.end&&t.fragmentHint&&(g=t.fragmentHint);var o=this.getNextPart(s,g,C);if(o>-1){var c,d=s[o];return this.log("Loading part sn: "+g.sn+" p: "+d.index+" cc: "+g.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+o+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+g.level+", target: "+parseFloat(C.toFixed(3))),this.nextLoadPosition=d.start+d.duration,this.state=YC,c=l?l.then((function(C){return!C||e.fragContextChanged(C.frag)?null:e.doFragPartsLoad(g,d,I,A)})).catch((function(g){return e.handleFragLoadError(g)})):this.doFragPartsLoad(g,d,I,A).catch((function(g){return e.handleFragLoadError(g)})),this.hls.trigger(B.FRAG_LOADING,{frag:g,part:d,targetBufferTime:C}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!g.url||this.loadedEndOfParts(s,C))return Promise.resolve(null)}}this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+g.level+", target: "+parseFloat(C.toFixed(3))),W(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=YC;var a,n=this.config.progressive;return a=n&&l?l.then((function(I){return!I||e.fragContextChanged(null==I?void 0:I.frag)?null:e.fragmentLoader.load(g,A)})).catch((function(g){return e.handleFragLoadError(g)})):Promise.all([this.fragmentLoader.load(g,n?A:void 0),l]).then((function(g){var I=g[0];return!n&&I&&A&&A(I),I})).catch((function(g){return e.handleFragLoadError(g)})),this.hls.trigger(B.FRAG_LOADING,{frag:g,targetBufferTime:C}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):a},C.doFragPartsLoad=function(g,I,C,A){var i=this;return new Promise((function(e,t){var l,s=[],o=null==(l=C.details)?void 0:l.partList;!function I(l){i.fragmentLoader.loadPart(g,l,A).then((function(A){s[l.index]=A;var t=A.part;i.hls.trigger(B.FRAG_LOADED,A);var c=JI(C,g.sn,l.index+1)||kI(o,g.sn,l.index+1);if(!c)return e({frag:g,part:t,partsLoaded:s});I(c)})).catch(t)}(I)}))},C.handleFragLoadError=function(g){if("data"in g){var I=g.data;g.data&&I.details===V.INTERNAL_ABORTED?this.handleFragLoadAborted(I.frag,I.part):this.hls.trigger(B.ERROR,I)}else this.hls.trigger(B.ERROR,{type:y.OTHER_ERROR,details:V.INTERNAL_EXCEPTION,err:g,error:g,fatal:!0});return null},C._handleTransmuxerFlush=function(g){var I=this.getCurrentContext(g);if(I&&this.state===HC){var C=I.frag,A=I.part,i=I.level,e=self.performance.now();C.stats.parsing.end=e,A&&(A.stats.parsing.end=e),this.updateLevelTiming(C,A,i,g.partial)}else this.fragCurrent||this.state===yC||this.state===FC||(this.state=VC)},C.getCurrentContext=function(g){var I=this.levels,C=this.fragCurrent,A=g.level,i=g.sn,e=g.part;if(null==I||!I[A])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+A+". The current chunk will not be buffered."),null;var t=I[A],l=e>-1?JI(t,i,e):null,s=l?l.fragment:function(g,I,C){if(null==g||!g.details)return null;var A=g.details,i=A.fragments[I-A.startSN];return i||((i=A.fragmentHint)&&i.sn===I?i:Ie&&this.flushMainBuffer(t,g.start)}else this.flushMainBuffer(0,g.start)},C.getFwdBufferInfo=function(g,I){var C=this.getLoadPosition();return W(C)?this.getFwdBufferInfoAtPos(g,C,I):null},C.getFwdBufferInfoAtPos=function(g,I,C){var A=this.config.maxBufferHole,i=mC.bufferInfo(g,I,A);if(0===i.len&&void 0!==i.nextStart){var e=this.fragmentTracker.getBufferedFrag(I,C);if(e&&i.nextStart=C&&(I.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+I.maxMaxBufferLength+"s"),!0)},C.getAppendedFrag=function(g,I){var C=this.fragmentTracker.getAppendedFrag(g,nI);return C&&"fragment"in C?C.fragment:C},C.getNextFragment=function(g,I){var C=I.fragments,A=C.length;if(!A)return null;var i,e=this.config,t=C[0].start;if(I.live){var l=e.initialLiveManifestSize;if(AI},C.getNextFragmentLoopLoading=function(g,I,C,A,i){var e=g.gap,t=this.getNextFragment(this.nextLoadPosition,I);if(null===t)return t;if(g=t,e&&g&&!g.gap&&C.nextStart){var l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,C.nextStart,A);if(null!==l&&C.len+l.len>=i)return this.log('buffer full after gaps in "'+A+'" playlist starting at sn: '+g.sn),null}return g},C.mapToInitFragWhenRequired=function(g){return null==g||!g.initSegment||null!=g&&g.initSegment.data||this.bitrateTest?g:g.initSegment},C.getNextPart=function(g,I,C){for(var A=-1,i=!1,e=!0,t=0,l=g.length;t-1&&CC.start&&C.loaded},C.getInitialLiveFragment=function(g,I){var C,A,i=this.fragPrevious,e=null;if(i){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),e=function(g,I,C){if(null===I||!Array.isArray(g)||!g.length||!W(I))return null;if(I<(g[0].programDateTime||0))return null;if(I>=(g[g.length-1].endProgramDateTime||0))return null;C=C||0;for(var A=0;A=g.startSN&&t<=g.endSN){var l=I[t-g.startSN];i.cc===l.cc&&(e=l,this.log("Live playlist, switching playlist, load frag with next SN: "+e.sn))}e||(C=I,A=i.cc,(e=xI(C,(function(g){return g.ccA?-1:0})))&&this.log("Live playlist, switching playlist, load frag with same CC: "+e.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(e=this.getFragmentAtPosition(s,this.bitrateTest?g.fragmentEnd:g.edge,g))}return e},C.getFragmentAtPosition=function(g,I,C){var A,i=this.config,e=this.fragPrevious,t=C.fragments,l=C.endSN,s=C.fragmentHint,o=i.maxFragLookUpTolerance,c=C.partList,d=!!(i.lowLatencyMode&&null!=c&&c.length&&s);if(d&&s&&!this.bitrateTest&&(t=t.concat(s),l=s.sn),A=gI-o?0:o):t[t.length-1]){var a=A.sn-C.startSN,n=this.fragmentTracker.getState(A);if((n===AC||n===CC&&A.gap)&&(e=A),e&&A.sn===e.sn&&(!d||c[0].fragment.sn>A.sn)&&e&&A.level===e.level){var r=t[a+1];A=A.sn=e-I.maxFragLookUpTolerance&&i<=t;if(null!==A&&C.duration>A&&(ie.startCC||i&&i.cc"+g.startSN+" prev-sn: "+(i?i.sn:"na")+" fragments: "+t),c}return l},C.waitForCdnTuneIn=function(g){return g.live&&g.canBlockReload&&g.partTarget&&g.tuneInGoal>Math.max(g.partHoldBack,3*g.partTarget)},C.setStartPosition=function(g,I){var C=this.startPosition;if(C "+(null==(i=this.fragCurrent)?void 0:i.url))}else{var e=I.details===V.FRAG_GAP;e&&this.fragmentTracker.fragBuffered(A,!0);var t=I.errorAction,l=t||{},s=l.action,o=l.retryCount,c=void 0===o?0:o,d=l.retryConfig;if(t&&5===s&&d){var a;this.resetStartWhenNotLoaded(null!=(a=this.levelLastLoaded)?a:A.level);var n=LI(d,c);this.warn("Fragment "+A.sn+" of "+g+" "+A.level+" errored with "+I.details+", retrying loading "+(c+1)+"/"+d.maxNumRetry+" in "+n+"ms"),t.resolved=!0,this.retryDate=self.performance.now()+n,this.state=RC}else d&&t?(this.resetFragmentErrors(g),c.5;A&&this.reduceMaxBufferLength(C.len);var i=!A;return i&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+I+" buffer"),g.frag&&(this.fragmentTracker.removeFragment(g.frag),this.nextLoadPosition=g.frag.start),this.resetLoadingState(),i}return!1},C.resetFragmentErrors=function(g){g===rI&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==yC&&(this.state=VC)},C.afterBufferFlushed=function(g,I,C){if(g){var A=mC.getBuffered(g);this.fragmentTracker.detectEvictedFragments(I,A,C),this.state===fC&&this.resetLoadingState()}},C.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=VC},C.resetStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var I=this.levels?this.levels[g].details:null;null!=I&&I.live?(this.startPosition=-1,this.setStartPosition(I,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},C.resetWhenMissingContext=function(g){var I;this.warn("The loading context changed while buffering fragment "+g.sn+" of level "+g.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(I=this.levelLastLoaded)?I:g.level),this.resetLoadingState()},C.removeUnbufferedFrags=function(g){void 0===g&&(g=0),this.fragmentTracker.removeFragmentsInRange(g,1/0,this.playlistType,!1,!0)},C.updateLevelTiming=function(g,I,C,A){var i,e=this,t=C.details;if(t){if(Object.keys(g.elementaryStreams).reduce((function(I,i){var l=g.elementaryStreams[i];if(l){var s=l.endPTS-l.startPTS;if(s<=0)return e.warn("Could not parse fragment "+g.sn+" "+i+" duration reliably ("+s+")"),I||!1;var o=A?0:FI(t,g,l.startPTS,l.endPTS,l.startDTS,l.endDTS);return e.hls.trigger(B.LEVEL_PTS_UPDATED,{details:t,level:C,drift:o,type:i,frag:g,start:l.startPTS,end:l.endPTS}),!0}return I}),!1))C.fragmentError=0;else if(null===(null==(i=this.transmuxer)?void 0:i.error)){var l=new Error("Found no media in fragment "+g.sn+" of level "+g.level+" resetting transmuxer to fallback to playlist timing");if(0===C.fragmentError&&(C.fragmentError++,g.gap=!0,this.fragmentTracker.removeFragment(g),this.fragmentTracker.fragBuffered(g,!0)),this.warn(l.message),this.hls.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:g,reason:"Found no media in msn "+g.sn+' of level "'+C.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=KC,this.hls.trigger(B.FRAG_PARSED,{frag:g,part:I})}else this.warn("level.details undefined")},C.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C.recoverWorkerError=function(g){var I,C,A;"demuxerWorker"===g.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(I=null!=(C=this.levelLastLoaded)?C:null==(A=this.fragCurrent)?void 0:A.level)?I:0),this.resetLoadingState())},e(I,[{key:"state",get:function(){return this._state},set:function(g){var I=this._state;I!==g&&(this._state=g,this.log(I+"->"+g))}}]),I}(nC);function kC(){return self.SourceBuffer||self.WebKitSourceBuffer}function DC(g,I){return void 0===g&&(g=""),void 0===I&&(I=9e4),{type:g,id:-1,pid:-1,inputTimeScale:I,sequenceNumber:-1,samples:[],dropped:0}}var vC=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var I=g.prototype;return I.resetInitSegment=function(g,I,C,A){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},I.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},I.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},I.canParse=function(g,I){return!1},I.appendFrame=function(g,I,C){},I.demux=function(g,I){this.cachedData&&(g=fg(this.cachedData,g),this.cachedData=null);var C,A=lg(g,0),i=A?A.length:0,e=this._audioTrack,t=this._id3Track,l=A?function(g){for(var I=ag(g),C=0;C0&&t.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:A,type:WI,duration:Number.POSITIVE_INFINITY});i>>5}function UC(g,I){return I+1=g.length)return!1;var A=xC(g,I);if(A<=C)return!1;var i=I+A;return i===g.length||UC(g,i)}return!1}function QC(g,I,C,A,i){if(!g.samplerate){var e=function(g,I,C,A){var i,e,t,l,s=navigator.userAgent.toLowerCase(),o=A,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=1+((192&I[C+2])>>>6);var d=(60&I[C+2])>>>2;if(!(d>c.length-1))return t=(1&I[C+2])<<2,t|=(192&I[C+3])>>>6,H.log("manifest codec:"+A+", ADTS type:"+i+", samplingIndex:"+d),/firefox/i.test(s)?d>=6?(i=5,l=new Array(4),e=d-3):(i=2,l=new Array(2),e=d):-1!==s.indexOf("android")?(i=2,l=new Array(2),e=d):(i=5,l=new Array(4),A&&(-1!==A.indexOf("mp4a.40.29")||-1!==A.indexOf("mp4a.40.5"))||!A&&d>=6?e=d-3:((A&&-1!==A.indexOf("mp4a.40.2")&&(d>=6&&1===t||/vivaldi/i.test(s))||!A&&1===t)&&(i=2,l=new Array(2)),e=d)),l[0]=i<<3,l[0]|=(14&d)>>1,l[1]|=(1&d)<<7,l[1]|=t<<3,5===i&&(l[1]|=(14&e)>>1,l[2]=(1&e)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:c[d],channelCount:t,codec:"mp4a.40."+i,manifestCodec:o};g.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(I,C,A,i);if(!e)return;g.config=e.config,g.samplerate=e.samplerate,g.channelCount=e.channelCount,g.codec=e.codec,g.manifestCodec=e.manifestCodec,H.log("parsed codec:"+g.codec+", rate:"+e.samplerate+", channels:"+e.channelCount)}}function OC(g){return 9216e4/g}function EC(g,I,C,A,i){var e,t=A+i*OC(g.samplerate),l=function(g,I){var C=TC(g,I);if(I+C<=g.length){var A=xC(g,I)-C;if(A>0)return{headerLength:C,frameLength:A}}}(I,C);if(l){var s=l.frameLength,o=l.headerLength,c=o+s,d=Math.max(0,C+c-I.length);d?(e=new Uint8Array(c-o)).set(I.subarray(C+o,I.length),0):e=I.subarray(C+o,C+c);var a={unit:e,pts:t};return d||g.samples.push(a),{sample:a,length:c,missing:d}}var n=I.length-C;return(e=new Uint8Array(n)).set(I.subarray(C,I.length),0),{sample:{unit:e,pts:t},length:n,missing:-1}}var PC=function(g){function I(I,C){var A;return(A=g.call(this)||this).observer=void 0,A.config=void 0,A.observer=I,A.config=C,A}s(I,g);var C=I.prototype;return C.resetInitSegment=function(I,C,A,i){g.prototype.resetInitSegment.call(this,I,C,A,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:C,duration:i,inputTimeScale:9e4,dropped:0}},I.probe=function(g){if(!g)return!1;for(var I=(lg(g,0)||[]).length,C=g.length;I16384?g.subarray(0,16384):g,["moof"]).length>0},I.demux=function(g,I){this.timeOffset=I;var C=g,A=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(C=fg(this.remainderData,g));var e=function(g){var I={valid:null,remainder:null},C=Yg(g,["moof"]);if(!C)return I;if(C.length<2)return I.remainder=g,I;var A=C[C.length-1];return I.valid=Ag(g,0,A.byteOffset-8),I.remainder=Ag(g,A.byteOffset-8),I}(C);this.remainderData=e.remainder,A.samples=e.valid||new Uint8Array}else A.samples=C;var t=this.extractID3Track(A,I);return i.samples=Fg(I,A),{videoTrack:A,audioTrack:this.audioTrack,id3Track:t,textTrack:this.txtTrack}},I.flush=function(){var g=this.timeOffset,I=this.videoTrack,C=this.txtTrack;I.samples=this.remainderData||new Uint8Array,this.remainderData=null;var A=this.extractID3Track(I,this.timeOffset);return C.samples=Fg(g,I),{videoTrack:I,audioTrack:DC(),id3Track:A,textTrack:DC()}},I.extractID3Track=function(g,I){var C=this.id3Track;if(g.samples.length){var A=Yg(g.samples,["emsg"]);A&&A.forEach((function(g){var A=function(g){var I=g[0],C="",A="",i=0,e=0,t=0,l=0,s=0,o=0;if(0===I){for(;"\0"!==Wg(g.subarray(o,o+1));)C+=Wg(g.subarray(o,o+1)),o+=1;for(C+=Wg(g.subarray(o,o+1)),o+=1;"\0"!==Wg(g.subarray(o,o+1));)A+=Wg(g.subarray(o,o+1)),o+=1;A+=Wg(g.subarray(o,o+1)),o+=1,i=yg(g,12),e=yg(g,16),l=yg(g,20),s=yg(g,24),o=28}else if(1===I){i=yg(g,o+=4);var c=yg(g,o+=4),d=yg(g,o+=4);for(o+=4,t=Math.pow(2,32)*c+d,Number.isSafeInteger(t)||(t=Number.MAX_SAFE_INTEGER,H.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=yg(g,o),s=yg(g,o+=4),o+=4;"\0"!==Wg(g.subarray(o,o+1));)C+=Wg(g.subarray(o,o+1)),o+=1;for(C+=Wg(g.subarray(o,o+1)),o+=1;"\0"!==Wg(g.subarray(o,o+1));)A+=Wg(g.subarray(o,o+1)),o+=1;A+=Wg(g.subarray(o,o+1)),o+=1}return{schemeIdUri:C,value:A,timeScale:i,presentationTime:t,presentationTimeDelta:e,eventDuration:l,id:s,payload:g.subarray(o,g.byteLength)}}(g);if(_C.test(A.schemeIdUri)){var i=W(A.presentationTime)?A.presentationTime/A.timeScale:I+A.presentationTimeDelta/A.timeScale,e=4294967295===A.eventDuration?Number.POSITIVE_INFINITY:A.eventDuration/A.timeScale;e<=.001&&(e=Number.POSITIVE_INFINITY);var t=A.payload;C.samples.push({data:t,len:t.byteLength,dts:i,pts:i,type:BI,duration:e})}}))}return C},I.demuxSampleAes=function(g,I,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},g}(),$C=null,gA=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],IA=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],CA=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],AA=[0,1,1,4];function iA(g,I,C,A,i){if(!(C+24>I.length)){var e=eA(I,C);if(e&&C+e.frameLength<=I.length){var t=A+i*(9e4*e.samplesPerFrame/e.sampleRate),l={unit:I.subarray(C,C+e.frameLength),pts:t,dts:t};return g.config=[],g.channelCount=e.channelCount,g.samplerate=e.sampleRate,g.samples.push(l),{sample:l,length:e.frameLength,missing:0}}}}function eA(g,I){var C=g[I+1]>>3&3,A=g[I+1]>>1&3,i=g[I+2]>>4&15,e=g[I+2]>>2&3;if(1!==C&&0!==i&&15!==i&&3!==e){var t=g[I+2]>>1&1,l=g[I+3]>>6,s=1e3*gA[14*(3===C?3-A:3===A?3:4)+i-1],o=IA[3*(3===C?0:2===C?1:2)+e],c=3===l?1:2,d=CA[C][A],a=AA[A],n=8*d*a,r=Math.floor(d*s/o+t)*a;if(null===$C){var m=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$C=m?parseInt(m[1]):0}return!!$C&&$C<=87&&2===A&&s>=224e3&&0===l&&(g[I+3]=128|g[I+3]),{sampleRate:o,channelCount:c,frameLength:r,samplesPerFrame:n}}}function tA(g,I){return!(255!==g[I]||224&~g[I+1]||!(6&g[I+1]))}function lA(g,I){return I+1g?(this.word<<=g,this.bitsAvailable-=g):(g-=this.bitsAvailable,g-=(I=g>>3)<<3,this.bytesAvailable-=I,this.loadWord(),this.word<<=g,this.bitsAvailable-=g)},I.readBits=function(g){var I=Math.min(this.bitsAvailable,g),C=this.word>>>32-I;if(g>32&&H.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=I,this.bitsAvailable>0)this.word<<=I;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(I=g-I)>0&&this.bitsAvailable?C<>>g)return this.word<<=g,this.bitsAvailable-=g,g;return this.loadWord(),g+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var g=this.skipLZ();return this.readBits(g+1)-1},I.readEG=function(){var g=this.readUEG();return 1&g?1+g>>>1:-1*(g>>>1)},I.readBoolean=function(){return 1===this.readBits(1)},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(g){for(var I=8,C=8,A=0;A=g.length)return void C();if(!(g[I].unit.length<32||(this.decryptAacSample(g,I,C),this.decrypter.isSync())))return}},I.getAvcEncryptedData=function(g){for(var I=16*Math.floor((g.length-48)/160)+16,C=new Int8Array(I),A=0,i=32;i=g.length)return void A();for(var i=g[I].units;!(C>=i.length);C++){var e=i[C];if(!(e.data.length<=48||1!==e.type&&5!==e.type||(this.decryptAvcSample(g,I,C,A,e),this.decrypter.isSync())))return}}},g}(),dA=188,aA=function(){function g(g,I,C){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=g,this.config=I,this.typeSupported=C}g.probe=function(I){var C=g.syncOffset(I);return C>0&&H.warn("MPEG2-TS detected but first sync word found @ offset "+C),-1!==C},g.syncOffset=function(g){for(var I=g.length,C=Math.min(940,g.length-dA)+1,A=0;A1&&(0===e&&t>2||l+dA>C))return e}A++}return-1},g.createTrack=function(g,I){return{container:"video"===g||"audio"===g?"video/mp2t":void 0,type:g,id:wg[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===g?I:void 0}};var I=g.prototype;return I.resetInitSegment=function(I,C,A,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",i),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=C,this.videoCodec=A,this._duration=i},I.resetTimeStamp=function(){},I.resetContiguity=function(){var g=this._audioTrack,I=this._avcTrack,C=this._id3Track;g&&(g.pesData=null),I&&(I.pesData=null),C&&(C.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},I.demux=function(I,C,A,i){var e;void 0===A&&(A=!1),void 0===i&&(i=!1),A||(this.sampleAes=null);var t=this._avcTrack,l=this._audioTrack,s=this._id3Track,o=this._txtTrack,c=t.pid,d=t.pesData,a=l.pid,n=s.pid,r=l.pesData,m=s.pesData,h=null,Z=this.pmtParsed,b=this._pmtId,G=I.length;if(this.remainderData&&(G=(I=fg(this.remainderData,I)).length,this.remainderData=null),G>4>1){if((Y=w+5+I[w+4])===w+dA)continue}else Y=w+4;switch(X){case c:W&&(d&&(e=ZA(d))&&this.parseAVCPES(t,o,e,!1),d={data:[],size:0}),d&&(d.data.push(I.subarray(Y,w+dA)),d.size+=w+dA-Y);break;case a:if(W){if(r&&(e=ZA(r)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,e);break;case"mp3":this.parseMPEGPES(l,e)}r={data:[],size:0}}r&&(r.data.push(I.subarray(Y,w+dA)),r.size+=w+dA-Y);break;case n:W&&(m&&(e=ZA(m))&&this.parseID3PES(s,e),m={data:[],size:0}),m&&(m.data.push(I.subarray(Y,w+dA)),m.size+=w+dA-Y);break;case 0:W&&(Y+=I[Y]+1),b=this._pmtId=mA(I,Y);break;case b:W&&(Y+=I[Y]+1);var R=hA(I,Y,this.typeSupported,A);(c=R.avc)>0&&(t.pid=c),(a=R.audio)>0&&(l.pid=a,l.segmentCodec=R.segmentCodec),(n=R.id3)>0&&(s.pid=n),null===h||Z||(H.warn("MPEG-TS PMT found at "+w+" after unknown PID '"+h+"'. Backtracking to sync byte @"+u+" to parse all TS packets."),h=null,w=u-188),Z=this.pmtParsed=!0;break;case 17:case 8191:break;default:h=X}}else p++;if(p>0){var N=new Error("Found "+p+" TS packet/s that do not start with 0x47");this.observer.emit(B.ERROR,B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_PARSING_ERROR,fatal:!1,error:N,reason:N.message})}t.pesData=d,l.pesData=r,s.pesData=m;var K={audioTrack:l,videoTrack:t,id3Track:s,textTrack:o};return i&&this.extractRemainingSamples(K),K},I.flush=function(){var g,I=this.remainderData;return this.remainderData=null,g=I?this.demux(I,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},I.extractRemainingSamples=function(g){var I,C=g.audioTrack,A=g.videoTrack,i=g.id3Track,e=g.textTrack,t=A.pesData,l=C.pesData,s=i.pesData;if(t&&(I=ZA(t))?(this.parseAVCPES(A,e,I,!0),A.pesData=null):A.pesData=t,l&&(I=ZA(l))){switch(C.segmentCodec){case"aac":this.parseAACPES(C,I);break;case"mp3":this.parseMPEGPES(C,I)}C.pesData=null}else null!=l&&l.size&&H.log("last AAC PES packet truncated,might overlap between fragments"),C.pesData=l;s&&(I=ZA(s))?(this.parseID3PES(i,I),i.pesData=null):i.pesData=s},I.demuxSampleAes=function(g,I,C){var A=this.demux(g,C,!0,!this.config.progressive),i=this.sampleAes=new cA(this.observer,this.config,I);return this.decrypt(A,i)},I.decrypt=function(g,I){return new Promise((function(C){var A=g.audioTrack,i=g.videoTrack;A.samples&&"aac"===A.segmentCodec?I.decryptAacSamples(A.samples,0,(function(){i.samples?I.decryptAvcSamples(i.samples,0,0,(function(){C(g)})):C(g)})):i.samples&&I.decryptAvcSamples(i.samples,0,0,(function(){C(g)}))}))},I.destroy=function(){this._duration=0},I.parseAVCPES=function(g,I,C,A){var i,e=this,t=this.parseAVCNALu(g,C.data),l=this.avcSample,s=!1;C.data=null,l&&t.length&&!g.audFound&&(bA(l,g),l=this.avcSample=nA(!1,C.pts,C.dts,"")),t.forEach((function(A){var t;switch(A.type){case 1:var o=!1;i=!0;var c,d=A.data;if(s&&d.length>4){var a=new oA(d).readSliceType();2!==a&&4!==a&&7!==a&&9!==a||(o=!0)}o&&null!=(c=l)&&c.frame&&!l.key&&(bA(l,g),l=e.avcSample=null),l||(l=e.avcSample=nA(!0,C.pts,C.dts,"")),l.frame=!0,l.key=o;break;case 5:i=!0,null!=(t=l)&&t.frame&&!l.key&&(bA(l,g),l=e.avcSample=null),l||(l=e.avcSample=nA(!0,C.pts,C.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0,Sg(A.data,1,C.pts,I.samples);break;case 7:if(i=!0,s=!0,!g.sps){var n=A.data,r=new oA(n).readSPS();g.width=r.width,g.height=r.height,g.pixelRatio=r.pixelRatio,g.sps=[n],g.duration=e._duration;for(var m=n.subarray(1,4),h="avc1.",Z=0;Z<3;Z++){var b=m[Z].toString(16);b.length<2&&(b="0"+b),h+=b}g.codec=h}break;case 8:i=!0,g.pps||(g.pps=[A.data]);break;case 9:i=!1,g.audFound=!0,l&&bA(l,g),l=e.avcSample=nA(!1,C.pts,C.dts,"");break;case 12:i=!0;break;default:i=!1,l&&(l.debug+="unknown NAL "+A.type+" ")}l&&i&&l.units.push(A)})),A&&l&&(bA(l,g),this.avcSample=null)},I.getLastNalUnit=function(g){var I,C,A=this.avcSample;if(A&&0!==A.units.length||(A=g[g.length-1]),null!=(I=A)&&I.units){var i=A.units;C=i[i.length-1]}return C},I.parseAVCNALu=function(g,I){var C,A,i=I.byteLength,e=g.naluState||0,t=e,l=[],s=0,o=-1,c=0;for(-1===e&&(o=0,c=31&I[0],e=0,s=1);s=0){var d={data:I.subarray(o,s-e-1),type:c};l.push(d)}else{var a=this.getLastNalUnit(g.samples);if(a&&(t&&s<=4-t&&a.state&&(a.data=a.data.subarray(0,a.data.byteLength-t)),(A=s-e-1)>0)){var n=new Uint8Array(a.data.byteLength+A);n.set(a.data,0),n.set(I.subarray(0,A),a.data.byteLength),a.data=n,a.state=0}}s=0&&e>=0){var r={data:I.subarray(o,i),type:c,state:e};l.push(r)}if(0===l.length){var m=this.getLastNalUnit(g.samples);if(m){var h=new Uint8Array(m.data.byteLength+I.byteLength);h.set(m.data,0),h.set(I,m.data.byteLength),m.data=h}}return g.naluState=e,l},I.parseAACPES=function(g,I){var C,A,i,e=0,t=this.aacOverFlow,l=I.data;if(t){this.aacOverFlow=null;var s=t.missing,o=t.sample.unit.byteLength;if(-1===s){var c=new Uint8Array(o+l.byteLength);c.set(t.sample.unit,0),c.set(l,o),l=c}else{var d=o-s;t.sample.unit.set(l.subarray(0,s),d),g.samples.push(t.sample),e=t.missing}}for(C=e,A=l.length;C1;){var s=new Uint8Array(l[0].length+l[1].length);s.set(l[0]),s.set(l[1],l[0].length),l[0]=s,l.splice(1,1)}if(1===((I=l[0])[0]<<16)+(I[1]<<8)+I[2]){if((C=(I[4]<<8)+I[5])&&C>g.size-6)return null;var o=I[7];192&o&&(i=536870912*(14&I[9])+4194304*(255&I[10])+16384*(254&I[11])+128*(255&I[12])+(254&I[13])/2,64&o?i-(e=536870912*(14&I[14])+4194304*(255&I[15])+16384*(254&I[16])+128*(255&I[17])+(254&I[18])/2)>54e5&&(H.warn(Math.round((i-e)/9e4)+"s delta between PTS and DTS, align them"),i=e):e=i);var c=(A=I[8])+9;if(g.size<=c)return null;g.size-=c;for(var d=new Uint8Array(g.size),a=0,n=l.length;ar){c-=r;continue}I=I.subarray(c),r-=c,c=0}d.set(I,t),t+=r}return C&&(C-=A+3),{data:d,pts:i,dts:e,len:C}}return null}function bA(g,I){if(g.units.length&&g.frame){if(void 0===g.pts){var C=I.samples,A=C.length;if(!A)return void I.dropped++;var i=C[A-1];g.pts=i.pts,g.dts=i.dts}I.samples.push(g)}g.debug.length&&H.log(g.pts+"/"+g.dts+":"+g.debug)}var GA=function(g){function I(){return g.apply(this,arguments)||this}s(I,g);var C=I.prototype;return C.resetInitSegment=function(I,C,A,i){g.prototype.resetInitSegment.call(this,I,C,A,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:C,duration:i,inputTimeScale:9e4,dropped:0}},I.probe=function(g){if(!g)return!1;for(var I=(lg(g,0)||[]).length,C=g.length;I1?C-1:0),i=1;i>24&255,l[1]=I>>16&255,l[2]=I>>8&255,l[3]=255&I,l.set(g,4),e=0,I=8;e>24&255,I>>16&255,I>>8&255,255&I,A>>24,A>>16&255,A>>8&255,255&A,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},g.mdia=function(I){return g.box(g.types.mdia,g.mdhd(I.timescale,I.duration),g.hdlr(I.type),g.minf(I))},g.mfhd=function(I){return g.box(g.types.mfhd,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,255&I]))},g.minf=function(I){return"audio"===I.type?g.box(g.types.minf,g.box(g.types.smhd,g.SMHD),g.DINF,g.stbl(I)):g.box(g.types.minf,g.box(g.types.vmhd,g.VMHD),g.DINF,g.stbl(I))},g.moof=function(I,C,A){return g.box(g.types.moof,g.mfhd(I),g.traf(A,C))},g.moov=function(I){for(var C=I.length,A=[];C--;)A[C]=g.trak(I[C]);return g.box.apply(null,[g.types.moov,g.mvhd(I[0].timescale,I[0].duration)].concat(A).concat(g.mvex(I)))},g.mvex=function(I){for(var C=I.length,A=[];C--;)A[C]=g.trex(I[C]);return g.box.apply(null,[g.types.mvex].concat(A))},g.mvhd=function(I,C){C*=I;var A=Math.floor(C/(pA+1)),i=Math.floor(C%(pA+1)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,255&I,A>>24,A>>16&255,A>>8&255,255&A,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return g.box(g.types.mvhd,e)},g.sdtp=function(I){var C,A,i=I.samples||[],e=new Uint8Array(4+i.length);for(C=0;C>>8&255),e.push(255&i),e=e.concat(Array.prototype.slice.call(A));for(C=0;C>>8&255),t.push(255&i),t=t.concat(Array.prototype.slice.call(A));var l=g.box(g.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|I.sps.length].concat(e).concat([I.pps.length]).concat(t))),s=I.width,o=I.height,c=I.pixelRatio[0],d=I.pixelRatio[1];return g.box(g.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,s>>8&255,255&s,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,g.box(g.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),g.box(g.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},g.esds=function(g){var I=g.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(g.config).concat([6,1,2]))},g.mp4a=function(I){var C=I.samplerate;return g.box(g.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,I.channelCount,0,16,0,0,0,0,C>>8&255,255&C,0,0]),g.box(g.types.esds,g.esds(I)))},g.mp3=function(I){var C=I.samplerate;return g.box(g.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,I.channelCount,0,16,0,0,0,0,C>>8&255,255&C,0,0]))},g.stsd=function(I){return"audio"===I.type?"mp3"===I.segmentCodec&&"mp3"===I.codec?g.box(g.types.stsd,g.STSD,g.mp3(I)):g.box(g.types.stsd,g.STSD,g.mp4a(I)):g.box(g.types.stsd,g.STSD,g.avc1(I))},g.tkhd=function(I){var C=I.id,A=I.duration*I.timescale,i=I.width,e=I.height,t=Math.floor(A/(pA+1)),l=Math.floor(A%(pA+1));return g.box(g.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,255&C,0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))},g.traf=function(I,C){var A=g.sdtp(I),i=I.id,e=Math.floor(C/(pA+1)),t=Math.floor(C%(pA+1));return g.box(g.types.traf,g.box(g.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),g.box(g.types.tfdt,new Uint8Array([1,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,t>>24,t>>16&255,t>>8&255,255&t])),g.trun(I,A.length+16+20+8+16+8+8),A)},g.trak=function(I){return I.duration=I.duration||4294967295,g.box(g.types.trak,g.tkhd(I),g.mdia(I))},g.trex=function(I){var C=I.id;return g.box(g.types.trex,new Uint8Array([0,0,0,0,C>>24,C>>16&255,C>>8&255,255&C,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},g.trun=function(I,C){var A,i,e,t,l,s,o=I.samples||[],c=o.length,d=12+16*c,a=new Uint8Array(d);for(C+=8+d,a.set(["video"===I.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,C>>>24&255,C>>>16&255,C>>>8&255,255&C],0),A=0;A>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.paddingValue<<1|l.isNonSync,61440&l.degradPrio,15&l.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*A);return g.box(g.types.trun,a)},g.initSegment=function(I){g.types||g.init();var C=g.moov(I),A=new Uint8Array(g.FTYP.byteLength+C.byteLength);return A.set(g.FTYP),A.set(C,g.FTYP.byteLength),A},g}();function WA(g,I,C,A){void 0===C&&(C=1),void 0===A&&(A=!1);var i=g*I*C;return A?Math.round(i):i}function BA(g,I){return WA(g,1e3,1/9e4,I)}wA.types=void 0,wA.HDLR_TYPES=void 0,wA.STTS=void 0,wA.STSC=void 0,wA.STCO=void 0,wA.STSZ=void 0,wA.VMHD=void 0,wA.SMHD=void 0,wA.STSD=void 0,wA.FTYP=void 0,wA.DINF=void 0;var yA=null,VA=null,XA=function(){function g(g,I,C,A){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=g,this.config=I,this.typeSupported=C,this.ISGenerated=!1,null===yA){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);yA=i?parseInt(i[1]):0}if(null===VA){var e=navigator.userAgent.match(/Safari\/(\d+)/i);VA=e?parseInt(e[1]):0}}var I=g.prototype;return I.destroy=function(){},I.resetTimeStamp=function(g){H.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=g},I.resetNextTimestamp=function(){H.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},I.resetInitSegment=function(){H.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},I.getVideoStartPts=function(g){var I=!1,C=g.reduce((function(g,C){var A=C.pts-g;return A<-4294967296?(I=!0,YA(g,C.pts)):A>0?g:C.pts}),g[0].pts);return I&&H.debug("PTS rollover detected"),C},I.remux=function(g,I,C,A,i,e,t,l){var s,o,c,d,a,n,r=i,m=i,h=g.pid>-1,Z=I.pid>-1,b=I.samples.length,G=g.samples.length>0,u=t&&b>0||b>1;if((!h||G)&&(!Z||u)||this.ISGenerated||t){this.ISGenerated||(c=this.generateIS(g,I,i,e));var p,w=this.isVideoContiguous,W=-1;if(u&&(W=function(g){for(var I=0;I0){H.warn("[mp4-remuxer]: Dropped "+W+" out of "+b+" video samples due to a missing keyframe");var B=this.getVideoStartPts(I.samples);I.samples=I.samples.slice(W),I.dropped+=W,p=m+=(I.samples[0].pts-B)/I.inputTimeScale}else-1===W&&(H.warn("[mp4-remuxer]: No keyframe found out of "+b+" video samples"),n=!1);if(this.ISGenerated){if(G&&u){var y=this.getVideoStartPts(I.samples),V=(YA(g.samples[0].pts,y)-y)/I.inputTimeScale;r+=Math.max(0,V),m+=Math.max(0,-V)}if(G){if(g.samplerate||(H.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(g,I,i,e)),o=this.remuxAudio(g,r,this.isAudioContiguous,e,Z||u||l===rI?m:void 0),u){var X=o?o.endPTS-o.startPTS:0;I.inputTimeScale||(H.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(g,I,i,e)),s=this.remuxVideo(I,m,w,X)}}else u&&(s=this.remuxVideo(I,m,w,0));s&&(s.firstKeyFrame=W,s.independent=-1!==W,s.firstKeyFramePTS=p)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(C.samples.length&&(a=RA(C,i,this._initPTS,this._initDTS)),A.samples.length&&(d=NA(A,i,this._initPTS))),{audio:o,video:s,initSegment:c,independent:n,text:d,id3:a}},I.generateIS=function(g,I,C,A){var i,e,t,l=g.samples,s=I.samples,o=this.typeSupported,c={},d=this._initPTS,a=!d||A,n="audio/mp4";if(a&&(i=e=1/0),g.config&&l.length&&(g.timescale=g.samplerate,"mp3"===g.segmentCodec&&(o.mpeg?(n="audio/mpeg",g.codec=""):o.mp3&&(g.codec="mp3")),c.audio={id:"audio",container:n,codec:g.codec,initSegment:"mp3"===g.segmentCodec&&o.mpeg?new Uint8Array(0):wA.initSegment([g]),metadata:{channelCount:g.channelCount}},a&&(t=g.inputTimeScale,d&&t===d.timescale?a=!1:i=e=l[0].pts-Math.round(t*C))),I.sps&&I.pps&&s.length&&(I.timescale=I.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:I.codec,initSegment:wA.initSegment([I]),metadata:{width:I.width,height:I.height}},a))if(t=I.inputTimeScale,d&&t===d.timescale)a=!1;else{var r=this.getVideoStartPts(s),m=Math.round(t*C);e=Math.min(e,YA(s[0].dts,r)-m),i=Math.min(i,r-m)}if(Object.keys(c).length)return this.ISGenerated=!0,a?(this._initPTS={baseTime:i,timescale:t},this._initDTS={baseTime:e,timescale:t}):i=t=void 0,{tracks:c,initPTS:i,timescale:t}},I.remuxVideo=function(g,I,C,A){var i,e,t=g.inputTimeScale,s=g.samples,o=[],c=s.length,d=this._initPTS,a=this.nextAvcDts,n=8,r=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,Z=!1;C&&null!==a||(a=I*t-(s[0].pts-YA(s[0].dts,s[0].pts)));for(var b=d.baseTime*t/d.timescale,G=0;G0?G-1:G].dts&&(Z=!0)}Z&&s.sort((function(g,I){var C=g.dts-I.dts,A=g.pts-I.pts;return C||A})),i=s[0].dts;var p=s[s.length-1].dts-i,w=p?Math.round(p/(c-1)):r||g.inputTimeScale/30;if(C){var W=i-a,X=W>w,Y=W<-1;if((X||Y)&&(X?H.warn("AVC: "+BA(W,!0)+" ms ("+W+"dts) hole between fragments detected, filling it"):H.warn("AVC: "+BA(-W,!0)+" ms ("+W+"dts) overlapping between fragments detected"),!Y||a>=s[0].pts)){i=a;var R=s[0].pts-W;s[0].dts=i,s[0].pts=R,H.log("Video: First PTS/DTS adjusted: "+BA(R,!0)+"/"+BA(i,!0)+", delta: "+BA(W,!0)+" ms")}}i=Math.max(0,i);for(var N=0,K=0,f=0;f0?O.dts-s[Q-1].dts:w;if(Cg=Q>0?O.pts-s[Q-1].pts:w,Ag.stretchShortVideoTrack&&null!==this.nextAudioPts){var eg=Math.floor(Ag.maxBufferHole*t),tg=(A?m+A*t:this.nextAudioPts)-O.pts;tg>eg?((r=tg-ig)<0?r=ig:z=!0,H.log("[mp4-remuxer]: It is approximately "+tg/90+" ms to the next segment; using duration "+r/90+" ms for the last video frame.")):r=ig}else r=ig}var lg=Math.round(O.pts-O.dts);T=Math.min(T,r),U=Math.max(U,r),x=Math.min(x,Cg),j=Math.max(j,Cg),o.push(new KA(O.key,r,P,lg))}if(o.length)if(yA){if(yA<70){var sg=o[0].flags;sg.dependsOn=2,sg.isNonSync=0}}else if(VA&&j-x0&&(A&&Math.abs(Z-h)<9e3||Math.abs(YA(r[0].pts-b,Z)-h)<20*o),r.forEach((function(g){g.pts=YA(g.pts-b,Z)})),!C||h<0){if(!(r=r.filter((function(g){return g.pts>=0}))).length)return;h=0===i?0:A&&!n?Math.max(0,Z):r[0].pts}if("aac"===g.segmentCodec)for(var G=this.config.maxAudioFramesDrift,u=0,p=h;u=G*o&&Y<1e4&&n){var R=Math.round(X/o);(p=W-R*o)<0&&(R--,p+=o),0===u&&(this.nextAudioPts=h=p),H.warn("[mp4-remuxer]: Injecting "+R+" audio frame @ "+(p/e).toFixed(3)+"s due to "+Math.round(1e3*X/e)+" ms gap.");for(var N=0;N0))return;J+=m;try{F=new Uint8Array(J)}catch(_){return void this.observer.emit(B.ERROR,B.ERROR,{type:y.MUX_ERROR,details:V.REMUX_ALLOC_ERROR,fatal:!1,error:_,bytes:J,reason:"fail allocating audio mdat "+J})}d||(new DataView(F.buffer).setUint32(0,J),F.set(wA.types.mdat,4))}F.set(z,m);var x=z.byteLength;m+=x,a.push(new KA(!0,s,x,0)),S=T}var U=a.length;if(U){var j=a[a.length-1];this.nextAudioPts=h=S+t*j.duration;var Q=d?new Uint8Array(0):wA.moof(g.sequenceNumber++,M/t,l({},g,{samples:a}));g.samples=[];var O=M/e,E=h/e,P={data1:Q,data2:F,startPTS:O,endPTS:E,startDTS:O,endDTS:E,type:"audio",hasAudio:!0,hasVideo:!1,nb:U};return this.isAudioContiguous=!0,P}},I.remuxEmptyAudio=function(g,I,C,A){var i=g.inputTimeScale,e=i/(g.samplerate?g.samplerate:i),t=this.nextAudioPts,l=this._initDTS,s=9e4*l.baseTime/l.timescale,o=(null!==t?t:A.startDTS*i)+s,c=A.endDTS*i+s,d=1024*e,a=Math.ceil((c-o)/d),n=uA.getSilentFrame(g.manifestCodec||g.codec,g.channelCount);if(H.warn("[mp4-remuxer]: remux empty Audio"),n){for(var r=[],m=0;m4294967296;)g+=C;return g}function RA(g,I,C,A){var i=g.samples.length;if(i){for(var e=g.inputTimeScale,t=0;t0;i||(A=Yg(I,["encv"])),A.forEach((function(g){Yg(i?g.subarray(28):g.subarray(78),["sinf"]).forEach((function(g){var I=Hg(g);if(I){var A=I.subarray(8,24);A.some((function(g){return 0!==g}))||(H.log("[eme] Patching keyId in 'enc"+(i?"a":"v")+">sinf>>tenc' box: "+Gg(A)+" -> "+Gg(C)),I.set(C,8))}}))}))})),g}(g,A)),this.emitInitSegment=!0},I.generateInitSegment=function(g){var I=this.audioCodec,C=this.videoCodec;if(null==g||!g.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var A=this.initData=Ng(g);I||(I=MA(A.audio,k)),C||(C=MA(A.video,D));var i={};A.audio&&A.video?i.audiovideo={container:"video/mp4",codec:I+","+C,initSegment:g,id:"main"}:A.audio?i.audio={container:"audio/mp4",codec:I,initSegment:g,id:"audio"}:A.video?i.video={container:"video/mp4",codec:C,initSegment:g,id:"main"}:H.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i},I.remux=function(g,I,C,A,i,e){var t,l,s=this.initPTS,o=this.lastEndTime,c={audio:void 0,video:void 0,text:A,id3:C,initSegment:void 0};W(o)||(o=this.lastEndTime=i||0);var d=I.samples;if(null==d||!d.length)return c;var a={initPTS:void 0,timescale:1},n=this.initData;if(null!=(t=n)&&t.length||(this.generateInitSegment(d),n=this.initData),null==(l=n)||!l.length)return H.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(a.tracks=this.initTracks,this.emitInitSegment=!1);var r,m=function(g,I){for(var C=0,A=0,i=0,e=Yg(g,["moof","traf"]),t=0;ti}(s,Z,i,m)||a.timescale!==s.timescale&&e)&&(a.initPTS=Z-i,s&&1===s.timescale&&H.warn("Adjusting initPTS by "+(a.initPTS-s.baseTime)),this.initPTS=s={baseTime:a.initPTS,timescale:1});var b=g?Z-s.baseTime/s.timescale:o,G=b+m;!function(g,I,C){Yg(I,["moof","traf"]).forEach((function(I){Yg(I,["tfhd"]).forEach((function(A){var i=yg(A,4),e=g[i];if(e){var t=e.timescale||9e4;Yg(I,["tfdt"]).forEach((function(g){var I=g[0],A=yg(g,4);if(0===I)A-=C*t,Xg(g,4,A=Math.max(A,0));else{A*=Math.pow(2,32),A+=yg(g,8),A-=C*t,A=Math.max(A,0);var i=Math.floor(A/(ug+1)),e=Math.floor(A%(ug+1));Xg(g,4,i),Xg(g,8,e)}}))}}))}))}(n,d,s.baseTime/s.timescale),m>0?this.lastEndTime=G:(H.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!n.audio,p=!!n.video,w="";u&&(w+="audio"),p&&(w+="video");var B={data1:d,startPTS:b,startDTS:b,endPTS:G,endDTS:G,type:w,hasAudio:u,hasVideo:p,nb:1,dropped:0};return c.audio="audio"===B.type?B:void 0,c.video="audio"!==B.type?B:void 0,c.initSegment=a,c.id3=RA(C,i,s,s),A.samples.length&&(c.text=NA(A,i,s)),c},g}();function MA(g,I){var C=null==g?void 0:g.codec;return C&&C.length>4?C:"hvc1"===C||"hev1"===C?"hvc1.1.6.L120.90":"av01"===C?"av01.0.04M.08":"avc1"===C||I===D?"avc1.42e01e":"mp4a.40.5"}try{HA=self.performance.now.bind(self.performance)}catch(Xe){H.debug("Unable to use Performance API on this environment"),HA="undefined"!=typeof self&&self.Date.now}var SA=[{demux:qC,remux:FA},{demux:aA,remux:XA},{demux:PC,remux:XA},{demux:GA,remux:XA}],JA=function(){function g(g,I,C,A,i){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=g,this.typeSupported=I,this.config=C,this.vendor=A,this.id=i}var I=g.prototype;return I.configure=function(g){this.transmuxConfig=g,this.decrypter&&this.decrypter.reset()},I.push=function(g,I,C,A){var i=this,e=C.transmuxing;e.executeStart=HA();var t=new Uint8Array(g),l=this.currentTransmuxState,s=this.transmuxConfig;A&&(this.currentTransmuxState=A);var o,c,d=A||l,a=d.contiguous,n=d.discontinuity,r=d.trackSwitch,m=d.accurateTimeOffset,h=d.timeOffset,Z=d.initSegmentChange,b=s.audioCodec,G=s.videoCodec,u=s.defaultInitPts,p=s.duration,w=s.initSegmentData,W=(o=I,c=null,t.byteLength>0&&null!=o&&null!=o.key&&null!==o.iv&&null!=o.method&&(c=o),c);if(W&&"AES-128"===W.method){var X=this.getDecrypter();if(!X.isSync())return this.decryptionPromise=X.webCryptoDecrypt(t,W.key.buffer,W.iv.buffer).then((function(g){var I=i.push(g,null,C);return i.decryptionPromise=null,I})),this.decryptionPromise;var Y=X.softwareDecrypt(t,W.key.buffer,W.iv.buffer);if(C.part>-1&&(Y=X.flush()),!Y)return e.executeEnd=HA(),kA(C);t=new Uint8Array(Y)}var R=this.needsProbing(n,r);if(R){var N=this.configureTransmuxer(t);if(N)return H.warn("[transmuxer] "+N.message),this.observer.emit(B.ERROR,B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_PARSING_ERROR,fatal:!1,error:N,reason:N.message}),e.executeEnd=HA(),kA(C)}(n||r||Z||R)&&this.resetInitSegment(w,b,G,p,I),(n||Z||R)&&this.resetInitialTimestamp(u),a||this.resetContiguity();var K=this.transmux(t,W,h,m,C),f=this.currentTransmuxState;return f.contiguous=!0,f.discontinuity=!1,f.trackSwitch=!1,e.executeEnd=HA(),K},I.flush=function(g){var I=this,C=g.transmuxing;C.executeStart=HA();var A=this.decrypter,i=this.currentTransmuxState,e=this.decryptionPromise;if(e)return e.then((function(){return I.flush(g)}));var t=[],l=i.timeOffset;if(A){var s=A.flush();s&&t.push(this.push(s,null,g))}var o=this.demuxer,c=this.remuxer;if(!o||!c)return C.executeEnd=HA(),[kA(g)];var d=o.flush(l);return DA(d)?d.then((function(C){return I.flushRemux(t,C,g),t})):(this.flushRemux(t,d,g),t)},I.flushRemux=function(g,I,C){var A=I.audioTrack,i=I.videoTrack,e=I.id3Track,t=I.textTrack,l=this.currentTransmuxState,s=l.accurateTimeOffset,o=l.timeOffset;H.log("[transmuxer.ts]: Flushed fragment "+C.sn+(C.part>-1?" p: "+C.part:"")+" of level "+C.level);var c=this.remuxer.remux(A,i,e,t,o,s,!0,this.id);g.push({remuxResult:c,chunkMeta:C}),C.transmuxing.executeEnd=HA()},I.resetInitialTimestamp=function(g){var I=this.demuxer,C=this.remuxer;I&&C&&(I.resetTimeStamp(g),C.resetTimeStamp(g))},I.resetContiguity=function(){var g=this.demuxer,I=this.remuxer;g&&I&&(g.resetContiguity(),I.resetNextTimestamp())},I.resetInitSegment=function(g,I,C,A,i){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetInitSegment(g,I,C,A),t.resetInitSegment(g,I,C,i))},I.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},I.transmux=function(g,I,C,A,i){return I&&"SAMPLE-AES"===I.method?this.transmuxSampleAes(g,I,C,A,i):this.transmuxUnencrypted(g,C,A,i)},I.transmuxUnencrypted=function(g,I,C,A){var i=this.demuxer.demux(g,I,!1,!this.config.progressive),e=i.audioTrack,t=i.videoTrack,l=i.id3Track,s=i.textTrack;return{remuxResult:this.remuxer.remux(e,t,l,s,I,C,!1,this.id),chunkMeta:A}},I.transmuxSampleAes=function(g,I,C,A,i){var e=this;return this.demuxer.demuxSampleAes(g,I,C).then((function(g){return{remuxResult:e.remuxer.remux(g.audioTrack,g.videoTrack,g.id3Track,g.textTrack,C,A,!1,e.id),chunkMeta:i}}))},I.configureTransmuxer=function(g){for(var I,C=this.config,A=this.observer,i=this.typeSupported,e=this.vendor,t=0,l=SA.length;t1&&s.id===(null==h?void 0:h.stats.chunkCount),w=!b&&(1===G||0===G&&(1===u||p&&u<=0)),W=self.performance.now();(b||G||0===i.stats.parsing.start)&&(i.stats.parsing.start=W),!e||!u&&w||(e.stats.parsing.start=W);var B=!(h&&(null==(c=i.initSegment)?void 0:c.url)===(null==(d=h.initSegment)?void 0:d.url)),y=new LA(Z,w,l,b,r,B);if(!w||Z||B){H.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+s.sn+" p: "+s.part+" level: "+s.level+" id: "+s.id+"\n discontinuity: "+Z+"\n trackSwitch: "+b+"\n contiguous: "+w+"\n accurateTimeOffset: "+l+"\n timeOffset: "+r+"\n initSegmentChange: "+B);var V=new vA(C,A,I,t,o);this.configureTransmuxer(V)}if(this.frag=i,this.part=e,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:g,decryptdata:m,chunkMeta:s,state:y},g instanceof ArrayBuffer?[g]:[]);else if(n){var X=n.push(g,m,s,y);DA(X)?(n.async=!0,X.then((function(g){a.handleTransmuxComplete(g)})).catch((function(g){a.transmuxerError(g,s,"transmuxer-interface push error")}))):(n.async=!1,this.handleTransmuxComplete(X))}},C.flush=function(g){var I=this;g.transmuxing.start=self.performance.now();var C=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:g});else if(C){var A=C.flush(g);DA(A)||C.async?(DA(A)||(A=Promise.resolve(A)),A.then((function(C){I.handleFlushResult(C,g)})).catch((function(C){I.transmuxerError(C,g,"transmuxer-interface flush error")}))):this.handleFlushResult(A,g)}},C.transmuxerError=function(g,I,C){this.hls&&(this.error=g,this.hls.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_PARSING_ERROR,chunkMeta:I,fatal:!1,error:g,err:g,reason:C}))},C.handleFlushResult=function(g,I){var C=this;g.forEach((function(g){C.handleTransmuxComplete(g)})),this.onFlush(I)},C.onWorkerMessage=function(g){var I=g.data,C=this.hls;switch(I.event){case"init":var A,i=null==(A=this.workerContext)?void 0:A.objectURL;i&&self.URL.revokeObjectURL(i);break;case"transmuxComplete":this.handleTransmuxComplete(I.data);break;case"flush":this.onFlush(I.data);break;case"workerLog":H[I.data.logType]&&H[I.data.logType](I.data.message);break;default:I.data=I.data||{},I.data.frag=this.frag,I.data.id=this.id,C.trigger(I.event,I.data)}},C.configureTransmuxer=function(g){var I=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:g}):I&&I.configure(g)},C.handleTransmuxComplete=function(g){g.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(g)},g}(),EA=function(){function g(g,I,C,A){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=g,this.media=I,this.fragmentTracker=C,this.hls=A}var I=g.prototype;return I.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},I.poll=function(g,I){var C=this.config,A=this.media,i=this.stalled;if(null!==A){var e=A.currentTime,t=A.seeking,l=this.seeking&&!t,s=!this.seeking&&t;if(this.seeking=t,e===g){if(s||l)this.stalled=null;else if(!(A.paused&&!t||A.ended||0===A.playbackRate)&&mC.getBuffered(A).length){var o=mC.bufferInfo(A,e,0),c=o.len>0,d=o.nextStart||0;if(c||d){if(t){var a=o.len>2,n=!d||I&&I.start<=e||d-e>2&&!this.fragmentTracker.getPartialFragment(e);if(a||n)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var r,m=Math.max(d,o.start||0)-e,h=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,Z=(null==h||null==(r=h.details)?void 0:r.live)?2*h.details.targetduration:2,b=this.fragmentTracker.getPartialFragment(e);if(m>0&&(m<=Z||b))return void this._trySkipBufferHole(b)}var G=self.performance.now();if(null!==i){var u=G-i;if(t||!(u>=250)||(this._reportStall(o),this.media)){var p=mC.bufferInfo(A,e,C.maxBufferHole);this._tryFixBufferStall(p,u)}}else this.stalled=G}}}else if(this.moved=!0,null!==i){if(this.stallReported){var w=self.performance.now()-i;H.warn("playback not stuck anymore @"+e+", after "+Math.round(w)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},I._tryFixBufferStall=function(g,I){var C=this.config,A=this.fragmentTracker,i=this.media;if(null!==i){var e=i.currentTime,t=A.getPartialFragment(e);if(t&&(this._trySkipBufferHole(t)||!this.media))return;(g.len>C.maxBufferHole||g.nextStart&&g.nextStart-e1e3*C.highBufferWatchdogPeriod&&(H.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},I._reportStall=function(g){var I=this.hls,C=this.media;if(!this.stallReported&&C){this.stallReported=!0;var A=new Error("Playback stalling at @"+C.currentTime+" due to low buffer ("+JSON.stringify(g)+")");H.warn(A.message),I.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.BUFFER_STALLED_ERROR,fatal:!1,error:A,buffer:g.len})}},I._trySkipBufferHole=function(g){var I=this.config,C=this.hls,A=this.media;if(null===A)return 0;var i=A.currentTime,e=mC.bufferInfo(A,i,0),t=i0&&e.len<1&&A.readyState<3,o=t-i;if(o>0&&(l||s)){if(o>I.maxBufferHole){var c=this.fragmentTracker,d=!1;if(0===i){var a=c.getAppendedFrag(0,nI);a&&t1?(A=0,this.bitrateTest=!0):A=C.nextAutoLevel),this.level=C.nextLoadLevel=A,this.loadedmetadata=!1}I>0&&-1===g&&(this.log("Override startPosition with lastCurrentTime @"+I.toFixed(3)),g=I),this.state=VC,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=g,this.tick()}else this._forceStartLoad=!0,this.state=yC},C.stopLoad=function(){this._forceStartLoad=!1,g.prototype.stopLoad.call(this)},C.doTick=function(){switch(this.state){case SC:var g,I=this.levels,C=this.level,A=null==I||null==(g=I[C])?void 0:g.details;if(A&&(!A.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(A))break;this.state=VC;break}if(this.hls.nextLoadLevel!==this.level){this.state=VC;break}break;case RC:var i,e=self.performance.now(),t=this.retryDate;(!t||e>=t||null!=(i=this.media)&&i.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=VC)}this.state===VC&&this.doTickIdle(),this.onTickEnd()},C.onTickEnd=function(){g.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},C.doTickIdle=function(){var g=this.hls,I=this.levelLastLoaded,C=this.levels,A=this.media,i=g.config,e=g.nextLoadLevel;if(null!==I&&(A||!this.startFragRequested&&i.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=C&&C[e]){var t=C[e],l=this.getMainFwdBufferInfo();if(null!==l){var s=this.getLevelDetails();if(s&&this._streamEnded(l,s)){var o={};return this.altAudio&&(o.type="video"),this.hls.trigger(B.BUFFER_EOS,o),void(this.state=fC)}g.loadLevel!==e&&-1===g.manualLevel&&this.log("Adapting to level "+e+" from level "+this.level),this.level=g.nextLoadLevel=e;var c=t.details;if(!c||this.state===SC||c.live&&this.levelLastLoaded!==e)return this.level=e,void(this.state=SC);var d=l.len,a=this.getMaxBufferLength(t.maxBitrate);if(!(d>=a)){this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);var n=this.backtrackFragment?this.backtrackFragment.start:l.end,r=this.getNextFragment(n,c);if(this.couldBacktrack&&!this.fragPrevious&&r&&"initSegment"!==r.sn&&this.fragmentTracker.getState(r)!==AC){var m,h=(null!=(m=this.backtrackFragment)?m:r).sn-c.startSN,Z=c.fragments[h-1];Z&&r.cc===Z.cc&&(r=Z,this.fragmentTracker.removeFragment(Z))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(r&&this.isLoopLoading(r,n)){if(!r.gap){var b=this.audioOnly&&!this.altAudio?k:D,G=(b===D?this.videoBuffer:this.mediaBuffer)||this.media;G&&this.afterBufferFlushed(G,b,nI)}r=this.getNextFragmentLoopLoading(r,c,l,nI,a)}r&&(!r.initSegment||r.initSegment.data||this.bitrateTest||(r=r.initSegment),this.loadFragment(r,t,n))}}}},C.loadFragment=function(I,C,A){var i=this.fragmentTracker.getState(I);this.fragCurrent=I,i===gC||i===CC?"initSegment"===I.sn?this._loadInitSegment(I,C):this.bitrateTest?(this.log("Fragment "+I.sn+" of level "+I.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(I,C)):(this.startFragRequested=!0,g.prototype.loadFragment.call(this,I,C,A)):this.clearTrackerIfNeeded(I)},C.getBufferedFrag=function(g){return this.fragmentTracker.getBufferedFrag(g,nI)},C.followingBufferedFrag=function(g){return g?this.getBufferedFrag(g.end+.5):null},C.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},C.nextLevelSwitch=function(){var g=this.levels,I=this.media;if(null!=I&&I.readyState){var C,A=this.getAppendedFrag(I.currentTime);A&&A.start>1&&this.flushMainBuffer(0,A.start-1);var i=this.getLevelDetails();if(null!=i&&i.live){var e=this.getMainFwdBufferInfo();if(!e||e.len<2*i.targetduration)return}if(!I.paused&&g){var t=g[this.hls.nextLoadLevel],l=this.fragLastKbps;C=l&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*l)+1:0}else C=0;var s=this.getBufferedFrag(I.currentTime+C);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var c=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,a=Math.max(s.end,c+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,.5*d),.75*d));this.flushMainBuffer(a,Number.POSITIVE_INFINITY)}}}},C.abortCurrentFrag=function(){var g=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,g&&(g.abortRequests(),this.fragmentTracker.removeFragment(g)),this.state){case XC:case YC:case RC:case HC:case KC:this.state=VC}this.nextLoadPosition=this.getLoadPosition()},C.flushMainBuffer=function(I,C){g.prototype.flushMainBuffer.call(this,I,C,this.altAudio?"video":null)},C.onMediaAttached=function(I,C){g.prototype.onMediaAttached.call(this,I,C);var A=C.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),A.addEventListener("playing",this.onvplaying),A.addEventListener("seeked",this.onvseeked),this.gapController=new EA(this.config,A,this.fragmentTracker,this.hls)},C.onMediaDetaching=function(){var I=this.media;I&&this.onvplaying&&this.onvseeked&&(I.removeEventListener("playing",this.onvplaying),I.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),g.prototype.onMediaDetaching.call(this)},C.onMediaPlaying=function(){this.tick()},C.onMediaSeeked=function(){var g=this.media,I=g?g.currentTime:null;W(I)&&this.log("Media seeked to "+I.toFixed(3));var C=this.getMainFwdBufferInfo();null!==C&&0!==C.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(C?C.len:"empty")+")")},C.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(B.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},C.onManifestParsed=function(g,I){var C,A,i,e=!1,t=!1;I.levels.forEach((function(g){(C=g.audioCodec)&&(-1!==C.indexOf("mp4a.40.2")&&(e=!0),-1!==C.indexOf("mp4a.40.5")&&(t=!0))})),this.audioCodecSwitch=e&&t&&!("function"==typeof(null==(i=kC())||null==(A=i.prototype)?void 0:A.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=I.levels,this.startFragRequested=!1},C.onLevelLoading=function(g,I){var C=this.levels;if(C&&this.state===VC){var A=C[I.level];(!A.details||A.details.live&&this.levelLastLoaded!==I.level||this.waitForCdnTuneIn(A.details))&&(this.state=SC)}},C.onLevelLoaded=function(g,I){var C,A=this.levels,i=I.level,e=I.details,t=e.totalduration;if(A){this.log("Level "+i+" loaded ["+e.startSN+","+e.endSN+"]"+(e.lastPartSn?"[part-"+e.lastPartSn+"-"+e.lastPartIndex+"]":"")+", cc ["+e.startCC+", "+e.endCC+"] duration:"+t);var l=A[i],s=this.fragCurrent;!s||this.state!==YC&&this.state!==RC||s.level===I.level&&s.urlId===l.urlId||!s.loader||this.abortCurrentFrag();var o=0;if(e.live||null!=(C=l.details)&&C.live){if(this.checkLiveUpdate(e),e.deltaUpdateFailed)return;o=this.alignPlaylists(e,l.details)}if(l.details=e,this.levelLastLoaded=i,this.hls.trigger(B.LEVEL_UPDATED,{details:e,level:i}),this.state===SC){if(this.waitForCdnTuneIn(e))return;this.state=VC}this.startFragRequested?e.live&&this.synchronizeToLiveEdge(e):this.setStartPosition(e,o),this.tick()}else this.warn("Levels were reset while loading level "+i)},C._handleFragmentLoadProgress=function(g){var I,C=g.frag,A=g.part,i=g.payload,e=this.levels;if(e){var t=e[C.level],l=t.details;if(!l)return this.warn("Dropping fragment "+C.sn+" of level "+C.level+" after level details were reset"),void this.fragmentTracker.removeFragment(C);var s=t.videoCodec,o=l.PTSKnown||!l.live,c=null==(I=C.initSegment)?void 0:I.data,d=this._getAudioCodec(t),a=this.transmuxer=this.transmuxer||new OA(this.hls,nI,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),n=A?A.index:-1,r=-1!==n,m=new hC(C.level,C.sn,C.stats.chunkCount,i.byteLength,n,r),h=this.initPTS[C.cc];a.push(i,c,d,s,C,A,l.totalduration,o,m,h)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+C.sn+" of level "+C.level+" will not be buffered")},C.onAudioTrackSwitching=function(g,I){var C=this.altAudio;if(!I.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var A=this.fragCurrent;A&&(this.log("Switching to main audio track, cancel main fragment load"),A.abortRequests(),this.fragmentTracker.removeFragment(A)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var i=this.hls;C&&(i.trigger(B.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(B.AUDIO_TRACK_SWITCHED,I)}},C.onAudioTrackSwitched=function(g,I){var C=I.id,A=!!this.hls.audioTracks[C].url;if(A){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=A,this.tick()},C.onBufferCreated=function(g,I){var C,A,i=I.tracks,e=!1;for(var t in i){var l=i[t];if("main"===l.id){if(A=t,C=l,"video"===t){var s=i[t];s&&(this.videoBuffer=s.buffer)}}else e=!0}e&&C?(this.log("Alternate track found, use "+A+".buffered to schedule main fragment loading"),this.mediaBuffer=C.buffer):this.mediaBuffer=this.media},C.onFragBuffered=function(g,I){var C=I.frag,A=I.part;if(!C||C.type===nI){if(this.fragContextChanged(C))return this.warn("Fragment "+C.sn+(A?" p: "+A.index:"")+" of level "+C.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===KC&&(this.state=VC));var i=A?A.stats:C.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==C.sn&&(this.fragPrevious=C),this.fragBufferedComplete(C,A)}},C.onError=function(g,I){var C;if(I.fatal)this.state=FC;else switch(I.details){case V.FRAG_GAP:case V.FRAG_PARSING_ERROR:case V.FRAG_DECRYPT_ERROR:case V.FRAG_LOAD_ERROR:case V.FRAG_LOAD_TIMEOUT:case V.KEY_LOAD_ERROR:case V.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(nI,I);break;case V.LEVEL_LOAD_ERROR:case V.LEVEL_LOAD_TIMEOUT:case V.LEVEL_PARSING_ERROR:I.levelRetry||this.state!==SC||(null==(C=I.context)?void 0:C.type)!==cI||(this.state=VC);break;case V.BUFFER_FULL_ERROR:if(!I.parent||"main"!==I.parent)return;this.reduceLengthAndFlushBuffer(I)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case V.INTERNAL_EXCEPTION:this.recoverWorkerError(I)}},C.checkBuffer=function(){var g=this.media,I=this.gapController;if(g&&I&&g.readyState){if(this.loadedmetadata||!mC.getBuffered(g).length){var C=this.state!==VC?this.fragCurrent:null;I.poll(this.lastCurrentTime,C)}this.lastCurrentTime=g.currentTime}},C.onFragLoadEmergencyAborted=function(){this.state=VC,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},C.onBufferFlushed=function(g,I){var C=I.type;if(C!==k||this.audioOnly&&!this.altAudio){var A=(C===D?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(A,C,nI)}},C.onLevelsUpdated=function(g,I){this.levels=I.levels},C.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},C.seekToStartPos=function(){var g=this.media;if(g){var I=g.currentTime,C=this.startPosition;if(C>=0&&I0&&(iG.cc;if(!1!==i.independent){var w=c.startPTS,y=c.endPTS,V=c.startDTS,X=c.endDTS;if(s)s.elementaryStreams[c.type]={startPTS:w,endPTS:y,startDTS:V,endDTS:X};else if(c.firstKeyFrame&&c.independent&&1===e.id&&!p&&(this.couldBacktrack=!0),c.dropped&&c.independent){var Y=this.getMainFwdBufferInfo(),R=(Y?Y.end:this.getLoadPosition())+this.config.maxBufferHole,N=c.firstKeyFramePTS?c.firstKeyFramePTS:w;if(!u&&R1&&!1===g.seeking){var C=g.currentTime;if(mC.isBuffered(g,C)?I=this.getAppendedFrag(C):mC.isBuffered(g,C+.1)&&(I=this.getAppendedFrag(C+.1)),I){this.backtrackFragment=null;var A=this.fragPlaying,i=I.level;A&&I.sn===A.sn&&A.level===i&&I.urlId===A.urlId||(this.fragPlaying=I,this.hls.trigger(B.FRAG_CHANGED,{frag:I}),A&&A.level===i||this.hls.trigger(B.LEVEL_SWITCHED,{level:i}))}}},e(I,[{key:"nextLevel",get:function(){var g=this.nextBufferedFrag;return g?g.level:-1}},{key:"currentFrag",get:function(){var g=this.media;return g?this.fragPlaying||this.getAppendedFrag(g.currentTime):null}},{key:"currentProgramDateTime",get:function(){var g=this.media;if(g){var I=g.currentTime,C=this.currentFrag;if(C&&W(I)&&W(C.programDateTime)){var A=C.programDateTime+1e3*(I-C.start);return new Date(A)}}return null}},{key:"currentLevel",get:function(){var g=this.currentFrag;return g?g.level:-1}},{key:"nextBufferedFrag",get:function(){var g=this.currentFrag;return g?this.followingBufferedFrag(g):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),I}(JC),_A=function(){function g(g,I,C){void 0===I&&(I=0),void 0===C&&(C=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=g,this.alpha_=g?Math.exp(Math.log(.5)/g):0,this.estimate_=I,this.totalWeight_=C}var I=g.prototype;return I.sample=function(g,I){var C=Math.pow(this.alpha_,g);this.estimate_=I*(1-C)+C*this.estimate_,this.totalWeight_+=g},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var g=1-Math.pow(this.alpha_,this.totalWeight_);if(g)return this.estimate_/g}return this.estimate_},g}(),qA=function(){function g(g,I,C,A){void 0===A&&(A=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=C,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new _A(g),this.fast_=new _A(I),this.defaultTTFB_=A,this.ttfb_=new _A(g)}var I=g.prototype;return I.update=function(g,I){var C=this.slow_,A=this.fast_,i=this.ttfb_;C.halfLife!==g&&(this.slow_=new _A(g,C.getEstimate(),C.getTotalWeight())),A.halfLife!==I&&(this.fast_=new _A(I,A.getEstimate(),A.getTotalWeight())),i.halfLife!==g&&(this.ttfb_=new _A(g,i.getEstimate(),i.getTotalWeight()))},I.sample=function(g,I){var C=(g=Math.max(g,this.minDelayMs_))/1e3,A=8*I/C;this.fast_.sample(C,A),this.slow_.sample(C,A)},I.sampleTTFB=function(g){var I=g/1e3,C=Math.sqrt(2)*Math.exp(-Math.pow(I,2)/2);this.ttfb_.sample(C,Math.max(g,5))},I.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},I.destroy=function(){},g}(),$A=function(){function g(g){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=g;var I=g.config;this.bwEstimator=new qA(I.abrEwmaSlowVoD,I.abrEwmaFastVoD,I.abrEwmaDefaultEstimate),this.registerListeners()}var I=g.prototype;return I.registerListeners=function(){var g=this.hls;g.on(B.FRAG_LOADING,this.onFragLoading,this),g.on(B.FRAG_LOADED,this.onFragLoaded,this),g.on(B.FRAG_BUFFERED,this.onFragBuffered,this),g.on(B.LEVEL_SWITCHING,this.onLevelSwitching,this),g.on(B.LEVEL_LOADED,this.onLevelLoaded,this)},I.unregisterListeners=function(){var g=this.hls;g.off(B.FRAG_LOADING,this.onFragLoading,this),g.off(B.FRAG_LOADED,this.onFragLoaded,this),g.off(B.FRAG_BUFFERED,this.onFragBuffered,this),g.off(B.LEVEL_SWITCHING,this.onLevelSwitching,this),g.off(B.LEVEL_LOADED,this.onLevelLoaded,this)},I.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},I.onFragLoading=function(g,I){var C,A=I.frag;this.ignoreFragment(A)||(this.fragCurrent=A,this.partCurrent=null!=(C=I.part)?C:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},I.onLevelSwitching=function(g,I){this.clearTimer()},I.getTimeToLoadFrag=function(g,I,C,A){return g+C/I+(A?this.lastLevelLoadSec:0)},I.onLevelLoaded=function(g,I){var C=this.hls.config,A=I.stats,i=A.total,e=A.bwEstimate;W(i)&&W(e)&&(this.lastLevelLoadSec=8*i/e),I.details.live?this.bwEstimator.update(C.abrEwmaSlowLive,C.abrEwmaFastLive):this.bwEstimator.update(C.abrEwmaSlowVoD,C.abrEwmaFastVoD)},I._abandonRulesCheck=function(){var g=this.fragCurrent,I=this.partCurrent,C=this.hls,A=C.autoLevelEnabled,i=C.media;if(g&&i){var e=performance.now(),t=I?I.stats:g.stats,l=I?I.duration:g.duration,s=e-t.loading.start;if(t.aborted||t.loaded&&t.loaded===t.total||0===g.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(A&&!i.paused&&i.playbackRate&&i.readyState){var o=C.mainForwardBufferInfo;if(null!==o){var c=this.bwEstimator.getEstimateTTFB(),d=Math.abs(i.playbackRate);if(!(s<=Math.max(c,l/(2*d)*1e3))){var a=o.len/d;if(!(a>=2*l/d)){var n=t.loading.first?t.loading.first-t.loading.start:-1,r=t.loaded&&n>-1,m=this.bwEstimator.getEstimate(),h=C.levels,Z=C.minAutoLevel,b=h[g.level],G=t.total||Math.max(t.loaded,Math.round(l*b.maxBitrate/8)),u=s-n;u<1&&r&&(u=Math.min(s,8*t.loaded/m));var p=r?1e3*t.loaded/u:0,w=p?(G-t.loaded)/p:8*G/m+c/1e3;if(!(w<=a)){var y,V=p?8*p:m,X=Number.POSITIVE_INFINITY;for(y=g.level-1;y>Z;y--){var Y=h[y].maxBitrate;if((X=this.getTimeToLoadFrag(c/1e3,V,l*Y,!h[y].details))=w||X>10*l||(C.nextLoadLevel=y,r?this.bwEstimator.sample(s-Math.min(c,n),t.loaded):this.bwEstimator.sampleTTFB(s),this.clearTimer(),H.warn("[abr] Fragment "+g.sn+(I?" part "+I.index:"")+" of level "+g.level+" is loading too slowly;\n Time to underbuffer: "+a.toFixed(3)+" s\n Estimated load time for current fragment: "+w.toFixed(3)+" s\n Estimated load time for down switch fragment: "+X.toFixed(3)+" s\n TTFB estimate: "+n+"\n Current BW estimate: "+(W(m)?(m/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+y),g.loader&&(this.fragCurrent=this.partCurrent=null,g.abortRequests()),C.trigger(B.FRAG_LOAD_EMERGENCY_ABORTED,{frag:g,part:I,stats:t}))}}}}}}},I.onFragLoaded=function(g,I){var C=I.frag,A=I.part,i=A?A.stats:C.stats;if(C.type===nI&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(C)){if(this.clearTimer(),this.lastLoadedFragLevel=C.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var e=A?A.duration:C.duration,t=this.hls.levels[C.level],l=(t.loaded?t.loaded.bytes:0)+i.loaded,s=(t.loaded?t.loaded.duration:0)+e;t.loaded={bytes:l,duration:s},t.realBitrate=Math.round(8*l/s)}if(C.bitrateTest){var o={stats:i,frag:C,part:A,id:C.type};this.onFragBuffered(B.FRAG_BUFFERED,o),C.bitrateTest=!1}}},I.onFragBuffered=function(g,I){var C=I.frag,A=I.part,i=null!=A&&A.stats.loaded?A.stats:C.stats;if(!i.aborted&&!this.ignoreFragment(C)){var e=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(e,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),C.bitrateTest?this.bitrateTestDelay=e/1e3:this.bitrateTestDelay=0}},I.ignoreFragment=function(g){return g.type!==nI||"initSegment"===g.sn},I.clearTimer=function(){self.clearInterval(this.timer)},I.getNextABRAutoLevel=function(){var g=this.fragCurrent,I=this.partCurrent,C=this.hls,A=C.maxAutoLevel,i=C.config,e=C.minAutoLevel,t=C.media,l=I?I.duration:g?g.duration:0,s=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,o=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,c=C.mainForwardBufferInfo,d=(c?c.len:0)/s,a=this.findBestLevel(o,e,A,d,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(a>=0)return a;H.trace("[abr] "+(d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var n=l?Math.min(l,i.maxStarvationDelay):i.maxStarvationDelay,r=i.abrBandWidthFactor,m=i.abrBandWidthUpFactor;if(!d){var h=this.bitrateTestDelay;h&&(n=(l?Math.min(l,i.maxLoadingDelay):i.maxLoadingDelay)-h,H.trace("[abr] bitrate test took "+Math.round(1e3*h)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*n)+" ms"),r=m=1)}return a=this.findBestLevel(o,e,A,d+n,r,m),Math.max(a,0)},I.findBestLevel=function(g,I,C,A,i,e){for(var t,l=this.fragCurrent,s=this.partCurrent,o=this.lastLoadedFragLevel,c=this.hls.levels,d=c[o],a=!(null==d||null==(t=d.details)||!t.live),n=null==d?void 0:d.codecSet,r=s?s.duration:l?l.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3,h=I,Z=-1,b=C;b>=I;b--){var G=c[b];if(!G||n&&G.codecSet!==n)G&&(h=Math.min(b,h),Z=Math.max(b,Z));else{-1!==Z&&H.trace("[abr] Skipped level(s) "+h+"-"+Z+' with CODECS:"'+c[Z].attrs.CODECS+'"; not compatible with "'+d.attrs.CODECS+'"');var u,p=G.details,w=(s?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||r;u=b<=o?i*g:e*g;var B=c[b].maxBitrate,y=this.getTimeToLoadFrag(m,u,B*w,void 0===p);if(H.trace("[abr] level:"+b+" adjustedbw-bitrate:"+Math.round(u-B)+" avgDuration:"+w.toFixed(1)+" maxFetchDuration:"+A.toFixed(1)+" fetchDuration:"+y.toFixed(1)),u>B&&(0===y||!W(y)||a&&!this.bitrateTestDelay||yMath.max(g,C)&&A[g].loadError<=A[C].loadError)return g}return-1!==g&&(C=Math.min(g,C)),C},set:function(g){this._nextAutoLevel=g}}]),g}(),gi=function(){function g(){this.chunks=[],this.dataLength=0}var I=g.prototype;return I.push=function(g){this.chunks.push(g),this.dataLength+=g.length},I.flush=function(){var g,I=this.chunks,C=this.dataLength;return I.length?(g=1===I.length?I[0]:function(g,I){for(var C=new Uint8Array(I),A=0,i=0;i0&&-1===g?(this.log("Override startPosition with lastCurrentTime @"+I.toFixed(3)),g=I,this.state=VC):(this.loadedmetadata=!1,this.state=NC),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=g,this.tick()},C.doTick=function(){switch(this.state){case VC:this.doTickIdle();break;case NC:var I,C=this.levels,A=this.trackId,i=null==C||null==(I=C[A])?void 0:I.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=MC}break;case RC:var e,t=performance.now(),l=this.retryDate;(!l||t>=l||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=VC);break;case MC:var s=this.waitingData;if(s){var o=s.frag,c=s.part,d=s.cache,a=s.complete;if(void 0!==this.initPTS[o.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=YC;var n={frag:o,part:c,payload:d.flush(),networkDetails:null};this._handleFragmentLoadProgress(n),a&&g.prototype._handleFragmentLoadComplete.call(this,n)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+o.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var r=this.getLoadPosition(),m=mC.bufferInfo(this.mediaBuffer,r,this.config.maxBufferHole);jI(m.end,this.config.maxFragLookUpTolerance,o)<0&&(this.log("Waiting fragment cc ("+o.cc+") @ "+o.start+" cancelled because another fragment at "+m.end+" is needed"),this.clearWaitingFragment())}}else this.state=VC}this.onTickEnd()},C.clearWaitingFragment=function(){var g=this.waitingData;g&&(this.fragmentTracker.removeFragment(g.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=VC)},C.resetLoadingState=function(){this.clearWaitingFragment(),g.prototype.resetLoadingState.call(this)},C.onTickEnd=function(){var g=this.media;null!=g&&g.readyState&&(this.lastCurrentTime=g.currentTime)},C.doTickIdle=function(){var g=this.hls,I=this.levels,C=this.media,A=this.trackId,i=g.config;if(null!=I&&I[A]&&(C||!this.startFragRequested&&i.startFragPrefetch)){var e=I[A],t=e.details;if(!t||t.live&&this.levelLastLoaded!==A||this.waitForCdnTuneIn(t))this.state=NC;else{var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,k,rI));var s=this.getFwdBufferInfo(l,rI);if(null!==s){var o=this.bufferedTrack,c=this.switchingTrack;if(!c&&this._streamEnded(s,t))return g.trigger(B.BUFFER_EOS,{type:"audio"}),void(this.state=fC);var d=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,nI),a=s.len,n=this.getMaxBufferLength(null==d?void 0:d.len);if(!(a>=n)||c){var r=t.fragments[0].start,m=s.end;if(c&&C){var h=this.getLoadPosition();o&&c.attrs!==o.attrs&&(m=h),t.PTSKnown&&hr||s.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),C.currentTime=r+.05)}var Z=this.getNextFragment(m,t),b=!1;if(Z&&this.isLoopLoading(Z,m)&&(b=!!Z.gap,Z=this.getNextFragmentLoopLoading(Z,t,s,nI,n)),Z){var G=d&&Z.start>d.end+t.targetduration;if(G||(null==d||!d.len)&&s.len){var u=this.getAppendedFrag(Z.start,nI);if(null===u)return;if(b||(b=!!u.gap||!!G&&0===d.len),G&&!b||b&&s.nextStart&&s.nextStart=I.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var C=this.currentTrack;I[this.trackId];var i=I[g],e=i.groupId,t=i.name;if(this.log("Switching to audio-track "+g+' "'+t+'" lang:'+i.lang+" group:"+e),this.trackId=g,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(B.AUDIO_TRACK_SWITCHING,A({},i)),!i.details||i.details.live){var l=this.switchParams(i.url,null==C?void 0:C.details);this.loadPlaylist(l)}}},C.selectInitialTrack=function(){var g=this.tracksInGroup,I=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==I)this.setAudioTrack(I);else{var C=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+g.length);this.warn(C.message),this.hls.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:C})}},C.findTrackId=function(g){for(var I=this.tracksInGroup,C=0;C=i[l].start&&t<=i[l].end){e=i[l];break}var s=C.start+C.duration;e?e.end=s:(e={start:t,end:s},i.push(e)),this.fragmentTracker.fragBuffered(C)}}},C.onBufferFlushing=function(g,I){var C=I.startOffset,A=I.endOffset;if(0===C&&A!==Number.POSITIVE_INFINITY){var i=A-1;if(i<=0)return;I.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach((function(g){for(var I=0;I=t.length||i!==e)&&l){this.mediaBuffer=this.mediaBufferTimeRanges;var s=0;if(A.live||null!=(C=l.details)&&C.live){var o=this.mainDetails;if(A.deltaUpdateFailed||!o)return;var c=o.fragments[0];l.details?0===(s=this.alignPlaylists(A,l.details))&&c&&SI(A,s=c.start):A.hasProgramDateTime&&o.hasProgramDateTime?(uC(A,o),s=A.fragments[0].start):c&&SI(A,s=c.start)}l.details=A,this.levelLastLoaded=i,this.startFragRequested||!this.mainDetails&&A.live||this.setStartPosition(l.details,s),this.tick(),A.live&&!this.fragCurrent&&this.media&&this.state===VC&&(UI(null,A.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}}},C._handleFragmentLoadComplete=function(g){var I=this,C=g.frag,A=g.payload,i=C.decryptdata,e=this.hls;if(!this.fragContextChanged(C)&&A&&A.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){var t=performance.now();this.decrypter.decrypt(new Uint8Array(A),i.key.buffer,i.iv.buffer).catch((function(g){throw e.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.FRAG_DECRYPT_ERROR,fatal:!1,error:g,reason:g.message,frag:C}),g})).then((function(g){var I=performance.now();e.trigger(B.FRAG_DECRYPTED,{frag:C,payload:g,stats:{tstart:t,tdecrypt:I}})})).catch((function(g){I.warn(g.name+": "+g.message),I.state=VC}))}},C.doTick=function(){if(this.media){if(this.state===VC){var g=this.currentTrackId,I=this.levels,C=I[g];if(!I.length||!C||!C.details)return;var A=this.config,i=this.getLoadPosition(),e=mC.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,A.maxBufferHole),t=e.end,l=e.len,s=this.getFwdBufferInfo(this.media,nI),o=C.details;if(l>this.getMaxBufferLength(null==s?void 0:s.len)+o.levelTargetDuration)return;var c=o.fragments,d=c.length,a=o.edge,n=null,r=this.fragPrevious;if(ta-m?0:m;!(n=UI(r,c,Math.max(c[0].start,t),h))&&r&&r.start>>=0)>A-1)throw new DOMException("Failed to execute '"+I+"' on 'TimeRanges': The index provided ("+C+") is greater than the maximum bound ("+A+")");return g[C][I]};this.buffered={get length(){return g.length},end:function(C){return I("end",C,g.length)},start:function(C){return I("start",C,g.length)}}},li=function(g){function I(I){var C;return(C=g.call(this,I,"[subtitle-track-controller]")||this).media=null,C.tracks=[],C.groupId=null,C.tracksInGroup=[],C.trackId=-1,C.selectDefaultTrack=!0,C.queuedDefaultTrack=-1,C.trackChangeListener=function(){return C.onTextTracksChanged()},C.asyncPollTrackChange=function(){return C.pollTrackChange(0)},C.useTextTrackPolling=!1,C.subtitlePollingInterval=-1,C._subtitleDisplay=!0,C.registerListeners(),C}s(I,g);var C=I.prototype;return C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,g.prototype.destroy.call(this)},C.registerListeners=function(){var g=this.hls;g.on(B.MEDIA_ATTACHED,this.onMediaAttached,this),g.on(B.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(B.MANIFEST_LOADING,this.onManifestLoading,this),g.on(B.MANIFEST_PARSED,this.onManifestParsed,this),g.on(B.LEVEL_LOADING,this.onLevelLoading,this),g.on(B.LEVEL_SWITCHING,this.onLevelSwitching,this),g.on(B.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),g.on(B.ERROR,this.onError,this)},C.unregisterListeners=function(){var g=this.hls;g.off(B.MEDIA_ATTACHED,this.onMediaAttached,this),g.off(B.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(B.MANIFEST_LOADING,this.onManifestLoading,this),g.off(B.MANIFEST_PARSED,this.onManifestParsed,this),g.off(B.LEVEL_LOADING,this.onLevelLoading,this),g.off(B.LEVEL_SWITCHING,this.onLevelSwitching,this),g.off(B.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),g.off(B.ERROR,this.onError,this)},C.onMediaAttached=function(g,I){this.media=I.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},C.pollTrackChange=function(g){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,g)},C.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),si(this.media.textTracks).forEach((function(g){pI(g)})),this.subtitleTrack=-1,this.media=null)},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(g,I){this.tracks=I.subtitleTracks},C.onSubtitleTrackLoaded=function(g,I){var C=I.id,A=I.details,i=this.trackId,e=this.tracksInGroup[i];if(e){var t=e.details;e.details=I.details,this.log("subtitle track "+C+" loaded ["+A.startSN+"-"+A.endSN+"]"),C===this.trackId&&this.playlistLoaded(C,I,t)}else this.warn("Invalid subtitle track id "+C)},C.onLevelLoading=function(g,I){this.switchLevel(I.level)},C.onLevelSwitching=function(g,I){this.switchLevel(I.level)},C.switchLevel=function(g){var I=this.hls.levels[g];if(null!=I&&I.textGroupIds){var C=I.textGroupIds[I.urlId],A=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==C){var i=this.tracks.filter((function(g){return!C||g.groupId===C}));this.tracksInGroup=i;var e=this.findTrackId(null==A?void 0:A.name)||this.findTrackId();this.groupId=C||null;var t={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+C+'" group-id'),this.hls.trigger(B.SUBTITLE_TRACKS_UPDATED,t),-1!==e&&this.setSubtitleTrack(e,A)}else this.shouldReloadPlaylist(A)&&this.setSubtitleTrack(this.trackId,A)}},C.findTrackId=function(g){for(var I=this.tracksInGroup,C=0;C=A.length)){this.clearTimer();var i=A[g];if(this.log("Switching to subtitle-track "+g+(i?' "'+i.name+'" lang:'+i.lang+" group:"+i.groupId:"")),this.trackId=g,i){var e=i.id,t=i.groupId,l=void 0===t?"":t,s=i.name,o=i.type,c=i.url;this.hls.trigger(B.SUBTITLE_TRACK_SWITCH,{id:e,groupId:l,name:s,type:o,url:c});var d=this.switchParams(i.url,null==I?void 0:I.details);this.loadPlaylist(d)}else this.hls.trigger(B.SUBTITLE_TRACK_SWITCH,{id:g})}}else this.queuedDefaultTrack=g},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var g=-1,I=si(this.media.textTracks),C=0;C-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(g){this.selectDefaultTrack=!1;var I=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(g,I)}}]),I}(PI);function si(g){for(var I=[],C=0;C "+g.src+")")},this.hls=g,this._initSourceBuffer(),this.registerListeners()}var I=g.prototype;return I.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},I.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},I.registerListeners=function(){var g=this.hls;g.on(B.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(B.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(B.MANIFEST_LOADING,this.onManifestLoading,this),g.on(B.MANIFEST_PARSED,this.onManifestParsed,this),g.on(B.BUFFER_RESET,this.onBufferReset,this),g.on(B.BUFFER_APPENDING,this.onBufferAppending,this),g.on(B.BUFFER_CODECS,this.onBufferCodecs,this),g.on(B.BUFFER_EOS,this.onBufferEos,this),g.on(B.BUFFER_FLUSHING,this.onBufferFlushing,this),g.on(B.LEVEL_UPDATED,this.onLevelUpdated,this),g.on(B.FRAG_PARSED,this.onFragParsed,this),g.on(B.FRAG_CHANGED,this.onFragChanged,this)},I.unregisterListeners=function(){var g=this.hls;g.off(B.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(B.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(B.MANIFEST_LOADING,this.onManifestLoading,this),g.off(B.MANIFEST_PARSED,this.onManifestParsed,this),g.off(B.BUFFER_RESET,this.onBufferReset,this),g.off(B.BUFFER_APPENDING,this.onBufferAppending,this),g.off(B.BUFFER_CODECS,this.onBufferCodecs,this),g.off(B.BUFFER_EOS,this.onBufferEos,this),g.off(B.BUFFER_FLUSHING,this.onBufferFlushing,this),g.off(B.LEVEL_UPDATED,this.onLevelUpdated,this),g.off(B.FRAG_PARSED,this.onFragParsed,this),g.off(B.FRAG_CHANGED,this.onFragChanged,this)},I._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new oi(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},I.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},I.onManifestParsed=function(g,I){var C=2;(I.audio&&!I.video||!I.altAudio)&&(C=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=C,H.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},I.onMediaAttaching=function(g,I){var C=this.media=I.media;if(C&&ci){var A=this.mediaSource=new ci;A.addEventListener("sourceopen",this._onMediaSourceOpen),A.addEventListener("sourceended",this._onMediaSourceEnded),A.addEventListener("sourceclose",this._onMediaSourceClose),C.src=self.URL.createObjectURL(A),this._objectUrl=C.src,C.addEventListener("emptied",this._onMediaEmptied)}},I.onMediaDetaching=function(){var g=this.media,I=this.mediaSource,C=this._objectUrl;if(I){if(H.log("[buffer-controller]: media source detaching"),"open"===I.readyState)try{I.endOfStream()}catch(A){H.warn("[buffer-controller]: onMediaDetaching: "+A.message+" while calling endOfStream")}this.onBufferReset(),I.removeEventListener("sourceopen",this._onMediaSourceOpen),I.removeEventListener("sourceended",this._onMediaSourceEnded),I.removeEventListener("sourceclose",this._onMediaSourceClose),g&&(g.removeEventListener("emptied",this._onMediaEmptied),C&&self.URL.revokeObjectURL(C),g.src===C?(g.removeAttribute("src"),g.load()):H.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(B.MEDIA_DETACHED,void 0)},I.onBufferReset=function(){var g=this;this.getSourceBufferTypes().forEach((function(I){var C=g.sourceBuffer[I];try{C&&(g.removeBufferListeners(I),g.mediaSource&&g.mediaSource.removeSourceBuffer(C),g.sourceBuffer[I]=void 0)}catch(A){H.warn("[buffer-controller]: Failed to reset the "+I+" buffer",A)}})),this._initSourceBuffer()},I.onBufferCodecs=function(g,I){var C=this,A=this.getSourceBufferTypes().length;Object.keys(I).forEach((function(g){if(A){var i=C.tracks[g];if(i&&"function"==typeof i.buffer.changeType){var e=I[g],t=e.id,l=e.codec,s=e.levelCodec,o=e.container,c=e.metadata,d=(i.levelCodec||i.codec).replace(di,"$1"),a=(s||l).replace(di,"$1");if(d!==a){var n=o+";codecs="+(s||l);C.appendChangeType(g,n),H.log("[buffer-controller]: switching codec "+d+" to "+a),C.tracks[g]={buffer:i.buffer,codec:l,container:o,levelCodec:s,metadata:c,id:t}}}}else C.pendingTracks[g]=I[g]})),A||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},I.appendChangeType=function(g,I){var C=this,A=this.operationQueue,i={execute:function(){var i=C.sourceBuffer[g];i&&(H.log("[buffer-controller]: changing "+g+" sourceBuffer type to "+I),i.changeType(I)),A.shiftAndExecuteNext(g)},onStart:function(){},onComplete:function(){},onError:function(I){H.warn("[buffer-controller]: Failed to change "+g+" SourceBuffer type",I)}};A.append(i,g)},I.onBufferAppending=function(g,I){var C=this,A=this.hls,i=this.operationQueue,e=this.tracks,t=I.data,l=I.type,s=I.frag,o=I.part,c=I.chunkMeta,d=c.buffering[l],a=self.performance.now();d.start=a;var n=s.stats.buffering,r=o?o.stats.buffering:null;0===n.start&&(n.start=a),r&&0===r.start&&(r.start=a);var m=e.audio,h=!1;"audio"===l&&"audio/mpeg"===(null==m?void 0:m.container)&&(h=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var Z=s.start,b={execute:function(){if(d.executeStart=self.performance.now(),h){var g=C.sourceBuffer[l];if(g){var I=Z-g.timestampOffset;Math.abs(I)>=.1&&(H.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+Z+" (delta: "+I+") sn: "+s.sn+")"),g.timestampOffset=Z)}}C.appendExecutor(t,l)},onStart:function(){},onComplete:function(){var g=self.performance.now();d.executeEnd=d.end=g,0===n.first&&(n.first=g),r&&0===r.first&&(r.first=g);var I=C.sourceBuffer,A={};for(var i in I)A[i]=mC.getBuffered(I[i]);C.appendError=0,C.hls.trigger(B.BUFFER_APPENDED,{type:l,frag:s,part:o,chunkMeta:c,parent:s.type,timeRanges:A})},onError:function(g){H.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",g);var I={type:y.MEDIA_ERROR,parent:s.type,details:V.BUFFER_APPEND_ERROR,frag:s,part:o,chunkMeta:c,error:g,err:g,fatal:!1};g.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=V.BUFFER_FULL_ERROR:(C.appendError++,I.details=V.BUFFER_APPEND_ERROR,C.appendError>A.config.appendErrorMaxRetry&&(H.error("[buffer-controller]: Failed "+A.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),I.fatal=!0)),A.trigger(B.ERROR,I)}};i.append(b,l)},I.onBufferFlushing=function(g,I){var C=this,A=this.operationQueue,i=function(g){return{execute:C.removeExecutor.bind(C,g,I.startOffset,I.endOffset),onStart:function(){},onComplete:function(){C.hls.trigger(B.BUFFER_FLUSHED,{type:g})},onError:function(I){H.warn("[buffer-controller]: Failed to remove from "+g+" SourceBuffer",I)}}};I.type?A.append(i(I.type),I.type):this.getSourceBufferTypes().forEach((function(g){A.append(i(g),g)}))},I.onFragParsed=function(g,I){var C=this,A=I.frag,i=I.part,e=[],t=i?i.elementaryStreams:A.elementaryStreams;t[v]?e.push("audiovideo"):(t[k]&&e.push("audio"),t[D]&&e.push("video")),0===e.length&&H.warn("Fragments must have at least one ElementaryStreamType set. type: "+A.type+" level: "+A.level+" sn: "+A.sn),this.blockBuffers((function(){var g=self.performance.now();A.stats.buffering.end=g,i&&(i.stats.buffering.end=g);var I=i?i.stats:A.stats;C.hls.trigger(B.FRAG_BUFFERED,{frag:A,part:i,stats:I,id:A.type})}),e)},I.onFragChanged=function(g,I){this.flushBackBuffer()},I.onBufferEos=function(g,I){var C=this;this.getSourceBufferTypes().reduce((function(g,A){var i=C.sourceBuffer[A];return!i||I.type&&I.type!==A||(i.ending=!0,i.ended||(i.ended=!0,H.log("[buffer-controller]: "+A+" sourceBuffer now EOS"))),g&&!(i&&!i.ended)}),!0)&&(H.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){C.getSourceBufferTypes().forEach((function(g){var I=C.sourceBuffer[g];I&&(I.ending=!1)}));var g=C.mediaSource;g&&"open"===g.readyState?(H.log("[buffer-controller]: Calling mediaSource.endOfStream()"),g.endOfStream()):g&&H.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+g.readyState)})))},I.onLevelUpdated=function(g,I){var C=I.details;C.fragments.length&&(this.details=C,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},I.flushBackBuffer=function(){var g=this.hls,I=this.details,C=this.media,A=this.sourceBuffer;if(C&&null!==I){var i=this.getSourceBufferTypes();if(i.length){var e=I.live&&null!==g.config.liveBackBufferLength?g.config.liveBackBufferLength:g.config.backBufferLength;if(W(e)&&!(e<0)){var t=C.currentTime,l=I.levelTargetDuration,s=Math.max(e,l),o=Math.floor(t/l)*l-s;i.forEach((function(C){var i=A[C];if(i){var e=mC.getBuffered(i);if(e.length>0&&o>e.start(0)){if(g.trigger(B.BACK_BUFFER_REACHED,{bufferEnd:o}),I.live)g.trigger(B.LIVE_BACK_BUFFER_REACHED,{bufferEnd:o});else if(i.ended&&e.end(e.length-1)-t<2*l)return void H.info("[buffer-controller]: Cannot flush "+C+" back buffer while SourceBuffer is in ended state");g.trigger(B.BUFFER_FLUSHING,{startOffset:0,endOffset:o,type:C})}}}))}}}},I.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var g=this.details,I=this.hls,C=this.media,A=this.mediaSource,i=g.fragments[0].start+g.totalduration,e=C.duration,t=W(A.duration)?A.duration:0;g.live&&I.config.liveDurationInfinity?(H.log("[buffer-controller]: Media Source duration is set to Infinity"),A.duration=1/0,this.updateSeekableRange(g)):(i>t&&i>e||!W(e))&&(H.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),A.duration=i)}},I.updateSeekableRange=function(g){var I=this.mediaSource,C=g.fragments;if(C.length&&g.live&&null!=I&&I.setLiveSeekableRange){var A=Math.max(0,C[0].start),i=Math.max(A,A+g.totalduration);I.setLiveSeekableRange(A,i)}},I.checkPendingTracks=function(){var g=this.bufferCodecEventsExpected,I=this.operationQueue,C=this.pendingTracks,A=Object.keys(C).length;if(A&&!g||2===A){this.createSourceBuffers(C),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length)this.hls.trigger(B.BUFFER_CREATED,{tracks:this.tracks}),i.forEach((function(g){I.executeNext(g)}));else{var e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}},I.createSourceBuffers=function(g){var I=this.sourceBuffer,C=this.mediaSource;if(!C)throw Error("createSourceBuffers called when mediaSource was null");for(var A in g)if(!I[A]){var i=g[A];if(!i)throw Error("source buffer exists for track "+A+", however track does not");var e=i.levelCodec||i.codec,t=i.container+";codecs="+e;H.log("[buffer-controller]: creating sourceBuffer("+t+")");try{var l=I[A]=C.addSourceBuffer(t),s=A;this.addBufferListener(s,"updatestart",this._onSBUpdateStart),this.addBufferListener(s,"updateend",this._onSBUpdateEnd),this.addBufferListener(s,"error",this._onSBUpdateError),this.tracks[A]={buffer:l,codec:e,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(o){H.error("[buffer-controller]: error while trying to add sourceBuffer: "+o.message),this.hls.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:o,mimeType:t})}}},I._onSBUpdateStart=function(g){this.operationQueue.current(g).onStart()},I._onSBUpdateEnd=function(g){var I=this.operationQueue;I.current(g).onComplete(),I.shiftAndExecuteNext(g)},I._onSBUpdateError=function(g,I){var C=new Error(g+" SourceBuffer error");H.error("[buffer-controller]: "+C,I),this.hls.trigger(B.ERROR,{type:y.MEDIA_ERROR,details:V.BUFFER_APPENDING_ERROR,error:C,fatal:!1});var A=this.operationQueue.current(g);A&&A.onError(I)},I.removeExecutor=function(g,I,C){var A=this.media,i=this.mediaSource,e=this.operationQueue,t=this.sourceBuffer[g];if(!A||!i||!t)return H.warn("[buffer-controller]: Attempting to remove from the "+g+" SourceBuffer, but it does not exist"),void e.shiftAndExecuteNext(g);var l=W(A.duration)?A.duration:1/0,s=W(i.duration)?i.duration:1/0,o=Math.max(0,I),c=Math.min(C,l,s);c>o&&!t.ending?(t.ended=!1,H.log("[buffer-controller]: Removing ["+o+","+c+"] from the "+g+" SourceBuffer"),t.remove(o,c)):e.shiftAndExecuteNext(g)},I.appendExecutor=function(g,I){var C=this.operationQueue,A=this.sourceBuffer[I];if(!A)return H.warn("[buffer-controller]: Attempting to append to the "+I+" SourceBuffer, but it does not exist"),void C.shiftAndExecuteNext(I);A.ended=!1,A.appendBuffer(g)},I.blockBuffers=function(g,I){var C=this;if(void 0===I&&(I=this.getSourceBufferTypes()),!I.length)return H.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(g);var A=this.operationQueue,i=I.map((function(g){return A.appendBlocker(g)}));Promise.all(i).then((function(){g(),I.forEach((function(g){var I=C.sourceBuffer[g];null!=I&&I.updating||A.shiftAndExecuteNext(g)}))}))},I.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},I.addBufferListener=function(g,I,C){var A=this.sourceBuffer[g];if(A){var i=C.bind(this,g);this.listeners[g].push({event:I,listener:i}),A.addEventListener(I,i)}},I.removeBufferListeners=function(g){var I=this.sourceBuffer[g];I&&this.listeners[g].forEach((function(g){I.removeEventListener(g.event,g.listener)}))},g}(),ni={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ri=function(g){var I=g;return ni.hasOwnProperty(g)&&(I=ni[g]),String.fromCharCode(I)},mi=15,hi=100,Zi={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},bi={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Gi={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ui={25:2,26:4,29:6,30:8,31:10,27:13,28:15},pi=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],wi=function(){function g(){this.time=null,this.verboseLevel=0}return g.prototype.log=function(g,I){if(this.verboseLevel>=g){var C="function"==typeof I?I():I;H.log(this.time+" ["+g+"] "+C)}},g}(),Wi=function(g){for(var I=[],C=0;Chi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=hi)},I.moveCursor=function(g){var I=this.pos+g;if(g>1)for(var C=this.pos+1;C=144&&this.backSpace();var C=ri(g);this.pos>=hi?this.logger.log(0,(function(){return"Cannot insert "+g.toString(16)+" ("+C+") at position "+I.pos+". Skipping it!"})):(this.chars[this.pos].setChar(C,this.currPenState),this.moveCursor(1))},I.clearFromPos=function(g){var I;for(I=g;I0&&(C=g?"["+I.join(" | ")+"]":I.join("\n")),C},I.getTextAndFormat=function(){return this.rows},g}(),Yi=function(){function g(g,I,C){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=g,this.outputFilter=I,this.mode=null,this.verbose=0,this.displayedMemory=new Xi(C),this.nonDisplayedMemory=new Xi(C),this.lastOutputScreen=new Xi(C),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=C}var I=g.prototype;return I.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},I.getHandler=function(){return this.outputFilter},I.setHandler=function(g){this.outputFilter=g},I.setPAC=function(g){this.writeScreen.setPAC(g)},I.setBkgData=function(g){this.writeScreen.setBkgData(g)},I.setMode=function(g){g!==this.mode&&(this.mode=g,this.logger.log(2,(function(){return"MODE="+g})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=g)},I.insertChars=function(g){for(var I=this,C=0;C=46,I.italics)I.foreground="white";else{var C=Math.floor(g/2)-16;I.foreground=["white","green","blue","cyan","red","yellow","magenta"][C]}this.logger.log(2,"MIDROW: "+JSON.stringify(I)),this.writeScreen.setPen(I)},I.outputDataUpdate=function(g){void 0===g&&(g=!1);var I=this.logger.time;null!==I&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,I,this.lastOutputScreen),g&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:I):this.cueStartTime=I,this.lastOutputScreen.copy(this.displayedMemory))},I.cueSplitAtTime=function(g){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,g,this.displayedMemory),this.cueStartTime=g))},g}(),Ri=function(){function g(g,I,C){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var A=new wi;this.channels=[null,new Yi(g,I,A),new Yi(g+1,C,A)],this.cmdHistory={a:null,b:null},this.logger=A}var I=g.prototype;return I.getHandler=function(g){return this.channels[g].getHandler()},I.setHandler=function(g,I){this.channels[g].setHandler(I)},I.addData=function(g,I){var C,A,i,e=!1;this.logger.time=g;for(var t=0;t ("+Wi([A,i])+")"),(C=this.parseCmd(A,i))||(C=this.parseMidrow(A,i)),C||(C=this.parsePAC(A,i)),C||(C=this.parseBackgroundAttributes(A,i)),!C&&(e=this.parseChars(A,i))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(e):this.logger.log(2,"No channel found yet. TEXT-MODE?")}C||e||this.logger.log(2,"Couldn't parse cleaned data "+Wi([A,i])+" orig: "+Wi([I[t],I[t+1]]))}},I.parseCmd=function(g,I){var C=this.cmdHistory;if(!((20===g||28===g||21===g||29===g)&&I>=32&&I<=47||(23===g||31===g)&&I>=33&&I<=35))return!1;if(Hi(g,I,C))return Ni(null,null,C),this.logger.log(3,"Repeated command ("+Wi([g,I])+") is dropped"),!0;var A=20===g||21===g||23===g?1:2,i=this.channels[A];return 20===g||21===g||28===g||29===g?32===I?i.ccRCL():33===I?i.ccBS():34===I?i.ccAOF():35===I?i.ccAON():36===I?i.ccDER():37===I?i.ccRU(2):38===I?i.ccRU(3):39===I?i.ccRU(4):40===I?i.ccFON():41===I?i.ccRDC():42===I?i.ccTR():43===I?i.ccRTD():44===I?i.ccEDM():45===I?i.ccCR():46===I?i.ccENM():47===I&&i.ccEOC():i.ccTO(I-32),Ni(g,I,C),this.currentChannel=A,!0},I.parseMidrow=function(g,I){var C=0;if((17===g||25===g)&&I>=32&&I<=47){if((C=17===g?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var A=this.channels[C];return!!A&&(A.ccMIDROW(I),this.logger.log(3,"MIDROW ("+Wi([g,I])+")"),!0)}return!1},I.parsePAC=function(g,I){var C,A=this.cmdHistory;if(!((g>=17&&g<=23||g>=25&&g<=31)&&I>=64&&I<=127||(16===g||24===g)&&I>=64&&I<=95))return!1;if(Hi(g,I,A))return Ni(null,null,A),!0;var i=g<=23?1:2;C=I>=64&&I<=95?1===i?Zi[g]:Gi[g]:1===i?bi[g]:ui[g];var e=this.channels[i];return!!e&&(e.setPAC(this.interpretPAC(C,I)),Ni(g,I,A),this.currentChannel=i,!0)},I.interpretPAC=function(g,I){var C,A={color:null,italics:!1,indent:null,underline:!1,row:g};return C=I>95?I-96:I-64,A.underline=!(1&~C),C<=13?A.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(C/2)]:C<=15?(A.italics=!0,A.color="white"):A.indent=4*Math.floor((C-16)/2),A},I.parseChars=function(g,I){var C,A,i=null,e=null;if(g>=25?(C=2,e=g-8):(C=1,e=g),e>=17&&e<=19?(A=17===e?I+80:18===e?I+112:I+144,this.logger.log(2,"Special char '"+ri(A)+"' in channel "+C),i=[A]):g>=32&&g<=127&&(i=0===I?[g]:[g,I]),i){var t=Wi(i);this.logger.log(3,"Char codes = "+t.join(",")),Ni(g,I,this.cmdHistory)}return i},I.parseBackgroundAttributes=function(g,I){var C;if(!((16===g||24===g)&&I>=32&&I<=47||(23===g||31===g)&&I>=45&&I<=47))return!1;var A={};16===g||24===g?(C=Math.floor((I-32)/2),A.background=pi[C],I%2==1&&(A.background=A.background+"_semi")):45===I?A.background="transparent":(A.foreground="black",47===I&&(A.underline=!0));var i=g<=23?1:2;return this.channels[i].setBkgData(A),Ni(g,I,this.cmdHistory),!0},I.reset=function(){for(var g=0;gg)&&(this.startTime=g),this.endTime=I,this.screen=C,this.timelineController.createCaptionsTrack(this.trackName)},I.reset=function(){this.cueRanges=[],this.startTime=null},g}(),fi=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var g=["","lr","rl"],I=["start","middle","end","left","right"];function C(g,I){if("string"!=typeof I)return!1;if(!Array.isArray(g))return!1;var C=I.toLowerCase();return!!~g.indexOf(C)&&C}function A(g){return C(I,g)}function i(g){for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A100)throw new Error("Position must be between 0 and 100.");G=g,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},s,{get:function(){return u},set:function(g){var I=A(g);if(!I)throw new SyntaxError("An invalid or illegal string was specified.");u=I,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},s,{get:function(){return p},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");p=g,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},s,{get:function(){return w},set:function(g){var I=A(g);if(!I)throw new SyntaxError("An invalid or illegal string was specified.");w=I,this.hasBeenReset=!0}})),l.displayState=void 0}return e.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},e}(),Fi=function(){function g(){}return g.prototype.decode=function(g,I){if(!g)return"";if("string"!=typeof g)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(g))},g}();function Mi(g){function I(g,I,C,A){return 3600*(0|g)+60*(0|I)+(0|C)+parseFloat(A||0)}var C=g.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?I(C[2],C[3],0,C[4]):I(C[1],C[2],C[3],C[4]):null}var Si=function(){function g(){this.values=Object.create(null)}var I=g.prototype;return I.set=function(g,I){this.get(g)||""===I||(this.values[g]=I)},I.get=function(g,I,C){return C?this.has(g)?this.values[g]:I[C]:this.has(g)?this.values[g]:I},I.has=function(g){return g in this.values},I.alt=function(g,I,C){for(var A=0;A=0&&C<=100)return this.set(g,C),!0}return!1},g}();function Ji(g,I,C,A){var i=A?g.split(A):[g];for(var e in i)if("string"==typeof i[e]){var t=i[e].split(C);2===t.length&&I(t[0],t[1])}}var ki=new fi(0,0,""),Di="middle"===ki.align?"middle":"center";function vi(g,I,C){var A=g;function i(){var I=Mi(g);if(null===I)throw new Error("Malformed timestamp: "+A);return g=g.replace(/^[^\sa-zA-Z-]+/,""),I}function e(){g=g.replace(/^\s+/,"")}if(e(),I.startTime=i(),e(),"--\x3e"!==g.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+A);g=g.slice(3),e(),I.endTime=i(),e(),function(g,I){var A=new Si;Ji(g,(function(g,I){var i;switch(g){case"region":for(var e=C.length-1;e>=0;e--)if(C[e].id===I){A.set(g,C[e].region);break}break;case"vertical":A.alt(g,I,["rl","lr"]);break;case"line":i=I.split(","),A.integer(g,i[0]),A.percent(g,i[0])&&A.set("snapToLines",!1),A.alt(g,i[0],["auto"]),2===i.length&&A.alt("lineAlign",i[1],["start",Di,"end"]);break;case"position":i=I.split(","),A.percent(g,i[0]),2===i.length&&A.alt("positionAlign",i[1],["start",Di,"end","line-left","line-right","auto"]);break;case"size":A.percent(g,I);break;case"align":A.alt(g,I,["start",Di,"end","left","right"])}}),/:/,/\s/),I.region=A.get("region",null),I.vertical=A.get("vertical","");var i=A.get("line","auto");"auto"===i&&-1===ki.line&&(i=-1),I.line=i,I.lineAlign=A.get("lineAlign","start"),I.snapToLines=A.get("snapToLines",!0),I.size=A.get("size",100),I.align=A.get("align",Di);var e=A.get("position","auto");"auto"===e&&50===ki.position&&(e="start"===I.align||"left"===I.align?0:"end"===I.align||"right"===I.align?100:50),I.position=e}(g,I)}function Li(g){return g.replace(//gi,"\n")}var zi=function(){function g(){this.state="INITIAL",this.buffer="",this.decoder=new Fi,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var I=g.prototype;return I.parse=function(g){var I=this;function C(){var g=I.buffer,C=0;for(g=Li(g);C>>0).toString()};function ji(g,I,C){return Ui(g.toString())+Ui(I.toString())+Ui(C)}var Qi="stpp.ttml.im1t",Oi=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ei=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Pi={left:"start",center:"center",right:"end",start:"start",end:"end"};function _i(g,I,C,A){var i=Yg(new Uint8Array(g),["mdat"]);if(0!==i.length){var e,t,s,o=i.map((function(g){return bg(g)})),c=(e=I.baseTime,void 0===(t=I.timescale)&&(t=1),void 0===s&&(s=!1),WA(e,1,1/t,s));try{o.forEach((function(g){return C(function(g,I){var C=(new DOMParser).parseFromString(g,"text/xml").getElementsByTagName("tt")[0];if(!C)throw new Error("Invalid ttml");var A={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(A).reduce((function(g,I){return g[I]=C.getAttribute("ttp:"+I)||A[I],g}),{}),e="preserve"!==C.getAttribute("xml:space"),t=$i(qi(C,"styling","style")),s=$i(qi(C,"layout","region")),o=qi(C,"body","[begin]");return[].map.call(o,(function(g){var C=ge(g,e);if(!C||!g.hasAttribute("begin"))return null;var A=Ae(g.getAttribute("begin"),i),o=Ae(g.getAttribute("dur"),i),c=Ae(g.getAttribute("end"),i);if(null===A)throw Ce(g);if(null===c){if(null===o)throw Ce(g);c=A+o}var d=new fi(A-I,c-I,C);d.id=ji(d.startTime,d.endTime,d.text);var a,n,r,m,h,Z,b=(a=s[g.getAttribute("region")],n=t[g.getAttribute("style")],r=t,m="http://www.w3.org/ns/ttml#styling",h=null,(Z=null!=a&&a.hasAttribute("style")?a.getAttribute("style"):null)&&r.hasOwnProperty(Z)&&(h=r[Z]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(g,I){var C=Ie(n,m,I)||Ie(a,m,I)||Ie(h,m,I);return C&&(g[I]=C),g}),{})),G=b.textAlign;if(G){var u=Pi[G];u&&(d.lineAlign=u),d.align=G}return l(d,b),d})).filter((function(g){return null!==g}))}(g,c))}))}catch(d){A(d)}}else A(new Error("Could not parse IMSC1 mdat"))}function qi(g,I,C){var A=g.getElementsByTagName(I)[0];return A?[].slice.call(A.querySelectorAll(C)):[]}function $i(g){return g.reduce((function(g,I){var C=I.getAttribute("xml:id");return C&&(g[C]=I),g}),{})}function ge(g,I){return[].slice.call(g.childNodes).reduce((function(g,C,A){var i;return"br"===C.nodeName&&A?g+"\n":null!=(i=C.childNodes)&&i.length?ge(C,I):I?g+C.textContent.trim().replace(/\s+/g," "):g+C.textContent}),"")}function Ie(g,I,C){return g&&g.hasAttributeNS(I,C)?g.getAttributeNS(I,C):null}function Ce(g){return new Error("Could not parse ttml timestamp "+g)}function Ae(g,I){if(!g)return null;var C=Mi(g);return null===C&&(Oi.test(g)?C=function(g,I){var C=Oi.exec(g),A=(0|C[4])+(0|C[5])/I.subFrameRate;return 3600*(0|C[1])+60*(0|C[2])+(0|C[3])+A/I.frameRate}(g,I):Ei.test(g)&&(C=function(g,I){var C=Ei.exec(g),A=Number(C[1]);switch(C[2]){case"h":return 3600*A;case"m":return 60*A;case"ms":return 1e3*A;case"f":return A/I.frameRate;case"t":return A/I.tickRate}return A}(g,I))),C}var ie=function(){function g(g){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=g,this.config=g.config,this.Cues=g.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var I=new Ki(this,"textTrack1"),C=new Ki(this,"textTrack2"),A=new Ki(this,"textTrack3"),i=new Ki(this,"textTrack4");this.cea608Parser1=new Ri(1,I,C),this.cea608Parser2=new Ri(3,A,i)}g.on(B.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(B.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(B.MANIFEST_LOADING,this.onManifestLoading,this),g.on(B.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(B.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.on(B.FRAG_LOADING,this.onFragLoading,this),g.on(B.FRAG_LOADED,this.onFragLoaded,this),g.on(B.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.on(B.FRAG_DECRYPTED,this.onFragDecrypted,this),g.on(B.INIT_PTS_FOUND,this.onInitPtsFound,this),g.on(B.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.on(B.BUFFER_FLUSHING,this.onBufferFlushing,this)}var I=g.prototype;return I.destroy=function(){var g=this.hls;g.off(B.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(B.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(B.MANIFEST_LOADING,this.onManifestLoading,this),g.off(B.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(B.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(B.FRAG_LOADING,this.onFragLoading,this),g.off(B.FRAG_LOADED,this.onFragLoaded,this),g.off(B.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(B.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(B.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(B.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(B.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},I.addCues=function(g,I,C,A,i){for(var e,t,l,s,o=!1,c=i.length;c--;){var d=i[c],a=(e=d[0],t=d[1],l=I,s=C,Math.min(t,s)-Math.max(e,l));if(a>=0&&(d[0]=Math.min(d[0],I),d[1]=Math.max(d[1],C),o=!0,a/(C-I)>.5))return}if(o||i.push([I,C]),this.config.renderTextTracksNatively){var n=this.captionsTracks[g];this.Cues.newCue(n,I,C,A)}else{var r=this.Cues.newCue(null,I,C,A);this.hls.trigger(B.CUES_PARSED,{type:"captions",cues:r,track:g})}},I.onInitPtsFound=function(g,I){var C=this,A=I.frag,i=I.id,e=I.initPTS,t=I.timescale,l=this.unparsedVttFrags;"main"===i&&(this.initPTS[A.cc]={baseTime:e,timescale:t}),l.length&&(this.unparsedVttFrags=[],l.forEach((function(g){C.onFragLoaded(B.FRAG_LOADED,g)})))},I.getExistingTrack=function(g){var I=this.media;if(I)for(var C=0;C0&&a.push(g)},c.onparsingerror=function(g){o=g},c.onflush=function(){o?t(o):e(a)},d.forEach((function(g){if(Z){if(xi(g,"X-TIMESTAMP-MAP=")){Z=!1,g.slice(16).split(",").forEach((function(g){xi(g,"LOCAL:")?r=g.slice(6):xi(g,"MPEGTS:")&&(m=parseInt(g.slice(7)))}));try{h=function(g){var I=parseInt(g.slice(-3)),C=parseInt(g.slice(-6,-4)),A=parseInt(g.slice(-9,-7)),i=g.length>9?parseInt(g.substring(0,g.indexOf(":"))):0;if(!(W(I)&&W(C)&&W(A)&&W(i)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+g);return I+=1e3*C,(I+=6e4*A)+36e5*i}(r)/1e3}catch(I){o=I}return}""===g&&(Z=!1)}c.parse(g+"\n")})),c.flush()}(null!=(I=A.initSegment)&&I.data?fg(A.initSegment.data,new Uint8Array(i)):i,this.initPTS[A.cc],this.vttCCs,A.cc,A.start,(function(g){C._appendCues(g,A.level),s.trigger(B.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:A})}),(function(I){var e="Missing initPTS for VTT MPEGTS"===I.message;e?t.push(g):C._fallbackToIMSC1(A,i),H.log("Failed to parse VTT cue: "+I),e&&l>A.cc||s.trigger(B.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:A,error:I})}))}else t.push(g)},I._fallbackToIMSC1=function(g,I){var C=this,A=this.tracks[g.level];A.textCodec||_i(I,this.initPTS[g.cc],(function(){A.textCodec=Qi,C._parseIMSC1(g,I)}),(function(){A.textCodec="wvtt"}))},I._appendCues=function(g,I){var C=this.hls;if(this.config.renderTextTracksNatively){var A=this.textTracks[I];if(!A||"disabled"===A.mode)return;g.forEach((function(g){return uI(A,g)}))}else{var i=this.tracks[I];if(!i)return;var e=i.default?"default":"subtitles"+I;C.trigger(B.CUES_PARSED,{type:"subtitles",cues:g,track:e})}},I.onFragDecrypted=function(g,I){I.frag.type===mI&&this.onFragLoaded(B.FRAG_LOADED,I)},I.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},I.onFragParsingUserdata=function(g,I){var C=this.cea608Parser1,A=this.cea608Parser2;if(this.enabled&&C&&A){var i=I.frag,e=I.samples;if(i.type!==nI||"NONE"!==this.closedCaptionsForLevel(i))for(var t=0;t0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var I=this.hls;I.autoLevelCapping=this.getMaxLevel(g.length-1),I.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=I.autoLevelCapping}}},I.getMaxLevel=function(I){var C=this,A=this.hls.levels;if(!A.length)return-1;var i=A.filter((function(g,A){return C.isLevelAllowed(g)&&A<=I}));return this.clientRect=null,g.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},I.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},I.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},I.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,I={width:0,height:0};if(g){var C=g.getBoundingClientRect();I.width=C.width,I.height=C.height,I.width||I.height||(I.width=C.right-C.left||g.width||0,I.height=C.bottom-C.top||g.height||0)}return this.clientRect=I,I},I.isLevelAllowed=function(g){return!this.restrictedLevels.some((function(I){return g.bitrate===I.bitrate&&g.width===I.width&&g.height===I.height}))},g.getMaxLevelByMediaSize=function(g,I,C){if(null==g||!g.length)return-1;for(var A,i,e=g.length-1,t=0;t=I||l.height>=C)&&(A=l,!(i=g[t+1])||A.width!==i.width||A.height!==i.height)){e=t;break}}return e},e(g,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var g=1;if(!this.hls.config.ignoreDevicePixelRatio)try{g=self.devicePixelRatio}catch(I){}return g}}]),g}(),le=function(){function g(g){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=g,this.registerListeners()}var I=g.prototype;return I.setStreamController=function(g){this.streamController=g},I.registerListeners=function(){this.hls.on(B.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(B.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(g,I){var C=this.hls.config;if(C.capLevelOnFPSDrop){var A=I.media instanceof self.HTMLVideoElement?I.media:null;this.media=A,A&&"function"==typeof A.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),C.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(g,I,C){var A=performance.now();if(I){if(this.lastTime){var i=A-this.lastTime,e=C-this.lastDroppedFrames,t=I-this.lastDecodedFrames,l=1e3*e/i,s=this.hls;if(s.trigger(B.FPS_DROP,{currentDropped:e,currentDecoded:t,totalDroppedFrames:C}),l>0&&e>s.config.fpsDroppedMonitoringThreshold*t){var o=s.currentLevel;H.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(-1===s.autoLevelCapping||s.autoLevelCapping>=o)&&(o-=1,s.trigger(B.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:s.currentLevel}),s.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=A,this.lastDroppedFrames=C,this.lastDecodedFrames=I}},I.checkFPSInterval=function(){var g=this.media;if(g)if(this.isVideoPlaybackQualityAvailable){var I=g.getVideoPlaybackQuality();this.checkFPS(g,I.totalVideoFrames,I.droppedVideoFrames)}else this.checkFPS(g,g.webkitDecodedFrameCount,g.webkitDroppedFrameCount)},g}(),se="[eme]",oe=function(){function g(I){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=g.CDMCleanupPromise?[g.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=H.debug.bind(H,se),this.log=H.log.bind(H,se),this.warn=H.warn.bind(H,se),this.error=H.error.bind(H,se),this.hls=I,this.config=I.config,this.registerListeners()}var I=g.prototype;return I.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var g=this.config;g.requestMediaKeySystemAccessFunc=null,g.licenseXhrSetup=g.licenseResponseCallback=void 0,g.drmSystems=g.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},I.registerListeners=function(){this.hls.on(B.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(B.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(B.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(B.MANIFEST_LOADED,this.onManifestLoaded,this)},I.unregisterListeners=function(){this.hls.off(B.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(B.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(B.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(B.MANIFEST_LOADED,this.onManifestLoaded,this)},I.getLicenseServerUrl=function(g){var I=this.config,C=I.drmSystems,A=I.widevineLicenseUrl,i=C[g];if(i)return i.licenseUrl;if(g===Q.WIDEVINE&&A)return A;throw new Error('no license server URL configured for key-system "'+g+'"')},I.getServerCertificateUrl=function(g){var I=this.config.drmSystems[g];if(I)return I.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+g+'"]')},I.attemptKeySystemAccess=function(g){var I=this,C=this.hls.levels,A=function(g,I,C){return!!g&&C.indexOf(g)===I},i=C.map((function(g){return g.audioCodec})).filter(A),e=C.map((function(g){return g.videoCodec})).filter(A);return i.length+e.length===0&&e.push("avc1.42e01e"),new Promise((function(C,A){!function g(t){var l=t.shift();I.getMediaKeysPromise(l,i,e).then((function(g){return C({keySystem:l,mediaKeys:g})})).catch((function(I){t.length?g(t):A(I instanceof ce?I:new ce({type:y.KEY_SYSTEM_ERROR,details:V.KEY_SYSTEM_NO_ACCESS,error:I,fatal:!0},I.message))}))}(g)}))},I.requestMediaKeySystemAccess=function(g,I){var C=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof C){var A="Configured requestMediaKeySystemAccess is not a function "+C;return null===Cg&&"http:"===self.location.protocol&&(A="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(A))}return C(g,I)},I.getMediaKeysPromise=function(g,I,C){var A=this,i=function(g,I,C,A){var i,e,t,l;switch(g){case Q.FAIRPLAY:i=["cenc","sinf"];break;case Q.WIDEVINE:case Q.PLAYREADY:i=["cenc"];break;case Q.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+g)}return e=I,t=C,[{initDataTypes:i,persistentState:(l=A).persistentState||"not-allowed",distinctiveIdentifier:l.distinctiveIdentifier||"not-allowed",sessionTypes:l.sessionTypes||[l.sessionType||"temporary"],audioCapabilities:e.map((function(g){return{contentType:'audio/mp4; codecs="'+g+'"',robustness:l.audioRobustness||"",encryptionScheme:l.audioEncryptionScheme||null}})),videoCapabilities:t.map((function(g){return{contentType:'video/mp4; codecs="'+g+'"',robustness:l.videoRobustness||"",encryptionScheme:l.videoEncryptionScheme||null}}))}]}(g,I,C,this.config.drmSystemOptions),e=this.keySystemAccessPromises[g],t=null==e?void 0:e.keySystemAccess;if(!t){this.log('Requesting encrypted media "'+g+'" key-system access with config: '+JSON.stringify(i)),t=this.requestMediaKeySystemAccess(g,i);var l=this.keySystemAccessPromises[g]={keySystemAccess:t};return t.catch((function(I){A.log('Failed to obtain access to key-system "'+g+'": '+I)})),t.then((function(I){A.log('Access for key-system "'+I.keySystem+'" obtained');var C=A.fetchServerCertificate(g);return A.log('Create media-keys for "'+g+'"'),l.mediaKeys=I.createMediaKeys().then((function(I){return A.log('Media-keys created for "'+g+'"'),C.then((function(C){return C?A.setMediaKeysServerCertificate(I,g,C):I}))})),l.mediaKeys.catch((function(I){A.error('Failed to create media-keys for "'+g+'"}: '+I)})),l.mediaKeys}))}return t.then((function(){return e.mediaKeys}))},I.createMediaKeySessionContext=function(g){var I=g.decryptdata,C=g.keySystem,A=g.mediaKeys;this.log('Creating key-system session "'+C+'" keyId: '+Gg(I.keyId||[]));var i=A.createSession(),e={decryptdata:I,keySystem:C,mediaKeys:A,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(e),e},I.renewKeySession=function(g){var I=g.decryptdata;if(I.pssh){var C=this.createMediaKeySessionContext(g),A=this.getKeyIdString(I);this.keyIdToKeySessionPromise[A]=this.generateRequestWithPreferredKeySession(C,"cenc",I.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(g)},I.getKeyIdString=function(g){if(!g)throw new Error("Could not read keyId of undefined decryptdata");if(null===g.keyId)throw new Error("keyId is null");return Gg(g.keyId)},I.updateKeySession=function(g,I){var C,A=g.mediaKeysSession;return this.log('Updating key-session "'+A.sessionId+'" for keyID '+Gg((null==(C=g.decryptdata)?void 0:C.keyId)||[])+"\n } (data length: "+(I?I.byteLength:I)+")"),A.update(I)},I.selectKeySystemFormat=function(g){var I=Object.keys(g.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+g.sn+" "+g.type+": "+g.level+") key formats "+I.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(I)),this.keyFormatPromise},I.getKeyFormatPromise=function(g){var I=this;return new Promise((function(C,A){var i=Ig(I.config),e=g.map(q).filter((function(g){return!!g&&-1!==i.indexOf(g)}));return I.getKeySystemSelectionPromise(e).then((function(g){var I=g.keySystem,i=gg(I);i?C(i):A(new Error('Unable to find format for key-system "'+I+'"'))})).catch(A)}))},I.loadKey=function(g){var I=this,C=g.keyInfo.decryptdata,A=this.getKeyIdString(C),i="(keyId: "+A+' format: "'+C.keyFormat+'" method: '+C.method+" uri: "+C.uri+")";this.log("Starting session for key "+i);var e=this.keyIdToKeySessionPromise[A];return e||(e=this.keyIdToKeySessionPromise[A]=this.getKeySystemForKeyPromise(C).then((function(A){var e=A.keySystem,t=A.mediaKeys;return I.throwIfDestroyed(),I.log("Handle encrypted media sn: "+g.frag.sn+" "+g.frag.type+": "+g.frag.level+" using key "+i),I.attemptSetMediaKeys(e,t).then((function(){I.throwIfDestroyed();var g=I.createMediaKeySessionContext({keySystem:e,mediaKeys:t,decryptdata:C});return I.generateRequestWithPreferredKeySession(g,"cenc",C.pssh,"playlist-key")}))}))).catch((function(g){return I.handleError(g)})),e},I.throwIfDestroyed=function(g){if(!this.hls)throw new Error("invalid state")},I.handleError=function(g){this.hls&&(this.error(g.message),g instanceof ce?this.hls.trigger(B.ERROR,g.data):this.hls.trigger(B.ERROR,{type:y.KEY_SYSTEM_ERROR,details:V.KEY_SYSTEM_NO_KEYS,error:g,fatal:!0}))},I.getKeySystemForKeyPromise=function(g){var I=this.getKeyIdString(g),C=this.keyIdToKeySessionPromise[I];if(!C){var A=q(g.keyFormat),i=A?[A]:Ig(this.config);return this.attemptKeySystemAccess(i)}return C},I.getKeySystemSelectionPromise=function(g){if(g.length||(g=Ig(this.config)),0===g.length)throw new ce({type:y.KEY_SYSTEM_ERROR,details:V.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(g)},I._onMediaEncrypted=function(g){var I=this,C=g.initDataType,A=g.initData;if(this.debug('"'+g.type+'" event: init data type: "'+C+'"'),null!==A){var i,e;if("sinf"===C&&this.config.drmSystems[Q.FAIRPLAY]){var t=Wg(new Uint8Array(A));try{var l=U(JSON.parse(t).sinf),s=Hg(new Uint8Array(l));if(!s)return;i=s.subarray(8,24),e=Q.FAIRPLAY}catch(Z){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var o=function(g){if(!(g instanceof ArrayBuffer)||g.byteLength<32)return null;var I={version:0,systemId:"",kids:null,data:null},C=new DataView(g),A=C.getUint32(0);if(g.byteLength!==A&&A>44)return null;if(1886614376!==C.getUint32(4))return null;if(I.version=C.getUint32(8)>>>24,I.version>1)return null;I.systemId=Gg(new Uint8Array(g,12,16));var i=C.getUint32(28);if(0===I.version){if(A-32d||l.status>=400&&l.status<500)e(new ce({type:y.KEY_SYSTEM_ERROR,details:V.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:l,response:{url:t,data:void 0,code:l.status,text:l.statusText}},"License Request XHR failed ("+t+"). Status: "+l.status+" ("+l.statusText+")"));else{var a=d-C._requestLicenseFailureCount+1;C.warn("Retrying license request, "+a+" attempts left"),C.requestLicense(g,I).then(i,e)}}},g.licenseXhr&&g.licenseXhr.readyState!==XMLHttpRequest.DONE&&g.licenseXhr.abort(),g.licenseXhr=l,C.setupLicenseXHR(l,t,g,I).then((function(g){var I=g.xhr,C=g.licenseChallenge;I.send(C)}))}))},I.onMediaAttached=function(g,I){if(this.config.emeEnabled){var C=I.media;this.media=C,C.addEventListener("encrypted",this.onMediaEncrypted),C.addEventListener("waitingforkey",this.onWaitingForKey)}},I.onMediaDetached=function(){var I=this,C=this.media,A=this.mediaKeySessions;C&&(C.removeEventListener("encrypted",this.onMediaEncrypted),C.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Dg.clearKeyUriToKeyIdMap();var i=A.length;g.CDMCleanupPromise=Promise.all(A.map((function(g){return I.removeSession(g)})).concat(null==C?void 0:C.setMediaKeys(null).catch((function(g){I.log("Could not clear media keys: "+g+". media.src: "+(null==C?void 0:C.src))})))).then((function(){i&&(I.log("finished closing key sessions and clearing media keys"),A.length=0)})).catch((function(g){I.log("Could not close sessions and clear media keys: "+g+". media.src: "+(null==C?void 0:C.src))}))},I.onManifestLoading=function(){this.keyFormatPromise=null},I.onManifestLoaded=function(g,I){var C=I.sessionKeys;if(C&&this.config.emeEnabled&&!this.keyFormatPromise){var A=C.reduce((function(g,I){return-1===g.indexOf(I.keyFormat)&&g.push(I.keyFormat),g}),[]);this.log("Selecting key-system from session-keys "+A.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(A)}},I.removeSession=function(g){var I=this,C=g.mediaKeysSession,A=g.licenseXhr;if(C){this.log("Remove licenses and keys and close session "+C.sessionId),C.onmessage=null,C.onkeystatuseschange=null,A&&A.readyState!==XMLHttpRequest.DONE&&A.abort(),g.mediaKeysSession=g.decryptdata=g.licenseXhr=void 0;var i=this.mediaKeySessions.indexOf(g);return i>-1&&this.mediaKeySessions.splice(i,1),C.remove().catch((function(g){I.log("Could not remove session: "+g)})).then((function(){return C.close()})).catch((function(g){I.log("Could not close session: "+g)}))}},g}();oe.CDMCleanupPromise=void 0;var ce=function(g){function I(I,C){var A;return(A=g.call(this,C)||this).data=void 0,I.error||(I.error=new Error(C)),A.data=I,I.err=I.error,A}return s(I,g),I}(a(Error)),de="a",ae="av",ne=function(){function g(I){var C=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){C.initialized&&(C.starved=!0),C.buffering=!0},this.onPlaying=function(){C.initialized||(C.initialized=!0),C.buffering=!1},this.applyPlaylistData=function(g){try{C.apply(g,{ot:"m",su:!C.initialized})}catch(I){H.warn("Could not generate manifest CMCD data.",I)}},this.applyFragmentData=function(g){try{var I=g.frag,A=C.hls.levels[I.level],i=C.getObjectType(I),e={d:1e3*I.duration,ot:i};"v"!==i&&i!==de&&i!=ae||(e.br=A.bitrate/1e3,e.tb=C.getTopBandwidth(i)/1e3,e.bl=C.getBufferLength(i)),C.apply(g,e)}catch(t){H.warn("Could not generate segment CMCD data.",t)}},this.hls=I;var A=this.config=I.config,i=A.cmcd;null!=i&&(A.pLoader=this.createPlaylistLoader(),A.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||g.uuid(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.registerListeners())}var I=g.prototype;return I.registerListeners=function(){var g=this.hls;g.on(B.MEDIA_ATTACHED,this.onMediaAttached,this),g.on(B.MEDIA_DETACHED,this.onMediaDetached,this),g.on(B.BUFFER_CREATED,this.onBufferCreated,this)},I.unregisterListeners=function(){var g=this.hls;g.off(B.MEDIA_ATTACHED,this.onMediaAttached,this),g.off(B.MEDIA_DETACHED,this.onMediaDetached,this),g.off(B.BUFFER_CREATED,this.onBufferCreated,this)},I.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},I.onMediaAttached=function(g,I){this.media=I.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},I.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},I.onBufferCreated=function(g,I){var C,A;this.audioBuffer=null==(C=I.tracks.audio)?void 0:C.buffer,this.videoBuffer=null==(A=I.tracks.video)?void 0:A.buffer},I.createData=function(){var g;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(g=this.media)?void 0:g.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},I.apply=function(I,C){void 0===C&&(C={}),l(C,this.createData());var A="i"===C.ot||"v"===C.ot||C.ot===ae;if(this.starved&&A&&(C.bs=!0,C.su=!0,this.starved=!1),null==C.su&&(C.su=this.buffering),this.useHeaders){var i=g.toHeaders(C);if(!Object.keys(i).length)return;I.headers||(I.headers={}),l(I.headers,i)}else{var e=g.toQuery(C);if(!e)return;I.url=g.appendQueryToUri(I.url,e)}},I.getObjectType=function(g){var I=g.type;return"subtitle"===I?"tt":"initSegment"===g.sn?"i":"audio"===I?de:"main"===I?this.hls.audioTracks.length?"v":ae:void 0},I.getTopBandwidth=function(g){var I,C=0,A=this.hls;if(g===de)I=A.audioTracks;else{var i=A.maxAutoLevel,e=i>-1?i+1:A.levels.length;I=A.levels.slice(0,e)}for(var t,l=r(I);!(t=l()).done;){var s=t.value;s.bitrate>C&&(C=s.bitrate)}return C>0?C:NaN},I.getBufferLength=function(g){var I=this.hls.media,C=g===de?this.audioBuffer:this.videoBuffer;return C&&I?1e3*mC.bufferInfo(C,I.currentTime,this.config.maxBufferHole).len:NaN},I.createPlaylistLoader=function(){var g=this.config.pLoader,I=this.applyPlaylistData,C=g||this.config.loader;return function(){function g(g){this.loader=void 0,this.loader=new C(g)}var A=g.prototype;return A.destroy=function(){this.loader.destroy()},A.abort=function(){this.loader.abort()},A.load=function(g,C,A){I(g),this.loader.load(g,C,A)},e(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},I.createFragmentLoader=function(){var g=this.config.fLoader,I=this.applyFragmentData,C=g||this.config.loader;return function(){function g(g){this.loader=void 0,this.loader=new C(g)}var A=g.prototype;return A.destroy=function(){this.loader.destroy()},A.abort=function(){this.loader.abort()},A.load=function(g,C,A){I(g),this.loader.load(g,C,A)},e(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},g.uuid=function(){var g=URL.createObjectURL(new Blob),I=g.toString();return URL.revokeObjectURL(g),I.slice(I.lastIndexOf("/")+1)},g.serialize=function(g){for(var I,C=[],A=function(g){return Math.round(g)},i=function(g){return 100*A(g/100)},e={br:A,d:A,bl:i,dl:i,mtp:i,nor:function(g){return encodeURIComponent(g)},rtp:i,tb:A},t=r(Object.keys(g||{}).sort());!(I=t()).done;){var l=I.value,s=g[l];if(!(a=s,Number.isNaN(a)||null==a||""===a||!1===a||"v"===l&&1===s||"pr"==l&&1===s)){var o=e[l];o&&(s=o(s));var c,d=typeof s;c="ot"===l||"sf"===l||"st"===l?l+"="+s:"boolean"===d?l:"number"===d?l+"="+s:l+"="+JSON.stringify(s),C.push(c)}}var a;return C.join(",")},g.toHeaders=function(I){for(var C={},A=["Object","Request","Session","Status"],i=[{},{},{},{}],e={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},t=0,l=Object.keys(I);t1&&(this.updatePathwayPriority(A),C.resolved=this.pathwayId!==i)}},I.filterParsedLevels=function(g){this.levels=g;var I=this.getLevelsForPathway(this.pathwayId);if(0===I.length){var C=g[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+C+'"'),I=this.getLevelsForPathway(C),this.pathwayId=C}return I.length!==g.length?(this.log("Found "+I.length+"/"+g.length+' levels in Pathway "'+this.pathwayId+'"'),I):g},I.getLevelsForPathway=function(g){return null===this.levels?[]:this.levels.filter((function(I){return g===I.pathwayId}))},I.updatePathwayPriority=function(g){var I;this.pathwayPriority=g;var C=this.penalizedPathways,A=performance.now();Object.keys(C).forEach((function(g){A-C[g]>3e5&&delete C[g]}));for(var i=0;i0){this.log('Setting Pathway to "'+e+'"'),this.pathwayId=e,this.hls.trigger(B.LEVELS_UPDATED,{levels:I});var s=this.hls.levels[t];l&&s&&this.levels&&(s.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&s.bitrate!==l.bitrate&&this.log("Unstable Pathways change from bitrate "+l.bitrate+" to "+s.bitrate),this.hls.nextLoadLevel=t);break}}}},I.clonePathways=function(g){var I=this,C=this.levels;if(C){var A={},i={};g.forEach((function(g){var e=g.ID,t=g["BASE-ID"],s=g["URI-REPLACEMENT"];if(!C.some((function(g){return g.pathwayId===e}))){var o=I.getLevelsForPathway(t).map((function(g){var I=l({},g);I.details=void 0,I.url=he(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s);var C=new F(g.attrs);C["PATHWAY-ID"]=e;var t=C.AUDIO&&C.AUDIO+"_clone_"+e,o=C.SUBTITLES&&C.SUBTITLES+"_clone_"+e;t&&(A[C.AUDIO]=t,C.AUDIO=t),o&&(i[C.SUBTITLES]=o,C.SUBTITLES=o),I.attrs=C;var c=new KI(I);return qI(c,"audio",t),qI(c,"text",o),c}));C.push.apply(C,o),me(I.audioTracks,A,s,e),me(I.subtitleTracks,i,s,e)}}))}},I.loadSteeringManifest=function(g){var I,C=this,A=this.hls.config,i=A.loader;this.loader&&this.loader.destroy(),this.loader=new i(A);try{I=new self.URL(g)}catch(d){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+g)}if("data:"!==I.protocol){var e=0|(this.hls.bandwidthEstimate||A.abrEwmaDefaultEstimate);I.searchParams.set("_HLS_pathway",this.pathwayId),I.searchParams.set("_HLS_throughput",""+e)}var t={responseType:"json",url:I.href},l=A.steeringManifestLoadPolicy.default,s=l.errorRetry||l.timeoutRetry||{},o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},c={onSuccess:function(g,A,i,e){C.log('Loaded steering manifest: "'+I+'"');var t=g.data;if(1===t.VERSION){C.updated=performance.now(),C.timeToLoad=t.TTL;var l=t["RELOAD-URI"],s=t["PATHWAY-CLONES"],o=t["PATHWAY-PRIORITY"];if(l)try{C.uri=new self.URL(l,I).href}catch(c){return C.enabled=!1,void C.log("Failed to parse Steering Manifest RELOAD-URI: "+l)}C.scheduleRefresh(C.uri||i.url),s&&C.clonePathways(s),o&&C.updatePathwayPriority(o)}else C.log("Steering VERSION "+t.VERSION+" not supported!")},onError:function(g,I,A,i){if(C.log("Error loading steering manifest: "+g.code+" "+g.text+" ("+I.url+")"),C.stopLoad(),410===g.code)return C.enabled=!1,void C.log("Steering manifest "+I.url+" no longer available");var e=1e3*C.timeToLoad;if(429!==g.code)C.scheduleRefresh(C.uri||I.url,e);else{var t=C.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){var l=t.getResponseHeader("Retry-After");l&&(e=1e3*parseFloat(l))}C.log("Steering manifest "+I.url+" rate limited")}},onTimeout:function(g,I,A){C.log("Timeout loading steering manifest ("+I.url+")"),C.scheduleRefresh(C.uri||I.url)}};this.log("Requesting steering manifest: "+I),this.loader.load(t,o,c)},I.scheduleRefresh=function(g,I){var C=this;void 0===I&&(I=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((function(){C.loadSteeringManifest(g)}),I)},g}();function me(g,I,C,A){g&&Object.keys(I).forEach((function(i){var e=g.filter((function(g){return g.groupId===i})).map((function(g){var e=l({},g);return e.details=void 0,e.attrs=new F(e.attrs),e.url=e.attrs.URI=he(g.url,g.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",C),e.groupId=e.attrs["GROUP-ID"]=I[i],e.attrs["PATHWAY-ID"]=A,e}));g.push.apply(g,e)}))}function he(g,I,C,A){var i,e=A.HOST,t=A.PARAMS,l=A[C];I&&(i=null==l?void 0:l[I])&&(g=i);var s=new self.URL(g);return e&&!i&&(s.host=e),t&&Object.keys(t).sort().forEach((function(g){g&&s.searchParams.set(g,t[g])})),s.href}var Ze=/^age:\s*[\d.]+\s*$/im,be=function(){function g(g){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=g&&g.xhrSetup||null,this.stats=new J,this.retryDelay=0}var I=g.prototype;return I.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},I.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,4!==g.readyState&&(this.stats.aborted=!0,g.abort()))},I.abort=function(){var g;this.abortInternal(),null!=(g=this.callbacks)&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},I.load=function(g,I,C){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=I,this.callbacks=C,this.loadInternal()},I.loadInternal=function(){var g=this,I=this.config,C=this.context;if(I){var A=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;var e=this.xhrSetup;e?Promise.resolve().then((function(){if(!g.stats.aborted)return e(A,C.url)})).catch((function(g){return A.open("GET",C.url,!0),e(A,C.url)})).then((function(){g.stats.aborted||g.openAndSendXhr(A,C,I)})).catch((function(I){g.callbacks.onError({code:A.status,text:I.message},C,A,i)})):this.openAndSendXhr(A,C,I)}},I.openAndSendXhr=function(g,I,C){g.readyState||g.open("GET",I.url,!0);var A=this.context.headers,i=C.loadPolicy,e=i.maxTimeToFirstByteMs,t=i.maxLoadTimeMs;if(A)for(var l in A)g.setRequestHeader(l,A[l]);I.rangeEnd&&g.setRequestHeader("Range","bytes="+I.rangeStart+"-"+(I.rangeEnd-1)),g.onreadystatechange=this.readystatechange.bind(this),g.onprogress=this.loadprogress.bind(this),g.responseType=I.responseType,self.clearTimeout(this.requestTimeout),C.timeout=e&&W(e)?e:t,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),C.timeout),g.send()},I.readystatechange=function(){var g=this.context,I=this.loader,C=this.stats;if(g&&I){var A=I.readyState,i=this.config;if(!C.aborted&&A>=2&&(0===C.loading.first&&(C.loading.first=Math.max(self.performance.now(),C.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(C.loading.first-C.loading.start)))),4===A)){self.clearTimeout(this.requestTimeout),I.onreadystatechange=null,I.onprogress=null;var e=I.status,t="text"!==I.responseType;if(e>=200&&e<300&&(t&&I.response||null!==I.responseText)){C.loading.end=Math.max(self.performance.now(),C.loading.first);var l=t?I.response:I.responseText,s="arraybuffer"===I.responseType?l.byteLength:l.length;if(C.loaded=C.total=s,C.bwEstimate=8e3*C.total/(C.loading.end-C.loading.first),!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(C,g,l,I),!this.callbacks)return;var c={url:I.responseURL,data:l,code:e};this.callbacks.onSuccess(c,C,g,I)}else{var d=i.loadPolicy.errorRetry;TI(d,C.retry,!1,e)?this.retry(d):(H.error(e+" while loading "+g.url),this.callbacks.onError({code:e,text:I.statusText},g,I,C))}}}},I.loadtimeout=function(){var g,I=null==(g=this.config)?void 0:g.loadPolicy.timeoutRetry;if(TI(I,this.stats.retry,!0))this.retry(I);else{H.warn("timeout while loading "+this.context.url);var C=this.callbacks;C&&(this.abortInternal(),C.onTimeout(this.stats,this.context,this.loader))}},I.retry=function(g){var I=this.context,C=this.stats;this.retryDelay=LI(g,C.retry),C.retry++,H.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+I.url+", retrying "+C.retry+"/"+g.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},I.loadprogress=function(g){var I=this.stats;I.loaded=g.loaded,g.lengthComputable&&(I.total=g.total)},I.getCacheAge=function(){var g=null;if(this.loader&&Ze.test(this.loader.getAllResponseHeaders())){var I=this.loader.getResponseHeader("age");g=I?parseFloat(I):null}return g},I.getResponseHeader=function(g){return this.loader&&new RegExp("^"+g+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(g):null},g}(),Ge=/(\d+)-(\d+)\/(\d+)/,ue=function(){function g(g){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=g.fetchSetup||pe,this.controller=new self.AbortController,this.stats=new J}var I=g.prototype;return I.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},I.abortInternal=function(){var g=this.response;null!=g&&g.ok||(this.stats.aborted=!0,this.controller.abort())},I.abort=function(){var g;this.abortInternal(),null!=(g=this.callbacks)&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},I.load=function(g,I,C){var A=this,i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();var e,t,s,o=(e=g,t=this.controller.signal,s={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(l({},e.headers))},e.rangeEnd&&s.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),s),c=C.onProgress,d="arraybuffer"===g.responseType,a=d?"byteLength":"length",n=I.loadPolicy,r=n.maxTimeToFirstByteMs,m=n.maxLoadTimeMs;this.context=g,this.config=I,this.callbacks=C,this.request=this.fetchSetup(g,o),self.clearTimeout(this.requestTimeout),I.timeout=r&&W(r)?r:m,this.requestTimeout=self.setTimeout((function(){A.abortInternal(),C.onTimeout(i,g,A.response)}),I.timeout),self.fetch(this.request).then((function(e){A.response=A.loader=e;var t=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(A.requestTimeout),I.timeout=m,A.requestTimeout=self.setTimeout((function(){A.abortInternal(),C.onTimeout(i,g,A.response)}),m-(t-i.loading.start)),!e.ok){var l=e.status,s=e.statusText;throw new we(s||"fetch, bad network response",l,e)}return i.loading.first=t,i.total=function(g){var I=g.get("Content-Range");if(I){var C=function(g){var I=Ge.exec(g);if(I)return parseInt(I[2])-parseInt(I[1])+1}(I);if(W(C))return C}var A=g.get("Content-Length");if(A)return parseInt(A)}(e.headers)||i.total,c&&W(I.highWaterMark)?A.loadProgressively(e,i,g,I.highWaterMark,c):d?e.arrayBuffer():"json"===g.responseType?e.json():e.text()})).then((function(e){var t=A.response;self.clearTimeout(A.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);var l=e[a];l&&(i.loaded=i.total=l);var s={url:t.url,data:e,code:t.status};c&&!W(I.highWaterMark)&&c(i,g,e,t),C.onSuccess(s,i,g,t)})).catch((function(I){if(self.clearTimeout(A.requestTimeout),!i.aborted){var e=I&&I.code||0,t=I?I.message:null;C.onError({code:e,text:t},g,I?I.details:null,i)}}))},I.getCacheAge=function(){var g=null;if(this.response){var I=this.response.headers.get("age");g=I?parseFloat(I):null}return g},I.getResponseHeader=function(g){return this.response?this.response.headers.get(g):null},I.loadProgressively=function(g,I,C,A,i){void 0===A&&(A=0);var e=new gi,t=g.body.getReader();return function l(){return t.read().then((function(t){if(t.done)return e.dataLength&&i(I,C,e.flush(),g),Promise.resolve(new ArrayBuffer(0));var s=t.value,o=s.length;return I.loaded+=o,o=A&&i(I,C,e.flush(),g)):i(I,C,s,g),l()})).catch((function(){return Promise.reject()}))}()},g}();function pe(g,I){return new self.Request(g.url,I)}var we=function(g){function I(I,C,A){var i;return(i=g.call(this,I)||this).code=void 0,i.details=void 0,i.code=C,i.details=A,i}return s(I,g),I}(a(Error)),We=/\s/,Be=A(A({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:be,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$A,bufferController:ai,capLevelController:te,errorController:EI,fpsController:le,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Cg,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(g,I,C,A){for(var i,e,t,l,s,o=[],c=self.VTTCue||self.TextTrackCue,d=0;d=16?l--:l++;var r=Li(s.trim()),m=ji(I,C,r);null!=g&&null!=(a=g.cues)&&a.getCueById(m)||((e=new c(I,C,r)).id=m,e.line=d+1,e.align="left",e.position=10+Math.min(80,10*Math.floor(8*l/32)),o.push(e))}return g&&o.length&&(o.sort((function(g,I){return"auto"===g.line||"auto"===I.line?0:g.line>8&&I.line>8?I.line-g.line:g.line-I.line})),o.forEach((function(I){return uI(g,I)}))),o}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:ei,subtitleTrackController:li,timelineController:ie,audioStreamController:Ii,audioTrackController:Ci,emeController:oe,cmcdController:ne,contentSteeringController:re});function ye(g){return g&&"object"==typeof g?Array.isArray(g)?g.map(ye):Object.keys(g).reduce((function(I,C){return I[C]=ye(g[C]),I}),{}):g}var Ve=function(){function g(I){void 0===I&&(I={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new TA,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,N(I.debug||!1,"Hls instance");var C=this.config=function(g,I){if((I.liveSyncDurationCount||I.liveMaxLatencyDurationCount)&&(I.liveSyncDuration||I.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==I.liveMaxLatencyDurationCount&&(void 0===I.liveSyncDurationCount||I.liveMaxLatencyDurationCount<=I.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==I.liveMaxLatencyDuration&&(void 0===I.liveSyncDuration||I.liveMaxLatencyDuration<=I.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var C=ye(g),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(g){var A=("level"===g?"playlist":g)+"LoadPolicy",e=void 0===I[A],t=[];i.forEach((function(i){var l=g+"Loading"+i,s=I[l];if(void 0!==s&&e){t.push(l);var o=C[A].default;switch(I[A]={default:o},i){case"TimeOut":o.maxLoadTimeMs=s,o.maxTimeToFirstByteMs=s;break;case"MaxRetry":o.errorRetry.maxNumRetry=s,o.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":o.errorRetry.retryDelayMs=s,o.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":o.errorRetry.maxRetryDelayMs=s,o.timeoutRetry.maxRetryDelayMs=s}}})),t.length&&H.warn('hls.js config: "'+t.join('", "')+'" setting(s) are deprecated, use "'+A+'": '+JSON.stringify(I[A]))})),A(A({},C),I)}(g.DefaultConfig,I);this.userConfig=I,this._autoLevelCapping=-1,C.progressive&&function(g){var I=g.loader;I!==ue&&I!==be?(H.log("[config]: Custom loader detected, cannot enable progressive streaming"),g.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(g){}return!1}()&&(g.loader=ue,g.progressive=!0,g.enableSoftwareAES=!0,H.log("[config]: Progressive streaming enabled, using FetchLoader"))}(C);var i=C.abrController,e=C.bufferController,t=C.capLevelController,l=C.errorController,s=C.fpsController,o=new l(this),c=this.abrController=new i(this),d=this.bufferController=new e(this),a=this.capLevelController=new t(this),n=new s(this),r=new bI(this),m=new YI(this),h=C.contentSteeringController,Z=h?new h(this):null,b=this.levelController=new _I(this,Z),G=new iC(this),u=new aC(this.config),p=this.streamController=new PA(this,G,u);a.setStreamController(p),n.setStreamController(p);var w=[r,b,p];Z&&w.splice(1,0,Z),this.networkControllers=w;var W=[c,d,a,n,m,G];this.audioTrackController=this.createController(C.audioTrackController,w);var y=C.audioStreamController;y&&w.push(new y(this,G,u)),this.subtitleTrackController=this.createController(C.subtitleTrackController,w);var V=C.subtitleStreamController;V&&w.push(new V(this,G,u)),this.createController(C.timelineController,W),u.emeController=this.emeController=this.createController(C.emeController,W),this.cmcdController=this.createController(C.cmcdController,W),this.latencyController=this.createController(RI,W),this.coreComponents=W,w.push(o);var X=o.onErrorOut;"function"==typeof X&&this.on(B.ERROR,X,o)}g.isSupported=function(){return function(){var g=jg();if(!g)return!1;var I=kC(),C=g&&"function"==typeof g.isTypeSupported&&g.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),A=!I||I.prototype&&"function"==typeof I.prototype.appendBuffer&&"function"==typeof I.prototype.remove;return!!C&&!!A}()};var I=g.prototype;return I.createController=function(g,I){if(g){var C=new g(this);return I&&I.push(C),C}return null},I.on=function(g,I,C){void 0===C&&(C=this),this._emitter.on(g,I,C)},I.once=function(g,I,C){void 0===C&&(C=this),this._emitter.once(g,I,C)},I.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},I.off=function(g,I,C,A){void 0===C&&(C=this),this._emitter.off(g,I,C,A)},I.listeners=function(g){return this._emitter.listeners(g)},I.emit=function(g,I,C){return this._emitter.emit(g,I,C)},I.trigger=function(g,I){if(this.config.debug)return this.emit(g,g,I);try{return this.emit(g,g,I)}catch(C){H.error("An internal error happened while handling event "+g+'. Error message: "'+C.message+'". Here is a stacktrace:',C),this.trigger(B.ERROR,{type:y.OTHER_ERROR,details:V.INTERNAL_EXCEPTION,fatal:!1,event:g,error:C})}return!1},I.listenerCount=function(g){return this._emitter.listenerCount(g)},I.destroy=function(){H.log("destroy"),this.trigger(B.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(g){return g.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(g){return g.destroy()})),this.coreComponents.length=0;var g=this.config;g.xhrSetup=g.fetchSetup=void 0,this.userConfig=null},I.attachMedia=function(g){H.log("attachMedia"),this._media=g,this.trigger(B.MEDIA_ATTACHING,{media:g})},I.detachMedia=function(){H.log("detachMedia"),this.trigger(B.MEDIA_DETACHING,void 0),this._media=null},I.loadSource=function(g){this.stopLoad();var I=this.media,C=this.url,A=this.url=w.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});H.log("loadSource:"+A),I&&C&&(C!==A||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(I)),this.trigger(B.MANIFEST_LOADING,{url:g})},I.startLoad=function(g){void 0===g&&(g=-1),H.log("startLoad("+g+")"),this.networkControllers.forEach((function(I){I.startLoad(g)}))},I.stopLoad=function(){H.log("stopLoad"),this.networkControllers.forEach((function(g){g.stopLoad()}))},I.swapAudioCodec=function(){H.log("swapAudioCodec"),this.streamController.swapAudioCodec()},I.recoverMediaError=function(){H.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},I.removeLevel=function(g,I){void 0===I&&(I=0),this.levelController.removeLevel(g,I)},e(g,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){H.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){H.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){H.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){H.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){H.log("set startLevel:"+g),-1!==g&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var I=!!g;I!==this.config.capLevelToPlayerSize&&(I?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=I)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(H.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(g){NI.indexOf(g)>-1&&(this._maxHdcpLevel=g)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,I=this.config.minAutoBitrate;if(!g)return 0;for(var C=g.length,A=0;A=I)return A;return 0}},{key:"maxAutoLevel",get:function(){var g,I=this.levels,C=this.autoLevelCapping,A=this.maxHdcpLevel;if(g=-1===C&&I&&I.length?I.length-1:C,A)for(var i=g;i--;){var e=I[i].attrs["HDCP-LEVEL"];if(e&&e<=A)return i}return g}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var I=this.audioTrackController;I&&(I.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var I=this.subtitleTrackController;I&&(I.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return!!g&&g.subtitleDisplay},set:function(g){var I=this.subtitleTrackController;I&&(I.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.12"}},{key:"Events",get:function(){return B}},{key:"ErrorTypes",get:function(){return y}},{key:"ErrorDetails",get:function(){return V}},{key:"DefaultConfig",get:function(){return g.defaultConfig?g.defaultConfig:Be},set:function(I){g.defaultConfig=I}}]),g}();return Ve.defaultConfig=void 0,Ve},"object"==typeof g&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(A="undefined"!=typeof globalThis?globalThis:A||self).Hls=i()}(!1);!function(){if("undefined"==typeof document||customElements.get("r-option"))return K("document is undefined or r-option is exist");{class g extends HTMLElement{constructor(){super(),C(this,"_option"),C(this,"_optionContent"),C(this,"_shadowDom"),C(this,"_slot"),this._slot=document.createElement("slot"),this._option=document.createElement("div"),this._option.setAttribute("class","ran-option"),this._optionContent=document.createElement("div"),this._optionContent.setAttribute("class","ran-option-content"),this._optionContent.appendChild(this._slot),this._option.appendChild(this._optionContent);const g=this.attachShadow({mode:"closed"});this._shadowDom=g,g.appendChild(this._option)}static get observedAttributes(){return["disabled","sheet","value"]}get value(){return this.getAttribute("value")}set value(g){this.setAttribute("value",g||"")}get sheet(){return this.getAttribute("sheet")}set sheet(g){this.setAttribute("sheet",g||"")}get disabled(){return H(this)}set disabled(g){g&&"false"!==g?this.setAttribute("disabled",""):this.removeAttribute("disabled")}handlerExternalCss(){if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(g,I,C){"disabled"===g&&this._option&&(C&&"false"!==C?this._option.removeAttribute("disabled"):this._option.setAttribute("disabled","")),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}}}}();let Zg=class extends(f()){constructor(){super(),C(this,"dropdown"),C(this,"_slot"),C(this,"_shadowDom"),C(this,"arrowIcon"),C(this,"container"),C(this,"handlerTransit",(()=>{this.transit&&(Z(this.dropdown.element,this.transit),setTimeout((()=>{b(this.dropdown.element,this.transit)}),300))})),C(this,"handlerArrow",(()=>{this.arrow&&(this.arrowIcon||(this.arrowIcon=w("div").setAttribute("class",`ranui-dropdown-arrow ${this.arrow}`),this.container.addChild([this.arrowIcon])))})),C(this,"stopPropagation",(g=>{g.stopPropagation()})),this._slot=w("slot").setAttribute("class","slot"),this.dropdown=w("div").setStyle("-webkit-tap-highlight-color","transparent").setStyle("outline","0").setAttribute("class","ranui-dropdown").setAttribute("part","ranui-dropdown").addChild([this._slot]),this.container=w("div").setAttribute("class","ranui-dropdown-container").addChild([this.dropdown]);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes ranui-dropdown-down-in{0%{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}to{transform:scaleY(1);transform-origin:100% 100%;opacity:1}}@keyframes ranui-dropdown-down-out{0%{transform:scaleY(1);transform-origin:100% 100%;opacity:1}to{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}}@keyframes ranui-dropdown-up-in{0%{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}to{transform:scaleY(1);transform-origin:0% 0%;opacity:1}}@keyframes ranui-dropdown-up-out{0%{transform:scaleY(1);transform-origin:0% 0%;opacity:1}to{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}}.ran-dropdown-down-in{animation:ranui-dropdown-up-in .2s;animation-fill-mode:forwards}.ran-dropdown-down-out{animation:ranui-dropdown-up-out .2s;animation-fill-mode:forwards}.ran-dropdown-up-in{animation:ranui-dropdown-down-in .2s;animation-fill-mode:forwards}.ran-dropdown-up-out{animation:ranui-dropdown-down-out .2s;animation-fill-mode:forwards}:host{text-align:var(--ran-dropdown-host-text-align, left);z-index:10}.ranui-dropdown{transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);box-sizing:var(--ran-dropdown-box-sizing, border-box);margin:var(--ran-dropdown-margin, 0);padding:var(--ran-dropdown-padding, 4px);color:var(--ran-dropdown-color, rgba(0, 0, 0, .88));font-size:var(--ran-dropdown-font-size, 14px);list-style:var(--ran-dropdown-list-style, none);font-family:var(--ran-dropdown-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");z-index:var(--ran-dropdown-z-index, 1050);overflow:var(--ran-dropdown-overflow, hidden);font-variant:var(--ran-dropdown-font-variant, initial);background:var(--ran-dropdown-background, #ffffff);border-radius:var(--ran-dropdown-border-radius, 8px);outline:var(--ran-dropdown-outline, none);box-shadow:var(--ran-dropdown-box-shadow, 0 6px 16px 0 rgba(0, 0, 0, .08), 0 3px 6px -4px rgba(0, 0, 0, .12), 0 9px 28px 8px rgba(0, 0, 0, .05));cursor:var(--ran-dropdown-cursor, pointer);width:var(--ran-dropdown-width, 100%)}.ranui-dropdown-container{position:var(--ran-dropdown-container-position, relative);display:var(--ran-dropdown-container-display, inline-block);width:var(--ran-dropdown-container-width, 100%);min-width:var(--ran-popover-width)}.ranui-dropdown-container .top{transform:translate(calc(var(--ran-popover-width) / 2 - 8px)) translateY(-16px) rotate(0);top:0}.ranui-dropdown-container .bottom{transform:translate(calc(var(--ran-popover-width) / 2 - 8px)) translateY(0) rotate(180deg);top:calc(var(--ran-popover-height) - 4px,0px)}.ranui-dropdown-arrow{position:var(--ran-dropdown-arrow-position, absolute);z-index:var(--ran-dropdown-arrow-z-index, 1);display:var(--ran-dropdown-arrow-display, block);pointer-events:var(--ran-dropdown-arrow-pointer-events, none);width:var(--ran-dropdown-arrow-width, 16px);height:var(--ran-dropdown-arrow-height, 16px);overflow:var(--ran-dropdown-arrow-overflow, hidden)}.ranui-dropdown-arrow:before{background:var(--ran-dropdown-arrow-before-background, #fff);position:var(--ran-dropdown-arrow-before-position, absolute);bottom:var(--ran-dropdown-arrow-before-bottom, 0);inset-inline-start:0;width:var(--ran-dropdown-arrow-before-width, 16px);height:var(--ran-dropdown-arrow-before-height, 8px );clip-path:path("M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z");content:var(--ran-dropdown-arrow-before-content, "")}.ranui-dropdown-arrow:after{content:var(--ran-dropdown-arrow-after-content, "");position:var(--ran-dropdown-arrow-after-position, absolute);width:var(--ran-dropdown-arrow-after-width, 9px);height:var(--ran-dropdown-arrow-after-height, 9px);bottom:var(--ran-dropdown-arrow-after-bottom, 0);inset-inline:0;margin:var(--ran-dropdown-arrow-after-margin, auto);border-radius:var(--ran-dropdown-arrow-after-border-radius, 0 0 2px 0);transform:var(--ran-dropdown-arrow-after-transform, translateY(50%) rotate(-135deg));box-shadow:var(--ran-dropdown-arrow-after-box-shadow, 2px 2px 5px rgba(0, 0, 0, .05));z-index:var(--ran-dropdown-arrow-after-z-index, 0);background:var(--ran-dropdown-arrow-after-background, transparent)}',g.appendChild(I),this._shadowDom=g,g.appendChild(this.container.element)}static get observedAttributes(){return["transit","arrow"]}get transit(){return this.getAttribute("transit")||""}set transit(g){g?this.setAttribute("transit",g):this.removeAttribute("transit")}get arrow(){return this.getAttribute("arrow")||""}set arrow(g){g?this.setAttribute("arrow",g):this.removeAttribute("arrow")}get show(){return this.getAttribute("show")||""}set show(g){g?this.setAttribute("show",g):this.removeAttribute("show")}connectedCallback(){this.handlerTransit(),this.handlerArrow()}disconnectedCallback(){}attributeChangedCallback(g,I,C){"transit"===g&&C&&(Z(this.dropdown.element,this.transit),setTimeout((()=>{b(this.dropdown.element,this.transit)}),300)),"arrow"===g&&this.handlerArrow()}};"undefined"==typeof document||customElements.get("r-dropdown")?K("document is undefined or r-dropdown is exist"):customElements.define("r-dropdown",Zg);let bg=class extends(f()){constructor(){super(),C(this,"ionDropdownItem"),C(this,"_slot"),C(this,"_shadowDom"),C(this,"ionDropdownItemContent"),this._slot=w("slot").setAttribute("class","slot"),this.ionDropdownItemContent=w("div").setAttribute("class","ranui-dropdown-option-item-content").setAttribute("part","ranui-dropdown-option-item-content").addChild(this._slot),this.ionDropdownItem=w("div").setAttribute("class","ranui-dropdown-option-item").setAttribute("part","ranui-dropdown-option-item").addChild([this.ionDropdownItemContent]);const g=this.attachShadow({mode:"closed"});this._shadowDom=g;const I=w("style").setTextContent('.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ranui-dropdown-option-item{position:var(--ran-dropdown-option-item-position, relative);display:var(--ran-dropdown-option-item-display, block);padding:var(--ran-dropdown-option-item-padding, 5px 12px);color:var(--ran-dropdown-option-item-color, rgba(0, 0, 0, .88));font-weight:var(--ran-dropdown-option-item-font-weight, normal);font-size:var(--ran-dropdown-option-item-font-size, 14px);transition:var(--ran-dropdown-option-item-transition, background .3s ease);border-radius:var(--ran-dropdown-option-item-border-radius, 4px)}.ranui-dropdown-option-item:hover{background-color:var(--ran-dropdown-option-item-hover-background-color, rgba(0, 0, 0, .04))}.ranui-dropdown-option-item-content{text-align:var(--ran-dropdown-content-text-align, left);overflow:var(--ran-dropdown-content-overflow, hidden);white-space:var(--ran-dropdown-content-white-space, nowrap);text-overflow:var(--ran-dropdown-content-text-overflow, ellipsis);color:var(--ran-dropdown-content-color, rgba(0, 0, 0, .88));font-size:var(--ran-dropdown-content-font-size, 14px);line-height:var(--ran-dropdown-content-line-height, 1.57142857);box-sizing:var(--ran-dropdown-content-box-sizing, border-box);list-style:var(--ran-dropdown-content-list-style, none);font-family:var(--ran-dropdown-content-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-variant:var(--ran-dropdown-content-font-variant, initial)}.ranui-dropdown-option-active{background-color:var(--ran-dropdown-option-active-background-color, #e6f7ff);font-weight:var(--ran-dropdown-option-active-font-weight, bold)}.ranui-dropdown-option-active:hover{background-color:var(--ran-dropdown-option-active-hover-background-color, #e6f7ff)}');g.appendChild(I.element),g.appendChild(this.ionDropdownItem.element)}static get observedAttributes(){return["active","value","title"]}get value(){return this.getAttribute("value")||""}set value(g){!H(this)&&g?this.setAttribute("value",g):this.removeAttribute("value")}get active(){return this.getAttribute("active")||""}set active(g){g?this.setAttribute("active",g):this.removeAttribute("active")}get title(){return this.getAttribute("title")||""}set title(g){g?this.setAttribute("title",g):this.removeAttribute("title")}connectedCallback(){this.active&&Z(this.ionDropdownItem.element,"ranui-dropdown-option-active")}attributeChangedCallback(g,I,C){"active"===g&&C?Z(this.ionDropdownItem.element,"ranui-dropdown-option-active"):b(this.ionDropdownItem.element,"ranui-dropdown-option-active")}};"undefined"==typeof document||customElements.get("r-dropdown-item")?K("document is undefined or r-dropdown-item is exist"):customElements.define("r-dropdown-item",bg);const Gg={bottom:{add:"ran-dropdown-down-in",remove:"ran-dropdown-down-out"},top:{add:"ran-dropdown-up-in",remove:"ran-dropdown-up-out"}},ug=W();let pg=class extends(f()){constructor(){super(),C(this,"removeTimeId"),C(this,"_slot"),C(this,"_shadowDom"),C(this,"_select"),C(this,"_selection"),C(this,"_search"),C(this,"_icon"),C(this,"_selectDropdown"),C(this,"_selectionDropdown"),C(this,"_selectDropDownInTimeId"),C(this,"_selectDropDownOutTimeId"),C(this,"_optionList"),C(this,"_optionLabelMapValue"),C(this,"_optionValueMapLabel"),C(this,"_activeOption"),C(this,"_text"),C(this,"_selector"),C(this,"onSearch"),C(this,"setSelectDropdownDisplayNone",(()=>{this._selectDropDownOutTimeId||this._selectionDropdown&&"none"!==this._selectionDropdown.style.display&&(this._selectionDropdown.setAttribute("transit",Gg[this.placement].remove),this._selectDropDownOutTimeId=setTimeout((()=>{var g;null==(g=this._selectionDropdown)||g.style.setProperty("display","none"),this._selectionDropdown&&this._selectionDropdown.removeAttribute("transit"),clearTimeout(this._selectDropDownOutTimeId),this._selectDropDownOutTimeId=void 0}),300))})),C(this,"setSelectDropdownDisplayBlock",(()=>{var g;this._selectDropDownInTimeId||this._selectionDropdown&&"block"!==this._selectionDropdown.style.display&&(this._selectionDropdown.setAttribute("transit",Gg[this.placement].add),null==(g=this._selectionDropdown)||g.style.setProperty("display","block"),this._selectDropDownInTimeId=setTimeout((()=>{this._selectionDropdown&&this._selectionDropdown.removeAttribute("transit"),clearTimeout(this._selectDropDownInTimeId),this._selectDropDownInTimeId=void 0}),300))})),C(this,"placementPosition",(()=>{if(!this._selectionDropdown||!this._selectDropdown)return;const g=this.getBoundingClientRect(),{top:I,left:C,bottom:A,width:i,height:e,x:t,y:l,right:s}=g,o=document.getElementById(this.getPopupContainerId);this._selectionDropdown.style.setProperty("position","absolute"),this._selectionDropdown.style.setProperty("--ran-x",`${I+window.scrollX}`),this._selectionDropdown.style.setProperty("--ran-y",`${C+window.scrollY}`);let c=A+window.scrollY,d=C+window.scrollX;if(this._selectionDropdown.style.setProperty("width",`${i}px`),"top"===this.placement&&(c=I+window.scrollY-this._selectionDropdown.clientHeight),this.getPopupContainerId&&o){d=C-o.getBoundingClientRect().left,c="top"===this.placement?I-o.getBoundingClientRect().top-this._selectionDropdown.clientHeight:o.getBoundingClientRect().height}this._selectionDropdown.style.setProperty("inset",`${c}px auto auto ${d}px`)})),C(this,"selectMouseDown",(g=>{g.stopPropagation(),H(this)||(this.removeDropDownTimeId(g),this.setSelectDropdownDisplayNone(),this.setSelectDropdownDisplayBlock(),this.placementPosition())})),C(this,"removeDropDownTimeId",(g=>{g.stopPropagation(),this._search.setAttribute("value",""),this.trigger.includes("hover")&&!c()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)})),C(this,"selectBlur",(g=>{g.stopPropagation(),this.removeTimeId&&this.removeDropDownTimeId(g),this.removeTimeId=setTimeout((()=>{this.removeDropDownTimeId(g),this.setSelectDropdownDisplayNone()}),300)})),C(this,"clickOption",(g=>{g.stopPropagation();const I=g.target,C=I.innerHTML,A=this._optionLabelMapValue.get(C);A&&(this.setAttribute("value",A),this._text.innerHTML=C,this._text.setAttribute("title",C),this._search.setAttribute("placeholder",C));const i=this.getBoundingClientRect(),{height:e}=i;this._text.style.setProperty("line-height",`${e}px`),this._activeOption&&this._activeOption.removeAttribute("active"),this._activeOption=I,this._activeOption&&this._activeOption.setAttribute("active",A||""),this.setSelectDropdownDisplayNone(),this.dispatchEvent(new CustomEvent("change",{detail:{value:A,label:C}})),this.removeDropDownTimeId(g)})),C(this,"createOption",(()=>{if(!this._selectDropdown){const g=document.getElementById(this.getPopupContainerId)||document.body;this._selectDropdown=document.createElement("div"),this._selectDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectDropdown.style.setProperty("outline","0"),this._selectDropdown.addEventListener("click",this.clickOption),this._selectionDropdown=document.createElement("r-dropdown"),this.dropdownclass&&this._selectionDropdown.setAttribute("class",this.dropdownclass),this.trigger.includes("hover")&&!c()&&(this._selectDropdown.addEventListener("mouseleave",this.selectBlur),this._selectDropdown.addEventListener("mouseenter",this.removeDropDownTimeId)),this._selectDropdown.appendChild(this._selectionDropdown),this._selectionDropdown.style.setProperty("display","none"),g.appendChild(this._selectDropdown)}})),C(this,"removeSelectDropdown",(()=>{try{if(this._selectDropdown){(document.getElementById(this.getPopupContainerId)||document.body).removeChild(this._selectDropdown)}}catch(g){}})),C(this,"addOptionToSlot",(()=>{this._slot.assignedElements().forEach((g=>{var I;if("R-OPTION"!==g.tagName)return;const C=g.innerHTML,A=g.getAttribute("value")||"";null==(I=this._optionList)||I.push({label:C,value:A}),this._optionLabelMapValue.get(C)&&console.warn(`${C} is repeat option`),this._optionValueMapLabel.get(A)&&console.warn(`${A} is repeat option`),this._optionLabelMapValue.set(C,A),this._optionValueMapLabel.set(A,C)})),this.createSelectDropdownContent(this._optionList)})),C(this,"createSelectDropdownContent",((g=[])=>{var I,C;0===g.length?null==(I=this._selectDropdown)||I.style.setProperty("display","none"):null==(C=this._selectDropdown)||C.style.setProperty("display","block"),g.forEach((g=>{if(this._selectionDropdown){const{label:I,value:C}=g,A=document.createElement("r-dropdown-item");(this.getAttribute("defaultValue")||this.getAttribute("value"))===C?(A.setAttribute("active",C),this._activeOption=A):A.removeAttribute("active"),A.innerHTML=`${I}`,A.setAttribute("value",`${C}`),A.setAttribute("title",`${I}`),this._selectionDropdown.appendChild(A)}})),this.setDefaultValue()})),C(this,"setDefaultValue",(()=>{const g=this.getAttribute("defaultValue")||this.getAttribute("value");if(!g)return;const I=this._optionValueMapLabel.get(g);if(!I)return;this.setAttribute("value",g);const C=this.getBoundingClientRect(),{height:A}=C;this._text.style.setProperty("line-height",`${A}px`),this._text.innerHTML=I,this._text.setAttribute("title",I)})),C(this,"changeSearch",(g=>{const I=g.detail.value||"";if(this.dispatchEvent(new CustomEvent("search",{detail:{value:I}})),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),I.length>0){const g=this._optionList.map((g=>{const{label:C}=g;if(`${C}`.toLowerCase().includes(I))return{label:C,value:g.value}})).filter((g=>g));this.createSelectDropdownContent(g)}else this.createSelectDropdownContent(this._optionList)})),C(this,"setShowSearch",(()=>{this.onSearch=ug(this.changeSearch),this.onSearch&&this._search.addEventListener("change",this.onSearch),this.onSearch&&this._search.addEventListener("click",this.onSearch)})),C(this,"removeShowSearch",(()=>{this.onSearch&&this._search.removeEventListener("change",this.onSearch),this.onSearch&&this._search.removeEventListener("click",this.onSearch)})),C(this,"listenSlotChange",(()=>{this._slot.addEventListener("slotchange",this.addOptionToSlot)})),C(this,"removeListenSlotChange",(()=>{this._slot.removeEventListener("slotchange",this.addOptionToSlot)})),C(this,"listenActionEvent",(()=>{this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.trigger.includes("hover")&&!c()&&(this.addEventListener("mouseenter",this.selectMouseDown),this.addEventListener("mouseleave",this.selectBlur)),this.trigger.includes("click")&&(this.addEventListener("click",this.selectMouseDown),this.addEventListener("blur",this.selectBlur))})),C(this,"clickRemoveSelect",(g=>{g.stopPropagation(),this.setSelectDropdownDisplayNone()})),this._slot=document.createElement("slot"),this._select=document.createElement("div"),this._select.setAttribute("class","ran-select"),this._select.setAttribute("part","select"),this._selection=document.createElement("div"),this._selection.setAttribute("class","selection"),this._selection.setAttribute("part","selection"),this._selector=document.createElement("div"),this._search=document.createElement("r-input"),this._search.setAttribute("class","selection-search"),this._search.setAttribute("part","search"),this._search.setAttribute("type","search"),this._search.setAttribute("autocomplete","off"),this._text=document.createElement("span"),this._text.setAttribute("class","selection-item"),this._text.setAttribute("part","selection-item"),this._icon=document.createElement("ra-icon"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("part","icon"),this._icon.setAttribute("name","arrow-down"),this._icon.setAttribute("color","#d9d9d9"),this._icon.setAttribute("size","16"),this._selector.appendChild(this._text),this._selector.appendChild(this._search),this._selection.appendChild(this._icon),this._selection.appendChild(this._selector),this._slot.setAttribute("class","slot"),this._select.appendChild(this._selection),this._select.appendChild(this._slot),this._optionList=[],this._optionLabelMapValue=new Map,this._optionValueMapLabel=new Map;const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}r-select{position:var(--ran-select, relative);width:var(--ran-select, 120px);height:var(--ran-select, 40px)}:host{position:var(--ran-select-host, relative);display:var(--ran-select-host, inline-block);cursor:var(--ran-select-host, pointer);height:var(--ran-select-host, 32px);outline:var(--ran-select-host, 0);-webkit-tap-highlight-color:var(--ran-select-host-highlight-color, transparent)}:host,:host(:focus),:host(:active){outline:var(--ran-select-host-focus-outline, 0);-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:none}:host([disabled]){cursor:var(--ran-select-host-disabled-cursor, not-allowed);pointer-events:var(--ran-select-host-disabled-pointer-events, all);opacity:var(--ran-select-host-disabled-opacity, .6)}:host([type="text"])::part(selection){border:none}:host([type="text"])::part(icon){display:none}:host(:not([disabled]):hover) .select{cursor:var(--ran-select-host-hover-cursor, pointer)}:host(:not([disabled]):hover) .selection{border:var(--ran-select-host-selection-border, 1px solid #1890ff)}:host(:not([disabled]):hover) .selection-search{cursor:var(--ran-select-host-selection-search-cursor, pointer)}:host(:not([disabled]):hover) .selection-item{cursor:var(--ran-select-host-selection-item-cursor, pointer);color:var(--ran-select-host-selection-item-color, #bfbfbf)}:host(:not([disabled]):focus) .selection{border:var(--ran-select-host-selection-focus-border, 1px solid #1890ff)}:host(:not([disabled]):focus) .selection-search{cursor:var(--ran-select-host-selection-focus-search-cursor, pointer)}:host(:not([disabled]):focus) .selection-item{cursor:var(--ran-select-host-selection-focus-item-cursor, pointer);color:var(--ran-select-host-selection-focus-item-color, #bfbfbf)}:host .selection-search{display:var(--ran-select-host-selection-search-display, none)}:host([showSearch]:not([disabled])) .selection-search{cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);display:var(--ran-select-host-showSearch-selection-search-display, block)}:host([showSearch]:not([disabled])) .selection-item{cursor:var(--ran-select-host-showSearch-selection-item-cursor, pointer)}:host([showSearch]:not([disabled]):focus) .selection-search{display:var(--ran-select-host-showSearch-selection-search-display, block);cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);opacity:var(--ran-select-host-showSearch-selection-search-opacity, 1)}.ran-select{width:var(--ran-select-width, 100%);height:var(--ran-select-width, 100%);font-size:var(--ran-select-font-size, 14px);box-sizing:var(--ran-select-box-sizing, border-box);margin:var(--ran-select-margin, 0);padding:var(--ran-select-padding, 0);color:var(--ran-select-color, rgba(0, 0, 0, .88));line-height:var(--ran-select-line-height, 1.57142857);list-style:var(--ran-select-list-style, none);font-family:var(--ran-select-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");position:var(--ran-select-position, relative);display:var(--ran-select-display, inline-block)}.ran-select .selection{position:var(--ran-select-selection-position, relative);background-color:var(--ran-select-selection-background-color, #ffffff);border:var(--ran-select-selection-border, 1px solid #d9d9d9);transition:var(--ran-select-selection-transition, all .2s cubic-bezier(.645, .045, .355, 1));width:var(--ran-select-selection-width, 100%);height:var(--ran-select-selection-height, 100%);padding:var(--ran-select-selection-padding, 0 11px);box-sizing:var(--ran-select-selection-box-sizing, border-box);margin:var(--ran-select-selection-margin, 0);color:var(--ran-select-selection-color, rgba(0, 0, 0, .88));font-size:var(--ran-select-selection-font-size, 14px);line-height:var(--ran-select-selection-line-height, 1.57142857);list-style:var(--ran-select-selection-list-style, none);font-family:var(--ran-select-selection-font-family, inherit);display:var(--ran-select-selection-display, flex);border-radius:var(--ran-select-selection-border-radius, 6px)}.ran-select .selection-search{position:var(--ran-select-selection-search-position, absolute);opacity:var(--ran-select-selection-search-opacity, 0);top:var(--ran-select-selection-search-top, 0);left:var(--ran-select-selection-search-left, 0);height:var(--ran-select-selection-search-height, 100%);inset-inline-start:var(--ran-select-selection-search-inset-inline-start, 11px);inset-inline-end:var(--ran-select-selection-search-inset-inline-end, 11px);margin:var(--ran-select-selection-search-margin, 0);padding:var(--ran-select-selection-search-padding, 0);background:var(--ran-select-selection-search-background, transparent);border:var(--ran-select-selection-search-border, none);outline:var(--ran-select-selection-search-outline, none);-webkit-appearance:var(--ran-select-selection-search-appearance, none);-moz-appearance:var(--ran-select-selection-search-appearance, none);appearance:var(--ran-select-selection-search-appearance, none);font-family:var(--ran-select-selection-search-font-family, inherit);cursor:var(--ran-select-selection-search-cursor, not-allowed)}.ran-select .selection-search::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-select .selection-search::part(ran-input){border:none;padding:0;height:100%;outline:none}.ran-select .selection-search::part(ran-input):active{border:none;padding:0;height:100%;outline:none;border-color:transparent;box-shadow:none;border-right-width:0px}.ran-select .selection-item{position:var(--ran-select-selection-item-position, absolute);top:var(--ran-select-selection-item-top, 0);left:var(--ran-select-selection-item-left, 12px);margin:var(--ran-select-selection-item-margin, 0);padding:var(--ran-select-selection-item-padding, 0);background:var(--ran-select-selection-item-background, transparent);border:var(--ran-select-selection-item-border, none);outline:var(--ran-select-selection-item-outline, none);-webkit-appearance:var(--ran-select-selection-item-appearance, none);-moz-appearance:var(--ran-select-selection-item-appearance, none);appearance:var(--ran-select-selection-item-appearance, none);font-family:var(--ran-select-selection-item-font-family, inherit);height:var(--ran-select-selection-item-height, 100%);-webkit-user-select:var(--ran-select-selection-item-user-select, none);user-select:var(--ran-select-selection-item-user-select, none);overflow:var(--ran-select-selection-item-overflow, hidden);white-space:var(--ran-select-selection-item-white-space, nowrap);text-overflow:var(--ran-select-selection-item-text-overflow, ellipsis);cursor:var(--ran-select-selection-item-cursor, pointer)}.ran-select .selection-select{color:var(--ran-select-selection-select-color, rgba(0, 0, 0, .25))}.ran-select .selection .icon{display:var(--ran-select-selection-icon-display, flex);align-items:var(--ran-select-selection-icon-align-items, center);color:var(--ran-select-selection-icon-color, rgba(0, 0, 0, .25));font-style:var(--ran-select-selection-icon-font-style, normal);text-align:var(--ran-select-selection-icon-text-align, center);text-transform:var(--ran-select-selection-icon-text-transform, none);text-rendering:var(--ran-select-selection-icon-text-rendering, optimizeLegibility);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:var(--ran-select-selection-icon-position, absolute);top:var(--ran-select-selection-icon-top, 50%);inset-inline-start:var(--ran-select-selection-icon-inset-inline-start, auto);inset-inline-end:var(--ran-select-selection-icon-inset-inline-end, 8px);height:var(--ran-select-selection-icon-height, 12px);margin-top:var(--ran-select-selection-icon-margin-top, -3px);font-size:var(--ran-select-selection-icon-font-size, 12px);pointer-events:var(--ran-select-selection-icon-color, pointer-events)}',g.appendChild(I),this._shadowDom=g,this._shadowDom.appendChild(this._select)}static get observedAttributes(){return["disabled","sheet","clear","type","defaultValue","showSearch","placement","getPopupContainerId","dropdownclass","trigger"]}get value(){return this.getAttribute("value")||""}set value(g){!H(this)&&g?this.setAttribute("value",g):this.removeAttribute("value")}get defaultValue(){return this.getAttribute("defaultValue")||""}set defaultValue(g){this.setAttribute("defaultValue",g||"")}get showSearch(){return this.getAttribute("showSearch")||""}set showSearch(g){this.setAttribute("showSearch",g||"")}get type(){return this.getAttribute("type")||""}set type(g){this.setAttribute("type",g||"")}get placement(){return this.getAttribute("placement")||"bottom"}set placement(g){this.setAttribute("placement",g||"")}get sheet(){return this.getAttribute("sheet")||""}set sheet(g){this.setAttribute("sheet",g||"")}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(g){this.setAttribute("getPopupContainerId",g||"")}get dropdownclass(){return this.getAttribute("dropdownclass")||""}set dropdownclass(g){this.setAttribute("dropdownclass",g||"")}get trigger(){return this.getAttribute("trigger")||"click"}set trigger(g){this.setAttribute("trigger",g||"")}get disabled(){return H(this)}set disabled(g){g&&"false"!==g?(this.setAttribute("disabled",""),this._selection.setAttribute("disabled","")):(this.removeAttribute("disabled"),this._selection.removeAttribute("disabled"))}handlerExternalCss(){if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){this.handlerExternalCss(),this.createOption(),this.listenActionEvent(),this.listenSlotChange(),this.setShowSearch(),document.addEventListener("click",this.clickRemoveSelect)}disconnectCallback(){var g;this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.removeSelectDropdown(),null==(g=this._selectDropdown)||g.removeEventListener("click",this.clickOption),this.removeListenSlotChange(),document.removeEventListener("click",this.clickRemoveSelect)}attributeChangedCallback(g,I,C){"disabled"===g&&this._select&&(C&&"false"!==C?(this._select.removeAttribute("disabled"),this._selection.removeAttribute("disabled")):(this._select.setAttribute("disabled",""),this._selection.setAttribute("disabled",""))),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}};const wg="undefined"==typeof document||customElements.get("r-select")?K("document is undefined or r-select is exist"):(customElements.define("r-select",pg),pg),Wg=Object.freeze(Object.defineProperty({__proto__:null,Select:pg,default:wg},Symbol.toStringTag,{value:"Module"})),Bg=["play","playing","timeupdate"],yg=W(),Vg=[{label:"2.0X",value:2},{label:"1.5X",value:1.5},{label:"1.0X",value:1},{label:"0.8X",value:.8},{label:"0.5X",value:.5}];class Xg extends(f()){constructor(){super(),C(this,"ctx"),C(this,"_player"),C(this,"_container"),C(this,"_slot"),C(this,"_playerController"),C(this,"_playerBtn"),C(this,"_progress"),C(this,"_progressDot"),C(this,"_progressWrap"),C(this,"_progressWrapValue"),C(this,"requestAnimationFrameId"),C(this,"moveProgress"),C(this,"_playerControllerBottom"),C(this,"_playerControllerBottomRight"),C(this,"_playerControllerBottomLeft"),C(this,"_playerControllerBottomPlayBtn"),C(this,"_playerControllerBottomTimeCurrent"),C(this,"_playerControllerBottomTimeDuration"),C(this,"_playerControllerBottomTimeDivide"),C(this,"_playControllerBottomClarity"),C(this,"_playControllerBottomSpeed"),C(this,"_playControllerBottomSpeedIcon"),C(this,"_playControllerBottomVolumeProgress"),C(this,"_playControllerBottomRightFullScreen"),C(this,"_playControllerBottomVolume"),C(this,"_playControllerBottomSpeedPopover"),C(this,"controllerBarTimeId"),C(this,"_playerTip"),C(this,"_playerTipTime"),C(this,"_playerTipText"),C(this,"_volume"),C(this,"_video"),C(this,"_hls"),C(this,"changeClarityToSetVideo",(()=>{const{currentTime:g,playbackRate:I,volume:C,currentState:A}=this.ctx;this.setCurrentTime(g),this.setPlaybackRate(I),this.setVolume(C),Bg.includes(A)?this.play():this.pause()})),C(this,"changeClarity",(g=>{this.ctx.clarity=g.detail.value;const I=this.ctx.levelMap.get(g.detail.value);I&&this._hls&&(this._hls.loadSource(I),this._hls.startLoad(),this.changeClarityToSetVideo())})),C(this,"createClaritySelect",(()=>{const{levels:g,url:I}=this.ctx;if(this._playControllerBottomClarity.innerHTML="",g.length<=0)return;const C=document.createDocumentFragment();g.forEach((g=>{const{name:I,url:A}=g;if(!I||!A)return;this.ctx.levelMap.set(I,A);const i=document.createElement("r-option");i.setAttribute("value",I),i.innerHTML=I,C.appendChild(i)}));const A=document.createElement("r-select");A.setAttribute("value",this.ctx.clarity||"Auto"),A.appendChild(C),A.setAttribute("type","text"),A.setAttribute("trigger","hover,click"),A.setAttribute("placement","top");const i=this._player.getAttribute("id");i&&A.setAttribute("getPopupContainerId",i),A.setAttribute("dropdownclass","video-clarity-dropdown"),A.addEventListener("change",this.changeClarity),this._playControllerBottomClarity.appendChild(A)})),C(this,"manifestLoaded",((g,I)=>{if("hlsManifestLoaded"===g){const{url:g,levels:C=[]}=I;if(C.length<=0)return;C.forEach((g=>{this.ctx.levelMap.get(g.name)!==g.url&&this.ctx.levels.push(g)})),this.ctx.levelMap.get("Auto")||(this.ctx.levels.push({name:"Auto",url:g}),this.ctx.levelMap.set("Auto",g)),this.ctx.url=g,this.createClaritySelect(),this.change("hlsManifestLoaded",{data:I})}})),C(this,"updatePlayer",(()=>{var g;const{Hls:I}=window;this.innerHTML="",this.contains(this._player)||this.appendChild(this._player),this._hls&&(this._hls.destroy(),this._hls=void 0),this._video=document.createElement("video"),this._video.setAttribute("class","ran-player-video"),this._video.setAttribute("preload","auto"),this._video.setAttribute("x5-video-player-type","h5"),this._video.setAttribute("x5-video-orientation","portrait"),this._video.setAttribute("webkit-playsinline","true"),this._video.setAttribute("playsinline","true"),this._video.setAttribute("controls","false"),this._video.controls=!1,this._video.setAttribute("initial-time","0.01");try{this._video.canPlayType("application/vnd.apple.mpegurl")&&this.src?this._video.src=this.src:(null==I?void 0:I.isSupported())&&this.src&&(this._hls=new I,this._hls&&(this._hls.off(I.Events.MANIFEST_LOADED,this.manifestLoaded),this._hls.on(I.Events.MANIFEST_LOADED,this.manifestLoaded),this._hls.off(I.Events.ERROR,this.hlsError),this._hls.on(I.Events.ERROR,this.hlsError),this._hls.loadSource(this.src),this._hls.attachMedia(this._video)),this._container.appendChild(this._video),null==(g=this._video.parentElement)||g.setAttribute("class","ran-player-contain")),this.listenEvent()}catch(C){}})),C(this,"hlsError",((g,I)=>{this.change("hlsError",{event:g,data:I}),this._video&&(this._video.src=this.src)})),C(this,"change",((g,I)=>{const C=this.getCurrentTime(),A=this.getTotalTime();this.debug&&console.log(g,I),this.dispatchEvent(new CustomEvent("change",{detail:{type:g,data:I,currentTime:C,duration:A,tag:this}}))})),C(this,"onCanplay",(g=>{this.ctx.currentState=g.type,b(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),Z(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),this.change("canplay",g),this.resize()})),C(this,"onCanplaythrough",(g=>{this.ctx.currentState=g.type,this.change("canplaythrough",g)})),C(this,"onComplete",(g=>{this.ctx.currentState=g.type,this.change("complete",g)})),C(this,"onDurationchange",(g=>{this.ctx.currentState=g.type,this.change("durationchange",g)})),C(this,"onEmptied",(g=>{this.ctx.currentState=g.type,this.change("emptied",g)})),C(this,"onEnded",(g=>{this.ctx.currentState=g.type,this.change("ended",g)})),C(this,"onError",(g=>{this.ctx.currentState=g.type,this.change("error",g)})),C(this,"onLoadedmetadata",(g=>{this.ctx.currentState=g.type,this.change("loadedmetadata",g)})),C(this,"onLoadstart",(g=>{this.ctx.currentState=g.type,this.change("loadstart",g)})),C(this,"onProgress",(g=>{this.ctx.currentState=g.type,this.change("progress",g)})),C(this,"onRatechange",(g=>{this.ctx.currentState=g.type,this.change("ratechange",g)})),C(this,"onSeeked",(g=>{this.ctx.currentState=g.type,this.change("seeked",g)})),C(this,"onSeeking",(g=>{this.ctx.currentState=g.type,this.change("seeking",g)})),C(this,"onStalled",(g=>{this.ctx.currentState=g.type,this.change("stalled",g)})),C(this,"onSuspend",(g=>{this.ctx.currentState=g.type,this.change("suspend",g)})),C(this,"onLoadeddata",(g=>{this.ctx.currentState=g.type;const I=this.getTotalTime();this.ctx.duration=I,this._playerControllerBottomTimeCurrent.innerText="00:00",this._playerControllerBottomTimeDivide.innerText="/",this._playerControllerBottomTimeDuration.innerText=m(this.ctx.duration),this.change("loadeddata",g)})),C(this,"onTimeupdate",(g=>{this.ctx.currentState=g.type,this.change("timeupdate",g)})),C(this,"onVolumechange",(g=>{this.ctx.currentState=g.type,this.change("volumechange",g)})),C(this,"onWaiting",(g=>{this.ctx.currentState=g.type,this.change("waiting",g)})),C(this,"onPlay",(g=>{this.ctx.currentState=g.type,this.requestAnimationFrame(this.updateCurrentProgress),b(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),Z(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),this.showControllerBar(),this.change("play",g)})),C(this,"onPlaying",(g=>{this.ctx.currentState=g.type,this._playerBtn.style.setProperty("display","none"),b(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),Z(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),this.requestAnimationFrame(this.updateCurrentProgress),this.showControllerBar(),this.change("playing",g)})),C(this,"onPause",(g=>{this.ctx.currentState=g.type,this._playerBtn.style.setProperty("display","block"),this.change("pause",g),b(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),Z(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),this.cancelAnimationFrame(),this._playerController.style.setProperty("opacity","1"),this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0)})),C(this,"clearListenerEvent",(()=>{this._video&&(this._video.removeEventListener("canplay",this.onCanplay),this._video.removeEventListener("canplaythrough",this.onCanplaythrough),this._video.removeEventListener("complete",this.onComplete),this._video.removeEventListener("durationchange",this.onDurationchange),this._video.removeEventListener("emptied",this.onEmptied),this._video.removeEventListener("ended",this.onEnded),this._video.removeEventListener("error",this.onError),this._video.removeEventListener("loadeddata",this.onLoadeddata),this._video.removeEventListener("loadedmetadata",this.onLoadedmetadata),this._video.removeEventListener("loadstart",this.onLoadstart),this._video.removeEventListener("pause",this.onPause),this._video.removeEventListener("play",this.onPlay),this._video.removeEventListener("playing",this.onPlaying),this._video.removeEventListener("progress",this.onProgress),this._video.removeEventListener("ratechange",this.onRatechange),this._video.removeEventListener("seeked",this.onSeeked),this._video.removeEventListener("seeking",this.onSeeking),this._video.removeEventListener("stalled",this.onStalled),this._video.removeEventListener("suspend",this.onSuspend),this._video.removeEventListener("timeupdate",this.onTimeupdate),this._video.removeEventListener("volumechange",this.onVolumechange),this._video.removeEventListener("waiting",this.onWaiting))})),C(this,"listenEvent",(()=>{this._video&&(this.clearListenerEvent(),this._video.addEventListener("canplay",this.onCanplay),this._video.addEventListener("canplaythrough",this.onCanplaythrough),this._video.addEventListener("complete",this.onComplete),this._video.addEventListener("durationchange",this.onDurationchange),this._video.addEventListener("emptied",this.onEmptied),this._video.addEventListener("ended",this.onEnded),this._video.addEventListener("error",this.onError),this._video.addEventListener("loadeddata",this.onLoadeddata),this._video.addEventListener("loadedmetadata",this.onLoadedmetadata),this._video.addEventListener("loadstart",this.onLoadstart),this._video.addEventListener("pause",this.onPause),this._video.addEventListener("play",this.onPlay),this._video.addEventListener("playing",this.onPlaying),this._video.addEventListener("progress",this.onProgress),this._video.addEventListener("ratechange",this.onRatechange),this._video.addEventListener("seeked",this.onSeeked),this._video.addEventListener("seeking",this.onSeeking),this._video.addEventListener("stalled",this.onStalled),this._video.addEventListener("suspend",this.onSuspend),this._video.addEventListener("timeupdate",this.onTimeupdate),this._video.addEventListener("volumechange",this.onVolumechange),this._video.addEventListener("waiting",this.onWaiting))})),C(this,"showControllerBar",(g=>{if(g){if(g.target.classList.value.includes("ran-player-controller"))return this._playerController.style.setProperty("opacity","1"),void(this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0))}Bg.includes(this.ctx.currentState)?(this._playerController.style.setProperty("opacity","1"),this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0),this.controllerBarTimeId=setTimeout((()=>{this._playerController.style.setProperty("opacity","0"),clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0}),2e3)):(this._playerController.style.setProperty("opacity","1"),this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0))})),C(this,"progressClick",(g=>{const I=this._progressWrap.getBoundingClientRect(),C=g.clientX-I.left,A=V(C/this._progress.offsetWidth);this.setCurrentTime(this.ctx.duration*A),this.updateCurrentProgress()})),C(this,"progressDotMouseDown",(g=>{this._playerBtn.style.setProperty("display","none"),this.moveProgress.mouseDown=!0,this.cancelAnimationFrame()})),C(this,"progressDotMouseMove",(g=>{if(this.showControllerBar(g),!this.moveProgress.mouseDown)return;const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left-9,A=V(C/this._progress.offsetWidth);this._progressWrapValue.style.setProperty("transform",`scaleX(${A})`),this._progressDot.style.setProperty("transform",`translateX(${A*this._progress.offsetWidth}px)`),this.moveProgress.percentage=Math.floor(100*A)/100})),C(this,"progressDotMouseUp",(()=>{if(!this.moveProgress.mouseDown)return;const g=this.moveProgress.percentage;this.setCurrentTime(this.ctx.duration*g),this.play(),this.moveProgress.mouseDown=!1,this.requestAnimationFrame(this.updateCurrentProgress)})),C(this,"requestAnimationFrame",(g=>{this.requestAnimationFrameId||(this.requestAnimationFrameId=window.requestAnimationFrame((()=>{g(),this.requestAnimationFrameId&&cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=void 0,this.requestAnimationFrame(g)})))})),C(this,"cancelAnimationFrame",(()=>{this.requestAnimationFrameId&&(cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=void 0)})),C(this,"updateCurrentProgress",(()=>{const g=this.getCurrentTime();this.ctx.currentTime=g;const{duration:I}=this.ctx;this._progressWrapValue.style.setProperty("transform",`scaleX(${g/I})`),this._progressDot.style.setProperty("transform",`translateX(${g/I*this._progress.offsetWidth}px)`),g>=0&&(this._playerControllerBottomTimeCurrent.innerText=m(g))})),C(this,"changeAttribute",((g,I,C,A,i)=>{g===A&&I!==C&&yg(i)()})),C(this,"dispatchClickPlayerContainerAction",(g=>{g.stopPropagation(),g.preventDefault(),Bg.includes(this.ctx.currentState)?(this.pause(),this._playerBtn.style.setProperty("display","block")):(this.play(),this._playerBtn.style.setProperty("display","none"))})),C(this,"SpaceKeyDown",(g=>{const{currentTime:I,duration:C}=this.ctx;if("Space"===g.code&&this.dispatchClickPlayerBtnAction(g),"Escape"===g.code&&this.customExitFullscreen().then((()=>{this.ctx.fullScreen=!1})).catch((g=>{})),"ArrowLeft"===g.code){const g=V(I-5,0,C);this.setCurrentTime(g),this.play()}if("ArrowRight"===g.code){const g=V(I+5,0,C);this.setCurrentTime(g),this.play()}})),C(this,"dispatchClickPlayerBtnAction",(g=>{g.stopPropagation(),g.preventDefault(),Bg.includes(this.ctx.currentState)?(this.pause(),this._playerBtn.style.setProperty("display","block")):(this.play(),this._playerBtn.style.setProperty("display","none"))})),C(this,"changeVolumeProgress",(g=>{this._video&&(this.setVolume(g.detail.value),this.change("volume",g.detail.value),g.detail.value>0&&(this._volume=g.detail.value))})),C(this,"customRequestFullscreen",(g=>this._player.requestFullscreen()||this._player.mozRequestFullScreen()||this._player.msRequestFullscreen()||this._player.oRequestFullscreen()||this._player.webkitRequestFullscreen()||this._player.webkitEnterFullscreen())),C(this,"customExitFullscreen",(()=>document.exitFullscreen()||document.msExitFullscreen()||document.mozCancelFullScreen()||document.oCancelFullScreen()||document.webkitExitFullscreen())),C(this,"openFullScreen",(()=>{this.ctx.fullScreen?this.customExitFullscreen().then((()=>{this.resize(),this.ctx.fullScreen=!1})).catch((g=>{})):this.customRequestFullscreen().then((()=>{this.resize(),this.ctx.fullScreen=!0})).catch((g=>{}))})),C(this,"changeSpeed",(g=>{this.change("speed",g.detail.value),this.setPlaybackRate(g.detail.value)})),C(this,"progressMouseEnter",(g=>{this._playerTip.style.setProperty("opacity","1");const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left;this._playerTipText.innerText?this._playerTip.style.setProperty("transform",`translate(calc(${C}px - 50%),-20px)`):this._playerTip.style.setProperty("transform",`translateX(calc(${C}px - 50%))`),this._playerTipTime.innerText=m(C/this._progress.clientWidth*this.ctx.duration)})),C(this,"progressMouseLeave",(g=>{g.target.classList.contains("ran-player-controller-progress-wrap-dot")||this._playerTip.style.setProperty("opacity","0")})),C(this,"progressMouseMove",(g=>{const I=this._progress.getBoundingClientRect();this._playerTip.style.setProperty("opacity","1");const C=g.clientX-I.left;this._playerTipText.innerText?this._playerTip.style.setProperty("transform",`translate(calc(${C}px - 50%),-20px)`):this._playerTip.style.setProperty("transform",`translateX(calc(${C}px - 50%))`),this._playerTipTime.innerText=m(C/this._progress.clientWidth*this.ctx.duration)})),C(this,"changePlayerVolume",(()=>{if(!this._video)return;const{volume:g}=this.ctx;g>0?(Z(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-mute"),b(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-volume"),this._playControllerBottomVolumeProgress.setAttribute("percent","0"),this.setVolume(0),this.change("volume",0)):(Z(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-volume"),b(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-mute"),this._playControllerBottomVolumeProgress.setAttribute("percent",`${this._volume||.5}`),this.setVolume(.5),this.change("volume",this._volume||.5))})),C(this,"resize",(()=>{if(this._video){const{width:g,height:I}=this._player.getBoundingClientRect();this._video.style.setProperty("width",`${g}px`),this._video.style.setProperty("height",`${I}px`),document.body.clientWidth<500?this._playControllerBottomVolume.style.setProperty("display","none"):this._playControllerBottomVolume.style.setProperty("display","flex")}this.updateCurrentProgress()})),C(this,"fullScreenChange",(()=>{var g;(null==(g=document.fullscreenElement)?void 0:g.classList.contains("ran-player"))?(this.change("fullscreen",!0),this.ctx.fullScreen=!0):(this.change("fullscreen",!1),this.ctx.fullScreen=!1)})),C(this,"getPlaybackRate",(()=>(this._video&&(this.ctx.playbackRate=this._video.playbackRate||0),this.ctx.playbackRate))),C(this,"setPlaybackRate",(g=>(this._video&&(this.ctx.playbackRate=g,this._video.playbackRate=g),this.ctx.playbackRate))),C(this,"setVolume",(g=>(this._video&&(this.ctx.volume=g,this._video.volume=g),this.ctx.volume))),C(this,"getVolume",(()=>(this._video&&(this.ctx.volume=this._video.volume||0),this.ctx.volume))),C(this,"setCurrentTime",(g=>(this._video&&(this.ctx.currentTime=g,this._video.currentTime=g),this.ctx.currentTime))),C(this,"getCurrentTime",(()=>(this._video&&(this.ctx.currentTime=this._video.currentTime||0),this.ctx.currentTime))),C(this,"getTotalTime",(()=>(this._video&&(this.ctx.duration=this._video.duration||0),this.ctx.duration))),C(this,"play",(g=>{this._video&&(void 0!==g&&g>=0&&(this.ctx.currentTime=g,this._video.currentTime=g),this._video.play())})),C(this,"pause",(()=>{this._video&&this._video.pause()})),this.innerHTML="",this._player=document.createElement("div"),this._container=document.createElement("div"),this._slot=document.createElement("slot"),this._playerBtn=document.createElement("div"),this._progress=document.createElement("div"),this._progressWrap=document.createElement("div"),this._progressWrapValue=document.createElement("div"),this._progressDot=document.createElement("div"),this._playerControllerBottom=document.createElement("div"),this._playerControllerBottomRight=document.createElement("div"),this._playerControllerBottomLeft=document.createElement("div"),this._player.setAttribute("class","ran-player"),this._player.setAttribute("id","ran-player"+`${performance.now()}`.replace(".","")),this._playerBtn.setAttribute("class","ran-player-play-btn"),this._progress.setAttribute("class","ran-player-controller-progress"),this._progressWrap.setAttribute("class","ran-player-controller-progress-wrap"),this._progressWrapValue.setAttribute("class","ran-player-controller-progress-wrap-value"),this._progressDot.setAttribute("class","ran-player-controller-progress-dot"),this._playerControllerBottom.setAttribute("class","ran-player-controller-bottom"),this._playerControllerBottomRight.setAttribute("class","ran-player-controller-bottom-right"),this._playerControllerBottomLeft.setAttribute("class","ran-player-controller-bottom-left"),this._playerControllerBottomPlayBtn=document.createElement("div"),this._playerControllerBottomPlayBtn.setAttribute("class","ran-player-controller-bottom-left-btn"),this._playerControllerBottomTimeCurrent=document.createElement("div"),this._playerControllerBottomTimeCurrent.setAttribute("class","ran-player-controller-bottom-left-time-current"),this._playerControllerBottomTimeDivide=document.createElement("div"),this._playerControllerBottomTimeDivide.setAttribute("class","ran-player-controller-bottom-left-time-divide"),this._playerControllerBottomTimeDuration=document.createElement("div"),this._playerControllerBottomTimeDuration.setAttribute("class","ran-player-controller-bottom-left-time-duration"),this._playControllerBottomSpeed=document.createElement("div"),this._playControllerBottomSpeed.setAttribute("class","ran-player-controller-bottom-right-speed"),this._playControllerBottomSpeedPopover=document.createElement("r-select"),this._playControllerBottomSpeedPopover.setAttribute("value","1"),this._playControllerBottomSpeedPopover.setAttribute("trigger","hover,click"),this._playControllerBottomSpeedPopover.setAttribute("type","text"),this._playControllerBottomSpeedPopover.setAttribute("placement","top");const g=this._player.getAttribute("id");g&&this._playControllerBottomSpeedPopover.setAttribute("getPopupContainerId",g),this._playControllerBottomSpeedPopover.setAttribute("dropdownclass","video-speed-dropdown"),this._playControllerBottomSpeedPopover.addEventListener("change",this.changeSpeed);const I=document.createDocumentFragment();Vg.forEach((g=>{const{label:C,value:A}=g,i=document.createElement("r-option");i.innerHTML=C,i.setAttribute("value",`${A}`),I.appendChild(i)})),this._playControllerBottomSpeedPopover.appendChild(I),this._playControllerBottomSpeed.appendChild(this._playControllerBottomSpeedPopover),this._playControllerBottomVolume=document.createElement("div"),this._playControllerBottomVolume.setAttribute("class","ran-player-controller-bottom-right-volume"),this._playControllerBottomVolumeProgress=document.createElement("r-progress"),this._playControllerBottomVolumeProgress.setAttribute("class","ran-player-controller-bottom-right-volume-progress"),this._playControllerBottomVolumeProgress.setAttribute("percent","0.5"),this._playControllerBottomVolumeProgress.setAttribute("type","drag"),this._playControllerBottomSpeedIcon=document.createElement("div"),this._playControllerBottomSpeedIcon.setAttribute("class","ran-player-controller-bottom-right-volume-icon ran-player-controller-bottom-right-volume-icon-volume"),this._playControllerBottomClarity=document.createElement("div"),this._playControllerBottomClarity.setAttribute("class","ran-player-controller-bottom-right-clarity"),this._playControllerBottomRightFullScreen=document.createElement("div"),this._playControllerBottomRightFullScreen.setAttribute("class","ran-player-controller-bottom-right-full"),this._playerController=document.createElement("div"),this._playerController.setAttribute("class","ran-player-controller"),this._playerTip=document.createElement("div"),this._playerTip.setAttribute("class","ran-player-controller-tip"),this._playerTipTime=document.createElement("div"),this._playerTipTime.setAttribute("class","ran-player-controller-tip-time"),this._playerTipText=document.createElement("div"),this._playerTipText.setAttribute("class","ran-player-controller-tip-text"),this._playerTip.appendChild(G([this._playerTipTime,this._playerTipText])),this._playerController.appendChild(G([this._playerTip,this._progress,this._playerControllerBottom])),this._player.appendChild(G([this._container,this._slot,this._playerBtn,this._playerController])),this._progressWrap.appendChild(this._progressWrapValue),this._progress.appendChild(G([this._progressWrap,this._progressDot])),this._playerControllerBottom.appendChild(G([this._playerControllerBottomLeft,this._playerControllerBottomRight])),this._playerControllerBottomLeft.appendChild(G([this._playerControllerBottomPlayBtn,this._playerControllerBottomTimeCurrent,this._playerControllerBottomTimeDivide,this._playerControllerBottomTimeDuration])),this._playControllerBottomVolume.appendChild(G([this._playControllerBottomSpeedIcon,this._playControllerBottomVolumeProgress])),this._playerControllerBottomRight.appendChild(G([this._playControllerBottomClarity,this._playControllerBottomSpeed,this._playControllerBottomVolume,this._playControllerBottomRightFullScreen])),this.ctx={currentTime:0,duration:0,currentState:"",action:new R,volume:.5,playbackRate:1,clarity:"",fullScreen:!1,levels:[],url:"",levelMap:new Map},this.moveProgress={percentage:0,mouseDown:!1}}static get observedAttributes(){return["src","volume","currentTime","playbackRate","debug"]}get src(){return this.getAttribute("src")||""}set src(g){this.setAttribute("src",g||"")}get debug(){return this.getAttribute("debug")||""}set debug(g){this.setAttribute("debug",g||"")}get volume(){return this.getAttribute("volume")||""}set volume(g){this.setAttribute("volume",g||"")}get currentTime(){return this.getAttribute("currentTime")||""}set currentTime(g){this.setAttribute("currentTime",g||"")}get playbackRate(){return this.getAttribute("playbackRate")||""}set playbackRate(g){this.setAttribute("playbackRate",g||"")}connectedCallback(){this._container.addEventListener("click",this.dispatchClickPlayerContainerAction),this._playerBtn.addEventListener("click",this.dispatchClickPlayerBtnAction),this.addEventListener("keydown",this.SpaceKeyDown),this._progressDot.addEventListener("mousedown",this.progressDotMouseDown),this._playerControllerBottomPlayBtn.addEventListener("click",this.dispatchClickPlayerBtnAction),this._progress.addEventListener("click",this.progressClick),this._progress.addEventListener("mouseenter",this.progressMouseEnter),this._progress.addEventListener("mousemove",this.progressMouseMove),this._progress.addEventListener("mouseleave",this.progressMouseLeave),this._player.addEventListener("mousemove",this.progressDotMouseMove),this._player.addEventListener("mouseup",this.progressDotMouseUp),this._playControllerBottomVolumeProgress.addEventListener("change",this.changeVolumeProgress),this._playControllerBottomRightFullScreen.addEventListener("click",this.openFullScreen),this._playControllerBottomSpeedIcon.addEventListener("click",this.changePlayerVolume),document.addEventListener("fullscreenchange",this.fullScreenChange),window.addEventListener("resize",this.resize),this.updatePlayer()}disconnectCallback(){this._container.removeEventListener("click",this.dispatchClickPlayerContainerAction),this._playerBtn.removeEventListener("click",this.dispatchClickPlayerBtnAction),this._playerControllerBottomPlayBtn.removeEventListener("click",this.dispatchClickPlayerBtnAction),this.cancelAnimationFrame(),this.removeEventListener("keydown",this.SpaceKeyDown),this._progress.removeEventListener("click",this.progressClick),this._progress.removeEventListener("mouseenter",this.progressMouseEnter),this._progress.removeEventListener("mousemove",this.progressMouseMove),this._progress.removeEventListener("mouseleave",this.progressMouseLeave),this._progressDot.removeEventListener("mousedown",this.progressDotMouseDown),this._player.removeEventListener("mousemove",this.progressDotMouseMove),this._player.removeEventListener("mouseup",this.progressDotMouseUp),this._playControllerBottomVolumeProgress.removeEventListener("change",this.changeVolumeProgress),this._playControllerBottomRightFullScreen.removeEventListener("click",this.openFullScreen),window.removeEventListener("resize",this.resize),document.removeEventListener("fullscreenchange",this.fullScreenChange)}attributeChangedCallback(g,I,C){}}const Yg=function(){if("undefined"!=typeof document&&!customElements.get("r-player"))return customElements.define("r-player",Xg),Xg}(),Rg=Object.freeze(Object.defineProperty({__proto__:null,RanPlayer:Xg,default:Yg},Symbol.toStringTag,{value:"Module"}));const Ng=function(){if("undefined"!=typeof window&&!customElements.get("r-modal")){class g extends HTMLElement{constructor(){super()}}customElements.define("r-modal",g)}}(),Hg=Object.freeze(Object.defineProperty({__proto__:null,default:Ng},Symbol.toStringTag,{value:"Module"})),Kg=["percent","type","total","dot"];class fg extends(f()){constructor(){super(),C(this,"_progress"),C(this,"_progressWrap"),C(this,"_progressWrapValue"),C(this,"_progressDot"),C(this,"moveProgress"),C(this,"_shadowDom"),C(this,"progressClick",(g=>{const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left,A=Math.min(1,Math.max(0,C/this._progress.offsetWidth));this.percent=""+A*Number(this.total),this._progressWrapValue.style.setProperty("transform",`scaleX(${A})`),this._progressDot.style.setProperty("transform",`translateX(${A*this._progress.offsetWidth}px)`),this.change()})),C(this,"progressDotMouseDown",(()=>{this.moveProgress.mouseDown=!0})),C(this,"progressDotMouseMove",(g=>{if(!this.moveProgress.mouseDown)return;const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left,A=Math.min(1,Math.max(0,C/this._progress.offsetWidth));this.percent=""+A*Number(this.total),this._progressWrapValue.style.setProperty("transform",`scaleX(${A})`),this._progressDot.style.setProperty("transform",`translateX(${A*this._progress.offsetWidth}px)`),this.change()})),C(this,"progressDotMouseUp",(g=>{this.moveProgress.mouseDown&&(this.moveProgress.mouseDown=!1)})),C(this,"change",(()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.percent,percent:this.percent,total:this.total}}))})),C(this,"appendProgressDot",(()=>{"true"!==this.dot||this._progress.contains(this._progressDot)||this._progress.appendChild(this._progressDot),"false"===this.dot&&this._progress.contains(this._progressDot)&&this._progress.removeChild(this._progressDot)})),C(this,"updateCurrentProgress",(()=>{const g=Number(this.percent)/Number(this.total);this._progressWrapValue.style.setProperty("transform",`scaleX(${g})`),this._progressDot.style.setProperty("transform",`translateX(${g*this._progress.offsetWidth}px)`)})),C(this,"dragEvent",(()=>{"drag"===this.type&&(this._progress.addEventListener("click",this.progressClick),this._progressDot.addEventListener("mousedown",this.progressDotMouseDown),document.addEventListener("mousemove",this.progressDotMouseMove),document.addEventListener("mouseup",this.progressDotMouseUp))})),C(this,"resize",(()=>{this.updateCurrentProgress()})),this._progress=document.createElement("div"),this._progress.setAttribute("class","ran-progress"),this._progress.setAttribute("role","progressbar"),this._progressWrap=document.createElement("div"),this._progressWrap.setAttribute("class","ran-progress-wrap"),this._progress.appendChild(this._progressWrap),this._progressWrapValue=document.createElement("div"),this._progressWrapValue.setAttribute("class","ran-progress-wrap-value"),this._progressWrap.appendChild(this._progressWrapValue),this._progressDot=document.createElement("div"),this._progressDot.setAttribute("class","ran-progress-dot"),this.moveProgress={mouseDown:!1},this._progress.appendChild(this._progressDot);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host:active,:host:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-progress{position:var(--ran-progress-position, relative);cursor:var(--ran-progress-cursor, pointer);width:var(--ran-progress-width, 100%);height:var(--ran-progress-height, 100%)}.ran-progress:active,.ran-progress:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-progress-wrap{width:var(--ran-progress-wrap-width, 100%);height:var(--ran-progress-wrap-height, 8px);border-radius:var(--ran-progress-wrap-border-radius, 20px);background:var(--ran-progress-wrap-background, #5b5b5b);position:var(--ran-progress-wrap-position, relative);overflow:var(--ran-progress-wrap-overflow, hidden)}.ran-progress-wrap-value{position:var(--ran-progress-wrap-value-position, absolute);top:var(--ran-progress-wrap-value-top, 0);left:var(--ran-progress-wrap-value-left, 0);height:var(--ran-progress-wrap-value-height, 100%);width:var(--ran-progress-wrap-value-width, 100%);transform:var(--ran-progress-wrap-value-transform, scaleX(0));transform-origin:var(--ran-progress-wrap-value-transform-origin, 0 0);will-change:var(--ran-progress-wrap-value-will-change, transform);background:var(--ran-progress-wrap-value-background, linear-gradient(90deg, #0bc8bb 2.42%, #00d297 98.79%));border-radius:var(--ran-progress-wrap-value-border-radius, 20px)}.ran-progress-dot{position:var(--ran-progress-dot-position, absolute);top:var(--ran-progress-dot-top, -5px);left:var(--ran-progress-dot-left, -9px);border-radius:var(--ran-progress-dot-border-radius, 50%);width:var(--ran-progress-dot-width, 18px);height:var(--ran-progress-dot-height, 18px);background:var(--ran-progress-dot-background, linear-gradient(90deg, #0bc8bb 2.42%, #00d297 98.79%));cursor:var(--ran-progress-dot-cursor, pointer)}",g.appendChild(I),this._shadowDom=g,g.appendChild(this._progress)}static get observedAttributes(){return Kg}get percent(){const g=this.getAttribute("percent")||"",I=y(g);return Number(I)>Number(this.total)?(console.error("percent must be < total"),this.total):`${y(g)}`}set percent(g){this.setAttribute("percent",`${g||0}`),this.setAttribute("aria-valuenow",`${g||0}`)}get total(){const g=this.getAttribute("total");return g?`${y(g)}`:"1"}set total(g){this.setAttribute("total",g||"")}get type(){const g=this.getAttribute("type")||"";return["primary","drag"].includes(g)?g:"primary"}set type(g){this.setAttribute("type",g||"primary")}get animation(){const g=this.getAttribute("animation")||"";return["play","pause"].includes(g)?g:"pause"}set animation(g){this.setAttribute("animation",g||"pause")}get dot(){const g=this.getAttribute("dot")||"";return["true","false"].includes(g)?g:"true"}set dot(g){this.setAttribute("dot",g||"true")}connectedCallback(){this.getAttribute("type")||this.setAttribute("type","primary"),this.dragEvent(),this.updateCurrentProgress(),window.addEventListener("resize",this.resize)}disconnectCallback(){this._progress.removeEventListener("click",this.progressClick),this._progressDot.removeEventListener("mousedown",this.progressDotMouseDown),document.removeEventListener("mousemove",this.progressDotMouseMove),document.removeEventListener("mouseup",this.progressDotMouseUp),window.removeEventListener("resize",this.resize)}attributeChangedCallback(g,I,C){I!==C&&("dot"===g&&this.appendProgressDot(),"percent"===g&&this.updateCurrentProgress())}}const Fg="undefined"==typeof document||customElements.get("r-progress")?K("document is undefined or r-progress is exist"):(fg&&customElements.define("r-progress",fg),fg),Mg=Object.freeze(Object.defineProperty({__proto__:null,Progress:fg,default:Fg},Symbol.toStringTag,{value:"Module"}));class Sg extends(f()){constructor(){super(),C(this,"checkInput"),C(this,"checkInner"),C(this,"context"),C(this,"container"),C(this,"_shadowDom"),C(this,"updateChecked",(()=>{const{checked:g}=this.context;g?(this.setAttribute("checked","true"),this.setAttribute("value","true"),Z(this.container,"ran-checkbox-checked")):(this.setAttribute("checked","false"),this.setAttribute("value","false"),b(this.container,"ran-checkbox-checked"))})),C(this,"update",(()=>{this.updateChecked()})),C(this,"onChange",(()=>{if(N.includes(this.disabled))return;if(this.hasAttribute("disabled"))return;const{checked:g}=this.context;this.context.checked=!g,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.context.checked}})),this.update()})),this.checkInput=document.createElement("input"),this.checkInput.setAttribute("class","ran-checkbox-input"),this.checkInput.setAttribute("type","checkbox"),this.checkInner=document.createElement("span"),this.checkInner.setAttribute("class","ran-checkbox-inner"),this.container=w("div").setAttribute("class","ran-checkbox").addChild([this.checkInput,this.checkInner]).element;const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-checkbox-host-position, relative);display:var(--ran-checkbox-host-display, block);margin:var(--ran-checkbox-host-margin, 0);padding:var(--ran-checkbox-host-padding, 0);box-sizing:var(--ran-checkbox-host-box-sizing, border-box);list-style:var(--ran-checkbox-host-list-style, none)}:host([disabled]){opacity:var(--ran-checkbox-disabled-opacity, .6)}:host([disabled]) .ran-checkbox-input{cursor:var(--ran-checkbox-disabled-cursor, not-allowed);pointer-events:var(--ran-checkbox-disabled-pointer-events, all)}:host([disabled]) .ran-checkbox-inner{background-color:var(--ran-checkbox-checked-background-color, #d9d9d9);border:1px solid #d9d9d9}:host([disabled]) .ran-checkbox-inner:after{cursor:not-allowed;pointer-events:none;opacity:var(--ran-checkbox-checked-after-opacity, 1)}:host([disabled]) .ran-checkbox-checked .ran-checkbox-inner{background-color:var(--ran-checkbox-checked-background-color, #d9d9d9)}:host([disabled]) .ran-checkbox-checked .ran-checkbox-inner:after{opacity:var(--ran-checkbox-checked-after-opacity, 0)}.ran-checkbox{position:var(--ran-checkbox-position, relative);display:var(--ran-checkbox-display, block);box-sizing:var(--ran-checkbox-box-sizing, border-box);margin:var(--ran-checkbox-margin, 0);width:var(--ran-checkbox-width, 16px);height:var(--ran-checkbox-height, 16px);padding:var(--ran-checkbox-padding, 0);color:var(--ran-checkbox-color, rgba(0, 0, 0, .88));font-size:var(--ran-checkbox-font-size, 14px);line-height:var(--ran-checkbox-line-height, 1);list-style:var(--ran-checkbox-list-style, none);font-family:var(--ran-checkbox-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");white-space:var(--ran-checkbox-white-space, nowrap);cursor:var(--ran-checkbox-cursor, pointer);border-radius:var(--ran-checkbox-border-radius, 4px)}.ran-checkbox-input{position:var(--ran-checkbox-input-position, absolute);inset:var(--ran-checkbox-input-inset, 0);z-index:var(--ran-checkbox-input-z-index, 1);cursor:var(--ran-checkbox-input-cursor, pointer);opacity:var(--ran-checkbox-input-opacity, 0);margin:var(--ran-checkbox-input-margin, 0)}.ran-checkbox-inner{box-sizing:var(--ran-checkbox-inner-box-sizing, border-box);display:var(--ran-checkbox-inner-display, block);width:var(--ran-checkbox-inner-width, 16px);height:var(--ran-checkbox-inner-height, 16px);direction:var(--ran-checkbox-inner-direction, ltr);background-color:var(--ran-checkbox-inner-background-color, #fff);border:var(--ran-checkbox-inner-border, 1px solid #d9d9d9);border-radius:var(--ran-checkbox-inner-border-radius, 4px);border-collapse:var(--ran-checkbox-inner-border-collapse, separate)}.ran-checkbox-inner:after{box-sizing:var(--ran-checkbox-inner-after-box-sizing, border-box);position:var(--ran-checkbox-inner-after-position, absolute);top:var(--ran-checkbox-inner-after-top, 50%);inset-inline-start:var(--ran-checkbox-inner-after-inset-inline-start, 25%);display:var(--ran-checkbox-inner-after-display, table);width:var(--ran-checkbox-inner-after-width, calc(16px / 14 * 5));height:var(--ran-checkbox-inner-after-height, calc(16px / 14 * 8));border:var(--ran-checkbox-inner-after-border, 2px solid #fff);border-top:var(--ran-checkbox-inner-after-border-top, 0);border-inline-start:var(--ran-checkbox-inner-after-border-inline-start, 0);opacity:var(--ran-checkbox-inner-after-opacity, 0);content:var(--ran-checkbox-inner-after-content, "");transition:var(--ran-checkbox-inner-after-transition, all .1s cubic-bezier(.71, -.46, .88, .6), opacity .1s);transform:var(--ran-checkbox-inner-after-transform, rotate(45deg) scale(1) translate(-50%, -50%))}.ran-checkbox-checked .ran-checkbox-inner{background-color:var(--ran-checkbox-checked-background-color, #1677ff);border:var(--ran-checkbox-checked-border, 1px solid #1677ff)}.ran-checkbox-checked .ran-checkbox-inner:after{opacity:var(--ran-checkbox-checked-after-opacity, 1)}',g.appendChild(I),this._shadowDom=g,g.appendChild(this.container),this.context={checked:!1}}static get observedAttributes(){return["disabled","checked","value"]}get disabled(){return this.getAttribute("disabled")||""}set disabled(g){this.setAttribute("disabled",g)}get value(){const g=this.getAttribute("value");return N.includes(g)&&(this.context.checked=!1),`${this.context.checked}`}set value(g){N.includes(g)?(this.setAttribute("value","false"),this.context.checked=!1):(this.setAttribute("value","true"),this.context.checked=!0),this.updateChecked()}get checked(){const g=this.getAttribute("checked");return N.includes(g)&&(this.context.checked=!1),`${this.context.checked}`}set checked(g){N.includes(g)?(this.setAttribute("checked","false"),this.context.checked=!1):(this.setAttribute("checked","true"),this.context.checked=!0),this.updateChecked()}connectedCallback(){this.addEventListener("click",this.onChange)}disconnectCallback(){this.removeEventListener("click",this.onChange)}attributeChangedCallback(g,I,C){I!==C&&("checked"===g&&(this.checked=C,this.value=C),"value"===g&&(this.checked=C,this.value=C))}}const Jg="undefined"==typeof document||customElements.get("r-checkbox")?K("document is undefined or r-checkbox is exist"):(customElements.define("r-checkbox",Sg),Sg),kg=Object.freeze(Object.defineProperty({__proto__:null,Checkbox:Sg,default:Jg},Symbol.toStringTag,{value:"Module"})),Dg=g=>("#"===g[0]&&(g=g.substr(1)),3===g.length?{r:parseInt(g[0]+g[0],16),g:parseInt(g[1]+g[1],16),b:parseInt(g[2]+g[2],16)}:{r:parseInt(g.substr(0,2),16),g:parseInt(g.substr(2,2),16),b:parseInt(g.substr(4,2),16)}),vg=(g,I,C)=>{let A;const i=Math.max(g,I,C),e=i-Math.min(g,I,C);A=0===e?0:g===i?(I-C)/e%6:I===i?(C-g)/e+2:(g-I)/e+4,A=Math.round(60*A),A<0&&(A+=360);return{h:A,s:Math.round(100*(0===i?0:e/i)),v:Math.round(i/255*100)}},Lg=(g,I,C)=>{let A=[];const i=(C/=100)*(I/=100),e=g/60,t=i*(1-Math.abs(e%2-1)),l=C-i;return A=e>=0&&e<1?[i,t,0]:e>=1&&e<2?[t,i,0]:e>=2&&e<3?[0,i,t]:g>=3&&e<4?[0,t,i]:g>=4&&e<5?[t,0,i]:g>=5&&e<=6?[i,0,t]:[0,0,0],{r:Math.round(255*(A[0]+l)),g:Math.round(255*(A[1]+l)),b:Math.round(255*(A[2]+l))}},zg=/^#([\da-f]{6}|[\da-f]{3})$/i,Tg=/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/,xg=/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}(\.\d+)?)\)$/;class Ug extends(f()){constructor(){super(),C(this,"observer"),C(this,"_shadowDom"),C(this,"_slot"),C(this,"callback",((g,I)=>{for(const C of g)("childList"===C.type||"attributes"===C.type)&&this.onChange(C)})),C(this,"onChange",(g=>{this.dispatchEvent(new CustomEvent("change",{detail:{type:g.type,value:{content:this.children,mutation:g}}}))})),this._slot=w("slot").setAttribute("class","slot").element;const g=this.attachShadow({mode:"closed"});this._shadowDom=g;const I=w("style").setTextContent(".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{visibility:hidden;position:absolute}");g.appendChild(I.element),g.appendChild(this._slot),this.observer=new MutationObserver(this.callback)}connectedCallback(){this.observer.observe(this,{attributes:!0,childList:!0,subtree:!0})}disconnectCallback(){this.observer.disconnect()}}"undefined"==typeof document||customElements.get("r-content")?K("document is undefined or r-content is exist"):customElements.define("r-content",Ug);const jg={bottom:{add:"ran-dropdown-down-in",remove:"ran-dropdown-down-out"},top:{add:"ran-dropdown-up-in",remove:"ran-dropdown-up-out"}};class Qg extends(f()){constructor(){super(),C(this,"_slot"),C(this,"popoverBlock"),C(this,"popoverContent"),C(this,"popoverInner"),C(this,"popoverInnerBlock"),C(this,"_shadowDom"),C(this,"dropDownInTimeId"),C(this,"dropDownOutTimeId"),C(this,"removeTimeId"),C(this,"stopPropagation",(g=>{g.stopPropagation()})),C(this,"createContent",(g=>{var I,C,A;if(g){if(!this.popoverContent){const g=document.createElement("div");this.popoverContent=w("r-dropdown").setAttribute("class","ran-popover-dropdown").setStyle("display","none").setStyle("position","absolute").element,null==(I=this.popoverContent)||I.addEventListener("click",this.stopPropagation),this.popoverContent&&g.appendChild(this.popoverContent),this.trigger.includes("hover")&&!c()&&(null==(C=this.popoverContent)||C.addEventListener("mouseleave",this.blur),null==(A=this.popoverContent)||A.addEventListener("mouseenter",this.removeDropDownTimeId)),document.body.appendChild(g)}if(this.popoverContent&&g.length>0){this.popoverContent.innerHTML="";const I=document.createDocumentFragment();for(const C of g)I.appendChild(C);this.popoverContent.appendChild(I)}}})),C(this,"watchContent",(g=>{const{value:I}=g.detail;this.createContent(I.content)})),C(this,"blur",(()=>{this.removeTimeId&&this.removeDropDownTimeId(),this.removeTimeId=setTimeout((()=>{this.removeDropDownTimeId(),this.setDropdownDisplayNone()}),300)})),C(this,"removeDropDownTimeId",(()=>{this.trigger.includes("hover")&&!c()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)})),C(this,"setDropdownDisplayBlock",(()=>{var g;this.dropDownInTimeId||this.popoverContent&&"block"!==this.popoverContent.style.display&&(this.popoverContent.setAttribute("transit",jg[this.placement].add),null==(g=this.popoverContent)||g.style.setProperty("display","block"),this.dropDownInTimeId=setTimeout((()=>{this.popoverContent&&this.popoverContent.removeAttribute("transit"),clearTimeout(this.dropDownInTimeId),this.dropDownInTimeId=void 0}),300))})),C(this,"setDropdownDisplayNone",(()=>{this.dropDownOutTimeId||this.popoverContent&&"none"!==this.popoverContent.style.display&&(this.popoverContent.setAttribute("transit",jg[this.placement].remove),this.dropDownOutTimeId=setTimeout((()=>{var g;null==(g=this.popoverContent)||g.style.setProperty("display","none"),this.popoverContent&&this.popoverContent.removeAttribute("transit"),clearTimeout(this.dropDownOutTimeId),this.dropDownOutTimeId=void 0}),300))})),C(this,"placementPosition",(()=>{if(!this.popoverContent)return;const g=this.getBoundingClientRect(),{top:I,left:C,bottom:A,width:i,height:e}=g;let t=A+window.scrollY+4,l=C+window.scrollX;const s=document.getElementById(this.getPopupContainerId),o=this.popoverContent.getBoundingClientRect();if("top"===this.placement&&(t=I+window.scrollY-o.height-4,this.getPopupContainerId&&s)){l=C-s.getBoundingClientRect().left,t=I-s.getBoundingClientRect().top-this.popoverContent.clientHeight-4,l=C-s.getBoundingClientRect().left}this.popoverContent.style.setProperty("inset",`${t}px auto auto ${l}px`),this.popoverContent.style.setProperty("--ran-x",`${l}px`),this.popoverContent.style.setProperty("--ran-y",`${t}px`),this.popoverContent.style.setProperty("--ran-popover-width",`${i}px`),this.popoverContent.style.setProperty("--ran-popover-height",`${o.height}px`)})),C(this,"hoverPopover",(g=>{this.clickPopover(g)})),C(this,"clickContent",(g=>{g.stopPropagation()})),C(this,"clickPopover",(g=>{g.stopPropagation(),g.preventDefault(),this.setDropdownDisplayBlock(),this.placementPosition()})),C(this,"clickRemovePopover",(g=>{this.hoverRemovePopover(g)})),C(this,"popoverTrigger",(()=>{this.removeEventListener("mouseenter",this.hoverPopover),this.removeEventListener("mouseleave",this.blur),this.removeEventListener("click",this.clickPopover),this.trigger.includes("hover")&&(this.addEventListener("mouseenter",this.hoverPopover),this.addEventListener("mouseleave",this.blur)),this.addEventListener("click",this.clickPopover)})),C(this,"hoverRemovePopover",(g=>{g.stopPropagation(),this.setDropdownDisplayNone()})),C(this,"changePlacement",(()=>{var g;if(this.placement){const I="bottom"===this.placement?"top":"bottom";null==(g=this.popoverContent)||g.setAttribute("arrow",I)}})),this._slot=document.createElement("slot"),this._slot.setAttribute("class","slot"),this.popoverBlock=document.createElement("div"),this.popoverBlock.setAttribute("class","ran-popover-block"),this.popoverBlock.setAttribute("role","tooltip"),this.popoverBlock.appendChild(this._slot);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-popover-host-display, inline-block)}.ran-popover{box-sizing:var(--ran-popover-box-sizing, border-box);position:var(--ran-popover-position, relative);display:var(--ran-popover-display, inline-block);margin:var(--ran-popover-margin, 0);padding:var(--ran-popover-padding, 0)}.ran-popover-block{display:var(--ran-popover-block-display, inline-block)}",g.appendChild(I),this._shadowDom=g,g.appendChild(this.popoverBlock)}static get observedAttributes(){return["placement","arrow","trigger"]}get placement(){return this.getAttribute("placement")||"top"}set placement(g){this.setAttribute("placement",g)}get arrow(){return this.getAttribute("arrow")||""}set arrow(g){this.setAttribute("arrow",g)}get trigger(){return this.getAttribute("trigger")||"hover"}set trigger(g){this.setAttribute("trigger",g)}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(g){this.setAttribute("getPopupContainerId",g)}connectedCallback(){for(const g of this.children)"R-CONTENT"===g.tagName&&(g.addEventListener("change",this.watchContent),this.createContent(g.children));this.popoverTrigger(),this.changePlacement(),document.addEventListener("click",this.clickRemovePopover)}disconnectCallback(){this.removeEventListener("mouseenter",this.hoverPopover),this.removeEventListener("mouseleave",this.hoverRemovePopover),this.removeEventListener("click",this.hoverPopover),document.removeEventListener("click",this.clickRemovePopover)}attributeChangedCallback(g,I,C){I!==C&&("trigger"===g&&this.popoverTrigger(),"placement"===g&&this.changePlacement())}}const Og="undefined"==typeof document||customElements.get("r-popover")?K("document is undefined or r-popover is exist"):(customElements.define("r-popover",Qg),Qg),Eg=Object.freeze(Object.defineProperty({__proto__:null,Popover:Qg,default:Og},Symbol.toStringTag,{value:"Module"}));class Pg extends(f()){constructor(){super(),C(this,"_input"),C(this,"_label"),C(this,"_inputContent"),C(this,"_icon"),C(this,"customInput",(g=>{g.stopPropagation(),g.preventDefault();const{target:I,data:C=""}=g;this.value=(null==I?void 0:I.value)||C||"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))})),C(this,"customChange",(()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))})),C(this,"listenPlaceholder",((g,I)=>{"placeholder"===g&&this._inputContent&&(null!=I?this._inputContent.setAttribute("placeholder",I):this._inputContent.removeAttribute("placeholder"))})),C(this,"listenLabel",((g,I)=>{"label"===g&&this._inputContent&&(null!=I?this._label?this._label.innerHTML=I:(this._label=document.createElement("label"),this._label.innerHTML=I,this._label.setAttribute("class","ran-input-label"),this._label.setAttribute("part","ran-input-label"),this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))})),C(this,"listenType",((g,I)=>{"type"===g&&this._inputContent&&(I?this._inputContent.setAttribute("type",I):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))})),C(this,"listenStatus",((g,I)=>{"status"===g&&this._input&&(I?this._input.setAttribute("status",I):this._input.removeAttribute("status"))})),C(this,"listenDisabled",((g,I)=>{"disabled"===g&&this._input&&(N.includes(I)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))})),C(this,"listenIcon",((g,I,C)=>{"icon"===g&&I&&I!==C&&(this.removeAttribute("label"),this.setAttribute("icon",I),this.dealIcon())})),C(this,"dealIcon",(()=>{if(!this._icon){this._icon=document.createElement("ra-icon");const{width:g,height:I}=this._inputContent.getBoundingClientRect(),C=Math.min(g,I);this._icon.setAttribute("size",`${C}`),this._inputContent.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)})),C(this,"listenEvent",((g,I,C)=>{this.listenPlaceholder(g,C),this.listenLabel(g,C),this.listenStatus(g,C),this.listenDisabled(g,C),this.listenIcon(g,C,I),"value"===g&&I!==C&&(this._inputContent.value=C,this._input.setAttribute("value",C))})),this._input=document.createElement("div"),this._input.setAttribute("class","ran-input"),this._input.setAttribute("part","ran-input"),this._inputContent=document.createElement("input"),this._inputContent.setAttribute("class","ran-input-content"),this._inputContent.setAttribute("part","ran-input-content"),this._input.appendChild(this._inputContent)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","prefix","suffix","allowclear","count","maxlength","showcount","onPressEnter","variant","minrows","maxrows"]}get value(){return this.getAttribute("value")||""}set value(g){!H(this)&&g?(this.setAttribute("value",g),this._input.setAttribute("value",g)):(this.removeAttribute("value"),this._input.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(g){g?this.setAttribute("placeholder",g):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")||""}set required(g){g&&"false"!==g?this.setAttribute("required",""):this.removeAttribute("required")}get disabled(){return`${H(this)}`}set disabled(g){N.includes(g)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(g){this.setAttribute("label",g)}get status(){return this.getAttribute("status")||""}set status(g){g?(this.setAttribute("status",g),this._input.setAttribute("status",g)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(g){this.setAttribute("name",g)}get min(){return this.getAttribute("min")||""}set min(g){"number"===this.type&&this.setAttribute("min",g)}get max(){return this.getAttribute("max")||""}set max(g){"number"===this.type&&this.setAttribute("max",g)}get step(){return this.getAttribute("step")||""}set step(g){"number"===this.type&&this.setAttribute("step",g)}get icon(){return this.getAttribute("icon")||""}set icon(g){g?this.setAttribute("icon",g):this.removeAttribute("icon")}get prefix(){return this.getAttribute("prefix")||""}set prefix(g){g?this.setAttribute("prefix",g):this.removeAttribute("prefix")}get suffix(){return this.getAttribute("suffix")||""}set suffix(g){g?this.setAttribute("suffix",g):this.removeAttribute("suffix")}get type(){return this.getAttribute("type")||""}set type(g){g?this.setAttribute("type",g):this.removeAttribute("type")}connectedCallback(){this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this.status&&this._input.setAttribute("status",this.status),H(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this._inputContent.addEventListener("input",this.customInput),"complete"===document.readyState&&this.dealIcon(),this.appendChild(this._input)}disconnectCallback(){this._inputContent.removeEventListener("input",this.customInput)}attributeChangedCallback(g,I,C){this.listenEvent(g,I,C)}}"undefined"==typeof window||customElements.get("ra-input")?K("document is undefined or ra-input is exist"):customElements.define("ra-input",Pg),function(){if("undefined"==typeof document||customElements.get("ra-option"))return K("document is undefined or ra-option is exist");{class g extends HTMLElement{constructor(){super(),C(this,"_option"),C(this,"_optionContent"),C(this,"_shadowDom"),C(this,"_slot"),this._slot=document.createElement("slot"),this._option=document.createElement("div"),this._option.setAttribute("class","ran-option"),this._optionContent=document.createElement("div"),this._optionContent.setAttribute("class","ran-option-content"),this._optionContent.appendChild(this._slot),this._option.appendChild(this._optionContent);const g=this.attachShadow({mode:"closed"});this._shadowDom=g,g.appendChild(this._option)}static get observedAttributes(){return["disabled","sheet","value"]}get value(){return this.getAttribute("value")}set value(g){this.setAttribute("value",g||"")}get sheet(){return this.getAttribute("sheet")}set sheet(g){this.setAttribute("sheet",g||"")}get disabled(){return H(this)}set disabled(g){g&&"false"!==g?this.setAttribute("disabled",""):this.removeAttribute("disabled")}handlerExternalCss(){if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(g,I,C){"disabled"===g&&this._option&&(C&&"false"!==C?this._option.removeAttribute("disabled"):this._option.setAttribute("disabled","")),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}}}}();const _g="http://www.w3.org/1999/xlink";!function(){if("undefined"!=typeof window&&!customElements.get("ra-icon")){class g extends HTMLElement{constructor(){super(),C(this,"_icon"),C(this,"_div"),C(this,"loadLocal",(()=>new Promise(((g,I)=>{k(Object.assign({"../../assets/icons/add-user.svg":()=>Promise.resolve().then((()=>dI)),"../../assets/icons/arrow-down.svg":()=>Promise.resolve().then((()=>aI)),"../../assets/icons/book.svg":()=>Promise.resolve().then((()=>nI)),"../../assets/icons/check-circle-fill.svg":()=>Promise.resolve().then((()=>rI)),"../../assets/icons/check-circle.svg":()=>Promise.resolve().then((()=>mI)),"../../assets/icons/close-circle-fill.svg":()=>Promise.resolve().then((()=>hI)),"../../assets/icons/close-circle.svg":()=>Promise.resolve().then((()=>ZI)),"../../assets/icons/close.svg":()=>Promise.resolve().then((()=>bI)),"../../assets/icons/drop.svg":()=>Promise.resolve().then((()=>GI)),"../../assets/icons/eye-close.svg":()=>Promise.resolve().then((()=>uI)),"../../assets/icons/eye.svg":()=>Promise.resolve().then((()=>pI)),"../../assets/icons/home.svg":()=>Promise.resolve().then((()=>wI)),"../../assets/icons/info-circle-fill.svg":()=>Promise.resolve().then((()=>WI)),"../../assets/icons/info-circle.svg":()=>Promise.resolve().then((()=>BI)),"../../assets/icons/loading-scene.svg":()=>Promise.resolve().then((()=>yI)),"../../assets/icons/loading.svg":()=>Promise.resolve().then((()=>VI)),"../../assets/icons/lock.svg":()=>Promise.resolve().then((()=>XI)),"../../assets/icons/message.svg":()=>Promise.resolve().then((()=>YI)),"../../assets/icons/power-off.svg":()=>Promise.resolve().then((()=>RI)),"../../assets/icons/preview.svg":()=>Promise.resolve().then((()=>NI)),"../../assets/icons/setting.svg":()=>Promise.resolve().then((()=>HI)),"../../assets/icons/sprite.svg":()=>Promise.resolve().then((()=>fI)),"../../assets/icons/team.svg":()=>Promise.resolve().then((()=>FI)),"../../assets/icons/unlock.svg":()=>Promise.resolve().then((()=>MI)),"../../assets/icons/user.svg":()=>Promise.resolve().then((()=>SI)),"../../assets/icons/warning-circle-fill.svg":()=>Promise.resolve().then((()=>JI)),"../../assets/icons/warning-circle.svg":()=>Promise.resolve().then((()=>kI))}),`../../assets/icons/${this.name}.svg`,5).then((C=>{if(C&&C.default&&C.default._identification){const{data:I}=C.default;this._icon&&this._div.removeChild(this._icon),this._icon=i(I,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),g())}else this.loadNs(),I(`\n couldn't be loaded by ra-icon, message: ${this.name} icon is undefined`)})).catch((g=>{this.loadNs()}))})))),C(this,"loadNs",(()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const g=document.createElementNS(_g,"use");g.setAttributeNS(_g,"xlink:href",`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(g),this._div.appendChild(this._icon)})),C(this,"setIcon",(async()=>{this.name&&this.loadLocal()})),C(this,"setSize",(()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))})),C(this,"setColor",(()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))})),C(this,"setSpin",(()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)})),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon")}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(g){g&&this.setAttribute("name",g)}get size(){return this.getAttribute("size")}set size(g){g&&this.setAttribute("size",g)}get color(){return this.getAttribute("color")}set color(g){g&&this.setAttribute("color",g)}get spin(){return this.getAttribute("spin")}set spin(g){null!=g&&this.setAttribute("spin",g)}connectedCallback(){this.appendChild(this._div),this.setIcon()}attributeChangedCallback(g,I,C){C!==I&&("name"===g&&this.setIcon(),"size"===g&&this.setSize(),"color"===g&&this.setColor(),"spin"===g&&this.setSpin())}}customElements.define("ra-icon",g)}}();const qg={bottom:{add:"ran-select-dropdown-down-in",remove:"ran-select-dropdown-down-out"},top:{add:"ran-select-dropdown-up-in",remove:"ran-select-dropdown-up-out"}},$g=W();class gI extends(f()){constructor(){super(),C(this,"removeTimeId"),C(this,"_select"),C(this,"_selection"),C(this,"_search"),C(this,"_icon"),C(this,"_selectDropdown"),C(this,"_selectionDropdown"),C(this,"_selectDropDownInTimeId"),C(this,"_selectDropDownOutTimeId"),C(this,"_optionList"),C(this,"_optionLabelMapValue"),C(this,"_optionValueMapLabel"),C(this,"_activeOption"),C(this,"_text"),C(this,"_selector"),C(this,"onSearch"),C(this,"setSelectDropdownDisplayNone",(()=>{this._selectDropDownOutTimeId||this._selectionDropdown&&"none"!==this._selectionDropdown.style.display&&(Z(this._selectionDropdown,qg[this.placement].remove),this._selectDropDownOutTimeId=setTimeout((()=>{var g;null==(g=this._selectionDropdown)||g.style.setProperty("display","none"),this._selectionDropdown&&b(this._selectionDropdown,qg[this.placement].remove),clearTimeout(this._selectDropDownOutTimeId),this._selectDropDownOutTimeId=void 0}),300))})),C(this,"setSelectDropdownDisplayBlock",(()=>{var g;this._selectDropDownInTimeId||this._selectionDropdown&&"block"!==this._selectionDropdown.style.display&&(Z(this._selectionDropdown,qg[this.placement].add),null==(g=this._selectionDropdown)||g.style.setProperty("display","block"),this._selectDropDownInTimeId=setTimeout((()=>{this._selectionDropdown&&b(this._selectionDropdown,qg[this.placement].add),clearTimeout(this._selectDropDownInTimeId),this._selectDropDownInTimeId=void 0}),200))})),C(this,"placementPosition",(()=>{if(!this._selectionDropdown||!this._selectDropdown)return;const g=this.getBoundingClientRect(),{top:I,left:C,bottom:A,width:i,height:e,x:t,y:l,right:s}=g,o=document.getElementById(this.getPopupContainerId);this._selectionDropdown.style.setProperty("--ran-x",`${I+window.scrollX}`),this._selectionDropdown.style.setProperty("--ran-y",`${C+window.scrollY}`);let c=A+window.scrollY,d=C+window.scrollX;this._selectionDropdown.style.setProperty("width",`${i}px`),"top"===this.placement&&(c=I+window.scrollY-this._selectionDropdown.clientHeight),this.getPopupContainerId&&o&&(c="top"===this.placement?I-o.getBoundingClientRect().top-this._selectionDropdown.clientHeight:o.getBoundingClientRect().height,d=0),this._selectionDropdown.style.setProperty("inset",`${c}px auto auto ${d}px`)})),C(this,"selectMouseDown",(g=>{g.stopPropagation(),H(this)||(this.removeDropDownTimeId(),this.setSelectDropdownDisplayNone(),this.setSelectDropdownDisplayBlock(),this.placementPosition())})),C(this,"removeDropDownTimeId",(()=>{this._search.setAttribute("value",""),this.trigger.includes("hover")&&!c()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)})),C(this,"selectBlur",(()=>{this.removeTimeId&&this.removeDropDownTimeId(),this.removeTimeId=setTimeout((()=>{this.removeDropDownTimeId(),this.setSelectDropdownDisplayNone()}),100)})),C(this,"clickOption",(g=>{var I,C;g.stopPropagation();let A=g.target;if((null==(I=A.classList)?void 0:I.contains("ranui-select-dropdown-option-item"))&&(A=A.children[0]),!(null==(C=A.classList)?void 0:C.contains("ranui-select-dropdown-option-item-content")))return;const i=A.innerHTML,e=this._optionLabelMapValue.get(i);e&&(this.setAttribute("value",e),this._text.innerHTML=i,this._text.setAttribute("title",i),this._search.setAttribute("placeholder",i));const t=this.getBoundingClientRect(),{height:l}=t;this._text.style.setProperty("line-height",`${l}px`),this._activeOption&&b(this._activeOption,"ranui-select-dropdown-option-active"),setTimeout((()=>{this._activeOption=(null==A?void 0:A.parentElement)||void 0,this._activeOption&&Z(this._activeOption,"ranui-select-dropdown-option-active")}),200),this.setSelectDropdownDisplayNone(),this.dispatchEvent(new CustomEvent("change",{detail:{value:e,label:i}})),this.removeDropDownTimeId()})),C(this,"createOption",(()=>{if(!this._selectDropdown){this.appendChild(this._select);const g=document.getElementById(this.getPopupContainerId)||document.body;this._selectDropdown=document.createElement("div"),this._selectDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectDropdown.style.setProperty("outline","0"),this._selectDropdown.addEventListener("click",this.clickOption),this._selectionDropdown=document.createElement("div"),this._selectionDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectionDropdown.style.setProperty("outline","0"),this.dropdownclass?this._selectionDropdown.setAttribute("class",`${this.dropdownclass} ranui-select-dropdown`):this._selectionDropdown.setAttribute("class","ranui-select-dropdown"),this.trigger.includes("hover")&&!c()&&(this._selectDropdown.addEventListener("mouseleave",this.selectBlur),this._selectDropdown.addEventListener("mouseenter",this.removeDropDownTimeId)),this._selectDropdown.appendChild(this._selectionDropdown),this._selectionDropdown.style.setProperty("display","none"),g.appendChild(this._selectDropdown)}this.addOptionToSlot()})),C(this,"removeSelectDropdown",(()=>{try{if(this._selectDropdown){(document.getElementById(this.getPopupContainerId)||document.body).removeChild(this._selectDropdown)}}catch(g){}})),C(this,"addOptionToSlot",(()=>{var g;const I=this.children||[];this._optionList=[];for(const C of I)if("R-OPTION"===C.tagName){const I=C.innerHTML,A=C.getAttribute("value")||"";null==(g=this._optionList)||g.push({label:I,value:A}),this._optionLabelMapValue.set(I,A),this._optionValueMapLabel.set(A,I)}this.createSelectDropdownContent(this._optionList)})),C(this,"createSelectDropdownContent",((g=[])=>{var I,C;0===g.length?null==(I=this._selectDropdown)||I.style.setProperty("display","none"):null==(C=this._selectDropdown)||C.style.setProperty("display","block"),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),g.forEach((g=>{if(this._selectionDropdown){const{label:I,value:C}=g,A=document.createElement("div");(this.getAttribute("defaultValue")||this.getAttribute("value"))===C?(A.setAttribute("class","ranui-select-dropdown-option-active ranui-select-dropdown-option-item"),this._activeOption=A):A.setAttribute("class","ranui-select-dropdown-option-item");const i=document.createElement("div");i.setAttribute("class","ranui-select-dropdown-option-item-content"),i.innerHTML=`${I}`,i.setAttribute("value",`${C}`),i.setAttribute("title",`${I}`),A.appendChild(i),this._selectionDropdown.appendChild(A)}})),this.setDefaultValue()})),C(this,"setDefaultValue",(()=>{const g=this.getAttribute("defaultValue")||this.getAttribute("value");if(!g)return;const I=this._optionValueMapLabel.get(g);if(!I)return;this.setAttribute("value",g);const C=this.getBoundingClientRect(),{height:A}=C;this._text.style.setProperty("line-height",`${A}px`),this._text.innerHTML=I,this._text.setAttribute("title",I)})),C(this,"changeSearch",(g=>{const I=g.detail.value||"";if(this.dispatchEvent(new CustomEvent("search",{detail:{value:I}})),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),I.length>0){const g=this._optionList.map((g=>{const{label:C}=g;if(`${C}`.toLowerCase().includes(I))return{label:C,value:g.value}})).filter((g=>g));this.createSelectDropdownContent(g)}else this.createSelectDropdownContent(this._optionList)})),C(this,"setShowSearch",(()=>{this.onSearch=$g(this.changeSearch),this.onSearch&&this._search.addEventListener("change",this.onSearch),this.onSearch&&this._search.addEventListener("click",this.onSearch)})),C(this,"removeShowSearch",(()=>{this.onSearch&&this._search.removeEventListener("change",this.onSearch),this.onSearch&&this._search.removeEventListener("click",this.onSearch)})),C(this,"listenActionEvent",(()=>{this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.trigger.includes("hover")&&!c()&&(this.addEventListener("mouseenter",this.selectMouseDown),this.addEventListener("mouseleave",this.selectBlur)),this.trigger.includes("click")&&(this.addEventListener("click",this.selectMouseDown),this.addEventListener("blur",this.selectBlur))})),C(this,"clickRemoveSelect",(g=>{g.stopPropagation(),this.setSelectDropdownDisplayNone()})),this._select=document.createElement("div"),this._select.setAttribute("class","ran-select"),this._select.setAttribute("part","select"),this._selection=document.createElement("div"),this._selection.setAttribute("class","selection"),this._selection.setAttribute("part","selection"),this._selector=document.createElement("div"),this._search=document.createElement("ra-input"),this._search.setAttribute("class","selection-search"),this._search.setAttribute("part","search"),this._search.setAttribute("type","search"),this._search.setAttribute("autocomplete","off"),this._text=document.createElement("span"),this._text.setAttribute("class","selection-item"),this._text.setAttribute("part","selection-item"),this._icon=document.createElement("ra-icon"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("part","icon"),this._icon.setAttribute("name","arrow-down"),this._icon.setAttribute("color","#d9d9d9"),this._icon.setAttribute("size","16"),this._selector.appendChild(this._text),this._selector.appendChild(this._search),this._selection.appendChild(this._icon),this._selection.appendChild(this._selector),this._select.appendChild(this._selection),this._optionList=[],this._optionLabelMapValue=new Map,this._optionValueMapLabel=new Map}static get observedAttributes(){return["disabled","sheet","clear","type","defaultValue","showSearch","placement","getPopupContainerId","dropdownclass","trigger"]}get value(){return this.getAttribute("value")||""}set value(g){!H(this)&&g?this.setAttribute("value",g):this.removeAttribute("value")}get defaultValue(){return this.getAttribute("defaultValue")||""}set defaultValue(g){this.setAttribute("defaultValue",g||"")}get showSearch(){return this.getAttribute("showSearch")||""}set showSearch(g){this.setAttribute("showSearch",g||"")}get type(){return this.getAttribute("type")||""}set type(g){this.setAttribute("type",g||"")}get placement(){return this.getAttribute("placement")||"bottom"}set placement(g){this.setAttribute("placement",g||"")}get sheet(){return this.getAttribute("sheet")||""}set sheet(g){this.setAttribute("sheet",g||"")}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(g){this.setAttribute("getPopupContainerId",g||"")}get dropdownclass(){return this.getAttribute("dropdownclass")||""}set dropdownclass(g){this.setAttribute("dropdownclass",g||"")}get trigger(){return this.getAttribute("trigger")||"click"}set trigger(g){this.setAttribute("trigger",g||"")}get disabled(){return H(this)}set disabled(g){g&&"false"!==g?(this.setAttribute("disabled",""),this._selection.setAttribute("disabled","")):(this.removeAttribute("disabled"),this._selection.removeAttribute("disabled"))}connectedCallback(){this.createOption(),this.listenActionEvent(),this.setShowSearch(),document.addEventListener("click",this.clickRemoveSelect)}disconnectCallback(){var g;this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.removeSelectDropdown(),null==(g=this._selectDropdown)||g.removeEventListener("click",this.clickOption),document.removeEventListener("click",this.clickRemoveSelect)}attributeChangedCallback(g,I,C){"disabled"===g&&this._select&&(C&&"false"!==C?(this._select.removeAttribute("disabled"),this._selection.removeAttribute("disabled")):(this._select.setAttribute("disabled",""),this._selection.setAttribute("disabled","")))}}"undefined"==typeof document||customElements.get("ra-select")?K("document is undefined or ra-select is exist"):customElements.define("ra-select",gI);class II extends(f()){constructor(){super(),C(this,"colorpicker"),C(this,"colorpickerInner"),C(this,"context"),C(this,"popoverBlock"),C(this,"popoverContent"),C(this,"colorPickerInner"),C(this,"colorPickerInnerContent"),C(this,"colorPickerPanel"),C(this,"colorPickerInputContainer"),C(this,"colorPickerPanelDot"),C(this,"colorPickerPanelSliderContainer"),C(this,"colorPickerPanelSliderGroup"),C(this,"colorPickerPanelSliderHue"),C(this,"colorPickerPanelSliderAlpha"),C(this,"colorPickerColorBlockInner"),C(this,"colorPickerColorBlock"),C(this,"colorPickerInnerContentSelect"),C(this,"colorPickerPanelPalette"),C(this,"colorPickerPanelSaturation"),C(this,"colorPickerInputContainerSelect"),C(this,"colorPickerInputContainerInputColor"),C(this,"colorPickerInputContainerInputNumber"),C(this,"colorPickerInputContainerSelectItem"),C(this,"colorPickerPaletteSelect"),C(this,"colorPickerPanelDotInner"),C(this,"createContext",(()=>{this.context={value:this.createColorValueSignal(),disabled:this.createColorDisabled(),hue:this.createColorHue(),saturation:this.createColorSaturation(),lightness:this.createColorLightness(),transparency:this.createColorTransparency()}})),C(this,"createColorHue",(()=>{const[g,I]=F(0,{subscriber:[this.updateColorPickerPanelSaturationBackground,this.updateColorPickerPanelSliderHueProgressPercent,this.updateColorPickerPanelSliderAlphaProgressWrap,this.updateColorPickerPanelSliderAlphaProgressDot,this.updateColorPickerColorBlockInnerBackground,this.updateColorPickerPanelSliderHueProgressDot]});return{getter:g,setter:I}})),C(this,"createColorSaturation",(()=>{const[g,I]=F(100,{subscriber:[this.updateColorPickerPanelSliderAlphaProgressWrap,this.updateColorPickerPanelSliderAlphaProgressDot,this.updateColorPickerColorBlockInnerBackground]});return{getter:g,setter:I}})),C(this,"createColorLightness",(()=>{const[g,I]=F(100,{subscriber:[this.updateColorPickerPanelSliderAlphaProgressWrap,this.updateColorPickerPanelSliderAlphaProgressDot,this.updateColorPickerColorBlockInnerBackground]});return{getter:g,setter:I}})),C(this,"createColorTransparency",(()=>{const[g,I]=F(80,{subscriber:[this.updateColorPickerPanelSliderAlphaProgressPercent,this.updateColorPickerColorBlockInnerBackground,this.updateColorPickerPanelSliderAlphaProgressDot]});return{getter:g,setter:I}})),C(this,"createColorDisabled",(()=>{const[g,I]=F(!0,{subscriber:[]});return{getter:g,setter:I}})),C(this,"createColorValueSignal",(()=>{const[g,I]=F("",{subscriber:[this.updateColorValue]});return{getter:g,setter:I}})),C(this,"generateHue2rgb",(()=>{const{hue:g}=this.context,{r:I,g:C,b:A}=Lg(g.getter(),100,100);return`rgb(${I}, ${C}, ${A})`})),C(this,"generateHsv2Rgb",(()=>{const{r:g,g:I,b:C}=this.generateHsv2Rgba();return`rgb(${g}, ${I}, ${C})`})),C(this,"generateHsv2Rgba",(()=>{const{hue:g,saturation:I,lightness:C,transparency:A}=this.context,{r:i,g:e,b:t}=Lg(g.getter(),I.getter(),C.getter());return{r:i,g:e,b:t,a:A.getter()/100}})),C(this,"generateHsv2RgbaValue",(()=>{const{r:g,g:I,b:C,a:A}=this.generateHsv2Rgba();return`rgb(${g}, ${I}, ${C}, ${A})`})),C(this,"generateColorPickerProgress",(()=>{const{r:g,g:I,b:C}=this.generateHsv2Rgba();return`linear-gradient(to right, rgba(255, 0, 4, 0), rgba(${g}, ${I}, ${C}, 1))`})),C(this,"updateColorValue",(g=>{var I,C;if(g!==(null==(I=this.context)?void 0:I.value.getter())){const I=zg.exec(g),A=Tg.exec(g.replace(/\s+/g,"")),i=xg.exec(g.replace(/\s+/g,""));if(I){const{h:g,s:C,v:A}=(g=>{const{r:I,g:C,b:A}=Dg(g);return vg(I,C,A)})(I[0]);this.context.hue.setter(g),this.context.saturation.setter(C),this.context.lightness.setter(A),this.context.transparency.setter(100)}else if(i){const{h:g,s:I,v:C}=vg(Number(i[1]),Number(i[2]),Number(i[3]));this.context.hue.setter(g),this.context.saturation.setter(I),this.context.lightness.setter(C),this.context.transparency.setter(Number(i[4]))}else{if(!A)return;{const{h:g,s:I,v:C}=vg(Number(A[1]),Number(A[2]),Number(A[3]));this.context.hue.setter(g),this.context.saturation.setter(I),this.context.lightness.setter(C),this.context.transparency.setter(100)}}this.setAttribute("value",g),this.colorpickerInner.style.setProperty("background",g),null==(C=this.context)||C.value.setter(g)}})),C(this,"updateColorPickerPanelSliderHueProgressPercent",(g=>{var I;null==(I=this.colorPickerPanelSliderHue)||I.setAttribute("percent",""+g/360)})),C(this,"updateColorPickerPanelSliderAlphaProgressPercent",(g=>{var I;null==(I=this.colorPickerPanelSliderAlpha)||I.setAttribute("percent",""+g/100)})),C(this,"updateColorPickerPanelSliderAlphaProgressWrap",(()=>{var g;null==(g=this.colorPickerPanelSliderAlpha)||g.style.setProperty("--ran-progress-wrap-background",this.generateColorPickerProgress())})),C(this,"updateColorPickerPanelSliderAlphaProgressDot",(()=>{var g;null==(g=this.colorPickerPanelSliderAlpha)||g.style.setProperty("--ran-progress-dot-background",this.generateHsv2RgbaValue())})),C(this,"updateColorPickerPanelSliderHueProgressDot",(()=>{var g;null==(g=this.colorPickerPanelSliderHue)||g.style.setProperty("--ran-progress-dot-background",this.generateHue2rgb())})),C(this,"updateColorPickerColorBlockInnerBackground",(()=>{var g;null==(g=this.colorPickerColorBlockInner)||g.style.setProperty("background",this.generateHsv2RgbaValue())})),C(this,"updateColorPickerPanelSaturationBackground",(()=>{var g;null==(g=this.colorPickerPanelSaturation)||g.style.setProperty("background-color",this.generateHue2rgb())})),C(this,"clickStop",(g=>{g.stopPropagation(),g.preventDefault()})),C(this,"changeColorPalettePositionByContext",(()=>{window.requestAnimationFrame((()=>{var g,I,C,A,i;if(this.updateColorValue(this.value),!this.colorPickerPanelPalette)return;if(!(null==(g=this.context)?void 0:g.lightness.getter)||!(null==(I=this.context)?void 0:I.saturation.getter))return;const{width:e,height:t}=(null==(C=this.colorPickerPanelPalette)?void 0:C.getBoundingClientRect())||{},l=t-this.context.lightness.getter()/100*t,s=this.context.saturation.getter()/100*e;null==(A=this.colorPickerPanelDot)||A.style.setProperty("top",l-8+"px"),null==(i=this.colorPickerPanelDot)||i.style.setProperty("left",s-8+"px")}))})),C(this,"changeColorPalettePosition",((g,I)=>{var C,A,i;if(!this.colorPickerPanelPalette)return;if(!(null==(C=this.context)?void 0:C.lightness.getter)||!(null==(A=this.context)?void 0:A.saturation.getter))return;const{width:e,height:t}=(null==(i=this.colorPickerPanelPalette)?void 0:i.getBoundingClientRect())||{},l=t-V(I,0,t),s=V(g,0,e);this.context.saturation.setter(s/e*100),this.context.lightness.setter(l/t*100),window.requestAnimationFrame((()=>{var C,A;null==(C=this.colorPickerPanelDot)||C.style.setProperty("top",I-8+"px"),null==(A=this.colorPickerPanelDot)||A.style.setProperty("left",g-8+"px")}))})),C(this,"clickColorPalette",(g=>{const{offsetX:I,offsetY:C}=g;this.changeColorPalettePosition(I,C)})),C(this,"createColorPickerProgress",(()=>{this.colorPickerPanelSliderContainer=document.createElement("div"),this.colorPickerPanelSliderContainer.setAttribute("class","ran-color-picker-slider-container"),this.colorPickerPanelSliderGroup=document.createElement("div"),this.colorPickerPanelSliderGroup.setAttribute("class","ran-color-picker-slider-container-group"),this.colorPickerPanelSliderHue=document.createElement("r-progress"),this.updateColorPickerPanelSliderHueProgressDot(),this.colorPickerPanelSliderHue.style.setProperty("--ran-progress-wrap-background","linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"),this.colorPickerPanelSliderHue.setAttribute("percent",""+this.context.hue.getter()/360),this.colorPickerPanelSliderHue.addEventListener("change",this.changeColorPickerHue),this.colorPickerPanelSliderHue.setAttribute("type","drag"),this.colorPickerPanelSliderHue.setAttribute("class","ran-color-picker-slider-container-group-hue"),this.colorPickerPanelSliderAlpha=document.createElement("r-progress"),this.updateColorPickerPanelSliderAlphaProgressDot(),this.colorPickerPanelSliderAlpha.setAttribute("percent",""+this.context.transparency.getter()/100),this.updateColorPickerPanelSliderAlphaProgressWrap(),this.colorPickerPanelSliderAlpha.addEventListener("change",this.changeColorPickerAlpha),this.colorPickerPanelSliderAlpha.setAttribute("type","drag"),this.colorPickerPanelSliderAlpha.setAttribute("class","ran-color-picker-slider-container-group-alpha"),this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderHue),this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderAlpha),this.colorPickerPanelSliderContainer.appendChild(this.colorPickerPanelSliderGroup),this.colorPickerColorBlock=document.createElement("div"),this.colorPickerColorBlock.setAttribute("class","ran-color-picker-slider-container-color-block"),this.colorPickerColorBlockInner=document.createElement("div"),this.colorPickerColorBlockInner.setAttribute("class","ran-color-picker-slider-container-color-block-inner"),this.updateColorPickerColorBlockInnerBackground(),this.colorPickerColorBlock.appendChild(this.colorPickerColorBlockInner),this.colorPickerPanelSliderContainer.appendChild(this.colorPickerColorBlock)})),C(this,"changeColorPickerHue",(g=>{this.context.hue.setter(360*g.detail.value)})),C(this,"changeColorPickerAlpha",(g=>{this.context.transparency.setter(100*g.detail.value)})),C(this,"createColorPickerSelect",(()=>{this.colorPickerPanel=document.createElement("div"),this.colorPickerPanel.setAttribute("class","ran-color-picker-panel"),this.colorPickerInnerContentSelect=document.createElement("div"),this.colorPickerInnerContentSelect.setAttribute("class","ran-color-picker-select"),this.colorPickerPanel.appendChild(this.colorPickerInnerContentSelect),this.colorPickerPanelPalette=document.createElement("div"),this.colorPickerPanelPalette.setAttribute("class","ran-color-picker-palette"),this.colorPickerInnerContentSelect.appendChild(this.colorPickerPanelPalette),this.colorPickerPanelSaturation=document.createElement("div"),this.colorPickerPanelSaturation.setAttribute("class","ran-color-picker-saturation"),this.updateColorPickerPanelSaturationBackground(),this.colorPickerPanelDot=document.createElement("div"),this.colorPickerPanelDotInner=document.createElement("div"),this.colorPickerPanelDotInner.setAttribute("class","ran-color-picker-palette-dot-inner"),this.colorPickerPanelDot.setAttribute("class","ran-color-picker-palette-dot"),this.colorPickerPanelDot.addEventListener("mousedown",this.mouseDownColorPickerPalette),document.body.addEventListener("mousemove",this.mouseMoveColorPickerPalette),this.colorPickerPanelDot.addEventListener("mouseup",this.mouseUpColorPickerPalette),this.colorPickerPanelDot.appendChild(this.colorPickerPanelDotInner),this.colorPickerPanelPalette.appendChild(this.colorPickerPanelDot),this.colorPickerPanelPalette.appendChild(this.colorPickerPanelSaturation),this.colorPickerPanelPalette.addEventListener("mousedown",this.clickColorPalette)})),C(this,"createColorPickerInput",(()=>{this.colorPickerInputContainer=document.createElement("div"),this.colorPickerInputContainer.setAttribute("class","ran-color-picker-input-container");const g=`${performance.now()}`.replace(".","");this.colorPickerInputContainerSelect=document.createElement("div"),this.colorPickerInputContainerSelect.setAttribute("class","ran-color-picker-input-container-select"),this.colorPickerInputContainerSelect.setAttribute("id",g),this.colorPickerInputContainerSelectItem=document.createElement("ra-select"),this.colorPickerInputContainerSelectItem.setAttribute("value","HEX"),this.colorPickerInputContainerSelectItem.setAttribute("class","ran-color-picker-input-container-select-item"),this.colorPickerInputContainerSelectItem.setAttribute("type","text"),this.colorPickerInputContainerSelectItem.setAttribute("getPopupContainerId",g);const I=document.createDocumentFragment();["HEX","HSB","RGB"].forEach((g=>{const C=document.createElement("r-option");C.setAttribute("value",g),C.innerText=g,I.appendChild(C)})),this.colorPickerInputContainerSelectItem.appendChild(I),this.colorPickerInputContainerSelect.appendChild(this.colorPickerInputContainerSelectItem),this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerSelect),this.colorPickerInputContainerInputColor=document.createElement("ra-input"),this.colorPickerInputContainerInputColor.setAttribute("class","ran-color-picker-input-container-input-color"),this.colorPickerInputContainerInputNumber=document.createElement("ra-input"),this.colorPickerInputContainerInputNumber.setAttribute("class","ran-color-picker-input-container-input-number"),this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputColor),this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputNumber)})),C(this,"openColorPicker",(()=>{this.colorPickerInner||(this.colorPickerInner=document.createElement("div"),this.colorPickerInner.setAttribute("class","ran-color-picker-inner"),this.colorPickerInnerContent=document.createElement("div"),this.colorPickerInnerContent.setAttribute("class","ran-color-picker-inner-content"),this.createColorPickerProgress(),this.createColorPickerSelect(),this.createColorPickerInput(),this.colorPickerPanel&&this.colorPickerInnerContent.appendChild(this.colorPickerPanel),this.colorPickerPanelSliderContainer&&this.colorPickerInnerContent.appendChild(this.colorPickerPanelSliderContainer),this.colorPickerInputContainer&&this.colorPickerInnerContent.appendChild(this.colorPickerInputContainer),this.colorPickerInner.appendChild(this.colorPickerInnerContent),this.popoverContent.appendChild(this.colorPickerInner),this.changeColorPalettePositionByContext())})),C(this,"mouseMoveColorPickerPalette",(g=>{var I;if(!this.colorPickerPanelPalette||!this.colorPickerPaletteSelect)return;const{pageX:C,pageY:A}=g,{top:i=0,left:e=0,width:t,height:l}=(null==(I=this.colorPickerPanelPalette)?void 0:I.getBoundingClientRect())||{},s=V(A-i-8,-8,l-8),o=V(C-e-8,-8,t-8);this.context.saturation.setter(o/t*100),this.context.lightness.setter(s/l*100),window.requestAnimationFrame((()=>{var g,I;null==(g=this.colorPickerPanelDot)||g.style.setProperty("top",`${s}px`),null==(I=this.colorPickerPanelDot)||I.style.setProperty("left",`${o}px`)}))})),C(this,"mouseDownColorPickerPalette",(g=>{g.stopPropagation(),g.preventDefault(),this.colorPickerPaletteSelect=!0})),C(this,"mouseUpColorPickerPalette",(g=>{this.colorPickerPaletteSelect=!1})),this.setAttribute("class","ran-colorpicker"),this.popoverBlock=document.createElement("r-popover"),this.popoverBlock.setAttribute("class","ran-popover"),this.popoverContent=document.createElement("r-content"),this.popoverContent.setAttribute("class","ran-content"),this.colorpicker=document.createElement("div"),this.colorpicker.setAttribute("class","ran-colorpicker-block"),this.colorpickerInner=document.createElement("div"),this.colorpickerInner.setAttribute("class","ran-colorpicker-inner"),this.popoverBlock.appendChild(this.colorpicker),this.popoverBlock.appendChild(this.popoverContent),this.colorpicker.appendChild(this.colorpickerInner),this.appendChild(this.popoverBlock),this.colorPickerPaletteSelect=!1,this.createContext()}static get observedAttributes(){return["disabled","value"]}get value(){var g;return(null==(g=this.context)?void 0:g.value.getter())||""}set value(g){this.setAttribute("value",g),this.updateColorValue(g)}connectedCallback(){this.popoverBlock.addEventListener("click",this.openColorPicker)}disconnectCallback(){var g,I,C;this.popoverBlock.removeEventListener("click",this.openColorPicker),null==(g=this.colorPickerPanelDot)||g.removeEventListener("mousedown",this.mouseDownColorPickerPalette),document.body.removeEventListener("mousemove",this.mouseMoveColorPickerPalette),null==(I=this.colorPickerPanelDot)||I.removeEventListener("mouseup",this.mouseUpColorPickerPalette),null==(C=this.colorPickerPanelPalette)||C.removeEventListener("mousedown",this.clickColorPalette)}attributeChangedCallback(g,I,C){I!==C&&"value"===g&&this.updateColorValue(C)}}const CI="undefined"==typeof document||customElements.get("r-colorpicker")?K("document is undefined or r-colorpicker is exist"):(customElements.define("r-colorpicker",II),II),AI=Object.freeze(Object.defineProperty({__proto__:null,ColorPicker:II,default:CI},Symbol.toStringTag,{value:"Module"}));var iI=(g=>(g.DOUBLE_BOUNCE="double-bounce",g.ROTATE="rotate",g.STRETCH="stretch",g.CUBE="cube",g.DOT="dot",g.TRIPLE_BOUNCE="triple-bounce",g.SCALE_OUT="scale-out",g.CIRCLE="circle",g.CIRCLE_LINE="circle-line",g.SQUARE="square",g.PULSE="pulse",g.SOLAR="solar",g.CUBE_FOLD="cube-fold",g.CIRCLE_FOLD="circle-fold",g.CUBE_GRID="cube-grid",g.CIRCLE_TURN="circle-turn",g.CIRCLE_ROTATE="circle-rotate",g.CIRCLE_SPIN="circle-spin",g.DOT_BAR="dot-bar",g.DOT_CIRCLE="dot-circle",g.LINE="line",g.DOT_PULSE="dot-pulse",g.LINE_SCALE="line-scale",g.TEXT="text",g.CUBE_DIM="cube-dim",g.DOT_LINE="dot-line",g.ARC="arc",g.DROP="drop",g.PACMAN="pacman",g))(iI||{});class eI extends(f()){constructor(){super(),C(this,"contain"),C(this,"rotateLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","rotate"),g.setAttribute("part","rotate"),this.contain.appendChild(g)})),C(this,"stretchLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","stretch"),g.setAttribute("part","stretch"),Array(5).fill(1).forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`rect${C+1}`),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"doubleBounceLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","double-bounce"),g.setAttribute("part","double-bounce"),Array(2).fill(1).forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`double-bounce${C+1}`),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"cubeLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","cube"),g.setAttribute("part","cube"),Array(2).fill(1).forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`cube${C+1}`),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"dotLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","dot"),g.setAttribute("part","dot"),Array(2).fill(1).forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`dot${C+1}`),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"tripleBounceLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","triple-bounce"),g.setAttribute("part","triple-bounce"),Array(3).fill(1).forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`triple-bounce${C+1}`),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"scaleOutLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","scale-out"),g.setAttribute("part","scale-out"),this.contain.appendChild(g)})),C(this,"circleLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","circle"),g.setAttribute("part","circle"),Array(3).fill(1).map((()=>new Array(4).fill(1))).forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`circle-container container${C+1}`),I.forEach(((g,I)=>{const C=document.createElement("div");C.setAttribute("class",`circle${I+1}`),A.appendChild(C)})),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"circleLineLoading",(()=>{const{element:g}=w("div").setAttribute("class","circle-line-core"),{element:I}=w("div").setAttribute("class","circle-line-border").append(g),{element:C}=w("div").setAttribute("class","circle-line").setAttribute("part","circle-line").append(I);this.contain.appendChild(C)})),C(this,"squareLoading",(()=>{const{element:g}=w("div").setAttribute("class","square-core"),{element:I}=w("div").setAttribute("class","square-box1").append(g),{element:C}=w("div").setAttribute("class","square-box2").append(g),{element:A}=w("div").setAttribute("class","square").setAttribute("part","square").append(I).append(C);this.contain.appendChild(A)})),C(this,"pulseLoading",(()=>{const g=w("div").setAttribute("class","pulse").setAttribute("part","pulse");Array(3).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class",`pulse-bubble pulse-bubble-${C+1}`);g.append(A)})),this.contain.appendChild(g.element)})),C(this,"solarLoading",(()=>{const{element:g}=w("div").setAttribute("class","sun").setAttribute("part","sun"),{element:I}=w("div").setAttribute("class","planet mercury"),{element:C}=w("div").setAttribute("class","mercury-orbit orbit").append(I).append(g),{element:A}=w("div").setAttribute("class","planet venus"),{element:i}=w("div").setAttribute("class","venus-orbit orbit").append(A).append(C),{element:e}=w("div").setAttribute("class","planet earth"),{element:t}=w("div").setAttribute("class","earth-orbit orbit").append(e).append(i),{element:l}=w("div").setAttribute("class","solar").setAttribute("part","solar").append(t);this.contain.appendChild(l)})),C(this,"cubeFoldLoading",(()=>{const{element:g}=w("div").setAttribute("class","cube-fold").setAttribute("part","cube-fold");Array(4).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class",`cube-fold-item cube-fold-item-${C+1}`);g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"circleFoldLoading",(()=>{const g=w("div").setAttribute("class","circle-fold").setAttribute("part","circle-fold");Array(12).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class",`circle-fold-item circle-fold-item-${C+1}`);g.append(A)})),this.contain.appendChild(g.element)})),C(this,"cubeGridLoading",(()=>{const g=w("div").setAttribute("class","cube-grid").setAttribute("part","cube-grid");Array(9).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class",`cube-grid-item cube-grid-item-${C+1}`);g.append(A)})),this.contain.appendChild(g.element)})),C(this,"circleTurnLoading",(()=>{const{element:g}=w("div").setAttribute("class","circle-turn").setAttribute("part","circle-turn");this.contain.appendChild(g)})),C(this,"circleRotateLoading",(()=>{const{element:g}=w("div").setAttribute("class","circle-rotate").setAttribute("part","circle-rotate"),{element:I}=w("div").setAttribute("class","circle-rotate-inner"),{element:C}=w("div").setAttribute("class","circle-rotate-outer");g.appendChild(C),g.appendChild(I),this.contain.appendChild(g)})),C(this,"circleSpinLoading",(()=>{const{element:g}=w("div").setAttribute("class","circle-spin").setAttribute("part","circle-spin"),{element:I}=w("div").setAttribute("class","circle-spin-inner"),{element:C}=w("div").setAttribute("class","circle-spin-outer");g.appendChild(C),g.appendChild(I),this.contain.appendChild(g)})),C(this,"dotBarLoading",(()=>{const{element:g}=w("div").setAttribute("class","dot-bar").setAttribute("part","dot-bar");Array(5).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class",`dot-bar-item dot-bar-item-${C+1}`);g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"dotCircleLoading",(()=>{const{element:g}=w("div").setAttribute("class","dot-circle").setAttribute("part","dot-circle");Array(5).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class",`dot-circle-item dot-circle-item-${C+1}`);g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"lineLoading",(()=>{const{element:g}=w("div").setAttribute("class","line").setAttribute("part","line");Array(3).fill(1).forEach((()=>{const{element:I}=w("div").setAttribute("class","line-item");g.appendChild(I)})),this.contain.appendChild(g)})),C(this,"dotPulseLoading",(()=>{const{element:g}=w("div").setAttribute("class","dot-pulse").setAttribute("class","dot-pulse");Array(5).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class","dot-pulse-item"),{element:i}=w("div").setAttribute("class",`dot-pulse-item-dot dot-pulse-item-dot-${C+1}`),{element:e}=w("div").setAttribute("class",`dot-pulse-item-ball dot-pulse-item-ball-${C+1}`);A.appendChild(i),A.appendChild(e),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"lineScaleLoading",(()=>{const{element:g}=w("div").setAttribute("class","line-scale").setAttribute("part","line-scale");Array(5).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class","line-scale-item");g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"textLoading",(()=>{const{element:g}=w("div").setAttribute("class","text").setAttribute("part","text");["L","o","a","d","i","n","g"].forEach((I=>{const{element:C}=w("span").setAttribute("class","text-item").setTextContent(I);g.appendChild(C)})),this.contain.appendChild(g)})),C(this,"cubeDimLoading",(()=>{const{element:g}=w("div").setAttribute("class","cube-dim").setAttribute("part","cube-dim");Array(9).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class","cube-dim-item");g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"dotLineLoading",(()=>{const{element:g}=w("div").setAttribute("class","dot-line").setAttribute("part","dot-line");Array(2).fill(1).forEach(((I,C)=>{const{element:A}=w("div").setAttribute("class","dot-line-item"),{element:i}=w("div").setAttribute("class","dot-line-item-circle");A.appendChild(i),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"arcLoading",(()=>{const{element:g}=w("div").setAttribute("class","arc-item"),{element:I}=w("div").setAttribute("class","arc").setAttribute("part","arc").append(g),{element:C}=w("span").setTextContent("LOADING"),{element:A}=w("h1").append(C);I.appendChild(A),this.contain.appendChild(I)})),C(this,"dropLoading",(()=>{const{element:g}=w("span").setTextContent("LOADING"),{element:I}=w("div").setAttribute("class","drop-item-bg").append(g),{element:C}=w("div").setAttribute("class","drop-dot-1"),{element:A}=w("div").setAttribute("class","drop-dot-2"),{element:i}=w("div").setAttribute("class","drop-dot").append(C).append(A),{element:e}=w("div").setAttribute("class","drop-item").append(I).append(i),{element:t}=w("div").setAttribute("class","drop").setAttribute("part","drop").append(e).append(i);this.contain.appendChild(t)})),C(this,"pacmanLoading",(()=>{const{element:g}=w("div").setAttribute("class","pacman").setAttribute("part","pacman");Array(5).fill(1).forEach((()=>{const{element:I}=w("div");g.append(I)})),this.contain.appendChild(g)})),C(this,"createLoading",(()=>{this.contain.innerHTML="";const g={stretch:this.stretchLoading,rotate:this.rotateLoading,"double-bounce":this.doubleBounceLoading,cube:this.cubeLoading,dot:this.dotLoading,"triple-bounce":this.tripleBounceLoading,"scale-out":this.scaleOutLoading,circle:this.circleLoading,"circle-line":this.circleLineLoading,square:this.squareLoading,pulse:this.pulseLoading,solar:this.solarLoading,"cube-fold":this.cubeFoldLoading,"circle-fold":this.circleFoldLoading,"cube-grid":this.cubeGridLoading,"circle-turn":this.circleTurnLoading,"circle-rotate":this.circleRotateLoading,"circle-spin":this.circleSpinLoading,"dot-bar":this.dotBarLoading,"dot-circle":this.dotCircleLoading,line:this.lineLoading,"dot-pulse":this.dotPulseLoading,"line-scale":this.lineScaleLoading,text:this.textLoading,"cube-dim":this.cubeDimLoading,"dot-line":this.dotLineLoading,arc:this.arcLoading,drop:this.dropLoading,pacman:this.pacmanLoading}[this.name];g&&g()})),this.contain=document.createElement("div"),this.contain.setAttribute("class","ran-loading");const g=this.attachShadow({mode:"open"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-loading .stretch{width:var(--loading-stretch-width, 4em);height:var(--loading-stretch-height, 5em);text-align:var(--loading-stretch-text-align, center);display:var(--loading-stretch-display, flex);flex-flow:var(--loading-stretch-flex-flow, row nowrap);justify-content:var(--loading-stretch-justify-content, space-between);align-items:var(--loading-stretch-align-items, center)}@keyframes ran-loading-stretch{0%,40%,to{transform:var(--loading-stretch-keyframes-0, scaleY(.4))}20%{transform:var(--loading-stretch-keyframes-20, scaleY(1))}}.ran-loading .stretch div{background-color:var(--loading-stretch-div-background-color, #4096ff);height:var(--loading-stretch-div-height, 100%);width:var(--loading-stretch-div-width, .4em);animation:var(--loading-stretch-div-animation, ran-loading-stretch 1.2s infinite ease-in-out);animation-play-state:var(--loading-stretch-div-animation-play-state, running)}.ran-loading .stretch .rect5{animation-delay:var(--loading-stretch-rect-animation-delay, -.8s)}.ran-loading .stretch .rect4{animation-delay:var(--loading-stretch-rect-animation-delay, -.9s)}.ran-loading .stretch .rect3{animation-delay:var(--loading-stretch-rect-animation-delay, -1s)}.ran-loading .stretch .rect2{animation-delay:var(--loading-stretch-rect-animation-delay, -1.1s)}.ran-loading .rotate{width:var(--loading-rotate-width, 4em);height:var(--loading-rotate-height, 4em);background:var(--loading-rotate-background, #4096ff);animation:var(--loading-rotate-animation, ran-loading-rotate 1.2s infinite ease-in-out);animation-play-state:var(--loading-rotate-div-animation-play-state, running)}@keyframes ran-loading-rotate{0%{transform:var(--loading-rotate-keyframes-0, perspective(120px) rotateX(0deg) rotateY(0deg))}50%{transform:var(--loading-rotate-keyframes-50, perspective(120px) rotateX(-180.1deg) rotateY(0deg))}to{transform:var(--loading-rotate-keyframes-100, perspective(120px) rotateX(-180deg) rotateY(-179.9deg))}}.ran-loading .double-bounce{width:var(--loading-double-bounce-width, 4em);height:var(--loading-double-bounce-height, 4em);position:var(--loading-double-bounce-height, relative)}.ran-loading .double-bounce .double-bounce1{width:var(--loading-double-bounce1-width, 100%);height:var(--loading-double-bounce1-height, 100%);border-radius:var(--loading-double-bounce1-border-radius, 50%);background:var(--loading-double-bounce1-background, #4096ff);opacity:var(--loading-double-bounce1-opacity, .6);position:var(--loading-double-bounce1-position, absolute);top:var(--loading-double-bounce1-top, 0);left:var(--loading-double-bounce1-left, 0);animation:var(--loading-double-bounce1-animation, ran-loading-bounce 2s infinite ease-in-out);animation-play-state:var(--loading-double-bounce1-animation-play-state, running)}.ran-loading .double-bounce .double-bounce2{width:var(--loading-double-bounce2-width, 100%);height:var(--loading-double-bounce2-height, 100%);border-radius:var(--loading-double-bounce2-border-radius, 50%);background:var(--loading-double-bounce2-background, #4096ff);opacity:var(--loading-double-bounce2-opacity, .6);position:var(--loading-double-bounce2-position, absolute);top:var(--loading-double-bounce2-top, 0);left:var(--loading-double-bounce2-left, 0);animation:var(--loading-double-bounce2-animation, ran-loading-bounce 2s infinite ease-in-out);animation-delay:var(--loading-double-bounce2-animation-delay, -1s);animation-play-state:var(--loading-double-bounce2-animation-play-state, running)}@keyframes ran-loading-bounce{0%,to{transform:var(--loading-double-bounce-keyframes-0, scale(0))}50%{transform:var(--loading-double-bounce-keyframes-50, scale(1))}}.ran-loading .cube{width:var(--loading-cube-width, 2em);height:var(--loading-cube-width, 2em);position:var(--loading-cube-width, relative)}.ran-loading .cube .cube1{background:var(--loading-cube1-background, #4096ff);width:var(--loading-cube1-width, 2em);height:var(--loading-cube1-height, 2em);position:var(--loading-cube1-position, absolute);top:var(--loading-cube1-top, 0);left:var(--loading-cube1-left, 0);animation:var(--loading-cube1-animation, ran-loading-cube 1.8s infinite ease-in-out);animation-play-state:var(--loading-cube1-animation-play-state, running)}.ran-loading .cube .cube2{background:var(--loading-cube2-background, #4096ff);width:var(--loading-cube2-width, 2em);height:var(--loading-cube2-height, 2em);position:var(--loading-cube2-position, absolute);top:var(--loading-cube2-top, 0);left:var(--loading-cube2-left, 0);animation:var(--loading-cube2-animation, ran-loading-cube 1.8s infinite ease-in-out);animation-delay:var(--loading-cube2-animation-delay, -.9s);animation-play-state:var(--loading-cube2-animation-play-state, running)}@keyframes ran-loading-cube{25%{transform:var(--loading-cube-keyframes-25, translateX(42px) rotate(-90deg) scale(.5))}50%{transform:var(--loading-cube-keyframes-50, translateX(42px) translateY(42px) rotate(-179deg))}50.1%{transform:var(--loading-cube-keyframes-501, translateX(42px) translateY(42px) rotate(-180deg))}75%{transform:var(--loading-cube-keyframes-75, translateX(0px) translateY(42px) rotate(-270deg) scale(.5))}to{transform:var(--loading-cube-keyframes-100, rotate(-360deg))}}.ran-loading .dot{width:var(--loading-dot-width, 4em);height:var(--loading-dot-height, 4em);position:var(--loading-dot-position, relative);text-align:var(--loading-dot-text-align, center);animation:var(--loading-dot-animation, ran-loading-dot-rotate 2s infinite linear);animation-play-state:var(--loading-dot-animation-play-state, running)}.ran-loading .dot .dot1{width:var(--loading-dot1-width, 60%);height:var(--loading-dot1-height, 60%);display:var(--loading-dot1-display, inline-block);position:var(--loading-dot1-position, absolute);top:var(--loading-dot1-top, 0);background:var(--loading-dot1-background, #4096ff);border-radius:var(--loading-dot1-border-radius, 100%);animation:var(--loading-dot1-animation, ran-loading-dot-bounce 2s infinite ease-in-out);animation-play-state:var(--loading-dot1-animation-play-state, running)}.ran-loading .dot .dot2{width:var(--loading-dot2-width, 60%);height:var(--loading-dot2-height, 60%);display:var(--loading-dot2-display, inline-block);position:var(--loading-dot2-position, absolute);background:var(--loading-dot2-background, #4096ff);border-radius:var(--loading-dot2-border-radius, 100%);animation:var(--loading-dot2-animation, ran-loading-dot-bounce 2s infinite ease-in-out);top:var(--loading-dot2-top, auto);bottom:var(--loading-dot2-bottom, 0px);animation-delay:var(--loading-dot2-animation-delay, -1s);animation-play-state:var(--loading-dot2-animation-play-state, running)}@keyframes ran-loading-dot-rotate{to{transform:var(--loading-dot-keyframes-rotate, rotate(360deg))}}@keyframes ran-loading-dot-bounce{0%,to{transform:var(--loading-dot-keyframes-bounce-0, scale(0))}50%{transform:var(--loading-dot-keyframes-bounce-50, scale(1))}}.ran-loading .triple-bounce{width:var(--loading-triple-bounce-width, 10em);text-align:var(--loading-triple-bounce-text-align, center)}.ran-loading .triple-bounce div{width:var(--loading-triple-bounce-div-width, 2em);height:var(--loading-triple-bounce-div-height, 2em);background:var(--loading-triple-bounce-div-background, #4096ff);border-radius:var(--loading-triple-bounce-div-border-radius, 100%);display:var(--loading-triple-bounce-div-display, inline-block);animation:var(--loading-triple-bounce-div-animation, ran-loading-triple-bounce 1.4s infinite ease-in-out);animation-play-state:var(--loading-triple-bounce-div-animation-play-state, running);animation-fill-mode:var(--loading-triple-bounce-div-animation-fill-mode, both)}.ran-loading .triple-bounce .triple-bounce1{animation-delay:var(--loading-triple-bounce1-animation-delay, -.32s)}.ran-loading .triple-bounce .triple-bounce2{animation-delay:var(--loading-triple-bounce2-animation-delay, -.16s)}@keyframes ran-loading-triple-bounce{0%,80%,to{transform:var(--loading-triple-bounce-keyframes-0, scale(0))}40%{transform:var(--loading-triple-bounce-keyframes-40, scale(1))}}.ran-loading .scale-out{width:var(--loading-scale-out-width, 4em);height:var(--loading-scale-out-height, 4em);background:var(--loading-scale-out-background, #4096ff);border-radius:var(--loading-scale-out-border-radius, 100%);animation:var(--loading-scale-out-animation, ran-loading-scale-out 1s infinite ease-in-out);animation-play-state:var(--loading-scale-out-animation-play-state, running)}@keyframes ran-loading-scale-out{0%{transform:var(--loading-scale-out-keyframes-0-transform, scale(0))}to{transform:var(--loading-scale-out-keyframes-100-transform, scale(1));opacity:var(--loading-scale-out-keyframes-100-transform, 0)}}.ran-loading .circle{width:var(--loading-circle-width, 4em);height:var(--loading-circle-height, 4em);position:var(--loading-circle-position, relative)}.ran-loading .circle-container{position:var(--loading-circle-container-position, absolute);width:var(--loading-circle-container-width, 100%);height:var(--loading-circle-container-height, 100%)}.ran-loading .circle-container div{width:var(--loading-circle-container-div-width, 1em);height:var(--loading-circle-container-div-height, 1em);background:var(--loading-circle-container-div-background, #4096ff);border-radius:var(--loading-circle-container-div-border-radius, 100%);position:var(--loading-circle-container-div-position, absolute);animation:var(--loading-circle-container-div-animation, ran-loading-circle 1.2s infinite ease-in-out);animation-play-state:var(--loading-circle-container-div-animation-play-state, running);animation-fill-mode:var(--loading-circle-container-div-animation-fill-mode, both)}.ran-loading .circle .container1 .circle2{animation-delay:var(--loading-circle-container1-circle2-animation-delay, -.9s)}.ran-loading .circle .container1 .circle3{animation-delay:var(--loading-circle-container1-circle3-animation-delay, -.6s)}.ran-loading .circle .container1 .circle4{animation-delay:var(--loading-circle-container1-circle4-animation-delay, -.3s)}.ran-loading .circle .container2{transform:var(--loading-circle-container2-transform, rotateZ(45deg))}.ran-loading .circle .container2 .circle1{animation-delay:var(--loading-circle-container2-circle1-animation-delay, -1.1s)}.ran-loading .circle .container2 .circle2{animation-delay:var(--loading-circle-container2-circle2-animation-delay, -.8s)}.ran-loading .circle .container2 .circle3{animation-delay:var(--loading-circle-container2-circle3-animation-delay, -.5s)}.ran-loading .circle .container2 .circle4{animation-delay:var(--loading-circle-container2-circle4-animation-delay, -.2s)}.ran-loading .circle .container3{transform:var(--loading-circle-container3-transform, rotateZ(90deg))}.ran-loading .circle .container3 .circle1{animation-delay:var(--loading-circle-container3-circle1-transform, -1s)}.ran-loading .circle .container3 .circle2{animation-delay:var(--loading-circle-container3-circle2-transform, -.7s)}.ran-loading .circle .container3 .circle3{animation-delay:var(--loading-circle-container3-circle3-transform, -.4s)}.ran-loading .circle .container3 .circle4{animation-delay:var(--loading-circle-container3-circle4-transform, -.1s)}.ran-loading .circle .circle1{top:var(--loading-circle1-top, 0);left:var(--loading-circle1-left, 0)}.ran-loading .circle .circle2{top:var(--loading-circle2-top, 0);right:var(--loading-circle2-right, 0)}.ran-loading .circle .circle3{right:var(--loading-circle3-right, 0);bottom:var(--loading-circle3-bottom, 0)}.ran-loading .circle .circle4{left:var(--loading-circle3-left, 0);bottom:var(--loading-circle3-bottom, 0)}@keyframes ran-loading-circle{0%,80%,to{transform:var(--loading-circle-keyframes-0, scale(0))}40%{transform:var(--loading-circle-keyframes-40, scale(1))}}@keyframes circle-line{0%{transform:var(--loading-circle-line-keyframes-from, rotate(0))}to{transform:var(--loading-circle-line-keyframes-to, rotate(359deg))}}.ran-loading .circle-line-border{width:var(--loading-circle-line-border-width, 50px);height:var(--loading-circle-line-border-height, 50px);padding:var(--loading-circle-line-border-padding, 3px);display:var(--loading-circle-line-border-display, flex);justify-content:var(--loading-circle-line-border-justify-content, center);align-items:var(--loading-circle-line-border-align-items, center);border-radius:var(--loading-circle-line-border-border-radius, 50%);background:var(--loading-circle-line-border-background, linear-gradient(0deg, rgba(63, 249, 220, .1) 33%, #3ff9dc 100%));animation:var(--loading-circle-line-border-animation, circle-line .8s linear 0s infinite);animation-play-state:var(--loading-circle-line-border-animation-play-state, running)}.ran-loading .circle-line-core{width:var(--loading-circle-line-core-width, 100%);height:var(--loading-circle-line-core-height, 100%);background:var(--loading-circle-line-core-background, #fff);border-radius:var(--loading-circle-line-core-border-radius, 50%)}@keyframes square-box1{0%{transform:var(--loading-square-box1-keyframes-0, rotate(0))}25%{transform:var(--loading-square-box1-keyframes-25, rotate(90deg))}50%{transform:var(--loading-square-box1-keyframes-50, rotate(180deg))}75%{transform:var(--loading-square-box1-keyframes-75, rotate(270deg))}to{transform:var(--loading-square-box1-keyframes-100, rotate(360deg))}}@keyframes square-box2{0%{transform:var(--loading-square-box2-keyframes-0, rotate(45deg))}25%{transform:var(--loading-square-box2-keyframes-25, rotate(-45deg))}50%{transform:var(--loading-square-box2-keyframes-50, rotate(-135deg))}75%{transform:var(--loading-square-box2-keyframes-75, rotate(-225deg))}to{transform:var(--loading-square-box2-keyframes-100, rotate(-315deg))}}.ran-loading .square-box1{width:var(--loading-square-box1-width, 50px);height:var(--loading-square-box1-height, 50px);padding:var(--loading-square-box1-padding, 3px);position:var(--loading-square-box1-position, absolute);display:var(--loading-square-box1-display, flex);justify-content:var(--loading-square-box1-justify-content, center);align-items:var(--loading-square-box1-align-items, center);background:var(--loading-square-box1-background, #ffab91);animation:var(--loading-square-box1-animation, square-box1 3s ease-in-out 0s infinite alternate);animation-play-state:var(--loading-square-box1-animation-play-state, running)}.ran-loading .square-box2{width:var(--loading-square-box2-width, 50px);height:var(--loading-square-box2-height, 50px);padding:var(--loading-square-box2-padding, 3px);left:var(--loading-square-box2-left, -50px);display:var(--loading-square-box2-display, flex);justify-content:var(--loading-square-box2-justify-content, center);align-items:var(--loading-square-box2-align-items, center);background:var(--loading-square-box2-background, #3ff9dc);transform:var(--loading-square-box2-transform, rotate(45deg));animation:var(--loading-square-box2-animation, square-box2 3s ease-in-out 0s infinite alternate);animation-play-state:var(--loading-square-box2-animation-play-state, running)}.ran-loading .square-core{width:var(--loading-square-core-width, 100%);height:var(--loading-square-core-height, 100%);background:var(--loading-square-core-background, #37474f)}.ran-loading .pulse{width:var(--loading-pulse-width, 120px);display:var(--loading-pulse-display, flex);justify-content:var(--loading-pulse-justify-content, space-between);align-items:var(--loading-pulse-align-items, center)}.ran-loading .pulse-bubble{width:var(--loading-pulse-bubble-width, 20px);height:var(--loading-pulse-bubble-height, 20px);border-radius:var(--loading-pulse-bubble-border-radius, 50%);background:var(--loading-pulse-bubble-background, #3ff9dc)}@keyframes pulse{0%{opacity:var(--loading-pulse-bubble-keyframes-from-opacity, 1);transform:var(--loading-pulse-bubble-keyframes-from-transform, scale(1))}to{opacity:var(--loading-pulse-bubble-keyframes-to-opacity, .25);transform:var(--loading-pulse-bubble-keyframes-to-transform, scale(.75))}}.ran-loading .pulse-bubble-1{animation:var(--loading-pulse-bubble-1-animation, pulse .4s ease 0s infinite alternate);animation-play-state:var(--loading-pulse-bubble-1-animation-play-state, running)}.ran-loading .pulse-bubble-2{animation:var(--loading-pulse-bubble-2-animation, pulse .4s ease .2s infinite alternate);animation-play-state:var(--loading-pulse-bubble-2-animation-play-state, running)}.ran-loading .pulse-bubble-3{animation:var(--loading-pulse-bubble-3-animation, pulse .4s ease .4s infinite alternate);animation-play-state:var(--loading-pulse-bubble-3-animation-play-state, running)}.ran-loading .solar{width:var(--loading-solar-width, 250px);height:var(--loading-solar-height, 250px);display:var(--loading-solar-display, flex);justify-content:var(--loading-solar-justify-content, center);align-items:var(--loading-solar-align-items, center)}@keyframes solar{0%{transform:var(--loading-solar-keyframes-from, rotate(0))}to{transform:var(--loading-solar-keyframes-to, rotate(359deg))}}.ran-loading .solar .orbit{position:var(--loading-solar-orbit-position, relative);display:var(--loading-solar-orbit-display, flex);justify-content:var(--loading-solar-orbit-justify-content, center);align-items:var(--loading-solar-orbit-align-items, center);border:var(--loading-solar-orbit-border, 1px solid #77777d);border-radius:var(--loading-solar-orbit-border-radius, 50%)}.ran-loading .solar .earth-orbit{width:var(--loading-solar-earth-orbit-width, 165px);height:var(--loading-solar-earth-orbit-height, 165px);animation:var(--loading-solar-earth-orbit-animation, solar 12s linear 0s infinite);animation-play-state:var(--loading-solar-earth-orbit-animation-play-state, running)}.ran-loading .solar .venus-orbit{width:var(--loading-solar-venus-orbit-width, 120px);height:var(--loading-solar-venus-orbit-height, 120px);animation:var(--loading-solar-venus-orbit-width, solar 7.4s linear 0s infinite);animation-play-state:var(--loading-solar-venus-orbit-animation-play-state, running)}.ran-loading .solar .mercury-orbit{width:var(--loading-solar-mercury-orbit-width, 90px);height:var(--loading-solar-mercury-orbit-height, 90px);animation:var(--loading-solar-mercury-orbit-animation, solar 3s linear 0s infinite);animation-play-state:var(--loading-solar-mercury-orbit-animation-play-state, running)}.ran-loading .solar .planet{position:var(--loading-solar-planet-position, absolute);top:var(--loading-solar-planet-top, -5px);width:var(--loading-solar-planet-width, 10px);height:var(--loading-solar-planet-height, 10px);border-radius:var(--loading-solar-planet-border-radius, 50%);background:var(--loading-solar-planet-background, #3ff9dc)}.ran-loading .solar .sun{width:var(--loading-solar-sun-width, 35px);height:var(--loading-solar-sun-height, 35px);border-radius:var(--loading-solar-sun-border-radius, 50%);background:var(--loading-solar-sun-background, #ffab91)}.ran-loading .cube-fold{width:var(--loading-cube-fold-width, 4em);height:var(--loading-cube-fold-height, 4em);position:var(--loading-cube-fold-position, relative);margin:var(--loading-cube-fold-margin, auto);transform:var(--loading-cube-fold-transform, rotateZ(45deg))}@keyframes cube-fold{0%,10%{transform:var(--loading-cube-fold-keyframes-0-transform, perspective(140px) rotateX(-180deg));opacity:var(--loading-cube-fold-keyframes-0-opacity, 0)}25%,75%{transform:var(--loading-cube-fold-keyframes-25-transform, perspective(140px) rotateX(0deg));opacity:var(--loading-cube-fold-keyframes-25-opacity, 1)}90%,to{transform:var(--loading-cube-fold-keyframes-90-transform, perspective(140px) rotateY(180deg));opacity:var(--loading-cube-fold-keyframes-90-opacity, 0)}}.ran-loading .cube-fold-item{float:var(--loading-cube-fold-item-float, left);width:var(--loading-cube-fold-item-width, 50%);height:var(--loading-cube-fold-item-height, 50%);position:var(--loading-cube-fold-item-position, relative);transform:var(--loading-cube-fold-item-transform, scale(1.1))}.ran-loading .cube-fold-item:before{content:var(--loading-cube-fold-item-before-content, " ");position:var(--loading-cube-fold-item-before-position, absolute);top:var(--loading-cube-fold-item-before-top, 0);left:var(--loading-cube-fold-item-before-left, 0);width:var(--loading-cube-fold-item-before-width, 100%);height:var(--loading-cube-fold-item-before-height, 100%);background:var(--loading-cube-fold-item-before-background, #337ab7);animation:var(--loading-cube-fold-item-before-animation, cube-fold 2.4s infinite linear both);animation-play-state:var(--loading-cube-fold-item-before-animation-play-state, running);transform-origin:var(--loading-cube-fold-item-before-transform-origin, 100% 100%)}.ran-loading .cube-fold-item-2{transform:var(--loading-cube-fold-item-2-transform, scale(1.1) rotateZ(90deg))}.ran-loading .cube-fold-item-2:before{animation-delay:var(--loading-cube-fold-item-2-before-animation-delay, .3s)}.ran-loading .cube-fold-item-3{transform:var(--loading-cube-fold-item-3-transform, scale(1.1) rotateZ(270deg))}.ran-loading .cube-fold-item-3:before{animation-delay:var(--loading-cube-fold-item-3-before-animation-delay, .9s)}.ran-loading .cube-fold-item-4{transform:var(--loading-cube-fold-item-4-transform, scale(1.1) rotateZ(180deg))}.ran-loading .cube-fold-item-4:before{animation-delay:var(--loading-cube-fold-item-4-before-animation-delay, .6s)}.ran-loading .circle-fold{width:var(--loading-circle-fold-width, 4em);height:var(--loading-circle-fold-height, 4em);position:var(--loading-circle-fold-position, relative);margin:var(--loading-circle-fold-margin, auto)}@keyframes circle-fold{0%,39%,to{opacity:var(--loading-circle-fold-keyframes-0-opacity, 0)}40%{opacity:var(--loading-circle-fold-keyframes-40-opacity, 1)}}.ran-loading .circle-fold-item{width:var(--loading-circle-fold-item-width, 100%);height:var(--loading-circle-fold-item-height, 100%);position:var(--loading-circle-fold-item-position, absolute);left:var(--loading-circle-fold-item-left, 0);top:var(--loading-circle-fold-item-top, 0)}.ran-loading .circle-fold-item:before{content:var(--loading-circle-fold-item-before-content, " ");display:var(--loading-circle-fold-item-before-display, block);margin:var(--loading-circle-fold-item-before-margin, 0 auto);width:var(--loading-circle-fold-item-before-width, 15%);height:var(--loading-circle-fold-item-before-height, 15%);background:var(--loading-circle-fold-item-before-background, #337ab7);border-radius:var(--loading-circle-fold-item-before-border-radius, 100%);animation:var(--loading-circle-fold-item-before-animation, circle-fold 1.2s infinite ease-in-out both);animation-play-state:var(--loading-circle-fold-item-before-animation-play-state, running)}.ran-loading .circle-fold-item-2{transform:var(--loading-circle-fold-item-2-transform, rotate(30deg))}.ran-loading .circle-fold-item-2:before{animation-delay:var(--loading-circle-fold-item-2-before-animation-delay, -1.1s)}.ran-loading .circle-fold-item-3{transform:var(--loading-circle-fold-item-3-transform, rotate(60deg))}.ran-loading .circle-fold-item-3:before{animation-delay:var(--loading-circle-fold-item-3-before-animation-delay, -1s)}.ran-loading .circle-fold-item-4{transform:var(--loading-circle-fold-item-4-transform, rotate(90deg))}.ran-loading .circle-fold-item-4:before{animation-delay:var(--loading-circle-fold-item-4-before-animation-delay, -.9s)}.ran-loading .circle-fold-item-5{transform:var(--loading-circle-fold-item-5-transform, rotate(120deg))}.ran-loading .circle-fold-item-5:before{animation-delay:var(--loading-circle-fold-item-5-before-animation-delay, -.8s)}.ran-loading .circle-fold-item-6{transform:var(--loading-circle-fold-item-6-transform, rotate(150deg))}.ran-loading .circle-fold-item-6:before{animation-delay:var(--loading-circle-fold-item-6-before-animation-delay, -.7s)}.ran-loading .circle-fold-item-7{transform:var(--loading-circle-fold-item-7-transform, rotate(180deg))}.ran-loading .circle-fold-item-7:before{animation-delay:var(--loading-circle-fold-item-7-before-animation-delay, -.6s)}.ran-loading .circle-fold-item-8{transform:var(--loading-circle-fold-item-8-transform, rotate(210deg))}.ran-loading .circle-fold-item-8:before{animation-delay:var(--loading-circle-fold-item-8-before-animation-delay, -.5s)}.ran-loading .circle-fold-item-9{transform:var(--loading-circle-fold-item-9-transform, rotate(240deg))}.ran-loading .circle-fold-item-9:before{animation-delay:var(--loading-circle-fold-item-9-before-animation-delay, -.4s)}.ran-loading .circle-fold-item-10{transform:var(--loading-circle-fold-item-10-transform, rotate(270deg))}.ran-loading .circle-fold-item-10:before{animation-delay:var(--loading-circle-fold-item-10-before-animation-delay, -.3s)}.ran-loading .circle-fold-item-11{transform:var(--loading-circle-fold-item-11-transform, rotate(300deg))}.ran-loading .circle-fold-item-11:before{animation-delay:var(--loading-circle-fold-item-11-before-animation-delay, -.2s)}.ran-loading .circle-fold-item-12{transform:var(--loading-circle-fold-item-12-transform, rotate(330deg))}.ran-loading .circle-fold-item-12:before{animation-delay:var(--loading-circle-fold-item-12-before-animation-delay, -.1s)}.ran-loading .cube-grid{width:var(--loading-cube-grid-width, 4em);height:var(--loading-cube-grid-height, 4em);margin:var(--loading-cube-grid-margin, auto)}@keyframes cube-grid{0%,70%,to{transform:var(--loading-cube-grid-keyframes-0-transform, scale3D(1, 1, 1))}35%{transform:var(--loading-cube-grid-keyframes-35-transform, scale3D(0, 0, 1))}}.ran-loading .cube-grid-item{width:var(--loading-cube-grid-item-width, 33%);height:var(--loading-cube-grid-item-height, 33%);background:var(--loading-cube-grid-item-background, #337ab7);float:var(--loading-cube-grid-item-float, left);animation:var(--loading-cube-grid-item-animation, cube-grid 1.3s infinite ease-in-out);animation-play-state:var(--loading-cube-grid-item-animation-play-state, running)}.ran-loading .cube-grid-item-1{animation-delay:var(--loading-cube-grid-item-1-animation-delay, .2s)}.ran-loading .cube-grid-item-2{animation-delay:var(--loading-cube-grid-item-2-animation-delay, .3s)}.ran-loading .cube-grid-item-3{animation-delay:var(--loading-cube-grid-item-3-animation-delay, .4s)}.ran-loading .cube-grid-item-4{animation-delay:var(--loading-cube-grid-item-4-animation-delay, .1s)}.ran-loading .cube-grid-item-5{animation-delay:var(--loading-cube-grid-item-5-animation-delay, .2s)}.ran-loading .cube-grid-item-6{animation-delay:var(--loading-cube-grid-item-6-animation-delay, .3s)}.ran-loading .cube-grid-item-7{animation-delay:var(--loading-cube-grid-item-7-animation-delay, 0s)}.ran-loading .cube-grid-item-8{animation-delay:var(--loading-cube-grid-item-8-animation-delay, .1s)}.ran-loading .cube-grid-item-9{animation-delay:var(--loading-cube-grid-item-9-animation-delay, .2s)}.ran-loading .circle-turn{width:var(--loading-circle-turn-width, 30px);height:var(--loading-circle-turn-height, 30px);border:var(--loading-circle-turn-border, 8px solid #fff);border-right-color:var(--loading-circle-turn-border-right-color, transparent);border-top-color:var(--loading-circle-turn-border-top-color, transparent);border-radius:var(--loading-circle-turn-border-radius, 50%);box-shadow:var(--loading-circle-turn-box-shadow, 0 0 25px 2px);border-color:var(--loading-circle-turn-border-color, #f00);color:var(--loading-circle-turn-color, #cc0000);animation:var(--loading-circle-turn-animation, circle-turn 1s linear infinite normal);animation-play-state:var(--loading-circle-turn-animation-play-state, running);animation-delay:var(--loading-circle-turn-animation-delay, 0);margin:var(--loading-circle-turn-margin, 30px auto 0)}@keyframes circle-turn{0%{transform:var(--loading-circle-turn-keyframes-from-transform, rotate(0deg));opacity:var(--loading-circle-turn-keyframes-from-opacity, .2)}50%{transform:var(--loading-circle-turn-keyframes-50-transform, rotate(180deg));opacity:var(--loading-circle-turn-keyframes-50-opacity, 1)}to{transform:var(--loading-circle-turn-keyframes-50-transform, rotate(360deg));opacity:var(--loading-circle-turn-keyframes-50-opacity, .2)}}.ran-loading .circle-turn:after{display:var(--loading-circle-turn-after-display, block);width:var(--loading-circle-turn-after-width, 13px);height:var(--loading-circle-turn-after-height, 13px);margin:var(--loading-circle-turn-after-margin, 3px);border:var(--loading-circle-turn-after-border, 6px solid #f00);content:var(--loading-circle-turn-after-content, " ");border-radius:var(--loading-circle-turn-after-border-radius, 50%);border-left-color:var(--loading-circle-turn-after-border-left-color, transparent);border-bottom-color:var(--loading-circle-turn-after-border-bottom-color, transparent)}.ran-loading .circle-rotate{margin:var(--loading-circle-rotate-margin, 30px auto 0)}@keyframes spin-right{0%{transform:var(--loading-circle-rotate-keyframes-spin-right-from-transform, rotate(0deg));opacity:var(--loading-circle-rotate-keyframes-spin-right-from-opacity, var(--loading-circle-rotate-margin, .2))}50%{transform:var(--loading-circle-rotate-keyframes-spin-right-50-opacity, rotate(180deg));opacity:var(--loading-circle-rotate-keyframes-spin-right-50-opacity, 1)}to{transform:var(--loading-circle-rotate-keyframes-spin-right-to-opacity, rotate(360deg));opacity:var(--loading-circle-rotate-keyframes-spin-right-to-opacity, .2)}}@keyframes spin-left{0%{transform:var(--loading-circle-rotate-keyframes-spin-left-from-transform, rotate(0deg));opacity:var(--loading-circle-rotate-keyframes-spin-left-from-opacity, .2)}50%{transform:var(--loading-circle-rotate-keyframes-spin-left-50-transform, rotate(-180deg));opacity:var(--loading-circle-rotate-keyframes-spin-left-50-opacity, 1)}to{transform:var(--loading-circle-rotate-keyframes-spin-left-to-transform, rotate(-360deg));opacity:var(--loading-circle-rotate-keyframes-spin-left-to-opacity, .2)}}.ran-loading .circle-rotate-outer{border:var(--loading-circle-rotate-outer-border, 5px solid rgba(0, 183, 229, .9));opacity:var(--loading-circle-rotate-outer-opacity, .9);width:var(--loading-circle-rotate-outer-width, 50px);height:var(--loading-circle-rotate-outer-height, 50px);border-top-color:var(--loading-circle-rotate-outer-border-top-color, transparent);border-bottom-color:var(--loading-circle-rotate-outer-border-bottom-color, transparent);border-radius:var(--loading-circle-rotate-outer-border-radius, 50%);box-shadow:var(--loading-circle-rotate-outer-box-shadow, 0 0 35px rgba(0, 61, 76, .9));animation:var(--loading-circle-rotate-outer-animation, spin-right .5s linear infinite normal);animation-play-state:var(--loading-circle-rotate-outer-animation-play-state, running);animation-delay:var(--loading-circle-rotate-outer-animation-delay, 0);margin:var(--loading-circle-rotate-outer-margin, 0 auto)}.ran-loading .circle-rotate-inner{display:var(--loading-circle-rotate-inner-display, block);width:var(--loading-circle-rotate-inner-width, 30px);height:var(--loading-circle-rotate-inner-height, 30px);border:var(--loading-circle-rotate-inner-border, 5px solid rgba(0, 183, 229, .9));opacity:var(--loading-circle-rotate-inner-opacity, .9);border-radius:var(--loading-circle-rotate-inner-border-radius, 50%);border-left-color:var(--loading-circle-rotate-inner-border-left-color, transparent);border-bottom-color:var(--loading-circle-rotate-inner-border-bottom-color, transparent);box-shadow:var(--loading-circle-rotate-inner-box-shadow, 0 0 35px rgba(0, 61, 76, .9));position:var(--loading-circle-rotate-inner-position, relative);top:var(--loading-circle-rotate-inner-top, -50px);margin:var(--loading-circle-rotate-inner-margin, 0 auto);animation:var(--loading-circle-rotate-inner-animation, spin-left .5s linear infinite normal);animation-play-state:var(--loading-circle-rotate-inner-animation-play-state, running);animation-delay:var(--loading-circle-rotate-inner-animation-delay, 0)}@keyframes spin-right{0%{transform:var(--loading-circle-spin-keyframes-spin-right-from-transform, rotate(0deg));opacity:var(--loading-circle-spin-keyframes-spin-right-from-opacity, .2)}50%{transform:var(--loading-circle-spin-keyframes-spin-right-50-transform, rotate(180deg));opacity:var(--loading-circle-spin-keyframes-spin-right-50-opacity, 1)}to{transform:var(--loading-circle-spin-keyframes-spin-right-to-transform, rotate(360deg));opacity:var(--loading-circle-spin-keyframes-spin-right-to-opacity, .2)}}@keyframes spin-pulse{0%{transform:var(--loading-circle-spin-keyframes-spin-pulse-from-transform, rotate(160deg));opacity:var(--loading-circle-spin-keyframes-spin-pulse-from-opacity, 0);box-shadow:var(--loading-circle-spin-keyframes-spin-pulse-from-box-shadow, 0 0 1px rgba(0, 61, 76, .9))}50%{transform:var(--loading-circle-spin-keyframes-spin-pulse-50-transform, rotate(145deg));opacity:var(--loading-circle-spin-keyframes-spin-pulse-50-opacity, 1)}to{transform:var(--loading-circle-spin-keyframes-spin-pulse-to-transform, rotate(-320deg));opacity:var(--loading-circle-spin-keyframes-spin-pulse-to-opacity, 0)}}.ran-loading .circle-spin-inner{border:var(--loading-circle-spin-inner-border, 5px solid rgba(0, 229, 183, .9));opacity:var(--loading-circle-spin-inner-opacity, .9);border-left-color:var(--loading-circle-spin-inner-border-left-color, transparent);border-right-color:var(--loading-circle-spin-inner-border-right-color, transparent);border-radius:var(--loading-circle-spin-inner-border-radius, 50%);box-shadow:var(--loading-circle-spin-inner-box-shadow, 0 0 15px rgba(0, 76, 61, .9));width:var(--loading-circle-spin-inner-width, 30px);height:var(--loading-circle-spin-inner-height, 30px);position:var(--loading-circle-spin-inner-position, relative);top:var(--loading-circle-spin-inner-top, -50px);margin:var(--loading-circle-spin-inner-margin, 0 auto);animation:var(--loading-circle-spin-inner-animation, spin-right 1s linear infinite normal);animation-play-state:var(--loading-circle-spin-inner-animation-play-state, running);animation-delay:var(--loading-circle-spin-inner-animation-delay, 0)}.ran-loading .circle-spin-outer{border:var(--loading-circle-spin-inner-border, 5px solid rgba(0, 229, 183, .9));opacity:var(--loading-circle-spin-inner-border, .9);border-right-color:var(--loading-circle-spin-inner-border, transparent);border-left-color:var(--loading-circle-spin-inner-border, transparent);width:var(--loading-circle-spin-inner-border, 50px);height:var(--loading-circle-spin-inner-border, 50px);margin:var(--loading-circle-spin-inner-border, 0 auto);border-radius:var(--loading-circle-spin-inner-border, 50%);box-shadow:var(--loading-circle-spin-inner-border, 0 0 35px rgba(0, 76, 61, .9));animation:var(--loading-circle-spin-inner-border, spin-pulse 1s linear infinite normal);animation-play-state:var(--loading-circle-spin-outer-animation-play-state, running);animation-delay:var(--loading-circle-spin-inner-border, 0)}.ran-loading .dot-bar{margin:var(--loading-dot-bar-margin, 0 auto);overflow:var(--loading-dot-bar-overflow, hidden);width:var(--loading-dot-bar-width, 90px)}@keyframes pulse{0%{transform:var(--loading-dot-bar-keyframes-from-transform, scale(1.2));opacity:var(--loading-dot-bar-margin-from-opacity, 1)}to{transform:var(--loading-dot-bar-keyframes-to-transform, scale(.7));opacity:var(--loading-dot-bar-keyframes-to-opacity, .1)}}.ran-loading .dot-bar-item{background-color:var(--loading-dot-bar-item-background-color, #8aff51);background-image:var(--loading-dot-bar-item-background-image, linear-gradient(45deg, #8aff51 25%, #f1ffea));width:var(--loading-dot-bar-item-width, 10px);height:var(--loading-dot-bar-item-height, 10px);float:var(--loading-dot-bar-item-float, left);margin-left:var(--loading-dot-bar-item-margin-left, 5px);opacity:var(--loading-dot-bar-item-opacity, .1);animation:var(--loading-dot-bar-item-animation, pulse 1s linear infinite normal);animation-play-state:var(--loading-dot-bar-item-animation-play-state, running);animation-delay:var(--loading-dot-bar-item-animation-delay, 0)}.ran-loading .dot-bar-item-1{animation-delay:var(--loading-dot-bar-item-1-animation-delay, .3s)}.ran-loading .dot-bar-item-2{animation-delay:var(--loading-dot-bar-item-2-animation-delay, .2s)}.ran-loading .dot-bar-item-3{animation-delay:var(--loading-dot-bar-item-3-animation-delay, .1s)}.ran-loading .dot-bar-item-4{animation-delay:var(--loading-dot-bar-item-4-animation-delay, .2s)}.ran-loading .dot-bar-item-5{animation-delay:var(--loading-dot-bar-item-5-animation-delay, .3s)}.ran-loading .dot-circle-item{background-color:var(--loading-dot-circle-item-background-color, #f00);background-image:var(--loading-dot-circle-item-background-image, linear-gradient(90deg, #f00 25%, #ff9999));width:var(--loading-dot-circle-item-width, 3px);height:var(--loading-dot-circle-item-height, 3px);border-radius:var(--loading-dot-circle-item-border-radius, 50%);box-shadow:var(--loading-dot-circle-item-box-shadow, 0 0 5px #cc0000);margin:var(--loading-dot-circle-item-margin, 0 auto);position:var(--loading-dot-circle-item-position, relative);animation:var(--loading-dot-circle-item-animation, dot-circle 2s infinite cubic-bezier(0, 0, .35, 1) normal)}.ran-loading .dot-circle-item-1{animation-play-state:var(--loading-dot-circle-item-1-animation-play-state, running);animation-delay:var(--loading-dot-circle-item-1-animation-delay, 0)}.ran-loading .dot-circle-item-2{opacity:var(--loading-dot-circle-item-2-opacity, .7);top:var(--loading-dot-circle-item-2-top, 1px);animation-play-state:var(--loading-dot-circle-item-2-animation-play-state, running);animation-delay:var(--loading-dot-circle-item-2-animation-delay, .1s)}.ran-loading .dot-circle-item-3{opacity:var(--loading-dot-circle-item-3-opacity, .5);top:var(--loading-dot-circle-item-3-top, 2px);animation-play-state:var(--loading-dot-circle-item-3-animation-play-state, running);animation-delay:var(--loading-dot-circle-item-3-animation-delay, .2s)}.ran-loading .dot-circle-item-4{opacity:var(--loading-dot-circle-item-4-opacity, .3);top:var(--loading-dot-circle-item-4-top, 3px);animation-play-state:var(--loading-dot-circle-item-4-animation-play-state, running);animation-delay:var(--loading-dot-circle-item-4-animation-delay, .3s)}.ran-loading .dot-circle-item-5{opacity:var(--loading-dot-circle-item-5-opacity, .1);top:var(--loading-dot-circle-item-5-top, 4px);animation-play-state:var(--loading-dot-circle-item-5-animation-play-state, running);animation-delay:var(--loading-dot-circle-item-5-animation-delay, .4s)}@keyframes dot-circle{0%{transform:var(--loading-dot-circle-keyframes-from-transform, translateX(0px))}25%{transform:var(--loading-dot-circle-keyframes-25-transform, translateX(25px));animation-timing-function:ease-in}50%{transform:var(--loading-dot-circle-keyframes-50-transform, translateX(0px))}75%{transform:var(--loading-dot-circle-keyframes-75-transform, translateX(-25px));animation-timing-function:ease-in}to{transform:var(--loading-dot-circle-keyframes-to-transform, translateX(0px))}}.ran-loading .line{width:var(--loading-line-width, 32px);height:var(--loading-line-width, 32px);margin:var(--loading-line-width, 0 auto)}@keyframes line{10%{margin-top:var(--loading-line-keyframes-10-margin-top, 5px);height:var(--loading-line-keyframes-10-height, 22px);border-color:var(--loading-line-keyframes-10-border-color, #d1d8e6);background-color:var(--loading-line-keyframes-10-background-color, #bac5db)}20%{margin-top:var(--loading-line-keyframes-20-margin-top, 0px);height:var(--loading-line-keyframes-20-height, 32px);border-color:var(--loading-line-keyframes-20-border-color, #d1d7e2);background-color:var(--loading-line-keyframes-20-background-color, #bac5db)}30%{margin-top:var(--loading-line-keyframes-30-margin-top, 1px);height:var(--loading-line-keyframes-30-height, 30px);border-color:var(--loading-line-keyframes-30-border-color, #d1d8e6);background-color:var(--loading-line-keyframes-30-background-color, #bac5db)}40%{margin-top:var(--loading-line-keyframes-40-margin-top, 3px);height:var(--loading-line-keyframes-40-height, 26px)}50%{margin-top:var(--loading-line-keyframes-50-margin-top, 5px);height:var(--loading-line-keyframes-50-height, 22px)}60%{margin-top:var(--loading-line-keyframes-60-margin-top, 6px);height:var(--loading-line-keyframes-60-height, 18px)}}.ran-loading .line-item{background:var(--loading-line-item-background, #99aaca);border:var(--loading-line-item-border, 1px solid #96a6c9);float:var(--loading-line-item-float, left);margin:var(--loading-line-item-margin, 6px 4px 0 0);width:var(--loading-line-item-width, 6px);height:var(--loading-line-item-height, 18px);animation:var(--loading-line-item-animation, line 1s linear infinite normal);animation-play-state:var(--loading-line-item-animation-play-state, running);animation-delay:var(--loading-line-item-animation-delay, 0)}.ran-loading .line-item:nth-child(2){animation-delay:var(--loading-line-nth-child-2-animation-delay, .1s)}.ran-loading .line-item:last-child{margin-right:var(--loading-line-last-child-margin-right, 0);animation-delay:var(--loading-line-last-child-animation-delay, .2s)}.ran-loading .dot-pulse{width:var(--loading-dot-pulse-width, 48px);padding:var(--loading-dot-pulse-padding, 8px 5px);margin:var(--loading-dot-pulse-margin, 30px auto);overflow:var(--loading-dot-pulse-overflow, hidden)}@keyframes dot-pulse{0%{transform:var(--loading-dot-pulse-keyframes-from, scale(0))}to{transform:var(--loading-dot-pulse-keyframes-to, scale(1))}}@keyframes dot-pulse-glow{0%{transform:var(--loading-dot-pulse-keyframes-glow-from-transform, scale(0));opacity:var(--loading-dot-pulse-keyframes-glow-from-opacity, 0)}10%{transform:var(--loading-dot-pulse-keyframes-glow-10-transform, scale(1));opacity:var(--loading-dot-pulse-keyframes-glow-10-opacity, .5)}50%{transform:var(--loading-dot-pulse-keyframes-glow-50-transform, scale(1.75));opacity:var(--loading-dot-pulse-keyframes-glow-50-opacity, 0)}to{transform:var(--loading-dot-pulse-keyframes-glow-to-transform, scale(0));opacity:var(--loading-dot-pulse-keyframes-glow-to-opacity, 0)}}.ran-loading .dot-pulse-item{float:var(--loading-dot-pulse-item-float, left);position:var(--loading-dot-pulse-item-position, relative);width:var(--loading-dot-pulse-item-width, 6px);height:var(--loading-dot-pulse-item-height, 6px);border-radius:var(--loading-dot-pulse-item-border-radius, 50px);margin-left:var(--loading-dot-pulse-item-margin-left, 2px)}.ran-loading .dot-pulse-item:first-child{margin-left:var(--loading-dot-pulse-item-first-child-margin-left, 0)}.ran-loading .dot-pulse-item-dot{background-color:var(--loading-dot-pulse-item-dot-background-color, #2187e7);background-image:var(--loading-dot-pulse-item-dot-background-image, linear-gradient(90deg, #2187e7 25%, #a0eaff));width:var(--loading-dot-pulse-item-dot-width, 6px);height:var(--loading-dot-pulse-item-dot-height, 6px);border-radius:var(--loading-dot-pulse-item-dot-border-radius, 50px);transform:var(--loading-dot-pulse-item-dot-transform, scale(0));animation:var(--loading-dot-pulse-item-dot-animation, dot-pulse 1s linear forwards normal);animation-play-state:var(--loading-dot-pulse-item-dot-animation-play-state, running);animation-delay:var(--loading-dot-pulse-item-dot-animation-delay, 0)}.ran-loading .dot-pulse-item-dot-1{animation-delay:var(--loading-dot-pulse-item-dot-1-animation-delay, .5s)}.ran-loading .dot-pulse-item-dot-2{animation-delay:var(--loading-dot-pulse-item-dot-2-animation-delay, 1s)}.ran-loading .dot-pulse-item-dot-3{animation-delay:var(--loading-dot-pulse-item-dot-3-animation-delay, 1.5s)}.ran-loading .dot-pulse-item-dot-4{animation-delay:var(--loading-dot-pulse-item-dot-4-animation-delay, 2s)}.ran-loading .dot-pulse-item-dot-5{animation-delay:var(--loading-dot-pulse-item-dot-5-animation-delay, 2.5s)}.ran-loading .dot-pulse-item-ball{width:var(--loading-dot-pulse-item-ball-width, 6px);height:var(--loading-dot-pulse-item-ball-height, 6px);border-radius:var(--loading-dot-pulse-item-ball-border-radius, 30px);border:var(--loading-dot-pulse-item-ball-border, 1px solid #00c6ff);box-shadow:var(--loading-dot-pulse-item-ball-box-shadow, 0 0 5px #00c6ff);position:var(--loading-dot-pulse-item-ball-position, absolute);top:var(--loading-dot-pulse-item-ball-top, -1px);left:var(--loading-dot-pulse-item-ball-left, -1px);transform:var(--loading-dot-pulse-item-ball-transform, scale(0));animation:var(--loading-dot-pulse-item-ball-animation, dot-pulse-glow 3s infinite ease-out normal);animation-play-state:var(--loading-dot-pulse-item-ball-animation-play-state, running);animation-delay:var(--loading-dot-pulse-item-ball-animation-delay, 0)}.ran-loading .dot-pulse-item-ball-1{animation-delay:var(--loading-dot-pulse-item-ball-1-animation-delay, 1.5s)}.ran-loading .dot-pulse-item-ball-2{animation-delay:var(--loading-dot-pulse-item-ball-2-animation-delay, 2s)}.ran-loading .dot-pulse-item-ball-3{animation-delay:var(--loading-dot-pulse-item-ball-3-animation-delay, 2.5s)}.ran-loading .dot-pulse-item-ball-4{animation-delay:var(--loading-dot-pulse-item-ball-4-animation-delay, 3s)}.ran-loading .dot-pulse-item-ball-5{animation-delay:var(--loading-dot-pulse-item-ball-5-animation-delay, 3.5s)}.ran-loading .line-scale{display:var(--loading-line-scale-display, block);position:var(--loading-line-scale-position, relative);overflow:var(--loading-line-scale-overflow, hidden);width:var(--loading-line-scale-width, 5em);margin:var(--loading-line-scale-margin, 30px auto);padding:var(--loading-line-scale-padding, 20px 10px)}@keyframes pound{to{transform:var(--loading-line-scale-keyframes-to-transform, scale(1.2))}}.ran-loading .line-scale-item{display:var(--loading-line-scale-item-display, block);float:var(--loading-line-scale-item-float, left);width:var(--loading-line-scale-item-width, .5em);height:var(--loading-line-scale-item-height, 3em);margin:var(--loading-line-scale-item-margin, 0 .5em 0 0);background:var(--loading-line-scale-item-background, #635863);background-image:var(--loading-line-scale-item-background-image, linear-gradient(top, #635863 25%, #3d353b));box-shadow:var(--loading-line-scale-item-box-shadow, 1px 1px 1px 0 rgba(0, 0, 0, 0), 1px 1px 1px 0 rgba(0, 0, 0, 0), 1px 1px 1px 0 rgba(0, 0, 0, 0));animation:var(--loading-line-scale-item-animation, pound .7s ease-in-out infinite alternate);animation-play-state:var(--loading-line-scale-item-animation-play-state, running);animation-delay:var(--loading-line-scale-item-animation-delay, .05s);transform-origin:var(--loading-line-scale-item-transform-origin, center bottom)}.ran-loading .line-scale-item:nth-child(2){animation-delay:var(--loading-line-scale-item--nth-child-2-animation-delay, .2s)}.ran-loading .line-scale-item:nth-child(3){animation-delay:var(--loading-line-scale-item--nth-child-3-animation-delay, .35s)}.ran-loading .line-scale-item:nth-child(4){animation-delay:var(--loading-line-scale-item--nth-child-4-animation-delay, .5s)}.ran-loading .line-scale-item:nth-child(5){animation-delay:var(--loading-line-scale-item--nth-child-5-animation-delay, .65s)}.ran-loading .text{text-align:var(--loading-text-text-align, center);text-transform:var(--loading-text-text-transform, uppercase);font-family:var(--loading-text-font-family, "Nunito", sans-serif);font-size:var(--loading-text-font-size, 4em);color:var(--loading-text-color, transparent);letter-spacing:var(--loading-text-letter-spacing, .4em)}@keyframes letters{to{text-shadow:var(--loading-text-keyframes-to-text-shadow, 0 0 2px rgba(204, 208, 212, .2), 0 0 3px rgba(0, 0, 0, .02), 0 0 0 rgba(0, 0, 0, 0), 0 0 0 rgba(255, 255, 255, 0), 0 0 0 rgba(0, 0, 0, 0), 0 0 0 rgba(255, 255, 255, 0), 0 0 0 rgba(255, 255, 255, 0))}}.ran-loading .text-item{text-shadow:var(--loading-text-item-text-shadow, 0 0 2px rgba(22, 22, 22, .9), 0 15px 25px rgba(0, 0, 0, .3), 0 -2px 3px rgba(0, 0, 0, .1), 0 -5px 10px rgba(22, 22, 22, .5), 0 5px 10px rgba(0, 0, 0, .3), 0 3px 4px rgba(22, 22, 22, .2), 0 0 20px rgba(22, 22, 22, .45));animation:var(--loading-text-item-animation, letters .85s ease-in-out infinite alternate);animation-play-state:var(--loading-text-item-animation-play-state, running);animation-delay:var(--loading-text-item-animation-delay, 0)}.ran-loading .text-item:nth-child(2){animation-delay:var(--loading-text-item-nth-child-2-animation-delay, .15s)}.ran-loading .text-item:nth-child(3){animation-delay:var(--loading-text-item-nth-child-3-animation-delay, .3s)}.ran-loading .text-item:nth-child(4){animation-delay:var(--loading-text-item-nth-child-4-animation-delay, .45s)}.ran-loading .text-item:nth-child(5){animation-delay:var(--loading-text-item-nth-child-5-animation-delay, .6s)}.ran-loading .text-item:nth-child(6){animation-delay:var(--loading-text-item-nth-child-6-animation-delay, .75s)}.ran-loading .text-item:nth-child(7){animation-delay:var(--loading-text-item-nth-child-7-animation-delay, .9s)}.ran-loading .cube-dim{height:var(--loading-cube-dim-height, 9em);width:var(--loading-cube-dim-width, 9em);padding:var(--loading-cube-dim-padding, 3em);transform:var(--loading-cube-dim-transform, rotateX(45deg) rotateZ(45deg));transform-style:var(--loading-cube-dim-transform-style, preserve-3d)}@keyframes anim{50%{transform:var(--loading-cube-dim-width, translateZ(.5em))}}.ran-loading .cube-dim-item{background-color:var(--loading-cube-dim-item-background-color, #05afd1);position:var(--loading-cube-dim-item-position, relative);transform:var(--loading-cube-dim-item-transform, translateZ(3em));transform-style:var(--loading-cube-dim-item-transform-style, preserve-3d);transition:var(--loading-cube-dim-item-transition, .25s);box-shadow:var(--loading-cube-dim-item-box-shadow, 13em 13em 1.5em rgba(0, 0, 0, .1));animation:var(--loading-cube-dim-item-animation, anim 1s infinite);animation-play-state:var(--loading-cube-dim-item-animation-play-state, running);float:var(--loading-cube-dim-item-float, left);height:var(--loading-cube-dim-item-height, 3em);width:var(--loading-cube-dim-item-width, 3em)}.ran-loading .cube-dim-item:nth-child(1){animation-delay:var(--loading-cube-dim-item-nth-child-1-animation-delay, .05s)}.ran-loading .cube-dim-item:nth-child(2){animation-delay:var(--loading-cube-dim-item-nth-child-2-animation-delay, .1s)}.ran-loading .cube-dim-item:nth-child(3){animation-delay:var(--loading-cube-dim-item-nth-child-3-animation-delay, .15s)}.ran-loading .cube-dim-item:nth-child(4){animation-delay:var(--loading-cube-dim-item-nth-child-4-animation-delay, .2s)}.ran-loading .cube-dim-item:nth-child(5){animation-delay:var(--loading-cube-dim-item-nth-child-5-animation-delay, .25s)}.ran-loading .cube-dim-item:nth-child(6){animation-delay:var(--loading-cube-dim-item-nth-child-6-animation-delay, .3s)}.ran-loading .cube-dim-item:nth-child(7){animation-delay:var(--loading-cube-dim-item-nth-child-7-animation-delay, .35s)}.ran-loading .cube-dim-item:nth-child(8){animation-delay:var(--loading-cube-dim-item-nth-child-8-animation-delay, .4s)}.ran-loading .cube-dim-item:nth-child(9){animation-delay:var(--loading-cube-dim-item-nth-child-9-animation-delay, .45s)}.ran-loading .cube-dim-item:before{content:var(--loading-cube-dim-item-before-content, "");float:var(--loading-cube-dim-item-before-float, left);height:var(--loading-cube-dim-item-before-height, 3em);position:var(--loading-cube-dim-item-before-position, absolute);width:var(--loading-cube-dim-item-before-width, 3em);background-color:var(--loading-cube-dim-item-before-background-color, #048ca7);transform:var(--loading-cube-dim-item-before-transform, rotateY(90deg) translateX(3em));transform-origin:var(--loading-cube-dim-item-before-transform-origin, 100% 0)}.ran-loading .cube-dim-item:after{content:var(--loading-cube-dim-item-after-content, "");float:var(--loading-cube-dim-item-after-float, left);height:var(--loading-cube-dim-item-after-height, 3em);position:var(--loading-cube-dim-item-after-position, absolute);width:var(--loading-cube-dim-item-after-width, 3em);background-color:var(--loading-cube-dim-item-after-background-color, #049dbc);transform:var(--loading-cube-dim-item-after-transform, rotateX(-90deg) translateY(3em));transform-origin:var(--loading-cube-dim-item-after-transform-origin, 100% 100%)}.ran-loading .dot-line{width:var(--loading-dot-line-width, 20em);height:var(--loading-dot-line-height, 20em);font-size:var(--loading-dot-line-font-size, 10px);position:var(--loading-dot-line-position, relative);display:var(--loading-dot-line-display, flex);align-items:var(--loading-dot-line-align-items, center);justify-content:var(--loading-dot-line-justify-content, center)}@keyframes dot-line{to{transform:var(--loading-dot-line-keyframes-to-transform, rotate(1turn))}}.ran-loading .dot-line-item{position:var(--loading-dot-line-item-position, absolute);border-radius:var(--loading-dot-line-item-border-radius, 50%);border-style:var(--loading-dot-line-item-order-style, solid);animation:var(--loading-dot-line-item-animation, dot-line 3s linear infinite);animation-play-state:var(--loading-dot-line-item-animation-play-state, running)}.ran-loading .dot-line-item:nth-child(1){width:var(--loading-dot-line-item-nth-child-1-width, 100%);height:var(--loading-dot-line-item-nth-child-1-height, 100%);color:var(--loading-dot-line-item-nth-child-1-color, gold);border-color:var(--loading-dot-line-item-nth-child-1-border-color, currentColor transparent transparent currentColor);border-width:var(--loading-dot-line-item-nth-child-1-border-width, .2em .2em 0em 0em);--deg: var(--loading-dot-line-item-nth-child-1-deg, -45deg);animation-direction:var(--loading-dot-line-item-nth-child-1-animation-direction, normal)}.ran-loading .dot-line-item:nth-child(2){width:var(--loading-dot-line-item-nth-child-2-width, 70%);height:var(--loading-dot-line-item-nth-child-2-height, 70%);color:var(--loading-dot-line-item-nth-child-2-color, lime);border-color:var(--loading-dot-line-item-nth-child-2-border-color, currentColor currentColor transparent transparent);border-width:var(--loading-dot-line-item-nth-child-2-border-width, .2em 0em 0em .2em);--deg: var(--loading-dot-line-item-nth-child-2-deg, -135deg);animation-direction:var(--loading-dot-line-item-nth-child-2-animation-direction, reverse)}.ran-loading .dot-line-item-circle{position:var(--loading-dot-line-item-circle-position, absolute);width:var(--loading-dot-line-item-circle-width, 50%);height:var(--loading-dot-line-item-circle-height, .1em);top:var(--loading-dot-line-item-circle-top, 50%);left:var(--loading-dot-line-item-circle-left, 50%);background-color:var(--loading-dot-line-item-circle-background-color, transparent);transform:rotate(var(--deg));transform-origin:var(--loading-dot-line-item-circle-transform-origin, left)}.ran-loading .dot-line-item-circle:before{position:var(--loading-dot-line-item-circle-before-position, absolute);top:var(--loading-dot-line-item-circle-before-top, -.5em);right:var(--loading-dot-line-item-circle-before-right, -.5em);content:var(--loading-dot-line-item-circle-before-content, "");width:var(--loading-dot-line-item-circle-before-width, 1em);height:var(--loading-dot-line-item-circle-before-height, 1em);background-color:var(--loading-dot-line-item-circle-before-background-color, currentColor);border-radius:var(--loading-dot-line-item-circle-before-border-radius, 50%);box-shadow:var(--loading-dot-line-item-circle-before-box-shadow, 0 0 2em, 0 0 4em, 0 0 6em, 0 0 8em, 0 0 10em, 0 0 0 .5em rgba(255, 255, 0, .1))}.ran-loading .arc{position:relative}@keyframes rt{to{transform:var(--loading-arc-keyframes-rt, rotate(360deg))}}@keyframes cw{0%{width:var(--loading-arc-keyframes-cw-0-width, 0);height:var(--loading-arc-keyframes-cw-0-height, 0)}75%{width:var(--loading-arc-keyframes-cw-75-width, 40px);height:var(--loading-arc-keyframes-cw-75-height, 40px)}to{width:var(--loading-arc-keyframes-cw-100-width, 0);height:var(--loading-arc-keyframes-cw-100-height, 0)}}@keyframes txt{0%{content:var(--loading-arc-keyframes-txt-0-content, "LOADING.")}50%{content:var(--loading-arc-keyframes-txt-50-content, "LOADING..")}to{content:var(--loading-arc-keyframes-txt-100-content, "LOADING...")}}.ran-loading .arc-item{margin:var(--loading-arc-item-margin, auto);width:var(--loading-arc-item-width, 100px);height:var(--loading-arc-item-height, 100px);border-radius:var(--loading-arc-item-border-radius, 50%);border-top:var(--loading-arc-item-border-top, 2px solid #ffea29);border-left:var(--loading-arc-item-border-left, 1px solid transparent);border-right:var(--loading-arc-item-border-right, 1px solid transparent);animation:var(--loading-arc-item-animation, rt 2s infinite linear);animation-play-state:var(--loading-arc-item-animation-play-state, running)}.ran-loading .arc-item:before{position:var(--loading-arc-item-before-position, absolute);margin:var(--loading-arc-item-before-margin, auto);top:var(--loading-arc-item-before-top, 0);right:var(--loading-arc-item-before-right, 0);bottom:var(--loading-arc-item-before-bottom, 0);left:var(--loading-arc-item-before-left, 0);width:var(--loading-arc-item-before-width, 70px);height:var(--loading-arc-item-before-height, 70px);border-radius:var(--loading-arc-item-before-border-radius, 50%);border-top:var(--loading-arc-item-before-border-top, 2px solid #8d29ff);border-left:var(--loading-arc-item-before-border-left, 1px solid transparent);border-right:var(--loading-arc-item-before-border-right, 1px solid transparent);animation:var(--loading-arc-item-before-animation, rt 4s infinite linear reverse);animation-play-state:var(--loading-arc-item-before-animation-play-state, running);content:var(--loading-arc-item-before-content, "")}.ran-loading .arc-item:after{position:var(--loading-arc-item-after-position, absolute);margin:var(--loading-arc-item-after-margin, auto);top:var(--loading-arc-item-after-top, 0);right:var(--loading-arc-item-after-right, 0);bottom:var(--loading-arc-item-after-bottom, 0);left:var(--loading-arc-item-after-left, 0);width:var(--loading-arc-item-after-width, 0);height:var(--loading-arc-item-after-height, 0);border-radius:var(--loading-arc-item-after-border-radius, 50%);border-top:var(--loading-arc-item-after-border-top, initial);border-left:var(--loading-arc-item-after-border-left, initial);border-right:var(--loading-arc-item-after-border-right, initial);animation:var(--loading-arc-item-after-animation, cw 1s infinite);animation-play-state:var(--loading-arc-item-after-animation-play-state, running);content:var(--loading-arc-item-after-content, "");background:var(--loading-arc-item-after-background, snow)}.ran-loading .arc h1{position:var(--loading-arc-h1-position, absolute);margin:var(--loading-arc-h1-margin, auto);top:var(--loading-arc-h1-top, 140px);left:var(--loading-arc-h1-left, 0);right:var(--loading-arc-h1-right, 0);bottom:var(--loading-arc-h1-bottom, 0);text-transform:var(--loading-arc-h1-text-transform, uppercase);text-align:var(--loading-arc-h1-text-align, center);letter-spacing:var(--loading-arc-h1-letter-spacing, .1em);font-size:var(--loading-arc-h1-font-size, 14px);font-weight:var(--loading-arc-h1-ont-weight, lighter);color:var(--loading-arc-h1-color, white)}.ran-loading .arc h1:after{animation:var(--loading-arc-h1-after-animation, txt 5s infinite);animation-play-state:var(--loading-arc-h1-after-animation-play-state, running);content:var(--loading-arc-h1-after-content, "");font-family:var(--loading-arc-h1-after-font-family, "Inconsolata", monospace)}.ran-loading .arc span{display:var(--loading-arc-span-display, none)}.ran-loading .drop{position:var(--loading-drop-position, relative);width:var(--loading-drop-position, 120px);height:var(--loading-drop-position, 120px)}@keyframes fade-in{0%{opacity:var(--loading-drop-keyframes-fade-in-0-opacity, 0)}to{opacity:var(--loading-drop-keyframes-fade-in-100-opacity, 1)}}@keyframes drop{0%{bottom:var(--loading-drop-keyframes-drop-0-bottom, 0px);opacity:var(--loading-drop-keyframes-drop-0-opacity, 1)}80%{opacity:var(--loading-drop-keyframes-drop-80-opacity, 1)}to{opacity:var(--loading-drop-keyframes-drop-100-opacity, 1);bottom:var(--loading-drop-keyframes-drop-100-bottom, -200px)}}@keyframes wave{0%{background-position:var(--loading-drop-keyframes-wave-0-background-position, 0 160px);background-size:var(--loading-drop-keyframes-wave-0-background-size, 170px 300px)}to{background-position:var(--loading-drop-keyframes-wave-100-background-position, 500px -18px);background-size:var(--loading-drop-keyframes-wave-100-background-size, 250px 150px)}}.ran-loading .drop-item{position:var(--loading-drop-item-position, absolute);width:var(--loading-drop-item-width, 100%);height:var(--loading-drop-item-height, 100%);left:var(--loading-drop-item-left, 0);right:var(--loading-drop-item-right, 0);top:var(--loading-drop-item-top, 0);bottom:var(--loading-drop-item-bottom, 0);background:var(--loading-drop-item-background, transparent repeat-x 0 100px/150px 300px url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAEsCAYAAACG+vy+AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja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OZ/Ta+ceh2MS6EcgoCOazLtcF3MWkIQCAgEBAICAQEAgIBgYBAQCCAQEAgIBAQCAgEBAICAYGAQEAggEBAICAQEAgIBAQCAgGBgEAAgYBAQCAgEBAICAQEAgIBgYBAAIGAQEAgIBAQCAgEBAICAYEAAgGBgEBAICAQEAgIBAQCAgGBAAIBgYBAQCAgEBAICAQEAgIBBAICAYGAQEAgIBAQCAgEBAICAQQCAgGBgEBAICAQEAgIBAQCAjEEIBAQCAgEBAICAYGAQEAgIBBAICAQEAgIBAQCAgGBgEBAICAQQCAgEBAICAQEAgIBgYBAQCCAQEAgIBAQCAgEBAICAYGAQEAggEBAICAQEAgIBAQCAgGBgEAAgYBAQCAgEBAICAQEAgIBgYBAAIGAQEAgIBAQCAgEBAICAYEAAgGBgEBAICAQEAgIBAQCAgGBAAIBgYBAQCAgEBAICAQEAgIBgRgCEAgIBAQCAgGBgEBAICAQEAggEBAICAQEAgIBgYBAQCAgEBAIIBAQCAgEBAICAYGAQEAgIBBAICAQEAgIBAQCAgGBgEBAICAQQCAgEBAICAQEAgIBgYBAQCCAQEAgIBAQCAgEBAICAYGAQEAggEBAICAQEAgIBAQCAgGBgEAAgYBAQCAgEBAICAQEAgIBgYBAAIGAQEAgIBAQCAgEBAICAYGAQAwBCAQEAgIBgYBAQCAgEBAICAQQCAgEBAICAYGAQEAgIBAQCIy3LwMAZISJmhIzD54AAAAASUVORK5CYII=));z-index:var(--loading-drop-item-z-index, 2);animation:var(--loading-drop-item-animation, wave 1s ease-out forwards);animation-play-state:var(--loading-drop-item-animation-play-state, running)}.ran-loading .drop-item-bg{text-align:var(--loading-drop-item-text-align, center);line-height:var(--loading-drop-item-line-height, 120px);font-family:var(--loading-drop-item-font-family, sans-serif);color:var(--loading-drop-item-color, #ffffff);font-size:var(--loading-drop-item-font-size, 16px)}.ran-loading .drop-dot{position:var(--loading-drop-dot-position, absolute);top:var(--loading-drop-dot-top, 0);left:var(--loading-drop-dot-left, 0);bottom:var(--loading-drop-dot-bottom, 0);right:var(--loading-drop-dot-right, 0);z-index:var(--loading-drop-dot-z-index, 1);opacity:var(--loading-drop-dot-opacity, 0);animation:var(--loading-drop-dot-animation, fade-in .1s linear .4s forwards);animation-play-state:var(--loading-drop-dot-animation-play-state, running);filter:var(--loading-drop-dot-filter, url(data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSI+CiAgICA8ZGVmcz4KICAgICAgPGZpbHRlciBpZD0icmFuLWxvYWRpbmctZHJvcCI+CiAgICAgICAgPGZlR2F1c3NpYW5CbHVyIGluPSJTb3VyY2VHcmFwaGljIiBzdGREZXZpYXRpb249IjEwIiByZXN1bHQ9ImJsdXIiIC8+CiAgICAgICAgPGZlQ29sb3JNYXRyaXggaW49ImJsdXIiIG1vZGU9Im1hdHJpeCIgdmFsdWVzPSIxIDAgMCAwIDAgIDAgMSAwIDAgMCAgMCAwIDEgMCAwICAwIDAgMCAxOCAtNyIgcmVzdWx0PSJyYW4tbG9hZGluZy1kcm9wIiAvPgogICAgICA8L2ZpbHRlcj4KICAgIDwvZGVmcz4KICA8L3N2Zz4=#ran-loading-drop))}.ran-loading .drop-dot-1{position:var(--loading-drop-dot-1-position, absolute);left:var(--loading-drop-dot-1-left, 0);right:var(--loading-drop-dot-1-right, 0);bottom:var(--loading-drop-dot-1-bottom, 0);margin:var(--loading-drop-dot-1-margin, auto);background-color:var(--loading-drop-dot-1-background-color, #10a7c1);width:var(--loading-drop-dot-1-width, 90px);height:var(--loading-drop-dot-1-height, 16px);bottom:var(--loading-drop-dot-1-bottom, 2px);border-radius:var(--loading-drop-dot-1-border-radius, 0)}.ran-loading .drop-dot-2{width:var(--loading-drop-dot-2-width, 21px);height:var(--loading-drop-dot-2-height, 24px);border-radius:var(--loading-drop-dot-2-border-radius, 50%);position:var(--loading-drop-dot-2-position, absolute);left:var(--loading-drop-dot-2-left, 0);right:var(--loading-drop-dot-2-right, 0);bottom:var(--loading-drop-dot-2-bottom, 0);margin:var(--loading-drop-dot-2-margin, auto);background-color:var(--loading-drop-dot-2-background-color, #10a7c1);animation:var(--loading-drop-dot-2-animation, drop 1.3s cubic-bezier(1, .19, .66, .12) .5s infinite);animation-play-state:var(--loading-drop-dot-2-animation-play-state, running)}.ran-loading .pacman{position:var(--loading-pacman-position, relative)}@keyframes rotate_pacman_half_up{0%{transform:var(--loading-pacman-keyframes-0-transform, rotate(270deg))}50%{transform:var(--loading-pacman-keyframes-50-transform, rotate(360deg))}to{transform:var(--loading-pacman-keyframes-100-transform, rotate(270deg))}}@keyframes pacman-balls{75%{opacity:var(--loading-pacman-keyframes-balls-75-opacity, .7)}to{transform:var(--loading-pacman-keyframes-balls-100-transform, translate(-100px, -6.25px))}}@keyframes rotate_pacman_half_down{0%{transform:var(--loading-pacman-keyframes-balls-100-transform, rotate(90deg))}50%{transform:var(--loading-pacman-keyframes-balls-100-transform, rotate(0deg))}to{transform:var(--loading-pacman-keyframes-balls-100-transform, rotate(90deg))}}.ran-loading .pacman div:nth-child(2){width:var(--loading-pacman-div-nth-child-2-width, 0px);height:var(--loading-pacman-div-nth-child-2-height, 0px);border-right:var(--loading-pacman-div-nth-child-2-border-right, 25px solid transparent);border-top:var(--loading-pacman-div-nth-child-2-border-top, 25px solid #279fcf);border-left:var(--loading-pacman-div-nth-child-2-border-left, 25px solid #279fcf);border-bottom:var(--loading-pacman-div-nth-child-2-border-bottom, 25px solid #279fcf);border-radius:var(--loading-pacman-div-nth-child-2-border-radius, 25px);margin-top:var(--loading-pacman-div-nth-child-2-margin-top, -50px);animation:var(--loading-pacman-div-nth-child-2-animation, rotate_pacman_half_down .5s 0s infinite);animation-play-state:var(--loading-pacman-div-nth-child-2-animation-play-state, running)}.ran-loading .pacman div:nth-child(3){background-color:var(--loading-pacman-div-nth-child-3-background-color, #279fcf);border-radius:var(--loading-pacman-div-nth-child-3-border-radius, 100%);margin:var(--loading-pacman-div-nth-child-3-margin, 2px);width:var(--loading-pacman-div-nth-child-3-width, 10px);height:var(--loading-pacman-div-nth-child-3-height, 10px);position:var(--loading-pacman-div-nth-child-3-position, absolute);transform:var(--loading-pacman-div-nth-child-3-transform, translate(0, -6.25px));top:var(--loading-pacman-div-nth-child-3-top, 25px);left:var(--loading-pacman-div-nth-child-3-left, 100px);animation:var(--loading-pacman-div-nth-child-3-animation, pacman-balls 1s .33s infinite linear);animation-play-state:var(--loading-pacman-div-nth-child-3-animation-play-state, running)}.ran-loading .pacman div:nth-child(4){background-color:var(--loading-pacman-div-nth-child-4-background-color, #279fcf);border-radius:var(--loading-pacman-div-nth-child-4-border-radius, 100%);margin:var(--loading-pacman-div-nth-child-4-margin, 2px);width:var(--loading-pacman-div-nth-child-4-width, 10px);height:var(--loading-pacman-div-nth-child-4-height, 10px);position:var(--loading-pacman-div-nth-child-4-position, absolute);transform:var(--loading-pacman-div-nth-child-4-transform, translate(0, -6.25px));top:var(--loading-pacman-div-nth-child-4-top, 25px);left:var(--loading-pacman-div-nth-child-4-left, 100px);animation:var(--loading-pacman-div-nth-child-4-animation, pacman-balls 1s .66s infinite linear);animation-play-state:var(--loading-pacman-div-nth-child-4-animation-play-state, running)}.ran-loading .pacman div:nth-child(5){background-color:var(--loading-pacman-div-nth-child-5-background-color, #279fcf);border-radius:var(--loading-pacman-div-nth-child-5-border-radius, 100%);margin:var(--loading-pacman-div-nth-child-5-margin, 2px);width:var(--loading-pacman-div-nth-child-5-width, 10px);height:var(--loading-pacman-div-nth-child-5-height, 10px);position:var(--loading-pacman-div-nth-child-5-position, absolute);transform:var(--loading-pacman-div-nth-child-5-transform, translate(0, -6.25px));top:var(--loading-pacman-div-nth-child-5-top, 25px);left:var(--loading-pacman-div-nth-child-5-left, 100px);animation:var(--loading-pacman-div-nth-child-5-animation, pacman-balls 1s .99s infinite linear);animation-play-state:var(--loading-pacman-div-nth-child-5-animation-play-state, running)}.ran-loading .pacman div:first-of-type{width:var(--loading-pacman-div-first-of-type-width, 0px);height:var(--loading-pacman-div-first-of-type-height, 0px);border-right:var(--loading-pacman-div-first-of-type-border-right, 25px solid transparent);border-top:var(--loading-pacman-div-first-of-type-border-top, 25px solid #279fcf);border-left:var(--loading-pacman-div-first-of-type-border-left, 25px solid #279fcf);border-bottom:var(--loading-pacman-div-first-of-type-border-bottom, 25px solid #279fcf);border-radius:var(--loading-pacman-div-first-of-type-border-radius, 25px);animation:var(--loading-pacman-div-first-of-type-animation, rotate_pacman_half_up .5s 0s infinite);animation-play-state:var(--loading-pacman-div-first-of-type-animation-play-state, running)}',g.appendChild(I),g.appendChild(this.contain)}static get observedAttributes(){return["name"]}get name(){const g=this.getAttribute("name")||"";return g||"circle"}set name(g){this.setAttribute("name",g||"")}connectedCallback(){this.createLoading()}disconnectCallback(){}attributeChangedCallback(g,I,C){I!==C&&"name"===g&&this.createLoading()}}const tI="undefined"==typeof document||customElements.get("r-loading")?K("document is undefined or r-loading is exist"):(customElements.define("r-loading",eI),eI),lI=Object.freeze(Object.defineProperty({__proto__:null,Loading:eI,NAME_AMP:iI,default:tI},Symbol.toStringTag,{value:"Module"}));let sI=class extends(f()){constructor(){super(),C(this,"contain"),this.contain=w("div").setAttribute("class","ran-math").element;const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-math-position, relative)}.ran-math{display:var(--ran-math-display, flex);justify-content:var(--ran-math-justify-content, space-around);align-items:var(--ran-math-align-items, center)}.katex-html{display:var(--ran-math-katex-display, none)}",g.appendChild(I),g.appendChild(this.contain)}static get observedAttributes(){return["latex"]}get latex(){const g=this.getAttribute("latex")||"";return decodeURIComponent(g)}set latex(g){this.setAttribute("latex",g||"")}render(){this.latex&&Promise.resolve().then((()=>Hr)).then((g=>{this.contain.innerHTML="";const I=w("span").setTextContent(`$$${this.latex}$$`).element;this.contain.appendChild(I),g&&g.renderMathInElement(this.contain)})).catch((function(g){console.warn(`ranui math component warning: ${g.message}\n${g}`)}))}connectedCallback(){this.render()}disconnectCallback(){}attributeChangedCallback(g,I,C){I!==C&&"latex"===g&&this.render()}};const oI=async function(){return"undefined"==typeof document||customElements.get("r-math")?K("document is undefined or r-math is exist"):(customElements.define("r-math",sI),sI)}(),cI=Object.freeze(Object.defineProperty({__proto__:null,Math:sI,default:oI},Symbol.toStringTag,{value:"Module"})),dI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n'}},Symbol.toStringTag,{value:"Module"})),aI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n'}},Symbol.toStringTag,{value:"Module"})),nI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),rI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),mI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),hI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),ZI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),bI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),GI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n \n \n \n \n'}},Symbol.toStringTag,{value:"Module"})),uI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n \n'}},Symbol.toStringTag,{value:"Module"})),pI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n \n'}},Symbol.toStringTag,{value:"Module"})),wI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),WI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),BI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n \n \n'}},Symbol.toStringTag,{value:"Module"})),yI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:' \n LOADING\n \n \n \n \n\n \n \n\n \n \n \n\n \n \n \n \n'}},Symbol.toStringTag,{value:"Module"})),VI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),XI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n \n'}},Symbol.toStringTag,{value:"Module"})),YI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),RI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),NI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),HI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),KI={success:!0,_identification:!0,data:'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n\n\n \n \n \n \n\n\n \n \n \n \n\n\n \n \n \n \n\n\n \n \n \n \n\n\n \n \n \n \n\n\n \n \n \n \n\n\n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'},fI=Object.freeze(Object.defineProperty({__proto__:null,default:KI},Symbol.toStringTag,{value:"Module"})),FI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),MI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\n \n \n'}},Symbol.toStringTag,{value:"Module"})),SI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),JI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),kI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"}));window.E0DD32CBDCB63F=function(){var g={version:"3.5.9"},I=[].slice,C=function(g){return I.call(g)},A=this.document;function i(g){return g&&(g.ownerDocument||g.document||g).documentElement}function e(g){return g&&(g.ownerDocument&&g.ownerDocument.defaultView||g.document&&g||g.defaultView)}if(A)try{C(A.documentElement.childNodes)[0].nodeType}catch(gs){C=function(g){for(var I=g.length,C=new Array(I);I--;)C[I]=g[I];return C}}if(Date.now||(Date.now=function(){return+new Date}),A)try{A.createElement("DIV").style.setProperty("opacity",0,"")}catch(Is){var t=this.Element.prototype,l=t.setAttribute,s=t.setAttributeNS,o=this.CSSStyleDeclaration.prototype,c=o.setProperty;t.setAttribute=function(g,I){l.call(this,g,I+"")},t.setAttributeNS=function(g,I,C){s.call(this,g,I,C+"")},o.setProperty=function(g,I,C){c.call(this,g,I+"",C)}}function d(g,I){return gI?1:g>=I?0:NaN}function a(g){return null===g?NaN:+g}function n(g){return!isNaN(g)}function r(g){return{left:function(I,C,A,i){for(arguments.length<3&&(A=0),arguments.length<4&&(i=I.length);A>>1;g(I[e],C)<0?A=e+1:i=e}return A},right:function(I,C,A,i){for(arguments.length<3&&(A=0),arguments.length<4&&(i=I.length);A>>1;g(I[e],C)>0?i=e:A=e+1}return A}}}g.ascending=d,g.descending=function(g,I){return Ig?1:I>=g?0:NaN},g.min=function(g,I){var C,A,i=-1,e=g.length;if(1===arguments.length){for(;++i=A){C=A;break}for(;++iA&&(C=A)}else{for(;++i=A){C=A;break}for(;++iA&&(C=A)}return C},g.max=function(g,I){var C,A,i=-1,e=g.length;if(1===arguments.length){for(;++i=A){C=A;break}for(;++iC&&(C=A)}else{for(;++i=A){C=A;break}for(;++iC&&(C=A)}return C},g.extent=function(g,I){var C,A,i,e=-1,t=g.length;if(1===arguments.length){for(;++e=A){C=i=A;break}for(;++eA&&(C=A),i=A){C=i=A;break}for(;++eA&&(C=A),i1)return t/(s-1)},g.deviation=function(){var I=g.variance.apply(this,arguments);return I?Math.sqrt(I):I};var m=r(d);function h(g){return g.length}g.bisectLeft=m.left,g.bisect=g.bisectRight=m.right,g.bisector=function(g){return r(1===g.length?function(I,C){return d(g(I),C)}:g)},g.shuffle=function(g,I,C){(e=arguments.length)<3&&(C=g.length,e<2&&(I=0));for(var A,i,e=C-I;e;)i=Math.random()*e--|0,A=g[e+I],g[e+I]=g[i+I],g[i+I]=A;return g},g.permute=function(g,I){for(var C=I.length,A=new Array(C);C--;)A[C]=g[I[C]];return A},g.pairs=function(g){for(var I=0,C=g.length-1,A=g[0],i=new Array(C<0?0:C);I=0;)for(I=(A=g[i]).length;--I>=0;)C[--t]=A[I];return C};var Z=Math.abs;function b(g,I){for(var C in I)Object.defineProperty(g.prototype,C,{value:I[C],enumerable:!1})}function G(){this._=Object.create(null)}g.range=function(g,I,C){if(arguments.length<3&&(C=1,arguments.length<2&&(I=g,g=0)),(I-g)/C==1/0)throw new Error("infinite range");var A,i=[],e=function(g){var I=1;for(;g*I%1;)I*=10;return I}(Z(C)),t=-1;if(g*=e,I*=e,(C*=e)<0)for(;(A=g+C*++t)>I;)i.push(A/e);else for(;(A=g+C*++t)=i.length)return C?C.call(A,e):I?e.sort(I):e;for(var s,o,c,d,a=-1,n=e.length,r=i[l++],m=new G;++a=i.length)return g;var C=[],A=e[I++];return g.forEach((function(g,A){C.push({key:g,values:l(A,I)})})),A?C.sort((function(g,I){return A(g.key,I.key)})):C}return A.map=function(g,I){return t(I,g,0)},A.entries=function(I){return l(t(g.map,I,0),0)},A.key=function(g){return i.push(g),A},A.sortKeys=function(g){return e[i.length-1]=g,A},A.sortValues=function(g){return I=g,A},A.rollup=function(g){return C=g,A},A},g.set=function(g){var I=new R;if(g)for(var C=0,A=g.length;C=0&&(A=g.slice(C+1),g=g.slice(0,C)),g)return arguments.length<2?this[g].on(A):this[g].on(A,I);if(2===arguments.length){if(null==I)for(g in this)this.hasOwnProperty(g)&&this[g].on(A,null);return this}},g.event=null,g.requote=function(g){return g.replace(v,"\\$&")};var v=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,L={}.__proto__?function(g,I){g.__proto__=I}:function(g,I){for(var C in I)g[C]=I[C]};function z(g){return L(g,j),g}var T=function(g,I){return I.querySelector(g)},x=function(g,I){return I.querySelectorAll(g)},U=function(g,I){var C=g.matches||g[K(g,"matchesSelector")];return(U=function(g,I){return C.call(g,I)})(g,I)};"function"==typeof Sizzle&&(T=function(g,I){return Sizzle(g,I)[0]||null},x=Sizzle,U=Sizzle.matchesSelector),g.selection=function(){return g.select(A.documentElement)};var j=g.selection.prototype=[];function Q(g){return"function"==typeof g?g:function(){return T(g,this)}}function O(g){return"function"==typeof g?g:function(){return x(g,this)}}j.select=function(g){var I,C,A,i,e=[];g=Q(g);for(var t=-1,l=this.length;++t=0&&"xmlns"!==(C=g.slice(0,I))&&(g=g.slice(I+1)),E.hasOwnProperty(C)?{space:E[C],local:g}:g}},j.attr=function(I,C){if(arguments.length<2){if("string"==typeof I){var A=this.node();return(I=g.ns.qualify(I)).local?A.getAttributeNS(I.space,I.local):A.getAttribute(I)}for(C in I)this.each(P(C,I[C]));return this}return this.each(P(I,C))},j.classed=function(g,I){if(arguments.length<2){if("string"==typeof g){var C=this.node(),A=(g=$(g)).length,i=-1;if(I=C.classList){for(;++i=0;)(C=A[i])&&(e&&e!==C.nextSibling&&e.parentNode.insertBefore(C,e),e=C);return this},j.sort=function(g){g=sg.apply(this,arguments);for(var I=-1,C=this.length;++I0&&(I=I.slice(0,t));var s=ng.get(I);function o(){var g=this[e];g&&(this.removeEventListener(I,g,g.$),delete this[e])}return s&&(I=s,l=mg),t?A?function(){var g=l(A,C(arguments));o.call(this),this.addEventListener(I,this[e]=g,g.$=i),g._=A}:o:A?F:function(){var C,A=new RegExp("^__on([^.]+)"+g.requote(I)+"$");for(var i in this)if(C=i.match(A)){var e=this[i];this.removeEventListener(C[1],e,e.$),delete this[i]}}}g.selection.enter=cg,g.selection.enter.prototype=dg,dg.append=j.append,dg.empty=j.empty,dg.node=j.node,dg.call=j.call,dg.size=j.size,dg.select=function(g){for(var I,C,A,i,e,t=[],l=-1,s=this.length;++l=A&&(A=I+1);!(t=l[A])&&++A0?1:g<0?-1:0}function Hg(g,I,C){return(I[0]-g[0])*(C[1]-g[1])-(I[1]-g[1])*(C[0]-g[0])}function Kg(g){return g>1?0:g<-1?Bg:Math.acos(g)}function fg(g){return g>1?Xg:g<-1?-Xg:Math.asin(g)}function Fg(g){return((g=Math.exp(g))+1/g)/2}function Mg(g){return(g=Math.sin(g/2))*g}var Sg=Math.SQRT2;g.interpolateZoom=function(g,I){var C,A,i=g[0],e=g[1],t=g[2],l=I[0],s=I[1],o=I[2],c=l-i,d=s-e,a=c*c+d*d;if(a0&&(I=I.transition().duration(m)),I.call(w.event)}function X(){o&&o.domain(s.range().map((function(g){return(g-a.x)/a.k})).map(s.invert)),d&&d.domain(c.range().map((function(g){return(g-a.y)/a.k})).map(c.invert))}function Y(g){h++||g({type:"zoomstart"})}function R(g){X(),g({type:"zoom",scale:a.k,translate:[a.x,a.y]})}function N(g){--h||(g({type:"zoomend"}),C=null)}function H(){var I=this,C=p.of(I,arguments),A=0,i=g.select(e(I)).on(b,(function(){A=1,y(g.mouse(I),t),R(C)})).on(G,(function(){i.on(b,null).on(G,null),l(A),N(C)})),t=W(g.mouse(I)),l=bg(I);Wl.call(I),Y(C)}function K(){var I,C=this,A=p.of(C,arguments),i={},e=0,t=".zoom-"+g.event.changedTouches[0].identifier,s="touchmove"+t,o="touchend"+t,c=[],d=g.select(C),n=bg(C);function r(){var A=g.touches(C);return I=a.k,A.forEach((function(g){g.identifier in i&&(i[g.identifier]=W(g))})),A}function m(){var I=g.event.target;g.select(I).on(s,h).on(o,b),c.push(I);for(var A=g.event.changedTouches,t=0,d=A.length;t1){Z=n[0];var G=n[1],u=Z[0]-G[0],p=Z[1]-G[1];e=u*u+p*p}}function h(){var t,s,o,c,d=g.touches(C);Wl.call(C);for(var a=0,n=d.length;a360?g-=360:g<0&&(g+=360),g<60?A+(i-A)*g/60:g<180?i:g<240?A+(i-A)*(240-g)/60:A}(g))}return g=isNaN(g)?0:(g%=360)<0?g+360:g,I=isNaN(I)||I<0?0:I>1?1:I,A=2*(C=C<0?0:C>1?1:C)-(i=C<=.5?C*(1+I):C+I-C*I),new iI(e(g+120),e(g),e(g-120))}function xg(I,C,A){return this instanceof xg?(this.h=+I,this.c=+C,void(this.l=+A)):arguments.length<2?I instanceof xg?new xg(I.h,I.c,I.l):gI(I instanceof Qg?I.l:(I=dI((I=g.rgb(I)).r,I.g,I.b)).l,I.a,I.b):new xg(I,C,A)}zg.brighter=function(g){return g=Math.pow(.7,arguments.length?g:1),new Lg(this.h,this.s,this.l/g)},zg.darker=function(g){return g=Math.pow(.7,arguments.length?g:1),new Lg(this.h,this.s,g*this.l)},zg.rgb=function(){return Tg(this.h,this.s,this.l)},g.hcl=xg;var Ug=xg.prototype=new vg;function jg(g,I,C){return isNaN(g)&&(g=0),isNaN(I)&&(I=0),new Qg(C,Math.cos(g*=Yg)*I,Math.sin(g)*I)}function Qg(g,I,C){return this instanceof Qg?(this.l=+g,this.a=+I,void(this.b=+C)):arguments.length<2?g instanceof Qg?new Qg(g.l,g.a,g.b):g instanceof xg?jg(g.h,g.c,g.l):dI((g=iI(g)).r,g.g,g.b):new Qg(g,I,C)}Ug.brighter=function(g){return new xg(this.h,this.c,Math.min(100,this.l+Og*(arguments.length?g:1)))},Ug.darker=function(g){return new xg(this.h,this.c,Math.max(0,this.l-Og*(arguments.length?g:1)))},Ug.rgb=function(){return jg(this.h,this.c,this.l).rgb()},g.lab=Qg;var Og=18,Eg=.95047,Pg=1,_g=1.08883,qg=Qg.prototype=new vg;function $g(g,I,C){var A=(g+16)/116,i=A+I/500,e=A-C/200;return new iI(AI(3.2404542*(i=II(i)*Eg)-1.5371385*(A=II(A)*Pg)-.4985314*(e=II(e)*_g)),AI(-.969266*i+1.8760108*A+.041556*e),AI(.0556434*i-.2040259*A+1.0572252*e))}function gI(g,I,C){return g>0?new xg(Math.atan2(C,I)*Rg,Math.sqrt(I*I+C*C),g):new xg(NaN,NaN,g)}function II(g){return g>.206893034?g*g*g:(g-4/29)/7.787037}function CI(g){return g>.008856?Math.pow(g,1/3):7.787037*g+4/29}function AI(g){return Math.round(255*(g<=.00304?12.92*g:1.055*Math.pow(g,1/2.4)-.055))}function iI(g,I,C){return this instanceof iI?(this.r=~~g,this.g=~~I,void(this.b=~~C)):arguments.length<2?g instanceof iI?new iI(g.r,g.g,g.b):oI(""+g,iI,Tg):new iI(g,I,C)}function eI(g){return new iI(g>>16,g>>8&255,255&g)}function tI(g){return eI(g)+""}qg.brighter=function(g){return new Qg(Math.min(100,this.l+Og*(arguments.length?g:1)),this.a,this.b)},qg.darker=function(g){return new Qg(Math.max(0,this.l-Og*(arguments.length?g:1)),this.a,this.b)},qg.rgb=function(){return $g(this.l,this.a,this.b)},g.rgb=iI;var lI=iI.prototype=new vg;function sI(g){return g<16?"0"+Math.max(0,g).toString(16):Math.min(255,g).toString(16)}function oI(g,I,C){var A,i,e,t=0,l=0,s=0;if(A=/([a-z]+)\((.*)\)/.exec(g=g.toLowerCase()))switch(i=A[2].split(","),A[1]){case"hsl":return C(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return I(nI(i[0]),nI(i[1]),nI(i[2]))}return(e=rI.get(g))?I(e.r,e.g,e.b):(null==g||"#"!==g.charAt(0)||isNaN(e=parseInt(g.slice(1),16))||(4===g.length?(t=(3840&e)>>4,t|=t>>4,l=240&e,l|=l>>4,s=15&e,s|=s<<4):7===g.length&&(t=(16711680&e)>>16,l=(65280&e)>>8,s=255&e)),I(t,l,s))}function cI(g,I,C){var A,i,e=Math.min(g/=255,I/=255,C/=255),t=Math.max(g,I,C),l=t-e,s=(t+e)/2;return l?(i=s<.5?l/(t+e):l/(2-t-e),A=g==t?(I-C)/l+(I0&&s<1?0:A),new Lg(A,i,s)}function dI(g,I,C){var A=CI((.4124564*(g=aI(g))+.3575761*(I=aI(I))+.1804375*(C=aI(C)))/Eg),i=CI((.2126729*g+.7151522*I+.072175*C)/Pg);return Qg(116*i-16,500*(A-i),200*(i-CI((.0193339*g+.119192*I+.9503041*C)/_g)))}function aI(g){return(g/=255)<=.04045?g/12.92:Math.pow((g+.055)/1.055,2.4)}function nI(g){var I=parseFloat(g);return"%"===g.charAt(g.length-1)?Math.round(2.55*I):I}lI.brighter=function(g){g=Math.pow(.7,arguments.length?g:1);var I=this.r,C=this.g,A=this.b,i=30;return I||C||A?(I&&I=200&&I<300||304===I){try{g=i.call(t,o)}catch(gs){return void l.error.call(t,gs)}l.load.call(t,g)}else l.error.call(t,o)}return this.XDomainRequest&&!("withCredentials"in o)&&/^(http(s)?:)?\/\//.test(I)&&(o=new XDomainRequest),"onload"in o?o.onload=o.onerror=d:o.onreadystatechange=function(){o.readyState>3&&d()},o.onprogress=function(I){var C=g.event;g.event=I;try{l.progress.call(t,o)}finally{g.event=C}},t.header=function(g,I){return g=(g+"").toLowerCase(),arguments.length<2?s[g]:(null==I?delete s[g]:s[g]=I+"",t)},t.mimeType=function(g){return arguments.length?(A=null==g?null:g+"",t):A},t.responseType=function(g){return arguments.length?(c=g,t):c},t.response=function(g){return i=g,t},["get","post"].forEach((function(g){t[g]=function(){return t.send.apply(t,[g].concat(C(arguments)))}})),t.send=function(g,C,i){if(2===arguments.length&&"function"==typeof C&&(i=C,C=null),o.open(g,I,!0),null==A||"accept"in s||(s.accept=A+",*/*"),o.setRequestHeader)for(var e in s)o.setRequestHeader(e,s[e]);return null!=A&&o.overrideMimeType&&o.overrideMimeType(A),null!=c&&(o.responseType=c),null!=i&&t.on("error",i).on("load",(function(g){i(null,g)})),l.beforesend.call(t,o),o.send(null==C?null:C),t},t.abort=function(){return o.abort(),t},g.rebind(t,l,"on"),null==e?t:t.get(function(g){return 1===g.length?function(I,C){g(null==I?C:null)}:g}(e))}rI.forEach((function(g,I){rI.set(g,eI(I))})),g.functor=mI,g.xhr=hI(N),g.dsv=function(g,I){var C=new RegExp('["'+g+"\n]"),A=g.charCodeAt(0);function i(g,C,A){arguments.length<3&&(A=C,C=null);var i=ZI(g,I,null==C?e:t(C),A);return i.row=function(g){return arguments.length?i.response(null==(C=g)?e:t(g)):C},i}function e(g){return i.parse(g.responseText)}function t(g){return function(I){return i.parse(I.responseText,g)}}function l(I){return I.map(s).join(g)}function s(g){return C.test(g)?'"'+g.replace(/\"/g,'""')+'"':g}return i.parse=function(g,I){var C;return i.parseRows(g,(function(g,A){if(C)return C(g,A-1);var i=new Function("d","return {"+g.map((function(g,I){return JSON.stringify(g)+": d["+I+"]"})).join(",")+"}");C=I?function(g,C){return I(i(g),C)}:i}))},i.parseRows=function(g,I){var C,i,e={},t={},l=[],s=g.length,o=0,c=0;function d(){if(o>=s)return t;if(i)return i=!1,e;var I=o;if(34===g.charCodeAt(I)){for(var C=I;C++24?(isFinite(I)&&(clearTimeout(pI),pI=setTimeout(BI,I)),uI=0):(uI=1,wI(BI))}function yI(){for(var g=Date.now(),I=bI;I;)g>=I.t&&I.c(g-I.t)&&(I.c=null),I=I.n;return g}function VI(){for(var g,I=bI,C=1/0;I;)I.c?(I.t8?function(g){return g/C}:function(g){return g*C},symbol:g}}));function RI(I){var C=I.decimal,A=I.thousands,i=I.grouping,e=I.currency,t=i&&A?function(g,I){for(var C=g.length,e=[],t=0,l=i[0],s=0;C>0&&l>0&&(s+l+1>I&&(l=Math.max(1,I-s)),e.push(g.substring(C-=l,C+l)),!((s+=l+1)>I));)l=i[t=(t+1)%i.length];return e.reverse().join(A)}:N;return function(I){var A=NI.exec(I),i=A[1]||" ",l=A[2]||">",s=A[3]||"-",o=A[4]||"",c=A[5],d=+A[6],a=A[7],n=A[8],r=A[9],m=1,h="",Z="",b=!1,G=!0;switch(n&&(n=+n.substring(1)),(c||"0"===i&&"="===l)&&(c=i="0",l="="),r){case"n":a=!0,r="g";break;case"%":m=100,Z="%",r="f";break;case"p":m=100,Z="%",r="r";break;case"b":case"o":case"x":case"X":"#"===o&&(h="0"+r.toLowerCase());case"c":G=!1;case"d":b=!0,n=0;break;case"s":m=-1,r="r"}"$"===o&&(h=e[0],Z=e[1]),"r"!=r||n||(r="g"),null!=n&&("g"==r?n=Math.max(1,Math.min(21,n)):"e"!=r&&"f"!=r||(n=Math.max(0,Math.min(20,n)))),r=HI.get(r)||KI;var u=c&&a;return function(I){var A=Z;if(b&&I%1)return"";var e=I<0||0===I&&1/I<0?(I=-I,"-"):"-"===s?"":s;if(m<0){var o=g.formatPrefix(I,n);I=o.scale(I),A=o.symbol+Z}else I*=m;var p,w,W=(I=r(I,n)).lastIndexOf(".");if(W<0){var B=G?I.lastIndexOf("e"):-1;B<0?(p=I,w=""):(p=I.substring(0,B),w=I.substring(B))}else p=I.substring(0,W),w=C+I.substring(W+1);!c&&a&&(p=t(p,1/0));var y=h.length+p.length+w.length+(u?0:e.length),V=y"===l?V+e+I:"^"===l?V.substring(0,y>>=1)+e+I+V.substring(y):e+(u?I:V+I))+A}}}g.formatPrefix=function(I,C){var A=0;return(I=+I)&&(I<0&&(I*=-1),C&&(I=g.round(I,XI(I,C))),A=1+Math.floor(1e-12+Math.log(I)/Math.LN10),A=Math.max(-24,Math.min(24,3*Math.floor((A-1)/3)))),YI[8+A/3]};var NI=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,HI=g.map({b:function(g){return g.toString(2)},c:function(g){return String.fromCharCode(g)},o:function(g){return g.toString(8)},x:function(g){return g.toString(16)},X:function(g){return g.toString(16).toUpperCase()},g:function(g,I){return g.toPrecision(I)},e:function(g,I){return g.toExponential(I)},f:function(g,I){return g.toFixed(I)},r:function(I,C){return(I=g.round(I,XI(I,C))).toFixed(Math.max(0,Math.min(20,XI(I*(1+1e-15),C))))}});function KI(g){return g+""}var fI=g.time={},FI=Date;function MI(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}MI.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){SI.setUTCDate.apply(this._,arguments)},setDay:function(){SI.setUTCDay.apply(this._,arguments)},setFullYear:function(){SI.setUTCFullYear.apply(this._,arguments)},setHours:function(){SI.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){SI.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){SI.setUTCMinutes.apply(this._,arguments)},setMonth:function(){SI.setUTCMonth.apply(this._,arguments)},setSeconds:function(){SI.setUTCSeconds.apply(this._,arguments)},setTime:function(){SI.setTime.apply(this._,arguments)}};var SI=Date.prototype;function JI(g,I,C){function A(I){var C=g(I),A=e(C,1);return I-C1)for(;t=o)return-1;if(37===(i=I.charCodeAt(l++))){if(t=I.charAt(l++),!(e=w[t in vI?I.charAt(l++):t])||(A=e(g,C,A))<0)return-1}else if(i!=C.charCodeAt(A++))return-1}return A}c.utc=function(g){var I=c(g);function C(g){try{var C=new(FI=MI);return C._=g,I(C)}finally{FI=Date}}return C.parse=function(g){try{FI=MI;var C=I.parse(g);return C&&C._}finally{FI=Date}},C.toString=I.toString,C},c.multi=c.utc.multi=lC;var a=g.map(),n=xI(t),r=UI(t),m=xI(l),h=UI(l),Z=xI(s),b=UI(s),G=xI(o),u=UI(o);e.forEach((function(g,I){a.set(g.toLowerCase(),I)}));var p={a:function(g){return l[g.getDay()]},A:function(g){return t[g.getDay()]},b:function(g){return o[g.getMonth()]},B:function(g){return s[g.getMonth()]},c:c(C),d:function(g,I){return TI(g.getDate(),I,2)},e:function(g,I){return TI(g.getDate(),I,2)},H:function(g,I){return TI(g.getHours(),I,2)},I:function(g,I){return TI(g.getHours()%12||12,I,2)},j:function(g,I){return TI(1+fI.dayOfYear(g),I,3)},L:function(g,I){return TI(g.getMilliseconds(),I,3)},m:function(g,I){return TI(g.getMonth()+1,I,2)},M:function(g,I){return TI(g.getMinutes(),I,2)},p:function(g){return e[+(g.getHours()>=12)]},S:function(g,I){return TI(g.getSeconds(),I,2)},U:function(g,I){return TI(fI.sundayOfYear(g),I,2)},w:function(g){return g.getDay()},W:function(g,I){return TI(fI.mondayOfYear(g),I,2)},x:c(A),X:c(i),y:function(g,I){return TI(g.getFullYear()%100,I,2)},Y:function(g,I){return TI(g.getFullYear()%1e4,I,4)},Z:eC,"%":function(){return"%"}},w={a:function(g,I,C){m.lastIndex=0;var A=m.exec(I.slice(C));return A?(g.w=h.get(A[0].toLowerCase()),C+A[0].length):-1},A:function(g,I,C){n.lastIndex=0;var A=n.exec(I.slice(C));return A?(g.w=r.get(A[0].toLowerCase()),C+A[0].length):-1},b:function(g,I,C){G.lastIndex=0;var A=G.exec(I.slice(C));return A?(g.m=u.get(A[0].toLowerCase()),C+A[0].length):-1},B:function(g,I,C){Z.lastIndex=0;var A=Z.exec(I.slice(C));return A?(g.m=b.get(A[0].toLowerCase()),C+A[0].length):-1},c:function(g,I,C){return d(g,p.c.toString(),I,C)},d:$I,e:$I,H:IC,I:IC,j:gC,L:iC,m:qI,M:CC,p:function(g,I,C){var A=a.get(I.slice(C,C+=2).toLowerCase());return null==A?-1:(g.p=A,C)},S:AC,U:QI,w:jI,W:OI,x:function(g,I,C){return d(g,p.x.toString(),I,C)},X:function(g,I,C){return d(g,p.X.toString(),I,C)},y:PI,Y:EI,Z:_I,"%":tC};return c}fI.year=JI((function(g){return(g=fI.day(g)).setMonth(0,1),g}),(function(g,I){g.setFullYear(g.getFullYear()+I)}),(function(g){return g.getFullYear()})),fI.years=fI.year.range,fI.years.utc=fI.year.utc.range,fI.day=JI((function(g){var I=new FI(2e3,0);return I.setFullYear(g.getFullYear(),g.getMonth(),g.getDate()),I}),(function(g,I){g.setDate(g.getDate()+I)}),(function(g){return g.getDate()-1})),fI.days=fI.day.range,fI.days.utc=fI.day.utc.range,fI.dayOfYear=function(g){var I=fI.year(g);return Math.floor((g-I-6e4*(g.getTimezoneOffset()-I.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(g,I){I=7-I;var C=fI[g]=JI((function(g){return(g=fI.day(g)).setDate(g.getDate()-(g.getDay()+I)%7),g}),(function(g,I){g.setDate(g.getDate()+7*Math.floor(I))}),(function(g){var C=fI.year(g).getDay();return Math.floor((fI.dayOfYear(g)+(C+I)%7)/7)-(C!==I)}));fI[g+"s"]=C.range,fI[g+"s"].utc=C.utc.range,fI[g+"OfYear"]=function(g){var C=fI.year(g).getDay();return Math.floor((fI.dayOfYear(g)+(C+I)%7)/7)}})),fI.week=fI.sunday,fI.weeks=fI.sunday.range,fI.weeks.utc=fI.sunday.utc.range,fI.weekOfYear=fI.sundayOfYear;var vI={"-":"",_:" ",0:"0"},LI=/^\s*\d+/,zI=/^%/;function TI(g,I,C){var A=g<0?"-":"",i=(A?-g:g)+"",e=i.length;return A+(e68?1900:2e3),C+i[0].length):-1}function _I(g,I,C){return/^[+-]\d{4}$/.test(I=I.slice(C,C+5))?(g.Z=-I,C+5):-1}function qI(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+2));return A?(g.m=A[0]-1,C+A[0].length):-1}function $I(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+2));return A?(g.d=+A[0],C+A[0].length):-1}function gC(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+3));return A?(g.j=+A[0],C+A[0].length):-1}function IC(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+2));return A?(g.H=+A[0],C+A[0].length):-1}function CC(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+2));return A?(g.M=+A[0],C+A[0].length):-1}function AC(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+2));return A?(g.S=+A[0],C+A[0].length):-1}function iC(g,I,C){LI.lastIndex=0;var A=LI.exec(I.slice(C,C+3));return A?(g.L=+A[0],C+A[0].length):-1}function eC(g){var I=g.getTimezoneOffset(),C=I>0?"-":"+",A=Z(I)/60|0,i=Z(I)%60;return C+TI(A,"0",2)+TI(i,"0",2)}function tC(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+1));return A?C+A[0].length:-1}function lC(g){for(var I=g.length,C=-1;++C=0?1:-1,l=t*e,s=Math.cos(I),o=Math.sin(I),c=i*o,d=A*s+c*Math.cos(l),a=c*t*Math.sin(l);RC.add(Math.atan2(a,d)),C=g,A=s,i=o}NC.point=function(t,l){NC.point=e,C=(g=t)*Yg,A=Math.cos(l=(I=l)*Yg/2+Bg/4),i=Math.sin(l)},NC.lineEnd=function(){e(g,I)}}function KC(g){var I=g[0],C=g[1],A=Math.cos(C);return[A*Math.cos(I),A*Math.sin(I),Math.sin(C)]}function fC(g,I){return g[0]*I[0]+g[1]*I[1]+g[2]*I[2]}function FC(g,I){return[g[1]*I[2]-g[2]*I[1],g[2]*I[0]-g[0]*I[2],g[0]*I[1]-g[1]*I[0]]}function MC(g,I){g[0]+=I[0],g[1]+=I[1],g[2]+=I[2]}function SC(g,I){return[g[0]*I,g[1]*I,g[2]*I]}function JC(g){var I=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);g[0]/=I,g[1]/=I,g[2]/=I}function kC(g){return[Math.atan2(g[1],g[0]),fg(g[2])]}function DC(g,I){return Z(g[0]-I[0])wg?i=90:o<-wg&&(C=-90),d[0]=I,d[1]=A}};function n(g,e){c.push(d=[I=g,A=g]),ei&&(i=e)}function r(g,t){var l=KC([g*Yg,t*Yg]);if(s){var o=FC(s,l),c=FC([o[1],-o[0],0],o);JC(c),c=kC(c);var d=g-e,a=d>0?1:-1,r=c[0]*Rg*a,m=Z(d)>180;if(m^(a*ei&&(i=h);else if(m^(a*e<(r=(r+360)%360-180)&&ri&&(i=t);m?gp(I,A)&&(A=g):p(g,A)>p(I,A)&&(I=g):A>=I?(gA&&(A=g)):g>e?p(I,g)>p(I,A)&&(A=g):p(g,A)>p(I,A)&&(I=g)}else n(g,t);s=l,e=g}function m(){a.point=r}function h(){d[0]=I,d[1]=A,a.point=n,s=null}function b(g,I){if(s){var C=g-e;o+=Z(C)>180?C+(C>0?360:-360):C}else t=g,l=I;NC.point(g,I),r(g,I)}function G(){NC.lineStart()}function u(){b(t,l),NC.lineEnd(),Z(o)>wg&&(I=-(A=180)),d[0]=I,d[1]=A,s=null}function p(g,I){return(I-=g)<0?I+360:I}function w(g,I){return g[0]-I[0]}function W(g,I){return I[0]<=I[1]?I[0]<=g&&g<=I[1]:gp(m[0],m[1])&&(m[1]=n[1]),p(n[0],m[1])>p(m[0],m[1])&&(m[0]=n[0])):l.push(m=n);for(var s,o,n,r=-1/0,m=(t=0,l[o=l.length-1]);t<=o;m=n,++t)n=l[t],(s=p(m[1],n[0]))>r&&(r=s,I=n[0],A=m[1])}return c=d=null,I===1/0||C===1/0?[[NaN,NaN],[NaN,NaN]]:[[I,C],[A,i]]}}(),g.geo.centroid=function(I){bC=GC=uC=pC=wC=WC=BC=yC=VC=XC=YC=0,g.geo.stream(I,vC);var C=VC,A=XC,i=YC,e=C*C+A*A+i*i;return e=0;--l)i.point((d=c[l])[0],d[1]);else A(n.x,n.p.x,-1,i);n=n.p}c=(n=n.o).z,r=!r}while(!n.v);i.lineEnd()}}}function EC(g){if(I=g.length){for(var I,C,A=0,i=g[0];++A=0?1:-1,W=w*p,B=W>Bg,y=r*G;if(RC.add(Math.atan2(y*w*Math.sin(W),m*u+y*Math.cos(W))),e+=B?p+w*yg:p,B^a>=C^Z>=C){var V=FC(KC(d),KC(g));JC(V);var X=FC(i,V);JC(X);var Y=(B^p>=0?-1:1)*fg(X[2]);(A>Y||A===Y&&(V[0]||V[1]))&&(t+=B^p>=0?1:-1)}if(!h++)break;a=Z,r=G,m=u,d=g}}return(e<-wg||e0){for(G||(t.polygonStart(),G=!0),t.lineStart();++e1&&2&I&&C.push(C.pop().concat(C.shift())),l.push(C.filter(qC))}return c}}function qC(g){return g.length>1}function $C(){var g,I=[];return{lineStart:function(){I.push(g=[])},point:function(I,C){g.push([I,C])},lineEnd:F,buffer:function(){var C=I;return I=[],g=null,C},rejoin:function(){I.length>1&&I.push(I.pop().concat(I.shift()))}}}function gA(g,I){return((g=g.x)[0]<0?g[1]-Xg-wg:Xg-g[1])-((I=I.x)[0]<0?I[1]-Xg-wg:Xg-I[1])}var IA=_C(QC,(function(g){var I,C=NaN,A=NaN,i=NaN;return{lineStart:function(){g.lineStart(),I=1},point:function(e,t){var l=e>0?Bg:-Bg,s=Z(e-C);Z(s-Bg)0?Xg:-Xg),g.point(i,A),g.lineEnd(),g.lineStart(),g.point(l,A),g.point(e,A),I=0):i!==l&&s>=Bg&&(Z(C-i)wg?Math.atan((Math.sin(I)*(e=Math.cos(A))*Math.sin(C)-Math.sin(A)*(i=Math.cos(I))*Math.sin(g))/(i*e*t)):(I+A)/2}(C,A,e,t),g.point(i,A),g.lineEnd(),g.lineStart(),g.point(l,A),I=0),g.point(C=e,A=t),i=l},lineEnd:function(){g.lineEnd(),C=A=NaN},clean:function(){return 2-I}}}),(function(g,I,C,A){var i;if(null==g)i=C*Xg,A.point(-Bg,i),A.point(0,i),A.point(Bg,i),A.point(Bg,0),A.point(Bg,-i),A.point(0,-i),A.point(-Bg,-i),A.point(-Bg,0),A.point(-Bg,i);else if(Z(g[0]-I[0])>wg){var e=g[0]0)){if(e/=a,a<0){if(e0){if(e>d)return;e>c&&(c=e)}if(e=C-s,a||!(e<0)){if(e/=a,a<0){if(e>d)return;e>c&&(c=e)}else if(a>0){if(e0)){if(e/=n,n<0){if(e0){if(e>d)return;e>c&&(c=e)}if(e=A-o,n||!(e<0)){if(e/=n,n<0){if(e>d)return;e>c&&(c=e)}else if(n>0){if(e0&&(i.a={x:s+c*a,y:o+c*n}),d<1&&(i.b={x:s+d*a,y:o+d*n}),i}}}}}}var AA=1e9;function iA(I,C,A,i){return function(s){var o,c,d,a,n,r,m,h,Z,b,G,u=s,p=$C(),w=CA(I,C,A,i),W={point:V,lineStart:function(){W.point=X,c&&c.push(d=[]);b=!0,Z=!1,m=h=NaN},lineEnd:function(){o&&(X(a,n),r&&Z&&p.rejoin(),o.push(p.buffer()));W.point=V,Z&&s.lineEnd()},polygonStart:function(){s=p,o=[],c=[],G=!0},polygonEnd:function(){s=u,o=g.merge(o);var C=function(g){for(var I=0,C=c.length,A=g[1],i=0;iA&&Hg(o,e,g)>0&&++I:e[1]<=A&&Hg(o,e,g)<0&&--I,o=e;return 0!==I}([I,i]),A=G&&C,e=o.length;(A||e)&&(s.polygonStart(),A&&(s.lineStart(),B(null,null,1,s),s.lineEnd()),e&&OC(o,t,C,B,s),s.polygonEnd()),o=c=d=null}};function B(g,t,s,o){var c=0,d=0;if(null==g||(c=e(g,s))!==(d=e(t,s))||l(g,t)<0^s>0)do{o.point(0===c||3===c?I:A,c>1?i:C)}while((c=(c+s+4)%4)!==d);else o.point(t[0],t[1])}function y(g,e){return I<=g&&g<=A&&C<=e&&e<=i}function V(g,I){y(g,I)&&s.point(g,I)}function X(g,I){var C=y(g=Math.max(-AA,Math.min(AA,g)),I=Math.max(-AA,Math.min(AA,I)));if(c&&d.push([g,I]),b)a=g,n=I,r=C,b=!1,C&&(s.lineStart(),s.point(g,I));else if(C&&Z)s.point(g,I);else{var A={a:{x:m,y:h},b:{x:g,y:I}};w(A)?(Z||(s.lineStart(),s.point(A.a.x,A.a.y)),s.point(A.b.x,A.b.y),C||s.lineEnd(),G=!1):C&&(s.lineStart(),s.point(g,I),G=!1)}m=g,h=I,Z=C}return W};function e(g,i){return Z(g[0]-I)0?0:3:Z(g[0]-A)0?2:1:Z(g[1]-C)0?1:0:i>0?3:2}function t(g,I){return l(g.x,I.x)}function l(g,I){var C=e(g,1),A=e(I,1);return C!==A?C-A:0===C?I[1]-g[1]:1===C?g[0]-I[0]:2===C?g[1]-I[1]:I[0]-g[0]}}function eA(g){var I=0,C=Bg/3,A=RA(g),i=A(I,C);return i.parallels=function(g){return arguments.length?A(I=g[0]*Bg/180,C=g[1]*Bg/180):[I/Bg*180,C/Bg*180]},i}function tA(g,I){var C=Math.sin(g),A=(C+Math.sin(I))/2,i=1+C*(2*A-C),e=Math.sqrt(i)/A;function t(g,I){var C=Math.sqrt(i-2*A*Math.sin(I))/A;return[C*Math.sin(g*=A),e-C*Math.cos(g)]}return t.invert=function(g,I){var C=e-I;return[Math.atan2(g,C)/A,fg((i-(g*g+C*C)*A*A)/(2*A))]},t}g.geo.clipExtent=function(){var g,I,C,A,i,e,t={stream:function(g){return i&&(i.valid=!1),(i=e(g)).valid=!0,i},extent:function(l){return arguments.length?(e=iA(g=+l[0][0],I=+l[0][1],C=+l[1][0],A=+l[1][1]),i&&(i.valid=!1,i=null),t):[[g,I],[C,A]]}};return t.extent([[0,0],[960,500]])},(g.geo.conicEqualArea=function(){return eA(tA)}).raw=tA,g.geo.albers=function(){return g.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},g.geo.albersUsa=function(){var I,C,A,i,e=g.geo.albers(),t=g.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=g.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(g,C){I=[g,C]}};function o(g){var e=g[0],t=g[1];return I=null,C(e,t),I||(A(e,t),I)||i(e,t),I}return o.invert=function(g){var I=e.scale(),C=e.translate(),A=(g[0]-C[0])/I,i=(g[1]-C[1])/I;return(i>=.12&&i<.234&&A>=-.425&&A<-.214?t:i>=.166&&i<.234&&A>=-.214&&A<-.115?l:e).invert(g)},o.stream=function(g){var I=e.stream(g),C=t.stream(g),A=l.stream(g);return{point:function(g,i){I.point(g,i),C.point(g,i),A.point(g,i)},sphere:function(){I.sphere(),C.sphere(),A.sphere()},lineStart:function(){I.lineStart(),C.lineStart(),A.lineStart()},lineEnd:function(){I.lineEnd(),C.lineEnd(),A.lineEnd()},polygonStart:function(){I.polygonStart(),C.polygonStart(),A.polygonStart()},polygonEnd:function(){I.polygonEnd(),C.polygonEnd(),A.polygonEnd()}}},o.precision=function(g){return arguments.length?(e.precision(g),t.precision(g),l.precision(g),o):e.precision()},o.scale=function(g){return arguments.length?(e.scale(g),t.scale(.35*g),l.scale(g),o.translate(e.translate())):e.scale()},o.translate=function(g){if(!arguments.length)return e.translate();var I=e.scale(),c=+g[0],d=+g[1];return C=e.translate(g).clipExtent([[c-.455*I,d-.238*I],[c+.455*I,d+.238*I]]).stream(s).point,A=t.translate([c-.307*I,d+.201*I]).clipExtent([[c-.425*I+wg,d+.12*I+wg],[c-.214*I-wg,d+.234*I-wg]]).stream(s).point,i=l.translate([c-.205*I,d+.212*I]).clipExtent([[c-.214*I+wg,d+.166*I+wg],[c-.115*I-wg,d+.234*I-wg]]).stream(s).point,o},o.scale(1070)};var lA,sA,oA,cA,dA,aA,nA={point:F,lineStart:F,lineEnd:F,polygonStart:function(){sA=0,nA.lineStart=rA},polygonEnd:function(){nA.lineStart=nA.lineEnd=nA.point=F,lA+=Z(sA/2)}};function rA(){var g,I,C,A;function i(g,I){sA+=A*g-C*I,C=g,A=I}nA.point=function(e,t){nA.point=i,g=C=e,I=A=t},nA.lineEnd=function(){i(g,I)}}var mA={point:function(g,I){gdA&&(dA=g);IaA&&(aA=I)},lineStart:F,lineEnd:F,polygonStart:F,polygonEnd:F};function hA(){var g=ZA(4.5),I=[],C={point:A,lineStart:function(){C.point=i},lineEnd:t,polygonStart:function(){C.lineEnd=l},polygonEnd:function(){C.lineEnd=t,C.point=A},pointRadius:function(I){return g=ZA(I),C},result:function(){if(I.length){var g=I.join("");return I=[],g}}};function A(C,A){I.push("M",C,",",A,g)}function i(g,A){I.push("M",g,",",A),C.point=e}function e(g,C){I.push("L",g,",",C)}function t(){C.point=A}function l(){I.push("Z")}return C}function ZA(g){return"m0,"+g+"a"+g+","+g+" 0 1,1 0,"+-2*g+"a"+g+","+g+" 0 1,1 0,"+2*g+"z"}var bA,GA={point:uA,lineStart:pA,lineEnd:wA,polygonStart:function(){GA.lineStart=WA},polygonEnd:function(){GA.point=uA,GA.lineStart=pA,GA.lineEnd=wA}};function uA(g,I){uC+=g,pC+=I,++wC}function pA(){var g,I;function C(C,A){var i=C-g,e=A-I,t=Math.sqrt(i*i+e*e);WC+=t*(g+C)/2,BC+=t*(I+A)/2,yC+=t,uA(g=C,I=A)}GA.point=function(A,i){GA.point=C,uA(g=A,I=i)}}function wA(){GA.point=uA}function WA(){var g,I,C,A;function i(g,I){var i=g-C,e=I-A,t=Math.sqrt(i*i+e*e);WC+=t*(C+g)/2,BC+=t*(A+I)/2,yC+=t,VC+=(t=A*g-C*I)*(C+g),XC+=t*(A+I),YC+=3*t,uA(C=g,A=I)}GA.point=function(e,t){GA.point=i,uA(g=C=e,I=A=t)},GA.lineEnd=function(){i(g,I)}}function BA(g){var I=4.5,C={point:A,lineStart:function(){C.point=i},lineEnd:t,polygonStart:function(){C.lineEnd=l},polygonEnd:function(){C.lineEnd=t,C.point=A},pointRadius:function(g){return I=g,C},result:F};function A(C,A){g.moveTo(C+I,A),g.arc(C,A,I,0,yg)}function i(I,A){g.moveTo(I,A),C.point=e}function e(I,C){g.lineTo(I,C)}function t(){C.point=A}function l(){g.closePath()}return C}function yA(g){var I=.5,C=Math.cos(30*Yg),A=16;function i(g){return(A?t:e)(g)}function e(I){return XA(I,(function(C,A){C=g(C,A),I.point(C[0],C[1])}))}function t(I){var C,i,e,t,s,o,c,d,a,n,r,m,h={point:Z,lineStart:b,lineEnd:u,polygonStart:function(){I.polygonStart(),h.lineStart=p},polygonEnd:function(){I.polygonEnd(),h.lineStart=b}};function Z(C,A){C=g(C,A),I.point(C[0],C[1])}function b(){d=NaN,h.point=G,I.lineStart()}function G(C,i){var e=KC([C,i]),t=g(C,i);l(d,a,c,n,r,m,d=t[0],a=t[1],c=C,n=e[0],r=e[1],m=e[2],A,I),I.point(d,a)}function u(){h.point=Z,I.lineEnd()}function p(){b(),h.point=w,h.lineEnd=W}function w(g,I){G(C=g,I),i=d,e=a,t=n,s=r,o=m,h.point=G}function W(){l(d,a,c,n,r,m,i,e,C,t,s,o,A,I),h.lineEnd=u,u()}return h}function l(A,i,e,t,s,o,c,d,a,n,r,m,h,b){var G=c-A,u=d-i,p=G*G+u*u;if(p>4*I&&h--){var w=t+n,W=s+r,B=o+m,y=Math.sqrt(w*w+W*W+B*B),V=Math.asin(B/=y),X=Z(Z(B)-1)I||Z((G*H+u*K)/p-.5)>.3||t*n+s*r+o*m0&&16,i):Math.sqrt(I)},i}function VA(g){this.stream=g}function XA(g,I){return{point:I,sphere:function(){g.sphere()},lineStart:function(){g.lineStart()},lineEnd:function(){g.lineEnd()},polygonStart:function(){g.polygonStart()},polygonEnd:function(){g.polygonEnd()}}}function YA(g){return RA((function(){return g}))()}function RA(I){var C,A,i,e,t,l,s=yA((function(g,I){return[(g=C(g,I))[0]*o+e,t-g[1]*o]})),o=150,c=480,d=250,a=0,n=0,r=0,m=0,h=0,b=IA,G=N,u=null,p=null;function w(g){return[(g=i(g[0]*Yg,g[1]*Yg))[0]*o+e,t-g[1]*o]}function W(g){return(g=i.invert((g[0]-e)/o,(t-g[1])/o))&&[g[0]*Rg,g[1]*Rg]}function B(){i=jC(A=fA(r,m,h),C);var g=C(a,n);return e=c-g[0]*o,t=d+g[1]*o,y()}function y(){return l&&(l.valid=!1,l=null),w}return w.stream=function(g){return l&&(l.valid=!1),(l=NA(b(A,s(G(g))))).valid=!0,l},w.clipAngle=function(g){return arguments.length?(b=null==g?(u=g,IA):function(g){var I=Math.cos(g),C=I>0,A=Z(I)>wg;return _C(i,(function(g){var I,l,s,o,c;return{lineStart:function(){o=s=!1,c=1},point:function(d,a){var n,r=[d,a],m=i(d,a),h=C?m?0:t(d,a):m?t(d+(d<0?Bg:-Bg),a):0;if(!I&&(o=s=m)&&g.lineStart(),m!==s&&(n=e(I,r),(DC(I,n)||DC(r,n))&&(r[0]+=wg,r[1]+=wg,m=i(r[0],r[1]))),m!==s)c=0,m?(g.lineStart(),n=e(r,I),g.point(n[0],n[1])):(n=e(I,r),g.point(n[0],n[1]),g.lineEnd()),I=n;else if(A&&I&&C^m){var Z;h&l||!(Z=e(r,I,!0))||(c=0,C?(g.lineStart(),g.point(Z[0][0],Z[0][1]),g.point(Z[1][0],Z[1][1]),g.lineEnd()):(g.point(Z[1][0],Z[1][1]),g.lineEnd(),g.lineStart(),g.point(Z[0][0],Z[0][1])))}!m||I&&DC(I,r)||g.point(r[0],r[1]),I=r,s=m,l=h},lineEnd:function(){s&&g.lineEnd(),I=null},clean:function(){return c|(o&&s)<<1}}}),JA(g,6*Yg),C?[0,-g]:[-Bg,g-Bg]);function i(g,C){return Math.cos(g)*Math.cos(C)>I}function e(g,C,A){var i=[1,0,0],e=FC(KC(g),KC(C)),t=fC(e,e),l=e[0],s=t-l*l;if(!s)return!A&&g;var o=I*t/s,c=-I*l/s,d=FC(i,e),a=SC(i,o);MC(a,SC(e,c));var n=d,r=fC(a,n),m=fC(n,n),h=r*r-m*(fC(a,a)-1);if(!(h<0)){var b=Math.sqrt(h),G=SC(n,(-r-b)/m);if(MC(G,a),G=kC(G),!A)return G;var u,p=g[0],w=C[0],W=g[1],B=C[1];w0^G[1]<(Z(G[0]-p)Bg^(p<=G[0]&&G[0]<=w)){var X=SC(n,(-r+b)/m);return MC(X,a),[G,kC(X)]}}}function t(I,A){var i=C?g:Bg-g,e=0;return I<-i?e|=1:I>i&&(e|=2),A<-i?e|=4:A>i&&(e|=8),e}}((u=+g)*Yg),y()):u},w.clipExtent=function(g){return arguments.length?(p=g,G=g?iA(g[0][0],g[0][1],g[1][0],g[1][1]):N,y()):p},w.scale=function(g){return arguments.length?(o=+g,B()):o},w.translate=function(g){return arguments.length?(c=+g[0],d=+g[1],B()):[c,d]},w.center=function(g){return arguments.length?(a=g[0]%360*Yg,n=g[1]%360*Yg,B()):[a*Rg,n*Rg]},w.rotate=function(g){return arguments.length?(r=g[0]%360*Yg,m=g[1]%360*Yg,h=g.length>2?g[2]%360*Yg:0,B()):[r*Rg,m*Rg,h*Rg]},g.rebind(w,s,"precision"),function(){return C=I.apply(this,arguments),w.invert=C.invert&&W,B()}}function NA(g){return XA(g,(function(I,C){g.point(I*Yg,C*Yg)}))}function HA(g,I){return[g,I]}function KA(g,I){return[g>Bg?g-yg:g<-Bg?g+yg:g,I]}function fA(g,I,C){return g?I||C?jC(MA(g),SA(I,C)):MA(g):I||C?SA(I,C):KA}function FA(g){return function(I,C){return[(I+=g)>Bg?I-yg:I<-Bg?I+yg:I,C]}}function MA(g){var I=FA(g);return I.invert=FA(-g),I}function SA(g,I){var C=Math.cos(g),A=Math.sin(g),i=Math.cos(I),e=Math.sin(I);function t(g,I){var t=Math.cos(I),l=Math.cos(g)*t,s=Math.sin(g)*t,o=Math.sin(I),c=o*C+l*A;return[Math.atan2(s*i-c*e,l*C-o*A),fg(c*i+s*e)]}return t.invert=function(g,I){var t=Math.cos(I),l=Math.cos(g)*t,s=Math.sin(g)*t,o=Math.sin(I),c=o*i-s*e;return[Math.atan2(s*i+o*e,l*C+c*A),fg(c*C-l*A)]},t}function JA(g,I){var C=Math.cos(g),A=Math.sin(g);return function(i,e,t,l){var s=t*I;null!=i?(i=kA(C,i),e=kA(C,e),(t>0?ie)&&(i+=t*yg)):(i=g+t*yg,e=g-.5*s);for(var o,c=i;t>0?c>e:c2?g[2]*Yg:0),I.invert=function(I){return(I=g.invert(I[0]*Yg,I[1]*Yg))[0]*=Rg,I[1]*=Rg,I},I},KA.invert=HA,g.geo.circle=function(){var g,I,C=[0,0],A=6;function i(){var g="function"==typeof C?C.apply(this,arguments):C,A=fA(-g[0]*Yg,-g[1]*Yg,0).invert,i=[];return I(null,null,1,{point:function(g,I){i.push(g=A(g,I)),g[0]*=Rg,g[1]*=Rg}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(g){return arguments.length?(C=g,i):C},i.angle=function(C){return arguments.length?(I=JA((g=+C)*Yg,A*Yg),i):g},i.precision=function(C){return arguments.length?(I=JA(g*Yg,(A=+C)*Yg),i):A},i.angle(90)},g.geo.distance=function(g,I){var C,A=(I[0]-g[0])*Yg,i=g[1]*Yg,e=I[1]*Yg,t=Math.sin(A),l=Math.cos(A),s=Math.sin(i),o=Math.cos(i),c=Math.sin(e),d=Math.cos(e);return Math.atan2(Math.sqrt((C=d*t)*C+(C=o*c-s*d*l)*C),s*c+o*d*l)},g.geo.graticule=function(){var I,C,A,i,e,t,l,s,o,c,d,a,n=10,r=n,m=90,h=360,b=2.5;function G(){return{type:"MultiLineString",coordinates:u()}}function u(){return g.range(Math.ceil(i/m)*m,A,m).map(d).concat(g.range(Math.ceil(s/h)*h,l,h).map(a)).concat(g.range(Math.ceil(C/n)*n,I,n).filter((function(g){return Z(g%m)>wg})).map(o)).concat(g.range(Math.ceil(t/r)*r,e,r).filter((function(g){return Z(g%h)>wg})).map(c))}return G.lines=function(){return u().map((function(g){return{type:"LineString",coordinates:g}}))},G.outline=function(){return{type:"Polygon",coordinates:[d(i).concat(a(l).slice(1),d(A).reverse().slice(1),a(s).reverse().slice(1))]}},G.extent=function(g){return arguments.length?G.majorExtent(g).minorExtent(g):G.minorExtent()},G.majorExtent=function(g){return arguments.length?(i=+g[0][0],A=+g[1][0],s=+g[0][1],l=+g[1][1],i>A&&(g=i,i=A,A=g),s>l&&(g=s,s=l,l=g),G.precision(b)):[[i,s],[A,l]]},G.minorExtent=function(g){return arguments.length?(C=+g[0][0],I=+g[1][0],t=+g[0][1],e=+g[1][1],C>I&&(g=C,C=I,I=g),t>e&&(g=t,t=e,e=g),G.precision(b)):[[C,t],[I,e]]},G.step=function(g){return arguments.length?G.majorStep(g).minorStep(g):G.minorStep()},G.majorStep=function(g){return arguments.length?(m=+g[0],h=+g[1],G):[m,h]},G.minorStep=function(g){return arguments.length?(n=+g[0],r=+g[1],G):[n,r]},G.precision=function(g){return arguments.length?(b=+g,o=DA(t,e,90),c=vA(C,I,b),d=DA(s,l,90),a=vA(i,A,b),G):b},G.majorExtent([[-180,-90+wg],[180,90-wg]]).minorExtent([[-180,-80-wg],[180,80+wg]])},g.geo.greatArc=function(){var I,C,A=LA,i=zA;function e(){return{type:"LineString",coordinates:[I||A.apply(this,arguments),C||i.apply(this,arguments)]}}return e.distance=function(){return g.geo.distance(I||A.apply(this,arguments),C||i.apply(this,arguments))},e.source=function(g){return arguments.length?(A=g,I="function"==typeof g?null:g,e):A},e.target=function(g){return arguments.length?(i=g,C="function"==typeof g?null:g,e):i},e.precision=function(){return arguments.length?e:0},e},g.geo.interpolate=function(g,I){return C=g[0]*Yg,A=g[1]*Yg,i=I[0]*Yg,e=I[1]*Yg,t=Math.cos(A),l=Math.sin(A),s=Math.cos(e),o=Math.sin(e),c=t*Math.cos(C),d=t*Math.sin(C),a=s*Math.cos(i),n=s*Math.sin(i),r=2*Math.asin(Math.sqrt(Mg(e-A)+t*s*Mg(i-C))),m=1/Math.sin(r),(h=r?function(g){var I=Math.sin(g*=r)*m,C=Math.sin(r-g)*m,A=C*c+I*a,i=C*d+I*n,e=C*l+I*o;return[Math.atan2(i,A)*Rg,Math.atan2(e,Math.sqrt(A*A+i*i))*Rg]}:function(){return[C*Rg,A*Rg]}).distance=r,h;var C,A,i,e,t,l,s,o,c,d,a,n,r,m,h},g.geo.length=function(I){return bA=0,g.geo.stream(I,TA),bA};var TA={sphere:F,point:F,lineStart:function(){var g,I,C;function A(A,i){var e=Math.sin(i*=Yg),t=Math.cos(i),l=Z((A*=Yg)-g),s=Math.cos(l);bA+=Math.atan2(Math.sqrt((l=t*Math.sin(l))*l+(l=C*e-I*t*s)*l),I*e+C*t*s),g=A,I=e,C=t}TA.point=function(i,e){g=i*Yg,I=Math.sin(e*=Yg),C=Math.cos(e),TA.point=A},TA.lineEnd=function(){TA.point=TA.lineEnd=F}},lineEnd:F,polygonStart:F,polygonEnd:F};function xA(g,I){function C(I,C){var A=Math.cos(I),i=Math.cos(C),e=g(A*i);return[e*i*Math.sin(I),e*Math.sin(C)]}return C.invert=function(g,C){var A=Math.sqrt(g*g+C*C),i=I(A),e=Math.sin(i),t=Math.cos(i);return[Math.atan2(g*e,A*t),Math.asin(A&&C*e/A)]},C}var UA=xA((function(g){return Math.sqrt(2/(1+g))}),(function(g){return 2*Math.asin(g/2)}));(g.geo.azimuthalEqualArea=function(){return YA(UA)}).raw=UA;var jA=xA((function(g){var I=Math.acos(g);return I&&I/Math.sin(I)}),N);function QA(g,I){var C=Math.cos(g),A=function(g){return Math.tan(Bg/4+g/2)},i=g===I?Math.sin(g):Math.log(C/Math.cos(I))/Math.log(A(I)/A(g)),e=C*Math.pow(A(g),i)/i;if(!i)return PA;function t(g,I){e>0?I<-Xg+wg&&(I=-Xg+wg):I>Xg-wg&&(I=Xg-wg);var C=e/Math.pow(A(I),i);return[C*Math.sin(i*g),e-C*Math.cos(i*g)]}return t.invert=function(g,I){var C=e-I,A=Ng(i)*Math.sqrt(g*g+C*C);return[Math.atan2(g,C)/i,2*Math.atan(Math.pow(e/A,1/i))-Xg]},t}function OA(g,I){var C=Math.cos(g),A=g===I?Math.sin(g):(C-Math.cos(I))/(I-g),i=C/A+g;if(Z(A)1&&Hg(g[C[A-2]],g[C[A-1]],g[i])<=0;)--A;C[A++]=i}return C.slice(0,A)}function ii(g,I){return g[0]-I[0]||g[1]-I[1]}(g.geo.stereographic=function(){return YA($A)}).raw=$A,gi.invert=function(g,I){return[-I,2*Math.atan(Math.exp(g))-Xg]},(g.geo.transverseMercator=function(){var g=_A(gi),I=g.center,C=g.rotate;return g.center=function(g){return g?I([-g[1],g[0]]):[(g=I())[1],-g[0]]},g.rotate=function(g){return g?C([g[0],g[1],g.length>2?g[2]+90:90]):[(g=C())[0],g[1],g[2]-90]},C([0,0,90])}).raw=gi,g.geom={},g.geom.hull=function(g){var I=Ii,C=Ci;if(arguments.length)return A(g);function A(g){if(g.length<3)return[];var A,i=mI(I),e=mI(C),t=g.length,l=[],s=[];for(A=0;A=0;--A)n.push(g[l[o[A]][2]]);for(A=+d;Awg)l=l.L;else{if(!((i=e-wi(l,t))>wg)){A>-wg?(I=l.P,C=l):i>-wg?(I=l,C=l.N):I=C=l;break}if(!l.R){I=l;break}l=l.R}var s=Zi(g);if(di.insert(I,s),I||C){if(I===C)return Xi(I),C=Zi(I.site),di.insert(s,C),s.edge=C.edge=Ni(I.site,s.site),Vi(I),void Vi(C);if(C){Xi(I),Xi(C);var o=I.site,c=o.x,d=o.y,a=g.x-c,n=g.y-d,r=C.site,m=r.x-c,h=r.y-d,Z=2*(a*h-n*m),b=a*a+n*n,G=m*m+h*h,u={x:(h*b-n*G)/Z+c,y:(a*G-m*b)/Z+d};Ki(C.edge,o,r,u),s.edge=Ni(o,g,null,u),C.edge=Ni(g,r,null,u),Vi(I),Vi(C)}else s.edge=Ni(I.site,s.site)}}function pi(g,I){var C=g.site,A=C.x,i=C.y,e=i-I;if(!e)return A;var t=g.P;if(!t)return-1/0;var l=(C=t.site).x,s=C.y,o=s-I;if(!o)return l;var c=l-A,d=1/e-1/o,a=c/o;return d?(-a+Math.sqrt(a*a-2*d*(c*c/(-2*o)-s+o/2+i-e/2)))/d+A:(A+l)/2}function wi(g,I){var C=g.N;if(C)return pi(C,I);var A=g.site;return A.y===I?A.x:1/0}function Wi(g){this.site=g,this.edges=[]}function Bi(g,I){return I.angle-g.angle}function yi(){Mi(this),this.x=this.y=this.arc=this.site=this.cy=null}function Vi(g){var I=g.P,C=g.N;if(I&&C){var A=I.site,i=g.site,e=C.site;if(A!==e){var t=i.x,l=i.y,s=A.x-t,o=A.y-l,c=e.x-t,d=2*(s*(h=e.y-l)-o*c);if(!(d>=-Wg)){var a=s*s+o*o,n=c*c+h*h,r=(h*a-o*n)/d,m=(s*n-c*a)/d,h=m+l,Z=mi.pop()||new yi;Z.arc=g,Z.site=i,Z.x=r+t,Z.y=h+Math.sqrt(r*r+m*m),Z.cy=h,g.circle=Z;for(var b=null,G=ni._;G;)if(Z.y=l)return;if(a>r){if(e){if(e.y>=o)return}else e={x:h,y:s};C={x:h,y:o}}else{if(e){if(e.y1)if(a>r){if(e){if(e.y>=o)return}else e={x:(s-i)/A,y:s};C={x:(o-i)/A,y:o}}else{if(e){if(e.y=l)return}else e={x:t,y:A*t+i};C={x:l,y:A*l+i}}else{if(e){if(e.xwg||Z(i-C)>wg)&&(l.splice(t,0,new fi(Hi(e.site,c,Z(A-d)wg?{x:d,y:Z(I-d)wg?{x:Z(C-r)wg?{x:a,y:Z(I-a)wg?{x:Z(C-n)=C&&o.x<=i&&o.y>=A&&o.y<=t?[[C,t],[i,t],[i,A],[C,A]]:[]).point=g[l]})),I}function l(g){return g.map((function(g,I){return{x:Math.round(A(g,I)/wg)*wg,y:Math.round(i(g,I)/wg)*wg,i:I}}))}return t.links=function(g){return Di(l(g)).edges.filter((function(g){return g.l&&g.r})).map((function(I){return{source:g[I.l.i],target:g[I.r.i]}}))},t.triangles=function(g){var I=[];return Di(l(g)).cells.forEach((function(C,A){for(var i,e,t,l,s=C.site,o=C.edges.sort(Bi),c=-1,d=o.length,a=o[d-1].edge,n=a.l===s?a.r:a.l;++ce&&(i=I.slice(e,i),l[t]?l[t]+=i:l[++t]=i),(C=C[0])===(A=A[0])?l[t]?l[t]+=A:l[++t]=A:(l[++t]=null,s.push({i:t,x:Qi(C,A)})),e=Pi.lastIndex;return em&&(m=s.x),s.y>h&&(h=s.y),o.push(s.x),c.push(s.y);else for(d=0;dm&&(m=u),p>h&&(h=p),o.push(u),c.push(p)}var w=m-n,W=h-r;function B(g,I,C,A,i,e,t,l){if(!isNaN(C)&&!isNaN(A))if(g.leaf){var s=g.x,o=g.y;if(null!=s)if(Z(s-C)+Z(o-A)<.01)y(g,I,C,A,i,e,t,l);else{var c=g.point;g.x=g.y=g.point=null,y(g,c,s,o,i,e,t,l),y(g,I,C,A,i,e,t,l)}else g.x=C,g.y=A,g.point=I}else y(g,I,C,A,i,e,t,l)}function y(g,I,C,A,i,e,t,l){var s=.5*(i+t),o=.5*(e+l),c=C>=s,d=A>=o,a=d<<1|c;g.leaf=!1,c?i=s:t=s,d?e=o:l=o,B(g=g.nodes[a]||(g.nodes[a]={leaf:!0,nodes:[],point:null,x:null,y:null}),I,C,A,i,e,t,l)}w>W?h=r+w:m=n+W;var V={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(g){B(V,g,+b(g,++d),+G(g,d),n,r,m,h)}};if(V.visit=function(g){xi(g,V,n,r,m,h)},V.find=function(g){return function(g,I,C,A,i,e,t){var l,s=1/0;return function g(o,c,d,a,n){if(!(c>e||d>t||a=p)<<1|I>=u,W=w+4;w=0&&!(A=g.interpolators[i](I,C)););return A}function qi(g,I){var C,A=[],i=[],e=g.length,t=I.length,l=Math.min(g.length,I.length);for(C=0;C=1)return 1;var I=g*g,C=I*g;return 4*(g<.5?C:3*(g-I)+C-.75)}function le(g){return 1-Math.cos(g*Xg)}function se(g){return Math.pow(2,10*(g-1))}function oe(g){return 1-Math.sqrt(1-g*g)}function ce(g){return g<1/2.75?7.5625*g*g:g<2/2.75?7.5625*(g-=1.5/2.75)*g+.75:g<2.5/2.75?7.5625*(g-=2.25/2.75)*g+.9375:7.5625*(g-=2.625/2.75)*g+.984375}function de(g,I){return I-=g,function(C){return Math.round(g+I*C)}}function ae(g){var I,C,A,i=[g.a,g.b],e=[g.c,g.d],t=re(i),l=ne(i,e),s=re(((I=e)[0]+=(A=-l)*(C=i)[0],I[1]+=A*C[1],I))||0;i[0]*e[1]=0?g.slice(0,A):g,e=A>=0?g.slice(A+1):"in";return i=ge.get(i)||$i,e=Ie.get(e)||N,C=e(i.apply(null,I.call(arguments,1))),function(g){return g<=0?0:g>=1?1:C(g)}},g.interpolateHcl=function(I,C){I=g.hcl(I),C=g.hcl(C);var A=I.h,i=I.c,e=I.l,t=C.h-A,l=C.c-i,s=C.l-e;isNaN(l)&&(l=0,i=isNaN(i)?C.c:i);isNaN(t)?(t=0,A=isNaN(A)?C.h:A):t>180?t-=360:t<-180&&(t+=360);return function(g){return jg(A+t*g,i+l*g,e+s*g)+""}},g.interpolateHsl=function(I,C){I=g.hsl(I),C=g.hsl(C);var A=I.h,i=I.s,e=I.l,t=C.h-A,l=C.s-i,s=C.l-e;isNaN(l)&&(l=0,i=isNaN(i)?C.s:i);isNaN(t)?(t=0,A=isNaN(A)?C.h:A):t>180?t-=360:t<-180&&(t+=360);return function(g){return Tg(A+t*g,i+l*g,e+s*g)+""}},g.interpolateLab=function(I,C){I=g.lab(I),C=g.lab(C);var A=I.l,i=I.a,e=I.b,t=C.l-A,l=C.a-i,s=C.b-e;return function(g){return $g(A+t*g,i+l*g,e+s*g)+""}},g.interpolateRound=de,g.transform=function(I){var C=A.createElementNS(g.ns.prefix.svg,"g");return(g.transform=function(g){if(null!=g){C.setAttribute("transform",g);var I=C.transform.baseVal.consolidate()}return new ae(I?I.matrix:me)})(I)},ae.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var me={a:1,b:0,c:0,d:1,e:0,f:0};function he(g){return g.length?g.pop()+",":""}function Ze(I,C){var A=[],i=[];return I=g.transform(I),C=g.transform(C),function(g,I,C,A){if(g[0]!==I[0]||g[1]!==I[1]){var i=C.push("translate(",null,",",null,")");A.push({i:i-4,x:Qi(g[0],I[0])},{i:i-2,x:Qi(g[1],I[1])})}else(I[0]||I[1])&&C.push("translate("+I+")")}(I.translate,C.translate,A,i),function(g,I,C,A){g!==I?(g-I>180?I+=360:I-g>180&&(g+=360),A.push({i:C.push(he(C)+"rotate(",null,")")-2,x:Qi(g,I)})):I&&C.push(he(C)+"rotate("+I+")")}(I.rotate,C.rotate,A,i),function(g,I,C,A){g!==I?A.push({i:C.push(he(C)+"skewX(",null,")")-2,x:Qi(g,I)}):I&&C.push(he(C)+"skewX("+I+")")}(I.skew,C.skew,A,i),function(g,I,C,A){if(g[0]!==I[0]||g[1]!==I[1]){var i=C.push(he(C)+"scale(",null,",",null,")");A.push({i:i-4,x:Qi(g[0],I[0])},{i:i-2,x:Qi(g[1],I[1])})}else 1===I[0]&&1===I[1]||C.push(he(C)+"scale("+I+")")}(I.scale,C.scale,A,i),I=C=null,function(g){for(var I,C=-1,e=i.length;++C0?A=g:(I.c=null,I.t=NaN,I=null,s.start({type:"end",alpha:A=0})):g>0&&(s.start({type:"start",alpha:A=g}),I=WI(l.tick)),l):A},l.start=function(){var g,I,C,A=Z.length,s=b.length,c=o[0],r=o[1];for(g=0;g=0;)C.push(i[A])}function Ke(g,I){for(var C=[g],A=[];null!=(g=C.pop());)if(A.push(g),(e=g.children)&&(i=e.length))for(var i,e,t=-1;++t=0;)t.push(c=o[s]),c.parent=e,c.depth=e.depth+1;C&&(e.value=0),e.children=o}else C&&(e.value=+C.call(A,e,e.depth)||0),delete e.children;return Ke(i,(function(I){var A,i;g&&(A=I.children)&&A.sort(g),C&&(i=I.parent)&&(i.value+=I.value)})),l}return A.sort=function(I){return arguments.length?(g=I,A):g},A.children=function(g){return arguments.length?(I=g,A):I},A.value=function(g){return arguments.length?(C=g,A):C},A.revalue=function(g){return C&&(He(g,(function(g){g.children&&(g.value=0)})),Ke(g,(function(g){var I;g.children||(g.value=+C.call(A,g,g.depth)||0),(I=g.parent)&&(I.value+=g.value)}))),g},A},g.layout.partition=function(){var I=g.layout.hierarchy(),C=[1,1];function A(g,I,C,i){var e=g.children;if(g.x=I,g.y=g.depth*i,g.dx=C,g.dy=i,e&&(t=e.length)){var t,l,s,o=-1;for(C=g.value?C/g.value:0;++ol&&(l=A),t.push(A)}for(C=0;Ci&&(A=C,i=I);return A}function je(g){return g.reduce(Qe,0)}function Qe(g,I){return g+I[1]}function Oe(g,I){return Ee(g,Math.ceil(Math.log(I.length)/Math.LN2+1))}function Ee(g,I){for(var C=-1,A=+g[0],i=(g[1]-A)/I,e=[];++C<=I;)e[C]=i*C+A;return e}function Pe(I){return[g.min(I),g.max(I)]}function _e(g,I){return g.value-I.value}function qe(g,I){var C=g._pack_next;g._pack_next=I,I._pack_prev=g,I._pack_next=C,C._pack_prev=I}function $e(g,I){g._pack_next=I,I._pack_prev=g}function gt(g,I){var C=I.x-g.x,A=I.y-g.y,i=g.r+I.r;return.999*i*i>C*C+A*A}function It(g){if((I=g.children)&&(s=I.length)){var I,C,A,i,e,t,l,s,o=1/0,c=-1/0,d=1/0,a=-1/0;if(I.forEach(Ct),(C=I[0]).x=-C.r,C.y=0,G(C),s>1&&((A=I[1]).x=A.r,A.y=0,G(A),s>2))for(et(C,A,i=I[2]),G(i),qe(C,i),C._pack_prev=i,qe(i,A),A=C._pack_next,e=3;e0)for(t=-1;++t=d[0]&&s<=d[1]&&((l=o[g.bisect(a,s,1,r)-1]).y+=m,l.push(e[t]));return o}return e.value=function(g){return arguments.length?(C=g,e):C},e.range=function(g){return arguments.length?(A=mI(g),e):A},e.bins=function(g){return arguments.length?(i="number"==typeof g?function(I){return Ee(I,g)}:mI(g),e):i},e.frequency=function(g){return arguments.length?(I=!!g,e):I},e},g.layout.pack=function(){var I,C=g.layout.hierarchy().sort(_e),A=0,i=[1,1];function e(g,e){var t=C.call(this,g,e),l=t[0],s=i[0],o=i[1],c=null==I?Math.sqrt:"function"==typeof I?I:function(){return I};if(l.x=l.y=0,Ke(l,(function(g){g.r=+c(g.value)})),Ke(l,It),A){var d=A*(I?1:Math.max(2*l.r/s,2*l.r/o))/2;Ke(l,(function(g){g.r+=d})),Ke(l,It),Ke(l,(function(g){g.r-=d}))}return it(l,s/2,o/2,I?1:1/Math.max(2*l.r/s,2*l.r/o)),t}return e.size=function(g){return arguments.length?(i=g,e):i},e.radius=function(g){return arguments.length?(I=null==g||"function"==typeof g?g:+g,e):I},e.padding=function(g){return arguments.length?(A=+g,e):A},Ne(e,C)},g.layout.tree=function(){var I=g.layout.hierarchy().sort(null).value(null),C=tt,A=[1,1],i=null;function e(g,e){var o=I.call(this,g,e),c=o[0],d=function(g){var I,C={A:null,children:[g]},A=[C];for(;null!=(I=A.pop());)for(var i,e=I.children,t=0,l=e.length;tn.x&&(n=g),g.depth>r.depth&&(r=g)}));var m=C(a,n)/2-a.x,h=A[0]/(n.x+C(n,a)/2+m),Z=A[1]/(r.depth||1);He(c,(function(g){g.x=(g.x+m)*h,g.y=g.depth*Z}))}return o}function t(g){var I=g.children,A=g.parent.children,i=g.i?A[g.i-1]:null;if(I.length){!function(g){var I,C=0,A=0,i=g.children,e=i.length;for(;--e>=0;)(I=i[e]).z+=C,I.m+=C,C+=I.s+(A+=I.c)}(g);var e=(I[0].z+I[I.length-1].z)/2;i?(g.z=i.z+C(g._,i._),g.m=g.z-e):g.z=e}else i&&(g.z=i.z+C(g._,i._));g.parent.A=function(g,I,A){if(I){for(var i,e=g,t=g,l=I,s=e.parent.children[0],o=e.m,c=t.m,d=l.m,a=s.m;l=st(l),e=lt(e),l&&e;)s=lt(s),(t=st(t)).a=g,(i=l.z+d-e.z-o+C(l._,e._))>0&&(ot(ct(l,g,A),g,i),o+=i,c+=i),d+=l.m,o+=e.m,a+=s.m,c+=t.m;l&&!st(t)&&(t.t=l,t.m+=d-c),e&&!lt(s)&&(s.t=e,s.m+=o-a,A=g)}return A}(g,i,g.parent.A||A[0])}function l(g){g._.x=g.z+g.parent.m,g.m+=g.parent.m}function s(g){g.x*=A[0],g.y=g.depth*A[1]}return e.separation=function(g){return arguments.length?(C=g,e):C},e.size=function(g){return arguments.length?(i=null==(A=g)?s:null,e):i?null:A},e.nodeSize=function(g){return arguments.length?(i=null==(A=g)?null:s,e):i?A:null},Ne(e,I)},g.layout.cluster=function(){var I=g.layout.hierarchy().sort(null).value(null),C=tt,A=[1,1],i=!1;function e(e,t){var l,s=I.call(this,e,t),o=s[0],c=0;Ke(o,(function(I){var A=I.children;A&&A.length?(I.x=function(g){return g.reduce((function(g,I){return g+I.x}),0)/g.length}(A),I.y=function(I){return 1+g.max(I,(function(g){return g.y}))}(A)):(I.x=l?c+=C(I,l):0,I.y=0,l=I)}));var d=dt(o),a=at(o),n=d.x-C(d,a)/2,r=a.x+C(a,d)/2;return Ke(o,i?function(g){g.x=(g.x-o.x)*A[0],g.y=(o.y-g.y)*A[1]}:function(g){g.x=(g.x-n)/(r-n)*A[0],g.y=(1-(o.y?g.y/o.y:1))*A[1]}),s}return e.separation=function(g){return arguments.length?(C=g,e):C},e.size=function(g){return arguments.length?(i=null==(A=g),e):i?null:A},e.nodeSize=function(g){return arguments.length?(i=null!=(A=g),e):i?A:null},Ne(e,I)},g.layout.treemap=function(){var I,C=g.layout.hierarchy(),A=Math.round,i=[1,1],e=null,t=nt,l=!1,s="squarify",o=.5*(1+Math.sqrt(5));function c(g,I){for(var C,A,i=-1,e=g.length;++i0;)l.push(C=o[i-1]),l.area+=C.area,"squarify"!==s||(A=n(l,m))<=a?(o.pop(),a=A):(l.area-=l.pop().area,r(l,m,e,!1),m=Math.min(e.dx,e.dy),l.length=l.area=0,a=1/0);l.length&&(r(l,m,e,!0),l.length=l.area=0),I.forEach(d)}}function a(g){var I=g.children;if(I&&I.length){var C,A=t(g),i=I.slice(),e=[];for(c(i,A.dx*A.dy/g.value),e.area=0;C=i.pop();)e.push(C),e.area+=C.area,null!=C.z&&(r(e,C.z?A.dx:A.dy,A,!i.length),e.length=e.area=0);I.forEach(a)}}function n(g,I){for(var C,A=g.area,i=0,e=1/0,t=-1,l=g.length;++ti&&(i=C));return I*=I,(A*=A)?Math.max(I*i*o/A,A/(I*e*o)):1/0}function r(g,I,C,i){var e,t=-1,l=g.length,s=C.x,o=C.y,c=I?A(g.area/I):0;if(I==C.dx){for((i||c>C.dy)&&(c=C.dy);++tC.dx)&&(c=C.dx);++t1);return g+I*C*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var I=g.random.normal.apply(g,arguments);return function(){return Math.exp(I())}},bates:function(I){var C=g.random.irwinHall(I);return function(){return C()/I}},irwinHall:function(g){return function(){for(var I=0,C=0;C2?ut:Zt,s=A?Ge:be;return i=t(g,I,s,C),e=t(I,g,s,_i),l}function l(g){return i(g)}return l.invert=function(g){return e(g)},l.domain=function(I){return arguments.length?(g=I.map(Number),t()):g},l.range=function(g){return arguments.length?(I=g,t()):I},l.rangeRound=function(g){return l.range(g).interpolate(de)},l.clamp=function(g){return arguments.length?(A=g,t()):A},l.interpolate=function(g){return arguments.length?(C=g,t()):C},l.ticks=function(I){return yt(g,I)},l.tickFormat=function(I,C){return Vt(g,I,C)},l.nice=function(I){return Wt(g,I),t()},l.copy=function(){return pt(g,I,C,A)},t()}function wt(I,C){return g.rebind(I,C,"range","rangeRound","interpolate","clamp")}function Wt(g,I){return bt(g,(C=Bt(g,I)[2])?{floor:function(g){return Math.floor(g/C)*C},ceil:function(g){return Math.ceil(g/C)*C}}:Gt);var C}function Bt(g,I){null==I&&(I=10);var C=mt(g),A=C[1]-C[0],i=Math.pow(10,Math.floor(Math.log(A/I)/Math.LN10)),e=I/A*i;return e<=.15?i*=10:e<=.35?i*=5:e<=.75&&(i*=2),C[0]=Math.ceil(C[0]/i)*i,C[1]=Math.floor(C[1]/i)*i+.5*i,C[2]=i,C}function yt(I,C){return g.range.apply(g,Bt(I,C))}function Vt(I,C,A){var i=Bt(I,C);if(A){var e=NI.exec(A);if(e.shift(),"s"===e[8]){var t=g.formatPrefix(Math.max(Z(i[0]),Z(i[1])));return e[7]||(e[7]="."+Yt(t.scale(i[2]))),e[8]="f",A=g.format(e.join("")),function(g){return A(t.scale(g))+t.symbol}}e[7]||(e[7]="."+function(g,I){var C=Yt(I[2]);return g in Xt?Math.abs(C-Yt(Math.max(Z(I[0]),Z(I[1]))))+ +("e"!==g):C-2*("%"===g)}(e[8],i)),A=e.join("")}else A=",."+Yt(i[2])+"f";return g.format(A)}g.scale.linear=function(){return pt([0,1],[0,1],_i,!1)};var Xt={s:1,g:1,p:1,r:1,e:1};function Yt(g){return-Math.floor(Math.log(g)/Math.LN10+.01)}function Rt(I,C,A,i){function e(g){return(A?Math.log(g<0?0:g):-Math.log(g>0?0:-g))/Math.log(C)}function t(g){return A?Math.pow(C,g):-Math.pow(C,-g)}function l(g){return I(e(g))}return l.invert=function(g){return t(I.invert(g))},l.domain=function(g){return arguments.length?(A=g[0]>=0,I.domain((i=g.map(Number)).map(e)),l):i},l.base=function(g){return arguments.length?(C=+g,I.domain(i.map(e)),l):C},l.nice=function(){var g=bt(i.map(e),A?Math:Ht);return I.domain(g),i=g.map(t),l},l.ticks=function(){var g=mt(i),I=[],l=g[0],s=g[1],o=Math.floor(e(l)),c=Math.ceil(e(s)),d=C%1?2:C;if(isFinite(c-o)){if(A){for(;o0;a--)I.push(t(o)*a);for(o=0;I[o]s;c--);I=I.slice(o,c)}return I},l.tickFormat=function(I,C){if(!arguments.length)return Nt;arguments.length<2?C=Nt:"function"!=typeof C&&(C=g.format(C));var i,s=Math.max(.1,I/l.ticks().length),o=A?(i=1e-12,Math.ceil):(i=-1e-12,Math.floor);return function(g){return g/t(o(e(g)+i))<=s?C(g):""}},l.copy=function(){return Rt(I.copy(),C,A,i)},wt(l,I)}g.scale.log=function(){return Rt(g.scale.linear().domain([0,1]),10,!0,[1,10])};var Nt=g.format(".0e"),Ht={floor:function(g){return-Math.ceil(-g)},ceil:function(g){return-Math.floor(-g)}};function Kt(g,I,C){var A=ft(I),i=ft(1/I);function e(I){return g(A(I))}return e.invert=function(I){return i(g.invert(I))},e.domain=function(I){return arguments.length?(g.domain((C=I.map(Number)).map(A)),e):C},e.ticks=function(g){return yt(C,g)},e.tickFormat=function(g,I){return Vt(C,g,I)},e.nice=function(g){return e.domain(Wt(C,g))},e.exponent=function(t){return arguments.length?(A=ft(I=t),i=ft(1/I),g.domain(C.map(A)),e):I},e.copy=function(){return Kt(g.copy(),I,C)},wt(e,g)}function ft(g){return function(I){return I<0?-Math.pow(-I,g):Math.pow(I,g)}}function Ft(I,C){var A,i,e;function t(g){return i[((A.get(g)||("range"===C.t?A.set(g,I.push(g)):NaN))-1)%i.length]}function l(C,A){return g.range(I.length).map((function(g){return C+A*g}))}return t.domain=function(g){if(!arguments.length)return I;I=[],A=new G;for(var i,e=-1,l=g.length;++e0?A[g-1]:I[0],gd?0:1;if(o=Vg)return s(o,n)+(l?s(l,1-n):"")+"Z";var r,m,h,Z,b,G,u,p,w,W,B,y,V=0,X=0,Y=[];if((Z=(+t.apply(this,arguments)||0)/2)&&(h=A===xt?Math.sqrt(l*l+o*o):+A.apply(this,arguments),n||(X*=-1),o&&(X=fg(h/o*Math.sin(Z))),l&&(V=fg(h/l*Math.sin(Z)))),o){b=o*Math.cos(c+X),G=o*Math.sin(c+X),u=o*Math.cos(d-X),p=o*Math.sin(d-X);var R=Math.abs(d-c-2*X)<=Bg?0:1;if(X&&Pt(b,G,u,p)===n^R){var N=(c+d)/2;b=o*Math.cos(N),G=o*Math.sin(N),u=p=null}}else b=G=0;if(l){w=l*Math.cos(d-V),W=l*Math.sin(d-V),B=l*Math.cos(c+V),y=l*Math.sin(c+V);var H=Math.abs(c-d+2*V)<=Bg?0:1;if(V&&Pt(w,W,B,y)===1-n^H){var K=(c+d)/2;w=l*Math.cos(K),W=l*Math.sin(K),B=y=null}}else w=W=0;if(a>wg&&(r=Math.min(Math.abs(o-l)/2,+C.apply(this,arguments)))>.001){m=l0?0:1}function _t(g,I,C,A,i){var e=g[0]-I[0],t=g[1]-I[1],l=(i?A:-A)/Math.sqrt(e*e+t*t),s=l*t,o=-l*e,c=g[0]+s,d=g[1]+o,a=I[0]+s,n=I[1]+o,r=(c+a)/2,m=(d+n)/2,h=a-c,Z=n-d,b=h*h+Z*Z,G=C-A,u=c*n-a*d,p=(Z<0?-1:1)*Math.sqrt(Math.max(0,G*G*b-u*u)),w=(u*Z-h*p)/b,W=(-u*h-Z*p)/b,B=(u*Z+h*p)/b,y=(-u*h+Z*p)/b,V=w-r,X=W-m,Y=B-r,R=y-m;return V*V+X*X>Y*Y+R*R&&(w=B,W=y),[[w-s,W-o],[w*C/G,W*C/G]]}function qt(g){var I=Ii,C=Ci,A=QC,i=gl,e=i.key,t=.7;function l(e){var l,s=[],o=[],c=-1,d=e.length,a=mI(I),n=mI(C);function r(){s.push("M",i(g(o),t))}for(;++c1&&i.push("H",A[0]);return i.join("")},"step-before":Cl,"step-after":Al,basis:tl,"basis-open":function(g){if(g.length<4)return gl(g);var I,C=[],A=-1,i=g.length,e=[0],t=[0];for(;++A<3;)I=g[A],e.push(I[0]),t.push(I[1]);C.push(ll(cl,e)+","+ll(cl,t)),--A;for(;++A9&&(i=3*I/Math.sqrt(i),t[l]=i*C,t[l+1]=i*A);l=-1;for(;++l<=s;)i=(g[Math.min(s,l+1)][0]-g[Math.max(0,l-1)][0])/(6*(1+t[l]*t[l])),e.push([i||0,t[l]*i||0]);return e}(g))}});function gl(g){return g.length>1?g.join("L"):g+"Z"}function Il(g){return g.join("L")+"Z"}function Cl(g){for(var I=0,C=g.length,A=g[0],i=[A[0],",",A[1]];++I1){l=I[1],e=g[s],s++,A+="C"+(i[0]+t[0])+","+(i[1]+t[1])+","+(e[0]-l[0])+","+(e[1]-l[1])+","+e[0]+","+e[1];for(var o=2;oBg)+",1 "+I}function s(g,I,C,A){return"Q 0,0 "+A}return e.radius=function(g){return arguments.length?(C=mI(g),e):C},e.source=function(I){return arguments.length?(g=mI(I),e):g},e.target=function(g){return arguments.length?(I=mI(g),e):I},e.startAngle=function(g){return arguments.length?(A=mI(g),e):A},e.endAngle=function(g){return arguments.length?(i=mI(g),e):i},e},g.svg.diagonal=function(){var g=LA,I=zA,C=hl;function A(A,i){var e=g.call(this,A,i),t=I.call(this,A,i),l=(e.y+t.y)/2,s=[e,{x:e.x,y:l},{x:t.x,y:l},t];return"M"+(s=s.map(C))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return A.source=function(I){return arguments.length?(g=mI(I),A):g},A.target=function(g){return arguments.length?(I=mI(g),A):I},A.projection=function(g){return arguments.length?(C=g,A):C},A},g.svg.diagonal.radial=function(){var I=g.svg.diagonal(),C=hl,A=I.projection;return I.projection=function(g){return arguments.length?A(function(g){return function(){var I=g.apply(this,arguments),C=I[0],A=I[1]-Xg;return[C*Math.cos(A),C*Math.sin(A)]}}(C=g)):C},I},g.svg.symbol=function(){var g=bl,I=Zl;function C(C,A){return(ul.get(g.call(this,C,A))||Gl)(I.call(this,C,A))}return C.type=function(I){return arguments.length?(g=mI(I),C):g},C.size=function(g){return arguments.length?(I=mI(g),C):I},C};var ul=g.map({circle:Gl,cross:function(g){var I=Math.sqrt(g/5)/2;return"M"+-3*I+","+-I+"H"+-I+"V"+-3*I+"H"+I+"V"+-I+"H"+3*I+"V"+I+"H"+I+"V"+3*I+"H"+-I+"V"+I+"H"+-3*I+"Z"},diamond:function(g){var I=Math.sqrt(g/(2*wl)),C=I*wl;return"M0,"+-I+"L"+C+",0 0,"+I+" "+-C+",0Z"},square:function(g){var I=Math.sqrt(g)/2;return"M"+-I+","+-I+"L"+I+","+-I+" "+I+","+I+" "+-I+","+I+"Z"},"triangle-down":function(g){var I=Math.sqrt(g/pl),C=I*pl/2;return"M0,"+C+"L"+I+","+-C+" "+-I+","+-C+"Z"},"triangle-up":function(g){var I=Math.sqrt(g/pl),C=I*pl/2;return"M0,"+-C+"L"+I+","+C+" "+-I+","+C+"Z"}});g.svg.symbolTypes=ul.keys();var pl=Math.sqrt(3),wl=Math.tan(30*Yg);j.transition=function(g){for(var I,C,A=Vl||++Rl,i=Kl(g),e=[],t=Xl||{time:Date.now(),ease:te,delay:0,duration:250},l=-1,s=this.length;++l0;)o[--a].call(g,t);if(e>=1)return d.event&&d.event.end.call(g,g.__data__,I),--c.count?delete c[A]:delete g[C],1}d||(e=i.time,t=WI((function(g){var I=d.delay;if(t.t=I+e,I<=g)return a(g-I);t.c=a}),0,e),d=c[A]={tween:new G,time:e,timer:t,delay:i.delay,duration:i.duration,ease:i.ease,index:I},i=null,++c.count)}Yl.call=j.call,Yl.empty=j.empty,Yl.node=j.node,Yl.size=j.size,g.transition=function(I,C){return I&&I.transition?Vl?I.transition(C):I:g.selection().transition(I)},g.transition.prototype=Yl,Yl.select=function(g){var I,C,A,i=this.id,e=this.namespace,t=[];g=Q(g);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function m(g){g.select(".extent").attr("y",s[0]),g.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function h(){var d,h,Z=this,b=g.select(g.event.target),G=A.of(Z,arguments),u=g.select(Z),p=b.datum(),w=!/^(n|s)$/.test(p)&&i,W=!/^(e|w)$/.test(p)&&t,B=b.classed("extent"),y=bg(Z),V=g.mouse(Z),X=g.select(e(Z)).on("keydown.brush",(function(){32==g.event.keyCode&&(B||(d=null,V[0]-=l[1],V[1]-=s[1],B=2),J())})).on("keyup.brush",(function(){32==g.event.keyCode&&2==B&&(V[0]+=l[1],V[1]+=s[1],B=0,J())}));if(g.event.changedTouches?X.on("touchmove.brush",N).on("touchend.brush",K):X.on("mousemove.brush",N).on("mouseup.brush",K),u.interrupt().selectAll("*").interrupt(),B)V[0]=l[0]-V[0],V[1]=s[0]-V[1];else if(p){var Y=+/w$/.test(p),R=+/^n/.test(p);h=[l[1-Y]-V[0],s[1-R]-V[1]],V[0]=l[Y],V[1]=s[R]}else g.event.altKey&&(d=V.slice());function N(){var I=g.mouse(Z),C=!1;h&&(I[0]+=h[0],I[1]+=h[1]),B||(g.event.altKey?(d||(d=[(l[0]+l[1])/2,(s[0]+s[1])/2]),V[0]=l[+(I[0]1?{floor:function(I){for(;l(I=g.floor(I));)I=Ul(I-1);return I},ceil:function(I){for(;l(I=g.ceil(I));)I=Ul(+I+1);return I}}:g))},i.ticks=function(g,I){var C=mt(i.domain()),A=null==g?e(C,10):"number"==typeof g?e(C,g):!g.range&&[{range:g},I];return A&&(g=A[0],I=A[1]),g.range(C[0],Ul(+C[1]+1),I<1?1:I)},i.tickFormat=function(){return A},i.copy=function(){return xl(I.copy(),C,A)},wt(i,I)}function Ul(g){return new Date(g)}vl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Tl:zl,Tl.parse=function(g){var I=new Date(g);return isNaN(I)?null:I},Tl.toString=zl.toString,fI.second=JI((function(g){return new FI(1e3*Math.floor(g/1e3))}),(function(g,I){g.setTime(g.getTime()+1e3*Math.floor(I))}),(function(g){return g.getSeconds()})),fI.seconds=fI.second.range,fI.seconds.utc=fI.second.utc.range,fI.minute=JI((function(g){return new FI(6e4*Math.floor(g/6e4))}),(function(g,I){g.setTime(g.getTime()+6e4*Math.floor(I))}),(function(g){return g.getMinutes()})),fI.minutes=fI.minute.range,fI.minutes.utc=fI.minute.utc.range,fI.hour=JI((function(g){var I=g.getTimezoneOffset()/60;return new FI(36e5*(Math.floor(g/36e5-I)+I))}),(function(g,I){g.setTime(g.getTime()+36e5*Math.floor(I))}),(function(g){return g.getHours()})),fI.hours=fI.hour.range,fI.hours.utc=fI.hour.utc.range,fI.month=JI((function(g){return(g=fI.day(g)).setDate(1),g}),(function(g,I){g.setMonth(g.getMonth()+I)}),(function(g){return g.getMonth()})),fI.months=fI.month.range,fI.months.utc=fI.month.utc.range;var jl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ql=[[fI.second,1],[fI.second,5],[fI.second,15],[fI.second,30],[fI.minute,1],[fI.minute,5],[fI.minute,15],[fI.minute,30],[fI.hour,1],[fI.hour,3],[fI.hour,6],[fI.hour,12],[fI.day,1],[fI.day,2],[fI.week,1],[fI.month,1],[fI.month,3],[fI.year,1]],Ol=vl.multi([[".%L",function(g){return g.getMilliseconds()}],[":%S",function(g){return g.getSeconds()}],["%I:%M",function(g){return g.getMinutes()}],["%I %p",function(g){return g.getHours()}],["%a %d",function(g){return g.getDay()&&1!=g.getDate()}],["%b %d",function(g){return 1!=g.getDate()}],["%B",function(g){return g.getMonth()}],["%Y",QC]]),El={range:function(I,C,A){return g.range(Math.ceil(I/A)*A,+C,A).map(Ul)},floor:N,ceil:N};Ql.year=fI.year,fI.scale=function(){return xl(g.scale.linear(),Ql,Ol)};var Pl=Ql.map((function(g){return[g[0].utc,g[1]]})),_l=Ll.multi([[".%L",function(g){return g.getUTCMilliseconds()}],[":%S",function(g){return g.getUTCSeconds()}],["%I:%M",function(g){return g.getUTCMinutes()}],["%I %p",function(g){return g.getUTCHours()}],["%a %d",function(g){return g.getUTCDay()&&1!=g.getUTCDate()}],["%b %d",function(g){return 1!=g.getUTCDate()}],["%B",function(g){return g.getUTCMonth()}],["%Y",QC]]);function ql(g){return JSON.parse(g.responseText)}function $l(g){var I=A.createRange();return I.selectNode(A.body),I.createContextualFragment(g.responseText)}return Pl.year=fI.year.utc,fI.scale.utc=function(){return xl(g.scale.linear(),Pl,_l)},g.text=hI((function(g){return g.responseText})),g.json=function(g,I){return ZI(g,"application/json",ql,I)},g.html=function(g,I){return ZI(g,"text/html",$l,I)},g.xml=hI((function(g){return g.responseXML})),g};const DI=window.E0DD32CBDCB63F();let vI=1;function LI(g){const I="<".charCodeAt(0),C=">".charCodeAt(0),A="-".charCodeAt(0),i="/".charCodeAt(0),e="!".charCodeAt(0),t="'".charCodeAt(0),l='"'.charCodeAt(0),s="?".charCodeAt(0),o="\r\n\t>/= ";let c=0;return vI=1,zI(function d(){const a=[];for(;g[c];){if(g.charCodeAt(c)===I){if(g.charCodeAt(c+1)===i)return c=g.indexOf(">",c),a;if(g.charCodeAt(c+1)===e){if(g.charCodeAt(c+2)===A){for(;g.charCodeAt(c)!==C||g.charCodeAt(c-1)!==A||g.charCodeAt(c-2)!==A||-1===c;)c=g.indexOf(">",c+1);-1===c&&(c=g.length)}else for(c+=2;g.charCodeAt(c)!==C;c++);c++;continue}if(g.charCodeAt(c+1)===s){c=g.indexOf(">",c),c++;continue}c++;let I=c;for(;-1===o.indexOf(g[c]);c++);const n=g.slice(I,c);let r,m=!1,h={};for(;g.charCodeAt(c)!==C;c++){const C=g.charCodeAt(c);if(C>64&&C<91||C>96&&C<123){for(I=c;-1===o.indexOf(g[c]);c++);const C=g.slice(I,c);let A=g.charCodeAt(c);for(;A!==t&&A!==l;)c++,A=g.charCodeAt(c);const i=g[c],e=++c;c=g.indexOf(i,e);const s=g.slice(e,c);m||(h={},m=!0),h[C]=s}}g.charCodeAt(c-1)!==i&&(c++,r=d()),a.push({children:r,tagName:n,attrs:h})}else{const I=c;c=g.indexOf("<",c)-1,-2===c&&(c=g.length);const C=g.slice(I,c+1);C.trim().length>0&&a.push(C)}c++}return a}())}function zI(g){const I={};if(void 0===g)return{};if(1===g.length&&("string"==typeof g[0]||g[0]instanceof String))return new String(g[0]);g.forEach((function(g){if("string"!=typeof g&&(I[g.tagName]||(I[g.tagName]=[])),"object"==typeof g){const C=zI(g.children);g.attrs&&(C.attrs=g.attrs),void 0===C.attrs?C.attrs={order:vI}:C.attrs.order=vI,vI++,I[g.tagName].push(C)}}));for(const C in I)1===I[C].length&&(I[C]=I[C][0]);return I}const TI=Math.round;class xI{constructor(g){C(this,"r"),C(this,"g"),C(this,"b"),this.r=g[0],this.g=g[1],this.b=g[2]}toString(){return`rgb(${this.r},${this.g},${this.b})`}}class UI extends xI{constructor(g){super(g),C(this,"a"),this.a=g[3]}toString(){return`rgba(${this.r},${this.g},${this.b},${this.a})`}}class jI{constructor(g){C(this,"h"),C(this,"s"),C(this,"l"),this.h=g[0],this.s=g[1],this.l=g[2]}toString(){return`hsl(${this.h},${this.s}%,${this.l}%)`}}class QI extends jI{constructor(g){super(g),C(this,"a"),this.a=g[3]}toString(){return`hsla(${this.h},${this.s}%,${this.l}%,${this.a})`}}class OI{constructor(g,I=0,A=0,i=1){if(C(this,"r"),C(this,"g"),C(this,"b"),C(this,"a"),C(this,"rgb"),C(this,"rgba"),C(this,"hex"),C(this,"hsl"),C(this,"hsla"),C(this,"h"),C(this,"s"),C(this,"l"),"string"==typeof g){let C=g;"#"!==C.charAt(0)&&(C="#"+C),C.length<7&&(C="#"+C[1]+C[1]+C[2]+C[2]+C[3]+C[3]),[g,I,A]=EI(C)}else g instanceof Array&&(i=g[3]||i,A=g[2],I=g[1],g=g[0]);this.r=Number(g),this.g=Number(I),this.b=Number(A),this.a=i,this.rgb=new xI([this.r,this.g,this.b]),this.rgba=new UI([this.r,this.g,this.b,this.a]),this.hex=qI(this.r,this.g,this.b),this.hsl=new jI($I(this.r,this.g,this.b)),this.h=this.hsl.h,this.s=this.hsl.s,this.l=this.hsl.l,this.hsla=new QI([this.h,this.s,this.l,this.a])}setHue(g){this.h=g,this.hsl.h=g,this.hsla.h=g,this.updateFromHsl()}setSat(g){this.s=g,this.hsl.s=g,this.hsla.s=g,this.updateFromHsl()}setLum(g){this.l=g,this.hsl.l=g,this.hsla.l=g,this.updateFromHsl()}setAlpha(g){this.a=g,this.hsla.a=g,this.rgba.a=g}updateFromHsl(){this.rgb=new xI(IC(this.h,this.s,this.l)),this.r=this.rgb.r,this.g=this.rgb.g,this.b=this.rgb.b,this.rgba.r=this.rgb.r,this.rgba.g=this.rgb.g,this.rgba.b=this.rgb.b,this.hex=qI([this.r,this.g,this.b])}}const EI=function(g){const I=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(g);return I?[parseInt(I[1],16),parseInt(I[2],16),parseInt(I[3],16)]:null},PI=(g,I)=>{const C=EI(g)||[];for(let A=0;A<3;A++)C[A]=Math.floor(Number(C[A])*(1-I));return qI(C[0],C[1],C[2])};const _I=function(g){const I=g.toString(16);return 1===I.length?"0"+I:I},qI=function(g,I=0,C=0){return g instanceof Array&&(C=g[2],I=g[1],g=g[0]),"#"+_I(g)+_I(I)+_I(C)},$I=function(g,I=0,C=0){g instanceof Array&&(C=g[2],I=g[1],g=g[0]);let A,i,e,t=0;g/=255,I/=255,C/=255;const l=Math.max(g,I,C),s=Math.min(g,I,C);if(i=(l+s)/2,l===s)t=A=0;else{switch(e=l-s,A=i>.5?e/(2-l-s):e/(l+s),l){case g:t=(I-C)/e+(I1&&(C-=1),C<1/6?g+6*(I-g)*C:C<.5?I:C<2/3?g+(I-g)*(2/3-C)*6:g},IC=function(g,I,C){let A,i,e,t,l;return g instanceof Array&&(C=g[2],I=g[1],g=g[0]),g=Number(g)/360,I=Number(I)/100,C=Number(C)/100,0===I?A=i=e=C:(t=C<.5?C*(1+I):C+I-C*I,l=2*C-t,A=gC(l,t,g+1/3),i=gC(l,t,g),e=gC(l,t,g-1/3)),[TI(255*A),TI(255*i),TI(255*e)]};function CC(g){const I=new Uint8Array(g);let C="";for(let A=0;A0&&I<1e3);else if(I>1e3){const C=I-1e3,A=i["a:theme"]["a:themeElements"]["a:fmtScheme"]["a:bgFillStyleLst"],t=[];Object.keys(A).forEach((function(g){const I=A[g];if("attrs"!==g)if(I.constructor===Array)for(let C=0;C0&&I<1e3);else if(I>1e3){const C=I-1e3,A=i["a:theme"]["a:themeElements"]["a:fmtScheme"]["a:bgFillStyleLst"],t=[];Object.keys(A).forEach((function(g){const I=A[g];if("attrs"!==g)if(I.constructor===Array)for(let C=0;C";for(const I in H)if(H[I].constructor===Array)for(let g=0;g"}function c(g){const I=g[Object.keys(g)[0]]["p:cSld"]["p:spTree"],C={},A={},i={};for(const e in I){if("p:nvGrpSpPr"===e||"p:grpSpPr"===e)continue;const g=I[e];if(g.constructor===Array)for(let I=0;I"}(I,i);break;case"p:graphicFrame":e=await async function(g,I){let i="";switch(M(g,["a:graphic","a:graphicData","attrs","uri"])){case"http://schemas.openxmlformats.org/drawingml/2006/table":i=await async function(g,I){const C=g.attrs.order,A=M(g,["a:graphic","a:graphicData","a:tbl"]),i=M(g,["p:xfrm"]),e=M(g,["a:graphic","a:graphicData","a:tbl","a:tblPr"]),t=M(g,["a:graphic","a:graphicData","a:tbl","a:tblGrid","a:gridCol"]);let s="";if(void 0!==e){s=1===e.attrs.rtl?"dir=rtl":"dir=ltr"}const o=e.attrs.firstRow,c=e.attrs.bandRow;let d="";const a=A["a:tr"];if(a.constructor===Array)for(let r=0;r0&&void 0!==c){let g="fff",I=1;if(r%2==0){if(void 0!==i["a:band2H"]){const C=M(i,["a:band2H","a:tcStyle","a:fill","a:solidFill"]);void 0!==C&&(g=R(C),I=K(C));const e=M(i,["a:band2H","a:tcStyle","a:tcBdr"]);if(void 0!==e){A+=W(e)}M(i,["a:band2H","a:tcTxStyle"])}}else if(void 0!==i["a:band1H"]){const C=M(i,["a:band1H","a:tcStyle","a:fill","a:solidFill"]);void 0!==C&&(g=R(C),I=K(C));const e=M(i,["a:band1H","a:tcStyle","a:tcBdr"]);if(void 0!==e){A+=W(e)}M(i,["a:band1H","a:tcTxStyle"])}A+=" background-color:#"+g+"; opacity:"+I+";"}d+="";const m=a[r]["a:tc"];if(m.constructor===Array)for(let o=0;o"+g+"":void 0!==A?d+="":void 0===i&&void 0===s&&(d+="")}else{const g=await n(m["a:txBody"]),I=t[0].attrs.w;let C="";if(void 0!==I){C+="width:"+96*parseInt(I)/914400+"px;"}const A=m["a:tcPr"]["a:solidFill"];let i="",e=1;void 0!==A&&(i=R(A),e=K(A)),""!==i&&(C+=" background-color:#"+i+";",C+=" opacity"+e+";"),d+=""}d+=""}else{const g=a.attrs.h;let I=0;void 0!==g?(I=96*parseInt(g)/914400,d+=""):d+="";const C=a["a:tc"];if(C.constructor===Array)for(let A=0;A"+g+""}else{const g=await n(C["a:txBody"]),I=t[0].attrs.w;let A="";if(void 0!==I){A+="width:"+96*parseInt(I)/914400+"px;"}const i=C["a:tcPr"]["a:solidFill"];let e="",l=1;void 0!==i&&(e=R(i),l=K(i)),""!==e&&(A+=" background-color:#"+e+";",A+=" opacity"+l+";"),d+=""}d+=""}return d}(g,I);break;case"http://schemas.openxmlformats.org/drawingml/2006/chart":i=await async function(g,I){const i=g.attrs.order,e=M(g,["p:xfrm"]),t="
",l=g["a:graphic"]["a:graphicData"]["c:chart"].attrs["r:id"],o=I.slideResObj[l].target,c=await s(I.zip,o),d=M(c,["c:chartSpace","c:chart","c:plotArea"]);let a=null;for(const C in d)switch(C){case"c:lineChart":a={type:"createChart",data:{chartID:"chart"+A,chartType:"lineChart",chartData:F(d[C]["c:ser"])}};break;case"c:barChart":a={type:"createChart",data:{chartID:"chart"+A,chartType:"barChart",chartData:F(d[C]["c:ser"])}};break;case"c:pieChart":a={type:"createChart",data:{chartID:"chart"+A,chartType:"pieChart",chartData:F(d[C]["c:ser"])}};break;case"c:pie3DChart":a={type:"createChart",data:{chartID:"chart"+A,chartType:"pie3DChart",chartData:F(d[C]["c:ser"])}};break;case"c:areaChart":a={type:"createChart",data:{chartID:"chart"+A,chartType:"areaChart",chartData:F(d[C]["c:ser"])}};break;case"c:scatterChart":a={type:"createChart",data:{chartID:"chart"+A,chartType:"scatterChart",chartData:F(d[C]["c:ser"])}}}null!=a&&C.push(a);return A++,t}(g,I);break;case"http://schemas.openxmlformats.org/drawingml/2006/diagram":i=function(g){const I=M(g,["p:xfrm"]);return"
TODO: diagram
"}(g)}return i}(I,i);break;case"p:grpSp":e=await async function(g,I){const C=96/914400,A=g["p:grpSpPr"]["a:xfrm"],i=parseInt(A["a:off"].attrs.x)*C,e=parseInt(A["a:off"].attrs.y)*C,t=parseInt(A["a:chOff"].attrs.x)*C,l=parseInt(A["a:chOff"].attrs.y)*C,s=parseInt(A["a:ext"].attrs.cx)*C,o=parseInt(A["a:ext"].attrs.cy)*C,c=parseInt(A["a:chExt"].attrs.cx)*C,a=parseInt(A["a:chExt"].attrs.cy)*C;let n="
";for(const r in g)if(g[r].constructor===Array)for(let C=0;C",r+="",Y=await V(g,!0,s);const C=X(M(g,["p:spPr"]));if("GRADIENT_FILL"===C){K=!0;const g=Y.color,I=Y.rot,C=function(g,I,C,A,i){const e=function(g){const I=["0%","100%"];if(0===g)return!0;{let C=g;for(;C--;){const A=100-100/(g+1)*(C+1)+"%";I.splice(-1,0,A)}}return I}(A.length-2),t=function(g,I,C){const A=parseFloat(C),i=parseFloat(I),e=parseFloat(g);let t=2,l=2;const s=A/2,o=i/2;let c=2,d=2,a=2,n=2;const r=(e%360+360)%360,m=(360-r)*Math.PI/180,h=Math.tan(m),Z=o-h*s;0===r?(c=A,d=o,a=0,n=o):r<90?(l=A,t=0):90===r?(c=s,d=0,a=s,n=i):r<180?(l=0,t=0):180===r?(c=0,d=o,a=A,n=o):r<270?(l=0,t=i):270===r?(c=s,d=i,a=s,n=0):(l=A,t=i);const b=t+l/h;c=2===c?h*(b-Z)/(Math.pow(h,2)+1):c,d=2===d?h*c+Z:d,a=2===a?A-c:a,n=2===n?i-d:n;const G=Math.round(a/A*100*100)/100,u=Math.round(n/i*100*100)/100,p=Math.round(c/A*100*100)/100,w=Math.round(d/i*100*100)/100;return[G,u,p,w]}(C,I,g),l=t[0],s=t[1],o=t[2],c=t[3],d=e.length,a=d<20?100:1e3;let n='\n';for(let r=0;r';return C+='',C+="",C}(Y,m);r+=g}if(H=B(g,!0),W=M(g,["p:spPr","a:ln","a:headEnd","attrs"]),y=M(g,["p:spPr","a:ln","a:tailEnd","attrs"]),void 0!==W&&("triangle"===W.type||"arrow"===W.type)||void 0!==y&&("triangle"===y.type||"arrow"===y.type)){r+=""}r+=""}if(void 0!==h&&void 0===G){switch(h){case"accentBorderCallout1":case"accentBorderCallout2":case"accentBorderCallout3":case"accentCallout1":case"accentCallout2":case"accentCallout3":case"actionButtonBackPrevious":case"actionButtonBeginning":case"actionButtonBlank":case"actionButtonDocument":case"actionButtonEnd":case"actionButtonForwardNext":case"actionButtonHelp":case"actionButtonHome":case"actionButtonInformation":case"actionButtonMovie":case"actionButtonReturn":case"actionButtonSound":case"arc":case"bevel":case"blockArc":case"borderCallout1":case"borderCallout2":case"borderCallout3":case"bracePair":case"bracketPair":case"callout1":case"callout2":case"callout3":case"can":case"chartPlus":case"chartStar":case"chartX":case"chevron":case"chord":case"cloud":case"cloudCallout":case"corner":case"cornerTabs":case"cube":case"diagStripe":case"donut":case"doubleWave":case"downArrowCallout":case"ellipseRibbon":case"ellipseRibbon2":case"flowChartAlternateProcess":case"flowChartCollate":case"flowChartConnector":case"flowChartDecision":case"flowChartDelay":case"flowChartDisplay":case"flowChartDocument":case"flowChartExtract":case"flowChartInputOutput":case"flowChartInternalStorage":case"flowChartMagneticDisk":case"flowChartMagneticDrum":case"flowChartMagneticTape":case"flowChartManualInput":case"flowChartManualOperation":case"flowChartMerge":case"flowChartMultidocument":case"flowChartOfflineStorage":case"flowChartOffpageConnector":case"flowChartOnlineStorage":case"flowChartOr":case"flowChartPredefinedProcess":case"flowChartPreparation":case"flowChartProcess":case"flowChartPunchedCard":case"flowChartPunchedTape":case"flowChartSort":case"flowChartSummingJunction":case"flowChartTerminator":case"folderCorner":case"frame":case"funnel":case"gear6":case"gear9":case"halfFrame":case"heart":case"homePlate":case"horizontalScroll":case"irregularSeal1":case"irregularSeal2":case"leftArrowCallout":case"leftBrace":case"leftBracket":case"leftRightArrowCallout":case"leftRightRibbon":case"lightningBolt":case"lineInv":case"mathDivide":case"mathEqual":case"mathMinus":case"mathMultiply":case"mathNotEqual":case"mathPlus":case"moon":case"nonIsoscelesTrapezoid":case"noSmoking":case"pie":case"pieWedge":case"plaque":case"plaqueTabs":case"quadArrowCallout":case"rect":case"ribbon":case"ribbon2":case"rightArrowCallout":case"rightBrace":case"rightBracket":case"round1Rect":case"round2DiagRect":case"round2SameRect":case"smileyFace":case"snip1Rect":case"snip2DiagRect":case"snip2SameRect":case"snipRoundRect":case"squareTabs":case"star10":case"star12":case"star16":case"star24":case"star32":case"star4":case"star5":case"star6":case"star7":case"star8":case"sun":case"teardrop":case"upArrowCallout":case"upDownArrowCallout":case"verticalScroll":case"wave":case"wedgeEllipseCallout":case"wedgeRectCallout":case"wedgeRoundRectCallout":r+="";break;case"ellipse":r+="";break;case"roundRect":r+="";break;case"bentConnector2":{let g;g=p?"M 0 "+R+" L "+N+" "+R+" L "+N+" 0":"M "+R+" 0 L "+R+" "+N+" L 0 "+N,r+="";break;case"triangle":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.5;void 0!==I&&(C=96*parseInt(I.substr(4))/9144e3),r+=" ";break}case"diamond":r+=" ";break;case"trapezoid":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.25;const A=.7407;if(void 0!==I){C=.5*(96*parseInt(I.substr(4))/9144e3)/A}r+=" ";break}case"parallelogram":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C,A=.25;if(C=R>N?R/N:N/R,void 0!==I){A=parseInt(I.substr(4))/1e5/C}r+=" ";break}case"pentagon":r+=" ";break;case"hexagon":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd"])||[];let C;for(let g=0;g";break}case"heptagon":r+=" ";break;case"octagon":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.25;void 0!==I&&(C=parseInt(I.substr(4))/1e5);const A=1-C;r+=" ";break}case"decagon":r+=" ";break;case"dodecagon":r+=" ";break;case"bentConnector3":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.5;void 0!==I&&(C=parseInt(I.substr(4))/1e5,r+=p?" ";break}case"line":case"straightConnector1":case"bentConnector4":case"bentConnector5":case"curvedConnector2":case"curvedConnector3":case"curvedConnector4":case"curvedConnector5":r+=p?"";break}case"leftArrow":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const t=R/N;if(void 0!==I)for(let g=0;g";break}case"downArrow":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const t=N/R;if(void 0!==I)for(let g=0;g";break}case"upArrow":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const t=N/R;if(void 0!==I)for(let g=0;g";break}case"leftRightArrow":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const t=R/N;if(void 0!==I)for(let g=0;g";break}case"upDownArrow":{const I=M(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const t=N/R;if(void 0!==I)for(let g=0;g";break}case"bentArrow":case"bentUpArrow":case"stripedRightArrow":case"quadArrow":case"circularArrow":case"swooshArrow":case"leftRightUpArrow":case"leftUpArrow":case"leftCircularArrow":case"notchedRightArrow":case"curvedDownArrow":case"curvedLeftArrow":case"curvedRightArrow":case"curvedUpArrow":case"uturnArrow":case"leftRightCircularArrow":break;default:console.warn("Undefine shape type.")}r+="",r+="
",void 0!==g["p:txBody"]&&(r+=await n(g["p:txBody"],I,C,t,s)),r+="
"}else if(void 0!==G){const o=M(G,["a:pathLst"]),h=M(o,["a:path","a:close"]),p=M(o,["a:path","a:moveTo","a:pt","attrs"])||{x:"0",y:"0"};let B="M"+96*parseInt(p.x)/914400+","+96*parseInt(p.y)/914400;const V=M(o,["a:path"]),X=V["a:lnTo"],R=V["a:cubicBezTo"],N=[];void 0!==X&&Object.keys(X).forEach((function(g){const I=X[g]["a:pt"];void 0!==I&&Object.keys(I).forEach((function(g){const C={},A=I[g],i=A.x,e=A.y,t=A.order;C.type="lnto",C.order=t,C.x=i,C.y=e,N.push(C)}))})),void 0!==R&&Object.keys(R).forEach((function(g){const I=R[g]["a:pt"];void 0!==I&&Object.keys(I).forEach((function(g){const C=I[g];Object.keys(C).forEach((function(g){const I={},A=C[g],i=A.x,e=A.y,t=A.order;I.type="cubicBezTo",I.order=t,I.x=i,I.y=e,N.push(I)}))}))}));const F=N.slice(0);F.sort((function(g,I){return g.order-I.order}));let S=0;for(;S",void 0!==g["p:txBody"]&&(r+=await n(g["p:txBody"],I,C,t,s)),r+="
"}else r+="
",void 0!==g["p:txBody"]&&(r+=await n(g["p:txBody"],I,C,t="",s)),r+="
";return r}async function n(g,I,C,A,i){let e="";const t=i&&i.slideMasterTextStyles;if(void 0===g)return e;let l,s;if(g["a:p"].constructor===Array)for(let o=0;o",e+=await r(l,I,C,A,i||{}),void 0===s)e+=m(l,I,C,A,i||{});else if(s.constructor===Array)for(let g=0;g");else e+=m(s,I,C,A,i||{});e+=""}else{if(l=g["a:p"],s=l["a:r"],e+="
",e+=await r(l,I,C,A,i),void 0===s)e+=m(l,I,C,A,i||{});else if(s.constructor===Array)for(let g=0;g");else e+=m(s,I,C,A,i||{});e+="
"}return e}async function r(g,I,C,A,i){const e=i&&i.slideMasterTextStyles,t=g["a:r"];let l,s,o,c;void 0!==t?(l=p(t),s=w(t,I,C,A,e)):(l=p(g),s=w(g,I,C,A,e));let d="";const a=g["a:pPr"],n=M(a,["attrs","rtl"]);let r=!1;void 0!==n&&"1"===n&&(r=!0);let m=parseInt(M(a,["attrs","lvl"]));isNaN(m)&&(m=0);const h=M(a,["a:buChar","attrs","char"]);let Z="TYPE_NONE";const b=M(a,["a:buAutoNum","attrs","type"]),G=M(a,["a:buBlip"]);void 0!==h&&(Z="TYPE_BULLET"),void 0!==b&&(Z="TYPE_NUMERIC"),void 0!==G&&(Z="TYPE_BULPIC");let u={};"TYPE_NONE"!==Z&&(u=M(a,["a:buFont","attrs"]));let W,B,y,V="NoNe";if(a){const g=a["a:buClr"];void 0!==g&&(V=R(g)||"")}if(o="NoNe"===V?l:"#"+V,W=M(a,["a:buSzPts","attrs","val"]),void 0!==W)c=parseInt(W)/100+"pt";else if(W=M(a,["a:buSzPct","attrs","val"]),void 0!==W){const g=parseInt(W)/1e5,I=s.substr(0,s.length-2);c=g*parseInt(I)+"pt"}else c=s;if("TYPE_BULLET"===Z)if(void 0!==u){B=96*parseInt(M(a,["attrs","marL"]))/914400,y=parseInt(u.pitchFamily),isNaN(B)&&(B=31545600/914400),isNaN(y)&&(y=0);d=""+h+""}else B=31545600/914400*m,d=""+h+"";else if("TYPE_NUMERIC"===Z)void 0!==u?(B=96*parseInt(M(a,["attrs","marL"]))/914400,y=parseInt(u.pitchFamily),isNaN(B)&&(B=31545600/914400),isNaN(y)&&(y=0),d=""):(B=31545600/914400*m,d="");else if("TYPE_BULPIC"===Z){B=96*parseInt(M(a,["attrs","marL"]))/914400,y=96*parseInt(M(a,["attrs","marR"]))/914400,isNaN(y)&&(y=0),B=isNaN(B)?31545600/914400:0;const g=M(G,["a:blip","attrs","r:embed"]);let I;if(void 0!==g){const C=i&&i.slideResObj[g].target,A=i&&await i.zip.file(C).async("arraybuffer");I=""}void 0===g&&(I="‣"),d=""+I+" "}else d="";return d}function m(g,I,C,A,e){const l=e.slideMasterTextStyles;let s=g["a:t"];"string"==typeof s||s instanceof String||(s=M(g,["a:fld","a:t"]),"string"==typeof s||s instanceof String||(s=" "));let o="color:"+p(g)+";font-size:"+w(g,I,C,A,l)+";font-family:"+function(g,I,C){let A=M(g,["a:rPr","a:latin","attrs","typeface"]);if(void 0===A){const g=M(i,["a:theme","a:themeElements","a:fontScheme"]);A=M(g,"title"===I||"subTitle"===I||"ctrTitle"===I?["a:majorFont","a:latin","attrs","typeface"]:["a:minorFont","a:latin","attrs","typeface"])}return void 0===A?"inherit":A}(g,A)+";font-weight:"+function(g,I,C){return void 0!==g["a:rPr"]&&"1"===g["a:rPr"].attrs.b?"bold":"initial"}(g)+";font-style:"+function(g,I,C){return void 0!==g["a:rPr"]&&"1"===g["a:rPr"].attrs.i?"italic":"normal"}(g)+";text-decoration:"+function(g,I,C){if(void 0!==g["a:rPr"]){const I=void 0!==g["a:rPr"].attrs.u?g["a:rPr"].attrs.u:"none",C=void 0!==g["a:rPr"].attrs.strike?g["a:rPr"].attrs.strike:"noStrike";return"none"!==I&&"noStrike"===C?"underline":"none"===I&&"noStrike"!==C?"line-through":"none"!==I&&"noStrike"!==C?"underline line-through":"initial"}return"initial"}(g)+";text-align:"+function(g,I,C){const A=M(g,["a:pPr","attrs","algn"]);let i="initial";if(void 0!==A)switch(A){case"l":i="left";break;case"r":i="right";break;case"ctr":i="center";break;case"just":case"dist":i="justify";break;default:i="initial"}return i}(g)+";vertical-align:"+function(g,I,C){const A=M(g,["a:rPr","attrs","baseline"]);return void 0===A?"baseline":parseInt(A)/1e3+"%"}(g)+";";const c=M(g,["a:rPr","a:highlight"]);void 0!==c&&(o+="background-color:#"+R(c)+";",o+="Opacity:"+K(c)+";");let d="";o in t?d=t[o].name:(d="_css_"+(Object.keys(t).length+1),t[o]={name:d,text:o});const a=M(g,["a:rPr","a:hlinkClick","attrs","r:id"]);if(void 0!==a){return""+s.replace(/\s/," ")+""}return""+s.replace(/\s/," ")+""}function h(){let g="";for(const I in t)g+="section ."+t[I].name+"{"+t[I].text+"}\n";return g}function Z(g,I,C){let A,i=-1,e=-1;return void 0!==g?A=g["a:off"].attrs:void 0!==I?A=I["a:off"].attrs:void 0!==C&&(A=C["a:off"].attrs),void 0===A?"":(i=96*parseInt(A.x)/914400,e=96*parseInt(A.y)/914400,isNaN(i)||isNaN(e)?"":"top:"+e+"px; left:"+i+"px;")}function b(g,I,C){let A,i=-1,e=-1;return void 0!==g?A=g["a:ext"].attrs:void 0!==I?A=I["a:ext"].attrs:void 0!==C&&(A=C["a:ext"].attrs),void 0===A?"":(i=96*parseInt(A.cx)/914400,e=96*parseInt(A.cy)/914400,isNaN(i)||isNaN(e)?"":"width:"+i+"px; height:"+e+"px;")}function G(g,I,C,A,i){let e=M(g,["a:pPr","attrs","algn"]);if(void 0===e&&(e=M(I,["p:txBody","a:p","a:pPr","attrs","algn"]),void 0===e&&(e=M(C,["p:txBody","a:p","a:pPr","attrs","algn"]),void 0===e)))switch(A){case"title":case"subTitle":case"ctrTitle":e=M(i,["p:titleStyle","a:lvl1pPr","attrs","alng"]);break;default:e=M(i,["p:otherStyle","a:lvl1pPr","attrs","alng"])}if(void 0===e){if("title"===A||"subTitle"===A||"ctrTitle"===A)return"h-mid";if("sldNum"===A)return"h-right"}return"ctr"===e?"h-mid":"r"===e?"h-right":"h-left"}function u(g,I,C,A,i){let e=M(g,["p:txBody","a:bodyPr","attrs","anchor"]);return void 0===e&&(e=M(I,["p:txBody","a:bodyPr","attrs","anchor"]),void 0===e&&(e=M(C,["p:txBody","a:bodyPr","attrs","anchor"]))),"ctr"===e?"v-mid":"b"===e?"v-down":"v-up"}function p(g,I,C){const A=function(g,I){return M(g,I.trim().split(/\s+/))}(g,"a:rPr a:solidFill"),i=R(A);return void 0===i||"FFF"===i?"#000":"#"+i}function w(g,I,C,A,i){let e=16,t="";void 0!==g["a:rPr"]&&(e=parseInt(g["a:rPr"].attrs.sz)/100),(isNaN(e)||void 0===e)&&(t=M(I,["p:txBody","a:lstStyle","a:lvl1pPr","a:defRPr","attrs","sz"]),e=parseInt(t)/100),(isNaN(e)||void 0===e)&&("title"===A||"subTitle"===A||"ctrTitle"===A?t=M(i,["p:titleStyle","a:lvl1pPr","a:defRPr","attrs","sz"]):"body"===A?t=M(i,["p:bodyStyle","a:lvl1pPr","a:defRPr","attrs","sz"]):"dt"===A||"sldNum"===A?t="1200":void 0===A&&(t=M(i,["p:otherStyle","a:lvl1pPr","a:defRPr","attrs","sz"])),e=parseInt(t)/100);return void 0===M(g,["a:rPr","attrs","baseline"])||isNaN(e)||(e-=10),isNaN(e)?"inherit":e+"pt"}function W(g){let I,C,A="";return void 0!==g["a:bottom"]&&(I={"p:spPr":{"a:ln":g["a:bottom"]["a:ln"]}},C=B(I,!1),A+=C.replace("border","border-bottom")),void 0!==g["a:top"]&&(I={"p:spPr":{"a:ln":g["a:top"]["a:ln"]}},C=B(I,!1),A+=C.replace("border","border-top")),void 0!==g["a:right"]&&(I={"p:spPr":{"a:ln":g["a:right"]["a:ln"]}},C=B(I,!1),A+=C.replace("border","border-right")),void 0!==g["a:left"]&&(I={"p:spPr":{"a:ln":g["a:left"]["a:ln"]}},C=B(I,!1),A+=C.replace("border","border-left")),A}function B(g,I){let C="border: ";const A=g["p:spPr"]["a:ln"],i=parseInt(M(A,["attrs","w"]))/12700;isNaN(i)||i<1?C+="1pt ":C+=i+"pt ";const e=M(A,["a:prstDash","attrs","val"]);let t="0";switch(e){case"solid":default:C+="solid",t="0";break;case"dash":C+="dashed",t="5";break;case"dashDot":C+="dashed",t="5, 5, 1, 5";break;case"dot":C+="dotted",t="1, 5";break;case"lgDash":C+="dashed",t="10, 5";break;case"lgDashDotDot":C+="dashed",t="10, 5, 1, 5, 1, 5";break;case"sysDash":C+="dashed",t="5, 2";break;case"sysDashDot":C+="dashed",t="5, 2, 1, 5";break;case"sysDashDotDot":C+="dashed",t="5, 2, 1, 5, 1, 5";break;case"sysDot":C+="dotted",t="2, 5"}let l=M(A,["a:solidFill","a:srgbClr","attrs","val"]);if(void 0===l){const g=M(A,["a:solidFill","a:schemeClr"]);if(void 0!==g){l=f("a:"+M(g,["attrs","val"]),void 0)}}if(void 0===l){const I=M(g,["p:style","a:lnRef","a:schemeClr"]);if(void 0!==I){l=f("a:"+M(I,["attrs","val"]),void 0)}if(void 0!==l){let g=M(I,["a:shade","attrs","val"]);if(void 0!==g){g=(parseInt(g)/1e5).toString();const I=new OI("#"+l);I.setLum(Number(I.hsl.l)*Number(g)),l=I.hex.replace("#","")}}}return l=void 0===l?I?"none":"#000":"#"+l,C+=" "+l+" ",I?{color:l,width:i,type:e,strokeDasharray:t}:C+";"}function y(g="FFFFFF"){const I=new ArrayBuffer(4);new DataView(I).setUint32(0,parseInt(g,16),!1);const C=new Uint8Array(I);return C[1]+","+C[2]+","+C[3]}async function V(g,I,C){const A=X(M(g,["p:spPr"]));let i;if("NO_FILL"===A)return I?"none":"background-color: initial;";if("SOLID_FILL"===A){i=R(g["p:spPr"]["a:solidFill"])}else if("GRADIENT_FILL"===A){i=function(g){const I=g["a:gsLst"]["a:gs"],C=[];for(let e=0;e=6&&(C-=6),C<1?(I-g)*C+g:C<3?I:C<4?(I-g)*(4-C)+g:g}function K(g){if(void 0===g)return;let I=1;if(void 0!==g["a:srgbClr"]){const C=M(g,["a:srgbClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:schemeClr"]){const C=M(g,["a:schemeClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:scrgbClr"]){const C=M(g,["a:scrgbClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:prstClr"]){const C=M(g,["a:prstClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:hslClr"]){const C=M(g,["a:hslClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:sysClr"]){const C=M(g,["a:sysClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}return I}function f(g,I){""!==e&&void 0!==e||(e=M(I,["p:sldMaster","p:clrMap","attrs"])||{});const C=g.substr(2);switch(C){case"tx1":case"tx2":case"bg1":case"bg2":g="a:"+e[C.toString()]}const A=M(i,["a:theme","a:themeElements","a:clrScheme",g]);let t=M(A,["a:srgbClr","attrs","val"]);return void 0===t&&(t=M(A,["a:sysClr","attrs","lastClr"])),t}function F(g){const I=[];if(void 0===g)return I;if(void 0!==g["c:xVal"]){let C=[];S(g["c:xVal"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return C.push(parseFloat(g["c:v"])),""})),I.push(C),C=[],S(g["c:yVal"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return C.push(parseFloat(g["c:v"])),""})),I.push(C)}else S(g,(function(g,C){const A=[],i=M(g,["c:tx","c:strRef","c:strCache","c:pt","c:v"])||C,e={};return void 0!==M(g,["c:cat","c:strRef","c:strCache","c:pt"])?S(g["c:cat"]["c:strRef"]["c:strCache"]["c:pt"],(function(g,I){return e[g.attrs.idx]=g["c:v"],""})):void 0!==M(g,["c:cat","c:numRef","c:numCache","c:pt"])&&S(g["c:cat"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return e[g.attrs.idx]=g["c:v"],""})),void 0!==M(g,["c:val","c:numRef","c:numCache","c:pt"])&&S(g["c:val"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return A.push({x:g.attrs.idx,y:parseFloat(g["c:v"])}),""})),I.push({key:i,values:A,xlabels:e}),""}));return I}function M(g,I){if(I.constructor!==Array)throw Error("Error of path type! path is not array.");if(void 0===g)return;const C=I.length;for(let A=0;A{if("processPPTX"===g.type)try{await async function(g){var A;const e=await Promise.resolve().then((()=>nC)),t=await e.loadAsync(g),c=Date.now();if(t.file("docProps/thumbnail.jpeg")){const g=await(null==(A=t.file("docProps/thumbnail.jpeg"))?void 0:A.async("base64"));I({type:"pptx-thumb",data:g})}const d=await async function(g){const I=await s(g,"[Content_Types].xml"),C=I.Types.Override,A=[],i=[];for(let e=0;e0?C=C.concat(I.data):A=!0);A&&this.chart.data&&(C=C.concat(this.chart.data))}return C},this._getFontSize=function(){return this.fontSize&&"auto"!==this.fontSize.toString().toLowerCase()?isNaN(this.fontSize)?this.fontSize:this.fontSize+"px":(this.chart._heightPixels()/35>10?this.chart._heightPixels()/35:10)+"px"},this._getFormat=function(){var g,I,C,A,i,e,t;return null!==this.tickFormat&&void 0!==this.tickFormat?g=this._hasTimeField()?DI.timeFormat(this.tickFormat):DI.format(this.tickFormat):this.showPercent?g=DI.format(".0%"):this.useLog&&null!==this.measure?g=function(g){var I=Math.floor(Math.abs(g),0).toString().length,C=Math.min(Math.floor((I-1)/3),4),A="kmBT".substring(C-1,C),i="0"===Math.round(g/Math.pow(1e3,C)*10).toString().slice(-1)?0:1;return 0===g?0:DI.format(",."+i+"f")(g/Math.pow(1e3,C))+A}:null!==this.measure?(I=Math.floor(Math.abs(this._max),0).toString(),C=Math.floor(Math.abs(this._min),0).toString(),(A=Math.max(C.length,I.length))>3?(i=Math.min(Math.floor((A-1)/3),4),e="kmBT".substring(i-1,i),t=A-3*i<=1?1:0,g=function(g){return 0===g?0:DI.format(",."+t+"f")(g/Math.pow(1e3,i))+e}):(t=Math.max(-(this._tick_step?Math.floor(Math.log(this._tick_step)/Math.LN10):0),0),g=DI.format(",."+t+"f"))):g=function(g){return g},g},this._getTimePeriod=function(){var g=this.timePeriod,I=30,C=this._max-this._min;return this._hasTimeField()&&!this.timePeriod&&(g=C/1e3<=I?DI.timeSecond:C/6e4<=I?DI.timeMinute:C/36e5<=I?DI.timeHour:C/864e5<=I?DI.timeHay:C/6048e5<=I?DI.timeWeek:C/26298e5<=I?DI.timeMonth:DI.timeYear),g},this._getTooltipText=function(g,I){if(this._hasTimeField())I[this.position+"Field"][0]&&g.push(this.timeField+": "+this._getFormat()(I[this.position+"Field"][0]));else if(this._hasCategories())this.categoryFields.forEach((function(C,A){null!=C&&I[this.position+"Field"][A]&&g.push(C+(I[this.position+"Field"][A]!==C?": "+I[this.position+"Field"][A]:""))}),this);else if(this._hasMeasure())switch(this.position){case"x":g.push(this.measure+": "+this._getFormat()(I.width));break;case"y":g.push(this.measure+": "+this._getFormat()(I.height));break;case"p":g.push(this.measure+": "+this._getFormat()(I.angle)+" ("+DI.format(".0%")(I.piePct)+")");break;default:g.push(this.measure+": "+this._getFormat()(I[this.position+"Value"]))}},this._getTopMaster=function(){var g=this;return null!==this.master&&void 0!==this.master&&(g=this.master._getTopMaster()),g},this._hasCategories=function(){return null!==this.categoryFields&&void 0!==this.categoryFields&&this.categoryFields.length>0},this._hasMeasure=function(){return null!==this.measure&&void 0!==this.measure},this._hasTimeField=function(){return null!==this.timeField&&void 0!==this.timeField},this._parseDate=function(g){return null===this.dateParseFormat||void 0===this.dateParseFormat?isNaN(g)?Date.parse(g):new Date(g):DI.timeParse(this.dateParseFormat)(g)},this._update=function(g){var I,C,A,i,e=[],t=this.ticks||10,l=function(g,I,C){var A,i,e=g.categoryFields[0],t=g._getAxisData(),l=e,s=!1,o=!0,c=null;for(A=0;A1?1:this._max,this._min=null!==this.overrideMin?this.overrideMin:this._min,this._max=null!==this.overrideMax?this.overrideMax:this._max,"x"!==this.position||null!==this._scale&&!g){if("y"!==this.position||null!==this._scale&&!g)this.position.length>0&&"z"===this.position[0]&&null===this._scale?this.useLog?this._scale=DI.scaleLog().range([this.chart._heightPixels()/300,this.chart._heightPixels()/10]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase):this._scale=DI.scaleLinear().range([1,this.chart._heightPixels()/10]).domain([this._min,this._max]).clamp(this.clamp):this.position.length>0&&"p"===this.position[0]&&null===this._scale?this.useLog?this._scale=DI.scaleLog().range([0,360]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase):this._scale=DI.scaleLinear().range([0,360]).domain([this._min,this._max]).clamp(this.clamp):this.position.length>0&&"c"===this.position[0]&&null===this._scale&&(this._scale=DI.scaleLinear().range([0,null===this.colors||1===this.colors.length?1:this.colors.length-1]).domain([this._min,this._max]).clamp(this.clamp));else if(this._hasTimeField()?this._scale=DI.scaleTime().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain([this._min,this._max]).clamp(this.clamp):this.useLog?this._scale=DI.scaleLog().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase).nice():null===this.measure||void 0===this.measure?(e=l(this,"y","x"),null!==this._slaves&&void 0!==this._slaves&&this._slaves.forEach((function(g){e=e.concat(l(g,"y","x"))}),this),this._scale=DI.scalePoint().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain(e.concat([""]))):this._scale=DI.scaleLinear().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain([this._min,this._max]).clamp(this.clamp).nice(),!this.hidden)switch(this.chart._axisIndex(this,"y")){case 0:this._draw=DI.axisLeft().scale(this._scale),this.ticks&&this._draw.ticks(t);break;case 1:this._draw=DI.axisRight().scale(this._scale),this.ticks&&this._draw.ticks(t)}}else if(this._hasTimeField()?this._scale=DI.scaleTime().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain([this._min,this._max]).clamp(this.clamp):this.useLog?this._scale=DI.scaleLog().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase).nice():null===this.measure||void 0===this.measure?(e=l(this,"x","y"),null!==this._slaves&&void 0!==this._slaves&&this._slaves.forEach((function(g){e=e.concat(l(g,"x","y"))}),this),this._scale=DI.scalePoint().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain(e.concat([""]))):this._scale=DI.scaleLinear().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain([this._min,this._max]).clamp(this.clamp).nice(),!this.hidden)switch(this.chart._axisIndex(this,"x")){case 0:this._draw=DI.axisBottom().scale(this._scale),this.ticks&&this._draw.ticks(t);break;case 1:this._draw=DI.axisTop().scale(this._scale),this.ticks&&this._draw.ticks(t)}return null!==this._slaves&&void 0!==this._slaves&&this._slaves.length>0&&this._slaves.forEach((function(g){g._scale=this._scale}),this),null!=g&&!1!==g||this._hasTimeField()||null===this._scale||null===this._scale.ticks||void 0===this._scale.ticks||!(this._scale.ticks(t).length>0)||"x"!==this.position&&"y"!==this.position||(C=(I=this._scale.ticks(t))[1]-I[0],A=((this._max-this._min)%C).toFixed(0),this._tick_step=C,0!==A&&(this._max=Math.ceil(this._max/C)*C,this._min=Math.floor(this._min/C)*C,this._update(!0))),i=null!=e&&e.length>0?this._scale.copy()(e[0]):this._min>0?this._scale.copy()(this._min):this._max<0?this._scale.copy()(this._max):this._scale.copy()(0),this._origin!==i&&(this._previousOrigin=null===this._origin?i:this._origin,this._origin=i),this},this.addGroupOrderRule=function(g,I){this._groupOrderRules.push({ordering:g,desc:I})},this.addOrderRule=function(g,I){this._orderRules.push({ordering:g,desc:I})}},chart:function(g,I){this.svg=g,this.x="10%",this.y="10%",this.width="80%",this.height="80%",this.data=I,this.noFormats=!1,this.axes=[],this.series=[],this.legends=[],this.storyboard=null,this.titleShape=null,this.shapes=null,this.ease=DI.easeCubicInOut,this.staggerDraw=!1,this.transition={},this._group=g.append("g"),this._group.attr("class","dimple-chart"),this._gridlines_group=this._group.insert("g"),this._gridlines_group.attr("class","dimple-gridlines-group"),this._axis_group=this._group.insert("g"),this._axis_group.attr("class","dimple-axis-group"),this._tooltipGroup=null,this._assignedColors={},this._assignedClasses={},this._nextColor=0,this._nextClass=0,this._axisIndex=function(g,I){var C=0,A=0,i=-1;for(C=0;C0&&(g=g.concat(this.data)),null!==this.series&&void 0!==this.series&&this.series.length>0&&this.series.forEach((function(I){null!==I.data&&void 0!==I.data&&I.data.length>0&&(g=g.concat(I.data))})),g},this._getData=function(g,I,C,A,i,e,t,l,s,o){var c,d,a=[],n=function(g,I){var C=[];return null!==g&&(g._hasTimeField()?C.push(g._parseDate(I[g.timeField])):g._hasCategories()&&g.categoryFields.forEach((function(g){C.push(I[g])}),this)),C},r={x:!1,y:!1,z:!1,p:!1,c:!1},m={x:[],y:[]},h={x:[],y:[],z:[],p:[]},Z={min:null,max:null},b={x:[],y:[],z:[],p:[]},G=[],u={},p={x:0,y:0,z:0,p:0},w="",W=[],B=[],y=[],V="",X=[],Y="",R=[],N="",H=[],K=[],f=g,F=[];for(d in this.storyboard&&this.storyboard.categoryFields.length>0&&(w=this.storyboard.categoryFields[0],W=iC._getOrderedList(f,w,this.storyboard._orderRules)),e&&e._hasCategories()&&e._hasMeasure()&&(V=e.categoryFields[0],X=iC._getOrderedList(f,V,e._orderRules.concat([{ordering:e.measure,desc:!0}]))),t&&t._hasCategories()&&t._hasMeasure()&&(Y=t.categoryFields[0],R=iC._getOrderedList(f,Y,t._orderRules.concat([{ordering:t.measure,desc:!0}]))),s&&s._hasCategories()&&s._hasMeasure()&&(N=s.categoryFields[0],H=iC._getOrderedList(f,N,s._orderRules.concat([{ordering:s.measure,desc:!0}]))),f.length>0&&I&&I.length>0&&(K=[].concat(A),B=[],I.forEach((function(g){void 0!==f[0][g]&&B.push(g)}),this),s&&s._hasMeasure()?K.push({ordering:s.measure,desc:!0}):o&&o._hasMeasure()?K.push({ordering:o.measure,desc:!0}):l&&l._hasMeasure()?K.push({ordering:l.measure,desc:!0}):e&&e._hasMeasure()?K.push({ordering:e.measure,desc:!0}):t&&t._hasMeasure()&&K.push({ordering:t.measure,desc:!0}),y=iC._getOrderedList(f,B,K)),f.sort((function(g,I){var C,A,i,e,t,l,s=0;if(""!==w&&(s=W.indexOf(g[w])-W.indexOf(I[w])),""!==V&&0===s&&(s=X.indexOf(g[V])-X.indexOf(I[V])),""!==Y&&0===s&&(s=R.indexOf(g[Y])-R.indexOf(I[Y])),""!==N&&0===s&&(s=H.indexOf(g[N])-R.indexOf(I[N])),B&&B.length>0&&0===s)for(C=[].concat(B),s=0,i=0;i0&&(o+="/"),o+=g[I],t=o===i}),this)),null!=I&&t&&(e=a[h],I._hasMeasure()&&null!==g[I.measure]&&void 0!==g[I.measure]&&(-1===e[I.position+"ValueList"].indexOf(g[I.measure])&&e[I.position+"ValueList"].push(g[I.measure]),isNaN(parseFloat(g[I.measure]))&&(r[I.position]=!0),l.value=e[I.position+"Value"],l.count=e[I.position+"Count"],s.value=g[I.measure],e[I.position+"Value"]=C(l,s),e[I.position+"Count"]+=1))})(e,this.storyboard),m(t,this.storyboard),m(l,this.storyboard),m(s,this.storyboard),m(o,this.storyboard)}),this),e&&e._hasCategories()&&e.categoryFields.length>1&&void 0!==m.x&&(F=[],t._hasMeasure()&&F.push({ordering:t.measure,desc:!0}),m.x=iC._getOrderedList(f,e.categoryFields[1],e._groupOrderRules.concat(F))),t&&t._hasCategories()&&t.categoryFields.length>1&&void 0!==m.y&&(F=[],e._hasMeasure()&&F.push({ordering:e.measure,desc:!0}),m.y=iC._getOrderedList(f,t.categoryFields[1],t._groupOrderRules.concat(F)),m.y.reverse()),a.forEach((function(g){null!==e&&(!0===r.x&&(g.xValue=g.xValueList.length),c=e._hasMeasure()&&e._hasCategories()?(h.x[g.xField.join("/")]||0)+(e._hasMeasure()?Math.abs(g.xValue):0):(h.x[g.xField.join("/")]||0)+(t._hasMeasure()?Math.abs(g.yValue):0),h.x[g.xField.join("/")]=c),null!==t&&(!0===r.y&&(g.yValue=g.yValueList.length),c=t._hasMeasure()&&t._hasCategories()?(h.y[g.yField.join("/")]||0)+(t._hasMeasure()?Math.abs(g.yValue):0):(h.y[g.yField.join("/")]||0)+(e._hasMeasure()?Math.abs(g.xValue):0),h.y[g.yField.join("/")]=c),null!==s&&(!0===r.p&&(g.pValue=g.pValueList.length),c=(h.p[g.pField.join("/")]||0)+(s._hasMeasure()?Math.abs(g.pValue):0),h.p[g.pField.join("/")]=c),null!==l&&(!0===r.z&&(g.zValue=g.zValueList.length),c=(h.z[g.zField.join("/")]||0)+(l._hasMeasure()?Math.abs(g.zValue):0),h.z[g.zField.join("/")]=c),null!==o&&((null===Z.min||g.cValueZ.max)&&(Z.max=g.cValue))}),this),h.x)Object.prototype.hasOwnProperty.call(h.x,d)&&(p.x+=h.x[d]);for(d in h.y)Object.prototype.hasOwnProperty.call(h.y,d)&&(p.y+=h.y[d]);for(d in h.p)Object.prototype.hasOwnProperty.call(h.p,d)&&(p.p+=h.p[d]);for(d in h.z)Object.prototype.hasOwnProperty.call(h.z,d)&&(p.z+=h.z[d]);return a.forEach((function(g){var I,C,A,c,d=function(I,C,A){var e,t,l,s,o;null!=I&&(s=I.position,I._hasCategories()?I._hasMeasure()?(e=g[I.position+"Field"].join("/"),t=I.showPercent?h[I.position][e]/p[I.position]:h[I.position][e],-1===G.indexOf(e)&&(u[e]=t+(G.length>0?u[G[G.length-1]]:0),G.push(e)),l=g[s+"Bound"]=g["c"+s]="x"!==s&&"y"!==s||!i?t:u[e],g[A]=t,g[s]=l-("x"===s&&t>=0||"y"===s&&t<=0?t:0)):(g[s]=g["c"+s]=g[s+"Field"][0],g[A]=1,void 0!==m[s]&&null!==m[s]&&m[s].length>=2&&(g[s+"Offset"]=m[s].indexOf(g[s+"Field"][1]),g[A]=1/m[s].length)):(t=I.showPercent?g[s+"Value"]/h[C][g[C+"Field"].join("/")]:g[s+"Value"],e=g[C+"Field"].join("/")+(g[s+"Value"]>=0),o=b[s][e]=(null===b[s][e]||void 0===b[s][e]||"z"===s||"p"===s?0:b[s][e])+t,l=g[s+"Bound"]=g["c"+s]="x"!==s&&"y"!==s||!i?t:o,g[A]=t,g[s]=l-("x"===s&&t>=0||"y"===s&&t<=0?t:0)))};d(e,"y","width"),d(t,"x","height"),d(l,"z","r"),d(s,"p","angle"),null!==o&&null!==Z.min&&null!==Z.max&&(Z.min===Z.max&&(Z.min-=.5,Z.max+=.5),Z.min=o.overrideMin||Z.min,Z.max=o.overrideMax||Z.max,g.cValue=g.cValue>Z.max?Z.max:g.cValue1?(I=DI.rgb(o.colors[Math.floor(A)]),C=DI.rgb(o.colors[Math.ceil(A)])):(I=DI.rgb("white"),C=DI.rgb(this.getColor(g.aggField.slice(-1)[0]).fill)),I.r=Math.floor(I.r+(C.r-I.r)*c),I.g=Math.floor(I.g+(C.g-I.g)*c),I.b=Math.floor(I.b+(C.b-I.b)*c),g.fill=I.toString(),g.stroke=I.darker(.5).toString())}),this),a},this._getDelay=function(g,I,C){return function(A){var i=0;return C&&I.staggerDraw&&(C.x._hasCategories()?i=iC._helpers.cx(A,I,C)/I._widthPixels()*g:C.y._hasCategories()&&(i=(1-iC._helpers.cy(A,I,C)/I._heightPixels())*g)),i}},this._getSeriesData=function(){null!==this.series&&void 0!==this.series&&this.series.forEach((function(g){var I,C,A,i,e,t=g.data||this.data||[],l=[].concat(g.categoryFields||"All"),s=this._getData(t,l,g.aggregate,g._orderRules,g._isStacked(),g.x,g.y,g.z,g.p,g.c),o=[],c={},d=g.startAngle*(Math.PI/180)||0,a=(g.endAngle||360)*(Math.PI/180);if(d>a&&(d-=2*Math.PI),g.p&&l.length>0){if(g.x&&g.y){for(l.pop(),o=this._getData(t,["__dimple_placeholder__"].concat(l),g.aggregate,g._orderRules,g._isStacked(),g.x,g.y,g.z,g.p,g.c),I=0;I0&&g._eventHandlers.forEach((function(I){var C,A=function(C){var A=new iC.eventArgs;null!==g.chart.storyboard&&(A.frameValue=g.chart.storyboard.getFrameValue()),A.seriesValue=C.aggField,A.xValue=C.x,A.yValue=C.y,A.zValue=C.z,A.pValue=C.p,A.colorValue=C.cValue,A.seriesShapes=g.shapes,A.selectedShape=DI.select(this),I.handler(A)};if(null!==I.handler&&"function"==typeof I.handler)if(null!==g._markers&&void 0!==g._markers)for(C in g._markers)Object.prototype.hasOwnProperty.call(g._markers,C)&&g._markers[C].on(I.event,A);else g.shapes.on(I.event,A)}),this)},this._widthPixels=function(){return iC._parseXPosition(this.width,this.svg.node())},this._xPixels=function(){return iC._parseXPosition(this.x,this.svg.node())},this._yPixels=function(){return iC._parseYPosition(this.y,this.svg.node())},this.addAxis=function(g,I,C,A){var i,e=null,t=null;if(null!=I&&(I=[].concat(I)),"string"==typeof g||g instanceof String)e=new iC.axis(this,g,I,C,A),this.axes.push(e);else{if(t=g,(e=new iC.axis(this,t.position,I,C,A))._hasMeasure()!==t._hasMeasure()?i="You have specified a composite axis where some but not all axes have a measure - this is not supported, all axes must be of the same type.":e._hasTimeField()!==t._hasTimeField()?i="You have specified a composite axis where some but not all axes have a time field - this is not supported, all axes must be of the same type.":(null===e.categoryFields||void 0===e.categoryFields?0:e.categoryFields.length)!==(null===t.categoryFields||void 0===t.categoryFields?0:t.categoryFields.length)&&(i="You have specified a composite axis where axes have differing numbers of category fields - this is not supported, all axes must be of the same type."),i)throw i;t._slaves.push(e)}return e},this.addCategoryAxis=function(g,I){return this.addAxis(g,I,null)},this.addColorAxis=function(g,I){var C=this.addAxis("c",null,g);return C.colors=null==I?null:[].concat(I),C},this.addLegend=function(g,I,C,A,i,e){e=null==e?this.series:[].concat(e),i=null==i?"left":i;var t=new iC.legend(this,g,I,C,A,i,e);return this.legends.push(t),t},this.addLogAxis=function(g,I,C){var A=this.addAxis(g,null,I,null);return null!=C&&(A.logBase=C),A.useLog=!0,A},this.addMeasureAxis=function(g,I){return this.addAxis(g,null,I)},this.addPctAxis=function(g,I,C){var A=null;return(A=null!=C?this.addAxis(g,C,I):this.addMeasureAxis(g,I)).showPercent=!0,A},this.addSeries=function(g,I,C){null==C&&(C=this.axes),null==I&&(I=iC.plot.bubble);var A,i=null,e=null,t=null,l=null,s=null;return C.forEach((function(g){null!==g&&I.supportedAxes.indexOf(g.position)>-1&&(null===i&&"x"===g.position[0]?i=g:null===e&&"y"===g.position[0]?e=g:null===t&&"z"===g.position[0]?t=g:null===l&&"c"===g.position[0]?l=g:null===l&&"p"===g.position[0]&&(s=g))}),this),g&&(g=[].concat(g)),A=new iC.series(this,g,i,e,t,l,s,I,iC.aggregateMethod.sum,I.stacked),this.series.push(A),A},this.addTimeAxis=function(g,I,C,A){var i=this.addAxis(g,null,null,I);return i.tickFormat=A,i.dateParseFormat=C,i},this.assignClass=function(g,I){return this._assignedClasses[g]=I,this._assignedClasses[g]},this.assignColor=function(g,I,C,A){return this._assignedColors[g]=new iC.color(I,C,A),this._assignedColors[g]},this.customClassList={axisLine:"dimple-custom-axis-line",axisLabel:"dimple-custom-axis-label",axisTitle:"dimple-custom-axis-title",tooltipBox:"dimple-custom-tooltip-box",tooltipLabel:"dimple-custom-tooltip-label",tooltipDropLine:"dimple-custom-tooltip-dropline",lineMarker:"dimple-custom-line-marker",lineMarkerCircle:"dimple-custom-line-marker-circle",legendLabel:"dimple-custom-legend-label",legendKey:"dimple-custom-legend-key",areaSeries:"dimple-custom-series-area",barSeries:"dimple-custom-series-bar",bubbleSeries:"dimple-custom-series-bubble",lineSeries:"dimple-custom-series-line",pieSeries:"dimple-custom-series-pie",gridline:"dimple-custom-gridline",colorClasses:["dimple-custom-format-1","dimple-custom-format-2","dimple-custom-format-3","dimple-custom-format-4","dimple-custom-format-5","dimple-custom-format-6","dimple-custom-format-7","dimple-custom-format-8","dimple-custom-format-9","dimple-custom-format-10"]},this.defaultColors=[new iC.color("#80B1D3"),new iC.color("#FB8072"),new iC.color("#FDB462"),new iC.color("#B3DE69"),new iC.color("#FFED6F"),new iC.color("#BC80BD"),new iC.color("#8DD3C7"),new iC.color("#CCEBC5"),new iC.color("#FFFFB3"),new iC.color("#BEBADA"),new iC.color("#FCCDE5"),new iC.color("#D9D9D9")],this.draw=function(g,I){g=g||0;var C,A,i=null,e=null,t=!1,l=!1,s=this._xPixels(),o=this._yPixels(),c=this._widthPixels(),d=this._heightPixels();return null!=I&&!1!==I||this._getSeriesData(),this.axes.forEach((function(g){g._scale=null}),this),this.axes.forEach((function(g){if(g._min=0,g._max=0,A=[],g._hasMeasure()){var I=!1;this.series.forEach((function(C){if(C._deepMatch(g)){var A=C._axisBounds(g.position);g._min>A.min&&(g._min=A.min),g._maxI[g.measure]&&(g._min=I[g.measure]),g._maxg._max)&&(g._max=A)}),this)}),this)):g._hasCategories()&&(g._min=0,C=[],this.series.forEach((function(I){I._deepMatch(g)&&null!==I[g.position].categoryFields[0]&&void 0!==I[g.position].categoryFields[0]&&-1===A.indexOf(I[g.position].categoryFields[0])&&A.push(I[g.position].categoryFields[0])}),this),g._getAxisData().forEach((function(g){A.forEach((function(I){-1===C.indexOf(g[I])&&C.push(g[I])}),this)}),this),g._max=C.length);null!==g._slaves&&void 0!==g._slaves&&g._slaves.length>0&&g._slaves.forEach((function(I){I._min=g._min,I._max=g._max}),this),g._update(),null===i&&"x"===g.position?i=g:null===e&&"y"===g.position&&(e=g)}),this),this.axes.forEach((function(I){var C=!1,A=null,a=0,n=null,r=!1,m=0,h={l:null,t:null,r:null,b:null},Z=0,b=0,G="",u=this,p=function(I){return null===A||0===g||C?I:u._handleTransition(I,g,u)},w=function(){var g=DI.select(this).selectAll("text");return!I.measure&&I._max>0&&("x"===I.position?g.attr("x",c/I._max/2):"y"===I.position&&g.attr("y",d/I._max*-1/2)),I.categoryFields&&I.categoryFields.length>0&&(I!==i||null!==e.categoryFields&&0!==e.categoryFields.length||g.attr("y",o+d-e._scale(0)+9),I!==e||null!==i.categoryFields&&0!==i.categoryFields.length||g.attr("x",-1*(i._scale(0)-s)-9)),this},W=function(g){return function(){var I=DI.select(this).attr("class")||"";return-1===I.indexOf(g)&&(I+=" "+g),I.trim()}};null===I.gridlineShapes?(I.showGridlines||null===I.showGridlines&&!I._hasCategories()&&(!t&&"x"===I.position||!l&&"y"===I.position))&&(I.gridlineShapes=this._gridlines_group.append("g").attr("class","dimple-gridline"),"x"===I.position?t=!0:l=!0):"x"===I.position?t=!0:l=!0,null===I.shapes&&(I.shapes=this._axis_group.append("g").attr("class","dimple-axis dimple-axis-"+I.position).each((function(){u.noFormats||DI.select(this).style("font-family",I.fontFamily).style("font-size",I._getFontSize())})),C=!0),I===i&&null!==e?(A="translate(0, "+(null===e.categoryFields||0===e.categoryFields.length?e._scale(0):o+d)+")",n="translate(0, "+(I===i?o+d:o)+")",a=-d):I===e&&null!==i?(A="translate("+(null===i.categoryFields||0===i.categoryFields.length?i._scale(0):s)+", 0)",n="translate("+(I===e?s:s+c)+", 0)",a=-c):"x"===I.position?(n=A="translate(0, "+(I===i?o+d:o)+")",a=-d):"y"===I.position&&(n=A="translate("+(I===e?s:s+c)+", 0)",a=-c),null!==A&&null!==I._draw&&(I._hasTimeField()?p(I.shapes).call(I._draw.ticks(I._getTimePeriod(),I.timeInterval).tickFormat(I._getFormat())).attr("transform",A).each(w):I.useLog?p(I.shapes).call(I._draw.ticks(4,I._getFormat())).attr("transform",A).each(w):p(I.shapes).call(I._draw.tickFormat(I._getFormat())).attr("transform",A).each(w),null!==I.gridlineShapes&&p(I.gridlineShapes).call(I._draw.tickSize(a,0,0).tickFormat("")).attr("transform",n)),p(I.shapes.selectAll("text")).attr("class",W(u.customClassList.axisLabel)).call((function(g){u.noFormats||g.style("font-family",I.fontFamily).style("font-size",I._getFontSize())})),p(I.shapes.selectAll("path, line")).attr("class",W(u.customClassList.axisLine)).call((function(g){u.noFormats||g.style("fill","none").style("stroke","black").style("shape-rendering","crispEdges")})),null!==I.gridlineShapes&&(I.gridlineShapes.selectAll("path").remove(),p(I.gridlineShapes.selectAll("line")).attr("class",W(u.customClassList.gridline)).call((function(g){u.noFormats||g.style("fill","none").style("stroke","lightgray").style("opacity",.8)}))),null!==I.measure&&void 0!==I.measure||(I.autoRotateLabel?I===i?(m=0,I.shapes.selectAll("text").each((function(){var g=this.getComputedTextLength();m=g>m?g:m})),m>c/I.shapes.selectAll("text").nodes().length?(r=!0,I.shapes.selectAll("text").style("text-anchor","start").each((function(){var g=this.getBBox();DI.select(this).attr("transform","rotate(90,"+g.x+","+(g.y+g.height/2)+") translate(-5, 0)")}))):(r=!1,I.shapes.selectAll("text").style("text-anchor","middle").attr("transform",""))):"x"===I.position&&(m=0,I.shapes.selectAll("text").each((function(){var g=this.getComputedTextLength();m=g>m?g:m})),m>c/I.shapes.selectAll("text").nodes().length?(r=!0,I.shapes.selectAll("text").style("text-anchor","end").each((function(){var g=this.getBBox();DI.select(this).attr("transform","rotate(90,"+(g.x+g.width)+","+(g.y+g.height/2)+") translate(5, 0)")}))):(r=!1,I.shapes.selectAll("text").style("text-anchor","middle").attr("transform",""))):(r=!1,I.shapes.selectAll("text").style("text-anchor","middle").attr("transform",""))),null!==I.titleShape&&void 0!==I.titleShape&&I.titleShape.remove(),I.shapes.selectAll("text").each((function(){var g=this.getBBox();(null===h.l||-9-g.widthh.r)&&(h.r=g.x+g.width),r?((null===h.t||g.y+g.height-g.widthh.b)&&(h.b=g.height+g.width)):((null===h.t||g.yh.b)&&(h.b=9+g.height))})),"x"===I.position?(b=I===i?o+d+h.b+5:o+h.t-10,Z=s+c/2):"y"===I.position&&(G="rotate(270, "+(Z=I===e?s+h.l-10:s+c+h.r+20)+", "+(b=o+d/2)+")"),I.hidden||"x"!==I.position&&"y"!==I.position||null===I.title||(I.titleShape=this._axis_group.append("text").attr("class","dimple-axis dimple-title "+u.customClassList.axisTitle+" dimple-axis-"+I.position),I.titleShape.attr("x",Z).attr("y",b).attr("text-anchor","middle").attr("transform",G).text(void 0!==I.title?I.title:null===I.categoryFields||void 0===I.categoryFields||0===I.categoryFields.length?I.measure:I.categoryFields.join("/")).each((function(){u.noFormats||DI.select(this).style("font-family",I.fontFamily).style("font-size",I._getFontSize())})),I===i?I.titleShape.each((function(){DI.select(this).attr("y",b+this.getBBox().height/1.65)})):I===e&&I.titleShape.each((function(){DI.select(this).attr("x",Z+this.getBBox().height/1.65)})))}),this),this.series.forEach((function(I){I.plot.draw(this,I,g),this._registerEventHandlers(I)}),this),this.legends.forEach((function(g){g._draw()}),this),this.storyboard&&(this.storyboard._drawText(),this.storyboard.autoplay&&this.storyboard.startAnimation()),this},this.getClass=function(g){return this._assignedClasses[g]||(this._assignedClasses[g]=this.customClassList.colorClasses[this._nextClass],this._nextClass=(this._nextClass+1)%this.customClassList.colorClasses.length),this._assignedClasses[g]},this.getColor=function(g){return null!==this._assignedColors[g]&&void 0!==this._assignedColors[g]||(this._assignedColors[g]=this.defaultColors[this._nextColor],this._nextColor=(this._nextColor+1)%this.defaultColors.length),this._assignedColors[g]},this.setBounds=function(g,I,C,A){return this.x=g,this.y=I,this.width=C,this.height=A,this._xPixels=function(){return iC._parseXPosition(this.x,this.svg.node())},this.draw(0,!0),this._yPixels=function(){return iC._parseYPosition(this.y,this.svg.node())},this._widthPixels=function(){return iC._parseXPosition(this.width,this.svg.node())},this._heightPixels=function(){return iC._parseYPosition(this.height,this.svg.node())},this},this.setMargins=function(g,I,C,A){return this.x=g,this.y=I,this.width=0,this.height=0,this._xPixels=function(){return iC._parseXPosition(this.x,this.svg.node())},this._yPixels=function(){return iC._parseYPosition(this.y,this.svg.node())},this._widthPixels=function(){return iC._parentWidth(this.svg.node())-this._xPixels()-iC._parseXPosition(C,this.svg.node())},this._heightPixels=function(){return iC._parentHeight(this.svg.node())-this._yPixels()-iC._parseYPosition(A,this.svg.node())},this},this.setStoryboard=function(g,I){return this.storyboard=new iC.storyboard(this,g),null!=I&&(this.storyboard.onTick=I),this.storyboard}},color:function(g,I,C){this.fill=g,this.stroke=null==I?DI.rgb(g).darker(.5).toString():I,this.opacity=null==C?.8:C},eventArgs:function(){this.seriesValue=null,this.xValue=null,this.yValue=null,this.zValue=null,this.pValue=null,this.colorValue=null,this.frameValue=null,this.seriesShapes=null,this.selectedShape=null},legend:function(g,I,C,A,i,e,t){this.chart=g,this.series=t,this.x=I,this.y=C,this.width=A,this.height=i,this.horizontalAlign=e,this.shapes=null,this.fontSize="10px",this.fontFamily="sans-serif",this._draw=function(){var g,I=this._getEntries(),C=0,A=0,i=0,e=0,t=this;this.shapes&&this.shapes.remove(),(g=this.chart._group.selectAll(".dimple-dont-select-any").data(I).enter().append("g").attr("class",(function(g){return"dimple-legend "+iC._createClass(g.aggField)})).attr("opacity",1)).append("text").attr("class",(function(g){return"dimple-legend dimple-legend-text "+iC._createClass(g.aggField)+" "+t.chart.customClassList.legendLabel})).text((function(g){return g.key})).call((function(g){t.chart.noFormats||g.style("font-family",t.fontFamily).style("font-size",t._getFontSize()).style("shape-rendering","crispEdges")})).each((function(){var g=this.getBBox();g.width>C&&(C=g.width),g.height>A&&(A=g.height)})),g.append("rect").attr("class",(function(g){return"dimple-legend dimple-legend-key "+iC._createClass(g.aggField)})).attr("height",9).attr("width",15),A=(A<9?9:A)+t._getVerticalPadding(),C+=15+t._getHorizontalPadding(),g.each((function(g){i+C>t._widthPixels()&&(i=0,e+=A),e>t._heightPixels()?DI.select(this).remove():(DI.select(this).select("text").attr("x","left"===t.horizontalAlign?t._xPixels()+15+5+i:t._xPixels()+(t._widthPixels()-i-C)+15+5).attr("y",(function(){return t._yPixels()+e+this.getBBox().height/1.65})).attr("width",t._widthPixels()).attr("height",t._heightPixels()),DI.select(this).select("rect").attr("class",(function(g){return"dimple-legend dimple-legend-key "+iC._createClass(g.aggField)+" "+t.chart.customClassList.legendKey+" "+g.css})).attr("x","left"===t.horizontalAlign?t._xPixels()+i:t._xPixels()+(t._widthPixels()-i-C)).attr("y",t._yPixels()+e).attr("height",9).attr("width",15).call((function(I){t.chart.noFormats||I.style("fill",g.fill).style("stroke",g.stroke).style("opacity",g.opacity).style("shape-rendering","crispEdges")})),i+=C)})),this.shapes=g},this._getEntries=function(){var g=[];return this.series&&this.series.forEach((function(I){I._positionData.forEach((function(C){var A,i=-1,e=I.plot.grouped&&!I.x._hasCategories()&&!I.y._hasCategories()&&C.aggField.length<2?"All":C.aggField.slice(-1)[0];for(A=0;A10?this.chart._heightPixels()/35:10)+"px"},this._getHorizontalPadding=function(){return isNaN(this.horizontalPadding)?20:this.horizontalPadding},this._getVerticalPadding=function(){return isNaN(this.verticalPadding)?2:this.verticalPadding},this._heightPixels=function(){return iC._parseYPosition(this.height,this.chart.svg.node())},this._widthPixels=function(){return iC._parseXPosition(this.width,this.chart.svg.node())},this._xPixels=function(){return iC._parseXPosition(this.x,this.chart.svg.node())},this._yPixels=function(){return iC._parseYPosition(this.y,this.chart.svg.node())}},series:function(g,I,C,A,i,e,t,l,s,o){this.chart=g,this.x=C,this.y=A,this.z=i,this.c=e,this.p=t,this.plot=l,this.categoryFields=I,this.aggregate=s,this.stacked=o,this.barGap=.2,this.clusterBarGap=.1,this.lineWeight=2,this.lineMarkers=!1,this.afterDraw=null,this.interpolation="linear",this.tooltipFontSize="10px",this.tooltipFontFamily="sans-serif",this.radius="auto",this._group=g._group.append("g"),this._group.attr("class","dimple-series-group-"+g.series.length),this._eventHandlers=[],this._positionData=[],this._orderRules=[],this._axisBounds=function(g){var I,C,A,i={min:0,max:0},e=null,t=null,l=[],s=this._positionData;return"x"===g?(e=this.x,t=this.y):"y"===g?(e=this.y,t=this.x):"z"===g?e=this.z:"p"===g?e=this.p:"c"===g&&(e=this.c),e.showPercent?s.forEach((function(g){g[e.position+"Bound"]i.max&&(i.max=g[e.position+"Bound"])}),this):null===t||null===t.categoryFields||0===t.categoryFields.length?s.forEach((function(g){!this._isStacked()||"x"!==e.position&&"y"!==e.position?(g[e.position+"Value"]i.max&&(i.max=g[e.position+"Value"])):g[e.position+"Value"]<0?i.min=i.min+g[e.position+"Value"]:i.max=i.max+g[e.position+"Value"]}),this):(I=e.position+"Value",C=t.position+"Field",A=[],s.forEach((function(g){var i=g[C].join("/"),e=A.indexOf(i);-1===e&&(A.push(i),e=A.length-1),void 0===l[e]&&(l[e]={min:0,max:0}),this.stacked?g[I]<0?l[e].min=l[e].min+g[I]:l[e].max=l[e].max+g[I]:(g[I]l[e].max&&(l[e].max=g[I]))}),this),l.forEach((function(g){void 0!==g&&(g.mini.max&&(i.max=g.max))}),this)),i},this._deepMatch=function(g){var I=!1;return this[g.position]===g?I=!0:void 0!==g._slaves&&null!==g._slaves&&g._slaves.length>0&&g._slaves.forEach((function(g){I=I||this._deepMatch(g)}),this),I},this._dropLineOrigin=function(){var g=0,I=0,C={x:null,y:null},A={x:null,y:null};return this.chart.axes.forEach((function(g){"x"===g.position&&null===A.x?g._hasTimeField()?A.x=this.chart._xPixels():A.x=g._origin:"y"===g.position&&null===A.y&&(g._hasTimeField()?A.y=this.chart._yPixels()+this.chart._heightPixels():A.y=g._origin)}),this),this.chart.axes.forEach((function(i){"x"!==i.position||this.x.hidden?"y"!==i.position||this.y.hidden||(this._deepMatch(i)&&(0===I?C.x=A.x:1===I&&(C.x=this.chart._xPixels()+this.chart._widthPixels())),I+=1):(this._deepMatch(i)&&(0===g?C.y=A.y:1===g&&(C.y=this.chart._yPixels())),g+=1)}),this),C},this._getTooltipFontSize=function(){return this.tooltipFontSize&&"auto"!==this.tooltipFontSize.toString().toLowerCase()?isNaN(this.tooltipFontSize)?this.tooltipFontSize:this.tooltipFontSize+"px":(this.chart._heightPixels()/35>10?this.chart._heightPixels()/35:10)+"px"},this._isStacked=function(){return this.stacked&&(this.x._hasCategories()||this.y._hasCategories())},this.addEventHandler=function(g,I){this._eventHandlers.push({event:g,handler:I})},this.addOrderRule=function(g,I){this._orderRules.push({ordering:g,desc:I})},this.getTooltipText=function(g){var I=[];return null!==this.categoryFields&&void 0!==this.categoryFields&&this.categoryFields.length>0&&this.categoryFields.forEach((function(C,A){null!=C&&null!==g.aggField[A]&&void 0!==g.aggField[A]&&I.push(C+(g.aggField[A]!==C?": "+g.aggField[A]:""))}),this),this.p?(this.x&&this.x._hasCategories()&&this.x._getTooltipText(I,g),this.y&&this.y._hasCategories()&&this.y._getTooltipText(I,g),this.z&&this.z._hasCategories()&&this.z._getTooltipText(I,g),this.p._getTooltipText(I,g)):(this.x&&this.x._getTooltipText(I,g),this.y&&this.y._getTooltipText(I,g),this.z&&this.z._getTooltipText(I,g)),this.c&&this.c._getTooltipText(I,g),I.filter((function(g,C){return I.indexOf(g)===C}))}},storyboard:function(g,I){null!=I&&(I=[].concat(I)),this.chart=g,this.categoryFields=I,this.autoplay=!0,this.frameDuration=3e3,this.storyLabel=null,this.onTick=null,this.fontSize="10px",this.fontFamily="sans-serif",this._frame=0,this._animationTimer=null,this._categories=[],this._cachedCategoryFields=[],this._orderRules=[],this._drawText=function(){var I=this,C=0;I.storyLabel||(I.chart.axes.forEach((function(g){"x"===g.position&&(C+=1)}),I),I.storyLabel=I.chart._group.append("text").attr("class","dimple-storyboard-label").attr("opacity",1).attr("x",I.chart._xPixels()+.01*I.chart._widthPixels()).attr("y",I.chart._yPixels()+(I.chart._heightPixels()/35>10?I.chart._heightPixels()/35:10)*(C>1?1.25:-1)).call((function(C){g.noFormats||C.style("font-family",I.fontFamily).style("font-size",I._getFontSize())}))),I.storyLabel.text(I.categoryFields.join("\\")+": "+I.getFrameValue())},this._getCategories=function(){return this._categoryFields!==this._cachedCategoryFields&&(this._categories=[],this.chart._getAllData().forEach((function(g){var I="";null!==this.categoryFields&&(this.categoryFields.forEach((function(C,A){A>0&&(I+="/"),I+=g[C]}),this),-1===this._categories.indexOf(I)&&(this._categories.push(I),this._categories.length))}),this),this._cachedCategoryFields=this._categoryFields),this._categories},this._getFontSize=function(){return this.fontSize&&"auto"!==this.fontSize.toString().toLowerCase()?isNaN(this.fontSize)?this.fontSize:this.fontSize+"px":(this.chart._heightPixels()/35>10?this.chart._heightPixels()/35:10)+"px"},this._goToFrameIndex=function(g){this._frame=g%this._getCategories().length,this.chart.draw(this.frameDuration/2)},this.addOrderRule=function(g,I){this._orderRules.push({ordering:g,desc:I})},this.getFrameValue=function(){var g=null;return this._frame>=0&&this._getCategories().length>this._frame&&(g=this._getCategories()[this._frame]),g},this.goToFrame=function(g){if(this._getCategories().length>0){var I=this._getCategories().indexOf(g);this._goToFrameIndex(I)}},this.pauseAnimation=function(){null!==this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null)},this.startAnimation=function(){null===this._animationTimer&&(null!==this.onTick&&this.onTick(this.getFrameValue()),this._animationTimer=setInterval(function(g){return function(){g._goToFrameIndex(g._frame+1),null!==g.onTick&&g.onTick(g.getFrameValue()),g._drawText(g.frameDuration/2)}}(this),this.frameDuration))},this.stopAnimation=function(){null!==this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null,this._frame=0)}}};iC.aggregateMethod.avg=function(g,I){return g.value=null===g.value||void 0===g.value?0:parseFloat(g.value),g.count=null===g.count||void 0===g.count?1:parseFloat(g.count),I.value=null===I.value||void 0===I.value?0:parseFloat(I.value),I.count=null===I.count||void 0===I.count?1:parseFloat(I.count),(g.value*g.count+I.value*I.count)/(g.count+I.count)},iC.aggregateMethod.count=function(g,I){return g.count=null===g.count||void 0===g.count?0:parseFloat(g.count),I.count=null===I.count||void 0===I.count?0:parseFloat(I.count),g.count+I.count},iC.aggregateMethod.max=function(g,I){return g.value=null===g.value||void 0===g.value?0:parseFloat(g.value),I.value=null===I.value||void 0===I.value?0:parseFloat(I.value),g.value>I.value?g.value:I.value},iC.aggregateMethod.min=function(g,I){return null===g.value?parseFloat(I.value):parseFloat(g.value)C&&i=2?X[i][y+"Field"][0]:"All"})),Y[o].data.push(X[i])}for(n&&Y.sort((function(g,I){return iC._arrayIndexCompare(n,g.key,I.key)})),i=0;i1&&y&&(I.x._hasCategories()?(r.push({x:2*r[r.length-1].x-r[r.length-2].x,y:r[r.length-1].y}),f[Y[i].group][r[r.length-1][y]]=I[V]._origin):I.y._hasCategories()&&(r=[{x:r[0].x,y:2*r[0].y-r[1].y}].concat(r),f[Y[i].group][r[0][y]]=I[V]._origin,Y[i].points=r))}for(Z in f)if(Object.prototype.hasOwnProperty.call(f,Z)){for(b in F[Z]=[],f[Z])Object.prototype.hasOwnProperty.call(f[Z],b)&&F[Z].push(parseFloat(b));F[Z].sort(D)}for(i=0;i0)for(e=0,t=0;e=r[0][y]&&F[G][e]<=r[r.length-1][y]&&((h={})[y]=F[G][e],h[V]=f[G][F[G][e]],m.push(h),r[t][y]>F[G][e]?M.push(h):(M.push(r[t]),f[Y[i].group][F[G][e]]=r[t][V],t+=1));else if(I._orderRules&&I._orderRules.length>0)M=r.concat(r[0]);else{r=r.sort(v),M.push(r[0]),B=0;do{B=L(r,M,B)}while(M.length<=r.length&&(M[0].x!==M[M.length-1].x||M[0].y!==M[M.length-1].y))}m=m.reverse(),u=k(A,"_previousOrigin")(M),p=k("step-after"===A?"step-before":"step-before"===A?"step-after":A,"_previousOrigin")(m),W=-1===(w=k("linear","_previousOrigin")(M)).indexOf("L")?void 0:w.indexOf("L"),Y[i].entry=u+(p&&p.length>0?"L"+p.substring(1):"")+(w&&w.length>0?"L"+w.substring(1,W):0),u=k(A)(M),p=k("step-after"===A?"step-before":"step-before"===A?"step-after":A)(m),W=-1===(w=k("linear")(M)).indexOf("L")?void 0:w.indexOf("L"),Y[i].update=u+(p&&p.length>0?"L"+p.substring(1):"")+(w&&w.length>0?"L"+w.substring(1,W):0),u=k(A,"_origin")(M),p=k("step-after"===A?"step-before":"step-before"===A?"step-after":A,"_origin")(m),W=-1===(w=k("linear","_origin")(M)).indexOf("L")?void 0:w.indexOf("L"),Y[i].exit=u+(p&&p.length>0?"L"+p.substring(1):"")+(w&&w.length>0?"L"+w.substring(1,W):0),Y[i].color=g.getColor(Y[i].key.length>0?Y[i].key[Y[i].key.length-1]:"All"),Y[i].css=g.getClass(Y[i].key.length>0?Y[i].key[Y[i].key.length-1]:"All")}g._tooltipGroup&&g._tooltipGroup.remove(),c=(R=I.shapes?I.shapes.data(Y,(function(g){return g.key})):I._group.selectAll("."+N).data(Y,(function(g){return g.key}))).enter().append("path").attr("id",(function(g){return iC._createClass([g.key])})).attr("class",(function(I){return N+" dimple-line "+I.keyString+" "+g.customClassList.areaSeries+" "+I.css})).attr("d",(function(g){return g.entry})).call((function(C){g.noFormats||C.attr("opacity",(function(g){return K?1:g.color.opacity})).style("fill",(function(g){return K?"url(#"+iC._createClass(["fill-area-gradient-"+g.keyString])+")":g.color.fill})).style("stroke",(function(g){return K?"url(#"+iC._createClass(["stroke-area-gradient-"+g.keyString])+")":g.color.stroke})).style("stroke-width",I.lineWeight)})).each((function(g){g.markerData=g.data,S(g,this)})),d=g._handleTransition(R.merge(c),C,g).attr("d",(function(g){return g.update})).each((function(g){g.markerData=g.data,S(g,this)})),a=g._handleTransition(R.exit(),C,g).attr("d",(function(g){return g.exit})).each((function(g){g.markerData=[],S(g,this)})),iC._postDrawHandling(I,d,a,C),I.shapes=I._group.selectAll("."+N)}},iC.plot.bar={stacked:!0,grouped:!1,supportedAxes:["x","y","c"],draw:function(g,I,C){var A,i,e,t=I._positionData,l=null,s=["dimple-series-"+g.series.indexOf(I),"dimple-bar"],o=!I._isStacked()&&I.x._hasMeasure(),c=!I._isStacked()&&I.y._hasMeasure(),d="none";I.x._hasCategories()&&I.y._hasCategories()?d="both":I.x._hasCategories()?d="x":I.y._hasCategories()&&(d="y"),g._tooltipGroup&&g._tooltipGroup.remove(),A=(l=I.shapes?I.shapes.data(t,(function(g){return g.key})):I._group.selectAll("."+s.join(".")).data(t,(function(g){return g.key}))).enter().append("rect").attr("id",(function(g){return iC._createClass([g.key])})).attr("class",(function(I){var C=[];return C=(C=(C=C.concat(I.aggField)).concat(I.xField)).concat(I.yField),s.join(" ")+" "+iC._createClass(C)+" "+g.customClassList.barSeries+" "+iC._helpers.css(I,g)})).attr("x",(function(C){var A=I.x._previousOrigin;return"x"===d?A=iC._helpers.x(C,g,I):"both"===d&&(A=iC._helpers.cx(C,g,I)),A})).attr("y",(function(C){var A=I.y._previousOrigin;return"y"===d?A=iC._helpers.y(C,g,I):"both"===d&&(A=iC._helpers.cy(C,g,I)),A})).attr("width",(function(C){return"x"===d?iC._helpers.width(C,g,I):0})).attr("height",(function(C){return"y"===d?iC._helpers.height(C,g,I):0})).on("mouseover",(function(C){iC._showBarTooltip(C,this,g,I)})).on("mouseleave",(function(C){iC._removeTooltip(C,this,g,I)})).call((function(C){g.noFormats||C.attr("opacity",(function(C){return iC._helpers.opacity(C,g,I)})).style("fill",(function(C){return iC._helpers.fill(C,g,I)})).style("stroke",(function(C){return iC._helpers.stroke(C,g,I)}))})),i=g._handleTransition(l.merge(A),C,g,I).attr("x",(function(C){return o?iC._helpers.cx(C,g,I)-I.x.floatingBarWidth/2:iC._helpers.x(C,g,I)})).attr("y",(function(C){return c?iC._helpers.cy(C,g,I)-I.y.floatingBarWidth/2:iC._helpers.y(C,g,I)})).attr("width",(function(C){return o?I.x.floatingBarWidth:iC._helpers.width(C,g,I)})).attr("height",(function(C){return c?I.y.floatingBarWidth:iC._helpers.height(C,g,I)})).call((function(C){g.noFormats||C.attr("fill",(function(C){return iC._helpers.fill(C,g,I)})).attr("stroke",(function(C){return iC._helpers.stroke(C,g,I)}))})),e=g._handleTransition(l.exit(),C,g,I).attr("x",(function(C){var A=I.x._origin;return"x"===d?A=iC._helpers.x(C,g,I):"both"===d&&(A=iC._helpers.cx(C,g,I)),A})).attr("y",(function(C){var A=I.y._origin;return"y"===d?A=iC._helpers.y(C,g,I):"both"===d&&(A=iC._helpers.cy(C,g,I)),A})).attr("width",(function(C){return"x"===d?iC._helpers.width(C,g,I):0})).attr("height",(function(C){return"y"===d?iC._helpers.height(C,g,I):0})),iC._postDrawHandling(I,i,e,C),I.shapes=I._group.selectAll("."+s.join("."))}},iC.plot.bubble={stacked:!1,grouped:!1,supportedAxes:["x","y","z","c"],draw:function(g,I,C){var A,i,e,t=I._positionData,l=null,s=["dimple-series-"+g.series.indexOf(I),"dimple-bubble"];g._tooltipGroup&&g._tooltipGroup.remove(),A=(l=I.shapes?I.shapes.data(t,(function(g){return g.key})):I._group.selectAll("."+s.join(".")).data(t,(function(g){return g.key}))).enter().append("circle").attr("id",(function(g){return iC._createClass([g.key])})).attr("class",(function(I){var C=[];return C=(C=(C=(C=C.concat(I.aggField)).concat(I.xField)).concat(I.yField)).concat(I.zField),s.join(" ")+" "+iC._createClass(C)+" "+g.customClassList.bubbleSeries+" "+iC._helpers.css(I,g)})).attr("cx",(function(C){return I.x._hasCategories()?iC._helpers.cx(C,g,I):I.x._previousOrigin})).attr("cy",(function(C){return I.y._hasCategories()?iC._helpers.cy(C,g,I):I.y._previousOrigin})).attr("r",0).on("mouseover",(function(C){iC._showPointTooltip(C,this,g,I)})).on("mouseleave",(function(C){iC._removeTooltip(C,this,g,I)})).call((function(C){g.noFormats||C.attr("opacity",(function(C){return iC._helpers.opacity(C,g,I)})).style("fill",(function(C){return iC._helpers.fill(C,g,I)})).style("stroke",(function(C){return iC._helpers.stroke(C,g,I)}))})),i=g._handleTransition(l.merge(A),C,g,I).attr("cx",(function(C){return iC._helpers.cx(C,g,I)})).attr("cy",(function(C){return iC._helpers.cy(C,g,I)})).attr("r",(function(C){return iC._helpers.r(C,g,I)})).call((function(C){g.noFormats||C.attr("fill",(function(C){return iC._helpers.fill(C,g,I)})).attr("stroke",(function(C){return iC._helpers.stroke(C,g,I)}))})),e=g._handleTransition(l.exit(),C,g,I).attr("r",0).attr("cx",(function(C){return I.x._hasCategories()?iC._helpers.cx(C,g,I):I.x._origin})).attr("cy",(function(C){return I.y._hasCategories()?iC._helpers.cy(C,g,I):I.y._origin})),iC._postDrawHandling(I,i,e,C),I.shapes=I._group.selectAll("."+s.join("."))}},iC.plot.line={stacked:!1,grouped:!0,supportedAxes:["x","y","c"],draw:function(g,I,C){var A,i,e,t,l,s,o,c,d,a,n,r=I._positionData,m=[],h=null,Z="dimple-series-"+g.series.indexOf(I),b=I.x._hasCategories()||I.y._hasCategories()?0:1,G=!1,u=function(A,i){var e;iC._drawMarkers(A,g,I,C,Z,G,(function(g,I,C,A){DI.select(I).style("opacity",1),iC._showPointTooltip(g,I,C,A)}),(e=A,function(g,I,C,A){DI.select(I).style("opacity",A.lineMarkers||e.data.length<2?iC._helpers.opacity(g,C,A):0),iC._removeTooltip(g,I,C,A)}),i)},p=function(C,A){var i;return"step"===I.interpolation&&I[C]._hasCategories()?(I.barGap=0,I.clusterBarGap=0,i=iC._helpers[C](A,g,I)+("y"===C?iC._helpers.height(A,g,I):0)):i=iC._helpers["c"+C](A,g,I),parseFloat(i.toFixed(1))},w=function(g,C){var A=DI.line().x((function(g){return I.x._hasCategories()||!C?g.x:I.x[C]})).y((function(g){return I.y._hasCategories()||!C?g.y:I.y[C]}));return iC._interpolate(A,g),A};for(A="step"===I.interpolation?"step-after":I.interpolation,n=iC._getSeriesOrder(I.data||g.data,I),I.c&&(I.x._hasCategories()&&I.y._hasMeasure()||I.y._hasCategories()&&I.x._hasMeasure())&&(G=!0),i=0;i1&&(I.x._hasCategories()?m[i].points.push({x:2*m[i].points[m[i].points.length-1].x-m[i].points[m[i].points.length-2].x,y:m[i].points[m[i].points.length-1].y}):I.y._hasCategories()&&(m[i].points=[{x:m[i].points[0].x,y:2*m[i].points[0].y-m[i].points[1].y}].concat(m[i].points))),m&&m[i]&&m[i].points&&1===m[i].points.length&&m[i].points.push({x:m[i].points[0].x,y:m[i].points[0].y}),m[i].entry=w(A,"_previousOrigin")(m[i].points),m[i].update=w(A)(m[i].points),m[i].exit=w(A,"_origin")(m[i].points),m[i].color=g.getColor(m[i].key.length>0?m[i].key[m[i].key.length-1]:"All"),m[i].css=g.getClass(m[i].key.length>0?m[i].key[m[i].key.length-1]:"All")}g._tooltipGroup&&g._tooltipGroup.remove(),c=(h=I.shapes?I.shapes.data(m,(function(g){return g.key})):I._group.selectAll("."+Z).data(m,(function(g){return g.key}))).enter().append("path").attr("id",(function(g){return iC._createClass([g.key])})).attr("class",(function(I){return Z+" dimple-line "+I.keyString+" "+g.customClassList.lineSeries+" "+I.css})).attr("d",(function(g){return g.entry})).call((function(C){g.noFormats||C.attr("opacity",(function(g){return G?1:g.color.opacity})).style("fill","none").style("stroke",(function(g){return G?"url(#"+iC._createClass(["fill-line-gradient-"+g.keyString])+")":g.color.stroke})).style("stroke-width",I.lineWeight)})).each((function(g){g.markerData=g.data,u(g,this)})),d=g._handleTransition(h.merge(c),C,g).attr("d",(function(g){return g.update})).each((function(g){g.markerData=g.data,u(g,this)})),a=g._handleTransition(h.exit(),C,g).attr("d",(function(g){return g.exit})).each((function(g){g.markerData=[],u(g,this)})),iC._postDrawHandling(I,d,a,C),I.shapes=I._group.selectAll("."+Z)}},iC.plot.pie={stacked:!1,grouped:!1,supportedAxes:["x","y","c","z","p"],draw:function(g,I,C){var A,i,e,t=I._positionData,l=null,s=["dimple-series-"+g.series.indexOf(I),"dimple-pie"],o=function(C){return I.x&&I.y?iC._helpers.r(C,g,I):g._widthPixels()0?A.attrTween("d",n):A.attr("d",a),g.noFormats||A.attr("fill",(function(C){return iC._helpers.fill(C,g,I)})).attr("stroke",(function(C){return iC._helpers.stroke(C,g,I)}))})).attr("transform",r(!1)),e=g._handleTransition(l.exit(),C,g,I).attr("transform",r(!0)).attr("d",a),iC._postDrawHandling(I,i,e,C),I.shapes=I._group.selectAll("."+s.join("."))}},iC._addGradient=function(g,I,C,A,i,e,t){var l=[].concat(g),s=i.svg.select("#"+iC._createClass([I])),o=[],c=C.position+"Field",d=!0,a=[];A.forEach((function(g){-1===o.indexOf(g[c])&&g.aggField.join("_")===l.join("_")&&o.push(g[c])}),this),o=o.sort((function(g,I){return C._scale(g)-C._scale(I)})),null===s.node()&&(d=!1,s=i.svg.append("defs").append("linearGradient").attr("id",iC._createClass([I])).attr("gradientUnits","userSpaceOnUse").attr("x1","x"===C.position?C._scale(o[0])+i._widthPixels()/o.length/2:0).attr("y1","y"===C.position?C._scale(o[0])-i._heightPixels()/o.length/2:0).attr("x2","x"===C.position?C._scale(o[o.length-1])+i._widthPixels()/o.length/2:0).attr("y2","y"===C.position?C._scale(o[o.length-1])-i._heightPixels()/o.length/2:0)),o.forEach((function(g,I){var C={},i=0;for(i=0;i=65&&I<=90&&(C=g.toLowerCase()),C},g.length>0)for(I=0;I0?g.aggField[g.aggField.length-1]:"All");return C.x._hasCategories()&&(A=A.concat(g.xField)),C.y._hasCategories()&&(A=A.concat(g.yField)),iC._createClass(A)+" "+a.join(" ")+" "+I.customClassList.lineMarker+" "+i})).on("mouseover",(function(g){t(g,this,I,C)})).on("mouseleave",(function(g){l(g,this,I,C)})).attr("cx",(function(g){return C.x._hasCategories()?iC._helpers.cx(g,I,C):C.x._previousOrigin})).attr("cy",(function(g){return C.y._hasCategories()?iC._helpers.cy(g,I,C):C.y._previousOrigin})).attr("r",0).attr("opacity",C.lineMarkers||g.data.length<2?g.color.opacity:0).call((function(A){I.noFormats||A.attr("fill","white").style("stroke-width",C.lineWeight).attr("stroke",(function(A){return e?iC._helpers.fill(A,I,C):g.color.stroke}))})),I._handleTransition(o.merge(d),A,I).attr("cx",(function(g){return iC._helpers.cx(g,I,C)})).attr("cy",(function(g){return iC._helpers.cy(g,I,C)})).attr("r",2+C.lineWeight).attr("opacity",C.lineMarkers||g.data.length<2?g.color.opacity:0).call((function(A){I.noFormats||A.attr("fill","white").style("stroke-width",C.lineWeight).attr("stroke",(function(A){return e?iC._helpers.fill(A,I,C):g.color.stroke}))})),c=I._handleTransition(o.exit(),A,I).attr("cx",(function(g){return C.x._hasCategories()?iC._helpers.cx(g,I,C):C.x._origin})).attr("cy",(function(g){return C.y._hasCategories()?iC._helpers.cy(g,I,C):C.y._origin})).attr("r",0),0===A?c.remove():c.each("end",(function(){DI.select(this).remove()})),void 0!==C._markers&&null!==C._markers||(C._markers={}),C._markers[g.keyString]=o,iC._drawMarkerBacks(g,I,C,A,i,s)},iC._ease=function(g,I){if(g&&I&&"[object String]"===Object.prototype.toString.call(I)){switch(I){case"linear":I=DI.easeLinear;break;case"poly":I=DI.easePoly;break;case"quad":I=DI.easeQuad;break;case"cubic":I=DI.easeCubic;break;case"sin":I=DI.easeSin;break;case"exp":I=DI.easeExp;break;case"circle":I=DI.easeCircle;break;case"elastic":I=DI.easeElastic;break;case"back":I=DI.easeBack;break;case"bounce":I=DI.easeBounce}g.ease(I)}},iC._getOrderedList=function(g,I,C){var A,i=[],e=[],t=[].concat(I),l=[].concat(I),s=[];return null!=C&&(s=s.concat(C)),(s=s.concat({ordering:t,desc:!1})).forEach((function(I){var C,A=[],i=[];if("function"==typeof I.ordering){if(g&&g.length>0)for(C in g[0])Object.prototype.hasOwnProperty.call(g[0],C)&&-1===l.indexOf(C)&&l.push(C)}else if(I.ordering instanceof Array){for(C=0;C0&&Object.prototype.hasOwnProperty.call(g[0],I.ordering[C])&&i.push(I.ordering[C]),A.push(I.ordering[C]);i.length>A.length/2?l.concat(i):I.values=A}else l.push(I.ordering)}),this),A=iC._rollUp(g,t,l),s.length>=1&&(s.forEach((function(g){var I=null!==g.desc&&void 0!==g.desc&&g.desc,C=g.ordering,A=[],e=function(g){var I,C=0;for(I=0;I0?(g.values.forEach((function(g){A.push([].concat(g).join("|"))}),this),i.push((function(g,C){var i,e,l,s="",o="";for(l=0;l0&&(s+="|",o+="|"),s+=g[t[l]],o+=C[t[l]];return i=A.indexOf(s),e=A.indexOf(o),i=i<0?I?-1:A.length:i,e=e<0?I?-1:A.length:e,(I?-1:1)*(i-e)}))):[].concat(g.ordering).forEach((function(g){i.push((function(C,A){var i=0;return void 0!==C[g]&&void 0!==A[g]&&(i=function(g,I){var C=0,A=e(g),i=e(I);return isNaN(A)||isNaN(i)?isNaN(Date.parse(g[0]))||isNaN(Date.parse(I[0]))?g[0]I[0]&&(C=1):C=Date.parse(g[0])-Date.parse(I[0]):C=parseFloat(A)-parseFloat(i),C}([].concat(C[g]),[].concat(A[g]))),(I?-1:1)*i}))}))})),A.sort((function(g,I){for(var C=0,A=0;C0&&(null!==I.c&&void 0!==I.c&&I.c._hasMeasure()&&C.push({ordering:I.c.measure,desc:!0}),I.x._hasMeasure()&&C.push({ordering:I.x.measure,desc:!0}),I.y._hasMeasure()&&C.push({ordering:I.y.measure,desc:!0}),i=iC._getOrderedList(g,A,C)),i},iC._getSeriesSortPredicate=function(g,I,C){return function(A,i){var e=0;return I.x._hasCategories()&&(e=iC._helpers.cx(A,g,I)-iC._helpers.cx(i,g,I)),0===e&&I.y._hasCategories()&&(e=iC._helpers.cy(A,g,I)-iC._helpers.cy(i,g,I)),0===e&&C&&(e=iC._arrayIndexCompare(C,A.aggField,i.aggField)),e}},iC._helpers={cx:function(g,I,C){return null!==C.x.measure&&void 0!==C.x.measure?C.x._scale(g.cx):C.x._hasCategories()&&C.x.categoryFields.length>=2?C.x._scale(g.cx)+iC._helpers.xGap(I,C)+(g.xOffset+.5)*((I._widthPixels()/C.x._max-2*iC._helpers.xGap(I,C))*g.width):C.x._scale(g.cx)+I._widthPixels()/C.x._max/2},cy:function(g,I,C){return null!==C.y.measure&&void 0!==C.y.measure?C.y._scale(g.cy):null!==C.y.categoryFields&&void 0!==C.y.categoryFields&&C.y.categoryFields.length>=2?C.y._scale(g.cy)-I._heightPixels()/C.y._max+iC._helpers.yGap(I,C)+(g.yOffset+.5)*((I._heightPixels()/C.y._max-2*iC._helpers.yGap(I,C))*g.height):C.y._scale(g.cy)-I._heightPixels()/C.y._max/2},r:function(g,I,C){var A=0,i=1;return null===C.z||void 0===C.z?A=C.radius&&"auto"!==C.radius?C.radius:5:(C.radius&&"auto"!==C.radius&&C.radius>1&&(i=C.radius/C.z._scale(C.z._max)),A=C.z._hasMeasure()?C.z._scale(g.r)*i:C.z._scale(I._heightPixels()/100)*i),A},xGap:function(g,I){var C=0;return(null===I.x.measure||void 0===I.x.measure)&&I.barGap>0&&(C=g._widthPixels()/I.x._max*(I.barGap>.99?.99:I.barGap)/2),C},xClusterGap:function(g,I,C){var A=0;return null!==C.x.categoryFields&&void 0!==C.x.categoryFields&&C.x.categoryFields.length>=2&&C.clusterBarGap>0&&!C.x._hasMeasure()&&(A=g.width*(I._widthPixels()/C.x._max-2*iC._helpers.xGap(I,C))*(C.clusterBarGap>.99?.99:C.clusterBarGap)/2),A},yGap:function(g,I){var C=0;return(null===I.y.measure||void 0===I.y.measure)&&I.barGap>0&&(C=g._heightPixels()/I.y._max*(I.barGap>.99?.99:I.barGap)/2),C},yClusterGap:function(g,I,C){var A=0;return null!==C.y.categoryFields&&void 0!==C.y.categoryFields&&C.y.categoryFields.length>=2&&C.clusterBarGap>0&&!C.y._hasMeasure()&&(A=g.height*(I._heightPixels()/C.y._max-2*iC._helpers.yGap(I,C))*(C.clusterBarGap>.99?.99:C.clusterBarGap)/2),A},x:function(g,I,C){return C.x._hasTimeField()?C.x._scale(g.x)-iC._helpers.width(g,I,C)/2:null!==C.x.measure&&void 0!==C.x.measure?C.x._scale(g.x):C.x._scale(g.x)+iC._helpers.xGap(I,C)+g.xOffset*(iC._helpers.width(g,I,C)+2*iC._helpers.xClusterGap(g,I,C))+iC._helpers.xClusterGap(g,I,C)},y:function(g,I,C){return C.y._hasTimeField()?C.y._scale(g.y)-iC._helpers.height(g,I,C)/2:null!==C.y.measure&&void 0!==C.y.measure?C.y._scale(g.y):C.y._scale(g.y)-I._heightPixels()/C.y._max+iC._helpers.yGap(I,C)+g.yOffset*(iC._helpers.height(g,I,C)+2*iC._helpers.yClusterGap(g,I,C))+iC._helpers.yClusterGap(g,I,C)},width:function(g,I,C){return null!==C.x.measure&&void 0!==C.x.measure?Math.abs(C.x._scale(g.x<0?g.x-g.width:g.x+g.width)-C.x._scale(g.x)):C.x._hasTimeField()?C.x.floatingBarWidth:g.width*(I._widthPixels()/C.x._max-2*iC._helpers.xGap(I,C))-2*iC._helpers.xClusterGap(g,I,C)},height:function(g,I,C){return C.y._hasTimeField()?C.y.floatingBarWidth:null!==C.y.measure&&void 0!==C.y.measure?Math.abs(C.y._scale(g.y)-C.y._scale(g.y<=0?g.y+g.height:g.y-g.height)):g.height*(I._heightPixels()/C.y._max-2*iC._helpers.yGap(I,C))-2*iC._helpers.yClusterGap(g,I,C)},opacity:function(g,I,C){return null!==C.c&&void 0!==C.c?g.opacity:I.getColor(g.aggField.slice(-1)[0]).opacity},fill:function(g,I,C){return null!==C.c&&void 0!==C.c?g.fill:I.getColor(g.aggField.slice(-1)[0]).fill},stroke:function(g,I,C){return null!==C.c&&void 0!==C.c?g.stroke:I.getColor(g.aggField.slice(-1)[0]).stroke},css:function(g,I){return I.getClass(g.aggField.slice(-1)[0])}},iC._interpolate=function(g,I){if(g&&I){if("[object String]"===Object.prototype.toString.call(I))switch(I){case"linear":I=DI.curveLinear;break;case"linear-closed":I=DI.curveLinearClosed;break;case"step":I=DI.curveStep;break;case"step-before":I=DI.curveStepBefore;break;case"step-after":I=DI.curveStepAfter;break;case"basis":I=DI.curveBasis;break;case"basis-open":I=DI.curveBasisOpen;break;case"basis-closed":I=DI.curveBasisClosed;break;case"bundle":I=DI.curveBundle;break;case"cardinal":I=DI.curveCardinal;break;case"cardinal-open":I=DI.curveCardinalOpen;break;case"cardinal-closed":I=DI.curveCardinalClosed;break;case"monotone":I=DI.curveMonotoneX}g.curve(I)}},iC._parentHeight=function(g){var I=g.getBoundingClientRect().height;return(!I||I<0)&&(I=g.clientHeight),I},iC._parentWidth=function(g){var I=g.getBoundingClientRect().width;return(!I||I<0)&&(I=g.clientWidth),I},iC._parsePosition=function(g,I){var C=0;return g&&g.toString().split(",").forEach((function(A){A&&(isNaN(A)?"%"===A.slice(-1)?C+=I*(parseFloat(A.slice(0,A.length-1))/100):"px"===A.slice(-2)?C+=parseFloat(A.slice(0,A.length-2)):C=g:C+=parseFloat(A))}),this),C<0&&(C=I+C),C},iC._parseXPosition=function(g,I){return iC._parsePosition(g,iC._parentWidth(I))},iC._parseYPosition=function(g,I){return iC._parsePosition(g,iC._parentHeight(I))},iC._postDrawHandling=function(g,I,C,A){0===A?(I.each((function(I,C){g.afterDraw&&g.afterDraw(this,I,C)})),C.remove()):(I.on("end",(function(I,C){g.afterDraw&&g.afterDraw(this,I,C)})),C.call((function(){g.shapes&&g.shapes.exit().remove()})))},iC._removeTooltip=function(g,I,C,A){C._tooltipGroup&&C._tooltipGroup.remove()},iC._rollUp=function(g,I,C){var A=[];return I=null!=I?[].concat(I):[],g.forEach((function(g){var i=-1,e={},t=!0;A.forEach((function(C,A){-1===i&&(t=!0,I.forEach((function(I){t=t&&g[I]===C[I]}),this),t&&(i=A))}),this),-1!==i?e=A[i]:(I.forEach((function(I){e[I]=g[I]}),this),A.push(e),i=A.length-1),C.forEach((function(C){-1===I.indexOf(C)&&(void 0===e[C]&&(e[C]=[]),e[C]=e[C].concat(g[C]))}),this),A[i]=e}),this),A},iC._showBarTooltip=function(g,I,C,A){var i,e,t,l,s,o,c=10,d=DI.select(I),a=d.node().getBBox().x,n=d.node().getBBox().y,r=d.node().getBBox().width,m=d.node().getBBox().height,h=d.attr("opacity"),Z=d.attr("fill"),b=A._dropLineOrigin(),G=DI.rgb(DI.rgb(Z).r+.6*(255-DI.rgb(Z).r),DI.rgb(Z).g+.6*(255-DI.rgb(Z).g),DI.rgb(Z).b+.6*(255-DI.rgb(Z).b)),u=DI.rgb(DI.rgb(Z).r+.8*(255-DI.rgb(Z).r),DI.rgb(Z).g+.8*(255-DI.rgb(Z).g),DI.rgb(Z).b+.8*(255-DI.rgb(Z).b)),p=A.getTooltipText(g),w=0,W=0,B=0,y=function(g,I){var A=d.node().getCTM(),i=C.svg.node().createSVGPoint();return i.x=g||0,i.y=I||0,i.matrixTransform(A)};null!==C._tooltipGroup&&void 0!==C._tooltipGroup&&C._tooltipGroup.remove(),C._tooltipGroup=C.svg.append("g"),A.p||(o=A._isStacked()?1:r/2,A.x._hasCategories()||null===b.y||C._tooltipGroup.append("line").attr("class","dimple-tooltip-dropline "+C.customClassList.tooltipDropLine).attr("x1",aW?this.getBBox().width:W,B=this.getBBox().width>B?this.getBBox().height:B})),i.selectAll("text").attr("x",0).attr("y",(function(){return(w+=this.getBBox().height)-this.getBBox().height/2})),e.attr("x",-5).attr("y",-5).attr("height",Math.floor(w+5)-.5).attr("width",W+10).attr("rx",5).attr("ry",5).call((function(g){C.noFormats||g.style("fill",u).style("stroke",G).style("stroke-width",2).style("opacity",.95)})),y(a+r+5+c+W).x0?(t=a-(15+W),l=n+m/2-(w-(B-5))/2):y(0,n+m+w+c+5).y0?t:c)+W0?t:c)+WG?this.getBBox().width:G,u=this.getBBox().width>u?this.getBBox().height:u})),i.selectAll("text").attr("x",0).attr("y",(function(){return(b+=this.getBBox().height)-this.getBBox().height/2})),e.attr("x",-5).attr("y",-5).attr("height",Math.floor(b+5)-.5).attr("width",G+10).attr("rx",5).attr("ry",5).call((function(g){C.noFormats||g.style("fill",Z).style("stroke",h).style("stroke-width",2).style("opacity",.95)})),c+a+5+s+G0?(t=c-a-(15+G),l=d-(b-(u-5))/2):d+a+b+s+50?t:s)+G0?t:s)+G-1)&&A.push(g)}),this)),A},iC.getUniqueValues=function(g,I){var C=[];return null!=I&&(I=[].concat(I),g.forEach((function(g){var A="";I.forEach((function(I,C){C>0&&(A+="/"),A+=g[I]}),this),-1===C.indexOf(A)&&C.push(A)}),this)),C},iC.newSvg=function(g,I,C){var A=null;if(null==g&&(g="body"),(A=DI.select(g)).empty())throw"The '"+g+"' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class";return A.append("svg").attr("width",I).attr("height",C)};const eC=(g,I,C)=>{null!=g&&void 0!==g||(g="body");const A=DI.select(g);if(A.empty())throw"The '"+g+"' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class";return A.append("svg").attr("width",I).attr("height",C)},tC=Object.freeze(Object.defineProperty({__proto__:null,renderPptx:g=>{if("undefined"!=typeof window){const{pptx:I,resultElement:A,thumbElement:e,onError:t,onLoad:l}=g,s=document.createElement("div");s.setAttribute("class","r-preview-pptx-main"),A.innerHTML="",A.appendChild(s);let o=!1;return new Promise(((g,A)=>{const i={postMessage:postMessage};AC((g=>{i.postMessage=g}),(I=>{if(o)return;const i=document.createElement("div"),c=document.createElement("style");switch(I.type){case"slide":i.innerHTML=I.data,s.appendChild(i);break;case"pptx-thumb":e&&(null==e||e.setAttribute("src",`data:image/jpeg;base64,${I.data}`));break;case"slideSize":break;case"globalCSS":c.innerHTML=I.data,s.appendChild(c);break;case"Done":o=!0,function(g){for(let I=0;I{const I=()=>{const g=Math.max(...Array.from(s.children).filter((g=>"section"===g.nodeName)).map((g=>g.offsetWidth))),I=s.children[0].offsetWidth;s.setAttribute("style",`transform: scale(${I/g}),transform-origin': 'top left'`)};return I(),window.addEventListener("resize",I),i(document.getElementsByClassName("block")),i(document.getElementsByTagName("td")),g}))}function I(g){const I=[],C=[],A=[];return g.forEach(((g,i)=>{const e=g.key;A[i]=g.key,g.values.forEach(((A,i)=>{const t=g.xlabels[i];C[i]=g.xlabels[i],I.push({name:t,group:e,value:A.y})}))})),{data:I,xLabels:C,groupLabels:A}}function C(g){const C=g.chartID,A=g.chartType,i=g.chartData;let e=[];switch(A){case"lineChart":{const{data:g,xLabels:A,groupLabels:t}=I(i);e=g;const l=document.getElementById(C)||document.body,s=l&&eC(`#${C}`,l.style.width,l.style.height),o=new iC.chart(s,e),c=o.addCategoryAxis("x","name");c.addOrderRule(A),c.addGroupOrderRule(t),c.title=null;o.addMeasureAxis("y","value").title=null,o.addSeries("group",iC.plot.line),o.addLegend(60,10,500,20,"right"),o.draw();break}case"barChart":{const{data:g,xLabels:A,groupLabels:t}=I(i);e=g;const l=document.getElementById(C)||document.body,s=eC("#"+C,l.style.width,l.style.height),o=new iC.chart(s,e),c=o.addCategoryAxis("x",["name","group"]);c.addOrderRule(A),c.addGroupOrderRule(t),c.title=null;o.addMeasureAxis("y","value").title=null,o.addSeries("group",iC.plot.bar),o.addLegend(60,10,500,20,"right"),o.draw();break}case"pieChart":case"pie3DChart":{const{data:g,groupLabels:A}=I(i);e=g;const t=document.getElementById(C)||document.body,l=eC(`#${C}`,t.style.width,t.style.height),s=new iC.chart(l,e);s.addMeasureAxis("p","value").addOrderRule(A),s.addSeries("name",iC.plot.pie),s.addLegend(50,20,400,300,"left"),s.draw();break}case"areaChart":{const{data:g,xLabels:A,groupLabels:t}=I(i);e=g;const l=document.getElementById(C)||document.body,s=eC("#"+C,l.style.width,l.style.height),o=new iC.chart(s,e),c=o.addCategoryAxis("x","name");c.addOrderRule(A),c.addGroupOrderRule(t),c.title=null;o.addMeasureAxis("y","value").title=null,o.addSeries("group",iC.plot.area),o.addLegend(60,10,500,20,"right"),o.draw();break}case"scatterChart":for(let g=0;g{g.forEach((g=>{g.children.length>0&&A(Array.from(g.children)),Array.from(g.classList).includes(I)&&C.push(g)}))};return g.children.length>0&&A(Array.from(g.children)),C}function i(g){const I=Array.from(g);for(let C=0;C0){let I="",C="",A=0;const i=[];let t=0;const l=[];for(let s=0;sNumber(C)?(I=o,C=c,t++,i[t]=A,l[t]=o,A=1):o!==I&&Number(c){const A=C[0];if(parseInt(A.toString())>0)for(;g>=Number(A);g-=Number(A))I+=C[1];else I=I.replace(A.toString(),C[1])})),I}});var s;function o(g,I){g=Number(g)-1;let C="";return"upperCase"===I?C=((g/26>=1?String.fromCharCode(g/26+64):"")+String.fromCharCode(g%26+65)).toUpperCase():"lowerCase"===I&&(C=((g/26>=1?String.fromCharCode(g/26+64):"")+String.fromCharCode(g%26+65)).toLowerCase()),C}}},Symbol.toStringTag,{value:"Module"}));var lC="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function sC(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function oC(g){throw new Error('Could not dynamically require "'+g+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var cC={exports:{}}; /*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */cC.exports=function g(I,C,A){function i(t,l){if(!C[t]){if(!I[t]){if(!l&&oC)return oC(t);if(e)return e(t,!0);var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}var o=C[t]={exports:{}};I[t][0].call(o.exports,(function(g){return i(I[t][1][g]||g)}),o,o.exports,g,I,C,A)}return C[t].exports}for(var e=oC,t=0;t>2,l=(3&I)<<4|C>>4,s=1>6:64,o=2>4,C=(15&t)<<4|(l=e.indexOf(g.charAt(o++)))>>2,A=(3&l)<<6|(s=e.indexOf(g.charAt(o++))),a[c++]=I,64!==l&&(a[c++]=C),64!==s&&(a[c++]=A);return a}},{"./support":30,"./utils":32}],2:[function(g,I,C){var A=g("./external"),i=g("./stream/DataWorker"),e=g("./stream/Crc32Probe"),t=g("./stream/DataLengthProbe");function l(g,I,C,A,i){this.compressedSize=g,this.uncompressedSize=I,this.crc32=C,this.compression=A,this.compressedContent=i}l.prototype={getContentWorker:function(){var g=new i(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new t("data_length")),I=this;return g.on("end",(function(){if(this.streamInfo.data_length!==I.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),g},getCompressedWorker:function(){return new i(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,I,C){return g.pipe(new e).pipe(new t("uncompressedSize")).pipe(I.compressWorker(C)).pipe(new t("compressedSize")).withStreamInfo("compression",I)},I.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(g,I,C){var A=g("./stream/GenericWorker");C.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},C.DEFLATE=g("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(g,I,C){var A=g("./utils"),i=function(){for(var g,I=[],C=0;C<256;C++){g=C;for(var A=0;A<8;A++)g=1&g?3988292384^g>>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I){return void 0!==g&&g.length?"string"!==A.getTypeOf(g)?function(g,I,C,A){var e=i,t=A+C;g^=-1;for(var l=A;l>>8^e[255&(g^I[l])];return~g}(0|I,g,g.length,0):function(g,I,C,A){var e=i,t=A+C;g^=-1;for(var l=A;l>>8^e[255&(g^I.charCodeAt(l))];return~g}(0|I,g,g.length,0):0}},{"./utils":32}],5:[function(g,I,C){C.base64=!1,C.binary=!1,C.dir=!1,C.createFolders=!0,C.date=null,C.compression=null,C.compressionOptions=null,C.comment=null,C.unixPermissions=null,C.dosPermissions=null},{}],6:[function(g,I,C){var A=null;A="undefined"!=typeof Promise?Promise:g("lie"),I.exports={Promise:A}},{lie:37}],7:[function(g,I,C){var A="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=g("pako"),e=g("./utils"),t=g("./stream/GenericWorker"),l=A?"uint8array":"array";function s(g,I){t.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=I,this.meta={}}C.magic="\b\0",e.inherits(s,t),s.prototype.processChunk=function(g){this.meta=g.meta,null===this._pako&&this._createPako(),this._pako.push(e.transformTo(l,g.data),!1)},s.prototype.flush=function(){t.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},s.prototype.cleanUp=function(){t.prototype.cleanUp.call(this),this._pako=null},s.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(I){g.push({data:I,meta:g.meta})}},C.compressWorker=function(g){return new s("Deflate",g)},C.uncompressWorker=function(){return new s("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(g,I,C){function A(g,I){var C,A="";for(C=0;C>>=8;return A}function i(g,I,C,i,t,c){var d,a,n=g.file,r=g.compression,m=c!==l.utf8encode,h=e.transformTo("string",c(n.name)),Z=e.transformTo("string",l.utf8encode(n.name)),b=n.comment,G=e.transformTo("string",c(b)),u=e.transformTo("string",l.utf8encode(b)),p=Z.length!==n.name.length,w=u.length!==b.length,W="",B="",y="",V=n.dir,X=n.date,Y={crc32:0,compressedSize:0,uncompressedSize:0};I&&!C||(Y.crc32=g.crc32,Y.compressedSize=g.compressedSize,Y.uncompressedSize=g.uncompressedSize);var R=0;I&&(R|=8),m||!p&&!w||(R|=2048);var N,H,K,f=0,F=0;V&&(f|=16),"UNIX"===t?(F=798,f|=(N=n.unixPermissions,H=V,K=N,N||(K=H?16893:33204),(65535&K)<<16)):(F=20,f|=function(g){return 63&(g||0)}(n.dosPermissions)),d=X.getUTCHours(),d<<=6,d|=X.getUTCMinutes(),d<<=5,d|=X.getUTCSeconds()/2,a=X.getUTCFullYear()-1980,a<<=4,a|=X.getUTCMonth()+1,a<<=5,a|=X.getUTCDate(),p&&(B=A(1,1)+A(s(h),4)+Z,W+="up"+A(B.length,2)+B),w&&(y=A(1,1)+A(s(G),4)+u,W+="uc"+A(y.length,2)+y);var M="";return M+="\n\0",M+=A(R,2),M+=r.magic,M+=A(d,2),M+=A(a,2),M+=A(Y.crc32,4),M+=A(Y.compressedSize,4),M+=A(Y.uncompressedSize,4),M+=A(h.length,2),M+=A(W.length,2),{fileRecord:o.LOCAL_FILE_HEADER+M+h+W,dirRecord:o.CENTRAL_FILE_HEADER+A(F,2)+M+A(G.length,2)+"\0\0\0\0"+A(f,4)+A(i,4)+h+W+G}}var e=g("../utils"),t=g("../stream/GenericWorker"),l=g("../utf8"),s=g("../crc32"),o=g("../signature");function c(g,I,C,A){t.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=I,this.zipPlatform=C,this.encodeFileName=A,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}e.inherits(c,t),c.prototype.push=function(g){var I=g.meta.percent||0,C=this.entriesCount,A=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,t.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:C?(I+100*(C-A-1))/C:100}}))},c.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var I=this.streamFiles&&!g.file.dir;if(I){var C=i(g,I,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:C.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(g){this.accumulate=!1;var I,C=this.streamFiles&&!g.file.dir,e=i(g,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(e.dirRecord),C)this.push({data:(I=g,o.DATA_DESCRIPTOR+A(I.crc32,4)+A(I.compressedSize,4)+A(I.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:e.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var g=this.bytesWritten,I=0;I=this.index;I--)C=(C<<8)+this.byteAt(I);return this.index+=g,C},readString:function(g){return A.transformTo("string",this.readData(g))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var g=this.readInt(4);return new Date(Date.UTC(1980+(g>>25&127),(g>>21&15)-1,g>>16&31,g>>11&31,g>>5&63,(31&g)<<1))}},I.exports=i},{"../utils":32}],19:[function(g,I,C){var A=g("./Uint8ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(g,I,C){var A=g("./DataReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.byteAt=function(g){return this.data.charCodeAt(this.zero+g)},i.prototype.lastIndexOfSignature=function(g){return this.data.lastIndexOf(g)-this.zero},i.prototype.readAndCheckSignature=function(g){return g===this.readData(4)},i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./DataReader":18}],21:[function(g,I,C){var A=g("./ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){if(this.checkOffset(g),0===g)return new Uint8Array(0);var I=this.data.subarray(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(g,I,C){var A=g("../utils"),i=g("../support"),e=g("./ArrayReader"),t=g("./StringReader"),l=g("./NodeBufferReader"),s=g("./Uint8ArrayReader");I.exports=function(g){var I=A.getTypeOf(g);return A.checkSupport(I),"string"!==I||i.uint8array?"nodebuffer"===I?new l(g):i.uint8array?new s(A.transformTo("uint8array",g)):new e(A.transformTo("array",g)):new t(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(g,I,C){C.LOCAL_FILE_HEADER="PK",C.CENTRAL_FILE_HEADER="PK",C.CENTRAL_DIRECTORY_END="PK",C.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",C.ZIP64_CENTRAL_DIRECTORY_END="PK",C.DATA_DESCRIPTOR="PK\b"},{}],24:[function(g,I,C){var A=g("./GenericWorker"),i=g("../utils");function e(g){A.call(this,"ConvertWorker to "+g),this.destType=g}i.inherits(e,A),e.prototype.processChunk=function(g){this.push({data:i.transformTo(this.destType,g.data),meta:g.meta})},I.exports=e},{"../utils":32,"./GenericWorker":28}],25:[function(g,I,C){var A=g("./GenericWorker"),i=g("../crc32");function e(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g("../utils").inherits(e,A),e.prototype.processChunk=function(g){this.streamInfo.crc32=i(g.data,this.streamInfo.crc32||0),this.push(g)},I.exports=e},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataLengthProbe for "+g),this.propName=g,this.withStreamInfo(g,0)}A.inherits(e,i),e.prototype.processChunk=function(g){if(g){var I=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=I+g.data.length}i.prototype.processChunk.call(this,g)},I.exports=e},{"../utils":32,"./GenericWorker":28}],27:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataWorker");var I=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,g.then((function(g){I.dataIsReady=!0,I.data=g,I.max=g&&g.length||0,I.type=A.getTypeOf(g),I.isPaused||I._tickAndRepeat()}),(function(g){I.error(g)}))}A.inherits(e,i),e.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},e.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},e.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},e.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var g=null,I=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":g=this.data.substring(this.index,I);break;case"uint8array":g=this.data.subarray(this.index,I);break;case"array":case"nodebuffer":g=this.data.slice(this.index,I)}return this.index=I,this.push({data:g,meta:{percent:this.max?this.index/this.max*100:0}})},I.exports=e},{"../utils":32,"./GenericWorker":28}],28:[function(g,I,C){function A(g){this.name=g||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}A.prototype={push:function(g){this.emit("data",g)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(g){this.emit("error",g)}return!0},error:function(g){return!this.isFinished&&(this.isPaused?this.generatedError=g:(this.isFinished=!0,this.emit("error",g),this.previous&&this.previous.error(g),this.cleanUp()),!0)},on:function(g,I){return this._listeners[g].push(I),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(g,I){if(this._listeners[g])for(var C=0;C "+g:g}},I.exports=A},{}],29:[function(g,I,C){var A=g("../utils"),i=g("./ConvertWorker"),e=g("./GenericWorker"),t=g("../base64"),l=g("../support"),s=g("../external"),o=null;if(l.nodestream)try{o=g("../nodejs/NodejsStreamOutputAdapter")}catch(a){}function c(g,I){return new s.Promise((function(C,i){var e=[],l=g._internalType,s=g._outputType,o=g._mimeType;g.on("data",(function(g,C){e.push(g),I&&I(C)})).on("error",(function(g){e=[],i(g)})).on("end",(function(){try{var g=function(g,I,C){switch(g){case"blob":return A.newBlob(A.transformTo("arraybuffer",I),C);case"base64":return t.encode(I);default:return A.transformTo(g,I)}}(s,function(g,I){var C,A=0,i=null,e=0;for(C=0;C>>6:(C<65536?I[t++]=224|C>>>12:(I[t++]=240|C>>>18,I[t++]=128|C>>>12&63),I[t++]=128|C>>>6&63),I[t++]=128|63&C);return I}(g)},C.utf8decode=function(g){return i.nodebuffer?A.transformTo("nodebuffer",g).toString("utf-8"):function(g){var I,C,i,e,t=g.length,s=new Array(2*t);for(I=C=0;I>10&1023,s[C++]=56320|1023&i)}return s.length!==C&&(s.subarray?s=s.subarray(0,C):s.length=C),A.applyFromCharCode(s)}(g=A.transformTo(i.uint8array?"uint8array":"array",g))},A.inherits(o,t),o.prototype.processChunk=function(g){var I=A.transformTo(i.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var e=I;(I=new Uint8Array(e.length+this.leftOver.length)).set(this.leftOver,0),I.set(e,this.leftOver.length)}else I=this.leftOver.concat(I);this.leftOver=null}var t=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+l[g[C]]>I?C:I}(I),s=I;t!==I.length&&(i.uint8array?(s=I.subarray(0,t),this.leftOver=I.subarray(t,I.length)):(s=I.slice(0,t),this.leftOver=I.slice(t,I.length))),this.push({data:C.utf8decode(s),meta:g.meta})},o.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:C.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},C.Utf8DecodeWorker=o,A.inherits(c,t),c.prototype.processChunk=function(g){this.push({data:C.utf8encode(g.data),meta:g.meta})},C.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(g,I,C){var A=g("./support"),i=g("./base64"),e=g("./nodejsUtils"),t=g("./external");function l(g){return g}function s(g,I){for(var C=0;C>8;this.dir=!!(16&this.externalFileAttributes),0==g&&(this.dosPermissions=63&this.externalFileAttributes),3==g&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=A(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var I,C,A,i=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4>>6:(C<65536?I[t++]=224|C>>>12:(I[t++]=240|C>>>18,I[t++]=128|C>>>12&63),I[t++]=128|C>>>6&63),I[t++]=128|63&C);return I},C.buf2binstring=function(g){return s(g,g.length)},C.binstring2buf=function(g){for(var I=new A.Buf8(g.length),C=0,i=I.length;C>10&1023,o[A++]=56320|1023&i)}return s(o,A)},C.utf8border=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+t[g[C]]>I?C:I}},{"./common":41}],43:[function(g,I,C){I.exports=function(g,I,C,A){for(var i=65535&g,e=g>>>16&65535,t=0;0!==C;){for(C-=t=2e3>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I,C,i){var e=A,t=i+C;g^=-1;for(var l=i;l>>8^e[255&(g^I[l])];return~g}},{}],46:[function(g,I,C){var A,i=g("../utils/common"),e=g("./trees"),t=g("./adler32"),l=g("./crc32"),s=g("./messages"),o=0,c=4,d=0,a=-2,n=-1,r=4,m=2,h=8,Z=9,b=286,G=30,u=19,p=2*b+1,w=15,W=3,B=258,y=B+W+1,V=42,X=113,Y=1,R=2,N=3,H=4;function K(g,I){return g.msg=s[I],I}function f(g){return(g<<1)-(4g.avail_out&&(C=g.avail_out),0!==C&&(i.arraySet(g.output,I.pending_buf,I.pending_out,C,g.next_out),g.next_out+=C,I.pending_out+=C,g.total_out+=C,g.avail_out-=C,I.pending-=C,0===I.pending&&(I.pending_out=0))}function S(g,I){e._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,I),g.block_start=g.strstart,M(g.strm)}function J(g,I){g.pending_buf[g.pending++]=I}function k(g,I){g.pending_buf[g.pending++]=I>>>8&255,g.pending_buf[g.pending++]=255&I}function D(g,I){var C,A,i=g.max_chain_length,e=g.strstart,t=g.prev_length,l=g.nice_match,s=g.strstart>g.w_size-y?g.strstart-(g.w_size-y):0,o=g.window,c=g.w_mask,d=g.prev,a=g.strstart+B,n=o[e+t-1],r=o[e+t];g.prev_length>=g.good_match&&(i>>=2),l>g.lookahead&&(l=g.lookahead);do{if(o[(C=I)+t]===r&&o[C+t-1]===n&&o[C]===o[e]&&o[++C]===o[e+1]){e+=2,C++;do{}while(o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&es&&0!=--i);return t<=g.lookahead?t:g.lookahead}function v(g){var I,C,A,e,s,o,c,d,a,n,r=g.w_size;do{if(e=g.window_size-g.lookahead-g.strstart,g.strstart>=r+(r-y)){for(i.arraySet(g.window,g.window,r,r,0),g.match_start-=r,g.strstart-=r,g.block_start-=r,I=C=g.hash_size;A=g.head[--I],g.head[I]=r<=A?A-r:0,--C;);for(I=C=r;A=g.prev[--I],g.prev[I]=r<=A?A-r:0,--C;);e+=r}if(0===g.strm.avail_in)break;if(o=g.strm,c=g.window,d=g.strstart+g.lookahead,n=void 0,(a=e)<(n=o.avail_in)&&(n=a),C=0===n?0:(o.avail_in-=n,i.arraySet(c,o.input,o.next_in,n,d),1===o.state.wrap?o.adler=t(o.adler,c,n,d):2===o.state.wrap&&(o.adler=l(o.adler,c,n,d)),o.next_in+=n,o.total_in+=n,n),g.lookahead+=C,g.lookahead+g.insert>=W)for(s=g.strstart-g.insert,g.ins_h=g.window[s],g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W)if(A=e._tr_tally(g,g.strstart-g.match_start,g.match_length-W),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=W){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W&&g.match_length<=g.prev_length){for(i=g.strstart+g.lookahead-W,A=e._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-W),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=i&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(C=g.pending_buf_size-5);;){if(g.lookahead<=1){if(v(g),0===g.lookahead&&I===o)return Y;if(0===g.lookahead)break}g.strstart+=g.lookahead,g.lookahead=0;var A=g.block_start+C;if((0===g.strstart||g.strstart>=A)&&(g.lookahead=g.strstart-A,g.strstart=A,S(g,!1),0===g.strm.avail_out))return Y;if(g.strstart-g.block_start>=g.w_size-y&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===c?(S(g,!0),0===g.strm.avail_out?N:H):(g.strstart>g.block_start&&(S(g,!1),g.strm.avail_out),Y)})),new T(4,4,8,4,L),new T(4,5,16,8,L),new T(4,6,32,32,L),new T(4,4,16,16,z),new T(8,16,32,32,z),new T(8,16,128,128,z),new T(8,32,128,256,z),new T(32,128,258,1024,z),new T(32,258,258,4096,z)],C.deflateInit=function(g,I){return Q(g,I,h,15,8,0)},C.deflateInit2=Q,C.deflateReset=j,C.deflateResetKeep=U,C.deflateSetHeader=function(g,I){return g&&g.state?2!==g.state.wrap?a:(g.state.gzhead=I,d):a},C.deflate=function(g,I){var C,i,t,s;if(!g||!g.state||5>8&255),J(i,i.gzhead.time>>16&255),J(i,i.gzhead.time>>24&255),J(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),J(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(J(i,255&i.gzhead.extra.length),J(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(g.adler=l(g.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(J(i,0),J(i,0),J(i,0),J(i,0),J(i,0),J(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),J(i,3),i.status=X);else{var n=h+(i.w_bits-8<<4)<<8;n|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(n|=32),n+=31-n%31,i.status=X,k(i,n),0!==i.strstart&&(k(i,g.adler>>>16),k(i,65535&g.adler)),g.adler=1}if(69===i.status)if(i.gzhead.extra){for(t=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),M(g),t=i.pending,i.pending!==i.pending_buf_size));)J(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),M(g),t=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindext&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),M(g),t=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindext&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&M(g),i.pending+2<=i.pending_buf_size&&(J(i,255&g.adler),J(i,g.adler>>8&255),g.adler=0,i.status=X)):i.status=X),0!==i.pending){if(M(g),0===g.avail_out)return i.last_flush=-1,d}else if(0===g.avail_in&&f(I)<=f(C)&&I!==c)return K(g,-5);if(666===i.status&&0!==g.avail_in)return K(g,-5);if(0!==g.avail_in||0!==i.lookahead||I!==o&&666!==i.status){var r=2===i.strategy?function(g,I){for(var C;;){if(0===g.lookahead&&(v(g),0===g.lookahead)){if(I===o)return Y;break}if(g.match_length=0,C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===c?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):3===i.strategy?function(g,I){for(var C,A,i,t,l=g.window;;){if(g.lookahead<=B){if(v(g),g.lookahead<=B&&I===o)return Y;if(0===g.lookahead)break}if(g.match_length=0,g.lookahead>=W&&0g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=W?(C=e._tr_tally(g,1,g.match_length-W),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===c?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):A[i.level].func(i,I);if(r!==N&&r!==H||(i.status=666),r===Y||r===N)return 0===g.avail_out&&(i.last_flush=-1),d;if(r===R&&(1===I?e._tr_align(i):5!==I&&(e._tr_stored_block(i,0,0,!1),3===I&&(F(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),M(g),0===g.avail_out))return i.last_flush=-1,d}return I!==c?d:i.wrap<=0?1:(2===i.wrap?(J(i,255&g.adler),J(i,g.adler>>8&255),J(i,g.adler>>16&255),J(i,g.adler>>24&255),J(i,255&g.total_in),J(i,g.total_in>>8&255),J(i,g.total_in>>16&255),J(i,g.total_in>>24&255)):(k(i,g.adler>>>16),k(i,65535&g.adler)),M(g),0=C.w_size&&(0===l&&(F(C.head),C.strstart=0,C.block_start=0,C.insert=0),n=new i.Buf8(C.w_size),i.arraySet(n,I,r-C.w_size,C.w_size,0),I=n,r=C.w_size),s=g.avail_in,o=g.next_in,c=g.input,g.avail_in=r,g.next_in=0,g.input=I,v(C);C.lookahead>=W;){for(A=C.strstart,e=C.lookahead-(W-1);C.ins_h=(C.ins_h<>>=u=G>>>24,r-=u,0==(u=G>>>16&255))V[e++]=65535&G;else{if(!(16&u)){if(!(64&u)){G=m[(65535&G)+(n&(1<>>=u,r-=u),r<15&&(n+=y[A++]<>>=u=G>>>24,r-=u,!(16&(u=G>>>16&255))){if(!(64&u)){G=h[(65535&G)+(n&(1<>>=u,r-=u,(u=e-t)>3,n&=(1<<(r-=p<<3))-1,g.next_in=A,g.next_out=e,g.avail_in=A>>24&255)+(g>>>8&65280)+((65280&g)<<8)+((255&g)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Z(g){var I;return g&&g.state?(I=g.state,g.total_in=g.total_out=I.total=0,g.msg="",I.wrap&&(g.adler=1&I.wrap),I.mode=a,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new A.Buf32(n),I.distcode=I.distdyn=new A.Buf32(r),I.sane=1,I.back=-1,c):d}function b(g){var I;return g&&g.state?((I=g.state).wsize=0,I.whave=0,I.wnext=0,Z(g)):d}function G(g,I){var C,A;return g&&g.state?(A=g.state,I<0?(C=0,I=-I):(C=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15=t.wsize?(A.arraySet(t.window,I,C-t.wsize,t.wsize,0),t.wnext=0,t.whave=t.wsize):(i<(e=t.wsize-t.wnext)&&(e=i),A.arraySet(t.window,I,C-i,e,t.wnext),(i-=e)?(A.arraySet(t.window,I,C-i,i,0),t.wnext=i,t.whave=t.wsize):(t.wnext+=e,t.wnext===t.wsize&&(t.wnext=0),t.whave>>8&255,C.check=e(C.check,v,2,0),p=u=0,C.mode=2;break}if(C.flags=0,C.head&&(C.head.done=!1),!(1&C.wrap)||(((255&u)<<8)+(u>>8))%31){g.msg="incorrect header check",C.mode=30;break}if(8!=(15&u)){g.msg="unknown compression method",C.mode=30;break}if(p-=4,M=8+(15&(u>>>=4)),0===C.wbits)C.wbits=M;else if(M>C.wbits){g.msg="invalid window size",C.mode=30;break}C.dmax=1<>8&1),512&C.flags&&(v[0]=255&u,v[1]=u>>>8&255,C.check=e(C.check,v,2,0)),p=u=0,C.mode=3;case 3:for(;p<32;){if(0===b)break g;b--,u+=n[h++]<>>8&255,v[2]=u>>>16&255,v[3]=u>>>24&255,C.check=e(C.check,v,4,0)),p=u=0,C.mode=4;case 4:for(;p<16;){if(0===b)break g;b--,u+=n[h++]<>8),512&C.flags&&(v[0]=255&u,v[1]=u>>>8&255,C.check=e(C.check,v,2,0)),p=u=0,C.mode=5;case 5:if(1024&C.flags){for(;p<16;){if(0===b)break g;b--,u+=n[h++]<>>8&255,C.check=e(C.check,v,2,0)),p=u=0}else C.head&&(C.head.extra=null);C.mode=6;case 6:if(1024&C.flags&&(b<(V=C.length)&&(V=b),V&&(C.head&&(M=C.head.extra_len-C.length,C.head.extra||(C.head.extra=new Array(C.head.extra_len)),A.arraySet(C.head.extra,n,h,V,M)),512&C.flags&&(C.check=e(C.check,n,V,h)),b-=V,h+=V,C.length-=V),C.length))break g;C.length=0,C.mode=7;case 7:if(2048&C.flags){if(0===b)break g;for(V=0;M=n[h+V++],C.head&&M&&C.length<65536&&(C.head.name+=String.fromCharCode(M)),M&&V>9&1,C.head.done=!0),g.adler=C.check=0,C.mode=12;break;case 10:for(;p<32;){if(0===b)break g;b--,u+=n[h++]<>>=7&p,p-=7&p,C.mode=27;break}for(;p<3;){if(0===b)break g;b--,u+=n[h++]<>>=1)){case 0:C.mode=14;break;case 1:if(B(C),C.mode=20,6!==I)break;u>>>=2,p-=2;break g;case 2:C.mode=17;break;case 3:g.msg="invalid block type",C.mode=30}u>>>=2,p-=2;break;case 14:for(u>>>=7&p,p-=7&p;p<32;){if(0===b)break g;b--,u+=n[h++]<>>16^65535)){g.msg="invalid stored block lengths",C.mode=30;break}if(C.length=65535&u,p=u=0,C.mode=15,6===I)break g;case 15:C.mode=16;case 16:if(V=C.length){if(b>>=5,p-=5,C.ndist=1+(31&u),u>>>=5,p-=5,C.ncode=4+(15&u),u>>>=4,p-=4,286>>=3,p-=3}for(;C.have<19;)C.lens[L[C.have++]]=0;if(C.lencode=C.lendyn,C.lenbits=7,J={bits:C.lenbits},S=l(0,C.lens,0,19,C.lencode,0,C.work,J),C.lenbits=J.bits,S){g.msg="invalid code lengths set",C.mode=30;break}C.have=0,C.mode=19;case 19:for(;C.have>>16&255,H=65535&D,!((R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>>=R,p-=R,C.lens[C.have++]=H;else{if(16===H){for(k=R+2;p>>=R,p-=R,0===C.have){g.msg="invalid bit length repeat",C.mode=30;break}M=C.lens[C.have-1],V=3+(3&u),u>>>=2,p-=2}else if(17===H){for(k=R+3;p>>=R)),u>>>=3,p-=3}else{for(k=R+7;p>>=R)),u>>>=7,p-=7}if(C.have+V>C.nlen+C.ndist){g.msg="invalid bit length repeat",C.mode=30;break}for(;V--;)C.lens[C.have++]=M}}if(30===C.mode)break;if(0===C.lens[256]){g.msg="invalid code -- missing end-of-block",C.mode=30;break}if(C.lenbits=9,J={bits:C.lenbits},S=l(s,C.lens,0,C.nlen,C.lencode,0,C.work,J),C.lenbits=J.bits,S){g.msg="invalid literal/lengths set",C.mode=30;break}if(C.distbits=6,C.distcode=C.distdyn,J={bits:C.distbits},S=l(o,C.lens,C.nlen,C.ndist,C.distcode,0,C.work,J),C.distbits=J.bits,S){g.msg="invalid distances set",C.mode=30;break}if(C.mode=20,6===I)break g;case 20:C.mode=21;case 21:if(6<=b&&258<=G){g.next_out=Z,g.avail_out=G,g.next_in=h,g.avail_in=b,C.hold=u,C.bits=p,t(g,W),Z=g.next_out,r=g.output,G=g.avail_out,h=g.next_in,n=g.input,b=g.avail_in,u=C.hold,p=C.bits,12===C.mode&&(C.back=-1);break}for(C.back=0;N=(D=C.lencode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>>=K,p-=K,C.back+=K}if(u>>>=R,p-=R,C.back+=R,C.length=H,0===N){C.mode=26;break}if(32&N){C.back=-1,C.mode=12;break}if(64&N){g.msg="invalid literal/length code",C.mode=30;break}C.extra=15&N,C.mode=22;case 22:if(C.extra){for(k=C.extra;p>>=C.extra,p-=C.extra,C.back+=C.extra}C.was=C.length,C.mode=23;case 23:for(;N=(D=C.distcode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>>=K,p-=K,C.back+=K}if(u>>>=R,p-=R,C.back+=R,64&N){g.msg="invalid distance code",C.mode=30;break}C.offset=H,C.extra=15&N,C.mode=24;case 24:if(C.extra){for(k=C.extra;p>>=C.extra,p-=C.extra,C.back+=C.extra}if(C.offset>C.dmax){g.msg="invalid distance too far back",C.mode=30;break}C.mode=25;case 25:if(0===G)break g;if(V=W-G,C.offset>V){if((V=C.offset-V)>C.whave&&C.sane){g.msg="invalid distance too far back",C.mode=30;break}X=V>C.wnext?(V-=C.wnext,C.wsize-V):C.wnext-V,V>C.length&&(V=C.length),Y=C.window}else Y=r,X=Z-C.offset,V=C.length;for(Gb?(u=J[k+d[B]],f[F+d[B]]):(u=96,0),n=1<>R)+(r-=n)]=G<<24|u<<16|p,0!==r;);for(n=1<>=1;if(0!==n?(K&=n-1,K+=n):K=0,B++,0==--M[W]){if(W===V)break;W=I[C+d[B]]}if(X>>7)]}function J(g,I){g.pending_buf[g.pending++]=255&I,g.pending_buf[g.pending++]=I>>>8&255}function k(g,I,C){g.bi_valid>m-C?(g.bi_buf|=I<>m-g.bi_valid,g.bi_valid+=C-m):(g.bi_buf|=I<>>=1,C<<=1,0<--I;);return C>>>1}function L(g,I,C){var A,i,e=new Array(r+1),t=0;for(A=1;A<=r;A++)e[A]=t=t+C[A-1]<<1;for(i=0;i<=I;i++){var l=g[2*i+1];0!==l&&(g[2*i]=v(e[l]++,l))}}function z(g){var I;for(I=0;I>1;1<=C;C--)U(g,e,C);for(i=s;C=g.heap[1],g.heap[1]=g.heap[g.heap_len--],U(g,e,1),A=g.heap[1],g.heap[--g.heap_max]=C,g.heap[--g.heap_max]=A,e[2*i]=e[2*C]+e[2*A],g.depth[i]=(g.depth[C]>=g.depth[A]?g.depth[C]:g.depth[A])+1,e[2*C+1]=e[2*A+1]=i,g.heap[1]=i++,U(g,e,1),2<=g.heap_len;);g.heap[--g.heap_max]=g.heap[1],function(g,I){var C,A,i,e,t,l,s=I.dyn_tree,o=I.max_code,c=I.stat_desc.static_tree,d=I.stat_desc.has_stree,a=I.stat_desc.extra_bits,m=I.stat_desc.extra_base,h=I.stat_desc.max_length,Z=0;for(e=0;e<=r;e++)g.bl_count[e]=0;for(s[2*g.heap[g.heap_max]+1]=0,C=g.heap_max+1;C>=7;A>>=1)if(1&C&&0!==g.dyn_ltree[2*I])return i;if(0!==g.dyn_ltree[18]||0!==g.dyn_ltree[20]||0!==g.dyn_ltree[26])return e;for(I=32;I>>3,(l=g.static_len+3+7>>>3)<=t&&(t=l)):t=l=C+5,C+4<=t&&-1!==I?_(g,I,C,A):4===g.strategy||l===t?(k(g,2+(A?1:0),3),j(g,y,V)):(k(g,4+(A?1:0),3),function(g,I,C,A){var i;for(k(g,I-257,5),k(g,C-1,5),k(g,A-4,4),i=0;i>>8&255,g.pending_buf[g.d_buf+2*g.last_lit+1]=255&I,g.pending_buf[g.l_buf+g.last_lit]=255&C,g.last_lit++,0===I?g.dyn_ltree[2*C]++:(g.matches++,I--,g.dyn_ltree[2*(Y[C]+o+1)]++,g.dyn_dtree[2*S(I)]++),g.last_lit===g.lit_bufsize-1},C._tr_align=function(g){var I;k(g,2,3),D(g,Z,y),16===(I=g).bi_valid?(J(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)}},{"../utils/common":41}],53:[function(g,I,C){I.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(g,I,C){(function(g){!function(g,I){if(!g.setImmediate){var C,A,i,e,t=1,l={},s=!1,o=g.document,c=Object.getPrototypeOf&&Object.getPrototypeOf(g);c=c&&c.setTimeout?c:g,C="[object process]"==={}.toString.call(g.process)?function(g){process.nextTick((function(){a(g)}))}:function(){if(g.postMessage&&!g.importScripts){var I=!0,C=g.onmessage;return g.onmessage=function(){I=!1},g.postMessage("","*"),g.onmessage=C,I}}()?(e="setImmediate$"+Math.random()+"$",g.addEventListener?g.addEventListener("message",n,!1):g.attachEvent("onmessage",n),function(I){g.postMessage(e+I,"*")}):g.MessageChannel?((i=new MessageChannel).port1.onmessage=function(g){a(g.data)},function(g){i.port2.postMessage(g)}):o&&"onreadystatechange"in o.createElement("script")?(A=o.documentElement,function(g){var I=o.createElement("script");I.onreadystatechange=function(){a(g),I.onreadystatechange=null,A.removeChild(I),I=null},A.appendChild(I)}):function(g){setTimeout(a,0,g)},c.setImmediate=function(g){"function"!=typeof g&&(g=new Function(""+g));for(var I=new Array(arguments.length-1),A=0;Afunction(g,I){let C={name:I.attr(g,"name"),embedFontRefs:[]};for(let A of I.elements(g))switch(A.localName){case"family":C.family=I.attr(A,"val");break;case"altName":C.altName=I.attr(A,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":C.embedFontRefs.push(yC(A,I))}return C}(g,I)))}function yC(g,I){return{id:I.attr(g,"id"),key:I.attr(g,"fontKey"),type:WC[g.localName]}}class VC extends wC{parseXml(g){this.fonts=BC(g,this._package.xmlParser)}}function XC(g){let I=g.lastIndexOf("/")+1;return[0==I?"":g.substring(0,I),0==I?g:g.substring(I)]}function YC(g,I){try{const C="http://docx/";return new URL(g,C+I).toString().substring(C.length)}catch{return`${I}${g}`}}function RC(g,I){return g.reduce(((g,C)=>(g[I(C)]=C,g)),{})}function NC(g){return g&&"object"==typeof g&&!Array.isArray(g)}function HC(g,...I){if(!I.length)return g;const C=I.shift();if(NC(g)&&NC(C))for(const i in C)if(NC(C[i])){var A;HC(null!==(A=g[i])&&void 0!==A?A:g[i]={},C[i])}else g[i]=C[i];return HC(g,...I)}function KC(g){return Array.isArray(g)?g:[g]}class fC{constructor(g,I){this._zip=g,this.options=I,this.xmlParser=new uC}get(g){return this._zip.files[function(g){return g.startsWith("/")?g.substr(1):g}(g)]}update(g,I){this._zip.file(g,I)}static async load(g,I){const C=await aC.loadAsync(g);return new fC(C,I)}save(g="blob"){return this._zip.generateAsync({type:g})}load(g,I="string"){var C,A;return null!==(A=null==(C=this.get(g))?void 0:C.async(I))&&void 0!==A?A:Promise.resolve(null)}async loadRelationships(g=null){let I="_rels/.rels";if(null!=g){const[C,A]=XC(g);I=`${C}_rels/${A}.rels`}const C=await this.load(I);return C?(A=this.parseXmlDocument(C).firstElementChild,(i=this.xmlParser).elements(A).map((g=>({id:i.attr(g,"Id"),type:i.attr(g,"Type"),target:i.attr(g,"Target"),targetMode:i.attr(g,"TargetMode")})))):null;var A,i}parseXmlDocument(g){return function(g,I=!1){var C;I&&(g=g.replace(/<[?].*[?]>/,"")),g=65279===(C=g).charCodeAt(0)?C.substring(1):C;const A=(new DOMParser).parseFromString(g,"application/xml"),i=null==(e=A.getElementsByTagName("parsererror")[0])?void 0:e.textContent;var e;if(i)throw new Error(i);return A}(g,this.options.trimXmlDeclaration)}}class FC extends wC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){this.body=this._documentParser.parseDocumentFile(g)}}function MC(g,I){return{type:I.attr(g,"val"),color:I.attr(g,"color"),size:I.lengthAttr(g,"sz",ZC.Border),offset:I.lengthAttr(g,"space",ZC.Point),frame:I.boolAttr(g,"frame"),shadow:I.boolAttr(g,"shadow")}}function SC(g,I){var C={};for(let A of I.elements(g))switch(A.localName){case"left":C.left=MC(A,I);break;case"top":C.top=MC(A,I);break;case"right":C.right=MC(A,I);break;case"bottom":C.bottom=MC(A,I)}return C}var JC,kC,DC,vC;function LC(g,I=pC){var C,A,i={};for(let e of I.elements(g))switch(e.localName){case"pgSz":i.pageSize={width:I.lengthAttr(e,"w"),height:I.lengthAttr(e,"h"),orientation:I.attr(e,"orient")};break;case"type":i.type=I.attr(e,"val");break;case"pgMar":i.pageMargins={left:I.lengthAttr(e,"left"),right:I.lengthAttr(e,"right"),top:I.lengthAttr(e,"top"),bottom:I.lengthAttr(e,"bottom"),header:I.lengthAttr(e,"header"),footer:I.lengthAttr(e,"footer"),gutter:I.lengthAttr(e,"gutter")};break;case"cols":i.columns=zC(e,I);break;case"headerReference":(null!==(C=i.headerRefs)&&void 0!==C?C:i.headerRefs=[]).push(xC(e,I));break;case"footerReference":(null!==(A=i.footerRefs)&&void 0!==A?A:i.footerRefs=[]).push(xC(e,I));break;case"titlePg":i.titlePage=I.boolAttr(e,"val",!0);break;case"pgBorders":i.pageBorders=SC(e,I);break;case"pgNumType":i.pageNumber=TC(e,I)}return i}function zC(g,I){return{numberOfColumns:I.intAttr(g,"num"),space:I.lengthAttr(g,"space"),separator:I.boolAttr(g,"sep"),equalWidth:I.boolAttr(g,"equalWidth",!0),columns:I.elements(g,"col").map((g=>({width:I.lengthAttr(g,"w"),space:I.lengthAttr(g,"space")})))}}function TC(g,I){return{chapSep:I.attr(g,"chapSep"),chapStyle:I.attr(g,"chapStyle"),format:I.attr(g,"fmt"),start:I.intAttr(g,"start")}}function xC(g,I){return{id:I.attr(g,"id"),type:I.attr(g,"type")}}function UC(g,I){let C={};for(let A of I.elements(g))jC(A,C,I);return C}function jC(g,I,C){return!!GC(g,I,C)}function QC(g,I){let C={};for(let A of I.elements(g))OC(A,C,I);return C}function OC(g,I,C){if(g.namespaceURI!=hC.wordml)return!1;if(GC(g,I,C))return!0;switch(g.localName){case"tabs":I.tabs=function(g,I){return I.elements(g,"tab").map((g=>({position:I.lengthAttr(g,"pos"),leader:I.attr(g,"leader"),style:I.attr(g,"val")})))}(g,C);break;case"sectPr":I.sectionProps=LC(g,C);break;case"numPr":I.numbering=function(g,I){var C={};for(let A of I.elements(g))switch(A.localName){case"numId":C.id=I.attr(A,"val");break;case"ilvl":C.level=I.intAttr(A,"val")}return C}(g,C);break;case"spacing":return I.lineSpacing=function(g,I){return{before:I.lengthAttr(g,"before"),after:I.lengthAttr(g,"after"),line:I.intAttr(g,"line"),lineRule:I.attr(g,"lineRule")}}(g,C),!1;case"textAlignment":return I.textAlignment=C.attr(g,"val"),!1;case"keepLines":I.keepLines=C.boolAttr(g,"val",!0);break;case"keepNext":I.keepNext=C.boolAttr(g,"val",!0);break;case"pageBreakBefore":I.pageBreakBefore=C.boolAttr(g,"val",!0);break;case"outlineLvl":I.outlineLevel=C.intAttr(g,"val");break;case"pStyle":I.styleName=C.attr(g,"val");break;case"rPr":I.runProps=UC(g,C);break;default:return!1}return!0}function EC(g,I){let C={id:I.attr(g,"numId"),overrides:[]};for(let A of I.elements(g))switch(A.localName){case"abstractNumId":C.abstractId=I.attr(A,"val");break;case"lvlOverride":C.overrides.push(qC(A,I))}return C}function PC(g,I){let C={id:I.attr(g,"abstractNumId"),levels:[]};for(let A of I.elements(g))switch(A.localName){case"name":C.name=I.attr(A,"val");break;case"multiLevelType":C.multiLevelType=I.attr(A,"val");break;case"numStyleLink":C.numberingStyleLink=I.attr(A,"val");break;case"styleLink":C.styleLink=I.attr(A,"val");break;case"lvl":C.levels.push(_C(A,I))}return C}function _C(g,I){let C={level:I.intAttr(g,"ilvl")};for(let A of I.elements(g))switch(A.localName){case"start":C.start=I.attr(A,"val");break;case"lvlRestart":C.restart=I.intAttr(A,"val");break;case"numFmt":C.format=I.attr(A,"val");break;case"lvlText":C.text=I.attr(A,"val");break;case"lvlJc":C.justification=I.attr(A,"val");break;case"lvlPicBulletId":C.bulletPictureId=I.attr(A,"val");break;case"pStyle":C.paragraphStyle=I.attr(A,"val");break;case"pPr":C.paragraphProps=QC(A,I);break;case"rPr":C.runProps=UC(A,I)}return C}function qC(g,I){let C={level:I.intAttr(g,"ilvl")};for(let A of I.elements(g))switch(A.localName){case"startOverride":C.start=I.intAttr(A,"val");break;case"lvl":C.numberingLevel=_C(A,I)}return C}function $C(g,I){var C=I.element(g,"pict"),A=C&&I.element(C,"shape"),i=A&&I.element(A,"imagedata");return i?{id:I.attr(g,"numPicBulletId"),referenceId:I.attr(i,"id"),style:I.attr(A,"style")}:null}(kC=JC||(JC={})).Continuous="continuous",kC.NextPage="nextPage",kC.NextColumn="nextColumn",kC.EvenPage="evenPage",kC.OddPage="oddPage";class gA extends wC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){Object.assign(this,function(g,I){let C={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let A of I.elements(g))switch(A.localName){case"num":C.numberings.push(EC(A,I));break;case"abstractNum":C.abstractNumberings.push(PC(A,I));break;case"numPicBullet":C.bulletPictures.push($C(A,I))}return C}(g,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(g)}}class IA extends wC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){this.styles=this._documentParser.parseStylesFile(g)}}(vC=DC||(DC={})).Document="document",vC.Paragraph="paragraph",vC.Run="run",vC.Break="break",vC.NoBreakHyphen="noBreakHyphen",vC.Table="table",vC.Row="row",vC.Cell="cell",vC.Hyperlink="hyperlink",vC.Drawing="drawing",vC.Image="image",vC.Text="text",vC.Tab="tab",vC.Symbol="symbol",vC.BookmarkStart="bookmarkStart",vC.BookmarkEnd="bookmarkEnd",vC.Footer="footer",vC.Header="header",vC.FootnoteReference="footnoteReference",vC.EndnoteReference="endnoteReference",vC.Footnote="footnote",vC.Endnote="endnote",vC.SimpleField="simpleField",vC.ComplexField="complexField",vC.Instruction="instruction",vC.VmlPicture="vmlPicture",vC.MmlMath="mmlMath",vC.MmlMathParagraph="mmlMathParagraph",vC.MmlFraction="mmlFraction",vC.MmlFunction="mmlFunction",vC.MmlFunctionName="mmlFunctionName",vC.MmlNumerator="mmlNumerator",vC.MmlDenominator="mmlDenominator",vC.MmlRadical="mmlRadical",vC.MmlBase="mmlBase",vC.MmlDegree="mmlDegree",vC.MmlSuperscript="mmlSuperscript",vC.MmlSubscript="mmlSubscript",vC.MmlPreSubSuper="mmlPreSubSuper",vC.MmlSubArgument="mmlSubArgument",vC.MmlSuperArgument="mmlSuperArgument",vC.MmlNary="mmlNary",vC.MmlDelimiter="mmlDelimiter",vC.MmlRun="mmlRun",vC.MmlEquationArray="mmlEquationArray",vC.MmlLimit="mmlLimit",vC.MmlLimitLower="mmlLimitLower",vC.MmlMatrix="mmlMatrix",vC.MmlMatrixRow="mmlMatrixRow",vC.MmlBox="mmlBox",vC.MmlBar="mmlBar",vC.MmlGroupChar="mmlGroupChar",vC.VmlElement="vmlElement",vC.Inserted="inserted",vC.Deleted="deleted",vC.DeletedText="deletedText";class CA{constructor(){this.children=[],this.cssStyle={}}}class AA extends CA{constructor(){super(...arguments),this.type=DC.Header}}class iA extends CA{constructor(){super(...arguments),this.type=DC.Footer}}class eA extends wC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(g)}}class tA extends eA{createRootElement(){return new AA}}class lA extends eA{createRootElement(){return new iA}}function sA(g){if(void 0!==g)return parseInt(g)}class oA extends wC{parseXml(g){this.props=function(g,I){const C={};for(let A of I.elements(g))switch(A.localName){case"Template":C.template=A.textContent;break;case"Pages":C.pages=sA(A.textContent);break;case"Words":C.words=sA(A.textContent);break;case"Characters":C.characters=sA(A.textContent);break;case"Application":C.application=A.textContent;break;case"Lines":C.lines=sA(A.textContent);break;case"Paragraphs":C.paragraphs=sA(A.textContent);break;case"Company":C.company=A.textContent;break;case"AppVersion":C.appVersion=A.textContent}return C}(g,this._package.xmlParser)}}class cA extends wC{parseXml(g){this.props=function(g,I){const C={};for(let A of I.elements(g))switch(A.localName){case"title":C.title=A.textContent;break;case"description":C.description=A.textContent;break;case"subject":C.subject=A.textContent;break;case"creator":C.creator=A.textContent;break;case"keywords":C.keywords=A.textContent;break;case"language":C.language=A.textContent;break;case"lastModifiedBy":C.lastModifiedBy=A.textContent;break;case"revision":A.textContent&&(C.revision=parseInt(A.textContent))}return C}(g,this._package.xmlParser)}}class dA{}function aA(g,I){var C={name:I.attr(g,"name"),colors:{}};for(let e of I.elements(g)){var A=I.element(e,"srgbClr"),i=I.element(e,"sysClr");A?C.colors[e.localName]=I.attr(A,"val"):i&&(C.colors[e.localName]=I.attr(i,"lastClr"))}return C}function nA(g,I){var C={name:I.attr(g,"name")};for(let A of I.elements(g))switch(A.localName){case"majorFont":C.majorFont=rA(A,I);break;case"minorFont":C.minorFont=rA(A,I)}return C}function rA(g,I){return{latinTypeface:I.elementAttr(g,"latin","typeface"),eaTypeface:I.elementAttr(g,"ea","typeface"),csTypeface:I.elementAttr(g,"cs","typeface")}}class mA extends wC{constructor(g,I){super(g,I)}parseXml(g){this.theme=function(g,I){var C=new dA,A=I.element(g,"themeElements");for(let i of I.elements(A))switch(i.localName){case"clrScheme":C.colorScheme=aA(i,I);break;case"fontScheme":C.fontScheme=nA(i,I)}return C}(g,this._package.xmlParser)}}class hA{}class ZA extends hA{constructor(){super(...arguments),this.type=DC.Footnote}}class bA extends hA{constructor(){super(...arguments),this.type=DC.Endnote}}class GA extends wC{constructor(g,I,C){super(g,I),this._documentParser=C}}class uA extends GA{constructor(g,I,C){super(g,I,C)}parseXml(g){this.notes=this._documentParser.parseNotes(g,"footnote",ZA)}}class pA extends GA{constructor(g,I,C){super(g,I,C)}parseXml(g){this.notes=this._documentParser.parseNotes(g,"endnote",bA)}}function wA(g,I){var C={defaultNoteIds:[]};for(let A of I.elements(g))switch(A.localName){case"numFmt":C.nummeringFormat=I.attr(A,"val");break;case"footnote":case"endnote":C.defaultNoteIds.push(I.attr(A,"id"))}return C}class WA extends wC{constructor(g,I){super(g,I)}parseXml(g){this.settings=function(g,I){var C={};for(let A of I.elements(g))switch(A.localName){case"defaultTabStop":C.defaultTabStop=I.lengthAttr(A,"val");break;case"footnotePr":C.footnoteProps=wA(A,I);break;case"endnotePr":C.endnoteProps=wA(A,I);break;case"autoHyphenation":C.autoHyphenation=I.boolAttr(A,"val")}return C}(g,this._package.xmlParser)}}class BA extends wC{parseXml(g){this.props=function(g,I){return I.elements(g,"property").map((g=>{const C=g.firstChild;return{formatId:I.attr(g,"fmtid"),name:I.attr(g,"name"),type:C.nodeName,value:C.textContent}}))}(g,this._package.xmlParser)}}const yA=[{type:rC.OfficeDocument,target:"word/document.xml"},{type:rC.ExtendedProperties,target:"docProps/app.xml"},{type:rC.CoreProperties,target:"docProps/core.xml"},{type:rC.CustomProperties,target:"docProps/custom.xml"}];class VA{constructor(){this.parts=[],this.partsMap={}}static async load(g,I,C){var A=new VA;return A._options=C,A._parser=I,A._package=await fC.load(g,C),A.rels=await A._package.loadRelationships(),await Promise.all(yA.map((g=>{var I;const C=null!==(I=A.rels.find((I=>I.type===g.type)))&&void 0!==I?I:g;return A.loadRelationshipPart(C.target,C.type)}))),A}save(g="blob"){return this._package.save(g)}async loadRelationshipPart(g,I){var C;if(this.partsMap[g])return this.partsMap[g];if(!this._package.get(g))return null;let A=null;switch(I){case rC.OfficeDocument:this.documentPart=A=new FC(this._package,g,this._parser);break;case rC.FontTable:this.fontTablePart=A=new VC(this._package,g);break;case rC.Numbering:this.numberingPart=A=new gA(this._package,g,this._parser);break;case rC.Styles:this.stylesPart=A=new IA(this._package,g,this._parser);break;case rC.Theme:this.themePart=A=new mA(this._package,g);break;case rC.Footnotes:this.footnotesPart=A=new uA(this._package,g,this._parser);break;case rC.Endnotes:this.endnotesPart=A=new pA(this._package,g,this._parser);break;case rC.Footer:A=new lA(this._package,g,this._parser);break;case rC.Header:A=new tA(this._package,g,this._parser);break;case rC.CoreProperties:this.corePropsPart=A=new cA(this._package,g);break;case rC.ExtendedProperties:this.extendedPropsPart=A=new oA(this._package,g);break;case rC.CustomProperties:A=new BA(this._package,g);break;case rC.Settings:this.settingsPart=A=new WA(this._package,g)}if(null==A)return Promise.resolve(null);if(this.partsMap[g]=A,this.parts.push(A),await A.load(),(null==(C=A.rels)?void 0:C.length)>0){const[g]=XC(A.path);await Promise.all(A.rels.map((I=>this.loadRelationshipPart(YC(I.target,g),I.type))))}return A}async loadDocumentImage(g,I){const C=await this.loadResource(null!=I?I:this.documentPart,g,"blob");return this.blobToURL(C)}async loadNumberingImage(g){const I=await this.loadResource(this.numberingPart,g,"blob");return this.blobToURL(I)}async loadFont(g,I){const C=await this.loadResource(this.fontTablePart,g,"uint8array");return C?this.blobToURL(new Blob([XA(C,I)])):C}blobToURL(g){return g?this._options.useBase64URL?function(g){return new Promise(((I,C)=>{const A=new FileReader;A.onloadend=()=>I(A.result),A.onerror=()=>C(),A.readAsDataURL(g)}))}(g):URL.createObjectURL(g):null}findPartByRelId(g,I=null){var C,A=(null!==(C=I.rels)&&void 0!==C?C:this.rels).find((I=>I.id==g));const i=I?XC(I.path)[0]:"";return A?this.partsMap[YC(A.target,i)]:null}getPathById(g,I){const C=g.rels.find((g=>g.id==I)),[A]=XC(g.path);return C?YC(C.target,A):null}loadResource(g,I,C){const A=this.getPathById(g,I);return A?this._package.load(A,C):Promise.resolve(null)}}function XA(g,I){const C=I.replace(/{|}|-/g,""),A=new Array(16);for(let i=0;i<16;i++)A[16-i-1]=parseInt(C.substr(2*i,2),16);for(let i=0;i<32;i++)g[i]=g[i]^A[i%16];return g}function YA(g,I){return{type:DC.BookmarkEnd,id:I.attr(g,"id")}}class RA extends CA{constructor(){super(...arguments),this.type=DC.VmlElement,this.attrs={}}}function NA(g,I){var C=new RA;switch(g.localName){case"rect":C.tagName="rect",Object.assign(C.attrs,{width:"100%",height:"100%"});break;case"oval":C.tagName="ellipse",Object.assign(C.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":C.tagName="line";break;case"shape":C.tagName="g";break;case"textbox":C.tagName="foreignObject",Object.assign(C.attrs,{width:"100%",height:"100%"});break;default:return null}for(const A of pC.attrs(g))switch(A.localName){case"style":C.cssStyleText=A.value;break;case"fillcolor":C.attrs.fill=A.value;break;case"from":const[g,I]=KA(A.value);Object.assign(C.attrs,{x1:g,y1:I});break;case"to":const[i,e]=KA(A.value);Object.assign(C.attrs,{x2:i,y2:e})}for(const A of pC.elements(g))switch(A.localName){case"stroke":Object.assign(C.attrs,HA(A));break;case"fill":Object.assign(C.attrs,{});break;case"imagedata":C.tagName="image",Object.assign(C.attrs,{width:"100%",height:"100%"}),C.imageHref={id:pC.attr(A,"id"),title:pC.attr(A,"title")};break;case"txbxContent":C.children.push(...I.parseBodyElements(A));break;default:const g=NA(A,I);g&&C.children.push(g)}return C}function HA(g){var I;return{stroke:pC.attr(g,"color"),"stroke-width":null!==(I=pC.lengthAttr(g,"weight",ZC.Emu))&&void 0!==I?I:"1px"}}function KA(g){return g.split(",")}var fA="inherit",FA="black",MA="black",SA="transparent";const JA=[],kA={oMath:DC.MmlMath,oMathPara:DC.MmlMathParagraph,f:DC.MmlFraction,func:DC.MmlFunction,fName:DC.MmlFunctionName,num:DC.MmlNumerator,den:DC.MmlDenominator,rad:DC.MmlRadical,deg:DC.MmlDegree,e:DC.MmlBase,sSup:DC.MmlSuperscript,sSub:DC.MmlSubscript,sPre:DC.MmlPreSubSuper,sup:DC.MmlSuperArgument,sub:DC.MmlSubArgument,d:DC.MmlDelimiter,nary:DC.MmlNary,eqArr:DC.MmlEquationArray,lim:DC.MmlLimit,limLow:DC.MmlLimitLower,m:DC.MmlMatrix,mr:DC.MmlMatrixRow,box:DC.MmlBox,bar:DC.MmlBar,groupChr:DC.MmlGroupChar};class DA{constructor(g){this.options={ignoreWidth:!1,debug:!1,...g}}parseNotes(g,I,C){var A=[];for(let i of pC.elements(g,I)){const g=new C;g.id=pC.attr(i,"id"),g.noteType=pC.attr(i,"type"),g.children=this.parseBodyElements(i),A.push(g)}return A}parseDocumentFile(g){var I=pC.element(g,"body"),C=pC.element(g,"background"),A=pC.element(I,"sectPr");return{type:DC.Document,children:this.parseBodyElements(I),props:A?LC(A,pC):{},cssStyle:C?this.parseBackground(C):{}}}parseBackground(g){var I={},C=LA.colorAttr(g,"color");return C&&(I["background-color"]=C),I}parseBodyElements(g){var I=[];for(let C of pC.elements(g))switch(C.localName){case"p":I.push(this.parseParagraph(C));break;case"tbl":I.push(this.parseTable(C));break;case"sdt":I.push(...this.parseSdt(C,(g=>this.parseBodyElements(g))))}return I}parseStylesFile(g){var I=[];return LA.foreach(g,(g=>{switch(g.localName){case"style":I.push(this.parseStyle(g));break;case"docDefaults":I.push(this.parseDefaultStyles(g))}})),I}parseDefaultStyles(g){var I={id:null,name:null,target:null,basedOn:null,styles:[]};return LA.foreach(g,(g=>{switch(g.localName){case"rPrDefault":var C=pC.element(g,"rPr");C&&I.styles.push({target:"span",values:this.parseDefaultProperties(C,{})});break;case"pPrDefault":var A=pC.element(g,"pPr");A&&I.styles.push({target:"p",values:this.parseDefaultProperties(A,{})})}})),I}parseStyle(g){var I={id:pC.attr(g,"styleId"),isDefault:pC.boolAttr(g,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(pC.attr(g,"type")){case"paragraph":I.target="p";break;case"table":I.target="table";break;case"character":I.target="span"}return LA.foreach(g,(g=>{switch(g.localName){case"basedOn":I.basedOn=pC.attr(g,"val");break;case"name":I.name=pC.attr(g,"val");break;case"link":I.linked=pC.attr(g,"val");break;case"next":I.next=pC.attr(g,"val");break;case"aliases":I.aliases=pC.attr(g,"val").split(",");break;case"pPr":I.styles.push({target:"p",values:this.parseDefaultProperties(g,{})}),I.paragraphProps=QC(g,pC);break;case"rPr":I.styles.push({target:"span",values:this.parseDefaultProperties(g,{})}),I.runProps=UC(g,pC);break;case"tblPr":case"tcPr":I.styles.push({target:"td",values:this.parseDefaultProperties(g,{})});break;case"tblStylePr":for(let C of this.parseTableStyle(g))I.styles.push(C);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${g.localName}`)}})),I}parseTableStyle(g){var I=[],C=pC.attr(g,"type"),A="",i="";switch(C){case"firstRow":i=".first-row",A="tr.first-row td";break;case"lastRow":i=".last-row",A="tr.last-row td";break;case"firstCol":i=".first-col",A="td.first-col";break;case"lastCol":i=".last-col",A="td.last-col";break;case"band1Vert":i=":not(.no-vband)",A="td.odd-col";break;case"band2Vert":i=":not(.no-vband)",A="td.even-col";break;case"band1Horz":i=":not(.no-hband)",A="tr.odd-row";break;case"band2Horz":i=":not(.no-hband)",A="tr.even-row";break;default:return[]}return LA.foreach(g,(g=>{switch(g.localName){case"pPr":I.push({target:`${A} p`,mod:i,values:this.parseDefaultProperties(g,{})});break;case"rPr":I.push({target:`${A} span`,mod:i,values:this.parseDefaultProperties(g,{})});break;case"tblPr":case"tcPr":I.push({target:A,mod:i,values:this.parseDefaultProperties(g,{})})}})),I}parseNumberingFile(g){var I=[],C={},A=[];return LA.foreach(g,(g=>{switch(g.localName){case"abstractNum":this.parseAbstractNumbering(g,A).forEach((g=>I.push(g)));break;case"numPicBullet":A.push(this.parseNumberingPicBullet(g));break;case"num":var i=pC.attr(g,"numId"),e=pC.elementAttr(g,"abstractNumId","val");C[e]=i}})),I.forEach((g=>g.id=C[g.id])),I}parseNumberingPicBullet(g){var I=pC.element(g,"pict"),C=I&&pC.element(I,"shape"),A=C&&pC.element(C,"imagedata");return A?{id:pC.intAttr(g,"numPicBulletId"),src:pC.attr(A,"id"),style:pC.attr(C,"style")}:null}parseAbstractNumbering(g,I){var C=[],A=pC.attr(g,"abstractNumId");return LA.foreach(g,(g=>{if("lvl"===g.localName)C.push(this.parseNumberingLevel(A,g,I))})),C}parseNumberingLevel(g,I,C){var A={id:g,level:pC.intAttr(I,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};return LA.foreach(I,(g=>{switch(g.localName){case"start":A.start=pC.intAttr(g,"val");break;case"pPr":this.parseDefaultProperties(g,A.pStyle);break;case"rPr":this.parseDefaultProperties(g,A.rStyle);break;case"lvlPicBulletId":var I=pC.intAttr(g,"val");A.bullet=C.find((g=>g.id==I));break;case"lvlText":A.levelText=pC.attr(g,"val");break;case"pStyle":A.pStyleName=pC.attr(g,"val");break;case"numFmt":A.format=pC.attr(g,"val");break;case"suff":A.suff=pC.attr(g,"val")}})),A}parseSdt(g,I){const C=pC.element(g,"sdtContent");return C?I(C):[]}parseInserted(g,I){var C,A;return{type:DC.Inserted,children:null!==(A=null==(C=I(g))?void 0:C.children)&&void 0!==A?A:[]}}parseDeleted(g,I){var C,A;return{type:DC.Deleted,children:null!==(A=null==(C=I(g))?void 0:C.children)&&void 0!==A?A:[]}}parseParagraph(g){var I,C,A={type:DC.Paragraph,children:[]};for(let i of pC.elements(g))switch(i.localName){case"pPr":this.parseParagraphProperties(i,A);break;case"r":A.children.push(this.parseRun(i,A));break;case"hyperlink":A.children.push(this.parseHyperlink(i,A));break;case"bookmarkStart":A.children.push((I=i,C=pC,{type:DC.BookmarkStart,id:C.attr(I,"id"),name:C.attr(I,"name"),colFirst:C.intAttr(I,"colFirst"),colLast:C.intAttr(I,"colLast")}));break;case"bookmarkEnd":A.children.push(YA(i,pC));break;case"oMath":case"oMathPara":A.children.push(this.parseMathElement(i));break;case"sdt":A.children.push(...this.parseSdt(i,(g=>this.parseParagraph(g).children)));break;case"ins":A.children.push(this.parseInserted(i,(g=>this.parseParagraph(g))));break;case"del":A.children.push(this.parseDeleted(i,(g=>this.parseParagraph(g))))}return A}parseParagraphProperties(g,I){this.parseDefaultProperties(g,I.cssStyle={},null,(g=>{if(OC(g,I,pC))return!0;switch(g.localName){case"pStyle":I.styleName=pC.attr(g,"val");break;case"cnfStyle":I.className=zA.classNameOfCnfStyle(g);break;case"framePr":this.parseFrame(g,I);break;case"rPr":break;default:return!1}return!0}))}parseFrame(g,I){"drop"==pC.attr(g,"dropCap")&&(I.cssStyle.float="left")}parseHyperlink(g,I){var C={type:DC.Hyperlink,parent:I,children:[]},A=pC.attr(g,"anchor"),i=pC.attr(g,"id");return A&&(C.href="#"+A),i&&(C.id=i),LA.foreach(g,(g=>{if("r"===g.localName)C.children.push(this.parseRun(g,C))})),C}parseRun(g,I){var C={type:DC.Run,parent:I,children:[]};return LA.foreach(g,(g=>{switch((g=this.checkAlternateContent(g)).localName){case"t":C.children.push({type:DC.Text,text:g.textContent});break;case"delText":C.children.push({type:DC.DeletedText,text:g.textContent});break;case"fldSimple":C.children.push({type:DC.SimpleField,instruction:pC.attr(g,"instr"),lock:pC.boolAttr(g,"lock",!1),dirty:pC.boolAttr(g,"dirty",!1)});break;case"instrText":C.fieldRun=!0,C.children.push({type:DC.Instruction,text:g.textContent});break;case"fldChar":C.fieldRun=!0,C.children.push({type:DC.ComplexField,charType:pC.attr(g,"fldCharType"),lock:pC.boolAttr(g,"lock",!1),dirty:pC.boolAttr(g,"dirty",!1)});break;case"noBreakHyphen":C.children.push({type:DC.NoBreakHyphen});break;case"br":C.children.push({type:DC.Break,break:pC.attr(g,"type")||"textWrapping"});break;case"lastRenderedPageBreak":C.children.push({type:DC.Break,break:"lastRenderedPageBreak"});break;case"sym":C.children.push({type:DC.Symbol,font:pC.attr(g,"font"),char:pC.attr(g,"char")});break;case"tab":C.children.push({type:DC.Tab});break;case"footnoteReference":C.children.push({type:DC.FootnoteReference,id:pC.attr(g,"id")});break;case"endnoteReference":C.children.push({type:DC.EndnoteReference,id:pC.attr(g,"id")});break;case"drawing":let I=this.parseDrawing(g);I&&(C.children=[I]);break;case"pict":C.children.push(this.parseVmlPicture(g));break;case"rPr":this.parseRunProperties(g,C)}})),C}parseMathElement(g){const I=`${g.localName}Pr`,C={type:kA[g.localName],children:[]};for(const i of pC.elements(g)){if(kA[i.localName])C.children.push(this.parseMathElement(i));else if("r"==i.localName){var A=this.parseRun(i);A.type=DC.MmlRun,C.children.push(A)}else i.localName==I&&(C.props=this.parseMathProperies(i))}return C}parseMathProperies(g){const I={};for(const C of pC.elements(g))switch(C.localName){case"chr":I.char=pC.attr(C,"val");break;case"vertJc":I.verticalJustification=pC.attr(C,"val");break;case"pos":I.position=pC.attr(C,"val");break;case"degHide":I.hideDegree=pC.boolAttr(C,"val");break;case"begChr":I.beginChar=pC.attr(C,"val");break;case"endChr":I.endChar=pC.attr(C,"val")}return I}parseRunProperties(g,I){this.parseDefaultProperties(g,I.cssStyle={},null,(g=>{switch(g.localName){case"rStyle":I.styleName=pC.attr(g,"val");break;case"vertAlign":I.verticalAlign=zA.valueOfVertAlign(g,!0);break;default:return!1}return!0}))}parseVmlPicture(g){const I={type:DC.VmlPicture,children:[]};for(const C of pC.elements(g)){const g=NA(C,this);g&&I.children.push(g)}return I}checkAlternateContent(g){var I;if("AlternateContent"!=g.localName)return g;var C=pC.element(g,"Choice");if(C){var A=pC.attr(C,"Requires"),i=g.lookupNamespaceURI(A);if(JA.includes(i))return C.firstElementChild}return null==(I=pC.element(g,"Fallback"))?void 0:I.firstElementChild}parseDrawing(g){for(var I of pC.elements(g))switch(I.localName){case"inline":case"anchor":return this.parseDrawingWrapper(I)}}parseDrawingWrapper(g){var I={type:DC.Drawing,children:[],cssStyle:{}},C="anchor"==g.localName;let A=null,i=pC.boolAttr(g,"simplePos"),e={relative:"page",align:"left",offset:"0"},t={relative:"page",align:"top",offset:"0"};for(var l of pC.elements(g))switch(l.localName){case"simplePos":i&&(e.offset=pC.lengthAttr(l,"x",ZC.Emu),t.offset=pC.lengthAttr(l,"y",ZC.Emu));break;case"extent":I.cssStyle.width=pC.lengthAttr(l,"cx",ZC.Emu),I.cssStyle.height=pC.lengthAttr(l,"cy",ZC.Emu);break;case"positionH":case"positionV":if(!i){var s;let g="positionH"==l.localName?e:t;var o=pC.element(l,"align"),c=pC.element(l,"posOffset");g.relative=null!==(s=pC.attr(l,"relativeFrom"))&&void 0!==s?s:g.relative,o&&(g.align=o.textContent),c&&(g.offset=LA.sizeValue(c,ZC.Emu))}break;case"wrapTopAndBottom":A="wrapTopAndBottom";break;case"wrapNone":A="wrapNone";break;case"graphic":var d=this.parseGraphic(l);d&&I.children.push(d)}return"wrapTopAndBottom"==A?(I.cssStyle.display="block",e.align&&(I.cssStyle["text-align"]=e.align,I.cssStyle.width="100%")):"wrapNone"==A?(I.cssStyle.display="block",I.cssStyle.position="relative",I.cssStyle.width="0px",I.cssStyle.height="0px",e.offset&&(I.cssStyle.left=e.offset),t.offset&&(I.cssStyle.top=t.offset)):!C||"left"!=e.align&&"right"!=e.align||(I.cssStyle.float=e.align),I}parseGraphic(g){var I=pC.element(g,"graphicData");for(let C of pC.elements(I))if("pic"===C.localName)return this.parsePicture(C);return null}parsePicture(g){var I={type:DC.Image,src:"",cssStyle:{}},C=pC.element(g,"blipFill"),A=pC.element(C,"blip");I.src=pC.attr(A,"embed");var i=pC.element(g,"spPr"),e=pC.element(i,"xfrm");for(var t of(I.cssStyle.position="relative",pC.elements(e)))switch(t.localName){case"ext":I.cssStyle.width=pC.lengthAttr(t,"cx",ZC.Emu),I.cssStyle.height=pC.lengthAttr(t,"cy",ZC.Emu);break;case"off":I.cssStyle.left=pC.lengthAttr(t,"x",ZC.Emu),I.cssStyle.top=pC.lengthAttr(t,"y",ZC.Emu)}return I}parseTable(g){var I={type:DC.Table,children:[]};return LA.foreach(g,(g=>{switch(g.localName){case"tr":I.children.push(this.parseTableRow(g));break;case"tblGrid":I.columns=this.parseTableColumns(g);break;case"tblPr":this.parseTableProperties(g,I)}})),I}parseTableColumns(g){var I=[];return LA.foreach(g,(g=>{if("gridCol"===g.localName)I.push({width:pC.lengthAttr(g,"w")})})),I}parseTableProperties(g,I){switch(I.cssStyle={},I.cellStyle={},this.parseDefaultProperties(g,I.cssStyle,I.cellStyle,(g=>{switch(g.localName){case"tblStyle":I.styleName=pC.attr(g,"val");break;case"tblLook":I.className=zA.classNameOftblLook(g);break;case"tblpPr":this.parseTablePosition(g,I);break;case"tblStyleColBandSize":I.colBandSize=pC.intAttr(g,"val");break;case"tblStyleRowBandSize":I.rowBandSize=pC.intAttr(g,"val");break;default:return!1}return!0})),I.cssStyle["text-align"]){case"center":delete I.cssStyle["text-align"],I.cssStyle["margin-left"]="auto",I.cssStyle["margin-right"]="auto";break;case"right":delete I.cssStyle["text-align"],I.cssStyle["margin-left"]="auto"}}parseTablePosition(g,I){var C=pC.lengthAttr(g,"topFromText"),A=pC.lengthAttr(g,"bottomFromText"),i=pC.lengthAttr(g,"rightFromText"),e=pC.lengthAttr(g,"leftFromText");I.cssStyle.float="left",I.cssStyle["margin-bottom"]=zA.addSize(I.cssStyle["margin-bottom"],A),I.cssStyle["margin-left"]=zA.addSize(I.cssStyle["margin-left"],e),I.cssStyle["margin-right"]=zA.addSize(I.cssStyle["margin-right"],i),I.cssStyle["margin-top"]=zA.addSize(I.cssStyle["margin-top"],C)}parseTableRow(g){var I={type:DC.Row,children:[]};return LA.foreach(g,(g=>{switch(g.localName){case"tc":I.children.push(this.parseTableCell(g));break;case"trPr":this.parseTableRowProperties(g,I)}})),I}parseTableRowProperties(g,I){I.cssStyle=this.parseDefaultProperties(g,{},null,(g=>{switch(g.localName){case"cnfStyle":I.className=zA.classNameOfCnfStyle(g);break;case"tblHeader":I.isHeader=pC.boolAttr(g,"val");break;default:return!1}return!0}))}parseTableCell(g){var I={type:DC.Cell,children:[]};return LA.foreach(g,(g=>{switch(g.localName){case"tbl":I.children.push(this.parseTable(g));break;case"p":I.children.push(this.parseParagraph(g));break;case"tcPr":this.parseTableCellProperties(g,I)}})),I}parseTableCellProperties(g,I){I.cssStyle=this.parseDefaultProperties(g,{},null,(g=>{var C;switch(g.localName){case"gridSpan":I.span=pC.intAttr(g,"val",null);break;case"vMerge":I.verticalMerge=null!==(C=pC.attr(g,"val"))&&void 0!==C?C:"continue";break;case"cnfStyle":I.className=zA.classNameOfCnfStyle(g);break;default:return!1}return!0}))}parseDefaultProperties(g,I=null,C=null,A=null){return I=I||{},LA.foreach(g,(i=>{if(!(null==A?void 0:A(i)))switch(i.localName){case"jc":I["text-align"]=zA.valueOfJc(i);break;case"textAlignment":I["vertical-align"]=zA.valueOfTextAlignment(i);break;case"color":I.color=LA.colorAttr(i,"val",null,FA);break;case"sz":I["font-size"]=I["min-height"]=pC.lengthAttr(i,"val",ZC.FontSize);break;case"shd":I["background-color"]=LA.colorAttr(i,"fill",null,fA);break;case"highlight":I["background-color"]=LA.colorAttr(i,"val",null,SA);break;case"vertAlign":break;case"position":I.verticalAlign=pC.lengthAttr(i,"val",ZC.FontSize);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":I.width=zA.valueOfSize(i,"w");break;case"trHeight":this.parseTrHeight(i,I);break;case"strike":I["text-decoration"]=pC.boolAttr(i,"val",!0)?"line-through":"none";break;case"b":I["font-weight"]=pC.boolAttr(i,"val",!0)?"bold":"normal";break;case"i":I["font-style"]=pC.boolAttr(i,"val",!0)?"italic":"normal";break;case"caps":I["text-transform"]=pC.boolAttr(i,"val",!0)?"uppercase":"none";break;case"smallCaps":I["font-variant"]=pC.boolAttr(i,"val",!0)?"small-caps":"none";break;case"u":this.parseUnderline(i,I);break;case"ind":case"tblInd":this.parseIndentation(i,I);break;case"rFonts":this.parseFont(i,I);break;case"tblBorders":this.parseBorderProperties(i,C||I);break;case"tblCellSpacing":I["border-spacing"]=zA.valueOfMargin(i),I["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(i,I);break;case"bdr":I.border=zA.valueOfBorder(i);break;case"tcBorders":this.parseBorderProperties(i,I);break;case"vanish":pC.boolAttr(i,"val",!0)&&(I.display="none");break;case"kern":case"noWrap":break;case"tblCellMar":case"tcMar":this.parseMarginProperties(i,C||I);break;case"tblLayout":I["table-layout"]=zA.valueOfTblLayout(i);break;case"vAlign":I["vertical-align"]=zA.valueOfTextAlignment(i);break;case"spacing":"pPr"==g.localName&&this.parseSpacing(i,I);break;case"wordWrap":pC.boolAttr(i,"val")&&(I["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":I.hyphens=pC.boolAttr(i,"val",!0)?"none":"auto";break;case"lang":I.$lang=pC.attr(i,"val");break;case"bCs":case"iCs":case"szCs":case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"webHidden":case"pageBreakBefore":case"suppressLineNumbers":case"keepLines":case"keepNext":case"widowControl":case"bidi":case"rtl":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${g.localName}.${i.localName}`)}})),I}parseUnderline(g,I){var C=pC.attr(g,"val");if(null!=C){switch(C){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":I["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":I["text-decoration"]="underline dotted";break;case"double":I["text-decoration"]="underline double";break;case"single":case"thick":case"words":I["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":I["text-decoration"]="underline wavy";break;case"none":I["text-decoration"]="none"}var A=LA.colorAttr(g,"color");A&&(I["text-decoration-color"]=A)}}parseFont(g,I){var C=[pC.attr(g,"ascii"),zA.themeValue(g,"asciiTheme")].filter((g=>g)).join(", ");C.length>0&&(I["font-family"]=C)}parseIndentation(g,I){var C=pC.lengthAttr(g,"firstLine"),A=pC.lengthAttr(g,"hanging"),i=pC.lengthAttr(g,"left"),e=pC.lengthAttr(g,"start"),t=pC.lengthAttr(g,"right"),l=pC.lengthAttr(g,"end");C&&(I["text-indent"]=C),A&&(I["text-indent"]=`-${A}`),(i||e)&&(I["margin-left"]=i||e),(t||l)&&(I["margin-right"]=t||l)}parseSpacing(g,I){var C=pC.lengthAttr(g,"before"),A=pC.lengthAttr(g,"after"),i=pC.intAttr(g,"line",null),e=pC.attr(g,"lineRule");if(C&&(I["margin-top"]=C),A&&(I["margin-bottom"]=A),null!==i)switch(e){case"auto":I["line-height"]=`${(i/240).toFixed(2)}`;break;case"atLeast":I["line-height"]=`calc(100% + ${i/20}pt)`;break;default:I["line-height"]=I["min-height"]=i/20+"pt"}}parseMarginProperties(g,I){LA.foreach(g,(g=>{switch(g.localName){case"left":I["padding-left"]=zA.valueOfMargin(g);break;case"right":I["padding-right"]=zA.valueOfMargin(g);break;case"top":I["padding-top"]=zA.valueOfMargin(g);break;case"bottom":I["padding-bottom"]=zA.valueOfMargin(g)}}))}parseTrHeight(g,I){pC.attr(g,"hRule"),I.height=pC.lengthAttr(g,"val")}parseBorderProperties(g,I){LA.foreach(g,(g=>{switch(g.localName){case"start":case"left":I["border-left"]=zA.valueOfBorder(g);break;case"end":case"right":I["border-right"]=zA.valueOfBorder(g);break;case"top":I["border-top"]=zA.valueOfBorder(g);break;case"bottom":I["border-bottom"]=zA.valueOfBorder(g)}}))}}const vA=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"];class LA{static foreach(g,I){for(var C=0;C"1"==I[C])).join(" ")}static valueOfJc(g){var I=pC.attr(g,"val");switch(I){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return I}static valueOfVertAlign(g,I=!1){var C=pC.attr(g,"val");switch(C){case"subscript":return"sub";case"superscript":return I?"sup":"super"}return I?null:C}static valueOfTextAlignment(g){var I=pC.attr(g,"val");switch(I){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return I}static addSize(g,I){return null==g?I:null==I?g:`calc(${g} + ${I})`}static classNameOftblLook(g){const I=pC.hexAttr(g,"val",0);let C="";return(pC.boolAttr(g,"firstRow")||32&I)&&(C+=" first-row"),(pC.boolAttr(g,"lastRow")||64&I)&&(C+=" last-row"),(pC.boolAttr(g,"firstColumn")||128&I)&&(C+=" first-col"),(pC.boolAttr(g,"lastColumn")||256&I)&&(C+=" last-col"),(pC.boolAttr(g,"noHBand")||512&I)&&(C+=" no-hband"),(pC.boolAttr(g,"noVBand")||1024&I)&&(C+=" no-vband"),C.trim()}}const TA={pos:0,leader:"none",style:"left"};function xA(g,I,C,A=.75){const i=g.closest("p"),e=g.getBoundingClientRect(),t=i.getBoundingClientRect(),l=getComputedStyle(i),s=(null==I?void 0:I.length)>0?I.map((g=>({pos:UA(g.position),leader:g.leader,style:g.style}))).sort(((g,I)=>g.pos-I.pos)):[TA],o=s[s.length-1],c=t.width*A,d=UA(C);let a=o.pos+d;if(a"clear"!=g.style&&g.pos>m));if(null==h)return;let Z=1;if("right"==h.style||"center"==h.style){const I=Array.from(i.querySelectorAll(`.${g.className}`)),C=I.indexOf(g)+1,e=document.createRange();e.setStart(g,1),Cg.id))),g.endnotesPart&&(this.endnoteMap=RC(g.endnotesPart.notes,(g=>g.id))),g.settingsPart&&(this.defaultTabSize=null==(i=g.settingsPart.settings)?void 0:i.defaultTabStop),!A.ignoreFonts&&g.fontTablePart&&this.renderFontTable(g.fontTablePart,C);var e=this.renderSections(g.documentPart.body);this.options.inWrapper?I.appendChild(this.renderWrapper(e)):$A(I,e),this.refreshTabStops()}renderTheme(g,I){var C,A;const i={},e=null==(C=g.theme)?void 0:C.fontScheme;e&&(e.majorFont&&(i["--docx-majorHAnsi-font"]=e.majorFont.latinTypeface),e.minorFont&&(i["--docx-minorHAnsi-font"]=e.minorFont.latinTypeface));const t=null==(A=g.theme)?void 0:A.colorScheme;if(t)for(let[s,o]of Object.entries(t.colors))i[`--docx-${s}-color`]=`#${o}`;const l=this.styleToString(`.${this.className}`,i);I.appendChild(gi(l))}renderFontTable(g,I){for(let C of g.fonts)for(let g of C.embedFontRefs)this.tasks.push(this.document.loadFont(g.id,g.key).then((A=>{const i={"font-family":C.name,src:`url(${A})`};"bold"!=g.type&&"boldItalic"!=g.type||(i["font-weight"]="bold"),"italic"!=g.type&&"boldItalic"!=g.type||(i["font-style"]="italic"),Ii(I,`docxjs ${C.name} font`);const e=this.styleToString("@font-face",i);I.appendChild(gi(e)),this.refreshTabStops()})))}processStyleName(g){return g?`${this.className}_${function(g){return null==g?void 0:g.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}(g)}`:this.className}processStyles(g){const I=RC(g.filter((g=>null!=g.id)),(g=>g.id));for(const A of g.filter((g=>g.basedOn))){var C=I[A.basedOn];if(C){A.paragraphProps=HC(A.paragraphProps,C.paragraphProps),A.runProps=HC(A.runProps,C.runProps);for(const g of C.styles){const I=A.styles.find((I=>I.target==g.target));I?this.copyStyleProperties(g.values,I.values):A.styles.push({...g,values:{...g.values}})}}else this.options.debug&&console.warn(`Can't find base style ${A.basedOn}`)}for(let A of g)A.cssName=this.processStyleName(A.id);return I}prodessNumberings(g){var I;for(let C of g.filter((g=>g.pStyleName))){const g=this.findStyle(C.pStyleName);(null==(I=null==g?void 0:g.paragraphProps)?void 0:I.numbering)&&(g.paragraphProps.numbering.level=C.level)}}processElement(g){if(g.children)for(var I of g.children)I.parent=g,I.type==DC.Table?this.processTable(I):this.processElement(I)}processTable(g){for(var I of g.children)for(var C of I.children)C.cssStyle=this.copyStyleProperties(g.cellStyle,C.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]),this.processElement(C)}copyStyleProperties(g,I,C=null){if(!g)return I;for(var A of(null==I&&(I={}),null==C&&(C=Object.getOwnPropertyNames(g)),C))g.hasOwnProperty(A)&&!I.hasOwnProperty(A)&&(I[A]=g[A]);return I}createSection(g,I){var C=this.createElement("section",{className:g});return I&&(I.pageMargins&&(C.style.paddingLeft=I.pageMargins.left,C.style.paddingRight=I.pageMargins.right,C.style.paddingTop=I.pageMargins.top,C.style.paddingBottom=I.pageMargins.bottom),I.pageSize&&(this.options.ignoreWidth||(C.style.width=I.pageSize.width),this.options.ignoreHeight||(C.style.minHeight=I.pageSize.height)),I.columns&&I.columns.numberOfColumns&&(C.style.columnCount=`${I.columns.numberOfColumns}`,C.style.columnGap=I.columns.space,I.columns.separator&&(C.style.columnRule="1px solid black"))),C}renderSections(g){const I=[];this.processElement(g);const C=this.splitBySection(g.children);let A=null;for(let e=0,t=C.length;e"first"==g.type)):null)&&void 0!==t?t:C%2==1?g.find((g=>"even"==g.type)):null)&&void 0!==e?e:g.find((g=>"default"==g.type)),s=l&&this.document.findPartByRelId(l.id,this.document.documentPart);if(s){this.currentPart=s,this.usedHederFooterParts.includes(s.path)||(this.processElement(s.rootElement),this.usedHederFooterParts.push(s.path));const[g]=this.renderElements([s.rootElement],i);(null==I?void 0:I.pageMargins)&&(s.rootElement.type===DC.Header?(g.style.marginTop=`calc(${I.pageMargins.header} - ${I.pageMargins.top})`,g.style.minHeight=`calc(${I.pageMargins.top} - ${I.pageMargins.header})`):s.rootElement.type===DC.Footer&&(g.style.marginBottom=`calc(${I.pageMargins.footer} - ${I.pageMargins.bottom})`,g.style.minHeight=`calc(${I.pageMargins.bottom} - ${I.pageMargins.footer})`)),this.currentPart=null}}}isPageBreakElement(g){return g.type==DC.Break&&("lastRenderedPageBreak"==g.break?!this.options.ignoreLastRenderedPageBreak:"page"==g.break)}splitBySection(g){var I,C={sectProps:null,elements:[]},A=[C];for(let c of g){if(c.type==DC.Paragraph){const g=this.findStyle(c.styleName);(null==(I=null==g?void 0:g.paragraphProps)?void 0:I.pageBreakBefore)&&(C.sectProps=i,C={sectProps:null,elements:[]},A.push(C))}if(C.elements.push(c),c.type==DC.Paragraph){const g=c;var i=g.sectionProps,e=-1,t=-1;if(this.options.breakPages&&g.children&&(e=g.children.findIndex((g=>{var I,C;return-1!=(t=null!==(C=null==(I=g.children)?void 0:I.findIndex(this.isPageBreakElement.bind(this)))&&void 0!==C?C:-1)}))),(i||-1!=e)&&(C.sectProps=i,C={sectProps:null,elements:[]},A.push(C)),-1!=e){let I=g.children[e],A=t=0;c--)null==A[c].sectProps?A[c].sectProps=o:o=A[c].sectProps;return A}renderWrapper(g){return this.createElement("div",{className:`${this.className}-wrapper`},g)}renderDefaultStyle(){var g=this.className;return gi(`\n.${g}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; } \n.${g}-wrapper>section.${g} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }\n.${g} { color: black; hyphens: auto; text-underline-position: from-font; }\nsection.${g} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }\nsection.${g}>article { margin-bottom: auto; z-index: 1; }\nsection.${g}>footer { z-index: 1; }\n.${g} table { border-collapse: collapse; }\n.${g} table td, .${g} table th { vertical-align: top; }\n.${g} p { margin: 0pt; min-height: 1em; }\n.${g} span { white-space: pre-wrap; overflow-wrap: break-word; }\n.${g} a { color: inherit; text-decoration: inherit; }\n`)}renderNumbering(g,I){var C="",A=[];for(var i of g){var e=`p.${this.numberingClass(i.id,i.level)}`,t="none";if(i.bullet){let g=`--${this.className}-${i.bullet.src}`.toLowerCase();C+=this.styleToString(`${e}:before`,{content:"' '",display:"inline-block",background:`var(${g})`},i.bullet.style),this.tasks.push(this.document.loadNumberingImage(i.bullet.src).then((C=>{var A=`${this.rootSelector} { ${g}: url(${C}) }`;I.appendChild(gi(A))})))}else if(i.levelText){let g=this.numberingCounter(i.id,i.level);const I=g+" "+(i.start-1);i.level>0&&(C+=this.styleToString(`p.${this.numberingClass(i.id,i.level-1)}`,{"counter-reset":I})),A.push(I),C+=this.styleToString(`${e}:before`,{content:this.levelTextToContent(i.levelText,i.suff,i.id,this.numFormatToCssValue(i.format)),"counter-increment":g,...i.rStyle})}else t=this.numFormatToCssValue(i.format);C+=this.styleToString(e,{display:"list-item","list-style-position":"inside","list-style-type":t,...i.pStyle})}return A.length>0&&(C+=this.styleToString(this.rootSelector,{"counter-reset":A.join(" ")})),gi(C)}renderStyles(g){var I="";const C=this.styleMap,A=RC(g.filter((g=>g.isDefault)),(g=>g.target));for(const s of g){var i=s.styles;if(s.linked){var e=s.linked&&C[s.linked];e?i=i.concat(e.styles):this.options.debug&&console.warn(`Can't find linked style ${s.linked}`)}for(const g of i){var t,l=`${null!==(t=s.target)&&void 0!==t?t:""}.${s.cssName}`;s.target!=g.target&&(l+=` ${g.target}`),A[s.target]==s&&(l=`.${this.className} ${s.target}, `+l),I+=this.styleToString(l,g.values)}}return gi(I)}renderNotes(g,I,C){var A=g.map((g=>I[g])).filter((g=>g));if(A.length>0){var i=this.createElement("ol",null,this.renderElements(A));C.appendChild(i)}}renderElement(g){switch(g.type){case DC.Paragraph:return this.renderParagraph(g);case DC.BookmarkStart:return this.renderBookmarkStart(g);case DC.BookmarkEnd:return null;case DC.Run:return this.renderRun(g);case DC.Table:return this.renderTable(g);case DC.Row:return this.renderTableRow(g);case DC.Cell:return this.renderTableCell(g);case DC.Hyperlink:return this.renderHyperlink(g);case DC.Drawing:return this.renderDrawing(g);case DC.Image:return this.renderImage(g);case DC.Text:case DC.Text:return this.renderText(g);case DC.DeletedText:return this.renderDeletedText(g);case DC.Tab:return this.renderTab(g);case DC.Symbol:return this.renderSymbol(g);case DC.Break:return this.renderBreak(g);case DC.Footer:return this.renderContainer(g,"footer");case DC.Header:return this.renderContainer(g,"header");case DC.Footnote:case DC.Endnote:return this.renderContainer(g,"li");case DC.FootnoteReference:return this.renderFootnoteReference(g);case DC.EndnoteReference:return this.renderEndnoteReference(g);case DC.NoBreakHyphen:return this.createElement("wbr");case DC.VmlPicture:return this.renderVmlPicture(g);case DC.VmlElement:return this.renderVmlElement(g);case DC.MmlMath:return this.renderContainerNS(g,QA,"math",{xmlns:QA});case DC.MmlMathParagraph:return this.renderContainer(g,"span");case DC.MmlFraction:return this.renderContainerNS(g,QA,"mfrac");case DC.MmlBase:return this.renderContainerNS(g,QA,g.parent.type==DC.MmlMatrixRow?"mtd":"mrow");case DC.MmlNumerator:case DC.MmlDenominator:case DC.MmlFunction:case DC.MmlLimit:case DC.MmlBox:return this.renderContainerNS(g,QA,"mrow");case DC.MmlGroupChar:return this.renderMmlGroupChar(g);case DC.MmlLimitLower:return this.renderContainerNS(g,QA,"munder");case DC.MmlMatrix:return this.renderContainerNS(g,QA,"mtable");case DC.MmlMatrixRow:return this.renderContainerNS(g,QA,"mtr");case DC.MmlRadical:return this.renderMmlRadical(g);case DC.MmlSuperscript:return this.renderContainerNS(g,QA,"msup");case DC.MmlSubscript:return this.renderContainerNS(g,QA,"msub");case DC.MmlDegree:case DC.MmlSuperArgument:case DC.MmlSubArgument:return this.renderContainerNS(g,QA,"mn");case DC.MmlFunctionName:return this.renderContainerNS(g,QA,"ms");case DC.MmlDelimiter:return this.renderMmlDelimiter(g);case DC.MmlRun:return this.renderMmlRun(g);case DC.MmlNary:return this.renderMmlNary(g);case DC.MmlPreSubSuper:return this.renderMmlPreSubSuper(g);case DC.MmlBar:return this.renderMmlBar(g);case DC.MmlEquationArray:return this.renderMllList(g);case DC.Inserted:return this.renderInserted(g);case DC.Deleted:return this.renderDeleted(g)}return null}renderChildren(g,I){return this.renderElements(g.children,I)}renderElements(g,I){if(null==g)return null;var C=g.flatMap((g=>this.renderElement(g))).filter((g=>null!=g));return I&&$A(I,C),C}renderContainer(g,I,C){return this.createElement(I,C,this.renderChildren(g))}renderContainerNS(g,I,C,A){return _A(I,C,A,this.renderChildren(g))}renderParagraph(g){var I,C,A,i,e=this.createElement("p");const t=this.findStyle(g.styleName);null!==(A=g.tabs)&&void 0!==A||(g.tabs=null==(I=null==t?void 0:t.paragraphProps)?void 0:I.tabs),this.renderClass(g,e),this.renderChildren(g,e),this.renderStyleValues(g.cssStyle,e),this.renderCommonProperties(e.style,g);const l=null!==(i=g.numbering)&&void 0!==i?i:null==(C=null==t?void 0:t.paragraphProps)?void 0:C.numbering;return l&&e.classList.add(this.numberingClass(l.id,l.level)),e}renderRunProperties(g,I){this.renderCommonProperties(g,I)}renderCommonProperties(g,I){null!=I&&(I.color&&(g.color=I.color),I.fontSize&&(g["font-size"]=I.fontSize))}renderHyperlink(g){var I=this.createElement("a");if(this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),g.href)I.href=g.href;else if(g.id){const C=this.document.documentPart.rels.find((I=>I.id==g.id&&"External"===I.targetMode));I.href=null==C?void 0:C.target}return I}renderDrawing(g){var I=this.createElement("div");return I.style.display="inline-block",I.style.position="relative",I.style.textIndent="0px",this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),I}renderImage(g){let I=this.createElement("img");return this.renderStyleValues(g.cssStyle,I),this.document&&this.tasks.push(this.document.loadDocumentImage(g.src,this.currentPart).then((g=>{I.src=g}))),I}renderText(g){return this.htmlDocument.createTextNode(g.text)}renderDeletedText(g){return this.options.renderEndnotes?this.htmlDocument.createTextNode(g.text):null}renderBreak(g){return"textWrapping"==g.break?this.createElement("br"):null}renderInserted(g){return this.options.renderChanges?this.renderContainer(g,"ins"):this.renderChildren(g)}renderDeleted(g){return this.options.renderChanges?this.renderContainer(g,"del"):null}renderSymbol(g){var I=this.createElement("span");return I.style.fontFamily=g.font,I.innerHTML=`&#x${g.char};`,I}renderFootnoteReference(g){var I=this.createElement("sup");return this.currentFootnoteIds.push(g.id),I.textContent=`${this.currentFootnoteIds.length}`,I}renderEndnoteReference(g){var I=this.createElement("sup");return this.currentEndnoteIds.push(g.id),I.textContent=`${this.currentEndnoteIds.length}`,I}renderTab(g){var I,C=this.createElement("span");if(C.innerHTML=" ",this.options.experimental){C.className=this.tabStopClass();var A=null==(I=function(g,I){var C=g.parent;for(;null!=C&&C.type!=I;)C=C.parent;return C}(g,DC.Paragraph))?void 0:I.tabs;this.currentTabs.push({stops:A,span:C})}return C}renderBookmarkStart(g){var I=this.createElement("span");return I.id=g.name,I}renderRun(g){if(g.fieldRun)return null;const I=this.createElement("span");if(g.id&&(I.id=g.id),this.renderClass(g,I),this.renderStyleValues(g.cssStyle,I),g.verticalAlign){const C=this.createElement(g.verticalAlign);this.renderChildren(g,C),I.appendChild(C)}else this.renderChildren(g,I);return I}renderTable(g){let I=this.createElement("table");return this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0},g.columns&&I.appendChild(this.renderTableColumns(g.columns)),this.renderClass(g,I),this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),I}renderTableColumns(g){let I=this.createElement("colgroup");for(let C of g){let g=this.createElement("col");C.width&&(g.style.width=C.width),I.appendChild(g)}return I}renderTableRow(g){let I=this.createElement("tr");return this.currentCellPosition.col=0,this.renderClass(g,I),this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),this.currentCellPosition.row++,I}renderTableCell(g){let I=this.createElement("td");const C=this.currentCellPosition.col;return g.verticalMerge?"restart"==g.verticalMerge?(this.currentVerticalMerge[C]=I,I.rowSpan=1):this.currentVerticalMerge[C]&&(this.currentVerticalMerge[C].rowSpan+=1,I.style.display="none"):this.currentVerticalMerge[C]=null,this.renderClass(g,I),this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),g.span&&(I.colSpan=g.span),this.currentCellPosition.col+=I.colSpan,I}renderVmlPicture(g){var I=EA("div");return this.renderChildren(g,I),I}renderVmlElement(g){var I,C,A=PA("svg");A.setAttribute("style",g.cssStyleText);const i=this.renderVmlChildElement(g);return(null==(I=g.imageHref)?void 0:I.id)&&this.tasks.push(null==(C=this.document)?void 0:C.loadDocumentImage(g.imageHref.id,this.currentPart).then((g=>i.setAttribute("href",g)))),A.appendChild(i),requestAnimationFrame((()=>{const g=A.firstElementChild.getBBox();A.setAttribute("width",`${Math.ceil(g.x+g.width)}`),A.setAttribute("height",`${Math.ceil(g.y+g.height)}`)})),A}renderVmlChildElement(g){const I=PA(g.tagName);Object.entries(g.attrs).forEach((([g,C])=>I.setAttribute(g,C)));for(let C of g.children)C.type==DC.VmlElement?I.appendChild(this.renderVmlChildElement(C)):I.appendChild(...KC(this.renderElement(C)));return I}renderMmlRadical(g){var I;const C=g.children.find((g=>g.type==DC.MmlBase));if(null==(I=g.props)?void 0:I.hideDegree)return _A(QA,"msqrt",null,this.renderElements([C]));const A=g.children.find((g=>g.type==DC.MmlDegree));return _A(QA,"mroot",null,this.renderElements([C,A]))}renderMmlDelimiter(g){var I,C;const A=[];return A.push(_A(QA,"mo",null,[null!==(I=g.props.beginChar)&&void 0!==I?I:"("])),A.push(...this.renderElements(g.children)),A.push(_A(QA,"mo",null,[null!==(C=g.props.endChar)&&void 0!==C?C:")"])),_A(QA,"mrow",null,A)}renderMmlNary(g){var I,C;const A=[],i=RC(g.children,(g=>g.type)),e=i[DC.MmlSuperArgument],t=i[DC.MmlSubArgument],l=e?_A(QA,"mo",null,KC(this.renderElement(e))):null,s=t?_A(QA,"mo",null,KC(this.renderElement(t))):null,o=_A(QA,"mo",null,[null!==(C=null==(I=g.props)?void 0:I.char)&&void 0!==C?C:"∫"]);return l||s?A.push(_A(QA,"munderover",null,[o,s,l])):l?A.push(_A(QA,"mover",null,[o,l])):s?A.push(_A(QA,"munder",null,[o,s])):A.push(o),A.push(...this.renderElements(i[DC.MmlBase].children)),_A(QA,"mrow",null,A)}renderMmlPreSubSuper(g){const I=[],C=RC(g.children,(g=>g.type)),A=C[DC.MmlSuperArgument],i=C[DC.MmlSubArgument],e=A?_A(QA,"mo",null,KC(this.renderElement(A))):null,t=i?_A(QA,"mo",null,KC(this.renderElement(i))):null,l=_A(QA,"mo",null);return I.push(_A(QA,"msubsup",null,[l,t,e])),I.push(...this.renderElements(C[DC.MmlBase].children)),_A(QA,"mrow",null,I)}renderMmlGroupChar(g){const I="bot"===g.props.verticalJustification?"mover":"munder",C=this.renderContainerNS(g,QA,I);return g.props.char&&C.appendChild(_A(QA,"mo",null,[g.props.char])),C}renderMmlBar(g){const I=this.renderContainerNS(g,QA,"mrow");switch(g.props.position){case"top":I.style.textDecoration="overline";break;case"bottom":I.style.textDecoration="underline"}return I}renderMmlRun(g){const I=_A(QA,"ms");return this.renderClass(g,I),this.renderStyleValues(g.cssStyle,I),this.renderChildren(g,I),I}renderMllList(g){const I=_A(QA,"mtable");this.renderClass(g,I),this.renderStyleValues(g.cssStyle,I),this.renderChildren(g);for(let C of this.renderChildren(g))I.appendChild(_A(QA,"mtr",null,[_A(QA,"mtd",null,[C])]));return I}renderStyleValues(g,I){for(let C in g)C.startsWith("$")?I.setAttribute(C.slice(1),g[C]):I.style[C]=g[C]}renderClass(g,I){g.className&&(I.className=g.className),g.styleName&&I.classList.add(this.processStyleName(g.styleName))}findStyle(g){var I;return g&&(null==(I=this.styleMap)?void 0:I[g])}numberingClass(g,I){return`${this.className}-num-${g}-${I}`}tabStopClass(){return`${this.className}-tab-stop`}styleToString(g,I,C=null){let A=`${g} {\r\n`;for(const i in I)i.startsWith("$")||(A+=` ${i}: ${I[i]};\r\n`);return C&&(A+=C),A+"}\r\n"}numberingCounter(g,I){return`${this.className}-num-${g}-${I}`}levelTextToContent(g,I,C,A){var i;return`"${g.replace(/%\d*/g,(g=>{let I=parseInt(g.substring(1),10)-1;return`"counter(${this.numberingCounter(C,I)}, ${A})"`}))}${null!==(i={tab:"\\9",space:"\\a0"}[I])&&void 0!==i?i:""}"`}numFormatToCssValue(g){var I;return null!==(I={none:"none",bullet:"disc",decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero",aiueo:"katakana",aiueoFullWidth:"katakana",chineseCounting:"simp-chinese-informal",chineseCountingThousand:"simp-chinese-informal",chineseLegalSimplified:"simp-chinese-formal",chosung:"hangul-consonant",ideographDigital:"cjk-ideographic",ideographTraditional:"cjk-heavenly-stem",ideographLegalTraditional:"trad-chinese-formal",ideographZodiac:"cjk-earthly-branch",iroha:"katakana-iroha",irohaFullWidth:"katakana-iroha",japaneseCounting:"japanese-informal",japaneseDigitalTenThousand:"cjk-decimal",japaneseLegal:"japanese-formal",thaiNumbers:"thai",koreanCounting:"korean-hangul-formal",koreanDigital:"korean-hangul-formal",koreanDigital2:"korean-hanja-informal",hebrew1:"hebrew",hebrew2:"hebrew",hindiNumbers:"devanagari",ganada:"hangul",taiwaneseCounting:"cjk-ideographic",taiwaneseCountingThousand:"cjk-ideographic",taiwaneseDigital:"cjk-decimal"}[g])&&void 0!==I?I:g}refreshTabStops(){this.options.experimental&&(clearTimeout(this.tabsTimeout),this.tabsTimeout=setTimeout((()=>{const g=function(g=document.body){const I=document.createElement("div");I.style.width="100pt",g.appendChild(I);const C=100/I.offsetWidth;return g.removeChild(I),C}();for(let I of this.currentTabs)xA(I.span,I.stops,this.defaultTabSize,g)}),500))}}function EA(g,I,C){return _A(void 0,g,I,C)}function PA(g,I,C){return _A(jA,g,I,C)}function _A(g,I,C,A){var i=g?document.createElementNS(g,I):document.createElement(I);return Object.assign(i,C),A&&$A(i,A),i}function qA(g){g.innerHTML=""}function $A(g,I){I.forEach((I=>{return g.appendChild("string"==typeof(C=I)||C instanceof String?document.createTextNode(I):I);var C}))}function gi(g){return EA("style",{innerHTML:g})}function Ii(g,I){g.appendChild(document.createComment(I))}const Ci={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,debug:!1,experimental:!1,className:"docx",inWrapper:!0,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1};async function Ai(g,I,C,A){const i=await function(g,I){const C={...Ci,...I};return VA.load(g,new DA(C),C)}(g,A);return await async function(g,I,C,A){const i={...Ci,...A},e=new OA(window.document);return e.render(g,I,C,i),Promise.allSettled(e.tasks.filter((g=>g)))}(i,I,C,A),i}const ii=Object.freeze(Object.defineProperty({__proto__:null,renderDocx:async g=>{if("undefined"!=typeof document){const{bodyContainer:I,styleContainer:C,buffer:A,docxOptions:i={}}=g,e={className:"docx"},t=Object.assign({},e,i);if(I)return Ai(A,I,C,t);{const g=document.createElement("div");return document.body.appendChild(g),Ai(A,g,C,t)}}}},Symbol.toStringTag,{value:"Module"}));class ei{constructor(g,I){C(this,"pdfDoc"),C(this,"pageNumber"),C(this,"total"),C(this,"dom"),C(this,"pdf"),C(this,"onError"),C(this,"onLoad"),C(this,"getPdfPage",(g=>new Promise(((I,C)=>{this.pdfDoc?this.pdfDoc.getPage(g).then((g=>{const C=g.getViewport(),A=document.createElement("canvas");this.dom.appendChild(A);const i=A.getContext("2d"),e=document.body.clientWidth-20,[t,l,s,o]=C.viewBox,c=s>e?e/s:1;A.width=s,A.height=o,C.width=s,C.height=o,A.style.width=Math.floor(C.width)*c+"px",A.style.height=Math.floor(C.height)*c+"px";const d={canvasContext:i,viewport:C,transform:[1,0,0,-1,0,C.height]};g.render(d),I({success:!0,data:g})})):C({success:!1,data:null,message:"pdfDoc is undefined"})})))),C(this,"pdfPreview",(()=>{var g;(g="data:text/javascript;base64,LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICoKICogICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMA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HJpbmcgPSBieXRlc1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSA9IGNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgZXhwb3J0cy5jcmVhdGVWYWxpZEFic29sdXRlVXJsID0gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0TW9kaWZpY2F0aW9uRGF0ZSA9IGdldE1vZGlmaWNhdGlvbkRhdGU7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFZlcmJvc2l0eUxldmVsID0gZ2V0VmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICBleHBvcnRzLmluZm8gPSBpbmZvOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc0FycmF5QnVmZmVyID0gaXNBcnJheUJ1ZmZlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNBcnJheUVxdWFsID0gaXNBcnJheUVxdWFsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5vYmplY3RGcm9tTWFwID0gb2JqZWN0RnJvbU1hcDsKICAgICAgICAgICAgICAgIGV4cG9ydHMub2JqZWN0U2l6ZSA9IG9iamVjdFNpemU7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldFZlcmJvc2l0eUxldmVsID0gc2V0VmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNoYWRvdyA9IHNoYWRvdzsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nMzIgPSBzdHJpbmczMjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nVG9CeXRlcyA9IHN0cmluZ1RvQnl0ZXM7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvUERGU3RyaW5nID0gc3RyaW5nVG9QREZTdHJpbmc7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvVVRGOFN0cmluZyA9IHN0cmluZ1RvVVRGOFN0cmluZzsKICAgICAgICAgICAgICAgIGV4cG9ydHMudW5yZWFjaGFibGUgPSB1bnJlYWNoYWJsZTsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXRmOFN0cmluZ1RvU3RyaW5nID0gdXRmOFN0cmluZ1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy53YXJuID0gd2FybjsKICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsVGhpcy5fcGRmanNDb21wYXRpYmlsaXR5Q2hlY2tlZCkgewogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuX3BkZmpzQ29tcGF0aWJpbGl0eUNoZWNrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oMik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBJREVOVElUWV9NQVRSSVggPSBbMSwgMCwgMCwgMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLklERU5USVRZX01BVFJJWCA9IElERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgIGNvbnN0IEZPTlRfSURFTlRJVFlfTUFUUklYID0gWzAuMDAxLCAwLCAwLCAwLjAwMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLkZPTlRfSURFTlRJVFlfTUFUUklYID0gRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfSU1BR0VfU0laRV9UT19DQUNIRSA9IDEwZTY7CiAgICAgICAgICAgICAgICBleHBvcnRzLk1BWF9JTUFHRV9TSVpFX1RPX0NBQ0hFID0gTUFYX0lNQUdFX1NJWkVfVE9fQ0FDSEU7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0ZBQ1RPUiA9IDEuMzU7CiAgICAgICAgICAgICAgICBleHBvcnRzLkxJTkVfRkFDVE9SID0gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0RFU0NFTlRfRkFDVE9SID0gMC4zNTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTElORV9ERVNDRU5UX0ZBQ1RPUiA9IExJTkVfREVTQ0VOVF9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBCQVNFTElORV9GQUNUT1IgPSBMSU5FX0RFU0NFTlRfRkFDVE9SIC8gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJBU0VMSU5FX0ZBQ1RPUiA9IEJBU0VMSU5FX0ZBQ1RPUjsKICAgICAgICAgICAgICAgIGNvbnN0IFJlbmRlcmluZ0ludGVudEZsYWcgPSB7CiAgICAgICAgICAgICAgICAgICAgQU5ZOiAweDAxLAogICAgICAgICAgICAgICAgICAgIERJU1BMQVk6IDB4MDIsCiAgICAgICAgICAgICAgICAgICAgUFJJTlQ6IDB4MDQsCiAgICAgICAgICAgICAgICAgICAgU0FWRTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19GT1JNUzogMHgxMCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19TVE9SQUdFOiAweDIwLAogICAgICAgICAgICAgICAgICAgIEFOTk9UQVRJT05TX0RJU0FCTEU6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgT1BMSVNUOiAweDEwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nSW50ZW50RmxhZyA9IFJlbmRlcmluZ0ludGVudEZsYWc7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTW9kZSA9IHsKICAgICAgICAgICAgICAgICAgICBESVNBQkxFOiAwLAogICAgICAgICAgICAgICAgICAgIEVOQUJMRTogMSwKICAgICAgICAgICAgICAgICAgICBFTkFCTEVfRk9STVM6IDIsCiAgICAgICAgICAgICAgICAgICAgRU5BQkxFX1NUT1JBR0U6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Nb2RlID0gQW5ub3RhdGlvbk1vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gInBkZmpzX2ludGVybmFsX2VkaXRvcl8iOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gQW5ub3RhdGlvbkVkaXRvclByZWZpeDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JUeXBlID0gewogICAgICAgICAgICAgICAgICAgIERJU0FCTEU6IC0xLAogICAgICAgICAgICAgICAgICAgIE5PTkU6IDAsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFQ6IDMsCiAgICAgICAgICAgICAgICAgICAgSU5LOiAxNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclR5cGUgPSBBbm5vdGF0aW9uRWRpdG9yVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlID0gewogICAgICAgICAgICAgICAgICAgIEZSRUVURVhUX1NJWkU6IDEsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfQ09MT1I6IDIsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfT1BBQ0lUWTogMywKICAgICAgICAgICAgICAgICAgICBJTktfQ09MT1I6IDExLAogICAgICAgICAgICAgICAgICAgIElOS19USElDS05FU1M6IDEyLAogICAgICAgICAgICAgICAgICAgIElOS19PUEFDSVRZOiAxMwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUgPSBBbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFBlcm1pc3Npb25GbGFnID0gewogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9DT05URU5UUzogMHgwOCwKICAgICAgICAgICAgICAgICAgICBDT1BZOiAweDEwLAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9BTk5PVEFUSU9OUzogMHgyMCwKICAgICAgICAgICAgICAgICAgICBGSUxMX0lOVEVSQUNUSVZFX0ZPUk1TOiAweDEwMCwKICAgICAgICAgICAgICAgICAgICBDT1BZX0ZPUl9BQ0NFU1NJQklMSVRZOiAweDIwMCwKICAgICAgICAgICAgICAgICAgICBBU1NFTUJMRTogMHg0MDAsCiAgICAgICAgICAgICAgICAgICAgUFJJTlRfSElHSF9RVUFMSVRZOiAweDgwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUGVybWlzc2lvbkZsYWcgPSBQZXJtaXNzaW9uRmxhZzsKICAgICAgICAgICAgICAgIGNvbnN0IFRleHRSZW5kZXJpbmdNb2RlID0gewogICAgICAgICAgICAgICAgICAgIEZJTEw6IDAsCiAgICAgICAgICAgICAgICAgICAgU1RST0tFOiAxLAogICAgICAgICAgICAgICAgICAgIEZJTExfU1RST0tFOiAyLAogICAgICAgICAgICAgICAgICAgIElOVklTSUJMRTogMywKICAgICAgICAgICAgICAgICAgICBGSUxMX0FERF9UT19QQVRIOiA0LAogICAgICAgICAgICAgICAgICAgIFNUUk9LRV9BRERfVE9fUEFUSDogNSwKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9BRERfVE9fUEFUSDogNiwKICAgICAgICAgICAgICAgICAgICBBRERfVE9fUEFUSDogNywKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9NQVNLOiAzLAogICAgICAgICAgICAgICAgICAgIEFERF9UT19QQVRIX0ZMQUc6IDQKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRSZW5kZXJpbmdNb2RlID0gVGV4dFJlbmRlcmluZ01vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBJbWFnZUtpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JBWVNDQUxFXzFCUFA6IDEsCiAgICAgICAgICAgICAgICAgICAgUkdCXzI0QlBQOiAyLAogICAgICAgICAgICAgICAgICAgIFJHQkFfMzJCUFA6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkltYWdlS2luZCA9IEltYWdlS2luZDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25UeXBlID0gewogICAgICAgICAgICAgICAgICAgIFRFWFQ6IDEsCiAgICAgICAgICAgICAgICAgICAgTElOSzogMiwKICAgICAgICAgICAgICAgICAgICBGUkVFVEVYVDogMywKICAgICAgICAgICAgICAgICAgICBMSU5FOiA0LAogICAgICAgICAgICAgICAgICAgIFNRVUFSRTogNSwKICAgICAgICAgICAgICAgICAgICBDSVJDTEU6IDYsCiAgICAgICAgICAgICAgICAgICAgUE9MWUdPTjogNywKICAgICAgICAgICAgICAgICAgICBQT0xZTElORTogOCwKICAgICAgICAgICAgICAgICAgICBISUdITElHSFQ6IDksCiAgICAgICAgICAgICAgICAgICAgVU5ERVJMSU5FOiAxMCwKICAgICAgICAgICAgICAgICAgICBTUVVJR0dMWTogMTEsCiAgICAgICAgICAgICAgICAgICAgU1RSSUtFT1VUOiAxMiwKICAgICAgICAgICAgICAgICAgICBTVEFNUDogMTMsCiAgICAgICAgICAgICAgICAgICAgQ0FSRVQ6IDE0LAogICAgICAgICAgICAgICAgICAgIElOSzogMTUsCiAgICAgICAgICAgICAgICAgICAgUE9QVVA6IDE2LAogICAgICAgICAgICAgICAgICAgIEZJTEVBVFRBQ0hNRU5UOiAxNywKICAgICAgICAgICAgICAgICAgICBTT1VORDogMTgsCiAgICAgICAgICAgICAgICAgICAgTU9WSUU6IDE5LAogICAgICAgICAgICAgICAgICAgIFdJREdFVDogMjAsCiAgICAgICAgICAgICAgICAgICAgU0NSRUVOOiAyMSwKICAgICAgICAgICAgICAgICAgICBQUklOVEVSTUFSSzogMjIsCiAgICAgICAgICAgICAgICAgICAgVFJBUE5FVDogMjMsCiAgICAgICAgICAgICAgICAgICAgV0FURVJNQVJLOiAyNCwKICAgICAgICAgICAgICAgICAgICBUSFJFRUQ6IDI1LAogICAgICAgICAgICAgICAgICAgIFJFREFDVDogMjYKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25UeXBlID0gQW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBSRVZJRVc6ICJSZXZpZXciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTWFya2VkU3RhdGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBVTk1BUktFRDogIlVubWFya2VkIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbk1hcmtlZFN0YXRlID0gQW5ub3RhdGlvbk1hcmtlZFN0YXRlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvblJldmlld1N0YXRlID0gewogICAgICAgICAgICAgICAgICAgIEFDQ0VQVEVEOiAiQWNjZXB0ZWQiLAogICAgICAgICAgICAgICAgICAgIFJFSkVDVEVEOiAiUmVqZWN0ZWQiLAogICAgICAgICAgICAgICAgICAgIENBTkNFTExFRDogIkNhbmNlbGxlZCIsCiAgICAgICAgICAgICAgICAgICAgQ09NUExFVEVEOiAiQ29tcGxldGVkIiwKICAgICAgICAgICAgICAgICAgICBOT05FOiAiTm9uZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25SZXZpZXdTdGF0ZSA9IEFubm90YXRpb25SZXZpZXdTdGF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25SZXBseVR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JPVVA6ICJHcm91cCIsCiAgICAgICAgICAgICAgICAgICAgUkVQTFk6ICJSIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblJlcGx5VHlwZSA9IEFubm90YXRpb25SZXBseVR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBJTlZJU0lCTEU6IDB4MDEsCiAgICAgICAgICAgICAgICAgICAgSElEREVOOiAweDAyLAogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE5PWk9PTTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBOT1JPVEFURTogMHgxMCwKICAgICAgICAgICAgICAgICAgICBOT1ZJRVc6IDB4MjAsCiAgICAgICAgICAgICAgICAgICAgUkVBRE9OTFk6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEOiAweDgwLAogICAgICAgICAgICAgICAgICAgIFRPR0dMRU5PVklFVzogMHgxMDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEQ09OVEVOVFM6IDB4MjAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRmxhZyA9IEFubm90YXRpb25GbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkZpZWxkRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBSRUFET05MWTogMHgwMDAwMDAxLAogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEOiAweDAwMDAwMDIsCiAgICAgICAgICAgICAgICAgICAgTk9FWFBPUlQ6IDB4MDAwMDAwNCwKICAgICAgICAgICAgICAgICAgICBNVUxUSUxJTkU6IDB4MDAwMTAwMCwKICAgICAgICAgICAgICAgICAgICBQQVNTV09SRDogMHgwMDAyMDAwLAogICAgICAgICAgICAgICAgICAgIE5PVE9HR0xFVE9PRkY6IDB4MDAwNDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJTzogMHgwMDA4MDAwLAogICAgICAgICAgICAgICAgICAgIFBVU0hCVVRUT046IDB4MDAxMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01CTzogMHgwMDIwMDAwLAogICAgICAgICAgICAgICAgICAgIEVESVQ6IDB4MDA0MDAwMCwKICAgICAgICAgICAgICAgICAgICBTT1JUOiAweDAwODAwMDAsCiAgICAgICAgICAgICAgICAgICAgRklMRVNFTEVDVDogMHgwMTAwMDAwLAogICAgICAgICAgICAgICAgICAgIE1VTFRJU0VMRUNUOiAweDAyMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTUEVMTENIRUNLOiAweDA0MDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTQ1JPTEw6IDB4MDgwMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01COiAweDEwMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgUklDSFRFWFQ6IDB4MjAwMDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJT1NJTlVOSVNPTjogMHgyMDAwMDAwLAogICAgICAgICAgICAgICAgICAgIENPTU1JVE9OU0VMQ0hBTkdFOiAweDQwMDAwMDAKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25GaWVsZEZsYWcgPSBBbm5vdGF0aW9uRmllbGRGbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkJvcmRlclN0eWxlVHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBTT0xJRDogMSwKICAgICAgICAgICAgICAgICAgICBEQVNIRUQ6IDIsCiAgICAgICAgICAgICAgICAgICAgQkVWRUxFRDogMywKICAgICAgICAgICAgICAgICAgICBJTlNFVDogNCwKICAgICAgICAgICAgICAgICAgICBVTkRFUkxJTkU6IDUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUgPSBBbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBFOiAiTW91c2UgRW50ZXIiLAogICAgICAgICAgICAgICAgICAgIFg6ICJNb3VzZSBFeGl0IiwKICAgICAgICAgICAgICAgICAgICBEOiAiTW91c2UgRG93biIsCiAgICAgICAgICAgICAgICAgICAgVTogIk1vdXNlIFVwIiwKICAgICAgICAgICAgICAgICAgICBGbzogIkZvY3VzIiwKICAgICAgICAgICAgICAgICAgICBCbDogIkJsdXIiLAogICAgICAgICAgICAgICAgICAgIFBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIFBDOiAiUGFnZUNsb3NlIiwKICAgICAgICAgICAgICAgICAgICBQVjogIlBhZ2VWaXNpYmxlIiwKICAgICAgICAgICAgICAgICAgICBQSTogIlBhZ2VJbnZpc2libGUiLAogICAgICAgICAgICAgICAgICAgIEs6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgIEY6ICJGb3JtYXQiLAogICAgICAgICAgICAgICAgICAgIFY6ICJWYWxpZGF0ZSIsCiAgICAgICAgICAgICAgICAgICAgQzogIkNhbGN1bGF0ZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25BY3Rpb25FdmVudFR5cGUgPSBBbm5vdGF0aW9uQWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgRG9jdW1lbnRBY3Rpb25FdmVudFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgV0M6ICJXaWxsQ2xvc2UiLAogICAgICAgICAgICAgICAgICAgIFdTOiAiV2lsbFNhdmUiLAogICAgICAgICAgICAgICAgICAgIERTOiAiRGlkU2F2ZSIsCiAgICAgICAgICAgICAgICAgICAgV1A6ICJXaWxsUHJpbnQiLAogICAgICAgICAgICAgICAgICAgIERQOiAiRGlkUHJpbnQiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Eb2N1bWVudEFjdGlvbkV2ZW50VHlwZSA9IERvY3VtZW50QWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgUGFnZUFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIEM6ICJQYWdlQ2xvc2UiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlQWN0aW9uRXZlbnRUeXBlID0gUGFnZUFjdGlvbkV2ZW50VHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFZlcmJvc2l0eUxldmVsID0gewogICAgICAgICAgICAgICAgICAgIEVSUk9SUzogMCwKICAgICAgICAgICAgICAgICAgICBXQVJOSU5HUzogMSwKICAgICAgICAgICAgICAgICAgICBJTkZPUzogNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBWZXJib3NpdHlMZXZlbDsKICAgICAgICAgICAgICAgIGNvbnN0IENNYXBDb21wcmVzc2lvblR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTk9ORTogMCwKICAgICAgICAgICAgICAgICAgICBCSU5BUlk6IDEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkNNYXBDb21wcmVzc2lvblR5cGUgPSBDTWFwQ29tcHJlc3Npb25UeXBlOwogICAgICAgICAgICAgICAgY29uc3QgT1BTID0gewogICAgICAgICAgICAgICAgICAgIGRlcGVuZGVuY3k6IDEsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZVdpZHRoOiAyLAogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXA6IDMsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW46IDQsCiAgICAgICAgICAgICAgICAgICAgc2V0TWl0ZXJMaW1pdDogNSwKICAgICAgICAgICAgICAgICAgICBzZXREYXNoOiA2LAogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudDogNywKICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzczogOCwKICAgICAgICAgICAgICAgICAgICBzZXRHU3RhdGU6IDksCiAgICAgICAgICAgICAgICAgICAgc2F2ZTogMTAsCiAgICAgICAgICAgICAgICAgICAgcmVzdG9yZTogMTEsCiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiAxMiwKICAgICAgICAgICAgICAgICAgICBtb3ZlVG86IDEzLAogICAgICAgICAgICAgICAgICAgIGxpbmVUbzogMTQsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzogMTUsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzI6IDE2LAogICAgICAgICAgICAgICAgICAgIGN1cnZlVG8zOiAxNywKICAgICAgICAgICAgICAgICAgICBjbG9zZVBhdGg6IDE4LAogICAgICAgICAgICAgICAgICAgIHJlY3RhbmdsZTogMTksCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlOiAyMCwKICAgICAgICAgICAgICAgICAgICBjbG9zZVN0cm9rZTogMjEsCiAgICAgICAgICAgICAgICAgICAgZmlsbDogMjIsCiAgICAgICAgICAgICAgICAgICAgZW9GaWxsOiAyMywKICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlOiAyNCwKICAgICAgICAgICAgICAgICAgICBlb0ZpbGxTdHJva2U6IDI1LAogICAgICAgICAgICAgICAgICAgIGNsb3NlRmlsbFN0cm9rZTogMjYsCiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2U6IDI3LAogICAgICAgICAgICAgICAgICAgIGVuZFBhdGg6IDI4LAogICAgICAgICAgICAgICAgICAgIGNsaXA6IDI5LAogICAgICAgICAgICAgICAgICAgIGVvQ2xpcDogMzAsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0OiAzMSwKICAgICAgICAgICAgICAgICAgICBlbmRUZXh0OiAzMiwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyU3BhY2luZzogMzMsCiAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmc6IDM0LAogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZTogMzUsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZzogMzYsCiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udDogMzcsCiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGU6IDM4LAogICAgICAgICAgICAgICAgICAgIHNldFRleHRSaXNlOiAzOSwKICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dDogNDAsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0OiA0MSwKICAgICAgICAgICAgICAgICAgICBzZXRUZXh0TWF0cml4OiA0MiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZTogNDMsCiAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQ6IDQ0LAogICAgICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0OiA0NSwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNob3dUZXh0OiA0NiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDogNDcsCiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoOiA0OCwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyV2lkdGhBbmRCb3VuZHM6IDQ5LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yU3BhY2U6IDUwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvclNwYWNlOiA1MSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDb2xvcjogNTIsCiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOOiA1MywKICAgICAgICAgICAgICAgICAgICBzZXRGaWxsQ29sb3I6IDU0LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck46IDU1LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUdyYXk6IDU2LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxHcmF5OiA1NywKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VSR0JDb2xvcjogNTgsCiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yOiA1OSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDTVlLQ29sb3I6IDYwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDTVlLQ29sb3I6IDYxLAogICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsOiA2MiwKICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlOiA2MywKICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YTogNjQsCiAgICAgICAgICAgICAgICAgICAgZW5kSW5saW5lSW1hZ2U6IDY1LAogICAgICAgICAgICAgICAgICAgIHBhaW50WE9iamVjdDogNjYsCiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50OiA2NywKICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wczogNjgsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50OiA2OSwKICAgICAgICAgICAgICAgICAgICBiZWdpbk1hcmtlZENvbnRlbnRQcm9wczogNzAsCiAgICAgICAgICAgICAgICAgICAgZW5kTWFya2VkQ29udGVudDogNzEsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Db21wYXQ6IDcyLAogICAgICAgICAgICAgICAgICAgIGVuZENvbXBhdDogNzMsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luOiA3NCwKICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kOiA3NSwKICAgICAgICAgICAgICAgICAgICBiZWdpbkdyb3VwOiA3NiwKICAgICAgICAgICAgICAgICAgICBlbmRHcm91cDogNzcsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Bbm5vdGF0aW9uOiA4MCwKICAgICAgICAgICAgICAgICAgICBlbmRBbm5vdGF0aW9uOiA4MSwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3Q6IDgzLAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwOiA4NCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdDogODUsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRJbmxpbmVJbWFnZVhPYmplY3Q6IDg2LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXA6IDg3LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0OiA4OCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3RSZXBlYXQ6IDg5LAogICAgICAgICAgICAgICAgICAgIHBhaW50U29saWRDb2xvckltYWdlTWFzazogOTAsCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aDogOTEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLk9QUyA9IE9QUzsKICAgICAgICAgICAgICAgIGNvbnN0IFBhc3N3b3JkUmVzcG9uc2VzID0gewogICAgICAgICAgICAgICAgICAgIE5FRURfUEFTU1dPUkQ6IDEsCiAgICAgICAgICAgICAgICAgICAgSU5DT1JSRUNUX1BBU1NXT1JEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXNzd29yZFJlc3BvbnNlcyA9IFBhc3N3b3JkUmVzcG9uc2VzOwogICAgICAgICAgICAgICAgbGV0IHZlcmJvc2l0eSA9IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2V0VmVyYm9zaXR5TGV2ZWwobGV2ZWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5ID0gbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0VmVyYm9zaXR5TGV2ZWwoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGluZm8obXNnKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZlcmJvc2l0eSA+PSBWZXJib3NpdHlMZXZlbC5JTkZPUykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhgSW5mbzogJHttc2d9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fybihtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmVyYm9zaXR5ID49IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGBXYXJuaW5nOiAke21zZ31gKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1bnJlYWNoYWJsZShtc2cpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFzc2VydChjb25kLCBtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUobXNnKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZFByb3RvY29sKHVybCkgewogICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh1cmwucHJvdG9jb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiaHR0cDoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJodHRwczoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJmdHA6IjoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibWFpbHRvOiI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRlbDoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYmFzZVVybCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBsZXQgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLmFkZERlZmF1bHRQcm90b2NvbCAmJiB1cmwuc3RhcnRzV2l0aCgid3d3LiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZG90cyA9IHVybC5tYXRjaCgvXC4vZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvdHMgJiYgZG90cy5sZW5ndGggPj0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMudHJ5Q29udmVydEVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gc3RyaW5nVG9VVEY4U3RyaW5nKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzVmFsaWRQcm90b2NvbChhYnNvbHV0ZVVybCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2hhZG93KG9iaiwgcHJvcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbm9uU2VyaWFsaXphYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBwcm9wLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhbm9uU2VyaWFsaXphYmxlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IEJhc2VFeGNlcHRpb24gPSBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uQ2xvc3VyZSgpIHsKICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uKG1lc3NhZ2UsIG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVucmVhY2hhYmxlKCJDYW5ub3QgaW5pdGlhbGl6ZSBCYXNlRXhjZXB0aW9uLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEJhc2VFeGNlcHRpb24ucHJvdG90eXBlID0gbmV3IEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgQmFzZUV4Y2VwdGlvbi5jb25zdHJ1Y3RvciA9IEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VFeGNlcHRpb24gPSBCYXNlRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgUGFzc3dvcmRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiUGFzc3dvcmRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlID0gY29kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBhc3N3b3JkRXhjZXB0aW9uID0gUGFzc3dvcmRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBVbmtub3duRXJyb3JFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiVW5rbm93bkVycm9yRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWlscyA9IGRldGFpbHM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Vbmtub3duRXJyb3JFeGNlcHRpb24gPSBVbmtub3duRXJyb3JFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBJbnZhbGlkUERGRXhjZXB0aW9uIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkludmFsaWRQREZFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkludmFsaWRQREZFeGNlcHRpb24gPSBJbnZhbGlkUERGRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgTWlzc2luZ1BERkV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihtc2csICJNaXNzaW5nUERGRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NaXNzaW5nUERGRXhjZXB0aW9uID0gTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZywgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXR1cyA9IHN0YXR1czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiA9IFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIEZvcm1hdEVycm9yIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkZvcm1hdEVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Gb3JtYXRFcnJvciA9IEZvcm1hdEVycm9yOwogICAgICAgICAgICAgICAgY2xhc3MgQWJvcnRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2cpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiQWJvcnRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkFib3J0RXhjZXB0aW9uID0gQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBieXRlc1RvU3RyaW5nKGJ5dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBieXRlcyAhPT0gIm9iamVjdCIgfHwgYnl0ZXMgPT09IG51bGwgfHwgYnl0ZXMubGVuZ3RoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUoIkludmFsaWQgYXJndW1lbnQgZm9yIGJ5dGVzVG9TdHJpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9BUkdVTUVOVF9DT1VOVCA9IDgxOTI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCBieXRlcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0VuZCA9IE1hdGgubWluKGkgKyBNQVhfQVJHVU1FTlRfQ09VTlQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gYnl0ZXMuc3ViYXJyYXkoaSwgY2h1bmtFbmQpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb0J5dGVzKHN0cikgewogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RyICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICB1bnJlYWNoYWJsZSgiSW52YWxpZCBhcmd1bWVudCBmb3Igc3RyaW5nVG9CeXRlcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBzdHIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkobGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2ldID0gc3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmczMih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHZhbHVlID4+IDI0ICYgMHhmZiwgdmFsdWUgPj4gMTYgJiAweGZmLCB2YWx1ZSA+PiA4ICYgMHhmZiwgdmFsdWUgJiAweGZmKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9iamVjdFNpemUob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKG9iaikubGVuZ3RoOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gb2JqZWN0RnJvbU1hcChtYXApIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNMaXR0bGVFbmRpYW4oKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyOCA9IG5ldyBVaW50OEFycmF5KDQpOwogICAgICAgICAgICAgICAgICAgIGJ1ZmZlcjhbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXczMiA9IG5ldyBVaW50MzJBcnJheShidWZmZXI4LmJ1ZmZlciwgMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXczMlswXSA9PT0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzRXZhbFN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBuZXcgRnVuY3Rpb24oIiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGZWF0dXJlVGVzdCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0xpdHRsZUVuZGlhbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNMaXR0bGVFbmRpYW4iLCBpc0xpdHRsZUVuZGlhbigpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0V2YWxTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaGFkb3codGhpcywgImlzRXZhbFN1cHBvcnRlZCIsIGlzRXZhbFN1cHBvcnRlZCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQiLCB0eXBlb2YgT2Zmc2NyZWVuQ2FudmFzICE9PSAidW5kZWZpbmVkIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgcGxhdGZvcm0oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgbmF2aWdhdG9yID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW46IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1dpbjogbmF2aWdhdG9yLnBsYXRmb3JtLmluY2x1ZGVzKCJXaW4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBuYXZpZ2F0b3IucGxhdGZvcm0uaW5jbHVkZXMoIk1hYyIpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRmVhdHVyZVRlc3QgPSBGZWF0dXJlVGVzdDsKICAgICAgICAgICAgICAgIGNvbnN0IGhleE51bWJlcnMgPSBbLi4uQXJyYXkoMjU2KS5rZXlzKCldLm1hcChuID0+IG4udG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIikpOwogICAgICAgICAgICAgICAgY2xhc3MgVXRpbCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG1ha2VIZXhDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7aGV4TnVtYmVyc1tyXX0ke2hleE51bWJlcnNbZ119JHtoZXhOdW1iZXJzW2JdfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzNdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IG1pbk1heFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzFdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm1bMl0gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzFdID0gdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gKj0gdHJhbnNmb3JtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsyXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0cmFuc2Zvcm0obTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbTFbMF0gKiBtMlswXSArIG0xWzJdICogbTJbMV0sIG0xWzFdICogbTJbMF0gKyBtMVszXSAqIG0yWzFdLCBtMVswXSAqIG0yWzJdICsgbTFbMl0gKiBtMlszXSwgbTFbMV0gKiBtMlsyXSArIG0xWzNdICogbTJbM10sIG0xWzBdICogbTJbNF0gKyBtMVsyXSAqIG0yWzVdICsgbTFbNF0sIG0xWzFdICogbTJbNF0gKyBtMVszXSAqIG0yWzVdICsgbTFbNV1dOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYXBwbHlUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4dCA9IHBbMF0gKiBtWzBdICsgcFsxXSAqIG1bMl0gKyBtWzRdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5dCA9IHBbMF0gKiBtWzFdICsgcFsxXSAqIG1bM10gKyBtWzVdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3h0LCB5dF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhcHBseUludmVyc2VUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gbVswXSAqIG1bM10gLSBtWzFdICogbVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHQgPSAocFswXSAqIG1bM10gLSBwWzFdICogbVsyXSArIG1bMl0gKiBtWzVdIC0gbVs0XSAqIG1bM10pIC8gZDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXQgPSAoLXBbMF0gKiBtWzFdICsgcFsxXSAqIG1bMF0gKyBtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeHQsIHl0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldEF4aWFsQWxpZ25lZEJvdW5kaW5nQm94KHIsIG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEgPSBVdGlsLmFwcGx5VHJhbnNmb3JtKHIsIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMiA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oci5zbGljZSgyLCA0KSwgbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzID0gVXRpbC5hcHBseVRyYW5zZm9ybShbclswXSwgclszXV0sIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNCA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JbMl0sIHJbMV1dLCBtKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbihwMVswXSwgcDJbMF0sIHAzWzBdLCBwNFswXSksIE1hdGgubWluKHAxWzFdLCBwMlsxXSwgcDNbMV0sIHA0WzFdKSwgTWF0aC5tYXgocDFbMF0sIHAyWzBdLCBwM1swXSwgcDRbMF0pLCBNYXRoLm1heChwMVsxXSwgcDJbMV0sIHAzWzFdLCBwNFsxXSldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW52ZXJzZVRyYW5zZm9ybShtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzBdICogbVszXSAtIG1bMV0gKiBtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW21bM10gLyBkLCAtbVsxXSAvIGQsIC1tWzJdIC8gZCwgbVswXSAvIGQsIChtWzJdICogbVs1XSAtIG1bNF0gKiBtWzNdKSAvIGQsIChtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc3Bvc2UgPSBbbVswXSwgbVsyXSwgbVsxXSwgbVszXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBtWzBdICogdHJhbnNwb3NlWzBdICsgbVsxXSAqIHRyYW5zcG9zZVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IG1bMF0gKiB0cmFuc3Bvc2VbMV0gKyBtWzFdICogdHJhbnNwb3NlWzNdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gbVsyXSAqIHRyYW5zcG9zZVswXSArIG1bM10gKiB0cmFuc3Bvc2VbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzJdICogdHJhbnNwb3NlWzFdICsgbVszXSAqIHRyYW5zcG9zZVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlyc3QgPSAoYSArIGQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2Vjb25kID0gTWF0aC5zcXJ0KChhICsgZCkgKiogMiAtIDQgKiAoYSAqIGQgLSBjICogYikpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ggPSBmaXJzdCArIHNlY29uZCB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzeSA9IGZpcnN0IC0gc2Vjb25kIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbTWF0aC5zcXJ0KHN4KSwgTWF0aC5zcXJ0KHN5KV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemVSZWN0KHJlY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgciA9IHJlY3Quc2xpY2UoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0WzBdID4gcmVjdFsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgclswXSA9IHJlY3RbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByWzJdID0gcmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVjdFsxXSA+IHJlY3RbM10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJbMV0gPSByZWN0WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgclszXSA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBpbnRlcnNlY3QocmVjdDEsIHJlY3QyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhMb3cgPSBNYXRoLm1heChNYXRoLm1pbihyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1pbihyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeEhpZ2ggPSBNYXRoLm1pbihNYXRoLm1heChyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1heChyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhMb3cgPiB4SGlnaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeUxvdyA9IE1hdGgubWF4KE1hdGgubWluKHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWluKHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5SGlnaCA9IE1hdGgubWluKE1hdGgubWF4KHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWF4KHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hMb3csIHlMb3csIHhIaWdoLCB5SGlnaF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBiZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHZhbHVlcyA9IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzID0gW1tdLCBbXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhLCBiLCBjLCB0LCB0MSwgdDIsIGIyYWMsIHNxcnRiMmFjOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHgwIC0gMTIgKiB4MSArIDYgKiB4MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB4MCArIDkgKiB4MSAtIDkgKiB4MiArIDMgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHgxIC0gMyAqIHgwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHkwIC0gMTIgKiB5MSArIDYgKiB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB5MCArIDkgKiB5MSAtIDkgKiB5MiArIDMgKiB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHkxIC0gMyAqIHkwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKGEpIDwgMWUtMTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoYikgPCAxZS0xMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHZhbHVlcy5wdXNoKHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGIyYWMgPSBiICogYiAtIDQgKiBjICogYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNxcnRiMmFjID0gTWF0aC5zcXJ0KGIyYWMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MSA9ICgtYiArIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MiA9ICgtYiAtIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGogPSB0dmFsdWVzLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqbGVuID0gajsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGotLSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IHR2YWx1ZXNbal07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2pdID0gbXQgKiBtdCAqIG10ICogeDAgKyAzICogbXQgKiBtdCAqIHQgKiB4MSArIDMgKiBtdCAqIHQgKiB0ICogeDIgKyB0ICogdCAqIHQgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqXSA9IG10ICogbXQgKiBtdCAqIHkwICsgMyAqIG10ICogbXQgKiB0ICogeTEgKyAzICogbXQgKiB0ICogdCAqIHkyICsgdCAqIHQgKiB0ICogeTM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuXSA9IHkwOwogICAgICAgICAgICAgICAgICAgICAgICBib3VuZHNbMF1bamxlbiArIDFdID0geDM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdLmxlbmd0aCA9IGJvdW5kc1sxXS5sZW5ndGggPSBqbGVuICsgMjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbiguLi5ib3VuZHNbMF0pLCBNYXRoLm1pbiguLi5ib3VuZHNbMV0pLCBN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4MTQyLCAweDE1MywgMHgxNjEsIDB4MTdlLCAwLCAweDIwYWNdOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc3RyaW5nVG9QREZTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0clswXSA+PSAiXHhFRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVuY29kaW5nOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyWzBdID09PSAiXHhGRSIgJiYgc3RyWzFdID09PSAiXHhGRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuY29kaW5nID0gInV0Zi0xNmJlIjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJbMF0gPT09ICJceEZGIiAmJiBzdHJbMV0gPT09ICJceEZFIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2RpbmcgPSAidXRmLTE2bGUiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0clswXSA9PT0gIlx4RUYiICYmIHN0clsxXSA9PT0gIlx4QkIiICYmIHN0clsyXSA9PT0gIlx4QkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGluZyA9ICJ1dGYtOCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBzdHJpbmdUb0J5dGVzKHN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZXIuZGVjb2RlKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm4oYHN0cmluZ1RvUERGU3RyaW5nOiAiJHtleH0iLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHN0ci5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBQREZTdHJpbmdUcmFuc2xhdGVUYWJsZVtzdHIuY2hhckNvZGVBdChpKV07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKGNvZGUgPyBTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpIDogc3RyLmNoYXJBdChpKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb1VURjhTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoc3RyKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1dGY4U3RyaW5nVG9TdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXNjYXBlKGVuY29kZVVSSUNvbXBvbmVudChzdHIpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlCdWZmZXIodikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgdiA9PT0gIm9iamVjdCIgJiYgdiAhPT0gbnVsbCAmJiB2LmJ5dGVMZW5ndGggIT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlFcXVhbChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFycjEubGVuZ3RoICE9PSBhcnIyLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGFycjEubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJyMVtpXSAhPT0gYXJyMltpXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0TW9kaWZpY2F0aW9uRGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IERhdGUoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbZGF0ZS5nZXRVVENGdWxsWWVhcigpLnRvU3RyaW5nKCksIChkYXRlLmdldFVUQ01vbnRoKCkgKyAxKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIiksIGRhdGUuZ2V0VVRDRGF0ZSgpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENIb3VycygpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENNaW51dGVzKCkudG9TdHJpbmcoKS5wYWRTdGFydCgyLCAiMCIpLCBkYXRlLmdldFVUQ1NlY29uZHMoKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIildOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSgpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaXNTZXR0bGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGNhcGFiaWxpdHksICJzZXR0bGVkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTZXR0bGVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlID0gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUgPSBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0ID0gZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja0RPTU1hdHJpeCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsVGhpcy5ET01NYXRyaXggfHwgIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsVGhpcy5ET01NYXRyaXggPSByZXF1aXJlKCJjYW52YXMiKS5ET01NYXRyaXg7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrUGF0aDJEKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlBhdGgyRCB8fCAhX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRAogICAgICAgICAgICAgICAgICAgIH0gPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJECiAgICAgICAgICAgICAgICAgICAgfSA9IHJlcXVpcmUoInBhdGgyZC1wb2x5ZmlsbCIpOwogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEID0gQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEOwogICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJEKGdsb2JhbFRoaXMpOwogICAgICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja1JlYWRhYmxlU3RyZWFtKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlJlYWRhYmxlU3RyZWFtIHx8ICFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuUmVhZGFibGVTdHJlYW0gPSByZXF1aXJlKCJ3ZWItc3RyZWFtcy1wb2x5ZmlsbC9kaXN0L3BvbnlmaWxsLmpzIikuUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrQXJyYXlBdCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg0KTsKICAgICAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgICAgICAoZnVuY3Rpb24gY2hlY2tUeXBlZEFycmF5QXQoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKFVpbnQ4QXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OCk7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrU3RydWN0dXJlZENsb25lKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLnN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTApOwogICAgICAgICAgICAgICAgfSkoKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgaXNOb2RlSlMgPSB0eXBlb2YgcHJvY2VzcyA9PT0gIm9iamVjdCIgJiYgcHJvY2VzcyArICIiID09PSAiW29iamVjdCBwcm9jZXNzXSIgJiYgIXByb2Nlc3MudmVyc2lvbnMubncgJiYgIShwcm9jZXNzLnZlcnNpb25zLmVsZWN0cm9uICYmIHByb2Nlc3MudHlwZSAmJiBwcm9jZXNzLnR5cGUgIT09ICJicm93c2VyIik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gaXNOb2RlSlM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oNSk7CiAgICAgICAgICAgICAgICB2YXIgZW50cnlVbmJpbmQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDc3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZW50cnlVbmJpbmQoJ0FycmF5JywgJ2F0Jyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciAkID0gX193X3BkZmpzX3JlcXVpcmVfXyg2KTsKICAgICAgICAgICAgICAgIHZhciB0b09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFkZFRvVW5zY29wYWJsZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcyKTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIHRhcmdldDogJ0FycmF5JywKICAgICAgICAgICAgICAgICAgICBwcm90bzogdHJ1ZQogICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgIGF0OiBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGVuID0gbGVuZ3RoT2ZBcnJheUxpa2UoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrID0gcmVsYXRpdmVJbmRleCA+PSAwID8gcmVsYXRpdmVJbmRleCA6IGxlbiArIHJlbGF0aXZlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBrIDwgMCB8fCBrID49IGxlbiA/IHVuZGVmaW5lZCA6IE9ba107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdhdCcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg4KS5mKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBjb3B5Q29uc3RydWN0b3JQcm9wZXJ0aWVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OSk7CiAgICAgICAgICAgICAgICB2YXIgaXNGb3JjZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9wdGlvbnMsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBUQVJHRVQgPSBvcHRpb25zLnRhcmdldDsKICAgICAgICAgICAgICAgICAgICB2YXIgR0xPQkFMID0gb3B0aW9ucy5nbG9iYWw7CiAgICAgICAgICAgICAgICAgICAgdmFyIFNUQVRJQyA9IG9wdGlvbnMuc3RhdDsKICAgICAgICAgICAgICAgICAgICB2YXIgRk9SQ0VELCB0YXJnZXQsIGtleSwgdGFyZ2V0UHJvcGVydHksIHNvdXJjZVByb3BlcnR5LCBkZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgICAgIGlmIChHTE9CQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0ID0gZ2xvYmFsOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoU1RBVElDKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IGdsb2JhbFtUQVJHRVRdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFRBUkdFVCwge30pOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IChnbG9iYWxbVEFSR0VUXSB8fCB7fSkucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGtleSBpbiBzb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZVByb3BlcnR5ID0gc291cmNlW2tleV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5kb250Q2FsbEdldFNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFByb3BlcnR5ID0gZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0UHJvcGVydHkgPSB0YXJnZXRba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZPUkNFRCA9IGlzRm9yY2VkKEdMT0JBTCA/IGtleSA6IFRBUkdFVCArIChTVEFUSUMgPyAnLicgOiAnIycpICsga2V5LCBvcHRpb25zLmZvcmNlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUZPUkNFRCAmJiB0YXJnZXRQcm9wZXJ0eSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2VQcm9wZXJ0eSA9PSB0eXBlb2YgdGFyZ2V0UHJvcGVydHkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDb25zdHJ1Y3RvclByb3BlcnRpZXMoc291cmNlUHJvcGVydHksIHRhcmdldFByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLnNoYW0gfHwgdGFyZ2V0UHJvcGVydHkgJiYgdGFyZ2V0UHJvcGVydHkuc2hhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShzb3VyY2VQcm9wZXJ0eSwgJ3NoYW0nLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNvdXJjZVByb3BlcnR5LCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjaGVjayA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCAmJiBpdC5NYXRoID09IE1hdGggJiYgaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBjaGVjayh0eXBlb2YgZ2xvYmFsVGhpcyA9PSAnb2JqZWN0JyAmJiBnbG9iYWxUaGlzKSB8fCBjaGVjayh0eXBlb2Ygd2luZG93ID09ICdvYmplY3QnICYmIHdpbmRvdykgfHwgY2hlY2sodHlwZW9mIHNlbGYgPT0gJ29iamVjdCcgJiYgc2VsZikgfHwgY2hlY2sodHlwZW9mIGdsb2JhbCA9PSAnb2JqZWN0JyAmJiBnbG9iYWwpIHx8IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9KCkpIHx8IEZ1bmN0aW9uKCdyZXR1cm4gdGhpcycpKCk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9Qcm9wZXJ0eUtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjEpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIElFOF9ET01fREVGSU5FID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NSk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/ICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgOiBmdW5jdGlvbiBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCkgewogICAgICAgICAgICAgICAgICAgIE8gPSB0b0luZGV4ZWRPYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgUCA9IHRvUHJvcGVydHlLZXkoUCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKElFOF9ET01fREVGSU5FKQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGFzT3duKE8sIFApKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKCFjYWxsKHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlLmYsIE8sIFApLCBPW1BdKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoe30sIDEsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pWzFdICE9IDc7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChleGVjKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZXhlYygpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gRnVuY3Rpb24ucHJvdG90eXBlLmNhbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gY2FsbC5iaW5kKGNhbGwpIDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGNhbGwsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlc3QgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfS5iaW5kKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiB0ZXN0ICE9ICdmdW5jdGlvbicgfHwgdGVzdC5oYXNPd25Qcm9wZXJ0eSgncHJvdG90eXBlJyk7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJHByb3BlcnR5SXNFbnVtZXJhYmxlID0ge30ucHJvcGVydHlJc0VudW1lcmFibGU7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcjsKICAgICAgICAgICAgICAgIHZhciBOQVNIT1JOX0JVRyA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvciAmJiAhJHByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoeyAxOiAyIH0sIDEpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gTkFTSE9STl9CVUcgPyBmdW5jdGlvbiBwcm9wZXJ0eUlzRW51bWVyYWJsZShWKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGhpcywgVik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLmVudW1lcmFibGU7CiAgICAgICAgICAgICAgICB9IDogJHByb3BlcnR5SXNFbnVtZXJhYmxlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGJpdG1hcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhKGJpdG1hcCAmIDEpLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6ICEoYml0bWFwICYgMiksCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiAhKGJpdG1hcCAmIDQpLAogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNik7CiAgICAgICAgICAgICAgICB2YXIgcmVxdWlyZU9iamVjdENvZXJjaWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gSW5kZXhlZE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGl0KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBzcGxpdCA9IHVuY3VycnlUaGlzKCcnLnNwbGl0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhJE9iamVjdCgneicpLnByb3BlcnR5SXNFbnVtZXJhYmxlKDApOwogICAgICAgICAgICAgICAgfSkgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xhc3NvZihpdCkgPT0gJ1N0cmluZycgPyBzcGxpdChpdCwgJycpIDogJE9iamVjdChpdCk7CiAgICAgICAgICAgICAgICB9IDogJE9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfQklORCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBGdW5jdGlvblByb3RvdHlwZS5jYWxsOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzV2l0aEJpbmQgPSBOQVRJVkVfQklORCAmJiBGdW5jdGlvblByb3RvdHlwZS5iaW5kLmJpbmQoY2FsbCwgY2FsbCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gdW5jdXJyeVRoaXNXaXRoQmluZCA6IGZ1bmN0aW9uIChmbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGZuLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyh7fS50b1N0cmluZyk7CiAgICAgICAgICAgICAgICB2YXIgc3RyaW5nU2xpY2UgPSB1bmN1cnJ5VGhpcygnJy5zbGljZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJpbmdTbGljZSh0b1N0cmluZyhpdCksIDgsIC0xKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCJDYW4ndCBjYWxsIG1ldGhvZCBvbiAiICsgaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQgPT09IG51bGwgfHwgaXQgPT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIyKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0gdG9QcmltaXRpdmUoYXJndW1lbnQsICdzdHJpbmcnKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTeW1ib2woa2V5KSA/IGtleSA6IGtleSArICcnOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIG9yZGluYXJ5VG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM2KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFRPX1BSSU1JVElWRSA9IHdlbGxLbm93blN5bWJvbCgndG9QcmltaXRpdmUnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGlucHV0LCBwcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChpbnB1dCkgfHwgaXNTeW1ib2woaW5wdXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7CiAgICAgICAgICAgICAgICAgICAgdmFyIGV4b3RpY1RvUHJpbSA9IGdldE1ldGhvZChpbnB1dCwgVE9fUFJJTUlUSVZFKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChleG90aWNUb1ByaW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgPT09IHVuZGVmaW5lZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnZGVmYXVsdCc7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGNhbGwoZXhvdGljVG9QcmltLCBpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QocmVzdWx0KSB8fCBpc1N5bWJvbChyZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSB1bmRlZmluZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnbnVtYmVyJzsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3JkaW5hcnlUb1ByaW1pdGl2ZShpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnb2JqZWN0JyA/IGl0ICE9PSBudWxsIDogaXNDYWxsYWJsZShpdCkgfHwgaXQgPT09IGRvY3VtZW50QWxsOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgaXQgPT0gJ29iamVjdCcgPyBpdCAhPT0gbnVsbCA6IGlzQ2FsbGFibGUoaXQpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBhcmd1bWVudCA9PSAnZnVuY3Rpb24nIHx8IGFyZ3VtZW50ID09PSBkb2N1bWVudEFsbDsKICAgICAgICAgICAgICAgIH0gOiBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGFyZ3VtZW50ID09ICdmdW5jdGlvbic7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9IHR5cGVvZiBkb2N1bWVudCA9PSAnb2JqZWN0JyAmJiBkb2N1bWVudC5hbGw7CiAgICAgICAgICAgICAgICB2YXIgSVNfSFRNTEREQSA9IHR5cGVvZiBkb2N1bWVudEFsbCA9PSAndW5kZWZpbmVkJyAmJiBkb2N1bWVudEFsbCAhPT0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgYWxsOiBkb2N1bWVudEFsbCwKICAgICAgICAgICAgICAgICAgICBJU19IVE1MRERBOiBJU19IVE1MRERBCiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gVVNFX1NZTUJPTF9BU19VSUQgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGl0ID09ICdzeW1ib2wnOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciAkU3ltYm9sID0gZ2V0QnVpbHRJbignU3ltYm9sJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ2FsbGFibGUoJFN5bWJvbCkgJiYgaXNQcm90b3R5cGVPZigkU3ltYm9sLnByb3RvdHlwZSwgJE9iamVjdChpdCkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBhRnVuY3Rpb24gPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZShhcmd1bWVudCkgPyBhcmd1bWVudCA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChuYW1lc3BhY2UsIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoIDwgMiA/IGFGdW5jdGlvbihnbG9iYWxbbmFtZXNwYWNlXSkgOiBnbG9iYWxbbmFtZXNwYWNlXSAmJiBnbG9iYWxbbmFtZXNwYWNlXVttZXRob2RdOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB1bmN1cnJ5VGhpcyh7fS5pc1Byb3RvdHlwZU9mKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfU1lNQk9MID0gX193X3BkZmpzX3JlcXVpcmVfXygzMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9TWU1CT0wgJiYgIVN5bWJvbC5zaGFtICYmIHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgPT0gJ3N5bWJvbCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDMwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVjhfVkVSU0lPTiA9IF9fd19wZGZqc19yZXF1aXJlX18oMzEpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICEhT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBzeW1ib2wgPSBTeW1ib2woKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIVN0cmluZyhzeW1ib2wpIHx8ICEoT2JqZWN0KHN5bWJvbCkgaW5zdGFuY2VvZiBTeW1ib2wpIHx8ICFTeW1ib2wuc2hhbSAmJiBWOF9WRVJTSU9OICYmIFY4X1ZFUlNJT04gPCA0MTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgdXNlckFnZW50ID0gX193X3BkZmpzX3JlcXVpcmVfXygzMik7CiAgICAgICAgICAgICAgICB2YXIgcHJvY2VzcyA9IGdsb2JhbC5wcm9jZXNzOwogICAgICAgICAgICAgICAgdmFyIERlbm8gPSBnbG9iYWwuRGVubzsKICAgICAgICAgICAgICAgIHZhciB2ZXJzaW9ucyA9IHByb2Nlc3MgJiYgcHJvY2Vzcy52ZXJzaW9ucyB8fCBEZW5vICYmIERlbm8udmVyc2lvbjsKICAgICAgICAgICAgICAgIHZhciB2OCA9IHZlcnNpb25zICYmIHZlcnNpb25zLnY4OwogICAgICAgICAgICAgICAgdmFyIG1hdGNoLCB2ZXJzaW9uOwogICAgICAgICAgICAgICAgaWYgKHY4KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB2OC5zcGxpdCgnLicpOwogICAgICAgICAgICAgICAgICAgIHZlcnNpb24gPSBtYXRjaFswXSA+IDAgJiYgbWF0Y2hbMF0gPCA0ID8gMSA6ICsobWF0Y2hbMF0gKyBtYXRjaFsxXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXZlcnNpb24gJiYgdXNlckFnZW50KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB1c2VyQWdlbnQubWF0Y2goL0VkZ2VcLyhcZCspLyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXRjaCB8fCBtYXRjaFsxXSA+PSA3NCkgewogICAgICAgICAgICAgICAgICAgICAgICBtYXRjaCA9IHVzZXJBZ2VudC5tYXRjaCgvQ2hyb21lXC8oXGQrKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uID0gK21hdGNoWzFdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdmVyc2lvbjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBuYXZpZ2F0b3IgIT0gJ3VuZGVmaW5lZCcgJiYgU3RyaW5nKG5hdmlnYXRvci51c2VyQWdlbnQpIHx8ICcnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChWLCBQKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZ1bmMgPSBWW1BdOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpc051bGxPclVuZGVmaW5lZChmdW5jKSA/IHVuZGVmaW5lZCA6IGFDYWxsYWJsZShmdW5jKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJFN0cmluZyhhcmd1bWVudCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdPYmplY3QnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpbnB1dCwgcHJlZikgewogICAgICAgICAgICAgICAgICAgIHZhciBmbiwgdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSAnc3RyaW5nJyAmJiBpc0NhbGxhYmxlKGZuID0gaW5wdXQudG9TdHJpbmcpICYmICFpc09iamVjdCh2YWwgPSBjYWxsKGZuLCBpbnB1dCkpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKGZuID0gaW5wdXQudmFsdWVPZikgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgIT09ICdzdHJpbmcnICYmIGlzQ2FsbGFibGUoZm4gPSBpbnB1dC50b1N0cmluZykgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX1NZTUJPTCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzApOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgU3ltYm9sID0gZ2xvYmFsLlN5bWJvbDsKICAgICAgICAgICAgICAgIHZhciBXZWxsS25vd25TeW1ib2xzU3RvcmUgPSBzaGFyZWQoJ3drcycpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVdlbGxLbm93blN5bWJvbCA9IFVTRV9TWU1CT0xfQVNfVUlEID8gU3ltYm9sWydmb3InXSB8fCBTeW1ib2wgOiBTeW1ib2wgJiYgU3ltYm9sLndpdGhvdXRTZXR0ZXIgfHwgdWlkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAobmFtZSkgewogICAgICAgICAgICAgICAgICAgIGlmICghaGFzT3duKFdlbGxLbm93blN5bWJvbHNTdG9yZSwgbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgV2VsbEtub3duU3ltYm9sc1N0b3JlW25hbWVdID0gTkFUSVZFX1NZTUJPTCAmJiBoYXNPd24oU3ltYm9sLCBuYW1lKSA/IFN5bWJvbFtuYW1lXSA6IGNyZWF0ZVdlbGxLbm93blN5bWJvbCgnU3ltYm9sLicgKyBuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFdlbGxLbm93blN5bWJvbHNTdG9yZVtuYW1lXTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM4ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgSVNfUFVSRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzkpOwogICAgICAgICAgICAgICAgdmFyIHN0b3JlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0MCk7CiAgICAgICAgICAgICAgICAobW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdG9yZVtrZXldIHx8IChzdG9yZVtrZXldID0gdmFsdWUgIT09IHVuZGVmaW5lZCA/IHZhbHVlIDoge30pOwogICAgICAgICAgICAgICAgfSkoJ3ZlcnNpb25zJywgW10pLnB1c2goewogICAgICAgICAgICAgICAgICAgIHZlcnNpb246ICczLjI5LjEnLAogICAgICAgICAgICAgICAgICAgIG1vZGU6IElTX1BVUkUgPyAncHVyZScgOiAnZ2xvYmFsJywKICAgICAgICAgICAgICAgICAgICBjb3B5cmlnaHQ6ICfCqSAyMDE0LTIwMjMgRGVuaXMgUHVzaGthcmV2ICh6bG9pcm9jay5ydSknLAogICAgICAgICAgICAgICAgICAgIGxpY2Vuc2U6ICdodHRwczovL2dpdGh1Yi5jb20vemxvaXJvY2svY29yZS1qcy9ibG9iL3YzLjI5LjEvTElDRU5TRScsCiAgICAgICAgICAgICAgICAgICAgc291cmNlOiAnaHR0cHM6Ly9naXRodWIuY29tL3psb2lyb2NrL2NvcmUtanMnCiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhbHNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBTSEFSRUQgPSAnX19jb3JlLWpzX3NoYXJlZF9fJzsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IGdsb2JhbFtTSEFSRURdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFNIQVJFRCwge30pOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gT2JqZWN0LmRlZmluZVByb3BlcnR5OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGdsb2JhbCwga2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICBnbG9iYWxba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd25Qcm9wZXJ0eSA9IHVuY3VycnlUaGlzKHt9Lmhhc093blByb3BlcnR5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gT2JqZWN0Lmhhc093biB8fCBmdW5jdGlvbiBoYXNPd24oaXQsIGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd25Qcm9wZXJ0eSh0b09iamVjdChpdCksIGtleSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHJlcXVpcmVPYmplY3RDb2VyY2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE5KTsKICAgICAgICAgICAgICAgIHZhciAkT2JqZWN0ID0gT2JqZWN0OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gJE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaWQgPSAwOwogICAgICAgICAgICAgICAgdmFyIHBvc3RmaXggPSBNYXRoLnJhbmRvbSgpOwogICAgICAgICAgICAgICAgdmFyIHRvU3RyaW5nID0gdW5jdXJyeVRoaXMoMS4wLnRvU3RyaW5nKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnU3ltYm9sKCcgKyAoa2V5ID09PSB1bmRlZmluZWQgPyAnJyA6IGtleSkgKyAnKV8nICsgdG9TdHJpbmcoKytpZCArIHBvc3RmaXgsIDM2KTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQ1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhREVTQ1JJUFRPUlMgJiYgIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmRlZmluZVByb3BlcnR5KGNyZWF0ZUVsZW1lbnQoJ2RpdicpLCAnYScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pLmEgIT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudCA9IGdsb2JhbC5kb2N1bWVudDsKICAgICAgICAgICAgICAgIHZhciBFWElTVFMgPSBpc09iamVjdChkb2N1bWVudCkgJiYgaXNPYmplY3QoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBFWElTVFMgPyBkb2N1bWVudC5jcmVhdGVFbGVtZW50KGl0KSA6IHt9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHlNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ4KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgPyBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBrZXksIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigxLCB2YWx1ZSkpOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChvYmplY3QsIGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBvYmplY3Rba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3Q7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIERFU0NSSVBUT1JTID0gX193X3BkZmpzX3JlcXVpcmVfXyg5KTsKICAgICAgICAgICAgICAgIHZhciBJRThfRE9NX0RFRklORSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDUpOwogICAgICAgICAgICAgICAgdmFyIFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0b1Byb3BlcnR5S2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciAkZGVmaW5lUHJvcGVydHkgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICB2YXIgRU5VTUVSQUJMRSA9ICdlbnVtZXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSAnY29uZmlndXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBXUklUQUJMRSA9ICd3cml0YWJsZSc7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/IFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgTyA9PT0gJ2Z1bmN0aW9uJyAmJiBQID09PSAncHJvdG90eXBlJyAmJiAndmFsdWUnIGluIEF0dHJpYnV0ZXMgJiYgV1JJVEFCTEUgaW4gQXR0cmlidXRlcyAmJiAhQXR0cmlidXRlc1tXUklUQUJMRV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN1cnJlbnQgPSAkZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKE8sIFApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudCAmJiBjdXJyZW50W1dSSVRBQkxFXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgT1tQXSA9IEF0dHJpYnV0ZXMudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdHRyaWJ1dGVzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogQ09ORklHVVJBQkxFIGluIEF0dHJpYnV0ZXMgPyBBdHRyaWJ1dGVzW0NPTkZJR1VSQUJMRV0gOiBjdXJyZW50W0NPTkZJR1VSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogRU5VTUVSQUJMRSBpbiBBdHRyaWJ1dGVzID8gQXR0cmlidXRlc1tFTlVNRVJBQkxFXSA6IGN1cnJlbnRbRU5VTUVSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICB9IDogJGRlZmluZVByb3BlcnR5IDogZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChJRThfRE9NX0RFRklORSkKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoJ2dldCcgaW4gQXR0cmlidXRlcyB8fCAnc2V0JyBpbiBBdHRyaWJ1dGVzKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCdBY2Nlc3NvcnMgbm90IHN1cHBvcnRlZCcpOwogICAgICAgICAgICAgICAgICAgIGlmICgndmFsdWUnIGluIEF0dHJpYnV0ZXMpCiAgICAgICAgICAgICAgICAgICAgICAgIE9bUF0gPSBBdHRyaWJ1dGVzLnZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgJiYgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIH0sICdwcm90b3R5cGUnLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiA0MiwKICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgfSkucHJvdG90eXBlICE9IDQyOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc09iamVjdChhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudDsKICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCRTdHJpbmcoYXJndW1lbnQpICsgJyBpcyBub3QgYW4gb2JqZWN0Jyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIG1ha2VCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKE8sIGtleSwgdmFsdWUsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9wdGlvbnMpCiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnMgPSB7fTsKICAgICAgICAgICAgICAgICAgICB2YXIgc2ltcGxlID0gb3B0aW9ucy5lbnVtZXJhYmxlOwogICAgICAgICAgICAgICAgICAgIHZhciBuYW1lID0gb3B0aW9ucy5uYW1lICE9PSB1bmRlZmluZWQgPyBvcHRpb25zLm5hbWUgOiBrZXk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbih2YWx1ZSwgbmFtZSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMuZ2xvYmFsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lR2xvYmFsUHJvcGVydHkoa2V5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3B0aW9ucy51bnNhZmUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE9ba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKE9ba2V5XSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW1wbGUgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHlNb2R1bGUuZihPLCBrZXksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiAhb3B0aW9ucy5ub25Db25maWd1cmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6ICFvcHRpb25zLm5vbldyaXRhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE87CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FID0gKF9fd19wZGZqc19yZXF1aXJlX18oNTMpLkNPTkZJR1VSQUJMRSk7CiAgICAgICAgICAgICAgICB2YXIgaW5zcGVjdFNvdXJjZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTQpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBlbmZvcmNlSW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZW5mb3JjZTsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXQ7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0eTsKICAgICAgICAgICAgICAgIHZhciBzdHJpbmdTbGljZSA9IHVuY3VycnlUaGlzKCcnLnNsaWNlKTsKICAgICAgICAgICAgICAgIHZhciByZXBsYWNlID0gdW5jdXJyeVRoaXMoJycucmVwbGFjZSk7CiAgICAgICAgICAgICAgICB2YXIgam9pbiA9IHVuY3VycnlUaGlzKFtdLmpvaW4pOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9MRU5HVEggPSBERVNDUklQVE9SUyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZpbmVQcm9wZXJ0eShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfSwgJ2xlbmd0aCcsIHsgdmFsdWU6IDggfSkubGVuZ3RoICE9PSA4OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB2YXIgVEVNUExBVEUgPSBTdHJpbmcoU3RyaW5nKS5zcGxpdCgnU3RyaW5nJyk7CiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh2YWx1ZSwgbmFtZSwgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGlmIChzdHJpbmdTbGljZSgkU3RyaW5nKG5hbWUpLCAwLCA3KSA9PT0gJ1N5bWJvbCgnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnWycgKyByZXBsYWNlKCRTdHJpbmcobmFtZSksIC9eU3ltYm9sXCgoW14pXSopXCkvLCAnJDEnKSArICddJzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgb3B0aW9ucy5nZXR0ZXIpCiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnZ2V0ICcgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zICYmIG9wdGlvbnMuc2V0dGVyKQogICAgICAgICAgICAgICAgICAgICAgICBuYW1lID0gJ3NldCAnICsgbmFtZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bih2YWx1ZSwgJ25hbWUnKSB8fCBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSAmJiB2YWx1ZS5uYW1lICE9PSBuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbmFtZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5uYW1lID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKENPTkZJR1VSQUJMRV9MRU5HVEggJiYgb3B0aW9ucyAmJiBoYXNPd24ob3B0aW9ucywgJ2FyaXR5JykgJiYgdmFsdWUubGVuZ3RoICE9PSBvcHRpb25zLmFyaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbGVuZ3RoJywgeyB2YWx1ZTogb3B0aW9ucy5hcml0eSB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgaGFzT3duKG9wdGlvbnMsICdjb25zdHJ1Y3RvcicpICYmIG9wdGlvbnMuY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eSh2YWx1ZSwgJ3Byb3RvdHlwZScsIHsgd3JpdGFibGU6IGZhbHNlIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlLnByb3RvdHlwZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLnByb3RvdHlwZSA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBlbmZvcmNlSW50ZXJuYWxTdGF0ZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oc3RhdGUsICdzb3VyY2UnKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zb3VyY2UgPSBqb2luKFRFTVBMQVRFLCB0eXBlb2YgbmFtZSA9PSAnc3RyaW5nJyA/IG5hbWUgOiAnJyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmcgPSBtYWtlQnVpbHRJbihmdW5jdGlvbiB0b1N0cmluZygpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZSh0aGlzKSAmJiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNvdXJjZSB8fCBpbnNwZWN0U291cmNlKHRoaXMpOwogICAgICAgICAgICAgICAgfSwgJ3RvU3RyaW5nJyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGdldERlc2NyaXB0b3IgPSBERVNDUklQVE9SUyAmJiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgdmFyIEVYSVNUUyA9IGhhc093bihGdW5jdGlvblByb3RvdHlwZSwgJ25hbWUnKTsKICAgICAgICAgICAgICAgIHZhciBQUk9QRVIgPSBFWElTVFMgJiYgZnVuY3Rpb24gc29tZXRoaW5nKCkgewogICAgICAgICAgICAgICAgfS5uYW1lID09PSAnc29tZXRoaW5nJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSBFWElTVFMgJiYgKCFERVNDUklQVE9SUyB8fCBERVNDUklQVE9SUyAmJiBnZXREZXNjcmlwdG9yKEZ1bmN0aW9uUHJvdG90eXBlLCAnbmFtZScpLmNvbmZpZ3VyYWJsZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBFWElTVFM6IEVYSVNUUywKICAgICAgICAgICAgICAgICAgICBQUk9QRVI6IFBST1BFUiwKICAgICAgICAgICAgICAgICAgICBDT05GSUdVUkFCTEU6IENPTkZJR1VSQUJMRQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDApOwogICAgICAgICAgICAgICAgdmFyIGZ1bmN0aW9uVG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyhGdW5jdGlvbi50b1N0cmluZyk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoc3RvcmUuaW5zcGVjdFNvdXJjZSkpIHsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5pbnNwZWN0U291cmNlID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvblRvU3RyaW5nKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZS5pbnNwZWN0U291cmNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9XRUFLX01BUCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTYpOwogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQwKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWRLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU3KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQgPSAnT2JqZWN0IGFscmVhZHkgaW5pdGlhbGl6ZWQnOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgV2Vha01hcCA9IGdsb2JhbC5XZWFrTWFwOwogICAgICAgICAgICAgICAgdmFyIHNldCwgZ2V0LCBoYXM7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXMoaXQpID8gZ2V0KGl0KSA6IHNldChpdCwge30pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXR0ZXJGb3IgPSBmdW5jdGlvbiAoVFlQRSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSB8fCAoc3RhdGUgPSBnZXQoaXQpKS50eXBlICE9PSBUWVBFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoJ0luY29tcGF0aWJsZSByZWNlaXZlciwgJyArIFRZUEUgKyAnIHJlcXVpcmVkJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgaWYgKE5BVElWRV9XRUFLX01BUCB8fCBzaGFyZWQuc3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmUgPSBzaGFyZWQuc3RhdGUgfHwgKHNoYXJlZC5zdGF0ZSA9IG5ldyBXZWFrTWFwKCkpOwogICAgICAgICAgICAgICAgICAgIHN0b3JlLmdldCA9IHN0b3JlLmdldDsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5oYXMgPSBzdG9yZS5oYXM7CiAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0ID0gc3RvcmUuc2V0OwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlLmhhcyhpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQpOwogICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YS5mYWNhZGUgPSBpdDsKICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0KGl0LCBtZXRhZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXRhZGF0YTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGdldCA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuZ2V0KGl0KSB8fCB7fTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGhhcyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuaGFzKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB2YXIgU1RBVEUgPSBzaGFyZWRLZXkoJ3N0YXRlJyk7CiAgICAgICAgICAgICAgICAgICAgaGlkZGVuS2V5c1tTVEFURV0gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihpdCwgU1RBVEUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKE9CSkVDVF9BTFJFQURZX0lOSVRJQUxJWkVEKTsKICAgICAgICAgICAgICAgICAgICAgICAgbWV0YWRhdGEuZmFjYWRlID0gaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShpdCwgU1RBVEUsIG1ldGFkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGFkYXRhOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgZ2V0ID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKSA/IGl0W1NUQVRFXSA6IHt9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaGFzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgc2V0OiBzZXQsCiAgICAgICAgICAgICAgICAgICAgZ2V0OiBnZXQsCiAgICAgICAgICAgICAgICAgICAgaGFzOiBoYXMsCiAgICAgICAgICAgICAgICAgICAgZW5mb3JjZTogZW5mb3JjZSwKICAgICAgICAgICAgICAgICAgICBnZXR0ZXJGb3I6IGdldHRlckZvcgogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBXZWFrTWFwID0gZ2xvYmFsLldlYWtNYXA7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGlzQ2FsbGFibGUoV2Vha01hcCkgJiYgL25hdGl2ZSBjb2RlLy50ZXN0KFN0cmluZyhXZWFrTWFwKSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDU3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIga2V5cyA9IHNoYXJlZCgna2V5cycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGtleXNba2V5XSB8fCAoa2V5c1trZXldID0gdWlkKGtleSkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHt9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1OSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIG93bktleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3JNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5TW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNvdXJjZSwgZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gb3duS2V5cyhzb3VyY2UpOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IGRlZmluZVByb3BlcnR5TW9kdWxlLmY7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvck1vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24odGFyZ2V0LCBrZXkpICYmICEoZXhjZXB0aW9ucyAmJiBoYXNPd24oZXhjZXB0aW9ucywga2V5KSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHRhcmdldCwga2V5LCBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3Ioc291cmNlLCBrZXkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzApOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgY29uY2F0ID0gdW5jdXJyeVRoaXMoW10uY29uY2F0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZ2V0QnVpbHRJbignUmVmbGVjdCcsICdvd25LZXlzJykgfHwgZnVuY3Rpb24gb3duS2V5cyhpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mKGFuT2JqZWN0KGl0KSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9scyA9IGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRPd25Qcm9wZXJ0eVN5bWJvbHMgPyBjb25jYXQoa2V5cywgZ2V0T3duUHJvcGVydHlTeW1ib2xzKGl0KSkgOiBrZXlzOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgdmFyIGhpZGRlbktleXMgPSBlbnVtQnVnS2V5cy5jb25jYXQoJ2xlbmd0aCcsICdwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzIHx8IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoTykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcm5hbE9iamVjdEtleXMoTywgaGlkZGVuS2V5cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgaW5kZXhPZiA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYzKS5pbmRleE9mKTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgcHVzaCA9IHVuY3VycnlUaGlzKFtdLnB1c2gpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBuYW1lcykgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBbXTsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5OwogICAgICAgICAgICAgICAgICAgIGZvciAoa2V5IGluIE8pCiAgICAgICAgICAgICAgICAgICAgICAgICFoYXNPd24oaGlkZGVuS2V5cywga2V5KSAmJiBoYXNPd24oTywga2V5KSAmJiBwdXNoKHJlc3VsdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmFtZXMubGVuZ3RoID4gaSkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihPLCBrZXkgPSBuYW1lc1tpKytdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgfmluZGV4T2YocmVzdWx0LCBrZXkpIHx8IHB1c2gocmVzdWx0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9BYnNvbHV0ZUluZGV4ID0gX193X3BkZmpzX3JlcXVpcmVfXyg2NCk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVNZXRob2QgPSBmdW5jdGlvbiAoSVNfSU5DTFVERVMpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCR0aGlzLCBlbCwgZnJvbUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KCR0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSB0b0Fic29sdXRlSW5kZXgoZnJvbUluZGV4LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJU19JTkNMVURFUyAmJiBlbCAhPSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGggPiBpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gT1tpbmRleCsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gdmFsdWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgbGVuZ3RoID4gaW5kZXg7IGluZGV4KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKElTX0lOQ0xVREVTIHx8IGluZGV4IGluIE8pICYmIE9baW5kZXhdID09PSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX0lOQ0xVREVTIHx8IGluZGV4IHx8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhSVNfSU5DTFVERVMgJiYgLTE7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBpbmNsdWRlczogY3JlYXRlTWV0aG9kKHRydWUpLAogICAgICAgICAgICAgICAgICAgIGluZGV4T2Y6IGNyZWF0ZU1ldGhvZChmYWxzZSkKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDY0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIG1heCA9IE1hdGgubWF4OwogICAgICAgICAgICAgICAgdmFyIG1pbiA9IE1hdGgubWluOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaW5kZXgsIGxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbnRlZ2VyID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGludGVnZXIgPCAwID8gbWF4KGludGVnZXIgKyBsZW5ndGgsIDApIDogbWluKGludGVnZXIsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRydW5jID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nik7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIHZhciBudW1iZXIgPSArYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bWJlciAhPT0gbnVtYmVyIHx8IG51bWJlciA9PT0gMCA/IDAgOiB0cnVuYyhudW1iZXIpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2VpbCA9IE1hdGguY2VpbDsKICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE1hdGgudHJ1bmMgfHwgZnVuY3Rpb24gdHJ1bmMoeCkgewogICAgICAgICAgICAgICAgICAgIHZhciBuID0gK3g7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChuID4gMCA/IGZsb29yIDogY2VpbCkobik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvTGVuZ3RoID0gX193X3BkZmpzX3JlcXVpcmVfXyg2OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChvYmopIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdG9MZW5ndGgob2JqLmxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2OCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvSW50ZWdlck9ySW5maW5pdHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY1KTsKICAgICAgICAgICAgICAgIHZhciBtaW4gPSBNYXRoLm1pbjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50ID4gMCA/IG1pbih0b0ludGVnZXJPckluZmluaXR5KGFyZ3VtZW50KSwgMHgxRkZGRkZGRkZGRkZGRikgOiAwOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IFsKICAgICAgICAgICAgICAgICAgICAnY29uc3RydWN0b3InLAogICAgICAgICAgICAgICAgICAgICdoYXNPd25Qcm9wZXJ0eScsCiAgICAgICAgICAgICAgICAgICAgJ2lzUHJvdG90eXBlT2YnLAogICAgICAgICAgICAgICAgICAgICdwcm9wZXJ0eUlzRW51bWVyYWJsZScsCiAgICAgICAgICAgICAgICAgICAgJ3RvTG9jYWxlU3RyaW5nJywKICAgICAgICAgICAgICAgICAgICAndG9TdHJpbmcnLAogICAgICAgICAgICAgICAgICAgICd2YWx1ZU9mJwogICAgICAgICAgICAgICAgXTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgcmVwbGFjZW1lbnQgPSAvI3xcLnByb3RvdHlwZVwuLzsKICAgICAgICAgICAgICAgIHZhciBpc0ZvcmNlZCA9IGZ1bmN0aW9uIChmZWF0dXJlLCBkZXRlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBkYXRhW25vcm1hbGl6ZShmZWF0dXJlKV07CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlID09IFBPTFlGSUxMID8gdHJ1ZSA6IHZhbHVlID09IE5BVElWRSA/IGZhbHNlIDogaXNDYWxsYWJsZShkZXRlY3Rpb24pID8gZmFpbHMoZGV0ZWN0aW9uKSA6ICEhZGV0ZWN0aW9uOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBub3JtYWxpemUgPSBpc0ZvcmNlZC5ub3JtYWxpemUgPSBmdW5jdGlvbiAoc3RyaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhzdHJpbmcpLnJlcGxhY2UocmVwbGFjZW1lbnQsICcuJykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZGF0YSA9IGlzRm9yY2VkLmRhdGEgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBOQVRJVkUgPSBpc0ZvcmNlZC5OQVRJVkUgPSAnTic7CiAgICAgICAgICAgICAgICB2YXIgUE9MWUZJTEwgPSBpc0ZvcmNlZC5QT0xZRklMTCA9ICdQJzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gaXNGb3JjZWQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgVU5TQ09QQUJMRVMgPSB3ZWxsS25vd25TeW1ib2woJ3Vuc2NvcGFibGVzJyk7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXlQcm90b3R5cGUgPSBBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBpZiAoQXJyYXlQcm90b3R5cGVbVU5TQ09QQUJMRVNdID09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KEFycmF5UHJvdG90eXBlLCBVTlNDT1BBQkxFUywgewogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIEFycmF5UHJvdG90eXBlW1VOU0NPUEFCTEVTXVtrZXldID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDczICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0aWVzTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3NCk7CiAgICAgICAgICAgICAgICB2YXIgZW51bUJ1Z0tleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY5KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNzYpOwogICAgICAgICAgICAgICAgdmFyIGRvY3VtZW50Q3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgdmFyIHNoYXJlZEtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTcpOwogICAgICAgICAgICAgICAgdmFyIEdUID0gJz4nOwogICAgICAgICAgICAgICAgdmFyIExUID0gJzwnOwogICAgICAgICAgICAgICAgdmFyIFBST1RPVFlQRSA9ICdwcm90b3R5cGUnOwogICAgICAgICAgICAgICAgdmFyIFNDUklQVCA9ICdzY3JpcHQnOwogICAgICAgICAgICAgICAgdmFyIElFX1BST1RPID0gc2hhcmVkS2V5KCdJRV9QUk9UTycpOwogICAgICAgICAgICAgICAgdmFyIEVtcHR5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIHNjcmlwdFRhZyA9IGZ1bmN0aW9uIChjb250ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIExUICsgU0NSSVBUICsgR1QgKyBjb250ZW50ICsgTFQgKyAnLycgKyBTQ1JJUFQgKyBHVDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0VmlhQWN0aXZlWCA9IGZ1bmN0aW9uIChhY3RpdmVYRG9jdW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCcnKSk7CiAgICAgICAgICAgICAgICAgICAgYWN0aXZlWERvY3VtZW50LmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlbXAgPSBhY3RpdmVYRG9jdW1lbnQucGFyZW50V2luZG93Lk9iamVjdDsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZW1wOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGlmcmFtZSA9IGRvY3VtZW50Q3JlYXRlRWxlbWVudCgnaWZyYW1lJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIEpTID0gJ2phdmEnICsgU0NSSVBUICsgJzonOwogICAgICAgICAgICAgICAgICAgIHZhciBpZnJhbWVEb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWUuc3R5bGUuZGlzcGxheSA9ICdub25lJzsKICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZENoaWxkKGlmcmFtZSk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lLnNyYyA9IFN0cmluZyhKUyk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQgPSBpZnJhbWUuY29udGVudFdpbmRvdy5kb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5vcGVuKCk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCdkb2N1bWVudC5GPU9iamVjdCcpKTsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpZnJhbWVEb2N1bWVudC5GOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBhY3RpdmVYRG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0ID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGl2ZVhEb2N1bWVudCA9IG5ldyBBY3RpdmVYT2JqZWN0KCdodG1sZmlsZScpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIE51bGxQcm90b09iamVjdCA9IHR5cGVvZiBkb2N1bWVudCAhPSAndW5kZWZpbmVkJyA/IGRvY3VtZW50LmRvbWFpbiAmJiBhY3RpdmVYRG9jdW1lbnQgPyBOdWxsUHJvdG9PYmplY3RWaWFBY3RpdmVYKGFjdGl2ZVhEb2N1bWVudCkgOiBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUoKSA6IE51bGxQcm90b09iamVjdFZpYUFjdGl2ZVgoYWN0aXZlWERvY3VtZW50KTsKICAgICAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoID0gZW51bUJ1Z0tleXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE51bGxQcm90b09iamVjdFtQUk9UT1RZUEVdW2VudW1CdWdLZXlzW2xlbmd0aF1dOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBOdWxsUHJvdG9PYmplY3QoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW0lFX1BST1RPXSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE9iamVjdC5jcmVhdGUgfHwgZnVuY3Rpb24gY3JlYXRlKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChPICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEVtcHR5Q29uc3RydWN0b3JbUFJPVE9UWVBFXSA9IGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBuZXcgRW1wdHlDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICBFbXB0eUNvbnN0cnVjdG9yW1BST1RPVFlQRV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRbSUVfUFJPVE9dID0gTzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gTnVsbFByb3RvT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb3BlcnRpZXMgPT09IHVuZGVmaW5lZCA/IHJlc3VsdCA6IGRlZmluZVByb3BlcnRpZXNNb2R1bGUuZihyZXN1bHQsIFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgVjhfUFJPVE9UWVBFX0RFRklORV9CVUcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ5KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgb2JqZWN0S2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNzUpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gREVTQ1JJUFRPUlMgJiYgIVY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMgOiBmdW5jdGlvbiBkZWZpbmVQcm9wZXJ0aWVzKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChPKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcHJvcHMgPSB0b0luZGV4ZWRPYmplY3QoUHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtleXMgPSBvYmplY3RLZXlzKFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBrZXlzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBrZXk7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGxlbmd0aCA+IGluZGV4KQogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eU1vZHVsZS5mKE8sIGtleSA9IGtleXNbaW5kZXgrK10sIHByb3BzW2tleV0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Qua2V5cyB8fCBmdW5jdGlvbiBrZXlzKE8pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZXJuYWxPYmplY3RLZXlzKE8sIGVudW1CdWdLZXlzKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBnZXRCdWlsdEluKCdkb2N1bWVudCcsICdkb2N1bWVudEVsZW1lbnQnKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChDT05TVFJVQ1RPUiwgTUVUSE9EKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuY3VycnlUaGlzKGdsb2JhbFtDT05TVFJVQ1RPUl0ucHJvdG90eXBlW01FVEhPRF0pOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgQXJyYXlCdWZmZXJWaWV3Q29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODApOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5ID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5hVHlwZWRBcnJheTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5TWV0aG9kID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5leHBvcnRUeXBlZEFycmF5TWV0aG9kOwogICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCgnYXQnLCBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gYVR5cGVkQXJyYXkodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbiA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGsgPSByZWxhdGl2ZUluZGV4ID49IDAgPyByZWxhdGl2ZUluZGV4IDogbGVuICsgcmVsYXRpdmVJbmRleDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gayA8IDAgfHwgayA+PSBsZW4gPyB1bmRlZmluZWQgOiBPW2tdOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9BUlJBWV9CVUZGRVIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgxKTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgdHJ5VG9TdHJpbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM1KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbkFjY2Vzc29yID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciB1aWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ0KTsKICAgICAgICAgICAgICAgIHZhciBJbnRlcm5hbFN0YXRlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NSk7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZUludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLmVuZm9yY2U7CiAgICAgICAgICAgICAgICB2YXIgZ2V0SW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0OwogICAgICAgICAgICAgICAgdmFyIEludDhBcnJheSA9IGdsb2JhbC5JbnQ4QXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgSW50OEFycmF5UHJvdG90eXBlID0gSW50OEFycmF5ICYmIEludDhBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXkgPSBnbG9iYWwuVWludDhDbGFtcGVkQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXlQcm90b3R5cGUgPSBVaW50OENsYW1wZWRBcnJheSAmJiBVaW50OENsYW1wZWRBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVHlwZWRBcnJheSA9IEludDhBcnJheSAmJiBnZXRQcm90b3R5cGVPZihJbnQ4QXJyYXkpOwogICAgICAgICAgICAgICAgdmFyIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBJbnQ4QXJyYXlQcm90b3R5cGUgJiYgZ2V0UHJvdG90eXBlT2YoSW50OEFycmF5UHJvdG90eXBlKTsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSBPYmplY3QucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIHZhciBUWVBFRF9BUlJBWV9UQUcgPSB1aWQoJ1RZUEVEX0FSUkFZX1RBRycpOwogICAgICAgICAgICAgICAgdmFyIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SID0gJ1R5cGVkQXJyYXlDb25zdHJ1Y3Rvcic7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyA9IE5BVElWRV9BUlJBWV9CVUZGRVIgJiYgISFzZXRQcm90b3R5cGVPZiAmJiBjbGFzc29mKGdsb2JhbC5vcGVyYSkgIT09ICdPcGVyYSc7CiAgICAgICAgICAgICAgICB2YXIgVFlQRURfQVJSQVlfVEFHX1JFUVVJUkVEID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgTkFNRSwgQ29uc3RydWN0b3IsIFByb3RvdHlwZTsKICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICBJbnQ4QXJyYXk6IDEsCiAgICAgICAgICAgICAgICAgICAgVWludDhBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBVaW50OENsYW1wZWRBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBJbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIFVpbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIEludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgVWludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgRmxvYXQzMkFycmF5OiA0LAogICAgICAgICAgICAgICAgICAgIEZsb2F0NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QgPSB7CiAgICAgICAgICAgICAgICAgICAgQmlnSW50NjRBcnJheTogOCwKICAgICAgICAgICAgICAgICAgICBCaWdVaW50NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBpc1ZpZXcgPSBmdW5jdGlvbiBpc1ZpZXcoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBrbGFzcyA9IGNsYXNzb2YoaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBrbGFzcyA9PT0gJ0RhdGFWaWV3JyB8fCBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKSB8fCBoYXNPd24oQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0LCBrbGFzcyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBwcm90byA9IGdldFByb3RvdHlwZU9mKGl0KTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHByb3RvKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsU3RhdGUocHJvdG8pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0ZSAmJiBoYXNPd24oc3RhdGUsIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SKSA/IHN0YXRlW1RZUEVEX0FSUkFZX0NPTlNUUlVDVE9SXSA6IGdldFR5cGVkQXJyYXlDb25zdHJ1Y3Rvcihwcm90byk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGlzVHlwZWRBcnJheSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtsYXNzID0gY2xhc3NvZihpdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc093bihUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCwga2xhc3MpIHx8IGhhc093bihCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgYVR5cGVkQXJyYXkgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNUeXBlZEFycmF5KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0OwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignVGFyZ2V0IGlzIG5vdCBhIHR5cGVkIGFycmF5Jyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoQykgewogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKEMpICYmICghc2V0UHJvdG90eXBlT2YgfHwgaXNQcm90b3R5cGVPZihUeXBlZEFycmF5LCBDKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDOwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcih0cnlUb1N0cmluZyhDKSArICcgaXMgbm90IGEgdHlwZWQgYXJyYXkgY29uc3RydWN0b3InKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCA9IGZ1bmN0aW9uIChLRVksIHByb3BlcnR5LCBmb3JjZWQsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciAmJiBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZSwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZVtLRVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IucHJvdG90eXBlW0tFWV0gPSBwcm9wZXJ0eTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlQcm90b3R5cGVbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihUeXBlZEFycmF5UHJvdG90eXBlLCBLRVksIGZvcmNlZCA/IHByb3BlcnR5IDogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBJbnQ4QXJyYXlQcm90b3R5cGVbS0VZXSB8fCBwcm9wZXJ0eSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kID0gZnVuY3Rpb24gKEtFWSwgcHJvcGVydHksIGZvcmNlZCkgewogICAgICAgICAgICAgICAgICAgIHZhciBBUlJBWSwgVHlwZWRBcnJheUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIGlmICghREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgaGFzT3duKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZUJ1aWx0SW4oVHlwZWRBcnJheSwgS0VZLCBmb3JjZWQgPyBwcm9wZXJ0eSA6IE5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgJiYgVHlwZWRBcnJheVtLRVldIHx8IHByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKEFSUkFZIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGdsb2JhbFtBUlJBWV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgKCFUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXSB8fCBmb3JjZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIU5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgfHwgIWlzQ2FsbGFibGUoVHlwZWRBcnJheSkgfHwgVHlwZWRBcnJheSA9PT0gRnVuY3Rpb24ucHJvdG90eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheSA9IGZ1bmN0aW9uIFR5cGVkQXJyYXkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmIChOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTKQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxbTkFNRV0pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoZ2xvYmFsW05BTUVdLCBUeXBlZEFycmF5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTIHx8ICFUeXBlZEFycmF5UHJvdG90eXBlIHx8IFR5cGVkQXJyYXlQcm90b3R5cGUgPT09IE9iamVjdFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBUeXBlZEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUykKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsW05BTUVdKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKGdsb2JhbFtOQU1FXS5wcm90b3R5cGUsIFR5cGVkQXJyYXlQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBnZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSkgIT09IFR5cGVkQXJyYXlQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICBzZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSwgVHlwZWRBcnJheVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMgJiYgIWhhc093bihUeXBlZEFycmF5UHJvdG90eXBlLCBUT19TVFJJTkdfVEFHKSkgewogICAgICAgICAgICAgICAgICAgIFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbkFjY2Vzc29yKFR5cGVkQXJyYXlQcm90b3R5cGUsIFRPX1NUUklOR19UQUcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc09iamVjdCh0aGlzKSA/IHRoaXNbVFlQRURfQVJSQVlfVEFHXSA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGZvciAoTkFNRSBpbiBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdsb2JhbFtOQU1FXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5KGdsb2JhbFtOQU1FXSwgVFlQRURfQVJSQVlfVEFHLCBOQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUzogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUywKICAgICAgICAgICAgICAgICAgICBUWVBFRF9BUlJBWV9UQUc6IFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCAmJiBUWVBFRF9BUlJBWV9UQUcsCiAgICAgICAgICAgICAgICAgICAgYVR5cGVkQXJyYXk6IGFUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIGFUeXBlZEFycmF5Q29uc3RydWN0b3I6IGFUeXBlZEFycmF5Q29uc3RydWN0b3IsCiAgICAgICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZDogZXhwb3J0VHlwZWRBcnJheU1ldGhvZCwKICAgICAgICAgICAgICAgICAgICBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kOiBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kLAogICAgICAgICAgICAgICAgICAgIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvcjogZ2V0VHlwZWRBcnJheUNvbnN0cnVjdG9yLAogICAgICAgICAgICAgICAgICAgIGlzVmlldzogaXNWaWV3LAogICAgICAgICAgICAgICAgICAgIGlzVHlwZWRBcnJheTogaXNUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXk6IFR5cGVkQXJyYXksCiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheVByb3RvdHlwZTogVHlwZWRBcnJheVByb3RvdHlwZQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBBcnJheUJ1ZmZlciAhPSAndW5kZWZpbmVkJyAmJiB0eXBlb2YgRGF0YVZpZXcgIT0gJ3VuZGVmaW5lZCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gd2VsbEtub3duU3ltYm9sKCd0b1N0cmluZ1RhZycpOwogICAgICAgICAgICAgICAgdmFyICRPYmplY3QgPSBPYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9BUkdVTUVOVFMgPSBjbGFzc29mUmF3KChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50czsKICAgICAgICAgICAgICAgIH0oKSkpID09ICdBcmd1bWVudHMnOwogICAgICAgICAgICAgICAgdmFyIHRyeUdldCA9IGZ1bmN0aW9uIChpdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W2tleV07CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyBjbGFzc29mUmF3IDogZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIE8sIHRhZywgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCA9PT0gdW5kZWZpbmVkID8gJ1VuZGVmaW5lZCcgOiBpdCA9PT0gbnVsbCA/ICdOdWxsJyA6IHR5cGVvZiAodGFnID0gdHJ5R2V0KE8gPSAkT2JqZWN0KGl0KSwgVE9fU1RSSU5HX1RBRykpID09ICdzdHJpbmcnID8gdGFnIDogQ09SUkVDVF9BUkdVTUVOVFMgPyBjbGFzc29mUmF3KE8pIDogKHJlc3VsdCA9IGNsYXNzb2ZSYXcoTykpID09ICdPYmplY3QnICYmIGlzQ2FsbGFibGUoTy5jYWxsZWUpID8gJ0FyZ3VtZW50cycgOiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSB3ZWxsS25vd25TeW1ib2woJ3RvU3RyaW5nVGFnJyk7CiAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgdGVzdFtUT19TVFJJTkdfVEFHXSA9ICd6JzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gU3RyaW5nKHRlc3QpID09PSAnW29iamVjdCB6XSc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUyKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IuZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLmdldCwgbmFtZSwgeyBnZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3Iuc2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLnNldCwgbmFtZSwgeyBzZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5LmYodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRvT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Myk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkS2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Nyk7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nik7CiAgICAgICAgICAgICAgICB2YXIgSUVfUFJPVE8gPSBzaGFyZWRLZXkoJ0lFX1BST1RPJyk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSAkT2JqZWN0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID8gJE9iamVjdC5nZXRQcm90b3R5cGVPZiA6IGZ1bmN0aW9uIChPKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIG9iamVjdCA9IHRvT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24ob2JqZWN0LCBJRV9QUk9UTykpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3RbSUVfUFJPVE9dOwogICAgICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3RvciA9IG9iamVjdC5jb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNDYWxsYWJsZShjb25zdHJ1Y3RvcikgJiYgb2JqZWN0IGluc3RhbmNlb2YgY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnN0cnVjdG9yLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iamVjdCBpbnN0YW5jZW9mICRPYmplY3QgPyBPYmplY3RQcm90b3R5cGUgOiBudWxsOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIEYoKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEYucHJvdG90eXBlLmNvbnN0cnVjdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldFByb3RvdHlwZU9mKG5ldyBGKCkpICE9PSBGLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg4KTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIGFQb3NzaWJsZVByb3RvdHlwZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgfHwgKCdfX3Byb3RvX18nIGluIHt9ID8gKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9TRVRURVIgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBzZXR0ZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGVyID0gdW5jdXJyeVRoaXNBY2Nlc3NvcihPYmplY3QucHJvdG90eXBlLCAnX19wcm90b19fJywgJ3NldCcpOwogICAgICAgICAgICAgICAgICAgICAgICBzZXR0ZXIodGVzdCwgW10pOwogICAgICAgICAgICAgICAgICAgICAgICBDT1JSRUNUX1NFVFRFUiA9IHRlc3QgaW5zdGFuY2VvZiBBcnJheTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gc2V0UHJvdG90eXBlT2YoTywgcHJvdG8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGFQb3NzaWJsZVByb3RvdHlwZShwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDT1JSRUNUX1NFVFRFUikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldHRlcihPLCBwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE8uX19wcm90b19fID0gcHJvdG87CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9KCkpIDogdW5kZWZpbmVkKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhhQ2FsbGFibGUoT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihvYmplY3QsIGtleSlbbWV0aG9kXSkpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyZ3VtZW50ID09ICdvYmplY3QnIHx8IGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3Qgc2V0ICIgKyAkU3RyaW5nKGFyZ3VtZW50KSArICcgYXMgYSBwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDkxKTsKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTgpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMDApOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjMpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjUpOwogICAgICAgICAgICAgICAgdmFyIHBhdGggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHBhdGguc3RydWN0dXJlZENsb25lOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciBhZGRUb1Vuc2NvcGFibGVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSW50ZXJuYWxTdGF0ZU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTUpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gKF9fd19wZGZqc19yZXF1aXJlX18oNDgpLmYpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgQVJSQVlfSVRFUkFUT1IgPSAnQXJyYXkgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgdmFyIHNldEludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLnNldDsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXR0ZXJGb3IoQVJSQVlfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBkZWZpbmVJdGVyYXRvcihBcnJheSwgJ0FycmF5JywgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgc2V0SW50ZXJuYWxTdGF0ZSh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEFSUkFZX0lURVJBVE9SLAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQ6IHRvSW5kZXhlZE9iamVjdChpdGVyYXRlZCksCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiAwLAogICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gc3RhdGUudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBzdGF0ZS5pbmRleCsrOwogICAgICAgICAgICAgICAgICAgIGlmICghdGFyZ2V0IHx8IGluZGV4ID49IHRhcmdldC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUudGFyZ2V0ID0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdCh1bmRlZmluZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoa2luZCA9PSAna2V5cycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGluZGV4LCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KHRhcmdldFtpbmRleF0sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXRbaW5kZXhdCiAgICAgICAgICAgICAgICAgICAgXSwgZmFsc2UpOwogICAgICAgICAgICAgICAgfSwgJ3ZhbHVlcycpOwogICAgICAgICAgICAgICAgdmFyIHZhbHVlcyA9IEl0ZXJhdG9ycy5Bcmd1bWVudHMgPSBJdGVyYXRvcnMuQXJyYXk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdrZXlzJyk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCd2YWx1ZXMnKTsKICAgICAgICAgICAgICAgIGFkZFRvVW5zY29wYWJsZXMoJ2VudHJpZXMnKTsKICAgICAgICAgICAgICAgIGlmICghSVNfUFVSRSAmJiBERVNDUklQVE9SUyAmJiB2YWx1ZXMubmFtZSAhPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodmFsdWVzLCAnbmFtZScsIHsgdmFsdWU6ICd2YWx1ZXMnIH0pOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0ge307CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgRnVuY3Rpb25OYW1lID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZUl0ZXJhdG9yQ29uc3RydWN0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk0KTsKICAgICAgICAgICAgICAgIHZhciBnZXRQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODUpOwogICAgICAgICAgICAgICAgdmFyIHNldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzQ29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oOTUpOwogICAgICAgICAgICAgICAgdmFyIFBST1BFUl9GVU5DVElPTl9OQU1FID0gRnVuY3Rpb25OYW1lLlBST1BFUjsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSA9IEZ1bmN0aW9uTmFtZS5DT05GSUdVUkFCTEU7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUgPSBJdGVyYXRvcnNDb3JlLkl0ZXJhdG9yUHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSBJdGVyYXRvcnNDb3JlLkJVR0dZX1NBRkFSSV9JVEVSQVRPUlM7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICB2YXIgS0VZUyA9ICdrZXlzJzsKICAgICAgICAgICAgICAgIHZhciBWQUxVRVMgPSAndmFsdWVzJzsKICAgICAgICAgICAgICAgIHZhciBFTlRSSUVTID0gJ2VudHJpZXMnOwogICAgICAgICAgICAgICAgdmFyIHJldHVyblRoaXMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoSXRlcmFibGUsIE5BTUUsIEl0ZXJhdG9yQ29uc3RydWN0b3IsIG5leHQsIERFRkFVTFQsIElTX1NFVCwgRk9SQ0VEKSB7CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlSXRlcmF0b3JDb25zdHJ1Y3RvcihJdGVyYXRvckNvbnN0cnVjdG9yLCBOQU1FLCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0SXRlcmF0aW9uTWV0aG9kID0gZnVuY3Rpb24gKEtJTkQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEtJTkQgPT09IERFRkFVTFQgJiYgZGVmYXVsdEl0ZXJhdG9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFCVUdHWV9TQUZBUklfSVRFUkFUT1JTICYmIEtJTkQgaW4gSXRlcmFibGVQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSXRlcmFibGVQcm90b3R5cGVbS0lORF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoS0lORCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBLRVlTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBrZXlzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVkFMVUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSXRlcmF0b3JDb25zdHJ1Y3Rvcih0aGlzLCBLSU5EKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBFTlRSSUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBlbnRyaWVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJdGVyYXRvckNvbnN0cnVjdG9yKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSBOQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJdGVyYWJsZVByb3RvdHlwZSA9IEl0ZXJhYmxlLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB2YXIgbmF0aXZlSXRlcmF0b3IgPSBJdGVyYWJsZVByb3RvdHlwZVtJVEVSQVRPUl0gfHwgSXRlcmFibGVQcm90b3R5cGVbJ0BAaXRlcmF0b3InXSB8fCBERUZBVUxUICYmIEl0ZXJhYmxlUHJvdG90eXBlW0RFRkFVTFRdOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0SXRlcmF0b3IgPSAhQlVHR1lfU0FGQVJJX0lURVJBVE9SUyAmJiBuYXRpdmVJdGVyYXRvciB8fCBnZXRJdGVyYXRpb25NZXRob2QoREVGQVVMVCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFueU5hdGl2ZUl0ZXJhdG9yID0gTkFNRSA9PSAnQXJyYXknID8gSXRlcmFibGVQcm90b3R5cGUuZW50cmllcyB8fCBuYXRpdmVJdGVyYXRvciA6IG5hdGl2ZUl0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBDdXJyZW50SXRlcmF0b3JQcm90b3R5cGUsIG1ldGhvZHMsIEtFWTsKICAgICAgICAgICAgICAgICAgICBpZiAoYW55TmF0aXZlSXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlID0gZ2V0UHJvdG90eXBlT2YoYW55TmF0aXZlSXRlcmF0b3IuY2FsbChuZXcgSXRlcmFibGUoKSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlICE9PSBPYmplY3QucHJvdG90eXBlICYmIEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZS5uZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUlTX1BVUkUgJiYgZ2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlKSAhPT0gSXRlcmF0b3JQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlLCBJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNDYWxsYWJsZShDdXJyZW50SXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgSVRFUkFUT1IsIHJldHVyblRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRvU3RyaW5nVGFnKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgVE9fU1RSSU5HX1RBRywgdHJ1ZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbVE9fU1RSSU5HX1RBR10gPSByZXR1cm5UaGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfRlVOQ1RJT05fTkFNRSAmJiBERUZBVUxUID09IFZBTFVFUyAmJiBuYXRpdmVJdGVyYXRvciAmJiBuYXRpdmVJdGVyYXRvci5uYW1lICE9PSBWQUxVRVMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19QVVJFICYmIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoSXRlcmFibGVQcm90b3R5cGUsICduYW1lJywgVkFMVUVTKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0SXRlcmF0b3IgPSBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGwobmF0aXZlSXRlcmF0b3IsIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoREVGQVVMVCkgewogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2RzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzOiBnZXRJdGVyYXRpb25NZXRob2QoVkFMVUVTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXM6IElTX1NFVCA/IGRlZmF1bHRJdGVyYXRvciA6IGdldEl0ZXJhdGlvbk1ldGhvZChLRVlTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJpZXM6IGdldEl0ZXJhdGlvbk1ldGhvZChFTlRSSUVTKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoRk9SQ0VEKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChLRVkgaW4gbWV0aG9kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgS0VZLCBtZXRob2RzW0tFWV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBOQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG1ldGhvZHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoKCFJU19QVVJFIHx8IEZPUkNFRCkgJiYgSXRlcmFibGVQcm90b3R5cGVbSVRFUkFUT1JdICE9PSBkZWZhdWx0SXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgSVRFUkFUT1IsIGRlZmF1bHRJdGVyYXRvciwgeyBuYW1lOiBERUZBVUxUIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbTkFNRV0gPSBkZWZhdWx0SXRlcmF0b3I7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHM7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvclByb3RvdHlwZSA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDk1KS5JdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKEl0ZXJhdG9yQ29uc3RydWN0b3IsIE5BTUUsIG5leHQsIEVOVU1FUkFCTEVfTkVYVCkgewogICAgICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gTkFNRSArICcgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yQ29uc3RydWN0b3IucHJvdG90eXBlID0gY3JlYXRlKEl0ZXJhdG9yUHJvdG90eXBlLCB7IG5leHQ6IGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigrIUVOVU1FUkFCTEVfTkVYVCwgbmV4dCkgfSk7CiAgICAgICAgICAgICAgICAgICAgc2V0VG9TdHJpbmdUYWcoSXRlcmF0b3JDb25zdHJ1Y3RvciwgVE9fU1RSSU5HX1RBRywgZmFsc2UsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzMpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBCVUdHWV9TQUZBUklfSVRFUkFUT1JTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUsIFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZSwgYXJyYXlJdGVyYXRvcjsKICAgICAgICAgICAgICAgIGlmIChbXS5rZXlzKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlJdGVyYXRvciA9IFtdLmtleXMoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnbmV4dCcgaW4gYXJyYXlJdGVyYXRvcikpCiAgICAgICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgPSBnZXRQcm90b3R5cGVPZihnZXRQcm90b3R5cGVPZihhcnJheUl0ZXJhdG9yKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgIT09IE9iamVjdC5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgTkVXX0lURVJBVE9SX1BST1RPVFlQRSA9ICFpc09iamVjdChJdGVyYXRvclByb3RvdHlwZSkgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0ge307CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yUHJvdG90eXBlW0lURVJBVE9SXS5jYWxsKHRlc3QpICE9PSB0ZXN0OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBpZiAoTkVXX0lURVJBVE9SX1BST1RPVFlQRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IHt9OwogICAgICAgICAgICAgICAgZWxzZSBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IGNyZWF0ZShJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoSXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oSXRlcmF0b3JQcm90b3R5cGUsIElURVJBVE9SLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0b3JQcm90b3R5cGU6IEl0ZXJhdG9yUHJvdG90eXBlLAogICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgVEFHLCBTVEFUSUMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICFTVEFUSUMpCiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IHRhcmdldC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAmJiAhaGFzT3duKHRhcmdldCwgVE9fU1RSSU5HX1RBRykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBUT19TVFJJTkdfVEFHLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogVEFHCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodmFsdWUsIGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGRvbmUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUdfU1VQUE9SVCA9IF9fd19wZGZqc19yZXF1aXJlX18oODMpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUxKTsKICAgICAgICAgICAgICAgIHZhciB0b1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oOTkpOwogICAgICAgICAgICAgICAgaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHsKICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKE9iamVjdC5wcm90b3R5cGUsICd0b1N0cmluZycsIHRvU3RyaW5nLCB7IHVuc2FmZTogdHJ1ZSB9KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyB7fS50b1N0cmluZyA6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnW29iamVjdCAnICsgY2xhc3NvZih0aGlzKSArICddJzsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMik7CiAgICAgICAgICAgICAgICB2YXIgY29sbGVjdGlvblN0cm9uZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIwKTsKICAgICAgICAgICAgICAgIGNvbGxlY3Rpb24oJ01hcCcsIGZ1bmN0aW9uIChpbml0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIE1hcCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluaXQodGhpcywgYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sIGNvbGxlY3Rpb25TdHJvbmcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzRm9yY2VkID0gX193X3BkZmpzX3JlcXVpcmVfXyg3MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsTWV0YWRhdGFNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMyk7CiAgICAgICAgICAgICAgICB2YXIgaXRlcmF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEwKTsKICAgICAgICAgICAgICAgIHZhciBhbkluc3RhbmNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc051bGxPclVuZGVmaW5lZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExOCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBpbmhlcml0SWZSZXF1aXJlZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTE5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUsIHdyYXBwZXIsIGNvbW1vbikgewogICAgICAgICAgICAgICAgICAgIHZhciBJU19NQVAgPSBDT05TVFJVQ1RPUl9OQU1FLmluZGV4T2YoJ01hcCcpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfV0VBSyA9IENPTlNUUlVDVE9SX05BTUUuaW5kZXhPZignV2VhaycpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgQURERVIgPSBJU19NQVAgPyAnc2V0JyA6ICdhZGQnOwogICAgICAgICAgICAgICAgICAgIHZhciBOYXRpdmVDb25zdHJ1Y3RvciA9IGdsb2JhbFtDT05TVFJVQ1RPUl9OQU1FXTsKICAgICAgICAgICAgICAgICAgICB2YXIgTmF0aXZlUHJvdG90eXBlID0gTmF0aXZlQ29uc3RydWN0b3IgJiYgTmF0aXZlQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IE5hdGl2ZUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBleHBvcnRlZCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBmaXhNZXRob2QgPSBmdW5jdGlvbiAoS0VZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1bmN1cnJpZWROYXRpdmVNZXRob2QgPSB1bmN1cnJ5VGhpcyhOYXRpdmVQcm90b3R5cGVbS0VZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oTmF0aXZlUHJvdG90eXBlLCBLRVksIEtFWSA9PSAnYWRkJyA/IGZ1bmN0aW9uIGFkZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIHZhbHVlID09PSAwID8gMCA6IHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdkZWxldGUnID8gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IEtFWSA9PSAnZ2V0JyA/IGZ1bmN0aW9uIGdldChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJU19XRUFLICYmICFpc09iamVjdChrZXkpID8gdW5kZWZpbmVkIDogdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdoYXMnID8gZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmN1cnJpZWROYXRpdmVNZXRob2QodGhpcywga2V5ID09PSAwID8gMCA6IGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFJFUExBQ0UgPSBpc0ZvcmNlZChDT05TVFJVQ1RPUl9OQU1FLCAhaXNDYWxsYWJsZShOYXRpdmVDb25zdHJ1Y3RvcikgfHwgIShJU19XRUFLIHx8IE5hdGl2ZVByb3RvdHlwZS5mb3JFYWNoICYmICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcigpLmVudHJpZXMoKS5uZXh0KCk7CiAgICAgICAgICAgICAgICAgICAgfSkpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoUkVQTEFDRSkgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IGNvbW1vbi5nZXRDb25zdHJ1Y3Rvcih3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxNZXRhZGF0YU1vZHVsZS5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzRm9yY2VkKENPTlNUUlVDVE9SX05BTUUsIHRydWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZSA9IG5ldyBDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgSEFTTlRfQ0hBSU5JTkcgPSBpbnN0YW5jZVtBRERFUl0oSVNfV0VBSyA/IHt9IDogLTAsIDEpICE9IGluc3RhbmNlOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgVEhST1dTX09OX1BSSU1JVElWRVMgPSBmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZS5oYXMoMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQUNDRVBUX0lURVJBQkxFUyA9IGNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcihpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQlVHR1lfWkVSTyA9ICFJU19XRUFLICYmIGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkaW5zdGFuY2UgPSBuZXcgTmF0aXZlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IDU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW5zdGFuY2VbQURERVJdKGluZGV4LCBpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gISRpbnN0YW5jZS5oYXMoLTApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBQ0NFUFRfSVRFUkFCTEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKGR1bW15LCBpdGVyYWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuSW5zdGFuY2UoZHVtbXksIE5hdGl2ZVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBpbmhlcml0SWZSZXF1aXJlZChuZXcgTmF0aXZlQ29uc3RydWN0b3IoKSwgZHVtbXksIENvbnN0cnVjdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgdGhhdFtBRERFUl0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQ6IHRoYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnN0cnVjdG9yLnByb3RvdHlwZSA9IE5hdGl2ZVByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5hdGl2ZVByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IENvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUSFJPV1NfT05fUFJJTUlUSVZFUyB8fCBCVUdHWV9aRVJPKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaXhNZXRob2QoJ2RlbGV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKCdoYXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElTX01BUCAmJiBmaXhNZXRob2QoJ2dldCcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9aRVJPIHx8IEhBU05UX0NIQUlOSU5HKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKElTX1dFQUsgJiYgTmF0aXZlUHJvdG90eXBlLmNsZWFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE5hdGl2ZVByb3RvdHlwZS5jbGVhcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0ZWRbQ09OU1RSVUNUT1JfTkFNRV0gPSBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAkKHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2xvYmFsOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBDb25zdHJ1Y3RvciAhPSBOYXRpdmVDb25zdHJ1Y3RvcgogICAgICAgICAgICAgICAgICAgIH0sIGV4cG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19XRUFLKQogICAgICAgICAgICAgICAgICAgICAgICBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGlkZGVuS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNTgpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5TmFtZXNFeHRlcm5hbE1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA0KTsKICAgICAgICAgICAgICAgIHZhciBpc0V4dGVuc2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNyk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgRlJFRVpJTkcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwOSk7CiAgICAgICAgICAgICAgICB2YXIgUkVRVUlSRUQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIHZhciBNRVRBREFUQSA9IHVpZCgnbWV0YScpOwogICAgICAgICAgICAgICAgdmFyIGlkID0gMDsKICAgICAgICAgICAgICAgIHZhciBzZXRNZXRhZGF0YSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGl0LCBNRVRBREFUQSwgewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0SUQ6ICdPJyArIGlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWFrRGF0YToge30KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBmYXN0S2V5ID0gZnVuY3Rpb24gKGl0LCBjcmVhdGUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnc3ltYm9sJyA/IGl0IDogKHR5cGVvZiBpdCA9PSAnc3RyaW5nJyA/ICdTJyA6ICdQJykgKyBpdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bihpdCwgTUVUQURBVEEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFeHRlbnNpYmxlKGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnRic7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3JlYXRlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdFJzsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0TWV0YWRhdGEoaXQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRbTUVUQURBVEFdLm9iamVjdElEOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXRXZWFrRGF0YSA9IGZ1bmN0aW9uIChpdCwgY3JlYXRlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oaXQsIE1FVEFEQVRBKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRXh0ZW5zaWJsZShpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjcmVhdGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W01FVEFEQVRBXS53ZWFrRGF0YTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgb25GcmVlemUgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoRlJFRVpJTkcgJiYgUkVRVUlSRUQgJiYgaXNFeHRlbnNpYmxlKGl0KSAmJiAhaGFzT3duKGl0LCBNRVRBREFUQSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBtZXRhLmVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lcyA9IGdldE93blByb3BlcnR5TmFtZXNNb2R1bGUuZjsKICAgICAgICAgICAgICAgICAgICB2YXIgc3BsaWNlID0gdW5jdXJyeVRoaXMoW10uc3BsaWNlKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHRlc3RbTUVUQURBVEFdID0gMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0T3duUHJvcGVydHlOYW1lcyh0ZXN0KS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuZ3RoID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFtpXSA9PT0gTUVUQURBVEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaWNlKHJlc3VsdCwgaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiAnT2JqZWN0JywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXQ6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZWQ6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSwgeyBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZiB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIG1ldGEgPSBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBlbmFibGU6IGVuYWJsZSwKICAgICAgICAgICAgICAgICAgICBmYXN0S2V5OiBmYXN0S2V5LAogICAgICAgICAgICAgICAgICAgIGdldFdlYWtEYXRhOiBnZXRXZWFrRGF0YSwKICAgICAgICAgICAgICAgICAgICBvbkZyZWV6ZTogb25GcmVlemUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW01FVEFEQVRBXSA9IHRydWU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciAkZ2V0T3duUHJvcGVydHlOYW1lcyA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYxKS5mKTsKICAgICAgICAgICAgICAgIHZhciBhcnJheVNsaWNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDUpOwogICAgICAgICAgICAgICAgdmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107CiAgICAgICAgICAgICAgICB2YXIgZ2V0V2luZG93TmFtZXMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGdldE93blByb3BlcnR5TmFtZXMoaXQpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheVNsaWNlKHdpbmRvd05hbWVzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuZiA9IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93TmFtZXMgJiYgY2xhc3NvZihpdCkgPT0gJ1dpbmRvdycgPyBnZXRXaW5kb3dOYW1lcyhpdCkgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvQWJzb2x1dGVJbmRleCA9IF9fd19wZGZqc19yZXF1aXJlX18oNjQpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgJEFycmF5ID0gQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgbWF4ID0gTWF0aC5tYXg7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChPLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciBrID0gdG9BYnNvbHV0ZUluZGV4KHN0YXJ0LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIHZhciBmaW4gPSB0b0Fic29sdXRlSW5kZXgoZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBlbmQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9ICRBcnJheShtYXgoZmluIC0gaywgMCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIG4gPSAwOyBrIDwgZmluOyBrKyssIG4rKykKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkocmVzdWx0LCBuLCBPW2tdKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHQubGVuZ3RoID0gbjsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIHRvUHJvcGVydHlLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIxKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5S2V5ID0gdG9Qcm9wZXJ0eUtleShrZXkpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0eUtleSBpbiBvYmplY3QpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBwcm9wZXJ0eUtleSwgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDAsIHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMTgpOwogICAgICAgICAgICAgICAgdmFyIEFSUkFZX0JVRkZFUl9OT05fRVhURU5TSUJMRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA4KTsKICAgICAgICAgICAgICAgIHZhciAkaXNFeHRlbnNpYmxlID0gT2JqZWN0LmlzRXh0ZW5zaWJsZTsKICAgICAgICAgICAgICAgIHZhciBGQUlMU19PTl9QUklNSVRJVkVTID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICRpc0V4dGVuc2libGUoMSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gRkFJTFNfT05fUFJJTUlUSVZFUyB8fCBBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgPyBmdW5jdGlvbiBpc0V4dGVuc2libGUoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmIChBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgJiYgY2xhc3NvZihpdCkgPT0gJ0FycmF5QnVmZmVyJykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkaXNFeHRlbnNpYmxlID8gJGlzRXh0ZW5zaWJsZShpdCkgOiB0cnVlOwogICAgICAgICAgICAgICAgfSA6ICRpc0V4dGVuc2libGU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyID09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcig4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5pc0V4dGVuc2libGUoYnVmZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShidWZmZXIsICdhJywgeyB2YWx1ZTogOCB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmlzRXh0ZW5zaWJsZShPYmplY3QucHJldmVudEV4dGVuc2lvbnMoe30pKTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgaXNBcnJheUl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTQpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdG9yQ2xvc2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNik7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBSZXN1bHQgPSBmdW5jdGlvbiAoc3RvcHBlZCwgcmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wcGVkID0gc3RvcHBlZDsKICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgUmVzdWx0UHJvdG90eXBlID0gUmVzdWx0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhYmxlLCB1bmJvdW5kRnVuY3Rpb24sIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IG9wdGlvbnMgJiYgb3B0aW9ucy50aGF0OwogICAgICAgICAgICAgICAgICAgIHZhciBBU19FTlRSSUVTID0gISEob3B0aW9ucyAmJiBvcHRpb25zLkFTX0VOVFJJRVMpOwogICAgICAgICAgICAgICAgICAgIHZhciBJU19SRUNPUkQgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfUkVDT1JEKTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfSVRFUkFUT1IgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgICAgIHZhciBJTlRFUlJVUFRFRCA9ICEhKG9wdGlvbnMgJiYgb3B0aW9ucy5JTlRFUlJVUFRFRCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gYmluZCh1bmJvdW5kRnVuY3Rpb24sIHRoYXQpOwogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvciwgaXRlckZuLCBpbmRleCwgbGVuZ3RoLCByZXN1bHQsIG5leHQsIHN0ZXA7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3AgPSBmdW5jdGlvbiAoY29uZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVyYXRvcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdG9yQ2xvc2UoaXRlcmF0b3IsICdub3JtYWwnLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlc3VsdCh0cnVlLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxGbiA9IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQVNfRU5UUklFUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWVbMF0sIHZhbHVlWzFdLCBzdG9wKSA6IGZuKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWUsIHN0b3ApIDogZm4odmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaWYgKElTX1JFQ09SRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGl0ZXJhYmxlLml0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoSVNfSVRFUkFUT1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0b3IgPSBpdGVyYWJsZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyRm4gPSBnZXRJdGVyYXRvck1ldGhvZChpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXRlckZuKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhpdGVyYWJsZSkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBcnJheUl0ZXJhdG9yTWV0aG9kKGl0ZXJGbikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW5kZXggPSAwLCBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZShpdGVyYWJsZSk7IGxlbmd0aCA+IGluZGV4OyBpbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbEZuKGl0ZXJhYmxlW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAmJiBpc1Byb3RvdHlwZU9mKFJlc3VsdFByb3RvdHlwZSwgcmVzdWx0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGdldEl0ZXJhdG9yKGl0ZXJhYmxlLCBpdGVyRm4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0ID0gSVNfUkVDT1JEID8gaXRlcmFibGUubmV4dCA6IGl0ZXJhdG9yLm5leHQ7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCEoc3RlcCA9IGNhbGwobmV4dCwgaXRlcmF0b3IpKS5kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBjYWxsRm4oc3RlcC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT0gJ29iamVjdCcgJiYgcmVzdWx0ICYmIGlzUHJvdG90eXBlT2YoUmVzdWx0UHJvdG90eXBlLCByZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZXN1bHQoZmFsc2UpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMik7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gdW5jdXJyeVRoaXModW5jdXJyeVRoaXMuYmluZCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCkgewogICAgICAgICAgICAgICAgICAgIGFDYWxsYWJsZShmbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQgPT09IHVuZGVmaW5lZCA/IGZuIDogTkFUSVZFX0JJTkQgPyBiaW5kKGZuLCB0aGF0KSA6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZuLmFwcGx5KHRoYXQsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZm4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2xhc3NvZlJhdyhmbikgPT09ICdGdW5jdGlvbicpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhmbik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMzUpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCwgdXNpbmdJdGVyYXRvcikgewogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvck1ldGhvZCA9IGFyZ3VtZW50cy5sZW5ndGggPCAyID8gZ2V0SXRlcmF0b3JNZXRob2QoYXJndW1lbnQpIDogdXNpbmdJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoYUNhbGxhYmxlKGl0ZXJhdG9yTWV0aG9kKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFuT2JqZWN0KGNhbGwoaXRlcmF0b3JNZXRob2QsIGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TWV0aG9kKGl0LCBJVEVSQVRPUikgfHwgZ2V0TWV0aG9kKGl0LCAnQEBpdGVyYXRvcicpIHx8IEl0ZXJhdG9yc1tjbGFzc29mKGl0KV07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRNZXRob2QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMzKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhdG9yLCBraW5kLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBnZXRNZXRob2QoaXRlcmF0b3IsICdyZXR1cm4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbm5lclJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09ICd0aHJvdycpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBjYWxsKGlubmVyUmVzdWx0LCBpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJFcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyUmVzdWx0ID0gZXJyb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSAndGhyb3cnKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJFcnJvcikKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgaW5uZXJSZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoaW5uZXJSZXN1bHQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzUHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI4KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1Byb3RvdHlwZU9mKFByb3RvdHlwZSwgaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElURVJBVE9SID0gd2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpOwogICAgICAgICAgICAgICAgdmFyIFNBRkVfQ0xPU0lORyA9IGZhbHNlOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICB2YXIgaXRlcmF0b3JXaXRoUmV0dXJuID0gewogICAgICAgICAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiAhIWNhbGxlZCsrIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICdyZXR1cm4nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQUZFX0NMT1NJTkcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBpdGVyYXRvcldpdGhSZXR1cm5bSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIEFycmF5LmZyb20oaXRlcmF0b3JXaXRoUmV0dXJuLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IDI7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYywgU0tJUF9DTE9TSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFTS0lQX0NMT1NJTkcgJiYgIVNBRkVfQ0xPU0lORykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmplY3QgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0W0lURVJBVE9SXSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiBJVEVSQVRJT05fU1VQUE9SVCA9IHRydWUgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBleGVjKG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElURVJBVElPTl9TVVBQT1JUOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCR0aGlzLCBkdW1teSwgV3JhcHBlcikgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQsIE5ld1RhcmdldFByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YgJiYgaXNDYWxsYWJsZShOZXdUYXJnZXQgPSBkdW1teS5jb25zdHJ1Y3RvcikgJiYgTmV3VGFyZ2V0ICE9PSBXcmFwcGVyICYmIGlzT2JqZWN0KE5ld1RhcmdldFByb3RvdHlwZSA9IE5ld1RhcmdldC5wcm90b3R5cGUpICYmIE5ld1RhcmdldFByb3RvdHlwZSAhPT0gV3JhcHBlci5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKCR0aGlzLCBOZXdUYXJnZXRQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyMCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjcmVhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDczKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdElucyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIxKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGFuSW5zdGFuY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciBpdGVyYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTApOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIHNldFNwZWNpZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhc3RLZXkgPSAoX193X3BkZmpzX3JlcXVpcmVfXygxMDMpLmZhc3RLZXkpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBzZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5zZXQ7CiAgICAgICAgICAgICAgICB2YXIgaW50ZXJuYWxTdGF0ZUdldHRlckZvciA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0dGVyRm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29uc3RydWN0b3I6IGZ1bmN0aW9uICh3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKHRoYXQsIGl0ZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbkluc3RhbmNlKHRoYXQsIFByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoYXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDT05TVFJVQ1RPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBjcmVhdGUobnVsbCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3Q6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0OiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRlKGl0ZXJhYmxlLCB0aGF0W0FEREVSXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0OiB0aGF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBQcm90b3R5cGUgPSBDb25zdHJ1Y3Rvci5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gaW50ZXJuYWxTdGF0ZUdldHRlckZvcihDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmluZSA9IGZ1bmN0aW9uICh0aGF0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gZ2V0RW50cnkodGhhdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2aW91cywgaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS52YWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCA9IGZhc3RLZXkoa2V5LCB0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldmlvdXM6IHByZXZpb3VzID0gc3RhdGUubGFzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5maXJzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuZmlyc3QgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzLm5leHQgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLnNpemUrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCAhPT0gJ0YnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5pbmRleFtpbmRleF0gPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGF0OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZmFzdEtleShrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICE9PSAnRicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmluZGV4W2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBzdGF0ZS5maXJzdDsgZW50cnk7IGVudHJ5ID0gZW50cnkubmV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS5rZXkgPT0ga2V5KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW5zKFByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXI6IGZ1bmN0aW9uIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc3RhdGUuaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gc3RhdGUuZmlyc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGVudHJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkucHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS5wcmV2aW91cyA9IGVudHJ5LnByZXZpb3VzLm5leHQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBkYXRhW2VudHJ5LmluZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS5uZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5maXJzdCA9IHN0YXRlLmxhc3QgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zaXplID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGF0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZW50cnkgPSBnZXRFbnRyeSh0aGF0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dCA9IGVudHJ5Lm5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5pbmRleFtlbnRyeS5pbmRleF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5wcmV2aW91cyA9IHByZXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5maXJzdCA9PSBlbnRyeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmZpcnN0ID0gbmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QgPT0gZW50cnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gcHJldjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2l6ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0LnNpemUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yRWFjaDogZnVuY3Rpb24gZm9yRWFjaChjYWxsYmFja2ZuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYm91bmRGdW5jdGlvbiA9IGJpbmQoY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5maXJzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3VuZEZ1bmN0aW9uKGVudHJ5LnZhbHVlLCBlbnRyeS5rZXksIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhczogZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIWdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdElucyhQcm90b3R5cGUsIElTX01BUCA/IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IGdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVudHJ5ICYmIGVudHJ5LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmaW5lKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gYWRkKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZSh0aGlzLCB2YWx1ZSA9IHZhbHVlID09PSAwID8gMCA6IHZhbHVlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoUHJvdG90eXBlLCAnc2l6ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9uZzogZnVuY3Rpb24gKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIElURVJBVE9SX05BTUUgPSBDT05TVFJVQ1RPUl9OQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbENvbGxlY3Rpb25TdGF0ZSA9IGludGVybmFsU3RhdGVHZXR0ZXJGb3IoQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbEl0ZXJhdG9yU3RhdGUgPSBpbnRlcm5hbFN0YXRlR2V0dGVyRm9yKElURVJBVE9SX05BTUUpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVJdGVyYXRvcihDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSwgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBJVEVSQVRPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaXRlcmF0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IGdldEludGVybmFsQ29sbGVjdGlvblN0YXRlKGl0ZXJhdGVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3Q6IHVuZGVmaW5lZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsSXRlcmF0b3JTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IHN0YXRlLmxhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LnByZXZpb3VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS50YXJnZXQgfHwgIShzdGF0ZS5sYXN0ID0gZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5zdGF0ZS5maXJzdCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS50YXJnZXQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUl0ZXJSZXN1bHRPYmplY3QodW5kZWZpbmVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICdrZXlzJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChlbnRyeS5rZXksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICd2YWx1ZXMnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGVudHJ5LnZhbHVlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkua2V5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIElTX01BUCA/ICdlbnRyaWVzJyA6ICd2YWx1ZXMnLCAhSVNfTUFQLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3BlY2llcyhDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNyYywgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzcmMpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTIyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoQ09OU1RSVUNUT1JfTkFNRSkgewogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IGdldEJ1aWx0SW4oQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTICYmIENvbnN0cnVjdG9yICYmICFDb25zdHJ1Y3RvcltTUEVDSUVTXSkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjQpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjb2xsZWN0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDIpOwogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb25TdHJvbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMCk7CiAgICAgICAgICAgICAgICBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBTZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbml0KHRoaXMsIGFyZ3VtZW50cy5sZW5ndGggPyBhcmd1bWVudHNbMF0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LCBjb2xsZWN0aW9uU3Ryb25nKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTI1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRCdWlsdGluID0gX193X3BkZmpzX3JlcXVpcmVfXygyNyk7CiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE3KTsKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIHVpZCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDQpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMjYpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Nyk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0ZUFyZ3VtZW50c0xlbmd0aCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRSZWdFeHBGbGFncyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI4KTsKICAgICAgICAgICAgICAgIHZhciBNYXBIZWxwZXJzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzApOwogICAgICAgICAgICAgICAgdmFyIFNldEhlbHBlcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMSk7CiAgICAgICAgICAgICAgICB2YXIgRVJST1JfU1RBQ0tfSU5TVEFMTEFCTEUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMik7CiAgICAgICAgICAgICAgICB2YXIgUFJPUEVSX1RSQU5TRkVSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzMpOwogICAgICAgICAgICAgICAgdmFyIE9iamVjdCA9IGdsb2JhbC5PYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXkgPSBnbG9iYWwuQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgRGF0ZSA9IGdsb2JhbC5EYXRlOwogICAgICAgICAgICAgICAgdmFyIEVycm9yID0gZ2xvYmFsLkVycm9yOwogICAgICAgICAgICAgICAgdmFyIEV2YWxFcnJvciA9IGdsb2JhbC5FdmFsRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUmFuZ2VFcnJvciA9IGdsb2JhbC5SYW5nZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJlZmVyZW5jZUVycm9yID0gZ2xvYmFsLlJlZmVyZW5jZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFN5bnRheEVycm9yID0gZ2xvYmFsLlN5bnRheEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVVJJRXJyb3IgPSBnbG9iYWwuVVJJRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUGVyZm9ybWFuY2VNYXJrID0gZ2xvYmFsLlBlcmZvcm1hbmNlTWFyazsKICAgICAgICAgICAgICAgIHZhciBXZWJBc3NlbWJseSA9IGdsb2JhbC5XZWJBc3NlbWJseTsKICAgICAgICAgICAgICAgIHZhciBDb21waWxlRXJyb3IgPSBXZWJBc3NlbWJseSAmJiBXZWJBc3NlbWJseS5Db21waWxlRXJyb3IgfHwgRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgTGlua0Vycm9yID0gV2ViQXNzZW1ibHkgJiYgV2ViQXNzZW1ibHkuTGlua0Vycm9yIHx8IEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJ1bnRpbWVFcnJvciA9IFdlYkFzc2VtYmx5ICYmIFdlYkFzc2VtYmx5LlJ1bnRpbWVFcnJvciB8fCBFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBET01FeGNlcHRpb24gPSBnZXRCdWlsdGluKCdET01FeGNlcHRpb24nKTsKICAgICAgICAgICAgICAgIHZhciBNYXAgPSBNYXBIZWxwZXJzLk1hcDsKICAgICAgICAgICAgICAgIHZhciBtYXBIYXMgPSBNYXBIZWxwZXJzLmhhczsKICAgICAgICAgICAgICAgIHZhciBtYXBHZXQgPSBNYXBIZWxwZXJzLmdldDsKICAgICAgICAgICAgICAgIHZhciBtYXBTZXQgPSBNYXBIZWxwZXJzLnNldDsKICAgICAgICAgICAgICAgIHZhciBTZXQgPSBTZXRIZWxwZXJzLlNldDsKICAgICAgICAgICAgICAgIHZhciBzZXRBZGQgPSBTZXRIZWxwZXJzLmFkZDsKICAgICAgICAgICAgICAgIHZhciBvYmplY3RLZXlzID0gZ2V0QnVpbHRpbignT2JqZWN0JywgJ2tleXMnKTsKICAgICAgICAgICAgICAgIHZhciBwdXNoID0gdW5jdXJyeVRoaXMoW10ucHVzaCk7CiAgICAgICAgICAgICAgICB2YXIgdGhpc0Jvb2xlYW5WYWx1ZSA9IHVuY3VycnlUaGlzKHRydWUudmFsdWVPZik7CiAgICAgICAgICAgICAgICB2YXIgdGhpc051bWJlclZhbHVlID0gdW5jdXJyeVRoaXMoMS4wLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNTdHJpbmdWYWx1ZSA9IHVuY3VycnlUaGlzKCcnLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNUaW1lVmFsdWUgPSB1bmN1cnJ5VGhpcyhEYXRlLnByb3RvdHlwZS5nZXRUaW1lKTsKICAgICAgICAgICAgICAgIHZhciBQRVJGT1JNQU5DRV9NQVJLID0gdWlkKCdzdHJ1Y3R1cmVkQ2xvbmUnKTsKICAgICAgICAgICAgICAgIHZhciBEQVRBX0NMT05FX0VSUk9SID0gJ0RhdGFDbG9uZUVycm9yJzsKICAgICAgICAgICAgICAgIHZhciBUUkFOU0ZFUlJJTkcgPSAnVHJhbnNmZXJyaW5nJzsKICAgICAgICAgICAgICAgIHZhciBjaGVja0Jhc2ljU2VtYW50aWMgPSBmdW5jdGlvbiAoc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNldDEgPSBuZXcgZ2xvYmFsLlNldChbN10pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgc2V0MiA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHNldDEpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbnVtYmVyID0gc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24oT2JqZWN0KDcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNldDIgPT0gc2V0MSB8fCAhc2V0Mi5oYXMoNykgfHwgdHlwZW9mIG51bWJlciAhPSAnb2JqZWN0JyB8fCBudW1iZXIgIT0gNzsKICAgICAgICAgICAgICAgICAgICB9KSAmJiBzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbjsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY2hlY2tFcnJvcnNDbG9uaW5nID0gZnVuY3Rpb24gKHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uLCAkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gbmV3ICRFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGVycm9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogZXJyb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKHRlc3QgJiYgdGVzdC5hID09PSB0ZXN0LmIgJiYgdGVzdC5hIGluc3RhbmNlb2YgJEVycm9yICYmIHRlc3QuYS5zdGFjayA9PT0gZXJyb3Iuc3RhY2spOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBjaGVja05ld0Vycm9yc0Nsb25pbmdTZW1hbnRpYyA9IGZ1bmN0aW9uIChzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKG5ldyBnbG9iYWwuQWdncmVnYXRlRXJyb3IoWzFdLCBQRVJGT1JNQU5DRV9NQVJLLCB7IGNhdXNlOiAzIH0pKTsKICAgICA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2YXIgdGhyb3dVbmNsb25lYWJsZSA9IGZ1bmN0aW9uICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IERPTUV4Y2VwdGlvbignVW5jbG9uZWFibGUgdHlwZTogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0aHJvd1VucG9seWZpbGxhYmxlID0gZnVuY3Rpb24gKHR5cGUsIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oKGFjdGlvbiB8fCAnQ2xvbmluZycpICsgJyBvZiAnICsgdHlwZSArICcgY2Fubm90IGJlIHByb3Blcmx5IHBvbHlmaWxsZWQgaW4gdGhpcyBlbmdpbmUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRGF0YVRyYW5zZmVyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBkYXRhVHJhbnNmZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5EYXRhVHJhbnNmZXIoKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5DbGlwYm9hcmRFdmVudCgnJykuY2xpcGJvYXJkRGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGFUcmFuc2ZlciAmJiBkYXRhVHJhbnNmZXIuaXRlbXMgJiYgZGF0YVRyYW5zZmVyLmZpbGVzID8gZGF0YVRyYW5zZmVyIDogbnVsbDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgc3RydWN0dXJlZENsb25lSW50ZXJuYWwgPSBmdW5jdGlvbiAodmFsdWUsIG1hcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1N5bWJvbCh2YWx1ZSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5jbG9uZWFibGUoJ1N5bWJvbCcpOwogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hcEdldChtYXAsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gY2xhc3NvZih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgQywgbmFtZSwgY2xvbmVkLCBkYXRhVHJhbnNmZXIsIGksIGxlbmd0aCwga2V5cywga2V5LCBzb3VyY2UsIHRhcmdldCwgb3B0aW9uczsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQXJyYXkobGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdTZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnUmVnRXhwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBSZWdFeHAodmFsdWUuc291cmNlLCBnZXRSZWdFeHBGbGFncyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQWdncmVnYXRlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBnZXRCdWlsdGluKCdBZ2dyZWdhdGVFcnJvcicpKFtdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRXZhbEVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gRXZhbEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JhbmdlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBSYW5nZUVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JlZmVyZW5jZUVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gUmVmZXJlbmNlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU3ludGF4RXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBTeW50YXhFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUeXBlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBUeXBlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVVJJRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBVUklFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDb21waWxlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDb21waWxlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnTGlua0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gTGlua0Vycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1J1bnRpbWVFcnJvcic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IFJ1bnRpbWVFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NRXhjZXB0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01FeGNlcHRpb24odmFsdWUubWVzc2FnZSwgdmFsdWUubmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdEYXRhVmlldyc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDhBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1VpbnQ4QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50OENsYW1wZWRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDE2QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MTZBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDMyQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0JpZ0ludDY0QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdCaWdVaW50NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEMoc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuYnVmZmVyLCBtYXApLCB2YWx1ZS5ieXRlT2Zmc2V0LCB0eXBlID09PSAnRGF0YVZpZXcnID8gdmFsdWUuYnl0ZUxlbmd0aCA6IHZhbHVlLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUXVhZCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01RdWFkKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnAxLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZS5wMiwgbWFwKSwgc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUucDMsIG1hcCksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnA0LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZUxpc3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gY3JlYXRlRGF0YVRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuZ3RoID0gbGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyLml0ZW1zLmFkZChzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZVtpXSwgbWFwKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IGRhdGFUcmFuc2Zlci5maWxlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdJbWFnZURhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgSW1hZ2VEYXRhKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmRhdGEsIG1hcCksIHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQsIHsgY29sb3JTcGFjZTogdmFsdWUuY29sb3JTcGFjZSB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmlnSW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IE9iamVjdCh2YWx1ZS52YWx1ZU9mKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Jvb2xlYW4nOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNCb29sZWFuVmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdOdW1iZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNOdW1iZXJWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1N0cmluZyc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBPYmplY3QodGhpc1N0cmluZ1ZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRGF0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgRGF0ZSh0aGlzVGltZVZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5EYXRhVmlldzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQyAmJiB0eXBlb2YgdmFsdWUuc2xpY2UgIT0gJ2Z1bmN0aW9uJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnNsaWNlID09ICdmdW5jdGlvbicgJiYgIXZhbHVlLnJlc2l6YWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB2YWx1ZS5zbGljZSgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zID0gJ21heEJ5dGVMZW5ndGgnIGluIHZhbHVlID8geyBtYXhCeXRlTGVuZ3RoOiB2YWx1ZS5tYXhCeXRlTGVuZ3RoIH0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBBcnJheUJ1ZmZlcihsZW5ndGgsIG9wdGlvbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2UgPSBuZXcgQyh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IG5ldyBDKGNsb25lZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnNldFVpbnQ4KGksIHNvdXJjZS5nZXRVaW50OChpKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0FycmF5QnVmZmVyIGlzIGRldGFjaGVkJywgREFUQV9DTE9ORV9FUlJPUik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU2hhcmVkQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmxvYic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IHZhbHVlLnNsaWNlKDAsIHZhbHVlLnNpemUsIHZhbHVlLnR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVBvaW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUG9pbnRSZWFkT25seSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDLmZyb21Qb2ludCA/IEMuZnJvbVBvaW50KHZhbHVlKSA6IG5ldyBDKHZhbHVlLngsIHZhbHVlLnksIHZhbHVlLnosIHZhbHVlLncpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVJlY3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdET01SZWN0UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tUmVjdCA/IEMuZnJvbVJlY3QodmFsdWUpIDogbmV3IEModmFsdWUueCwgdmFsdWUueSwgdmFsdWUud2lkdGgsIHZhbHVlLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tTWF0cml4ID8gQy5mcm9tTWF0cml4KHZhbHVlKSA6IG5ldyBDKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdWaWRlb0ZyYW1lJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZSh2YWx1ZS5jbG9uZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEZpbGUoW3ZhbHVlXSwgdmFsdWUubmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Nyb3BUYXJnZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDcnlwdG9LZXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtRGlyZWN0b3J5SGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZVN5c3RlbUZpbGVIYW5kbGUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25JbmZvJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25NZXNzYWdlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW1hZ2VCaXRtYXAnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSVENDZXJ0aWZpY2F0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1dlYkFzc2VtYmx5Lk1vZHVsZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG1hcFNldChtYXAsIHZhbHVlLCBjbG9uZWQpOwogICAgICAgICAgICAgICAgICAgIGlmIChkZWVwKQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0FycmF5JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5cyA9IG9iamVjdEtleXModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKGtleXMpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkoY2xvbmVkLCBrZXksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlW2tleV0sIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodiwgaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBTZXQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbChrLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1NldCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRBZGQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoY2xvbmVkLCAnbWVzc2FnZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLm1lc3NhZ2UsIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24odmFsdWUsICdjYXVzZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdjYXVzZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmNhdXNlLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgPT0gJ0FnZ3JlZ2F0ZUVycm9yJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQuZXJyb3JzID0gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuZXJyb3JzLCBtYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTUV4Y2VwdGlvbic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEVSUk9SX1NUQUNLX0lOU1RBTExBQkxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdzdGFjaycsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnN0YWNrLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmVkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1RyYW5zZmVyID0gZnVuY3Rpb24gKHJhd1RyYW5zZmVyLCBtYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHJhd1RyYW5zZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKCdUcmFuc2ZlciBvcHRpb24gY2Fubm90IGJlIGNvbnZlcnRlZCB0byBhIHNlcXVlbmNlJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShyYXdUcmFuc2ZlciwgZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2godHJhbnNmZXIsIGFuT2JqZWN0KHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZSh0cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlLCB0eXBlLCBDLCB0cmFuc2ZlcnJlZEFycmF5LCB0cmFuc2ZlcnJlZCwgY2FudmFzLCBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfVFJBTlNGRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJyZWRBcnJheSA9IG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSh0cmFuc2ZlciwgeyB0cmFuc2ZlcjogdHJhbnNmZXIgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdHJhbnNmZXJbaV0sIHRyYW5zZmVycmVkQXJyYXlbaSsrXSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRyYW5zZmVyW2krK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0R1cGxpY2F0ZSB0cmFuc2ZlcmFibGUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBjbGFzc29mKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ltYWdlQml0bWFwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5PZmZzY3JlZW5DYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDb25zdHJ1Y3RvcihDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcyA9IG5ldyBDKHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dCA9IGNhbnZhcy5nZXRDb250ZXh0KCdiaXRtYXByZW5kZXJlcicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC50cmFuc2ZlckZyb21JbWFnZUJpdG1hcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IGNhbnZhcy50cmFuc2ZlclRvSW1hZ2VCaXRtYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1ZpZGVvRnJhbWUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUuY2xvbmUpIHx8ICFpc0NhbGxhYmxlKHZhbHVlLmNsb3NlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVycmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUudHJhbnNmZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlLCBUUkFOU0ZFUlJJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IHZhbHVlLnRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01lZGlhU291cmNlSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdNZXNzYWdlUG9ydCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnT2Zmc2NyZWVuQ2FudmFzJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSZWFkYWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVHJhbnNmb3JtU3RyZWFtJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdXcml0YWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2ZlcnJlZCA9PT0gdW5kZWZpbmVkKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ1RoaXMgb2JqZWN0IGNhbm5vdCBiZSB0cmFuc2ZlcnJlZDogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdmFsdWUsIHRyYW5zZmVycmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIGdsb2JhbDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIHNoYW06ICFQUk9QRVJfVFJBTlNGRVIsCiAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBGT1JDRURfUkVQTEFDRU1FTlQKICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3R1cmVkQ2xvbmU6IGZ1bmN0aW9uIHN0cnVjdHVyZWRDbG9uZSh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IHZhbGlkYXRlQXJndW1lbnRzTGVuZ3RoKGFyZ3VtZW50cy5sZW5ndGgsIDEpID4gMSAmJiAhaXNOdWxsT3JVbmRlZmluZWQoYXJndW1lbnRzWzFdKSA/IGFuT2JqZWN0KGFyZ3VtZW50c1sxXSkgOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2ZlciA9IG9wdGlvbnMgPyBvcHRpb25zLnRyYW5zZmVyIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWFwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmZXIgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5VG9UcmFuc2Zlcih0cmFuc2ZlciwgbWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpbnNwZWN0U291cmNlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NCk7CiAgICAgICAgICAgICAgICB2YXIgbm9vcCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZW1wdHkgPSBbXTsKICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3QgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ2NvbnN0cnVjdCcpOwogICAgICAgICAgICAgICAgdmFyIGNvbnN0cnVjdG9yUmVnRXhwID0gL15ccyooPzpjbGFzc3xmdW5jdGlvbilcYi87CiAgICAgICAgICAgICAgICB2YXIgZXhlYyA9IHVuY3VycnlUaGlzKGNvbnN0cnVjdG9yUmVnRXhwLmV4ZWMpOwogICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9UT19TVFJJTkcgPSAhY29uc3RydWN0b3JSZWdFeHAuZXhlYyhub29wKTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yTW9kZXJuID0gZnVuY3Rpb24gaXNDb25zdHJ1Y3Rvcihhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZShhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Qobm9vcCwgZW1wdHksIGFyZ3VtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgaXNDb25zdHJ1Y3RvckxlZ2FjeSA9IGZ1bmN0aW9uIGlzQ29uc3RydWN0b3IoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChjbGFzc29mKGFyZ3VtZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0Z1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR2VuZXJhdG9yRnVuY3Rpb24nOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0dlbmVyYXRvckZ1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOQ09SUkVDVF9UT19TVFJJTkcgfHwgISFleGVjKGNvbnN0cnVjdG9yUmVnRXhwLCBpbnNwZWN0U291cmNlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlzQ29uc3RydWN0b3JMZWdhY3kuc2hhbSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFjb25zdHJ1Y3QgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBjYWxsZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ29uc3RydWN0b3JNb2Rlcm4oaXNDb25zdHJ1Y3Rvck1vZGVybi5jYWxsKSB8fCAhaXNDb25zdHJ1Y3Rvck1vZGVybihPYmplY3QpIHx8ICFpc0NvbnN0cnVjdG9yTW9kZXJuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9KSB8fCBjYWxsZWQ7CiAgICAgICAgICAgICAgICB9KSA/IGlzQ29uc3RydWN0b3JMZWdhY3kgOiBpc0NvbnN0cnVjdG9yTW9kZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHBhc3NlZCwgcmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGFzc2VkIDwgcmVxdWlyZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICRUeXBlRXJyb3IoJ05vdCBlbm91Z2ggYXJndW1lbnRzJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhc3NlZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBpc1Byb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXygyOCk7CiAgICAgICAgICAgICAgICB2YXIgcmVnRXhwRmxhZ3MgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyOSk7CiAgICAgICAgICAgICAgICB2YXIgUmVnRXhwUHJvdG90eXBlID0gUmVnRXhwLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFIpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZmxhZ3MgPSBSLmZsYWdzOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmbGFncyA9PT0gdW5kZWZpbmVkICYmICEoJ2ZsYWdzJyBpbiBSZWdFeHBQcm90b3R5cGUpICYmICFoYXNPd24oUiwgJ2ZsYWdzJykgJiYgaXNQcm90b3R5cGVPZihSZWdFeHBQcm90b3R5cGUsIFIpID8gY2FsbChyZWdFeHBGbGFncywgUikgOiBmbGFnczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBhbk9iamVjdCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaGFzSW5kaWNlcykKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdkJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5nbG9iYWwpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnZyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaWdub3JlQ2FzZSkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdpJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5tdWx0aWxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnbSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuZG90QWxsKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3MnOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGF0LnVuaWNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQudW5pY29kZVNldHMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndic7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuc3RpY2t5KQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3knOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIE1hcFByb3RvdHlwZSA9IE1hcC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBNYXA6IE1hcCwKICAgICAgICAgICAgICAgICAgICBzZXQ6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZS5zZXQpLAogICAgICAgICAgICAgICAgICAgIGdldDogdW5jdXJyeVRoaXMoTWFwUHJvdG90eXBlLmdldCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhNYXBQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBNYXBQcm90b3R5cGUKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgU2V0UHJvdG90eXBlID0gU2V0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gewogICAgICAgICAgICAgICAgICAgIFNldDogU2V0LAogICAgICAgICAgICAgICAgICAgIGFkZDogdW5jdXJyeVRoaXMoU2V0UHJvdG90eXBlLmFkZCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhTZXRQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKFNldFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBTZXRQcm90b3R5cGUsCiAgICAgICAgICAgICAgICAgICAgJGhhczogU2V0UHJvdG90eXBlLmhhcywKICAgICAgICAgICAgICAgICAgICAka2V5czogU2V0UHJvdG90eXBlLmtleXMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gRXJyb3IoJ2EnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnc3RhY2snIGluIGVycm9yKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGVycm9yLCAnc3RhY2snLCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMSwgNykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvci5zdGFjayAhPT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgVjggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMxKTsKICAgICAgICAgICAgICAgIHZhciBJU19CUk9XU0VSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzQpOwogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhIXN0cnVjdHVyZWRDbG9uZSAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChJU19ERU5PICYmIFY4ID4gOTIgfHwgSVNfTk9ERSAmJiBWOCA+IDk0IHx8IElTX0JST1dTRVIgJiYgVjggPiA5NykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoOCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGNsb25lID0gc3RydWN0dXJlZENsb25lKGJ1ZmZlciwgeyB0cmFuc2ZlcjogW2J1ZmZlcl0gfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlci5ieXRlTGVuZ3RoICE9IDAgfHwgY2xvbmUuYnl0ZUxlbmd0aCAhPSA4OwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIUlTX0RFTk8gJiYgIUlTX05PREUgJiYgdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB0eXBlb2YgZG9jdW1lbnQgPT0gJ29iamVjdCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdHlwZW9mIERlbm8gPT0gJ29iamVjdCcgJiYgRGVubyAmJiB0eXBlb2YgRGVuby52ZXJzaW9uID09ICdvYmplY3QnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBwcm9jZXNzICE9ICd1bmRlZmluZWQnICYmIGNsYXNzb2YocHJvY2VzcykgPT0gJ3Byb2Nlc3MnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewo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2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9hbm5vdGF0aW9uX3N0b3JhZ2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2ZvbnRfbG9hZGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDUpOwogICAgICAgICAgICAgICAgdmFyIF9jYW52YXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Nik7CiAgICAgICAgICAgICAgICB2YXIgX3dvcmtlcl9vcHRpb25zID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDkpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIHZhciBfbWVzc2FnZV9oYW5kbGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTApOwogICAgICAgICAgICAgICAgdmFyIF9tZXRhZGF0YSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTUxKTsKICAgICAgICAgICAgICAgIHZhciBfb3B0aW9uYWxfY29udGVudF9jb25maWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Mik7CiAgICAgICAgICAgICAgICB2YXIgX3RyYW5zcG9ydF9zdHJlYW0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Myk7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIH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FuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERlZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeTsKICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVDTWFwUmVhZGVyRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVTdGFuZGFyZEZvbnREYXRhRmFjdG9yeQogICAgICAgICAgICAgICAgICAgIH0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1NSk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q2FudmFzRmFjdG9yeSA9IERlZmF1bHRDYW52YXNGYWN0b3J5ID0gTm9kZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBEZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0RmlsdGVyRmFjdG9yeSA9IERlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBEZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgY3JlYXRlUERGTmV0d29ya1N0cmVhbTsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGTm9kZVN0cmVhbQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVQREZOZXR3b3JrU3RyZWFtID0gcGFyYW1zID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGTm9kZVN0cmVhbShwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBERk5ldHdvcmtTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU5KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGRmV0Y2hTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUERGTmV0d29ya1N0cmVhbSA9IHBhcmFtcyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF9kaXNwbGF5X3V0aWxzLmlzVmFsaWRGZXRjaFVybCkocGFyYW1zLnVybCkgPyBuZXcgUERGRmV0Y2hTdHJlYW0ocGFyYW1zKSA6IG5ldyBQREZOZXR3b3JrU3RyZWFtKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RG9jdW1lbnQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzcmMgPT09ICJzdHJpbmciIHx8IHNyYyBpbnN0YW5jZW9mIFVSTCkgewogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHNyYwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKHNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3JjID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogc3JjCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3JjICE9PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIGluIGdldERvY3VtZW50LCBuZWVkIHBhcmFtZXRlciBvYmplY3QuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghc3JjLnVybCAmJiAhc3JjLmRhdGEgJiYgIXNyYy5yYW5nZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIG9iamVjdDogbmVlZCBlaXRoZXIgLmRhdGEsIC5yYW5nZSBvciAudXJsIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgUERGRG9jdW1lbnRMb2FkaW5nVGFzaygpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQKICAgICAgICAgICAgICAgICAgICB9ID0gdGFzazsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzcmMudXJsID8gZ2V0VXJsUHJvcChzcmMudXJsKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHNyYy5kYXRhID8gZ2V0RGF0YVByb3Aoc3JjLmRhdGEpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBodHRwSGVhZGVycyA9IHNyYy5odHRwSGVhZGVycyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpdGhDcmVkZW50aWFscyA9IHNyYy53aXRoQ3JlZGVudGlhbHMgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFzc3dvcmQgPSBzcmMucGFzc3dvcmQgPz8gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZVRyYW5zcG9ydCA9IHNyYy5yYW5nZSBpbnN0YW5jZW9mIFBERkRhdGFSYW5nZVRyYW5zcG9ydCA/IHNyYy5yYW5nZSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VDaHVua1NpemUgPSBOdW1iZXIuaXNJbnRlZ2VyKHNyYy5yYW5nZUNodW5rU2l6ZSkgJiYgc3JjLnJhbmdlQ2h1bmtTaXplID4gMCA/IHNyYy5yYW5nZUNodW5rU2l6ZSA6IERFRkFVTFRfUkFOR0VfQ0hVTktfU0laRTsKICAgICAgICAgICAgICAgICAgICBsZXQgd29ya2VyID0gc3JjLndvcmtlciBpbnN0YW5jZW9mIFBERldvcmtlciA/IHNyYy53b3JrZXIgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcmJvc2l0eSA9IHNyYy52ZXJib3NpdHk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZG9jQmFzZVVybCA9IHR5cGVvZiBzcmMuZG9jQmFzZVVybCA9PT0gInN0cmluZyIgJiYgISgwLCBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWUpKHNyYy5kb2NCYXNlVXJsK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MuZmlsdGVyRmFjdG9yeSB8fCBuZXcgRGVmYXVsdEZpbHRlckZhY3RvcnkoewogICAgICAgICAgICAgICAgICAgICAgICBkb2NJZCwKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnNldFZlcmJvc2l0eUxldmVsKSh2ZXJib3NpdHkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydEZhY3RvcnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnkKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmICghdXNlV29ya2VyRmV0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNwb3J0RmFjdG9yeS5jTWFwUmVhZGVyRmFjdG9yeSA9IG5ldyBDTWFwUmVhZGVyRmFjdG9yeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlVXJsOiBjTWFwVXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkOiBjTWFwUGFja2VkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRGYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gbmV3IFN0YW5kYXJkRm9udERhdGFGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmw6IHN0YW5kYXJkRm9udERhdGFVcmwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghd29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlclBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclBvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyID0gd29ya2VyUGFyYW1zLnBvcnQgPyBQREZXb3JrZXIuZnJvbVBvcnQod29ya2VyUGFyYW1zKSA6IG5ldyBQREZXb3JrZXIod29ya2VyUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fd29ya2VyID0gd29ya2VyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBmZXRjaERvY1BhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGFwaVZlcnNpb246ICczLjUuMTIyJywKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY0Jhc2VVcmwsCiAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYSwKICAgICAgICAgICAgICAgICAgICAgICAgZXZhbHVhdG9yT3B0aW9uczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4SW1hZ2VTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNNYXhBcmVhSW5CeXRlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRFeHRyYVByb3BlcnRpZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VTeXN0ZW1Gb250cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBVcmw6IHVzZVdvcmtlckZldGNoID8gY01hcFVybCA6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZEZvbnREYXRhVXJsOiB1c2VXb3JrZXJGZXRjaCA/IHN0YW5kYXJkRm9udERhdGFVcmwgOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVGb250RmFjZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9udEV4dHJhUHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgZW5hYmxlWGZhLAogICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWcsCiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgd29ya2VyLnByb21pc2UudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0YXNrLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJMb2FkaW5nIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJJZFByb21pc2UgPSBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIGZldGNoRG9jUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV0d29ya1N0cmVhbVByb21pc2UgPSBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFuZ2VUcmFuc3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrU3RyZWFtID0gbmV3IF90cmFuc3BvcnRfc3RyZWFtLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0oewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluaXRpYWxEYXRhOiByYW5nZVRyYW5zcG9ydC5pbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NpdmVEb25lOiByYW5nZVRyYW5zcG9ydC5wcm9ncmVzc2l2ZURvbmUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiByYW5nZVRyYW5zcG9ydC5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgcmFuZ2VUcmFuc3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtTdHJlYW0gPSBjcmVhdGVQREZOZXR3b3JrU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0dHBIZWFkZXJzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoQ3JlZGVudGlhbHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUobmV0d29ya1N0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwoW3dvcmtlcklkUHJvbWlzZSwgbmV0d29ya1N0cmVhbVByb21pc2VdKS50aGVuKGZ1bmN0aW9uIChfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3dvcmtlcklkLCBuZXR3b3JrU3RyZWFtXSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkxvYWRpbmcgYWJvcnRlZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihkb2NJZCwgd29ya2VySWQsIHdvcmtlci5wb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9IG5ldyBXb3JrZXJUcmFuc3BvcnQobWVzc2FnZUhhbmRsZXIsIHRhc2ssIG5ldHdvcmtTdHJlYW0sIHRyYW5zcG9ydFBhcmFtcywgdHJhbnNwb3J0RmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXNrLl90cmFuc3BvcnQgPSB0cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJSZWFkeSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0YXNrLl9jYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhc2s7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIGlmICh3b3JrZXIuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiV29ya2VyIHdhcyBkZXN0cm95ZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgd29ya2VySWQgPSBhd2FpdCB3b3JrZXIubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NSZXF1ZXN0Iiwgc291cmNlLCBzb3VyY2UuZGF0YSA/IFtzb3VyY2UuZGF0YS5idWZmZXJdIDogbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdvcmtlci5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VySWQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRVcmxQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmICh2YWwgaW5zdGFuY2VvZiBVUkwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbC5ocmVmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVSTCh2YWwsIHdpbmRvdy5sb2NhdGlvbikuaHJlZjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFBERiB1cmwgZGF0YTogIiArICJlaXRoZXIgc3RyaW5nIG9yIFVSTC1vYmplY3QgaXMgZXhwZWN0ZWQgaW4gdGhlIHVybCBwcm9wZXJ0eS4iKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldERhdGFQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgQnVmZmVyICE9PSAidW5kZWZpbmVkIiAmJiB2YWwgaW5zdGFuY2VvZiBCdWZmZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJQbGVhc2UgcHJvdmlkZSBiaW5hcnkgZGF0YSBhcyBgVWludDhBcnJheWAsIHJhdGhlciB0aGFuIGBCdWZmZXJgLiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgdmFsLmJ5dGVMZW5ndGggPT09IHZhbC5idWZmZXIuYnl0ZUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gIm9iamVjdCIgJiYgIWlzTmFOKHZhbCA9PT0gbnVsbCB8fCB2YWwgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHZhbC5sZW5ndGgpIHx8ICgwLCBfdXRpbC5pc0FycmF5QnVmZmVyKSh2YWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVWludDhBcnJheSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgUERGIGJpbmFyeSBkYXRhOiBlaXRoZXIgVHlwZWRBcnJheSwgIiArICJzdHJpbmcsIG9yIGFycmF5LWxpa2Ugb2JqZWN0IGlzIGV4cGVjdGVkIGluIHRoZSBkYXRhIHByb3BlcnR5LiIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRG9jdW1lbnRMb2FkaW5nVGFzayB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljICNkb2NJZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZG9jSWQgPSBgZCR7UERGRG9jdW1lbnRMb2FkaW5nVGFzay4jZG9jSWQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUGFzc3dvcmQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF90cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgKChfdGhpcyRfdHJhbnNwb3J0ID0gdGhpcy5fdHJhbnNwb3J0KSA9PT0gbnVsbCB8fCBfdGhpcyRfdHJhbnNwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfdHJhbnNwb3J0LmRlc3Ryb3koKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93b3JrZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93b3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZEb2N1bWVudExvYWRpbmdUYXNrID0gUERGRG9jdW1lbnRMb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRhdGFSYW5nZVRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobGVuZ3RoLCBpbml0aWFsRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3NpdmVEb25lID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbml0aWFsRGF0YSA9IGluaXRpYWxEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2dyZXNzaXZlRG9uZSA9IHByb2dyZXNzaXZlRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZVJlYWRMaXN0ZW5lcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lTGlzdGVuZXJzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUmFuZ2VMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIobGlzdGVuZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXJzLnB1c2gobGlzdGVuZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRQcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcnMucHVzaChsaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVJhbmdlKGJlZ2luLCBjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3JhbmdlTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcihiZWdpbiwgY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzKGxvYWRlZCwgdG90YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXIobG9hZGVkLCB0b3RhbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbkRhdGFQcm9ncmVzc2l2ZVJlYWQoY2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlUmVhZExpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKGNodW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlRG9uZUxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBQREZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhYm9ydCgpIHt9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFSYW5nZVRyYW5zcG9ydCA9IFBERkRhdGFSYW5nZVRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRvY3VtZW50UHJveHkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBkZkluZm8sIHRyYW5zcG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZJbmZvID0gcGRmSW5mbzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNwb3J0ID0gdHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaWx0ZXJGYWN0b3J5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBudW1QYWdlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BkZkluZm8ubnVtUGFnZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaW5nZXJwcmludHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wZGZJbmZvLmZpbmdlcnByaW50czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUHVyZVhmYSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1B1cmVYZmEiLCAhIXRoaXMuX3RyYW5zcG9ydC5faHRtbEZvclhmYSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBhbGxYZmFIdG1sKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlKHBhZ2VOdW1iZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRQYWdlKHBhZ2VOdW1iZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlSW5kZXgocmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUluZGV4KHJlZik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbnMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RGVzdGluYXRpb24oaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbihpZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYWJlbHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUxhYmVscygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTGF5b3V0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBhZ2VMYXlvdXQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZU1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZU1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0T3BlbkFjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRPcGVuQWN0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEF0dGFjaG1lbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEF0dGFjaG1lbnRzKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEphdmFTY3JpcHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0SmF2YVNjcmlwdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RG9jSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3V0bGluZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3B0aW9uYWxDb250ZW50Q29uZmlnKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBlcm1pc3Npb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1ldGFkYXRhKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1hcmtJbmZvKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RGF0YSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuc2F2ZURvY3VtZW50KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvd25sb2FkSW5mbygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwTG9hZGVkRm9udHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LnN0YXJ0Q2xlYW51cChrZWVwTG9hZGVkRm9udHMgfHwgdGhpcy5pc1B1cmVYZmEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5sb2FkaW5nVGFzay5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nUGFyYW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmxvYWRpbmdQYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nVGFzaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5sb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEZpZWxkT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuaGFzSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Q2FsY3VsYXRpb25PcmRlcklkcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRG9jdW1lbnRQcm94eSA9IFBERkRvY3VtZW50UHJveHk7CiAgICAgICAgICAgICAgICB2YXIgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wZW5kaW5nQ2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF90cnlDbGVhbnVwID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2Fib3J0RGVsYXllZENsZWFudXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFBERlBhZ2VQcm94eSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFnZUluZGV4LCBwYWdlSW5mbywgdHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwZGZCdWcgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Fib3J0RGVsYXllZENsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3RyeUNsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYWdlSW5kZXggPSBwYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VJbmZvID0gcGFnZUluZm87CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IHRyYW5zcG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdHMgPSBwZGZCdWcgPyBuZXcgX2Rpc3BsYXlfdXRpbHMuU3RhdFRpbWVyKCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IHRyYW5zcG9ydC5jb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9ianMgPSBuZXcgUERGT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlbnRTdGF0ZXMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlTnVtYmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZGV4ICsgMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJvdGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJvdGF0ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJlZigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJlZjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHVzZXJVbml0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udXNlclVuaXQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCB2aWV3KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udmlldzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld3BvcnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZGlzcGxheV91dGlscy5QYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFubm90YXRpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRBcmdzID0gdGhpcy5fdHJhbnNwb3J0LmdldFJlbmRlcmluZ0ludGVudChpbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEFubm90YXRpb25zKHRoaXMuX3BhZ2VJbmRleCwgaW50ZW50QXJncy5yZW5kZXJpbmdJbnRlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUpTQWN0aW9ucyh0aGlzLl9wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNQdXJlWGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzUHVyZVhmYSIsICEhdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZ2V0WGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3RyYW5zcG9ydCRfaHRtOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKChfdGhpcyRfdHJhbnNwb3J0JF9odG0gPSB0aGlzLl90cmFuc3BvcnQuX2h0bWxGb3JYZmEpID09PSBudWxsIHx8IF90aGlzJF90cmFuc3BvcnQkX2h0bSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3RyYW5zcG9ydCRfaHRtLmNoaWxkcmVuW3RoaXMuX3BhZ2VJbmRleF0pIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcihfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbk1vZGUgPSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZ1Byb21pc2UgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlQ29sb3JzID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNhbnZhc0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5kZXByZWNhdGVkKSgicmVuZGVyIG5vIGxvbmdlciBhY2NlcHRzIHRoZSBgY2FudmFzRmFjdG9yeWAtb3B0aW9uLCAiICsgInBsZWFzZSBwYXNzIGl0IHRvIHRoZSBgZ2V0RG9jdW1lbnRgLWZ1bmN0aW9uIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0cyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0cy50aW1lKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudEFyZ3MgPSB0aGlzLl90cmFuc3BvcnQuZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCwgYW5ub3RhdGlvbk1vZGUsIHByaW50QW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlID0gdGhpcy5fdHJhbnNwb3J0LmdldE9wdGlvbmFsQ29udGVudENvbmZpZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQoaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRQcmludCA9ICEhKGludGVudEFyZ3MucmVuZGVyaW5nSW50ZW50ICYgX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5QUklOVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3NBcnJheTogW10sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdENodW5rOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXBhcmF0ZUFubm90czogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHMyID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czIudGltZSgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wdW1wT3BlcmF0b3JMaXN0KGludGVudEFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbXBsZXRlID0gZXJyb3IgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czMsIF90aGlzJF9zdGF0czQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciB8fCBpbnRlbnRQcmludCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsICFpbnRlbnRQcmludCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogZXJyb3IgaW5zdGFuY2VvZiBFcnJvciA/IGVycm9yIDogbmV3IEVycm9yKGVycm9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzMyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHMzLnRpbWVFbmQoIlJlbmRlcmluZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0czQgPSB0aGlzLl9zdGF0cykgPT09IG51bGwgfHwgX3RoaXMkX3N0YXRzNCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3N0YXRzNC50aW1lRW5kKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVybmFsUmVuZGVyVGFzayA9IG5ldyBJbnRlcm5hbFJlbmRlclRhc2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IGNvbXBsZXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9ianM6IHRoaXMub2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianM6IHRoaXMuY29tbW9uT2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25DYW52YXNNYXAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3Q6IGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeTogY2FudmFzRmFjdG9yeSB8fCB0aGlzLl90cmFuc3BvcnQuY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3Rvcnk6IHRoaXMuX3RyYW5zcG9ydC5maWx0ZXJGYWN0b3J5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlUmVxdWVzdEFuaW1hdGlvbkZyYW1lOiAhaW50ZW50UHJpbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWc6IHRoaXMuX3BkZkJ1ZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VDb2xvcnMKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcyB8fD0gbmV3IFNldCgpKS5hZGQoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVuZGVyVGFzayA9IGludGVybmFsUmVuZGVyVGFzay50YXNrOwogICAgICAgICAgICAgICAgICAgICAgICBQcm9taXNlLmFsbChbaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5wcm9taXNlLCBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlXSkudGhlbihfcmVmMyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbdHJhbnNwYXJlbmN5LCBvcHRpb25hbENvbnRlbnRDb25maWddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM1ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czUudGltZSgiUmVuZGVyaW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suaW5pdGlhbGl6ZUdyYXBoaWNzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKGNvbXBsZXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9wZXJhdG9yTGlzdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCA9ICJkaXNwbGF5IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25Nb2RlID0gX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlc29sdmUoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUob3BMaXN0VGFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50QXJncyA9IHRoaXMuX3RyYW5zcG9ydC5nZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50LCBhbm5vdGF0aW9uTW9kZSwgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcExpc3RUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdFRhc2sgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BMaXN0VGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkID0gb3BlcmF0b3JMaXN0Q2hhbmdlZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludGVudFN0YXRlLnJlbmRlclRhc2tzIHx8PSBuZXcgU2V0KCkpLmFkZChvcExpc3RUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbkFycmF5OiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RDaHVuazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHM6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzNiA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHM2ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHM2LnRpbWUoIlBhZ2UgUmVxdWVzdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHVtcE9wZXJhdG9yTGlzdChpbnRlbnRBcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RyZWFtVGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVEVYVF9DT05URU5UX0NIVU5LX1NJWkUgPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldFRleHRDb250ZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4OiB0aGlzLl9wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21iaW5lVGV4dEl0ZW1zOiBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyAhPT0gdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50OiBpbmNsdWRlTWFya2VkQ29udGVudCA9PT0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoV2F0ZXJNYXJrOiBURVhUX0NPTlRFTlRfQ0hVTktfU0laRSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUodGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0VGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbXMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRYZmEoKS50aGVuKHhmYSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfdGV4dC5YZmFUZXh0LnRleHRDb250ZW50KHhmYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkYWJsZVN0cmVhbSA9IHRoaXMuc3RyZWFtVGV4dENvbnRlbnQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1bXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLnJlYWQoKS50aGVuKGZ1bmN0aW9uIChfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUodGV4dENvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24odGV4dENvbnRlbnQuc3R5bGVzLCB2YWx1ZS5zdHlsZXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKC4uLnZhbHVlLml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSByZWFkYWJsZVN0cmVhbS5nZXRSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRDb250ZW50ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zOiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFN0cnVjdFRyZWUodGhpcy5fcGFnZUluZGV4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2FpdE9uID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZW50U3RhdGUgb2YgdGhpcy5faW50ZW50U3RhdGVzLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydE9wZXJhdG9yTGlzdCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiBuZXcgRXJyb3IoIlBhZ2Ugd2FzIGRlc3Ryb3llZC4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2goaW50ZXJuYWxSZW5kZXJUYXNrLmNvbXBsZXRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJuYWxSZW5kZXJUYXNrLmNhbmNlbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHdhaXRPbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXNldFN0YXRzID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1Y2Nlc3MgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzZXRTdGF0cyAmJiBzdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0cyAmJj0gbmV3IF9kaXNwbGF5X3V0aWxzLlN0YXRUaW1lcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzdWNjZXNzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc3RhcnRSZW5kZXJQYWdlKHRyYW5zcGFyZW5jeSwgY2FjaGVLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czcsIF9pbnRlbnRTdGF0ZSRkaXNwbGF5UjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50U3RhdGUgPSB0aGlzLl9pbnRlbnRTdGF0ZXMuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM3ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czcgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czcudGltZUVuZCgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIChfaW50ZW50U3RhdGUkZGlzcGxheVIgPSBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5KSA9PT0gbnVsbCB8fCBfaW50ZW50U3RhdGUkZGlzcGxheVIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9pbnRlbnRTdGF0ZSRkaXNwbGF5Ui5yZXNvbHZlKHRyYW5zcGFyZW5jeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJQYWdlQ2h1bmsob3BlcmF0b3JMaXN0Q2h1bmssIGludGVudFN0YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IG9wZXJhdG9yTGlzdENodW5rLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdC5mbkFycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuZm5BcnJheVtpXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QuYXJnc0FycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QubGFzdENodW5rID0gb3BlcmF0b3JMaXN0Q2h1bmsubGFzdENodW5rOwogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3Quc2VwYXJhdGVBbm5vdHMgPSBvcGVyYXRvckxpc3RDaHVuay5zZXBhcmF0ZUFubm90czsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbnRlcm5hbFJlbmRlclRhc2sgb2YgaW50ZW50U3RhdGUucmVuZGVyVGFza3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wZXJhdG9yTGlzdENodW5rLmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wdW1wT3BlcmF0b3JMaXN0KF9yZWY1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGFibGVTdHJlYW0gPSB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldE9wZXJhdG9yTGlzdCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50OiByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBhbm5vdGF0aW9uU3RvcmFnZU1hcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGVyID0gcmVhZGFibGVTdHJlYW0uZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudFN0YXRlID0gdGhpcy5faW50ZW50U3RhdGVzLmdldChjYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlciA9IHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHVtcCA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5yZWFkKCkudGhlbihfcmVmNiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlclBhZ2VDaHVuayh2YWx1ZSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuayA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2sub3BlcmF0b3JMaXN0Q2hhbmdlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3RyeUNsZWFudXAsIF90cnlDbGVhbnVwMikuY2FsbCh0aGlzLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLmRpc3BsYXlSZWFkeUNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYWJvcnRPcGVyYXRvckxpc3QoX3JlZjcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2UgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjc7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9yY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5zaXplID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXkgPSBSRU5ERVJJTkdfQ0FOQ0VMTEVEX1RJTUVPVVQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlYXNvbi5leHRyYURlbGF5ID4gMCAmJiByZWFzb24uZXh0cmFEZWxheSA8IDEwMDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXkgKz0gcmVhc29uLmV4dHJhRGVsYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2U6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZGVsYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXIuY2FuY2VsKG5ldyBfdXRpbC5BYm9ydEV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSkpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RyYW5zcG9ydC5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtjdXJDYWNoZUtleSwgY3VySW50ZW50U3RhdGVdIG9mIHRoaXMuX2ludGVudFN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1ckludGVudFN0YXRlID09PSBpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5kZWxldGUoY3VyQ2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xlYW51cCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc3RhdHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdGF0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERlBhZ2VQcm94eSA9IFBERlBhZ2VQcm94eTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF90cnlDbGVhbnVwMigpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXllZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWJvcnREZWxheWVkQ2xlYW51cCwgX2Fib3J0RGVsYXllZENsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZGVsYXllZCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9LCBERUxBWUVEX0NMRUFOVVBfVElNRU9VVCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUYXNrcywKICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0CiAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLl9pbnRlbnRTdGF0ZXMudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlclRhc2tzLnNpemUgPiAwIHx8ICFvcGVyYXRvckxpc3QubGFzdENodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5faW50ZW50U3RhdGVzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Fib3J0RGVsYXllZENsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBMb29wYmFja1BvcnQgewogICAgICAgICAgICAgICAgICAgICNsaXN0ZW5lcnMgPSBuZXcgU2V0KCk7CiAgICAgICAgICAgICAgICAgICAgI2RlZmVycmVkID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgcG9zdE1lc3NhZ2Uob2JqLCB0cmFuc2ZlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBldmVudCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IHN0cnVjdHVyZWRDbG9uZShvYmosIHRyYW5zZmVyID8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IDogbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jZGVmZXJyZWQudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuI2xpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuYWRkKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuZGVsZXRlKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGVybWluYXRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkxvb3BiYWNrUG9ydCA9IExvb3BiYWNrUG9ydDsKICAgICAgICAgICAgICAgIGNvbnN0IFBERldvcmtlclV0aWwgPSB7CiAgICAgICAgICAgICAgICAgICAgaXNXb3JrZXJEaXNhYmxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgZmFsbGJhY2tXb3JrZXJTcmM6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgZmFrZVdvcmtlcklkOiAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXJVdGlsID0gUERGV29ya2VyVXRpbDsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHJlcXVpcmUgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5mYWxsYmFja1dvcmtlclNyYyA9ICIuL3BkZi53b3JrZXIuanMiOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGRvY3VtZW50ID09PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50LCBfZG9jdW1lbnQkY3VycmVudFNjcmk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZmpzRmlsZVBhdGggPSAoX2RvY3VtZW50ID0gZG9jdW1lbnQpID09PSBudWxsIHx8IF9kb2N1bWVudCA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF9kb2N1bWVudCRjdXJyZW50U2NyaSA9IF9kb2N1bWVudC5jdXJyZW50U2NyaXB0KSA9PT0gbnVsbCB8fCBfZG9jdW1lbnQkY3VycmVudFNjcmkgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9kb2N1bWVudCRjdXJyZW50U2NyaS5zcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZGZqc0ZpbGVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXJVdGlsLmZhbGxiYWNrV29ya2VyU3JjID0gcGRmanNGaWxlUGF0aC5yZXBsYWNlKC8oXC4oPzptaW5cLik/anMpKFw/LiopPyQvaSwgIi53b3JrZXIkMSQyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4gPSBmdW5jdGlvbiAoYmFzZVVybCwgb3RoZXJVcmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlID0gbmV3IFVSTChiYXNlVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmFzZS5vcmlnaW4gfHwgYmFzZS5vcmlnaW4gPT09ICJudWxsIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyID0gbmV3IFVSTChvdGhlclVybCwgYmFzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiYXNlLm9yaWdpbiA9PT0gb3RoZXIub3JpZ2luOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gYGltcG9ydFNjcmlwdHMoIiR7dXJsfSIpO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKG5ldyBCbG9iKFt3cmFwcGVyXSkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZXb3JrZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyAjd29ya2VyUG9ydHMgPSBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3J0ID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSA9ICgwLCBfdXRpbC5nZXRWZXJib3NpdHlMZXZlbCkoKQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBvcnQgJiYgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5oYXMocG9ydCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ2Fubm90IHVzZSBtb3JlIHRoYW4gb25lIFBERldvcmtlciBwZXIgcG9ydC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZlcmJvc2l0eSA9IHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fd2ViV29ya2VyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5zZXQocG9ydCwgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbml0aWFsaXplRnJvbVBvcnQocG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5pdGlhbGl6ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcG9ydCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBtZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfaW5pdGlhbGl6ZUZyb21Qb3J0KHBvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoIm1haW4iLCAid29ya2VyIiwgcG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGZ1bmN0aW9uICgpIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIuc2VuZCgiY29uZmlndXJlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkICYmICFQREZXb3JrZXIuX21haW5UaHJlYWRXb3JrZXJNZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXJTcmMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4od2luZG93LmxvY2F0aW9uLmhyZWYsIHdvcmtlclNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyU3JjID0gUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyKG5ldyBVUkwod29ya2VyU3JjLCB3aW5kb3cubG9jYXRpb24pLmhyZWYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXIgPSBuZXcgV29ya2VyKHdvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcigibWFpbiIsICJ3b3JrZXIiLCB3b3JrZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRlcm1pbmF0ZUVhcmx5ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0dXBGYWtlV29ya2VyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9uV29ya2VyRXJyb3IgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigidGVzdCIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dlYldvcmtlciA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVzdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbmRUZXN0ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXN0T2JqID0gbmV3IFVpbnQ4QXJyYXkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuc2VuZCgidGVzdCIsIHRlc3RPYmosIFt0ZXN0T2JqLmJ1ZmZlcl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VuZFRlc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaGUgd29ya2VyIGhhcyBiZWVuIGRpc2FibGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldHVwRmFrZVdvcmtlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc2V0dXBGYWtlV29ya2VyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVBERldvcmtlclV0aWwuaXNXb3JrZXJEaXNhYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJTZXR0aW5nIHVwIGZha2Ugd29ya2VyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXIuX3NldHVwRmFrZVdvcmtlckdsb2JhbC50aGVuKFdvcmtlck1lc3NhZ2VIYW5kbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3J0ID0gbmV3IExvb3BiYWNrUG9ydCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBmYWtlJHtQREZXb3JrZXJVdGlsLmZha2VXb3JrZXJJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoaWQgKyAiX3dvcmtlciIsIGlkLCBwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFdvcmtlck1lc3NhZ2VIYW5kbGVyLnNldHVwKHdvcmtlckhhbmRsZXIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihpZCwgaWQgKyAiX3dvcmtlciIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBtZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkeUNhcGFiaWxpdHkucmVqZWN0KG5ldyBFcnJvcihgU2V0dGluZyB1cCBmYWtlIHdvcmtlciBmYWlsZWQ6ICIke3JlYXNvbi5tZXNzYWdlfSIuYCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIFBERldvcmtlci4jd29ya2VyUG9ydHMuZGVsZXRlKHRoaXMuX3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX21lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGZyb21Qb3J0KHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShwYXJhbXMgIT09IG51bGwgJiYgcGFyYW1zICE9PSB2b2lkIDAgJiYgcGFyYW1zLnBvcnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBERldvcmtlci5mcm9tUG9ydCAtIGludmFsaWQgbWV0aG9kIHNpZ25hdHVyZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jd29ya2VyUG9ydHMuaGFzKHBhcmFtcy5wb3J0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3dvcmtlclBvcnRzLmdldChwYXJhbXMucG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQREZXb3JrZXIocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCB3b3JrZXJTcmMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmMgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoJ05vICJHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyIgc3BlY2lmaWVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAiR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMiIHNwZWNpZmllZC4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfbWFpblRocmVhZFdvcmtlck1lc3NhZ2VIYW5kbGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9nbG9iYWxUaGlzJHBkZmpzV29yazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF9nbG9iYWxUaGlzJHBkZmpzV29yayA9IGdsb2JhbFRoaXMucGRmanNXb3JrZXIpID09PSBudWxsIHx8IF9nbG9iYWxUaGlzJHBkZmpzV29yayA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2dsb2JhbFRoaXMkcGRmanNXb3JrLldvcmtlck1lc3NhZ2VIYW5kbGVyKSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfc2V0dXBGYWtlV29ya2VyR2xvYmFsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsb2FkZXIgPSBhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYWluV29ya2VyTWVzc2FnZUhhbmRsZXIgPSB0aGlzLl9tYWluVGhyZWFkV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFpbldvcmtlck1lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1haW5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgcmVxdWlyZSA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlciA9IGV2YWwoInJlcXVpcmUiKSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0ICgwLCBfZGlzcGxheV91dGlscy5sb2FkU2NyaXB0KSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93LnBkZmpzV29ya2VyLldvcmtlck1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9zZXR1cEZha2VXb3JrZXJHbG9iYWwiLCBsb2FkZXIoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXIgPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICB2YXIgX21ldGhvZFByb21pc2VzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX3BhZ2VDYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wYWdlUHJvbWlzZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY2FjaGVTaW1wbGVNZXRob2QgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFdvcmtlclRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWVzc2FnZUhhbmRsZXIsIGxvYWRpbmdUYXNrLCBuZXR3b3JrU3RyZWFtLCBwYXJhbXMsIGZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tZXRob2RQcm9taXNlcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGFnZUNhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9wYWdlUHJvbWlzZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWRpbmdUYXNrID0gbG9hZGluZ1Rhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IG5ldyBQREZPYmplY3RzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udExvYWRlciA9IG5ldyBfZm9udF9sb2FkZXIuRm9udExvYWRlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50OiBwYXJhbXMub3duZXJEb2N1bWVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudDogcGFyYW1zLnN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBmYWN0b3J5LmNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZhY3RvcnkuZmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSA9IGZhY3RvcnkuY01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBmYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3lDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbSA9IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXN0UHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRvd25sb2FkSW5mb0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0dXBNZXNzYWdlSGFuZGxlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiYW5ub3RhdGlvblN0b3JhZ2UiLCBuZXcgX2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZSgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYW5ub3RhdGlvbk1vZGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc09wTGlzdCA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkRJU1BMQVk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhbm5vdGF0aW9uTWFwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImFueSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ID0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5BTlk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJkaXNwbGF5IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInByaW50IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgaW50ZW50OiAke2ludGVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGFubm90YXRpb25Nb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkRJU0FCTEU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEVfRk9STVM6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRk9STVM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRV9TVE9SQUdFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCArPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOTk9UQVRJT05TX1NUT1JBR0U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5ub3RhdGlvblN0b3JhZ2UgPSByZW5kZXJpbmdJbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UICYmIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgaW5zdGFuY2VvZiBfYW5ub3RhdGlvbl9zdG9yYWdlLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPyBwcmludEFubm90YXRpb25TdG9yYWdlIDogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uTWFwID0gYW5ub3RhdGlvblN0b3JhZ2Uuc2VyaWFsaXphYmxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgYW5ub3RhdGlvbk1vZGU6ICR7YW5ub3RhdGlvbk1vZGV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzT3BMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgKz0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5PUExJU1Q7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBgJHtyZW5kZXJpbmdJbnRlbnR9XyR7X2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZS5nZXRIYXNoKGFubm90YXRpb25NYXApfWAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZU1hcDogYW5ub3RhdGlvbk1hcAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Bhc3N3b3JkQ2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCBkdXJpbmcgb25QYXNzd29yZCBjYWxsYmFjayIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3YWl0T24gPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwYWdlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2gocGFnZS5fZGVzdHJveSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhhc093blByb3BlcnR5KCJhbm5vdGF0aW9uU3RvcmFnZSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFubm90YXRpb25TdG9yYWdlLnJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXJtaW5hdGVkID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIlRlcm1pbmF0ZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB3YWl0T24ucHVzaCh0ZXJtaW5hdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5hbGwod2FpdE9uKS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJGYWN0b3J5LmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9uZXR3b3JrU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbS5jYW5jZWxBbGxSZXF1ZXN0cyhuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIldvcmtlciB3YXMgdGVybWluYXRlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0dXBNZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzawogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkdldFJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmVhZGVyIC0gbm8gYElQREZTdHJlYW1gIGluc3RhbmNlIGF2YWlsYWJsZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldEZ1bGxSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIub25Qcm9ncmVzcyA9IGV2dCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGFzdFByb2dyZXNzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25QdWxsID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSZWFkZXIgLSBleHBlY3RlZCBhbiBBcnJheUJ1ZmZlci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lbnF1ZXVlKG5ldyBVaW50OEFycmF5KHZhbHVlKSwgMSwgW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25DYW5jZWwgPSByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJSZWFkZXJIZWFkZXJzUmVhZHkiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlYWRlcnNDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdWxsUmVhZGVyLmhlYWRlcnNSZWFkeS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZ1bGxSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQgfHwgIWZ1bGxSZWFkZXIuaXNSYW5nZVN1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbGFzdFByb2dyZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZSA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlLmNhbGwobG9hZGluZ1Rhc2ssIHRoaXMuX2xhc3RQcm9ncmVzcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnVsbFJlYWRlci5vblByb2dyZXNzID0gZXZ0ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZTIgPSBsb2FkaW5nVGFzay5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyLmNhbGwobG9hZGluZ1Rhc2ssIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC50b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1N0cmVhbWluZ1N1cHBvcnRlZDogZnVsbFJlYWRlci5pc1N0cmVhbWluZ1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSYW5nZVN1cHBvcnRlZDogZnVsbFJlYWRlci5pc1JhbmdlU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50TGVuZ3RoOiBmdWxsUmVhZGVyLmNvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGhlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXRSYW5nZVJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmFuZ2VSZWFkZXIgLSBubyBgSVBERlN0cmVhbWAgaW5zdGFuY2UgYXZhaWxhYmxlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldFJhbmdlUmVhZGVyKGRhdGEuYmVnaW4sIGRhdGEuZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcmFuZ2VSZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vblB1bGwgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSYW5nZVJlYWRlciAtIGV4cGVjdGVkIGFuIEFycmF5QnVmZmVyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUobmV3IFVpbnQ4QXJyYXkodmFsdWUpLCAxLCBbdmFsdWVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vbkNhbmNlbCA9IHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXREb2MiLCBfcmVmMTAgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZJbmZvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjEwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbnVtUGFnZXMgPSBwZGZJbmZvLm51bVBhZ2VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faHRtbEZvclhmYSA9IHBkZkluZm8uaHRtbEZvclhmYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwZGZJbmZvLmh0bWxGb3JYZmE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5fY2FwYWJpbGl0eS5yZXNvbHZlKG5ldyBQREZEb2N1bWVudFByb3h5KHBkZkluZm8sIHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NFeGNlcHRpb24iLCBmdW5jdGlvbiAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGV4Lm5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5jb2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiSW52YWxpZFBERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5JbnZhbGlkUERGRXhjZXB0aW9uKGV4Lm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNaXNzaW5nUERGRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oZXgubWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oZXgubWVzc2FnZSwgZXguc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiVW5rbm93bkVycm9yRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5kZXRhaWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiRG9jRXhjZXB0aW9uIC0gZXhwZWN0ZWQgYSB2YWxpZCBFcnJvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRpbmdUYXNrLl9jYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIlBhc3N3b3JkUmVxdWVzdCIsIGV4Y2VwdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobG9hZGluZ1Rhc2sub25QYXNzd29yZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVwZGF0ZVBhc3N3b3JkID0gcGFzc3dvcmQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFzc3dvcmQgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChwYXNzd29yZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5vblBhc3N3b3JkKHVwZGF0ZVBhc3N3b3JkLCBleGNlcHRpb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVqZWN0KG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleGNlcHRpb24ubWVzc2FnZSwgZXhjZXB0aW9uLmNvZGUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEYXRhTG9hZGVkIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfbG9hZGluZ1Rhc2skb25Qcm9ncmUzID0gbG9hZGluZ1Rhc2sub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMy5jYWxsKGxvYWRpbmdUYXNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBkYXRhLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbDogZGF0YS5sZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigiU3RhcnRSZW5kZXJQYWdlIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChkYXRhLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLl9zdGFydFJlbmRlclBhZ2UoZGF0YS50cmFuc3BhcmVuY3ksIGRhdGEuY2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oImNvbW1vbm9iaiIsIF9yZWYxMSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2dsb2JhbFRoaXMkRm9udEluc3BlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgdHlwZSwgZXhwb3J0ZWREYXRhXSA9IF9yZWYxMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbW1vbk9ianMuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkZvbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB0aGlzLl9wYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgiZXJyb3IiIGluIGV4cG9ydGVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXhwb3J0ZWRFcnJvciA9IGV4cG9ydGVkRGF0YS5lcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRXJyb3IgZHVyaW5nIGZvbnQgbG9hZGluZzogJHtleHBvcnRlZEVycm9yfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5zcGVjdEZvbnQgPSBwYXJhbXMucGRmQnVnICYmIChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkID8gKGZvbnQsIHVybCkgPT4gZ2xvYmFsVGhpcy5Gb250SW5zcGVjdG9yLmZvbnRBZGRlZChmb250LCB1cmwpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IG5ldyBfZm9udF9sb2FkZXIuRm9udEZhY2VPYmplY3QoZXhwb3J0ZWREYXRhLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQ6IHBhcmFtcy5pc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRm9udEZhY2U6IHBhcmFtcy5kaXNhYmxlRm9udEZhY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnM6IHBhcmFtcy5pZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNwZWN0Rm9udAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmJpbmQoZm9udCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkZvbnRGYWxsYmFjayIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmZpbmFsbHkoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXJhbXMuZm9udEV4dHJhUHJvcGVydGllcyAmJiBmb250LmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250LmRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGZvbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRm9udFBhdGgiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkltYWdlIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgR290IHVua25vd24gY29tbW9uIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJvYmoiLCBfcmVmMTIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgcGFnZUluZGV4LCB0eXBlLCBpbWFnZURhdGFdID0gX3JlZjEyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZVByb3h5ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VQcm94eS5vYmpzLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJJbWFnZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5vYmpzLnJlc29sdmUoaWQsIGltYWdlRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1hZ2VEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2ltYWdlRGF0YSRkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbmd0aCA9ICgoX2ltYWdlRGF0YSRkYXRhID0gaW1hZ2VEYXRhLmRhdGEpID09PSBudWxsIHx8IF9pbWFnZURhdGEkZGF0YSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2ltYWdlRGF0YSRkYXRhLmxlbmd0aCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPiBfdXRpbC5NQVhfSU1BR0VfU0laRV9UT19DQUNIRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5fbWF5YmVDbGVhbnVwQWZ0ZXJSZW5kZXIgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlUHJveHkub2Jqcy5yZXNvbHZlKGlkLCBpbWFnZURhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEdvdCB1bmtub3duIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NQcm9ncmVzcyIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9sb2FkaW5nVGFzayRvblByb2dyZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX2xvYWRpbmdUYXNrJG9uUHJvZ3JlNCA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9sb2FkaW5nVGFzayRvblByb2dyZTQuY2FsbChsb2FkaW5nVGFzaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogZGF0YS5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGRhdGEudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkZldGNoQnVpbHRJbkNNYXAiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIkNNYXBSZWFkZXJGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jTWFwUmVhZGVyRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJGZXRjaFN0YW5kYXJkRm9udERhdGEiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIlN0YW5kYXJkRm9udERhdGFGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGF0YSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoInNhdmVEb2N1bWVudCBjYWxsZWQgd2hpbGUgYGFubm90YXRpb25TdG9yYWdlYCBpcyBlbXB0eSwgIiArICJwbGVhc2UgdXNlIHRoZSBnZXREYXRhLW1ldGhvZCBpbnN0ZWFkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiU2F2ZURvY3VtZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNQdXJlWGZhOiAhIXRoaXMuX2h0bWxGb3JYZmEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBudW1QYWdlczogdGhpcy5fbnVtUGFnZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXJpYWxpemFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZTogKChfdGhpcyRfZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlci5maWxlbmFtZSkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KS5maW5hbGx5KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2UucmVzZXRNb2RpZmllZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZShwYWdlTnVtYmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihwYWdlTnVtYmVyKSB8fCBwYWdlTnVtYmVyIDw9IDAgfHwgcGFnZU51bWJlciA+IHRoaXMuX251bVBhZ2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2UgcmVxdWVzdC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZUluZGV4ID0gcGFnZU51bWJlciAtIDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGVkUHJvbWlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZFByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4ocGFnZUluZm8gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJUcmFuc3BvcnQgZGVzdHJveWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gbmV3IFBERlBhZ2VQcm94eShwYWdlSW5kZXgsIHBhZ2VJbmZvLCB0aGlzLCB0aGlzLl9wYXJhbXMucGRmQnVnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS5zZXQocGFnZUluZGV4LCBwYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLnNldChwYWdlSW5kZXgsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUluZGV4KHJlZikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlZiAhPT0gIm9iamVjdCIgfHwgcmVmID09PSBudWxsIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5udW0pIHx8IHJlZi5udW0gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5nZW4pIHx8IHJlZi5nZW4gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2VJbmRleCByZXF1ZXN0LiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBhZ2VJbmRleCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bTogcmVmLm51bSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdlbjogcmVmLmdlbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QW5ub3RhdGlvbnMocGFnZUluZGV4LCBpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRBbm5vdGF0aW9ucyIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2FjaGVTaW1wbGVNZXRob2QsIF9jYWNoZVNpbXBsZU1ldGhvZDIpLmNhbGwodGhpcywgIkdldEZpZWxkT2JqZWN0cyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCwgX2NhY2hlU2ltcGxlTWV0aG9kMikuY2FsbCh0aGlzLCAiSGFzSlNBY3Rpb25zIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0Q2FsY3VsYXRpb25PcmRlcklkcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXREZXN0aW5hdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9uKGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaWQgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIGRlc3RpbmF0aW9uIHJlcXVlc3QuIikpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb24iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUxhYmVscygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTGFiZWxzIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYXlvdXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0UGFnZUxheW91dCIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTW9kZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWaWV3ZXJQcmVmZXJlbmNlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRWaWV3ZXJQcmVmZXJlbmNlcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcGVuQWN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE9wZW5BY3Rpb24iLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QXR0YWNobWVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0QXR0YWNobWVudHMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0SmF2YVNjcmlwdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRKYXZhU2NyaXB0IiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvY0pTQWN0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NKU0FjdGlvbnMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUpTQWN0aW9ucyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlSlNBY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKHBhZ2VJbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFN0cnVjdFRyZWUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3V0bGluZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3B0aW9uYWxDb250ZW50Q29uZmlnIiwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX29wdGlvbmFsX2NvbnRlbnRfY29uZmlnLk9wdGlvbmFsQ29udGVudENvbmZpZyhyZXN1bHRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBlcm1pc3Npb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuYW1lID0gIkdldE1ldGFkYXRhIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlZFByb21pc2UgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkUHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjIsIF90aGlzJF9mdWxsUmVhZGVyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5mbzogcmVzdWx0c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YTogcmVzdWx0c1sxXSA/IG5ldyBfbWV0YWRhdGEuTWV0YWRhdGEocmVzdWx0c1sxXSkgOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiAoKF90aGlzJF9mdWxsUmVhZGVyMiA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZWFkZXIyLmZpbGVuYW1lKSA/PyBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRMZW5ndGg6ICgoX3RoaXMkX2Z1bGxSZWFkZXIzID0gdGhpcy5fZnVsbFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZWFkZXIzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlcjMuY29udGVudExlbmd0aCkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbWV0aG9kUHJvbWlzZXMpLnNldChuYW1lLCBwcm9taXNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE1hcmtJbmZvIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIHN0YXJ0Q2xlYW51cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGtlZXBMb2FkZWRGb250cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJDbGVhbnVwIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGFnZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsZWFudXBTdWNjZXNzZnVsID0gcGFnZS5jbGVhbnVwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNsZWFudXBTdWNjZXNzZnVsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzdGFydENsZWFudXA6IFBhZ2UgJHtwYWdlLnBhZ2VOdW1iZXJ9IGlzIGN1cnJlbnRseSByZW5kZXJpbmcuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgha2VlcExvYWRlZEZvbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRMb2FkZXIuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkuZGVzdHJveSh0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGxvYWRpbmdQYXJhbXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVYZmEKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuX3BhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJsb2FkaW5nUGFyYW1zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2FjaGVTaW1wbGVNZXRob2QyKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWNoZWRQcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuc2V0KG5hbWUsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm9taXNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgdmFyIF9vYmpzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Vuc3VyZU9iaiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGT2JqZWN0cyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5zdXJlT2JqKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ianMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5zdXJlT2JqLCBfZW5zdXJlT2JqMikuY2FsbCh0aGlzLCBvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmouY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gY2FsbGJhY2sob2JqLmRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2Jqcylbb2JqSWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShvYmogIT09IG51bGwgJiYgb2JqICE9PSB2b2lkIDAgJiYgb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgUmVxdWVzdGluZyBvYmplY3QgdGhhdCBpc24ndCByZXNvbHZlZCB5ZXQgJHtvYmpJZH0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iai5kYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXMob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAob2JqID09PSBudWxsIHx8IG9iaiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc29sdmUob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Vuc3VyZU9iaiwgX2Vuc3VyZU9iajIpLmNhbGwodGhpcywgb2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBvYmouZGF0YSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIG9iai5jYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xlYXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb2JqSWQgaW4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9kYXRhJGJpdG1hcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID09PSBudWxsIHx8IGRhdGEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfZGF0YSRiaXRtYXAgPSBkYXRhLmJpdG1hcCkgPT09IG51bGwgfHwgX2RhdGEkYml0bWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZGF0YSRiaXRtYXAuY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX29ianMsIE9iamVjdC5jcmVhdGUobnVsbCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbnN1cmVPYmoyKG9iaklkKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgaWYgKG9iaikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHk6ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKSwKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogbnVsbAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICAjaW50ZXJuYWxSZW5kZXJUYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihpbnRlcm5hbFJlbmRlclRhc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaW50ZXJuYWxSZW5kZXJUYXNrID0gaW50ZXJuYWxSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQ29udGludWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYW5jZWwobnVsbCwgZXh0cmFEZWxheSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBzZXBhcmF0ZUFubm90cygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VwYXJhdGVBbm5vdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLiNpbnRlcm5hbFJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZXBhcmF0ZUFubm90cy5mb3JtIHx8IHNlcGFyYXRlQW5ub3RzLmNhbnZhcyAmJiAoYW5ub3RhdGlvbkNhbnZhc01hcCA9PT0gbnVsbCB8fCBhbm5vdGF0aW9uQ2FudmFzTWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhbm5vdGF0aW9uQ2FudmFzTWFwLnNpemUpID4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlJlbmRlclRhc2sgPSBSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgY2xhc3MgSW50ZXJuYWxSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgI2NhbnZhc0luVXNlID0gbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmMTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBkZkJ1ZyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUNvbG9ycyA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYxMzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGNhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzID0gY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwID0gYW5ub3RhdGlvbkNhbnZhc01hcDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IG9wZXJhdG9yTGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUluZGV4ID0gcGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkgPSBmaWx0ZXJGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZUNvbG9ycyA9IHBhZ2VDb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucnVubmluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPT09IHRydWUgJiYgdHlwZW9mIHdpbmRvdyAhPT0gInVuZGVmaW5lZCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50YXNrID0gbmV3IFJlbmRlclRhc2sodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbmNlbEJvdW5kID0gdGhpcy5jYW5jZWwuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWVCb3VuZCA9IHRoaXMuX2NvbnRpbnVlLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kID0gdGhpcy5fc2NoZWR1bGVOZXh0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCA9IHRoaXMuX25leHQuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FudmFzID0gcGFyYW1zLmNhbnZhc0NvbnRleHQuY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY29tcGxldGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jYXBhYmlsaXR5LnByb21pc2UuY2F0Y2goZnVuY3Rpb24gKCkge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpbml0aWFsaXplR3JhcGhpY3MoX3JlZjE0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRTdGVwcGVyTWEsIF90aGlzJGdyYXBoaWNzUmVhZHlDYTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbmNlbGxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYW52YXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJbnRlcm5hbFJlbmRlclRhc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ICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNDb250ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZnggPSBuZXcgX2NhbnZhcy5DYW52YXNHcmFwaGljcyhjYW52YXNDb250ZXh0LCB0aGlzLmNvbW1vbk9ianMsIHRoaXMub2JqcywgdGhpcy5jYW52YXNGYWN0b3J5LCB0aGlzLmZpbHRlckZhY3RvcnksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZwogICAgICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLmFubm90YXRpb25DYW52YXNNYXApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5iZWdpbkRyYXdpbmcoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdElkeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRncmFwaGljc1JlYWR5Q2EgPSB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgPT09IG51bGwgfHwgX3RoaXMkZ3JhcGhpY3NSZWFkeUNhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRncmFwaGljc1JlYWR5Q2EuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2Z4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBleHRyYURlbGF5ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWxsZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZ2Z4ID0gdGhpcy5nZngpID09PSBudWxsIHx8IF90aGlzJGdmeCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZ2Z4LmVuZERyYXdpbmcodGhpcy5wYWdlQ29sb3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxSZW5kZXJUYXNrLiNjYW52YXNJblVzZS5kZWxldGUodGhpcy5fY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVycm9yIHx8IG5ldyBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24oYFJlbmRlcmluZyBjYW5jZWxsZWQsIHBhZ2UgJHt0aGlzLl9wYWdlSW5kZXggKyAxfWAsICJjYW52YXMiLCBleHRyYURlbGF5KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRzdGVwcGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhcGhpY3NSZWFkeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeUNhbGxiYWNrID0gdGhpcy5fY29udGludWVCb3VuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkc3RlcHBlciA9IHRoaXMuc3RlcHBlcikgPT09IG51bGwgfHwgX3RoaXMkc3RlcHBlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3RlcHBlci51cGRhdGVPcGVyYXRvckxpc3QodGhpcy5vcGVyYXRvckxpc3QpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NvbnRpbnVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5jZWxsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50YXNrLm9uQ29udGludWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFzay5vbkNvbnRpbnVlKHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zY2hlZHVsZU5leHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCgpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbih0aGlzLl9uZXh0Qm91bmQpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBfbmV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSB0aGlzLmdmeC5leGVjdXRlT3BlcmF0b3JMaXN0KHRoaXMub3BlcmF0b3JMaXN0LCB0aGlzLm9wZXJhdG9yTGlzdElkeCwgdGhpcy5fY29udGludWVCb3VuZCwgdGhpcy5zdGVwcGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMub3BlcmF0b3JMaXN0SWR4ID09PSB0aGlzLm9wZXJhdG9yTGlzdC5hcmdzQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm9wZXJhdG9yTGlzdC5sYXN0Q2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5lbmREcmF3aW5nKHRoaXMucGFnZUNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmRlbGV0ZSh0aGlzLl9jYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICAgICAgZXhwb3J0cy52ZXJzaW9uID0gdmVyc2lvbjsKICAgICAgICAgICAgICAgIGNvbnN0IGJ1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gYnVpbGQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBleHBvcnRzLkFubm90YXRpb25TdG9yYWdlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFkZChvYmopOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyhvYmosIHByaXZhdGVNYXAsIHZhbHVlKSB7IF9jaGVja1ByaXZhdGVSZWRlY2xhcmF0aW9uKG9iaiwgcHJpdmF0ZU1hcCk7IHByaXZhdGVNYXAuc2V0KG9iaiwgdmFsdWUpO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ICAgICAgICAgICAgICAgIHZhciBfc2V0TW9kaWZpZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25TdG9yYWdlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RpZmllZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9zdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXRNb2RpZmllZCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25SZXNldE1vZGlmaWVkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWYWx1ZShrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmYXVsdFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGRlZmF1bHRWYWx1ZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXdWYWx1ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB2YWx1ZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWYWx1ZShrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtb2RpZmllZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JqICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2VudHJ5LCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYmpbZW50cnldICE9PSB2YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmpbZW50cnldID0gdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RpZmllZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0TW9kaWZpZWQsIF9zZXRNb2RpZmllZDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yICYmIHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IodmFsdWUuY29uc3RydWN0b3IuX3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuaGFzKGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA+IDAgPyAoMCwgX3V0aWwub2JqZWN0RnJvbU1hcCkoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKSkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBbGwob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBPYmplY3QuZW50cmllcyhvYmopKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFZhbHVlKGtleSwgdmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzZXRNb2RpZmllZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGlmaWVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SZXNldE1vZGlmaWVkID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJpbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJpbnRBbm5vdGF0aW9uU3RvcmFnZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmUgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJpYWxpemVkID0gdmFsIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yID8gdmFsLnNlcmlhbGl6ZSgpIDogdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlcmlhbGl6ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZS5zZXQoa2V5LCBzZXJpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXRIYXNoKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc2ggPSBuZXcgX211cm11cmhhc2guTXVybXVySGFzaDNfNjQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzaC51cGRhdGUoYCR7a2V5fToke0pTT04uc3RyaW5naWZ5KHZhbCl9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2guaGV4ZGlnZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RvcmFnZSA9IEFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1vZGlmaWVkMigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbW9kaWZpZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25TZXRNb2RpZmllZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQcmludEFubm90YXRpb25TdG9yYWdlIGV4dGVuZHMgQW5ub3RhdGlvblN0b3JhZ2UgewogICAgICAgICAgICAgICAgICAgICNzZXJpYWxpemFibGUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNzZXJpYWxpemFibGUgPSBzdHJ1Y3R1cmVkQ2xvbmUocGFyZW50LnNlcmlhbGl6YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcmludCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIFByaW50QW5ub3RhdGlvblN0b3JhZ2UucHJpbnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3NlcmlhbGl6YWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBQcmludEFubm90YXRpb25TdG9yYWdlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yIHsKICAgICAgICAgICAgICAgICAgICAjYm91bmRGb2N1c2luID0gdGhpcy5mb2N1c2luLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2JvdW5kRm9jdXNvdXQgPSB0aGlzLmZvY3Vzb3V0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2hhc0JlZW5TZWxlY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNpc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAjaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX3VpTWFuYWdlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgI3pJbmRleCA9IEFubm90YXRpb25FZGl0b3IuX3pJbmRleCsrOwogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JNYW5hZ2VyID0gbmV3IF90b29scy5Db2xvck1hbmFnZXIoKTsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgX3pJbmRleCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQW5ub3RhdGlvbkVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQW5ub3RhdGlvbkVkaXRvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmFtZXRlcnMucGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlkID0gcGFyYW1ldGVycy5pZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aWR0aCA9IHRoaXMuaGVpZ2h0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJhbWV0ZXJzLnBhcmVudC5wYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IHBhcmFtZXRlcnMubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIgPSBwYXJhbWV0ZXJzLnVpTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEaW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMucGFyZW50LnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZURpbWVuc2lvbnMgPSBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlVHJhbnNsYXRpb24gPSBbcGFnZVgsIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3dpZHRoLCBoZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSBwYXJhbWV0ZXJzLnggLyB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55ID0gcGFyYW1ldGVycy55IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzQXR0YWNoZWRUb0RPTSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZ2V0IF9kZWZhdWx0TGluZUNvbG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9kZWZhdWx0TGluZUNvbG9yIiwgdGhpcy5fY29sb3JNYW5hZ2VyLmdldEhleENvZGUoIkNhbnZhc1RleHQiKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZENvbW1hbmRzKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkQ29tbWFuZHMocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRMYXllcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3VpTWFuYWdlci5jdXJyZW50TGF5ZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEluQmFja2dyb3VuZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUuekluZGV4ID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0SW5Gb3JlZ3JvdW5kKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS56SW5kZXggPSB0aGlzLiN6SW5kZXg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFBhcmVudChwYXJlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJlbnQucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlRGltZW5zaW9ucyA9IHBhcmVudC5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuI2hhc0JlZW5TZWxlY3RlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNoYXNCZWVuU2VsZWN0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb2N1c291dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkcGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gZXZlbnQucmVsYXRlZFRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAhPT0gbnVsbCAmJiB0YXJnZXQgIT09IHZvaWQgMCAmJiB0YXJnZXQuY2xvc2VzdChgIyR7dGhpcy5pZH1gKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChfdGhpcyRwYXJlbnQgPSB0aGlzLnBhcmVudCkgIT09IG51bGwgJiYgX3RoaXMkcGFyZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkcGFyZW50LmlzTXVsdGlwbGVTZWxlY3Rpb24pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0T3JSZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRyYWdzdGFydChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5wYXJlbnQuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0WCA9IGV2ZW50LmNsaWVudFggLSByZWN0Lng7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRZID0gZXZlbnQuY2xpZW50WSAtIHJlY3QueTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLnNldERhdGEoInRleHQvcGxhaW4iLCB0aGlzLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmVmZmVjdEFsbG93ZWQgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEF0KHgsIHksIHR4LCB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt0eCwgdHldID0gdGhpcy5zY3JlZW5Ub1BhZ2VUcmFuc2xhdGlvbih0eCwgdHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAoeCArIHR4KSAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAoeSArIHR5KSAvIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUubGVmdCA9IGAkezEwMCAqIHRoaXMueH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUudG9wID0gYCR7MTAwICogdGhpcy55fSVgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGUoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IHRoaXMuc2NyZWVuVG9QYWdlVHJhbnNsYXRpb24oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCArPSB4IC8gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSArPSB5IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5sZWZ0ID0gYCR7MTAwICogdGhpcy54fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS50b3AgPSBgJHsxMDAgKiB0aGlzLnl9JWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNjcmVlblRvUGFnZVRyYW5zbGF0aW9uKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnBhcmVudFJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeSwgLXhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteCwgLXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyNzA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteSwgeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCwgeV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFNjYWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJlYWxTY2FsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFJvdGF0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcGFyZW50RGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl91aU1hbmFnZXIudmlld1BhcmFtZXRlcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlV2lkdGgsIHBhZ2VIZWlnaHRdID0gdGhpcy5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtwYWdlV2lkdGggKiByZWFsU2NhbGUsIHBhZ2VIZWlnaHQgKiByZWFsU2NhbGVdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREaW1zKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS53aWR0aCA9IGAkezEwMCAqIHdpZHRoIC8gcGFyZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnN0eWxlLmhlaWdodCA9IGAkezEwMCAqIGhlaWdodCAvIHBhcmVudEhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZml4RGltcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUGVyY2VudCA9IHdpZHRoLmVuZHNXaXRoKCIlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFBlcmNlbnQgPSBoZWlnaHQuZW5kc1dpdGgoIiUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUGVyY2VudCAmJiBoZWlnaHRQZXJjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpZHRoUGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBgJHsxMDAgKiBwYXJzZUZsb2F0KHdpZHRoKSAvIHBhcmVudFdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaGVpZ2h0UGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogcGFyc2VGbG9hdChoZWlnaHQpIC8gcGFyZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImRhdGEtZWRpdG9yLXJvdGF0aW9uIiwgKDM2MCAtIHRoaXMucm90YXRpb24pICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuY2xhc3NOYW1lID0gdGhpcy5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImlkIiwgdGhpcy5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgidGFiSW5kZXgiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFkZEV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt0eCwgdHldID0gdGhpcy5nZXRJbml0aWFsVHJhbnNsYXRpb24oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUodHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF90b29scy5iaW5kRXZlbnRzKSh0aGlzLCB0aGlzLmRpdiwgWyJkcmFnc3RhcnQiLCAicG9pbnRlcmRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNNYWMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF91dGlsLkZlYXR1cmVUZXN0LnBsYXRmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwIHx8IGV2ZW50LmN0cmxLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYgIWlzTWFjIHx8IGV2ZW50LnNoaWZ0S2V5IHx8IGV2ZW50Lm1ldGFLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnRvZ2dsZVNlbGVjdGVkKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaGFzQmVlblNlbGVjdGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVjdCh0eCwgdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IHRoaXMucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlWCwgcGFnZVldID0gdGhpcy5wYWdlVHJhbnNsYXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WCA9IHR4IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WSA9IHR5IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSB0aGlzLnggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLnkgKiBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRYICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRZIC0gaGVpZ2h0ICsgcGFnZVksIHggKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VYLCBwYWdlSGVpZ2h0IC0geSAtIHNoaWZ0WSArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRYICsgcGFnZVksIHggKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCAtIHNoaWZ0WCAtIHdpZHRoICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRZICsgcGFnZVksIHggLSBzaGlmdFggKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3ggLSBzaGlmdFkgLSBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgLSBzaGlmdFggLSB3aWR0aCArIHBhZ2VZLCB4IC0gc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRYICsgcGFnZVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZWN0SW5DdXJyZW50Q29vcmRzKHJlY3QsIHBhZ2VIZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0geDIgLSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0geTIgLSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkyLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkxLCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeDIsIHBhZ2VIZWlnaHQgLSB5MSwgd2lkdGgsIGhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3gyLCBwYWdlSGVpZ2h0IC0geTIsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbmNlQWRkZWQoKSB7fQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzSW5FZGl0TW9kZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzSW5FZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzSW5FZGl0TW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2hvdWxkR2V0S2V5Ym9hcmRFdmVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmVlZHNUb0JlUmVidWlsdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2ICYmICF0aGlzLmlzQXR0YWNoZWRUb0RPTTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGRpdi5hZGRFdmVudExpc3RlbmVyKCJmb2N1c2luIiwgdGhpcy4jYm91bmRGb2N1c2luKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VyaWFsaXplKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBbiBlZGl0b3IgbXVzdCBiZSBzZXJpYWxpemFibGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGRlc2VyaWFsaXplKGRhdGEsIHBhcmVudCwgdWlNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IG5ldyB0aGlzLnByb3RvdHlwZS5jb25zdHJ1Y3Rvcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogcGFyZW50LmdldE5leHRJZCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlNYW5hZ2VyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iucm90YXRpb24gPSBkYXRhLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IGVkaXRvci5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gsIHksIHdpZHRoLCBoZWlnaHRdID0gZWRpdG9yLmdldFJlY3RJbkN1cnJlbnRDb29yZHMoZGF0YS5yZWN0LCBwYWdlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnggPSB4IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IueSA9IHkgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iud2lkdGggPSB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmhlaWdodCA9IGhlaWdodCAvIHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQucmVtb3ZlKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZGl2MiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkaXYyLmNsYXNzTGlzdC5hZGQoInNlbGVjdGVkRWRpdG9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGl2MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdjMgPSB0aGlzLmRpdikgPT09IG51bGwgfHwgX3RoaXMkZGl2MyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2My5jbGFzc0xpc3QucmVtb3ZlKCJzZWxlY3RlZEVkaXRvciIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVQYXJhbXModHlwZSwgdmFsdWUpIHt9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGVuYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7fTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnREaXYoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzRWRpdGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0IGlzRWRpdGluZyh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNpc0VkaXRpbmcgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRTZWxlY3RlZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvciA9IEFubm90YXRpb25FZGl0b3I7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE0MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLktleWJvYXJkTWFuYWdlciA9IGV4cG9ydHMuQ29tbWFuZE1hbmFnZXIgPSBleHBvcnRzLkNvbG9yTWFuYWdlciA9IGV4cG9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jaWQgPSAwOwogICAgICAgICAgICAgICAgICAgIGdldElkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYCR7X3V0aWwuQW5ub3RhdGlvbkVkaXRvclByZWZpeH0ke3RoaXMuI2lkKyt9YDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb21tYW5kTWFuYWdlciB7CiAgICAgICAgICAgICAgICAgICAgI2NvbW1hbmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgI2xvY2tlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICNwb3NpdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF4U2l6ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtYXhTaXplID0gbWF4U2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBOYU4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbyA9IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobXVzdEV4ZWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNsb2NrZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY21kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI3Bvc2l0aW9uID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI2NvbW1hbmRzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jcG9zaXRpb24gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHMucHVzaChzYXZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3ZlcndyaXRlSWZTYW1lVHlwZSAmJiB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0udHlwZSA9PT0gdHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtlZXBVbmRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZS51bmRvID0gdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG87CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0gPSBzYXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5leHQgPSB0aGlzLiNwb3NpdGlvbiArIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09PSB0aGlzLiNtYXhTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5zcGxpY2UoMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNwb3NpdGlvbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzLnNwbGljZShuZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5wdXNoKHNhdmUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jcG9zaXRpb24gPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uIC09IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsb2NrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLmNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jcG9zaXRpb24gIT09IC0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbW1hbmRNYW5hZ2VyID0gQ29tbWFuZE1hbmFnZXI7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgS2V5Ym9hcmRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlciA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcyA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleXMsIGNhbGxiYWNrXSBvZiBjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IG9mIGtleXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hY0tleSA9IGtleS5zdGFydHNXaXRoKCJtYWMrIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTWFjICYmIGlzTWFjS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tzLnNldChrZXkuc2xpY2UoNCksIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzLmFkZChrZXkuc3BsaXQoIisiKS5hdCgtMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTWFjICYmICFpc01hY0tleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcy5zZXQoa2V5LCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxsS2V5cy5hZGQoa2V5LnNwbGl0KCIrIikuYXQoLTEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlYyhzZWxmLCBldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuYWxsS2V5cy5oYXMoZXZlbnQua2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbGxiYWNrID0gdGhpcy5jYWxsYmFja3MuZ2V0KF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZSwgX3NlcmlhbGl6ZTIpLmNhbGwodGhpcywgZXZlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLmJpbmQoc2VsZikoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5LZXlib2FyZE1hbmFnZXIgPSBLZXlib2FyZE1hbmFnZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgiYWx0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVyLnB1c2goImN0cmwiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lm1ldGFLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgibWV0YSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuc2hpZnRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgic2hpZnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaChldmVudC5rZXkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRoaXMuYnVmZmVyLmpvaW4oIisiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvck1hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JzTWFwcGluZyA9IG5ldyBNYXAoW1siQ2FudmFzVGV4dCIsIFswLCAwLCAwXV0sIFsiQ2FudmFzIiwgWzI1NSwgMjU1LCAyNTVdXV0pOwogICAgICAgICAgICAgICAgICAgIGdldCBfY29sb3JzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvcnMgPSBuZXcgTWFwKFtbIkNhbnZhc1RleHQiLCBudWxsXSwgWyJDYW52YXMiLCBudWxsXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q29sb3JWYWx1ZXMpKGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX2NvbG9ycyIsIGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnZlcnQoY29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldFJHQikoY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpbmRvdy5tYXRjaE1lZGlhKCIoZm9yY2VkLWNvbG9yczogYWN0aXZlKSIpLm1hdGNoZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZ2I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbbmFtZSwgUkdCXSBvZiB0aGlzLl9jb2xvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSR0IuZXZlcnkoKHgsIGkpID0+IHggPT09IHJnYltpXSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQ29sb3JNYW5hZ2VyLl9jb2xvcnNNYXBwaW5nLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmdiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRIZXhDb2RlKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gdGhpcy5fY29sb3JzLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZ2IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5yZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQ29sb3JNYW5hZ2VyID0gQ29sb3JNYW5hZ2VyOwogICAgICAgICAgICAgICAgdmFyIF9hY3RpdmVFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYWxsRWRpdG9ycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hbGxMYXllcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYW5ub3RhdGlvblN0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29tbWFuZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudFBhZ2VJbmRleCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JUeXBlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzVG9SZXNjYWxlID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2ZW50QnVzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0VuYWJsZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfbW9kZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RlZEVkaXRvcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDb3B5ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ3V0ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kUGFzdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRLZXlkb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25FZGl0aW5nQWN0aW9uID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25QYWdlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblNjYWxlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcHJldmlvdXNTdGF0ZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGFpbmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEtleWJvYXJkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfYWRkQ29weVBhc3RlTGlzdGVuZXJzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVVJID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuYWJsZUFsbCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlQWxsID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEVkaXRvclRvTGF5ZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfaXNFbXB0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RFZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb250YWluZXIsIGV2ZW50QnVzLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3NlbGVjdEVkaXRvcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzRW1wdHkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEVkaXRvclRvTGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Rpc2FibGVBbGwpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2VuYWJsZUFsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYWRkQ29weVBhc3RlTGlzdGVuZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEtleWJvYXJkTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY3RpdmVFZGl0b3IsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxMYXllcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Fubm90YXRpb25TdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY29tbWFuZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBDb21tYW5kTWFuYWdlcigpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY3VycmVudFBhZ2VJbmRleCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvclR5cGVzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZWRpdG9yc1RvUmVzY2FsZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IFNldCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZXZlbnRCdXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBJZE1hbmFnZXIoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzRW5hYmxlZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgU2V0KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENvcHksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY29weS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDdXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY3V0LmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBhc3RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnBhc3RlLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEtleWRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMua2V5ZG93bi5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRPbkVkaXRpbmdBY3Rpb24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMub25FZGl0aW5nQWN0aW9uLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uUGFnZUNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUGFnZUNoYW5naW5nLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uU2NhbGVDaGFuZ2luZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5vblNjYWxlQ2hhbmdpbmcuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kT25Sb3RhdGlvbkNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUm90YXRpb25DaGFuZ2luZy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcHJldmlvdXNTdGF0ZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbnRhaW5lciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250YWluZXIsIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZXZlbnRCdXMsIGV2ZW50QnVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29uKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInBhZ2VjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblBhZ2VDaGFuZ2luZykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInNjYWxlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25TY2FsZUNoYW5naW5nKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLl9vbigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSwgYW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdQYXJhbWV0ZXJzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlOiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogMAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJwYWdlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25QYWdlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigic2NhbGVjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblNjYWxlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnNUb1Jlc2NhbGUpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25QYWdlQ2hhbmdpbmcoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VOdW1iZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgsIHBhZ2VOdW1iZXIgLSAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNNYWluQ29udGFpbmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRhaW5lcikuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5hZGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yZWFsU2NhbGUgPSBzY2FsZSAqIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2guUERGX1RPX0NTU19VTklUUzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uU2NhbGVDaGFuZ2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uUm90YXRpb25DaGFuZ2luZyhfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNSb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yb3RhdGlvbiA9IHBhZ2VzUm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLmlzRW1wdHkoKSAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Fubm90YXRpb25TdG9yYWdlKSAmJiAhX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSkuaGFzKGVkaXRvci5pZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpLnNldFZhbHVlKGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb3B5KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKS5jb21taXRPclJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNTZWxlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvci5zZXJpYWxpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcnMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuY2xpcGJvYXJkRGF0YS5zZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIsIEpTT04uc3RyaW5naWZ5KGVkaXRvcnMpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3V0KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29weShldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhc3RlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gZXZlbnQuY2xpcGJvYXJkRGF0YS5nZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdEFsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsTGF5ZXJzKS5nZXQoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jdXJyZW50UGFnZUluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdFZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzZXJpYWxpemVkRWRpdG9yID0gbGF5ZXIuZGVzZXJpYWxpemUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRlc2VyaWFsaXplZEVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0VkaXRvcnMucHVzaChkZXNlcmlhbGl6ZWRFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWRkRWRpdG9yVG9MYXllciwgX2FkZEVkaXRvclRvTGF5ZXIyKS5jYWxsKHRoaXMsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlbGVjdEVkaXRvcnMsIF9zZWxlY3RFZGl0b3JzMikuY2FsbCh0aGlzLCBuZXdFZGl0b3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAga2V5ZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2V0QWN0aXZlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgoX3RoaXMkZ2V0QWN0aXZlID0gdGhpcy5nZXRBY3RpdmUoKSkgIT09IG51bGwgJiYgX3RoaXMkZ2V0QWN0aXZlICE9PSB2b2lkIDAgJiYgX3RoaXMkZ2V0QWN0aXZlLnNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25FZGl0aW5nQWN0aW9uKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFsidW5kbyIsICJyZWRvIiwgImRlbGV0ZSIsICJzZWxlY3RBbGwiXS5pbmNsdWRlcyhkZXRhaWxzLm5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2RldGFpbHMubmFtZV0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRFZGl0aW5nU3RhdGUoaXNFZGl0aW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FkZEtleWJvYXJkTWFuYWdlciwgX2FkZEtleWJvYXJkTWFuYWdlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRWRpdGluZzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSAhPT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1VuZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmhhc1NvbWV0aGluZ1RvUmVkbygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZWdpc3RlckVkaXRvclR5cGVzKHR5cGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvclR5cGVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZWRpdG9yVHlwZXMsIHR5cGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3JUeXBlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yVHlwZS5kZWZhdWx0UHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaWRNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY3VycmVudExheWVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLmdldChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRQYWdlSW5kZXgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuc2V0KGxheWVyLnBhZ2VJbmRleCwgbGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRpc2FibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmVMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZGVsZXRlKGxheWVyLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZU1vZGUobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGUsIG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzYWJsZUFsbCwgX2Rpc2FibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9lbmFibGVBbGwsIF9lbmFibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci51cGRhdGVNb2RlKG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVRvb2xiYXIobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJzd2l0Y2hhbm5vdGF0aW9uZWRpdG9ybW9kZSIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhcmFtcyh0eXBlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvclR5cGUgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JUeXBlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvclR5cGUudXBkYXRlRGVmYXVsdFBhcmFtcyh0eXBlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RWRpdG9ycyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9ycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbEVkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLnBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVkaXRvcnM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEVkaXRvcihpZCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5nZXQoaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykuc2V0KGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5kZWxldGUoZWRpdG9yLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQyLnJlbW92ZShlZGl0b3IuaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBY3RpdmVFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikgPT09IGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yLnByb3BlcnRpZXNUb1VwZGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9nZ2xlU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuaGFzKGVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlVUksIF9kaXNwYXRjaFVwZGF0ZVVJMikuY2FsbCh0aGlzLCBlZGl0b3IucHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFNlbGVjdGVkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkICE9PSBlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZC51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZWxlY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSwgX2Rpc3BhdGNoVXBkYXRlVUkyKS5jYWxsKHRoaXMsIGVkaXRvci5wcm9wZXJ0aWVzVG9VcGRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5oYXMoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdW5zZWxlY3QoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuZGVsZXRlKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhhc1NlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5zaXplICE9PSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS51bmRvKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NvbWV0aGluZ1RvVW5kbzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb21tYW5kTWFuYWdlcikuaGFzU29tZXRoaW5nVG9VbmRvKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLnJlZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9SZWRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1JlZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzRW1wdHksIF9pc0VtcHR5MikuY2FsbCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWFuZHMocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmFkZChwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1VuZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eTogX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfaXNFbXB0eSwgX2lzRW1wdHkyKS5jYWxsKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZWxldGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvcnMgPSBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIGVkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRFZGl0b3JUb0xheWVyLCBfYWRkRWRpdG9yVG9MYXllcjIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdE9yUmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZWxlY3RFZGl0b3JzLCBfc2VsZWN0RWRpdG9yczIpLmNhbGwodGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS52YWx1ZXMoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLnNpemUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpID09PSBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFjdGl2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyID0gQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlcjsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5yZW1vdmVFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKCkgewogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNvcHkiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ29weSkpOwogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImN1dCIsIF9jbGFz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AgIGlmIChoYXNDaGFuZ2VkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJhbm5vdGF0aW9uZWRpdG9yc3RhdGVzY2hhbmdlZCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHM6IE9iamVjdC5hc3NpZ24oX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wcmV2aW91c1N0YXRlcyksIGRldGFpbHMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kaXNwYXRjaFVwZGF0ZVVJMihkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuZGlzcGF0Y2goImFubm90YXRpb25lZGl0b3JwYXJhbXNjaGFuZ2VkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHMKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmFibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmVuYWJsZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Rpc2FibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIHRoaXMudW5zZWxlY3RBbGwoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGF5ZXIgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5kaXNhYmxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfYWRkRWRpdG9yVG9MYXllcjIoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZ2V0KGVkaXRvci5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBsYXllci5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9pc0VtcHR5MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3IuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RFZGl0b3JzMihlZGl0b3JzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLm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mFuc2Zvcm07CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlID0gZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2U7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldEZpbGVuYW1lRnJvbVVybCA9IGdldEZpbGVuYW1lRnJvbVVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0UGRmRmlsZW5hbWVGcm9tVXJsID0gZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5nZXRSR0IgPSBnZXRSR0I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFhmYVBhZ2VWaWV3cG9ydCA9IGdldFhmYVBhZ2VWaWV3cG9ydDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNEYXRhU2NoZW1lID0gaXNEYXRhU2NoZW1lOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc1BkZkZpbGUgPSBpc1BkZkZpbGU7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzVmFsaWRGZXRjaFVybCA9IGlzVmFsaWRGZXRjaFVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMubG9hZFNjcmlwdCA9IGxvYWRTY3JpcHQ7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldExheWVyRGltZW5zaW9ucyA9IHNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNld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5IHByaXZhdGUgZmllbGQiKTsgfSBkZXNjcmlwdG9yLnZhbHVlID0gdmFsdWU7IH0gfQogICAgICAgICAgICAgICAgY29uc3QgU1ZHX05TID0gImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIjsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25QcmVmaXggPSAicGRmanNfaW50ZXJuYWxfaWRfIjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblByZWZpeCA9IEFubm90YXRpb25QcmVmaXg7CiAgICAgICAgICAgICAgICBjbGFzcyBQaXhlbHNQZXJJbmNoIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgQ1NTID0gOTYuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGID0gNzIuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGX1RPX0NTU19VTklUUyA9IHRoaXMuQ1NTIC8gdGhpcy5QREY7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBpeGVsc1BlckluY2ggPSBQaXhlbHNQZXJJbmNoOwogICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY0lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hjbUZpbHRlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oY21LZXkgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfaGNtVXJsID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hcHBlbmRGZUZ1bmMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIERPTUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudCA9IGdsb2JhbFRoaXMuZG9jdW1lbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYXBwZW5kRmVGdW5jKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2RlZnMyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfZGVmcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGUyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kZWZzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kb2NJZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZG9jdW1lbnQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hjbUZpbHRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGNtS2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9oY21VcmwsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RvY0lkLCBkb2NJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZG9jdW1lbnQsIG93bmVyRG9jdW1lbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRGaWx0ZXIobWFwcykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkaWQsIF90aGlzJGlkMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQobWFwcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWJsZVIsIHRhYmxlRywgdGFibGVCLCBrZXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXBzLmxlbmd0aCA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwUiA9IG1hcHNbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbaV0gPSBtYXBSW2ldIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0gdGFibGVSID0gdGFibGVHID0gdGFibGVCID0gYnVmZmVyLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFttYXBSLCBtYXBHLCBtYXBCXSA9IG1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJSID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJHID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJCID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyUltpXSA9IG1hcFJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyR1tpXSA9IG1hcEdbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyQltpXSA9IG1hcEJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWJsZVIgPSBidWZmZXJSLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhYmxlRyA9IGJ1ZmZlckcuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVCID0gYnVmZmVyQi5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgPSBgJHt0YWJsZVJ9JHt0YWJsZUd9JHt0YWJsZUJ9YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBnXyR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2NJZCl9X3RyYW5zZmVyX21hcF8keyhfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lkLCAoX3RoaXMkaWQgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2lkKSwgX3RoaXMkaWQyID0gX3RoaXMkaWQrKywgX3RoaXMkaWQpKSwgX3RoaXMkaWQyKX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKCMke2lkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5zZXQoa2V5LCB1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWx0ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLnNldEF0dHJpYnV0ZSgiaWQiLCBpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycyIsICJzUkdCIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29tcG9uZW50VHJhbnNmZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb21wb25lbnRUcmFuc2ZlciIpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYXBwZW5kKGZlQ29tcG9uZW50VHJhbnNmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgdGFibGVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYXBwZW5kRmVGdW5jLCBfYXBwZW5kRmVGdW5jMikuY2FsbCh0aGlzLCBmZUNvbXBvbmVudFRyYW5zZmVyLCAiZmVGdW5jRyIsIHRhYmxlRyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZUIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkSENNRmlsdGVyKGZnQ29sb3IsIGJnQ29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGAke2ZnQ29sb3J9LSR7YmdDb2xvcn1gOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21LZXkpID09PSBrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hjbVVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21LZXksIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtVXJsLCAibm9uZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtRmlsdGVyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0Mi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmZ0NvbG9yIHx8ICFiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpLnN0eWxlLmNvbG9yID0gZmdDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgZmdDb2xvciA9IGdldENvbXB1dGVkU3R5bGUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikpLmdldFByb3BlcnR5VmFsdWUoImNvbG9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZnUkdCID0gZ2V0UkdCKGZnQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZmdSR0IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5zdHlsZS5jb2xvciA9IGJnQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGJnQ29sb3IgPSBnZXRDb21wdXRlZFN0eWxlKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpKS5nZXRQcm9wZXJ0eVZhbHVlKCJjb2xvciIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZ1JHQiA9IGdldFJHQihiZ0NvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmJnUkdCKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikuc3R5bGUuY29sb3IgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZnQ29sb3IgPT09ICIjMDAwMDAwIiAmJiBiZ0NvbG9yID09PSAiI2ZmZmZmZiIgfHwgZmdDb2xvciA9PT0gYmdDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPD0gMjU1OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBpIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwW2ldID0geCA8PSAwLjAzOTI4ID8geCAvIDEyLjkyIDogKCh4ICsgMC4wNTUpIC8gMS4wNTUpICoqIDIuNDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IG1hcC5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gYGdfJHtfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY0lkKX1faGNtX2ZpbHRlcmA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlciA9IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtRmlsdGVyLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuc2V0QXR0cmlidXRlKCJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnMiLCAic1JHQiIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZl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GZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFN0ZXBzID0gKGMsIG4pID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gZmdSR0JbY10gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBiZ1JHQltjXSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBBcnJheShuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbaV0gPSBzdGFydCArIGkgLyBuICogKGVuZCAtIHN0YXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgZ2V0U3RlcHMoMCwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNHIiwgZ2V0U3RlcHMoMSwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNCIiwgZ2V0U3RlcHMoMiwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21VcmwsIGB1cmwoIyR7aWR9KWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQga2VlcEhDTSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZWVwSENNICYmIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpLnBhcmVudE5vZGUucGFyZW50Tm9kZS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVmcywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jYWNoZSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pZCwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01GaWx0ZXJGYWN0b3J5ID0gRE9NRmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9nZXRfY2FjaGUoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpIHx8IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2FjaGUsIG5ldyBNYXAoKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0X2RlZnMoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbnRhaW4gPSAic3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZS5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLnRvcCA9IHN0eWxlLmxlZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS56SW5kZXggPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgInN2ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kZWZzLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZGVmcyIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmcykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5ib2R5LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hcHBlbmRGZUZ1bmMyKGZlQ29tcG9uZW50VHJhbnNmZXIsIGZ1bmMsIHRhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmVGdW5jID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgZnVuYyk7CiAgICAgICAgICAgICAgICAgICAgZmVGdW5jLnNldEF0dHJpYnV0ZSgidHlwZSIsICJkaXNjcmV0ZSIpOwogICAgICAgICAgICAgICAgICAgIGZlRnVuYy5zZXRBdHRyaWJ1dGUoInRhYmxlVmFsdWVzIiwgdGFibGUpOwogICAgICAgICAgICAgICAgICAgIGZlQ29tcG9uZW50VHJhbnNmZXIuYXBwZW5kKGZlRnVuYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DYW52YXNGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50ID0gZ2xvYmFsVGhpcy5kb2N1bWVudAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlQ2FudmFzKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRE9NQ2FudmFzRmFjdG9yeSA9IERPTUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBmZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFzVHlwZWRBcnJheSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzVmFsaWRGZXRjaFVybCh1cmwsIGRvY3VtZW50LmJhc2VVUkkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKHJlc3BvbnNlLnN0YXR1c1RleHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhc1R5cGVkQXJyYXkgPyBuZXcgVWludDhBcnJheShhd2FpdCByZXNwb25zZS5hcnJheUJ1ZmZlcigpKSA6ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShhd2FpdCByZXNwb25zZS50ZXh0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub3BlbigiR0VUIiwgdXJsLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC5yZXNwb25zZVR5cGUgPSAiYXJyYXlidWZmZXIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub25yZWFkeXN0YXRlY2hhbmdlID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVlc3QucmVhZHlTdGF0ZSAhPT0gWE1MSHR0cFJlcXVlc3QuRE9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LnN0YXR1cyA9PT0gMjAwIHx8IHJlcXVlc3Quc3RhdHVzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSAmJiByZXF1ZXN0LnJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBuZXcgVWludDhBcnJheShyZXF1ZXN0LnJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFhc1R5cGVkQXJyYXkgJiYgcmVxdWVzdC5yZXNwb25zZVRleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShyZXF1ZXN0LnJlc3BvbnNlVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKHJlcXVlc3Quc3RhdHVzVGV4dCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DTWFwUmVhZGVyRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNNYXBSZWFkZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCwgY29tcHJlc3Npb25UeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaERhdGEodXJsLCB0aGlzLmlzQ29tcHJlc3NlZCkudGhlbihkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY01hcERhdGE6IGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcHJlc3Npb25UeXBlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkRPTUNNYXBSZWFkZXJGYWN0b3J5ID0gRE9NQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2hEYXRhKHVybCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERPTVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgRE9NU1ZHRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVTVkcodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TVkdGYWN0b3J5ID0gRE9NU1ZHRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIFBhZ2VWaWV3cG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3Qm94ID0gdmlld0JveDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZSA9IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WCA9IG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WSA9IG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNlbnRlclggPSAodmlld0JveFsyXSArIHZpZXdCb3hbMF0pIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2VudGVyWSA9ICh2aWV3Qm94WzNdICsgdmlld0JveFsxXSkgLyAyOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcm90YXRlQSwgcm90YXRlQiwgcm90YXRlQywgcm90YXRlRDsKICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24gJT0gMzYwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRpb24gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiArPSAzNjA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyb3RhdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVBID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVCID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjcwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUEgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBhZ2VWaWV3cG9ydDogSW52YWxpZCByb3RhdGlvbiwgbXVzdCBiZSBhIG11bHRpcGxlIG9mIDkwIGRlZ3JlZXMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbnRGbGlwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLXJvdGF0ZUM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gLXJvdGF0ZUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldENhbnZhc1gsIG9mZnNldENhbnZhc1k7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCwgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRlQSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Q2FudmFzWCA9IE1hdGguYWJzKGNlbnRlclkgLSB2aWV3Qm94WzFdKSAqIHNjYWxlICsgb2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1kgPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9ICh2aWV3Qm94WzNdIC0gdmlld0JveFsxXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9ICh2aWV3Qm94WzJdIC0gdmlld0JveFswXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1ggPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRDYW52YXNZID0gTWF0aC5hYnMoY2VudGVyWSAtIHZpZXdCb3hbMV0pICogc2NhbGUgKyBvZmZzZXRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSAodmlld0JveFsyXSAtIHZpZXdCb3hbMF0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQgPSAodmlld0JveFszXSAtIHZpZXdCb3hbMV0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0gPSBbcm90YXRlQSAqIHNjYWxlLCByb3RhdGVCICogc2NhbGUsIHJvdGF0ZUMgKiBzY2FsZSwgcm90YXRlRCAqIHNjYWxlLCBvZmZzZXRDYW52YXNYIC0gcm90YXRlQSAqIHNjYWxlICogY2VudGVyWCAtIHJvdGF0ZUMgKiBzY2FsZSAqIGNlbnRlclksIG9mZnNldENhbnZhc1kgLSByb3RhdGVCICogc2NhbGUgKiBjZW50ZXJYIC0gcm90YXRlRCAqIHNjYWxlICogY2VudGVyWV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCByYXdEaW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3Qm94CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInJhd0RpbXMiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGg6IHZpZXdCb3hbMl0gLSB2aWV3Qm94WzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodDogdmlld0JveFszXSAtIHZpZXdCb3hbMV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWDogdmlld0JveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZOiB2aWV3Qm94WzFdCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gdGhpcy5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFggPSB0aGlzLm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZID0gdGhpcy5vZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3Qm94LnNsaWNlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb250RmxpcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvVmlld3BvcnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt4LCB5XSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb252ZXJ0VG9WaWV3cG9ydFJlY3RhbmdsZShyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvcExlZnQgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFtyZWN0WzBdLCByZWN0WzFdXSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3R0b21SaWdodCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JlY3RbMl0sIHJlY3RbM11dLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbdG9wTGVmdFswXSwgdG9wTGVmdFsxXSwgYm90dG9tUmlnaHRbMF0sIGJvdHRvbVJpZ2h0WzFdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvUGRmUG9pbnQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbC5hcHBseUludmVyc2VUcmFuc2Zvcm0oW3gsIHldLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlVmlld3BvcnQgPSBQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24gZXh0ZW5kcyBfdXRpbC5CYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlJlbmRlcmluZ0NhbmNlbGxlZEV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnR5cGUgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmV4dHJhRGVsYXkgPSBleHRyYURlbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uID0gUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNEYXRhU2NoZW1lKHVybCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlpID0gdXJsLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGkgPCBpaSAmJiB1cmxbaV0udHJpbSgpID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwuc3Vic3RyaW5nKGksIGkgKyA1KS50b0xvd2VyQ2FzZSgpID09PSAiZGF0YToiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNQZGZGaWxlKGZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBmaWxlbmFtZSA9PT0gInN0cmluZyIgJiYgL1wucGRmJC9pLnRlc3QoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RmlsZW5hbWVGcm9tVXJsKHVybCkgewogICAgICAgICAgICAgICAgICAgIGxldCBvbmx5U3RyaXBQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9ubHlTdHJpcFBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgW3VybF0gPSB1cmwuc3BsaXQoL1sjP10vLCAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybC5zdWJzdHJpbmcodXJsLmxhc3RJbmRleE9mKCIvIikgKyAxKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFBkZkZpbGVuYW1lRnJvbVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVmYXVsdEZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAiZG9jdW1lbnQucGRmIjsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHVybCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzRGF0YVNjaGVtZSh1cmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgnZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOiBpZ25vcmUgImRhdGE6Ii1VUkwgZm9yIHBlcmZvcm1hbmNlIHJlYXNvbnMuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZhdWx0RmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlVVJJID0gL14oPzooPzpbXjpdKzopP1wvXC9bXi9dKyk/KFtePyNdKikoXD9bXiNdKik/KCMuKik/JC87CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVGaWxlbmFtZSA9IC9bXi8/Iz1dK1wucGRmXGIoPyEuKlwucGRmXGIpL2k7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BsaXRVUkkgPSByZVVSSS5leGVjKHVybCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKHNwbGl0VVJJWzFdKSB8fCByZUZpbGVuYW1lLmV4ZWMoc3BsaXRVUklbMl0pIHx8IHJlRmlsZW5hbWUuZXhlYyhzcGxpdFVSSVszXSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1Z2dlc3RlZEZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gc3VnZ2VzdGVkRmlsZW5hbWVbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdWdnZXN0ZWRGaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKGRlY29kZVVSSUNvbXBvbmVudChzdWdnZXN0ZWRGaWxlbmFtZSkpWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN1Z2dlc3RlZEZpbGVuYW1lIHx8IGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXRUaW1lciB7CiAgICAgICAgICAgICAgICAgICAgc3RhcnRlZCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgdGltZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB0aW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgaW4gdGhpcy5zdGFydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFRpbWVyIGlzIGFscmVhZHkgcnVubmluZyBmb3IgJHtuYW1lfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRlZFtuYW1lXSA9IERhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRpbWVFbmQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShuYW1lIGluIHRoaXMuc3RhcnRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVGltZXIgaGFzIG5vdCBiZWVuIHN0YXJ0ZWQgZm9yICR7bmFtZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbWVzLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiB0aGlzLnN0YXJ0ZWRbbmFtZV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ6IERhdGUubm93KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnN0YXJ0ZWRbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdXRCdWYgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxvbmdlc3QgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUKICAgICAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLnRpbWVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nZXN0ID0gTWF0aC5tYXgobmFtZS5sZW5ndGgsIGxvbmdlc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgdGhpcy50aW1lcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0QnVmLnB1c2goYCR7bmFtZS5wYWRFbmQobG9uZ2VzdCl9ICR7ZW5kIC0gc3RhcnR9bXNcbmApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5TdGF0VGltZXIgPSBTdGF0VGltZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBpc1ZhbGlkRmV0Y2hVcmwodXJsLCBiYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2wKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGJhc2VVcmwgPyBuZXcgVVJMKHVybCwgYmFzZVVybCkgOiBuZXcgVVJMKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm90b2NvbCA9PT0gImh0dHA6IiB8fCBwcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGxvYWRTY3JpcHQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHJlbW92ZVNjcmlwdEVsZW1lbnQgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmlwdCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQuc3JjID0gc3JjOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQub25sb2FkID0gZnVuY3Rpb24gKGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbW92ZVNjcmlwdEVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGV2dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHNjcmlwdC5vbmVycm9yID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihgQ2Fubm90IGxvYWQgc2NyaXB0IGF0OiAke3NjcmlwdC5zcmN9YCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAoZG9jdW1lbnQuaGVhZCB8fCBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpLmFwcGVuZChzY3JpcHQpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZGVwcmVjYXRlZChkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkRlcHJlY2F0ZWQgQVBJIHVzYWdlOiAiICsgZGV0YWlscyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgcGRmRGF0ZVN0cmluZ1JlZ2V4OwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0ZVN0cmluZyB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHRvRGF0ZU9iamVjdChpbnB1dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0IHx8IHR5cGVvZiBpbnB1dCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcGRmRGF0ZVN0cmluZ1JlZ2V4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZEYXRlU3RyaW5nUmVnZXggPSBuZXcgUmVnRXhwKCJeRDoiICsgIihcXGR7NH0pIiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFxcZHsyfSk/IiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFtafCt8LV0pPyIgKyAiKFxcZHsyfSk/IiArICInPyIgKyAiKFxcZHsyfSk/IiArICInPyIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBwZGZEYXRlU3RyaW5nUmVnZXguZXhlYyhpbnB1dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbWF0Y2hlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWVhciA9IHBhcnNlSW50KG1hdGNoZXNbMV0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1vbnRoID0gcGFyc2VJbnQobWF0Y2hlc1syXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBtb250aCA9IG1vbnRoID49IDEgJiYgbW9udGggPD0gMTIgPyBtb250aCAtIDEgOiAwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF5ID0gcGFyc2VJbnQobWF0Y2hlc1szXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBkYXkgPSBkYXkgPj0gMSAmJiBkYXkgPD0gMzEgPyBkYXkgOiAxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaG91ciA9IHBhcnNlSW50KG1hdGNoZXNbNF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgaG91ciA9IGhvdXIgPj0gMCAmJiBob3VyIDw9IDIzID8gaG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzVdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbnV0ZSA9IG1pbnV0ZSA+PSAwICYmIG1pbnV0ZSA8PSA1OSA/IG1pbnV0ZSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWNvbmQgPSBwYXJzZUludChtYXRjaGVzWzZdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNlY29uZCA9IHNlY29uZCA+PSAwICYmIHNlY29uZCA8PSA1OSA/IHNlY29uZCA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9IG1hdGNoZXNbN10gfHwgIloiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0SG91ciA9IHBhcnNlSW50KG1hdGNoZXNbOF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0SG91ciA9IG9mZnNldEhvdXIgPj0gMCAmJiBvZmZzZXRIb3VyIDw9IDIzID8gb2Zmc2V0SG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvZmZzZXRNaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzldLCAxMCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TWludXRlID0gb2Zmc2V0TWludXRlID49IDAgJiYgb2Zmc2V0TWludXRlIDw9IDU5ID8gb2Zmc2V0TWludXRlIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIi0iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyICs9IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgKz0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIisiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyIC09IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgLT0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRGF0ZShEYXRlLlVUQyh5ZWFyLCBtb250aCwgZGF5LCBob3VyLCBtaW51dGUsIHNlY29uZCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRGF0ZVN0cmluZyA9IFBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRYZmFQYWdlVmlld3BvcnQoeGZhUGFnZSwgX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gMAogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0geGZhUGFnZS5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXdCb3ggPSBbMCwgMCwgcGFyc2VJbnQod2lkdGgpLCBwYXJzZUludChoZWlnaHQpXTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBhZ2VWaWV3cG9ydCh7CiAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdCb3gsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbgogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0UkdCKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoIiMiKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvclJHQiA9IHBhcnNlSW50KGNvbG9yLnNsaWNlKDEpLCAxNik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbKGNvbG9yUkdCICYgMHhmZjAwMDApID4+IDE2LCAoY29sb3JSR0IgJiAweDAwZmYwMCkgPj4gOCwgY29sb3JSR0IgJiAweDAwMDBmZl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb2xvci5zdGFydHNXaXRoKCJyZ2IoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDQsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoInJnYmEoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDUsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKS5zbGljZSgwLCAzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBOb3QgYSB2YWxpZCBjb2xvciBmb3JtYXQ6ICIke2NvbG9yfSJgKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzAsIDAsIDBdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0Q29sb3JWYWx1ZXMoY29sb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZChzcGFuKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgY29sb3JzLmtleXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLmNvbG9yID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHV0ZWRDb2xvciA9IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKHNwYW4pLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb2xvcnMuc2V0KG5hbWUsIGdldFJHQihjb21wdXRlZENvbG9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNwYW4ucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRDdXJyZW50VHJhbnNmb3JtKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCkuaW52ZXJ0U2VsZigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzZXRMYXllckRpbWVuc2lvbnMoZGl2LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgIGxldCBtdXN0RmxpcCA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgbGV0IG11c3RSb3RhdGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpZXdwb3J0IGluc3RhbmNlb2YgUGFnZVZpZXdwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoU3RyID0gYGNhbGModmFyKC0tc2NhbGUtZmFjdG9yKSAqICR7cGFnZVdpZHRofXB4KWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFN0ciA9IGBjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikgKiAke3BhZ2VIZWlnaHR9cHgpYDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtdXN0RmxpcCB8fCB2aWV3cG9ydC5yb3RhdGlvbiAlIDE4MCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSB3aWR0aFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmhlaWdodCA9IGhlaWdodFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLndpZHRoID0gaGVpZ2h0U3RyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gd2lkdGhTdHI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSb3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnNldEF0dHJpYnV0ZSgiZGF0YS1tYWluLXJvdGF0aW9uIiwgdmlld3BvcnQucm90YXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQzICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IGV4cG9ydHMuQmFzZUZpbHRlckZhY3RvcnkgPSBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gZXhwb3J0cy5CYXNlQ01hcFJlYWRlckZhY3RvcnkgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZUZpbHRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZUZpbHRlckZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VGaWx0ZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEZpbHRlcihtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEhDTUZpbHRlcihmZ0NvbG9yLCBiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwSENNID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VGaWx0ZXJGYWN0b3J5ID0gQmFzZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbnN0cnVjdG9yID09PSBCYXNlQ2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNhbnZhc0ZhY3RvcnkuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoIDw9IDAgfHwgaGVpZ2h0IDw9IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBjYW52YXMgc2l6ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IHRoaXMuX2NyZWF0ZUNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc2V0KGNhbnZhc0FuZENvbnRleHQsIHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYW52YXNBbmRDb250ZXh0LmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW52YXMgaXMgbm90IHNwZWNpZmllZCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgY2FudmFzIHNpemUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koY2FudmFzQW5kQ29udGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhbnZhc0FuZENvbnRleHQuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbnZhcyBpcyBub3Qgc3BlY2lmaWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQW5kQ29udGV4dC5jYW52YXMud2lkdGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0FuZENvbnRleHQuY29udGV4dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9jcmVhdGVDYW52YXNgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gQmFzZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VDTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNNYXBSZWFkZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNDb21wcmVzc2VkID0gaXNDb21wcmVzc2VkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBmZXRjaChfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBDTWFwICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJjTWFwVXJsIiBhbmQgImNNYXBQYWNrZWQiIEFQSSBwYXJhbWV0ZXJzIGFyZSBwcm92aWRlZC4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ01hcCBuYW1lIG11c3QgYmUgc3BlY2lmaWVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVybCA9IHRoaXMuYmFzZVVybCArIG5hbWUgKyAodGhpcy5pc0NvbXByZXNzZWQgPyAiLmJjbWFwIiA6ICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHJlc3Npb25UeXBlID0gdGhpcy5pc0NvbXByZXNzZWQgPyBfdXRpbC5DTWFwQ29tcHJlc3Npb25UeXBlLkJJTkFSWSA6IF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGUuTk9ORTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgJHt0aGlzLmlzQ29tcHJlc3NlZCA/ICJiaW5hcnkgIiA6ICIifUNNYXAgYXQ6ICR7dXJsfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9mZXRjaERhdGFgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDTWFwUmVhZGVyRmFjdG9yeSA9IEJhc2VDTWFwUmVhZGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZjMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGZldGNoKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBzdGFuZGFyZCBmb250ICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJzdGFuZGFyZEZvbnREYXRhVXJsIiBBUEkgcGFyYW1ldGVyIGlzIHByb3ZpZGVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlsZW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiRm9udCBmaWxlbmFtZSBtdXN0IGJlIHNwZWNpZmllZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgJHt0aGlzLmJhc2VVcmx9JHtmaWxlbmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmV0Y2hEYXRhKHVybCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgZm9udCBkYXRhIGF0OiAke3VybH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgX2ZldGNoRGF0YWAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZVNWR0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VTVkdGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZSh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2lwRGltZW5zaW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgU1ZHIGRpbWVuc2lvbnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLl9jcmVhdGVTVkcoInN2ZzpzdmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgidmVyc2lvbiIsICIxLjEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFza2lwRGltZW5zaW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgid2lkdGgiLCBgJHt3aWR0aH1weGApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgiaGVpZ2h0IiwgYCR7aGVpZ2h0fXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgicHJlc2VydmVBc3BlY3RSYXRpbyIsICJub25lIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5zZXRBdHRyaWJ1dGUoInZpZXdCb3giLCBgMCAwICR7d2lkdGh9ICR7aGVpZ2h0fWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3ZnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjcmVhdGVFbGVtZW50KHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0eXBlICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFNWRyBlbGVtZW50IHR5cGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY3JlYXRlU1ZHKHR5cGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlU1ZHKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQWJzdHJhY3QgbWV0aG9kIGBfY3JlYXRlU1ZHYCBjYWxsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IEJhc2VTVkdGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NdXJtdXJIYXNoM182NCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBTRUVEID0gMHhjM2QyZTFmMDsKICAgICAgICAgICAgICAgIGNvbnN0IE1BU0tfSElHSCA9IDB4ZmZmZjAwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVNLX0xPVyA9IDB4ZmZmZjsKICAgICAgICAgICAgICAgIGNsYXNzIE11cm11ckhhc2gzXzY0IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzZWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDEgPSBzZWVkID8gc2VlZCAmIDB4ZmZmZmZmZmYgOiBTRUVEOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgyID0gc2VlZCA/IHNlZWQgJiAweGZmZmZmZmZmIDogU0VFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlKGlucHV0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhLCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaW5wdXQgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gbmV3IFVpbnQ4QXJyYXkoaW5wdXQubGVuZ3RoICogMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gaW5wdXQubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBpbnB1dC5jaGFyQ29kZUF0KGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb2RlIDw9IDB4ZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbbGVuZ3RoKytdID0gY29kZSA+Pj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKGlucHV0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IGlucHV0LnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSBkYXRhLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIldyb25nIGRhdGEgZm9ybWF0IGluIE11cm11ckhhc2gzXzY0X3VwZGF0ZS4gIiArICJJbnB1dCBtdXN0IGJlIGEgc3RyaW5nIG9yIGFycmF5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrQ291bnRzID0gbGVuZ3RoID4+IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhaWxMZW5ndGggPSBsZW5ndGggLSBibG9ja0NvdW50cyAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGFVaW50MzIgPSBuZXcgVWludDMyQXJyYXkoZGF0YS5idWZmZXIsIDAsIGJsb2NrQ291bnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGsxID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGgxID0gdGhpcy5oMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gdGhpcy5oMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQzEgPSAweGNjOWUyZDUxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzIgPSAweDFiODczNTkzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDMV9MT1cgPSBDMSAmIE1BU0tfTE9XLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJfTE9XID0gQzIgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBibG9ja0NvdW50czsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSAmIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGRhdGFVaW50MzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMxICYgTUFTS19ISUdIIHwgazEgKiBDMV9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxIDw8IDE1IHwgazEgPj4+IDE3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgKiBDMiAmIE1BU0tfSElHSCB8IGsxICogQzJfTE9XICYgTUFTS19MT1c7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgXj0gazE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSA8PCAxMyB8IGgxID4+PiAxOTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMSA9IGgxICogNSArIDB4ZTY1NDZiNjQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiBePSBrMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBrMSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodGFpbExlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0ICsgMl0gPDwgMTY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDQgKyAxXSA8PCA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxICogQzEgJiBNQVNLX0hJR0ggfCBrMSAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgPDwgMTUgfCBrMSA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMyICYgTUFTS19ISUdIIHwgazEgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmxvY2tDb3VudHMgJiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgxIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgxID0gaDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDIgPSBoMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGV4ZGlnZXN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaDEgPSB0aGlzLmgxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaDIgPSB0aGlzLmgyOwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4ZWQ1NThjY2QgJiBNQVNLX0hJR0ggfCBoMSAqIDB4OGNjZCAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhmZjUxYWZkNyAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhhZmQ3ZWQ1NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4MWE4NWVjNTMgJiBNQVNLX0hJR0ggfCBoMSAqIDB4ZWM1MyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhjNGNlYjlmZSAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhiOWZlMWE4NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChoMSA+Pj4gMCkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDgsICIwIikgKyAoaDIgPj4+IDApLnRvU3RyaW5nKDE2KS5wYWRTdGFydCg4LCAiMCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTXVybXVySGFzaDNfNjQgPSBNdXJtdXJIYXNoM182NDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGNsYXNzIEZvbnRMb2FkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG93bmVyRG9jdW1lbnQgPSBnbG9iYWxUaGlzLmRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVFbGVtZW50ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZGluZ1JlcXVlc3RzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZFRlc3RGb250SWQgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5wdXNoKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuYWRkKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaW5zZXJ0UnVsZShydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50ID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3R5bGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmRvY3VtZW50RWxlbWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpWzBdLmFwcGVuZCh0aGlzLnN0eWxlRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGVTaGVldCA9IHRoaXMuc3R5bGVFbGVtZW50LnNoZWV0OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZVNoZWV0Lmluc2VydFJ1bGUocnVsZSwgc3R5bGVTaGVldC5jc3NSdWxlcy5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbGVhcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBuYXRpdmVGb250RmFjZSBvZiB0aGlzLm5hdGl2ZUZvbnRGYWNlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuZGVsZXRlKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50LnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHlsZUVsZW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGJpbmQoZm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5hdHRhY2hlZCB8fCBmb250Lm1pc3NpbmdGaWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5hdHRhY2hlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRm9udExvYWRpbmdBUElTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hdGl2ZUZvbnRGYWNlID0gZm9udC5jcmVhdGVOYXRpdmVGb250RmFjZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgbmF0aXZlRm9udEZhY2UubG9hZGVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRmFpbGVkIHRvIGxvYWQgZm9udCAnJHtuYXRpdmVGb250RmFjZS5mYW1pbHl9JzogJyR7ZXh9Jy5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5kaXNhYmxlRm9udEZhY2UgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGZvbnQuY3JlYXRlRm9udEZhY2VSdWxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmluc2VydFJ1bGUocnVsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3QgPSB0aGlzLl9xdWV1ZUxvYWRpbmdDYWxsYmFjayhyZXNvbHZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2RvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNGb250cyA9ICEhKChfdGhpcyRfZG9jdW1lbnQgPSB0aGlzLl9kb2N1bWVudCkgIT09IG51bGwgJiYgX3RoaXMkX2RvY3VtZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkX2RvY3VtZW50LmZvbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkIiwgaGFzRm9udHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTeW5jRm9udExvYWRpbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdXBwb3J0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBuYXZpZ2F0b3IgIT09ICJ1bmRlZmluZWQiICYmIC9Nb3ppbGxhXC81LjAuKj9ydjpcZCsuKj8gR2Vja28vLnRlc3QobmF2aWdhdG9yLnVzZXJBZ2VudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCIsIHN1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9xdWV1ZUxvYWRpbmdDYWxsYmFjayhjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wbGV0ZVJlcXVlc3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghcmVxdWVzdC5kb25lLCAiY29tcGxldGVSZXF1ZXN0KCkgY2Fubm90IGJlIGNhbGxlZCB0d2ljZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobG9hZGluZ1JlcXVlc3RzLmxlbmd0aCA+IDAgJiYgbG9hZGluZ1JlcXVlc3RzWzBdLmRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdGhlclJlcXVlc3QgPSBsb2FkaW5nUmVxdWVzdHMuc2hpZnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KG90aGVyUmVxdWVzdC5jYWxsYmFjaywgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogY29tcGxldGVSZXF1ZXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sKICAgICAgICAgICA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ID0gcy5zdWJzdHJpbmcob2Zmc2V0ICsgcmVtb3ZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjaHVuazEgKyBpbnNlcnQgKyBjaHVuazI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLndpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNGb250UmVhZHkobmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgrK2NhbGxlZCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJMb2FkIHRlc3QgZm9udCBuZXZlciBsb2FkZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9ICIzMHB4ICIgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCIuIiwgMCwgMjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEuZGF0YVszXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoaXNGb250UmVhZHkuYmluZChudWxsLCBuYW1lLCBjYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRUZXN0Rm9udElkID0gYGx0JHtEYXRlLm5vdygpfSR7dGhpcy5sb2FkVGVzdEZvbnRJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gdGhpcy5fbG9hZFRlc3RGb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDT01NRU5UX09GRlNFVCA9IDk3NjsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNwbGljZVN0cmluZyhkYXRhLCBDT01NRU5UX09GRlNFVCwgbG9hZFRlc3RGb250SWQubGVuZ3RoLCBsb2FkVGVzdEZvbnRJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENGRl9DSEVDS1NVTV9PRkZTRVQgPSAxNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgWFhYWF9WQUxVRSA9IDB4NTg1ODU4NTg7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGVja3N1bSA9IGludDMyKGRhdGEsIENGRl9DSEVDS1NVTV9PRkZTRVQpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IGxvYWRUZXN0Rm9udElkLmxlbmd0aCAtIDM7IGkgPCBpaTsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja3N1bSA9IGNoZWNrc3VtIC0gWFhYWF9WQUxVRSArIGludDMyKGxvYWRUZXN0Rm9udElkLCBpKSB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCBsb2FkVGVzdEZvbnRJZC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrc3VtID0gY2hlY2tzdW0gLSBYWFhYX1ZBTFVFICsgaW50MzIobG9hZFRlc3RGb250SWQgKyAiWFhYIiwgaSkgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBzcGxpY2VTdHJpbmcoZGF0YSwgQ0ZGX0NIRUNLU1VNX09GRlNFVCwgNCwgKDAsIF91dGlsLnN0cmluZzMyKShjaGVja3N1bSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKGRhdGE6Zm9udC9vcGVudHlwZTtiYXNlNjQsJHtidG9hKGRhdGEpfSk7YDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGBAZm9udC1mYWNlIHtmb250LWZhbWlseToiJHtsb2FkVGVzdEZvbnRJZH0iO3NyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbnNlcnRSdWxlKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXYgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLndpZHRoID0gZGl2LnN0eWxlLmhlaWdodCA9ICIxMHB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnRvcCA9IGRpdi5zdHlsZS5sZWZ0ID0gIjBweCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBbZm9udC5sb2FkZWROYW1lLCBsb2FkVGVzdEZvbnRJZF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYW4gPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnRleHRDb250ZW50ID0gIkhpIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW4uc3R5bGUuZm9udEZhbWlseSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYuYXBwZW5kKHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmJvZHkuYXBwZW5kKGRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlzRm9udFJlYWR5KGxvYWRUZXN0Rm9udElkLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmNvbXBsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IEZvbnRMb2FkZXI7CiAgICAgICAgICAgICAgICBjbGFzcyBGb250RmFjZU9iamVjdCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IodHJhbnNsYXRlZERhdGEsIF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQgPSB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnMgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RGb250ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gdHJhbnNsYXRlZERhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbaV0gPSB0cmFuc2xhdGVkRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRXZhbFN1cHBvcnRlZCA9IGlzRXZhbFN1cHBvcnRlZCAhPT0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUZvbnRGYWNlID0gZGlzYWJsZUZvbnRGYWNlID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlnbm9yZUVycm9ycyA9IGlnbm9yZUVycm9ycyA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5zcGVjdEZvbnQgPSBpbnNwZWN0Rm9udDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlTmF0aXZlRm9udEZhY2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfaW5zcGVjdEZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhIHx8IHRoaXMuZGlzYWJsZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0aXZlRm9udEZhY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jc3NGb250SW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlRm9udEZhY2UgPSBuZXcgRm9udEZhY2UodGhpcy5sb2FkZWROYW1lLCB0aGlzLmRhdGEsIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNzcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWlnaHQ6IHRoaXMuY3NzRm9udEluZm8uZm9udFdlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzLnN0eWxlID0gYG9ibGlxdWUgJHt0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlfWRlZ2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVGb250RmFjZSA9IG5ldyBGb250RmFjZSh0aGlzLmNzc0ZvbnRJbmZvLmZvbnRGYW1pbHksIHRoaXMuZGF0YSwgY3NzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250ID0gdGhpcy5faW5zcGVjdEZvbnQpID09PSBudWxsIHx8IF90aGlzJF9pbnNwZWN0Rm9udCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2luc3BlY3RGb250LmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYXRpdmVGb250RmFjZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlRm9udEZhY2VSdWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2luc3BlY3RGb250MjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEgfHwgdGhpcy5kaXNhYmxlRm9udEZhY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSAoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykodGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gYHVybChkYXRhOiR7dGhpcy5taW1ldHlwZX07YmFzZTY0LCR7YnRvYShkYXRhKX0pO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzRm9udEluZm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBgQGZvbnQtZmFjZSB7Zm9udC1mYW1pbHk6IiR7dGhpcy5sb2FkZWROYW1lfSI7c3JjOiR7dXJsfX1gOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNzcyA9IGBmb250LXdlaWdodDogJHt0aGlzLmNzc0ZvbnRJbmZvLmZvbnRXZWlnaHR9O2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jc3NGb250SW5mby5pdGFsaWNBbmdsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzcyArPSBgZm9udC1zdHlsZTogb2JsaXF1ZSAke3RoaXMuY3NzRm9udEluZm8uaXRhbGljQW5nbGV9ZGVnO2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYEBmb250LWZhY2Uge2ZvbnQtZmFtaWx5OiIke3RoaXMuY3NzRm9udEluZm8uZm9udEZhbWlseX0iOyR7Y3NzfXNyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250MiA9IHRoaXMuX2luc3BlY3RGb250KSA9PT0gbnVsbCB8fCBfdGhpcyRfaW5zcGVjdEZvbnQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfaW5zcGVjdEZvbnQyLmNhbGwodGhpcywgdGhpcywgdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdGhHZW5lcmF0b3Iob2JqcywgY2hhcmFjdGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbXBpbGVkR2x5cGhzW2NoYXJhY3Rlcl0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kczsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZHMgPSBvYmpzLmdldCh0aGlzLmxvYWRlZE5hbWUgKyAiX3BhdGhfIiArIGNoYXJhY3Rlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFBhdGhHZW5lcmF0b3IgLSBpZ25vcmluZyBjaGFyYWN0ZXI6ICIke2V4fSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gZnVuY3Rpb24gKGMsIHNpemUpIHt9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRXZhbFN1cHBvcnRlZCAmJiBfdXRpbC5GZWF0dXJlVGVzdC5pc0V2YWxTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGpzQnVmID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBjdXJyZW50LmFyZ3MgIT09IHVuZGVmaW5lZCA/IGN1cnJlbnQuYXJncy5qb2luKCIsIikgOiAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0J1Zi5wdXNoKCJjLiIsIGN1cnJlbnQuY21kLCAiKCIsIGFyZ3MsICIpO1xuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gbmV3IEZ1bmN0aW9uKCJjIiwgInNpemUiLCBqc0J1Zi5qb2luKCIiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXSA9IGZ1bmN0aW9uIChjLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmNtZCA9PT0gInNjYWxlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmFyZ3MgPSBbc2l6ZSwgLXNpemVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjW2N1cnJlbnQuY21kXS5hcHBseShjLCBjdXJyZW50LmFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSBGb250RmFjZU9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ2ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQ2FudmFzR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgdmFyIF9wYXR0ZX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AgICAgICAgICBjb25zdCBFWEVDVVRJT05fVElNRSA9IDE1OwogICAgICAgICAgICAgICAgY29uc3QgRVhFQ1VUSU9OX1NURVBTID0gMTA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfU0laRV9UT19DT01QSUxFID0gMTAwMDsKICAgICAgICAgICAgICAgIGNvbnN0IEZVTExfQ0hVTktfSEVJR0hUID0gMTY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIGRlc3RDdHgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY3R4Ll9yZW1vdmVNaXJyb3JpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDb250ZXh0IGlzIGFscmVhZHkgZm9yd2FyZGluZyBvcGVyYXRpb25zLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFNhdmUgPSBjdHguc2F2ZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc3RvcmUgPSBjdHgucmVzdG9yZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJvdGF0ZSA9IGN0eC5yb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxTY2FsZSA9IGN0eC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZSA9IGN0eC50cmFuc2xhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxUcmFuc2Zvcm0gPSBjdHgudHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsU2V0VHJhbnNmb3JtID0gY3R4LnNldFRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtID0gY3R4LnJlc2V0VHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQ2xpcCA9IGN0eC5jbGlwOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsTW92ZVRvID0gY3R4Lm1vdmVUbzsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbExpbmVUbyA9IGN0eC5saW5lVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvID0gY3R4LmJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxSZWN0ID0gY3R4LnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGggPSBjdHguY2xvc2VQYXRoOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQmVnaW5QYXRoID0gY3R4LmJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICBjdHguX3JlbW92ZU1pcnJvcmluZyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBjdHguX19vcmlnaW5hbFNhdmU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlID0gY3R4Ll9fb3JpZ2luYWxSZXN0b3JlOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gY3R4Ll9fb3JpZ2luYWxSb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSA9IGN0eC5fX29yaWdpbmFsU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2xhdGUgPSBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsVHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gY3R4Ll9fb3JpZ2luYWxTZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsUmVzZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gY3R4Ll9fb3JpZ2luYWxDbGlwOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubW92ZVRvID0gY3R4Ll9fb3JpZ2luYWxNb3ZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8gPSBjdHguX19vcmlnaW5hbExpbmVUbzsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8gPSBjdHguX19vcmlnaW5hbEJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZWN0ID0gY3R4Ll9fb3JpZ2luYWxSZWN0OwogICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBjdHguX19vcmlnaW5hbEJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGN0eC5fcmVtb3ZlTWlycm9yaW5nOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBmdW5jdGlvbiBjdHhTYXZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsU2F2ZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUgPSBmdW5jdGlvbiBjdHhSZXN0b3JlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSA9IGZ1bmN0aW9uIGN0eFRyYW5zbGF0ZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2xhdGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUgPSBmdW5jdGlvbiBjdHhTY2FsZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2NhbGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNjYWxlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gZnVuY3Rpb24gY3R4U2V0VHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNldFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFJlc2V0VHJhbnNmb3JtKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gZnVuY3Rpb24gY3R4Um90YXRlKGFuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgucm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gZnVuY3Rpb24gY3R4Um90YXRlKHJ1bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5jbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyA9IGZ1bmN0aW9uICh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxNb3ZlVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvID0gZnVuY3Rpb24gKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbExpbmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvID0gZnVuY3Rpb24gKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5iZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlY3QgPSBmdW5jdGlvbiAoeCwgeSwgd2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbEJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYWNoZWRDYW52YXNlcyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoY2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2FudmFzKGlkLCB3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVbaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkucmVzZXQoY2FudmFzRW50cnksIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRW50cnkgPSB0aGlzLmNhbnZhc0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZVtpZF0gPSBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzRW50cnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlbGV0ZShpZCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGlkIGluIHRoaXMuY2FjaGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkuZGVzdHJveShjYW52YXNFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIGRlc3RYLCBkZXN0WSwgZGVzdFcsIGRlc3RIKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW2EsIGIsIGMsIGQsIHR4LCB0eV0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICBpZiAoYiA9PT0gMCAmJiBjID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RYICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WSAqIGQgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RYICsgZGVzdFcpICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFkgKyBkZXN0SCkgKiBkICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKE1hdGguc2lnbihhKSwgMCwgMCwgTWF0aC5zaWduKGQpLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJXaWR0aCwgckhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtyV2lkdGgsIHJIZWlnaHRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoYSA9PT0gMCAmJiBkID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RZICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WCAqIGIgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RZICsgZGVzdEgpICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFggKyBkZXN0VykgKiBiICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDAsIE1hdGguc2lnbihiKSwgTWF0aC5zaWduKGMpLCAwLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJIZWlnaHQsIHJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtySGVpZ2h0LCByV2lkdGhdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKHNyY0ltZywgc3JjWCwgc3JjWSwgc3JjVywgc3JjSCwgZGVzdFgsIGRlc3RZLCBkZXN0VywgZGVzdEgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlWCA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVZID0gTWF0aC5oeXBvdChjLCBkKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3NjYWxlWCAqIGRlc3RXLCBzY2FsZVkgKiBkZXN0SF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21waWxlVHlwZTNHbHlwaChpbWdEYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gTUFYX1NJWkVfVE9fQ09NUElMRSB8fCBoZWlnaHQgPiBNQVhfU0laRV9UT19DT01QSUxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UT19QUk9DRVNTX0xJTUlUID0gMTAwMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UWVBFUyA9IG5ldyBVaW50OEFycmF5KFswLCAyLCA0LCAwLCAxLCAwLCA1LCA0LCA4LCAxMCwgMCwgOCwgMCwgMiwgMSwgMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoMSA9IHdpZHRoICsgMTsKICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gbmV3IFVpbnQ4QXJyYXkod2lkdGgxICogKGhlaWdodCArIDEpKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaSwgaiwgajA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZVNpemUgPSB3aWR0aCArIDcgJiB+NzsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IG5ldyBVaW50OEFycmF5KGxpbmVTaXplICogaGVpZ2h0KSwKICAgICAgICAgICAgICAgICAgICAgICAgcG9zID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW0gb2YgaW1nRGF0YS5kYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobWFzayA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcG9zKytdID0gZWxlbSAmIG1hc2sgPyAwIDogMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzayA+Pj0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwOwogICAgICAgICAgICAgICAgICAgIHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbal0gPSBkYXRhW3Bvc10gPyAyIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChkYXRhW3Bvc10gIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2pdID0gMjsKICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMTsgaSA8IGhlaWdodDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcyA9IGkgKiBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgajAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3MgLSBsaW5lU2l6ZV0gIT09IGRhdGFbcG9zXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2owXSA9IGRhdGFbcG9zXSA/IDEgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3VtID0gKGRhdGFbcG9zXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplXSA/IDggOiAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChqID0gMTsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1bSA9IChzdW0gPj4gMikgKyAoZGF0YVtwb3MgKyAxXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplICsgMV0gPyA4IDogMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUE9JTlRfVFlQRVNbc3VtXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gUE9JTlRfVFlQRVNbc3VtXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zIC0gbGluZVNpemVdICE9PSBkYXRhW3Bvc10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gZGF0YVtwb3NdID8gMiA6IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvcyA9IGxpbmVTaXplICogKGhlaWdodCAtIDEpOwogICAgICAgICAgICAgICAgICAgIGowID0gaSAqIHdpZHRoMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMF0gPSA4OwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IGRhdGFbcG9zXSA/IDQgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb3MrKzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZXBzID0gbmV3IEludDMyQXJyYXkoWzAsIHdpZHRoMSwgLTEsIDAsIC13aWR0aDEsIDAsIDAsIDAsIDFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoID0gbmV3IFBhdGgyRCgpOwogICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGNvdW50ICYmIGkgPD0gaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBwICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwIDwgZW5kICYmICFwb2ludHNbcF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHArKzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocCA9PT0gZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRoLm1vdmVUbyhwICUgd2lkdGgxLCBpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDAgPSBwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IHBvaW50c1twXTsKICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RlcCA9IHN0ZXBzW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKCFwb2ludHNbcF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHAgPSBwb2ludHNbcF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHAgIT09IDUgJiYgcHAgIT09IDEwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9IHBwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1twXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBwcCAmIDB4MzMgKiB0eXBlID4+IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW3BdICY9IHR5cGUgPj4gMiB8IHR5cGUgPDwgMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgubGluZVRvKHAgJSB3aWR0aDEsIHAgLyB3aWR0aDEgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcG9pbnRzW3BdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLS1jb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAocDAgIT09IHApOwogICAgICAgICAgICAgICAgICAgICAgICAtLWk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd091dGxpbmUgPSBmdW5jdGlvbiAoYykgewogICAgICAgICAgICAgICAgICAgICAgICBjLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgYy50cmFuc2xhdGUoMCwgLWhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGMuZmlsbChwYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZHJhd091dGxpbmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYW52YXNFeHRyYVN0YXRlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcih3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxwaGFJc1NoYXBlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFNpemUgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRTaXplU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TWF0cml4ID0gX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGFyU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud29yZFNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbENvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdHRlcm5GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVdpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3RpdmVTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmZXJNYXBzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0TmV3UGF0aEFuZENsaXBCb3goWzAsIDAsIHdpZHRoLCBoZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lID0gT2JqZWN0LmNyZWF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmUuY2xpcEJveCA9IHRoaXMuY2xpcEJveC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEN1cnJlbnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhdGhNaW5NYXgodHJhbnNmb3JtLCB4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3gsIHldLCB0cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblggPSBNYXRoLm1pbih0aGlzLm1pblgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFkgPSBNYXRoLm1heCh0aGlzLm1heFksIHkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWN0TWluTWF4KHRyYW5zZm9ybSwgcmVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0ocmVjdCwgdHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKHJlY3Quc2xpY2UoMiksIHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgcDFbMF0sIHAyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5taW5ZID0gTWF0aC5taW4odGhpcy5taW5ZLCBwMVsxXSwgcDJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHAxWzBdLCBwMlswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgcDFbMV0sIHAyWzFdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlU2NhbGluZ1BhdGhNaW5NYXgodHJhbnNmb3JtLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX3V0aWwuVXRpbC5zY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgbWluTWF4WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gTWF0aC5tYXgodGhpcy5tYXhYLCBtaW5NYXhbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIG1pbk1heFsyXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgbWluTWF4WzNdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlQ3VydmVQYXRoTWluTWF4KHRyYW5zZm9ybSwgeDAsIHkwLCB4MSwgeTEsIHgyLCB5MiwgeDMsIHkzLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm94ID0gX3V0aWwuVXRpbC5iZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBNYXRoLm1pbihtaW5NYXhbMF0sIGJveFswXSwgYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYm94WzBdLCBib3hbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBib3hbMV0sIGJveFszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbM10gPSBNYXRoLm1heChtaW5NYXhbM10sIGJveFsxXSwgYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVJlY3RNaW5NYXgodHJhbnNmb3JtLCBib3gpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXRoQm91bmRpbmdCb3goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoVHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJveCA9IFt0aGlzLm1pblgsIHRoaXMubWluWSwgdGhpcy5tYXhYLCB0aGlzLm1heFldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgPT09IF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU3Ryb2tlIGJvdW5kaW5nIGJveCBtdXN0IGluY2x1ZGUgdHJhbnNmb3JtLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4U3Ryb2tlUGFkID0gc2NhbGVbMF0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5U3Ryb2tlUGFkID0gc2NhbGVbMV0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbMF0gLT0geFN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJveFsxXSAtPSB5U3Ryb2tlUGFkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm94WzJdICs9IHhTdHJva2VQYWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbM10gKz0geVN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYm94OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVDbGlwRnJvbVBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVyc2VjdCA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnROZXdQYXRoQW5kQ2xpcEJveChpbnRlcnNlY3QgfHwgWzAsIDAsIDAsIDBdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eUNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1pblggPT09IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGFydE5ld1BhdGhBbmRDbGlwQm94KGJveCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCb3ggPSBib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhZID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGhUeXBlID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZm9ybSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3gocGF0aFR5cGUsIHRyYW5zZm9ybSkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlRGF0YShjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEltYWdlRGF0YSAhPT0gInVuZGVmaW5lZCIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEltYWdlRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGltZ0RhdGEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFydGlhbENodW5rSGVpZ2h0ID0gaGVpZ2h0ICUgRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbENodW5rcyA9IChoZWlnaHQgLSBwYXJ0aWFsQ2h1bmtIZWlnaHQpIC8gRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdG90YWxDaHVua3MgPSBwYXJ0aWFsQ2h1bmtIZWlnaHQgPT09IDAgPyBmdWxsQ2h1bmtzIDogZnVsbENodW5rcyArIDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtJbWdEYXRhID0gY3R4LmNyZWF0ZUltYWdlRGF0YSh3aWR0aCwgRlVMTF9DSFVOS19IRUlHSFQpOwogICAgICAgICAgICAgICAgICAgIGxldCBzcmNQb3MgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYyA9IGltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0ID0gY2h1bmtJbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGosIHRoaXNDaHVua0hlaWdodCwgZWxlbXNJblRoaXNDaHVuazsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5raW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjTGVuZ3RoID0gc3JjLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QzMiA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlciwgMCwgZGVzdC5ieXRlTGVuZ3RoID4+IDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0MzJEYXRhTGVuZ3RoID0gZGVzdDMyLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFNyY0RpZmYgPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2hpdGUgPSAweGZmZmZmZmZmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibGFjayA9IF91dGlsLkZlYXR1cmVUZXN0LmlzTGl0dGxlRW5kaWFuID8gMHhmZjAwMDAwMCA6IDB4MDAwMDAwZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCB0b3RhbENodW5rczsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBpIDwgZnVsbENodW5rcyA/IEZVTExfQ0hVTktfSEVJR0hUIDogcGFydGlhbENodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgdGhpc0NodW5rSGVpZ2h0OyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcmNEaWZmID0gc3JjTGVuZ3RoIC0gc3JjUG9zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrRW5kID0gc3JjRGlmZiA+IGZ1bGxTcmNEaWZmID8gd2lkdGggOiBzcmNEaWZmICogOCAtIDc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga0VuZFVucm9sbGVkID0ga0VuZCAmIH43OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3JjQnl0ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICg7IGsgPCBrRW5kVW5yb2xsZWQ7IGsgKz0gOCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMTI4ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgNjQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAzMiA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDE2ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgOCA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAyID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMSA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoOyBrIDwga0VuZDsgaysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgbWFzayA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGRlc3RQb3MgPCBkZXN0MzJEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIEZVTExfQ0hVTktfSEVJR0hUICogNDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGZ1bGxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdC5zZXQoc3JjLnN1YmFycmF5KHNyY1Bvcywgc3JjUG9zICsgZWxlbXNJblRoaXNDaHVuaykpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zICs9IGVsZW1zSW5UaGlzQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IEZVTExfQ0hVTktfSEVJR0hUOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpIDwgdG90YWxDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIHBhcnRpYWxDaHVua0hlaWdodCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0LnNldChzcmMuc3ViYXJyYXkoc3JjUG9zLCBzcmNQb3MgKyBlbGVtc0luVGhpc0NodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbXNJblRoaXNDaHVuayA9IHdpZHRoICogdGhpc0NodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgdG90YWxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gZnVsbENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNDaHVua0hlaWdodCA9IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtc0luVGhpc0NodW5rID0gd2lkdGggKiB0aGlzQ2h1bmtIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IGVsZW1zSW5UaGlzQ2h1bms7IGotLTspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbc3JjUG9zKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IHNyY1tzcmNQb3MrK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaSAqIEZVTExfQ0hVTktfSEVJR0hUKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgYmFkIGltYWdlIGtpbmQ6ICR7aW1nRGF0YS5raW5kfWApOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlTWFzayhjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5iaXRtYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShpbWdEYXRhLmJpdG1hcCwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gaW1nRGF0YS5oZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0aWFsQ2h1bmtIZWlnaHQgPSBoZWlnaHQgJSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsQ2h1bmtzID0gKGhlaWdodCAtIHBhcnRpYWxDaHVua0hlaWdodCkgLyBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0b3RhbENodW5rcyA9IHBhcnRpYWxDaHVua0hlaWdodCA9PT0gMCA/IGZ1bGxDaHVua3MgOiBmdWxsQ2h1bmtzICsgMTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0ltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHNyY1BvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjID0gaW1nRGF0YS5kYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QgPSBjaHVua0ltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRvdGFsQ2h1bmtzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGhpc0NodW5rSGVpZ2h0ID0gaSA8IGZ1bGxDaHVua3MgPyBGVUxMX0NIVU5LX0hFSUdIVCA6IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1BvcwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gKDAsIF9pbWFnZV91dGlscy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSkoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0OiB0aGlzQ2h1bmtIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25CbGFja0NvbG9yOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29weUN0eFN0YXRlKHNvdXJjZUN0eCwgZGVzdEN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BlcnRpZXMgPSBbInN0cm9rZVN0eWxlIiwgImZpbGxTdHlsZSIsICJmaWxsUnVsZSIsICJnbG9iYWxBbHBoYSIsICJsaW5lV2lkdGgiLCAibGluZUNhcCIsICJsaW5lSm9pbiIsICJtaXRlckxpbWl0IiwgImdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiIsICJmb250IiwgImZpbHRlciJdOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJvcGVydHkgb2YgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlQ3R4W3Byb3BlcnR5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4W3Byb3BlcnR5XSA9IHNvdXJjZUN0eFtwcm9wZXJ0eV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZUN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2V0TGluZURhc2goc291cmNlQ3R4LmdldExpbmVEYXNoKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmxpbmVEYXNoT2Zmc2V0ID0gc291cmNlQ3R4LmxpbmVEYXNoT2Zmc2V0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlc2V0Q3R4VG9EZWZhdWx0KGN0eCkgewogICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IGN0eC5maWxsU3R5bGUgPSAiIzAwMDAwMCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxSdWxlID0gIm5vbnplcm8iOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAiYnV0dCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVKb2luID0gIm1pdGVyIjsKICAgICAgICAgICAgICAgICAgICBjdHgubWl0ZXJMaW1pdCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxDb21wb3NpdGVPcGVyYXRpb24gPSAic291cmNlLW92ZXIiOwogICAgICAgICAgICAgICAgICAgIGN0eC5mb250ID0gIjEwcHggc2Fucy1zZXJpZiI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lRGFzaE9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wb3NlU01hc2tCYWNrZHJvcChieXRlcywgcjAsIGcwLCBiMCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IGJ5dGVzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gYnl0ZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbHBoYSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSAtIDNdID0gcjA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpIC0gMl0gPSBnMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGIwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGFscGhhIDwgMjU1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhbHBoYV8gPSAyNTUgLSBhbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAzXSA9IGJ5dGVzW2kgLSAzXSAqIGFscGhhICsgcjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAyXSA9IGJ5dGVzW2kgLSAyXSAqIGFscGhhICsgZzAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGJ5dGVzW2kgLSAxXSAqIGFscGhhICsgYjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNvbXBvc2VTTWFza0FscGhhKG1hc2tEYXRhLCBsYXllckRhdGEsIHRyYW5zZmVyTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gbWFza0RhdGEubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gMSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gdHJhbnNmZXJNYXAgPyB0cmFuc2Zlck1hcFttYXNrRGF0YVtpXV0gOiBtYXNrRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGF5ZXJEYXRhW2ldID0gbGF5ZXJEYXRhW2ldICogYWxwaGEgKiBzY2FsZSB8IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrTHVtaW5vc2l0eShtYXNrRGF0YSwgbGF5ZXJEYXRhLCB0cmFuc2Zlck1hcCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IG1hc2tEYXRhLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSBtYXNrRGF0YVtpIC0gM10gKiA3NyArIG1hc2tEYXRhW2kgLSAyXSAqIDE1MiArIG1hc2tEYXRhW2kgLSAxXSAqIDI4OwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckRhdGFbaV0gPSB0cmFuc2Zlck1hcCA/IGxheWVyRGF0YVtpXSAqIHRyYW5zZmVyTWFwW3kgPj4gOF0gPj4gOCA6IGxheWVyRGF0YVtpXSAqIHkgPj4gMTY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJpY0NvbXBvc2VTTWFzayhtYXNrQ3R4LCBsYXllckN0eCwgd2lkdGgsIGhlaWdodCwgc3VidHlwZSwgYmFja2Ryb3AsIHRyYW5zZmVyTWFwLCBsYXllck9mZnNldFgsIGxheWVyT2Zmc2V0WSwgbWFza09mZnNldFgsIG1hc2tPZmZzZXRZKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFzQmFja2Ryb3AgPSAhIWJhY2tkcm9wOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHIwID0gaGFzQmFja2Ryb3AgPyBiYWNrZHJvcFswXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZzAgPSBoYXNCYWNrZHJvcCA/IGJhY2tkcm9wWzFdIDogMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBiMCA9IGhhc0JhY2tkcm9wID8gYmFja2Ryb3BbMl0gOiAwOwogICAgICAgICAgICAgICAgICAgIGxldCBjb21wb3NlRm47CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1YnR5cGUgPT09ICJMdW1pbm9zaXR5IikgewogICAgICAgICAgICAgICAgICAgICAgICBjb21wb3NlRm4gPSBjb21wb3NlU01hc2tMdW1pbm9zaXR5OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbiA9IGNvbXBvc2VTTWFza0FscGhhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQSVhFTFNfVE9fUFJPQ0VTUyA9IDEwNDg1NzY7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtTaXplID0gTWF0aC5taW4oaGVpZ2h0LCBNYXRoLmNlaWwoUElYRUxTX1RPX1BST0NFU1MgLyB3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHJvdyA9IDA7IHJvdyA8IGhlaWdodDsgcm93ICs9IGNodW5rU2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0hlaWdodCA9IE1hdGgubWluKGNodW5rU2l6ZSwgaGVpZ2h0IC0gcm93KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0RhdGEgPSBtYXNrQ3R4LmdldEltYWdlRGF0YShsYXllck9mZnNldFggLSBtYXNrT2Zmc2V0WCwgcm93ICsgKGxheWVyT2Zmc2V0WSAtIG1hc2tPZmZzZXRZKSwgd2lkdGgsIGNodW5rSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXJEYXRhID0gbGF5ZXJDdHguZ2V0SW1hZ2VEYXRhKGxheWVyT2Zmc2V0WCwgcm93ICsgbGF5ZXJPZmZzZXRZLCB3aWR0aCwgY2h1bmtIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGFzQmFja2Ryb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFza0JhY2tkcm9wKG1hc2tEYXRhLmRhdGEsIHIwLCBnMCwgYjApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbihtYXNrRGF0YS5kYXRhLCBsYXllckRhdGEuZGF0YSwgdHJhbnNmZXJNYXApOwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckN0eC5wdXRJbWFnZURhdGEobGF5ZXJEYXRhLCBsYXllck9mZnNldFgsIHJvdyArIGxheWVyT2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrKGN0eCwgc21hc2ssIGxheWVyQ3R4LCBsYXllckJveCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WCA9IGxheWVyQm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WSA9IGxheWVyQm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyV2lkdGggPSBsYXllckJveFsyXSAtIGxheWVyT2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllckhlaWdodCA9IGxheWVyQm94WzNdIC0gbGF5ZXJPZmZzZXRZOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcldpZHRoID09PSAwIHx8IGxheWVySGVpZ2h0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2VuZXJpY0NvbXBvc2VTTWFzayhzbWFzay5jb250ZXh0LCBsYXllckN0eCwgbGF5ZXJXaWR0aCwgbGF5ZXJIZWlnaHQsIHNtYXNrLnN1YnR5cGUsIHNtYXNrLmJhY2tkcm9wLCBzbWFzay50cmFuc2Zlck1hcCwgbGF5ZXJPZmZzZXRYLCBsYXllck9mZnNldFksIHNtYXNrLm9mZnNldFgsIHNtYXNrLm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1vdmVyIjsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UobGF5ZXJDdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0SW1hZ2VTbW9vdGhpbmdFbmFibGVkKHRyYW5zZm9ybSwgaW50ZXJwb2xhdGUpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUodHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVswXSA9IE1hdGguZnJvdW5kKHNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVsxXSA9IE1hdGguZnJvdW5kKHNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3R1YWxTY2FsZSA9IE1hdGguZnJvdW5kKChnbG9iYWxUaGlzLmRldmljZVBpeGVsUmF0aW8gfHwgMSkgKiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMpOwogICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcnBvbGF0ZSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcnBvbGF0ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNjYWxlWzBdIDw9IGFjdHVhbFNjYWxlIHx8IHNjYWxlWzFdIDw9IGFjdHVhbFNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0NBUF9TVFlMRVMgPSBbImJ1dHQiLCAicm91bmQiLCAic3F1YXJlIl07CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgY29uc3QgTk9STUFMX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIGNvbnN0IEVPX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBfcmVzdG9yZUluaXRpYWxTdGF0ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQ2FudmFzR3JhcGhpY3MgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNhbnZhc0N0eCwgY29tbW9uT2Jqcywgb2JqcywgY2FudmFzRmFjdG9yeSwgZmlsdGVyRmFjdG9yeSwgX3JlZiwgYW5ub3RhdGlvbkNhbnZhc01hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjYW52YXNDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG5ldyBDYW52YXNFeHRyYVN0YXRlKHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy54b2JqcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IGNvbW1vbk9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2JqcyA9IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzRmFjdG9yeSA9IGNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc21hc2tTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrQ291bnRlciA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGVtcFNNYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRWaXNpYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sgPSBtYXJrZWRDb250ZW50U3RhY2sgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnID0gb3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzID0gbmV3IENhY2hlZENhbnZhc2VzKHRoaXMuY2FudmFzRmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcCA9IGFubm90YXRpb25DYW52YXNNYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnRTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVYID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vdXRwdXRTY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmYWxsYmFjayA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxsYmFjazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5EcmF3aW5nKF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZCA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5jdHguY2FudmFzLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWxsU3R5bGUgPSB0aGlzLmN0eC5maWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGJhY2tncm91bmQgfHwgIiNmZmZmZmYiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCgwLCAwLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFN0eWxlID0gc2F2ZWRGaWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc3BhcmVuY3kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50Q2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInRyYW5zcGFyZW50Iiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2l0ZUN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc3BhcmVudENhbnZhcyA9IHRyYW5zcGFyZW50Q2FudmFzLmNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdHJhbnNwYXJlbnRDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jb21wb3NpdGVDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgudHJhbnNmb3JtKC4uLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm91dHB1dFNjYWxlWCA9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVZID0gdHJhbnNmb3JtWzBdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi52aWV3cG9ydC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0U2NhbGUgPSB2aWV3cG9ydC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYXNlVHJhbnNmb3JtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlY3V0ZU9wZXJhdG9yTGlzdChvcGVyYXRvckxpc3QsIGV4ZWN1dGlvblN0YXJ0SWR4LCBjb250aW51ZUNhbGxiYWNrLCBzdGVwcGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuQXJyYXkgPSBvcGVyYXRvckxpc3QuZm5BcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBleGVjdXRpb25TdGFydElkeCB8fCAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXlMZW4gPSBhcmdzQXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJnc0FycmF5TGVuID09PSBpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua09wZXJhdGlvbnMgPSBhcmdzQXJyYXlMZW4gLSBpID4gRVhFQ1VUSU9OX1NURVBTICYmIHR5cGVvZiBjb250aW51ZUNhbGxiYWNrID09PSAiZnVuY3Rpb24iOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRUaW1lID0gY2h1bmtPcGVyYXRpb25zID8gRGF0ZS5ub3coKSArIEVYRUNVVElPTl9USU1FIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tbW9uT2JqcyA9IHRoaXMuY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqcyA9IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZuSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RlcHBlciAhPT0gdW5kZWZpbmVkICYmIGkgPT09IHN0ZXBwZXIubmV4dEJyZWFrUG9pbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGVwcGVyLmJyZWFrSXQoaSwgY29udGludWVDYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbklkID0gZm5BcnJheVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbklkICE9PSBfdXRpbC5PUFMuZGVwZW5kZW5jeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbZm5JZF0uYXBwbHkodGhpcywgYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBkZXBPYmpJZCBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBkZXBPYmpJZC5zdGFydHNXaXRoKCJnXyIpID8gY29tbW9uT2JqcyA6IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb2Jqc1Bvb2wuaGFzKGRlcE9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KGRlcE9iaklkLCBjb250aW51ZUNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IGFyZ3NBcnJheUxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rT3BlcmF0aW9ucyAmJiArK3N0ZXBzID4gRVhFQ1VUSU9OX1NURVBTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERhdGUubm93KCkgPiBlbmRUaW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlQ2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmREcmF3aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZUNvbG9ycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVzdG9yZUluaXRpYWxTdGF0ZSwgX3Jlc3RvcmVJbml0aWFsU3RhdGUyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiB0aGlzLl9jYWNoZWRCaXRtYXBzTWFwLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNhbnZhcyBvZiBjYWNoZS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgSFRNTENhbnZhc0VsZW1lbnQgIT09ICJ1bmRlZmluZWQiICYmIGNhbnZhcyBpbnN0YW5jZW9mIEhUTUxDYW52YXNFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQml0bWFwc01hcC5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZUNvbG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGNtRmlsdGVySWQgPSB0aGlzLmZpbHRlckZhY3RvcnkuYWRkSENNRmlsdGVyKHBhZ2VDb2xvcnMuZm9yZWdyb3VuZCwgcGFnZUNvbG9ycy5iYWNrZ3JvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoY21GaWx0ZXJJZCAhPT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWx0ZXIgPSB0aGlzLmN0eC5maWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gaGNtRmlsdGVySWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMuY3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gc2F2ZWRGaWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NjYWxlSW1hZ2UoaW1nLCBpbnZlcnNlVHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWcuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgd2lkdGhTY2FsZSA9IE1hdGgubWF4KE1hdGguaHlwb3QoaW52ZXJzZVRyYW5zZm9ybVswXSwgaW52ZXJzZVRyYW5zZm9ybVsxXSksIDEpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaGVpZ2h0U2NhbGUgPSBNYXRoLm1heChNYXRoLmh5cG90KGludmVyc2VUcmFuc2Zvcm1bMl0sIGludmVyc2VUcmFuc2Zvcm1bM10pLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhaW50V2lkdGggPSB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50SGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdG1wQ2FudmFzSWQgPSAicHJlc2NhbGUxIjsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRtcENhbnZhcywgdG1wQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAod2lkdGhTY2FsZSA+IDIgJiYgcGFpbnRXaWR0aCA+IDEgfHwgaGVpZ2h0U2NhbGUgPiAyICYmIHBhaW50SGVpZ2h0ID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ld1dpZHRoID0gcGFpbnRXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdIZWlnaHQgPSBwYWludEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aFNjYWxlID4gMiAmJiBwYWludFdpZHRoID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1dpZHRoID0gcGFpbnRXaWR0aCA+PSAxNjM4NCA/IE1hdGguZmxvb3IocGFpbnRXaWR0aCAvIDIpIC0gMSB8fCAxIDogTWF0aC5jZWlsKHBhaW50V2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aFNjYWxlIC89IHBhaW50V2lkdGggLyBuZXdXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoZWlnaHRTY2FsZSA+IDIgJiYgcGFpbnRIZWlnaHQgPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SGVpZ2h0ID0gcGFpbnRIZWlnaHQgPj0gMTYzODQgPyBNYXRoLmZsb29yKHBhaW50SGVpZ2h0IC8gMikgLSAxIHx8IDEgOiBNYXRoLmNlaWwocGFpbnRIZWlnaHQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHRTY2FsZSAvPSBwYWludEhlaWdodCAvIG5ld0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKHRtcENhbnZhc0lkLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoaW1nLCAwLCAwLCBwYWludFdpZHRoLCBwYWludEhlaWdodCwgMCwgMCwgbmV3V2lkdGgsIG5ld0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRXaWR0aCA9IG5ld1dpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRIZWlnaHQgPSBuZXdIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDYW52YXNJZCA9IHRtcENhbnZhc0lkID09PSAicHJlc2NhbGUxIiA/ICJwcmVzY2FsZTIiIDogInByZXNjYWxlMSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50V2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWludEhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlTWFza0NhbnZhcyhpbWcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbGxDb2xvciA9IHRoaXMuY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUGF0dGVybkZpbGwgPSB0aGlzLmN1cnJlbnQucGF0dGVybkZpbGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNhY2hlLCBjYWNoZUtleSwgc2NhbGVkLCBtYXNrQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGltZy5iaXRtYXAgfHwgaW1nLmRhdGEpICYmIGltZy5jb3VudCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1haW5LZXkgPSBpbWcuYml0bWFwIHx8IGltZy5kYXRhLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5ID0gSlNPTi5zdHJpbmdpZnkoaXNQYXR0ZXJuRmlsbCA/IGN1cnJlbnRUcmFuc2Zvcm0gOiBbY3VycmVudFRyYW5zZm9ybS5zbGljZSgwLCA0KSwgZmlsbENvbG9yXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZSA9IHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuZ2V0KG1haW5LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWNoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuc2V0KG1haW5LZXksIGNhY2hlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlZEltYWdlID0gY2FjaGUuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRJbWFnZSAmJiAhaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLnJvdW5kKE1hdGgubWluKGN1cnJlbnRUcmFuc2Zvcm1bMF0sIGN1cnJlbnRUcmFuc2Zvcm1bMl0pICsgY3VycmVudFRyYW5zZm9ybVs0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgucm91bmQoTWF0aC5taW4oY3VycmVudFRyYW5zZm9ybVsxXSwgY3VycmVudFRyYW5zZm9ybVszXSkgKyBjdXJyZW50VHJhbnNmb3JtWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXM6IGNhY2hlZEltYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IGNhY2hlZEltYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoIm1hc2tDYW52YXMiLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlTWFzayhtYXNrQ2FudmFzLmNvbnRleHQsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGN1cnJlbnRUcmFuc2Zvcm0sIFsxIC8gd2lkdGgsIDAsIDAsIC0xIC8gaGVpZ2h0LCAwLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hc2tUb0NhbnZhcywgWzEsIDAsIDAsIDEsIDAsIC1oZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDEgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgaGVpZ2h0XSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbY29yZDFbMF0sIGNvcmQxWzFdLCBjb3JkMlswXSwgY29yZDJbMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IE1hdGgucm91bmQocmVjdFsyXSAtIHJlY3RbMF0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRyYXduSGVpZ2h0ID0gTWF0aC5yb3VuZChyZWN0WzNdIC0gcmVjdFsxXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJmaWxsQ2FudmFzIiwgZHJhd25XaWR0aCwgZHJhd25IZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ3R4ID0gZmlsbENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvZmZzZXRYID0gTWF0aC5taW4oY29yZDFbMF0sIGNvcmQyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgubWluKGNvcmQxWzFdLCBjb3JkMlsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNmb3JtKC4uLm1hc2tUb0NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWQgPSB0aGlzLl9zY2FsZUltYWdlKG1hc2tDYW52YXMuY2FudmFzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IHNjYWxlZC5pbWc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLnNldChjYWNoZUtleSwgc2NhbGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoZmlsbEN0eCksIGltZy5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhmaWxsQ3R4LCBzY2FsZWQsIDAsIDAsIHNjYWxlZC53aWR0aCwgc2NhbGVkLmhlaWdodCwgMCwgMCwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1pbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludmVyc2UgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybSgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpLCBbMSwgMCwgMCwgMSwgLW9mZnNldFgsIC1vZmZzZXRZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZmlsbFN0eWxlID0gaXNQYXR0ZXJuRmlsbCA/IGZpbGxDb2xvci5nZXRQYXR0ZXJuKGN0eCwgdGhpcywgaW52ZXJzZSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpIDogZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgIWlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkQ2FudmFzZXMuZGVsZXRlKCJmaWxsQ2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZS5zZXQoY2FjaGVLZXksIGZpbGxDYW52YXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBmaWxsQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IE1hdGgucm91bmQob2Zmc2V0WCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBNYXRoLnJvdW5kKG9mZnNldFkpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggIT09IHRoaXMuY3VycmVudC5saW5lV2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZVdpZHRoID0gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXAoc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVKb2luKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmxpbmVKb2luID0gTElORV9KT0lOX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubWl0ZXJMaW1pdCA9IGxpbWl0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREYXNoKGRhc2hBcnJheSwgZGFzaFBoYXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3R4LnNldExpbmVEYXNoICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChkYXNoQXJyYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaFBoYXNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudChpbnRlbnQpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0RmxhdG5lc3MoZmxhdG5lc3MpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBzdGF0ZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lQ2FwKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVKb2luKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldE1pdGVyTGltaXQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRSZW5kZXJpbmdJbnRlbnQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmxhdG5lc3ModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkNBIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUFscGhhID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5nbG9iYWxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJCTSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJTTWFzayI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayA9IHZhbHVlID8gdGhpcy50ZW1wU01hc2sgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRlbXBTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tTTWFza1N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlRSIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gdGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9IHRoaXMuZmlsdGVyRmFjdG9yeS5hZGRGaWx0ZXIodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaW5TTWFza01vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIXRoaXMuc3VzcGVuZGVkQ3R4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjaGVja1NNYXNrU3RhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluU01hc2tNb2RlID0gdGhpcy5pblNNYXNrTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayAmJiAhaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmVnaW5TTWFza01vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5jdXJyZW50LmFjdGl2ZVNNYXNrICYmIGluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFNNYXNrTW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNNYXNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJiZWdpblNNYXNrTW9kZSBjYWxsZWQgd2hpbGUgYWxyZWFkeSBpbiBzbWFzayBtb2RlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25IZWlnaHQgPSB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZUlkID0gInNtYXNrR3JvdXBBdCIgKyB0aGlzLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5zdXNwZW5kZWRDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuc3VzcGVuZGVkQ3R4LCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIHRoaXMuc3VzcGVuZGVkQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZW5kU01hc2tNb2RlIGNhbGxlZCB3aGlsZSBub3QgaW4gc21hc2sgbW9kZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Ll9yZW1vdmVNaXJyb3JpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuY3R4LCB0aGlzLnN1c3BlbmRlZEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tcG9zZShkaXJ0eUJveCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3VycmVudC5hY3RpdmVTTWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZGlydHlCb3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94ID0gWzAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJ0eUJveFswXSA9IE1hdGguZmxvb3IoZGlydHlCb3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlydHlCb3hbMV0gPSBNYXRoLmZsb29yKGRpcnR5Qm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzJdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzNdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzbWFzayA9IHRoaXMuY3VycmVudC5hY3RpdmVTTWFzazsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3VzcGVuZGVkQ3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFzayhzdXNwZW5kZWRDdHgsIHNtYXNrLCB0aGlzLmN0eCwgZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xlYXJSZWN0KDAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2F2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLmN0eCwgdGhpcy5zdXNwZW5kZWRDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9sZCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGF0ZVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gb2xkLmNsb25lKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoID09PSAwICYmIHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVTdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLnN1c3BlbmRlZEN0eCwgdGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoZWNrU01hc2tTdGF0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RQYXRoKG9wcywgYXJncywgbWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBjdXJyZW50Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdGFydFgsIHN0YXJ0WTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NjYWxpbmdNYXRyaXggPSBjdXJyZW50VHJhbnNmb3JtWzBdID09PSAwICYmIGN1cnJlbnRUcmFuc2Zvcm1bM10gPT09IDAgfHwgY3VycmVudFRyYW5zZm9ybVsxXSA9PT0gMCAmJiBjdXJyZW50VHJhbnNmb3JtWzJdID09PSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXhGb3JCZXppZXIgPSBpc1NjYWxpbmdNYXRyaXggPyBtaW5NYXguc2xpY2UoMCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gb3BzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BzW2ldIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHcgPSB4ICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHloID0geSArIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID09PSAwIHx8IGhlaWdodCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeWgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHh3LCB5aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHloKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU2NhbGluZ01hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVSZWN0TWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIFt4LCB5LCB4dywgeWhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NjYWxpbmdNYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5saW5lVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCBhcmdzW2ogKyAyXSwgYXJnc1tqICsgM10sIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZUN1cnZlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCBzdGFydFgsIHN0YXJ0WSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSwgeCwgeSwgbWluTWF4Rm9yQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8oeCwgeSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlQ3VydmVQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIHN0YXJ0WCwgc3RhcnRZLCB4LCB5LCBhcmdzW2pdLCBhcmdzW2ogKyAxXSwgYXJnc1tqICsgMl0sIGFyZ3NbaiArIDNdLCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2ogKyAzXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgM107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVDdXJ2ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgc3RhcnRYLCBzdGFydFksIGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5LCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVNjYWxpbmdQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIG1pbk1heEZvckJlemllcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5zZXRDdXJyZW50UG9pbnQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnN1bWVQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3Ryb2tlQ29sb3IgPSB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5zdHJva2VBbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3Ryb2tlQ29sb3IgPT09ICJvYmplY3QiICYmIHN0cm9rZUNvbG9yICE9PSBudWxsICYmIHN0cm9rZUNvbG9yICE9PSB2b2lkIDAgJiYgc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNUUk9LRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNjYWxlQW5kU3Ryb2tlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc2NhbGVBbmRTdHJva2UodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnN1bWVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKHRoaXMuY3VycmVudC5nZXRDbGlwcGVkUGF0aEJvdW5kaW5nQm94KCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5maWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29uc3VtZVBhdGggPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ29sb3IgPSB0aGlzLmN1cnJlbnQuZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1BhdHRlcm5GaWxsID0gdGhpcy5jdXJyZW50LnBhdHRlcm5GaWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZFJlc3RvcmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gZmlsbENvbG9yLmdldFBhdHRlcm4oY3R4LCB0aGlzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCksIF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5GSUxMKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRSZXN0b3JlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlcnNlY3QgPSB0aGlzLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiBpbnRlcnNlY3QgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdFT0ZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgiZXZlbm9kZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29uc3VtZVBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoaW50ZXJzZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlb0ZpbGwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZShmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdFT0ZpbGwgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRQYXRoKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBOT1JNQUxfQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9DbGlwKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gRU9fQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRUZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRocyA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHBhdGggb2YgcGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oLi4ucGF0aC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZShwYXRoLngsIHBhdGgueSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLmFkZFRvUGF0aChjdHgsIHBhdGguZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhclNwYWNpbmcoc3BhY2luZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRXb3JkU3BhY2luZyhzcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dEhTY2FsZSA9IHNjYWxlIC8gMTAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRMZWFkaW5nKGxlYWRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udChmb250UmVmTmFtZSwgc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250T2JqID0gdGhpcy5jb21tb25PYmpzLmdldChmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9udE9iaikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW4ndCBmaW5kIGZvbnQgZm9yICR7Zm9udFJlZk5hbWV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250TWF0cml4WzBdID09PSAwIHx8IGN1cnJlbnQuZm9udE1hdHJpeFszXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZvbnQgbWF0cml4IGZvciBmb250ICIgKyBmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplID0gLXNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZvbnQgPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZm9udFNpemUgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hbWUgPSBmb250T2JqLmxvYWRlZE5hbWUgfHwgInNhbnMtc2VyaWYiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm9sZCA9ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5ibGFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGZvbnRPYmouYm9sZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICJib2xkIjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGFsaWMgPSBmb250T2JqLml0YWxpYyA/ICJpdGFsaWMiIDogIm5vcm1hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVmYWNlID0gYCIke25hbWV9IiwgJHtmb250T2JqLmZhbGxiYWNrTmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnJvd3NlckZvbnRTaXplID0gc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCBNSU5fRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNSU5fRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNpemUgPiBNQVhfRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNQVhfRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5mb250U2l6ZVNjYWxlID0gc2l6ZSAvIGJyb3dzZXJGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZm9udCA9IGAke2l0YWxpY30gJHtib2xkfSAke2Jyb3dzZXJGb250U2l6ZX1weCAke3R5cGVmYWNlfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRSZW5kZXJpbmdNb2RlKG1vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID0gbW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJpc2UocmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dFJpc2UgPSByaXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYICs9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC55ID0gdGhpcy5jdXJyZW50LmxpbmVZICs9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmdNb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dCgwLCB0aGlzLmN1cnJlbnQubGVhZGluZyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Q2hhcihjaGFyYWN0ZXIsIHgsIHksIHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnQgPSBjdXJyZW50LmZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRSZW5kZXJpbmdNb2RlID0gY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udFNpemUgPSBjdXJyZW50LmZvbnRTaXplIC8gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNBZGRUb1BhdGhTZXQgPSAhISh0ZXh0UmVuZGVyaW5nTW9kZSAmIF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIX0ZMQUcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuRmlsbCA9IGN1cnJlbnQucGF0dGVybkZpbGwgJiYgIWZvbnQubWlzc2luZ0ZpbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhZGRUb1BhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmRpc2FibGVGb250RmFjZSB8fCBpc0FkZFRvUGF0aFNldCB8fCBwYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoID0gZm9udC5nZXRQYXRoR2VuZXJhdG9yKHRoaXMuY29tbW9uT2JqcywgY2hhcmFjdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5kaXNhYmxlRm9udEZhY2UgfHwgcGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoKGN0eCwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLlNUUk9LRSB8fCBmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsVGV4dChjaGFyYWN0ZXIsIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5TVFJPS0UgfHwgZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkZJTExfU1RST0tFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoY2hhcmFjdGVyLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBZGRUb1BhdGhTZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGhzID0gdGhpcy5wZW5kaW5nVGV4dFBhdGhzIHx8ICh0aGlzLnBlbmRpbmdUZXh0UGF0aHMgPSBbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm06ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRUb1BhdGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dDogY3R4CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygiaXNGb250U3VicGl4ZWxBQUVuYWJsZWQiLCAxMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoMS41LCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCJJIiwgMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxMCwgMTApLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAzOyBpIDwgZGF0YS5sZW5ndGg7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbaV0gPiAwICYmIGRhdGFbaV0gPCAyNTUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzRm9udFN1YnBpeGVsQUFFbmFibGVkIiwgZW5hYmxlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUZXh0KGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2hvd1R5cGUzVGV4dChnbHlwaHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvbnRTaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZVNjYWxlID0gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udERpcmVjdGlvbiA9IGN1cnJlbnQuZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRpY2FsID0gZm9udC52ZXJ0aWNhbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZ0RpciA9IHZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGhBZHZhbmNlU2NhbGUgPSBmb250U2l6ZSAqIGN1cnJlbnQuZm9udE1hdHJpeFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2ltcGxlRmlsbFRleHQgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMICYmICFmb250LmRpc2FibGVGb250RmFjZSAmJiAhY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55ICsgY3VycmVudC50ZXh0UmlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250RGlyZWN0aW9uID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZXh0SFNjYWxlLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVyblRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuID0gY3VycmVudC5maWxsQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVyblRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaW5lV2lkdGggPSBjdXJyZW50LmxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBjdXJyZW50LnRleHRNYXRyaXhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlID09PSAwIHx8IGxpbmVXaWR0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbFN0cm9rZU1vZGUgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCA9IHRoaXMuZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVdpZHRoIC89IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZVNjYWxlICE9PSAxLjApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZVNjYWxlLCBmb250U2l6ZVNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCAvPSBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmlzSW52YWxpZFBERmpzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJzLnB1c2goZ2x5cGgudW5pY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggKz0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcnMuam9pbigiIiksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC54ICs9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IHNwYWNpbmdEaXIgKiBnbHlwaCAqIGZvbnRTaXplIC8gMTAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXN0b3JlTmVlZGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXIgPSBnbHlwaC5mb250Q2hhcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjY2VudCA9IGdseXBoLmFjY2VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHdpZHRoID0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2bWV0cmljID0gZ2x5cGgudm1ldHJpYyB8fCBkZWZhdWx0Vk1ldHJpY3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnggPSAtKGdseXBoLnZtZXRyaWMgPyB2bWV0cmljWzFdIDogd2lkdGggKiAwLjUpICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnkgPSB2bWV0cmljWzJdICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0gdnggLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAoeCArIHZ5KSAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFggPSB4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LnJlbWVhc3VyZSAmJiB3aWR0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWFzdXJlZFdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGNoYXJhY3Rlcikud2lkdGggKiAxMDAwIC8gZm9udFNpemUgKiBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8IG1lYXN1cmVkV2lkdGggJiYgdGhpcy5pc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJTY2FsZVggPSB3aWR0aCAvIG1lYXN1cmVkV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmVOZWVkZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoY2hhcmFjdGVyU2NhbGVYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCAvPSBjaGFyYWN0ZXJTY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh3aWR0aCAhPT0gbWVhc3VyZWRXaWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYICs9ICh3aWR0aCAtIG1lYXN1cmVkV2lkdGgpIC8gMjAwMCAqIGZvbnRTaXplIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2ltcGxlRmlsbFRleHQgJiYgIWFjY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcmFjdGVyLCBzY2FsZWRYLCBzY2FsZWRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50Q2hhcihjaGFyYWN0ZXIsIHNjYWxlZFgsIHNjYWxlZFksIHBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZWRBY2NlbnRYID0gc2NhbGVkWCArIGZvbnRTaXplICogYWNjZW50Lm9mZnNldC54IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZEFjY2VudFkgPSBzY2FsZWRZIC0gZm9udFNpemUgKiBhY2NlbnQub2Zmc2V0LnkgLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludENoYXIoYWNjZW50LmZvbnRDaGFyLCBzY2FsZWRBY2NlbnRYLCBzY2FsZWRBY2NlbnRZLCBwYXR0ZXJuVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyV2lkdGggPSB3aWR0aCAqIHdpZHRoQWR2YW5jZVNjYWxlIC0gc3BhY2luZyAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gY2hhcldpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3RvcmVOZWVkZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0geCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUeXBlM1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZSA9IGN1cnJlbnQuZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnREaXJlY3Rpb24gPSBjdXJyZW50LmZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYWNpbmdEaXIgPSBmb250LnZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRNYXRyaXggPSBjdXJyZW50LmZvbnRNYXRyaXggfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzVGV4dEludmlzaWJsZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLklOVklTSUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGdseXBoLCB3aWR0aCwgc3BhY2luZ0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzVGV4dEludmlzaWJsZSB8fCBmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55KTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIGZvbnREaXJlY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjaW5nTGVuZ3RoID0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zbGF0ZShzcGFjaW5nTGVuZ3RoLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gc3BhY2luZ0xlbmd0aCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvckxpc3QgPSBmb250LmNoYXJQcm9jT3BlcmF0b3JMaXN0W2dseXBoLm9wZXJhdG9yTGlzdElkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUeXBlMyBjaGFyYWN0ZXIgIiR7Z2x5cGgub3BlcmF0b3JMaXN0SWR9IiBpcyBub3QgYXZhaWxhYmxlLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IGdseXBoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZSwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1lZCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW2dseXBoLndpZHRoLCAwXSwgZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IHRyYW5zZm9ybWVkWzBdICogZm9udFNpemUgKyBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh3aWR0aCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gd2lkdGggKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc2luZ1R5cGUzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoKHhXaWR0aCwgeVdpZHRoKSB7fQogICAgICAgICAgICAgICAgICAgIHNldENoYXJXaWR0aEFuZEJvdW5kcyh4V2lkdGgsIHlXaWR0aCwgbGx4LCBsbHksIHVyeCwgdXJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlY3QobGx4LCBsbHksIHVyeCAtIGxseCwgdXJ5IC0gbGx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xpcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29sb3JOX1BhdHRlcm4oSVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJUlswXSA9PT0gIlRpbGluZ1BhdHRlcm4iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IElSWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFzZVRyYW5zZm9ybSA9IHRoaXMuYmFzZVRyYW5zZm9ybSB8fCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzR3JhcGhpY3NGYWN0b3J5ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZUNhbnZhc0dyYXBoaWNzOiBjdHggPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENhbnZhc0dyYXBoaWNzKGN0eCwgdGhpcy5jb21tb25PYmpzLCB0aGlzLm9ianMsIHRoaXMuY2FudmFzRmFjdG9yeSwgdGhpcy5maWx0ZXJGYWN0b3J5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWc6IHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrOiB0aGlzLm1hcmtlZENvbnRlbnRTdGFjawogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IG5ldyBfcGF0dGVybl9oZWxwZXIuVGlsaW5nUGF0dGVybihJUiwgY29sb3IsIHRoaXMuY3R4LCBjYW52YXNHcmFwaGljc0ZhY3RvcnksIGJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2dldFBhdHRlcm4oSVJbMV0sIElSWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc3Ryb2tlU3R5bGUgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxSR0JDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IociwgZywgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0UGF0dGVybihvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF0cml4ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVkUGF0dGVybnMuaGFzKG9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuY2FjaGVkUGF0dGVybnMuZ2V0KG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4gPSAoMCwgX3BhdHRlcm5faGVscGVyLmdldFNoYWRpbmdQYXR0ZXJuKSh0aGlzLmdldE9iamVjdChvYmpJZCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZWRQYXR0ZXJucy5zZXQob2JqSWQsIHBhdHRlcm4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4ubWF0cml4ID0gbWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzaGFkaW5nRmlsbChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSB0aGlzLl9nZXRQYXR0ZXJuKG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IHBhdHRlcm4uZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNIQURJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnYgPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGNhbnZhcy5oZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIDBdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWwgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1ciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDAgPSBNYXRoLm1pbihibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MCA9IE1hdGgubWluKGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gTWF0aC5tYXgoYmxbMF0sIGJyWzBdLCB1bFswXSwgdXJbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSBNYXRoLm1heChibFsxXSwgYnJbMV0sIHVsWzFdLCB1clsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCh4MCwgeTAsIHgxIC0geDAsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFJlY3QoLTFlMTAsIC0xZTEwLCAyZTEwLCAyZTEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UodGhpcy5jdXJyZW50LmdldENsaXBwZWRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJTaG91bGQgbm90IGNhbGwgYmVnaW5JbmxpbmVJbWFnZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIGJlZ2luSW1hZ2VEYXRhIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RCZWdpbihtYXRyaXgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybSguLi5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKSh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZWN0KGJib3hbMF0sIGJib3hbMV0sIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSwgYmJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RFbmQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJhc2VUcmFuc2Zvcm0gPSB0aGlzLmJhc2VUcmFuc2Zvcm1TdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5Hcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuYWN0aXZlU01hc2sgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5pc29sYXRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUT0RPOiBTdXBwb3J0IG5vbi1pc29sYXRlZCBncm91cHMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmtub2Nrb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIktub2Nrb3V0IGdyb3VwcyBub3Qgc3VwcG9ydGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHgudHJhbnNmb3JtKC4uLmdyb3VwLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5iYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkJvdW5kaW5nIGJveCBpcyByZXF1aXJlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm91bmRzID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChncm91cC5iYm94LCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNCb3VuZHMgPSBbMCwgMCwgY3VycmVudEN0eC5jYW52YXMud2lkdGgsIGN1cnJlbnRDdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kcyA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KGJvdW5kcywgY2FudmFzQm91bmRzKSB8fCBbMCwgMCwgMCwgMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKGJvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKGJvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkcmF3bldpZHRoID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1syXSkgLSBvZmZzZXRYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRyYXduSGVpZ2h0ID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1szXSkgLSBvZmZzZXRZLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhd25XaWR0aCA+IE1BWF9HUk9VUF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBkcmF3bldpZHRoIC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bldpZHRoID0gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYXduSGVpZ2h0ID4gTUFYX0dST1VQX1NJWkUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IGRyYXduSGVpZ2h0IC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bkhlaWdodCA9IE1BWF9HUk9VUF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdGFydE5ld1BhdGhBbmRDbGlwQm94KFswLCAwLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FjaGVJZCA9ICJncm91cEF0IiArIHRoaXMuZ3JvdXBMZXZlbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUlkICs9ICJfc21hc2tfIiArIHRoaXMuc21hc2tDb3VudGVyKysgJSAyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdyb3VwQ3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBncm91cEN0eC5zY2FsZSgxIC8gc2NhbGVYLCAxIC8gc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXBDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwQ3R4LnRyYW5zZm9ybSguLi5jdXJyZW50VHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrU3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBzY3JhdGNoQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBncm91cEN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJ0eXBlOiBncm91cC5zbWFzay5zdWJ0eXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhY2tkcm9wOiBncm91cC5zbWFzay5iYWNrZHJvcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zlck1hcDogZ3JvdXAuc21hc2sudHJhbnNmZXJNYXAgfHwgbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydFRyYW5zZm9ybUludmVyc2U6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zZXRUcmFuc2Zvcm0oMSwgMCwgMCwgMSwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q3R4LnRyYW5zbGF0ZShvZmZzZXRYLCBvZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKGN1cnJlbnRDdHgsIGdyb3VwQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBncm91cEN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cFN0YWNrLnB1c2goY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCsrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRHcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyb3VwTGV2ZWwtLTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JvdXBDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5ncm91cFN0YWNrLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguaW1hZ2VTbW9vdGhpbmdFbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5zbWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZW1wU01hc2sgPSB0aGlzLnNtYXNrU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRNdHggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zZXRUcmFuc2Zvcm0oLi4uY3VycmVudE10eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXJ0eUJveCA9IF91dGlsLlV0aWwuZ2V0QXhpYWxBbGlnbmVkQm91bmRpbmdCb3goWzAsIDAsIGdyb3VwQ3R4LmNhbnZhcy53aWR0aCwgZ3JvdXBDdHguY2FudmFzLmhlaWdodF0sIGN1cnJlbnRNdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKGdyb3VwQ3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luQW5ub3RhdGlvbihpZCwgcmVjdCwgdHJhbnNmb3JtLCBtYXRyaXgsIGhhc093bkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlLCBfcmVzdG9yZUluaXRpYWxTdGF0ZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKC4uLnRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocmVjdCkgJiYgcmVjdC5sZW5ndGggPT09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSByZWN0WzNdIC0gcmVjdFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd25DYW52YXMgJiYgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gdHJhbnNmb3JtLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzRdIC09IHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzVdIC09IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCA9IHJlY3Quc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0WzBdID0gcmVjdFsxXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdFsyXSA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3RbM10gPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3NjYWxlWCwgc2NhbGVZXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzV2lkdGggPSBNYXRoLmNlaWwod2lkdGggKiB0aGlzLm91dHB1dFNjYWxlWCAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0hlaWdodCA9IE1hdGguY2VpbChoZWlnaHQgKiB0aGlzLm91dHB1dFNjYWxlWSAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhcyA9IHRoaXMuY2FudmFzRmFjdG9yeS5jcmVhdGUoY2FudmFzV2lkdGgsIGNhbnZhc0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5hbm5vdGF0aW9uQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcC5zZXQoaWQsIGNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybShzY2FsZVgsIDAsIDAsIC1zY2FsZVksIDAsIGhlaWdodCAqIHNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDdHhUb0RlZmF1bHQodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNldEN0eFRvRGVmYXVsdCh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgucmVjdChyZWN0WzBdLCByZWN0WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IENhbnZhc0V4dHJhU3RhdGUodGhpcy5jdHguY2FudmFzLndpZHRoLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4udHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4ubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kQW5ub3RhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvbkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSB0aGlzLmFubm90YXRpb25DYW52YXMuc2F2ZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMuYW5ub3RhdGlvbkNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3QoaW1nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvdW50ID0gaW1nLmNvdW50OwogICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0aGlzLmdldE9iamVjdChpbWcuZGF0YSwgaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaW1nLmNvdW50ID0gY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBnbHlwaCA9IHRoaXMucHJvY2Vzc2luZ1R5cGUzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaC5jb21waWxlZCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQgPSBjb21waWxlVHlwZTNHbHlwaChpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdseXBoLmNvbXBpbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuX2NyZWF0ZU1hc2tDYW52YXMoaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0NhbnZhcyA9IG1hc2suY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKG1hc2tDYW52YXMsIG1hc2sub2Zmc2V0WCwgbWFzay5vZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdFJlcGVhdChpbWcsIHNjYWxlWCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2tld1ggPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2V3WSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWSA9IGFyZ3VtZW50cy5sZW5ndGggPiA0ID8gYXJndW1lbnRzWzRdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9zaXRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDUgPyBhcmd1bWVudHNbNV0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGltZyA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNmb3JtKHNjYWxlWCwgc2tld1gsIHNrZXdZLCBzY2FsZVksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXNrID0gdGhpcy5fY3JlYXRlTWFza0NhbnZhcyhpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIG1hc2sub2Zmc2V0WCAtIGN1cnJlbnRUcmFuc2Zvcm1bNF0sIG1hc2sub2Zmc2V0WSAtIGN1cnJlbnRUcmFuc2Zvcm1bNV0pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwb3NpdGlvbnMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnMgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShjdXJyZW50VHJhbnNmb3JtLCBbc2NhbGVYLCBza2V3WCwgc2tld1ksIHNjYWxlWSwgcG9zaXRpb25zW2ldLCBwb3NpdGlvbnNbaSArIDFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeV0gPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgdHJhbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShtYXNrLmNhbnZhcywgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwKGltYWdlcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNQYXR0ZXJuRmlsbCA9IHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbWFnZSBvZiBpbWFnZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hc2tDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWFza0NhbnZhcyIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0N0eCA9IG1hc2tDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nID0gdGhpcy5nZXRPYmplY3QoZGF0YSwgaW1hZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0QmluYXJ5SW1hZ2VNYXNrKG1hc2tDdHgsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9ICJzb3VyY2UtaW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5maWxsU3R5bGUgPSBpc1BhdHRlcm5GaWxsID8gZmlsbENvbG9yLmdldFBhdHRlcm4obWFza0N0eCwgdGhpcywgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpLCBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTCkgOiBmaWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKDEsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIG1hc2tDYW52YXMuY2FudmFzLCAwLCAwLCB3aWR0aCwgaGVpZ2h0LCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbWdEYXRhID0gdGhpcy5nZXRPYmplY3Qob2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRGVwZW5kZW50IGltYWdlIGlzbid0IHJlYWR5IHlldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0KG9iaklkLCBzY2FsZVgsIHNjYWxlWSwgcG9zaXRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJEZXBlbmRlbnQgaW1hZ2UgaXNuJ3QgcmVhZHkgeWV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHBvc2l0aW9ucy5sZW5ndGg7IGkgPCBpaTsgaSArPSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXAucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBbc2NhbGVYLCAwLCAwLCBzY2FsZVksIHBvc2l0aW9uc1tpXSwgcG9zaXRpb25zW2kgKyAxXV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeDogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5OiAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHc6IHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdEdyb3VwKGltZ0RhdGEsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXMoY3R4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzICE9PSAibm9uZSIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSB0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShjdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9CaXRtYXAoaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9PT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0bWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9IHRoaXMuY3VycmVudC50cmFuc2Zlck1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRtcENhbnZhcy5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0KGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsdGVyID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGltZ1RvUGFpbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWdEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0JpdG1hcChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgSFRNTEVsZW1lbnQgPT09ICJmdW5jdGlvbiIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEhUTUxFbGVtZW50IHx8ICFpbWdEYXRhLmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSBpbWdEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoImlubGluZUltYWdlIiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlRGF0YSh0bXBDdHgsIGltZ0RhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0NhbnZhcyh0bXBDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZCA9IHRoaXMuX3NjYWxlSW1hZ2UoaW1nVG9QYWludCwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KSwgaW1nRGF0YS5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIHNjYWxlZC5pbWcsIDAsIDAsIHNjYWxlZC5wYWludFdpZHRoLCBzY2FsZWQucGFpbnRIZWlnaHQsIDAsIC1oZWlnaHQsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXAoaW1nRGF0YSwgbWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaW1nVG9QYWludDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdUb1BhaW50ID0gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3ID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGggPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRCaW5hcnlJbWFnZURhdGEodG1wQ3R4LCBpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSB0aGlzLmFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZW50cnkudHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxLCAtMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBpbWdUb1BhaW50LCBlbnRyeS54LCBlbnRyeS55LCBlbnRyeS53LCBlbnRyeS5oLCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludFNvbGlkQ29sb3JJbWFnZU1hc2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxSZWN0KDAsIDAsIDEsIDEpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50KHRhZykge30KICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wcyh0YWcsIHByb3BlcnRpZXMpIHt9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50KHRhZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpc2libGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luTWFya2VkQ29udGVudFByb3BzKHRhZywgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFnID09PSAiT0MiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aXNpYmxlOiB0aGlzLm9wdGlvbmFsQ29udGVudENvbmZpZy5pc1Zpc2libGUocHJvcGVydGllcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlzaWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRNYXJrZWRDb250ZW50KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkNvbXBhdCgpIHt9CiAgICAgICAgICAgICAgICAgICAgZW5kQ29tcGF0KCkge30KICAgICAgICAgICAgICAgICAgICBjb25zdW1lUGF0aChjbGlwQm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRW1wdHkgPSB0aGlzLmN1cnJlbnQuaXNFbXB0eUNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC51cGRhdGVDbGlwRnJvbVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZShjbGlwQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFbXB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdDbGlwID09PSBFT19DTElQKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3RhcnROZXdQYXRoQW5kQ2xpcEJveCh0aGlzLmN1cnJlbnQuY2xpcEJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzFdID09PSAwICYmIG1bMl0gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gMSAvIE1hdGgubWluKE1hdGguYWJzKG1bMF0pLCBNYXRoLmFicyhtWzNdKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic0RldCA9IE1hdGguYWJzKG1bMF0gKiBtWzNdIC0gbVsyXSAqIG1bMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5oeXBvdChtWzBdLCBtWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWSA9IE1hdGguaHlwb3QobVsxXSwgbVszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IE1hdGgubWF4KG5vcm1YLCBub3JtWSkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNjYWxlRm9yU3Ryb2tpbmcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCwgc2NhbGVZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5hYnMobVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmFicyhtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGluZVdpZHRoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWCA9IDEgLyBub3JtWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gMSAvIG5vcm1ZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZFhMaW5lV2lkdGggPSBub3JtWCAqIGxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVkWUxpbmVXaWR0aCA9IG5vcm1ZICogbGluZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBzY2FsZWRYTGluZVdpZHRoIDwgMSA/IDEgLyBzY2FsZWRYTGluZVdpZHRoIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gc2NhbGVkWUxpbmVXaWR0aCA8IDEgPyAxIC8gc2NhbGVkWUxpbmVXaWR0aCA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhYnNEZXQgPSBNYXRoLmFicyhtWzBdICogbVszXSAtIG1bMl0gKiBtWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWCA9IE1hdGguaHlwb3QobVswXSwgbVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmh5cG90KG1bMl0sIG1bM10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lV2lkdGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYID0gbm9ybVkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YIC8gYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhc2VBcmVhID0gbGluZVdpZHRoICogYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBub3JtWSA+IGJhc2VBcmVhID8gbm9ybVkgLyBiYXNlQXJlYSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YID4gYmFzZUFyZWEgPyBub3JtWCAvIGJhc2VBcmVhIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gW3NjYWxlWCwgc2NhbGVZXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzY2FsZUFuZFN0cm9rZShzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbc2NhbGVYLCBzY2FsZVldID0gdGhpcy5nZXRTY2FsZUZvclN0cm9raW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGggfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlWCA9PT0gMSAmJiBzY2FsZVkgPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2F2ZWRNYXRyaXgsIHNhdmVkRGFzaGVzLCBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZWRNYXRyaXggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaGVzID0gY3R4LmdldExpbmVEYXNoKCkuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaE9mZnNldCA9IGN0eC5saW5lRGFzaE9mZnNldDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IE1hdGgubWF4KHNjYWxlWCwgc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldExpbmVEYXNoKGN0eC5nZXRMaW5lRGFzaCgpLm1hcCh4ID0+IHggLyBzY2FsZSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgLz0gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNhdmVSZXN0b3JlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnNhdmVkTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChzYXZlZERhc2hlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgPSBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNDb250ZW50VmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMubWFya2VkQ29udGVudFN0YWNrLmxlbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMubWFya2VkQ29udGVudFN0YWNrW2ldLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5DYW52YXNHcmFwaGljcyA9IENhbnZhc0dyYXBoaWNzOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3Jlc3RvcmVJbml0aWFsU3RhdGUyKCkgewogICAgICAgICAgICAgICAgICAgIHdoaWxlICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoIHx8IHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50cmFuc3BhcmVudENhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY29tcG9zaXRlQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMudHJhbnNwYXJlbnRDYW52YXMsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNwYXJlbnRDYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3AgaW4gX3V0aWwuT1BTKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKENhbnZhc0dyYXBoaWNzLnByb3RvdHlwZVtvcF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbX3V0aWwuT1BTW29wXV0gPSBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbb3BdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ3ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVGlsaW5nUGF0dGVybiA9IGV4cG9ydHMuUGF0aFR5cGUgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFNoYWRpbmdQYXR0ZXJuID0gZ2V0U2hhZGluZ1BhdHRlcm47CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY29uc3QgUGF0aFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgRklMTDogIkZpbGwiLAogICAgICAgICAgICAgICAgICAgIFNUUk9LRTogIlN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgU0hBRElORzogIlNoYWRpbmciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXRoVHlwZSA9IFBhdGhUeXBlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gYXBwbHlCb3VuZGluZ0JveChjdHgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGJib3hbM10gLSBiYm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlZ2lvbiA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICByZWdpb24ucmVjdChiYm94WzBdLCBiYm94WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xpcChyZWdpb24pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTaGFkaW5nUGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVNoYWRpbmdQYXR0ZXJuLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgZ2V0UGF0dGVybmAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4gZXh0ZW5kcyBCYXNlU2hhZGluZ1BhdHRlcm4gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKElSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3R5cGUgPSBJUlsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmJveCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb2xvclN0b3BzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AwID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AxID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IwID0gSVJbNl07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IxID0gSVJbN107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF0cml4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUdyYWRpZW50KGN0eCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3R5cGUgPT09ICJheGlhbCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQgPSBjdHguY3JlYXRlTGluZWFyR3JhZGllbnQodGhpcy5fcDBbMF0sIHRoaXMuX3AwWzFdLCB0aGlzLl9wMVswXSwgdGhpcy5fcDFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3R5cGUgPT09ICJyYWRpYWwiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkID0gY3R4LmNyZWF0ZVJhZGlhbEdyYWRpZW50KHRoaXMuX3AwWzBdLCB0aGlzLl9wMFsxXSwgdGhpcy5fcjAsIHRoaXMuX3AxWzBdLCB0aGlzLl9wMVsxXSwgdGhpcy5fcjEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29sb3JTdG9wIG9mIHRoaXMuX2NvbG9yU3RvcHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQuYWRkQ29sb3JTdG9wKGNvbG9yU3RvcFswXSwgY29sb3JTdG9wWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ3JhZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGF0dGVybihjdHgsIG93bmVyLCBpbnZlcnNlLCBwYXRoVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlID09PSBQYXRoVHlwZS5TVFJPS0UgfHwgcGF0aFR5cGUgPT09IFBhdGhUeXBlLkZJTEwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG93bmVyQkJveCA9IG93bmVyLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveChwYXRoVHlwZSwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGN0eCkpIHx8IFswLCAwLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5jZWlsKG93bmVyQkJveFsyXSAtIG93bmVyQkJveFswXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IE1hdGguY2VpbChvd25lckJCb3hbM10gLSBvd25lckJCb3hbMV0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDYW52YXMgPSBvd25lci5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInBhdHRlcm4iLCB3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgucmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgudHJhbnNsYXRlKC1vd25lckJCb3hbMF0sIC1vd25lckJCb3hbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW52ZXJzZSA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGludmVyc2UsIFsxLCAwLCAwLCAxLCBvd25lckJCb3hbMF0sIG93bmVyQkJveFsxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnRyYW5zZm9ybSguLi5vd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2Zvcm0oLi4udGhpcy5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveCh0bXBDdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbGxTdHlsZSA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KHRtcEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IGN0eC5jcmVhdGVQYXR0ZXJuKHRtcENhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgoaW52ZXJzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHAxLCBwMiwgcDMsIGMxLCBjMiwgYzMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb29yZHMgPSBjb250ZXh0LmNvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JzID0gY29udGV4dC5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBkYXRhLmRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvd1NpemUgPSBkYXRhLndpZHRoICogNDsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wOwogICAgICAgICAgICAgICAgICAgIGlmIChjb29yZHNbcDEgKyAxXSA+IGNvb3Jkc1twMiArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHAxOwogICAgICAgICAgICAgICAgICAgICAgICBwMSA9IHAyOwogICAgICAgICAgICAgICAgICAgICAgICBwMiA9IHRtcDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gYzE7CiAgICAgICAgICAgICAgICAgICAgICAgIGMxID0gYzI7CiAgICAgICAgICAgICAgICAgICAgICAgIGMyID0gdG1wOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoY29vcmRzW3AyICsgMV0gPiBjb29yZHNbcDMgKyAxXSkgewogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBwMjsKICAgICAgICAgICAgICAgICAgICAgICAgcDIgPSBwMzsKICAgICAgICAgICAgICAgICAgICAgICAgcDMgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IGMyOwogICAgICAgICAgICAgICAgICAgICAgICBjMiA9IGMzOwogICAgICAgICAgICAgICAgICAgICAgICBjMyA9IHRtcDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvb3Jkc1twMSArIDFdID4gY29vcmRzW3AyICsgMV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gcDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHAxID0gcDI7CiAgICAgICAgICAgICAgICAgICAgICAgIHAyID0gdG1wOwogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBjMTsKICAgICAgICAgICAgICAgICAgICAgICAgYzEgPSBjMjsKICAgICAgICAgICAgICAgICAgICAgICAgYzIgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gKGNvb3Jkc1twMV0gKyBjb250ZXh0Lm9mZnNldFgpICogY29udGV4dC5zY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSAoY29vcmRzW3AxICsgMV0gKyBjb250ZXh0Lm9mZnNldFkpICogY29udGV4dC5zY2FsZVk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeDIgPSAoY29vcmRzW3AyXSArIGNvbnRleHQub2Zmc2V0WCkgKiBjb250ZXh0LnNjYWxlWDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB5MiA9IChjb29yZHNbcDIgKyAxXSArIGNvbnRleHQub2Zmc2V0WSkgKiBjb250ZXh0LnNjYWxlWTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB4MyA9IChjb29yZHNbcDNdICsgY29udGV4dC5vZmZzZXRYKSAqIGNvbnRleHQuc2NhbGVYOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHkzID0gKGNvb3Jkc1twMyArIDFdICsgY29udGV4dC5vZmZzZXRZKSAqIGNvbnRleHQuc2NhbGVZOwogICAgICAgICAgICAgICAgICAgIGlmICh5MSA+PSB5MykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGMxciA9IGNvbG9yc1tjMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMxZyA9IGNvbG9yc1tjMSArIDFdLAogICAgICAgICAgICAgICAgICAgICAgICBjMWIgPSBjb2xvcnNbYzEgKyAyXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjMnIgPSBjb2xvcnNbYzJdLAogICAgICAgICAgICAgICAgICAgICAgICBjMmcgPSBjb2xvcnNbYzIgKyAxXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzJiID0gY29sb3JzW2MyICsgMl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYzNyID0gY29sb3JzW2MzXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzNnID0gY29sb3JzW2MzICsgMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMzYiA9IGNvbG9yc1tjMyArIDJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1pblkgPSBNYXRoLnJvdW5kKHkxKSwKICAgICAgICAgICAgICAgICAgICAgICAgbWF4WSA9IE1hdGgucm91bmQoeTMpOwogICAgICAgICAgICAgICAgICAgIGxldCB4YSwgY2FyLCBjYWcsIGNhYjsKICAgICAgICAgICAgICAgICAgICBsZXQgeGIsIGNiciwgY2JnLCBjYmI7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeSA9IG1pblk7IHkgPD0gbWF4WTsgeSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4YSA9IHgxIC0gKHgxIC0geDIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhciA9IGMxciAtIChjMXIgLSBjMnIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhZyA9IGMxZyAtIChjMWcgLSBjMmcpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhYiA9IGMxYiAtIChjMWIgLSBjMmIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh5MiA9PT0geTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9ICh5MiAtIHkpIC8gKHkyIC0geTMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGEgPSB4MiAtICh4MiAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXIgPSBjMnIgLSAoYzJyIC0gYzNyKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWcgPSBjMmcgLSAoYzJnIC0gYzNnKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWIgPSBjMmIgLSAoYzJiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Myk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgeGIgPSB4MSAtICh4MSAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNiciA9IGMxciAtIChjMXIgLSBjM3IpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgY2JnID0gYzFnIC0gKGMxZyAtIGMzZykgKiBrOwogICAgICAgICAgICAgICAgICAgICAgICBjYmIgPSBjMWIgLSAoYzFiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxXyA9IE1hdGgucm91bmQoTWF0aC5taW4oeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgyXyA9IE1hdGgucm91bmQoTWF0aC5tYXgoeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gcm93U2l6ZSAqIHkgKyB4MV8gKiA0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0geDFfOyB4IDw9IHgyXzsgeCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHhhIC0geCkgLyAoeGEgLSB4Yik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoayA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoayA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSBjYXIgLSAoY2FyIC0gY2JyKSAqIGsgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaisrXSA9IGNhZyAtIChjYWcgLSBjYmcpICogayB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tqKytdID0gY2FiIC0gKGNhYiAtIGNiYikgKiBrIHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBzID0gZmlndXJlLmNvb3JkczsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjcyA9IGZpZ3VyZS5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmlndXJlLnR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibGF0dGljZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNlc1BlclJvdyA9IGZpZ3VyZS52ZXJ0aWNlc1BlclJvdzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvd3MgPSBNYXRoLmZsb29yKHBzLmxlbmd0aCAvIHZlcnRpY2VzUGVyUm93KSAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xzID0gdmVydGljZXNQZXJSb3cgLSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBxID0gaSAqIHZlcnRpY2VzUGVyUm93OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY29sczsgaisrLCBxKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHBzW3FdLCBwc1txICsgMV0sIHBzW3EgKyB2ZXJ0aWNlc1BlclJvd10sIGNzW3FdLCBjc1txICsgMV0sIGNzW3EgKyB2ZXJ0aWNlc1BlclJvd10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIHBzW3EgKyAxXSwgcHNbcSArIHZlcnRpY2VzUGVyUm93XSwgY3NbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIGNzW3EgKyAxXSwgY3NbcSArIHZlcnRpY2VzUGVyUm93XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRyaWFuZ2xlcyI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHBzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbaV0sIHBzW2kgKyAxXSwgcHNbaSArIDJdLCBjc1tpXSwgY3NbaSArIDFdLCBjc1tpICsgMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImlsbGVnYWwgZmlndXJlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTWVzaFNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihJUikgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb29yZHMgPSBJUlsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29sb3JzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZ3VyZXMgPSBJUls0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYm91bmRzID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Jib3ggPSBJUls3XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFja2dyb3VuZCA9IElSWzhdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVNZXNoQ2FudmFzKGNvbWJpbmVkU2NhbGUsIGJhY2tncm91bmRDb2xvciwgY2FjaGVkQ2FudmFzZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRVhQRUNURURfU0NBTEUgPSAxLjE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9QQVRURVJOX1NJWkUgPSAzMDAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBCT1JERVJfU0laRSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvdW5kc1dpZHRoID0gTWF0aC5jZWlsKHRoaXMuX2JvdW5kc1syXSkgLSBvZmZzZXRYOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3VuZHNIZWlnaHQgPSBNYXRoLmNlaWwodGhpcy5fYm91bmRzWzNdKSAtIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5taW4oTWF0aC5jZWlsKE1hdGguYWJzKGJvdW5kc1dpZHRoICogY29tYmluZWRTY2FsZVswXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLm1pbihNYXRoLmNlaWwoTWF0aC5hYnMoYm91bmRzSGVpZ2h0ICogY29tYmluZWRTY2FsZVsxXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVggPSBib3VuZHNXaWR0aCAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVkgPSBib3VuZHNIZWlnaHQgLyBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb29yZHM6IHRoaXMuX2Nvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yczogdGhpcy5fY29sb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogLW9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAtb2Zmc2V0WSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogMSAvIHNjYWxlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogMSAvIHNjYWxlWQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRXaWR0aCA9IHdpZHRoICsgQk9SREVSX1NJWkUgKiAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRIZWlnaHQgPSBoZWlnaHQgKyBCT1JERVJfU0laRSAqIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IGNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWVzaCIsIHBhZGRlZFdpZHRoLCBwYWRkZWRIZWlnaHQsIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0bXBDdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFja2dyb3VuZENvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBieXRlcyA9IGRhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpXSA9IGJhY2tncm91bmRDb2xvclswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpICsgMV0gPSBiYWNrZ3JvdW5kQ29sb3JbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSArIDJdID0gYmFja2dyb3VuZENvbG9yWzJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgKyAzXSA9IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZ3VyZSBvZiB0aGlzLl9maWd1cmVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnB1dEltYWdlRGF0YShkYXRhLCBCT1JERVJfU0laRSwgQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogb2Zmc2V0WCAtIEJPUkRFUl9TSVpFICogc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WTogb2Zmc2V0WSAtIEJPUkRFUl9TSVpFICogc2NhbGVZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oY3R4LCBvd25lciwgaW52ZXJzZSwgcGF0aFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRoVHlwZSA9PT0gUGF0aFR5cGUuU0hBRElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKCgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZShvd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdHJpeFNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZSh0aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBbc2NhbGVbMF0gKiBtYXRyaXhTY2FsZVswXSwgc2NhbGVbMV0gKiBtYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcyA9IHRoaXMuX2NyZWF0ZU1lc2hDYW52YXMoc2NhbGUsIHBhdGhUeXBlID09PSBQYXRoVHlwZS5TSEFESU5HID8gbnVsbCA6IHRoaXMuX2JhY2tncm91bmQsIG93bmVyLmNhY2hlZENhbnZhc2VzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlICE9PSBQYXRoVHlwZS5TSEFESU5HKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLm93bmVyLmJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMubWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWCwgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3R4LmNyZWF0ZVBhdHRlcm4odGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBEdW1teVNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFNoYWRpbmdQYXR0ZXJuKElSKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChJUlswXSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJSYWRpYWxBeGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4oSVIpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNZXNoIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTWVzaFNoYWRpbmdQYXR0ZXJuKElSKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBEdW1teVNoYWRpbmdQYXR0ZXJuKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke0lSWzBdfWApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgUGFpbnRUeXBlID0gewogICAgICAgICAgICAgICAgICAgIENPTE9SRUQ6IDEsCiAgICAgICAgICAgICAgICAgICAgVU5DT0xPUkVEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgVGlsaW5nUGF0dGVybiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBNQVhfUEFUVEVSTl9TSVpFKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIk1BWF9QQVRURVJOX1NJWkUiLCAzMDAwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoSVIsIGNvbG9yLCBjdHgsIGNhbnZhc0dyYXBoaWNzRmFjdG9yeSwgYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IElSWzNdIHx8IFsxLCAwLCAwLCAxLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYm94ID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueHN0ZXAgPSBJUls1XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55c3RlcCA9IElSWzZdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50VHlwZSA9IElSWzddOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbGluZ1R5cGUgPSBJUls4XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXNHcmFwaGljc0ZhY3RvcnkgPSBjYW52YXNHcmFwaGljc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IGJhc2VUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZVBhdHRlcm5DYW52YXMob3duZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JMaXN0ID0gdGhpcy5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJib3ggPSB0aGlzLmJib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhzdGVwID0gdGhpcy54c3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSB0aGlzLnlzdGVwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWludFR5cGUgPSB0aGlzLnBhaW50VHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGlsaW5nVHlwZSA9IHRoaXMudGlsaW5nVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNHcmFwaGljc0ZhY3RvcnkgPSB0aGlzLmNhbnZhc0dyYXBoaWNzRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaWxpbmdUeXBlOiAiICsgdGlsaW5nVHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgwID0gYmJveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkwID0gYmJveFsxXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgxID0gYmJveFsyXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkxID0gYmJveFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VyTWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbWJpbmVkU2NhbGUgPSBbbWF0cml4U2NhbGVbMF0gKiBjdXJNYXRyaXhTY2FsZVswXSwgbWF0cml4U2NhbGVbMV0gKiBjdXJNYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpbXggPSB0aGlzLmdldFNpemVBbmRTY2FsZSh4c3RlcCwgdGhpcy5jdHguY2FudmFzLndpZHRoLCBjb21iaW5lZFNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlteSA9IHRoaXMuZ2V0U2l6ZUFuZFNjYWxlKHlzdGVwLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0LCBjb21iaW5lZFNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gb3duZXIuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJwYXR0ZXJuIiwgZGlteC5zaXplLCBkaW15LnNpemUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JhcGhpY3MgPSBjYW52YXNHcmFwaGljc0ZhY3RvcnkuY3JlYXRlQ2FudmFzR3JhcGhpY3ModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuZ3JvdXBMZXZlbCA9IG93bmVyLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDAgPSB4MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTAgPSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDEgPSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTEgPSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHgwIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRqdXN0ZWRYMCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFgxICs9IE1hdGguYWJzKHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeTAgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFkwID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkanVzdGVkWTEgKz0gTWF0aC5hYnMoeTApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2xhdGUoLShkaW14LnNjYWxlICogYWRqdXN0ZWRYMCksIC0oZGlteS5zY2FsZSAqIGFkanVzdGVkWTApKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MudHJhbnNmb3JtKGRpbXguc2NhbGUsIDAsIDAsIGRpbXkuc2NhbGUsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCYm94KGdyYXBoaWNzLCBhZGp1c3RlZFgwLCBhZGp1c3RlZFkwLCBhZGp1c3RlZFgxLCBhZGp1c3RlZFkxKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShncmFwaGljcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZERyYXdpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhczogdG1wQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogZGlteC5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogZGlteS5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IGFkanVzdGVkWDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBhZGp1c3RlZFkwCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNpemVBbmRTY2FsZShzdGVwLCByZWFsT3V0cHV0U2l6ZSwgc2NhbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RlcCA9IE1hdGguYWJzKHN0ZXApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gTWF0aC5tYXgoVGlsaW5nUGF0dGVybi5NQVhfUEFUVEVSTl9TSVpFLCByZWFsT3V0cHV0U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzaXplID0gTWF0aC5jZWlsKHN0ZXAgKiBzY2FsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUgPSBtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBzaXplIC8gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXBCYm94KGdyYXBoaWNzLCB4MCwgeTAsIHgxLCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94V2lkdGggPSB4MSAtIHgwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94SGVpZ2h0ID0geTEgLSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuY3R4LnJlY3QoeDAsIHkwLCBiYm94V2lkdGgsIGJib3hIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGdyYXBoaWNzLmN0eCksIFt4MCwgeTAsIHgxLCB5MV0pOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSBncmFwaGljcy5jdHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gZ3JhcGhpY3MuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChwYWludFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgUGFpbnRUeXBlLkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC5maWxsU3R5bGUgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5maWxsQ29sb3IgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFBhaW50VHlwZS5VTkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmZpbGxTdHlsZSA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnN1cHBvcnRlZCBwYWludCB0eXBlOiAke3BhaW50VHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKGN0eCwgb3duZXIsIGludmVyc2UsIHBhdGhUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXRyaXggPSBpbnZlcnNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgIT09IFBhdGhUeXBlLlNIQURJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hdHJpeCwgb3duZXIuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRyaXggPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShtYXRyaXgsIHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzID0gdGhpcy5jcmVhdGVQYXR0ZXJuQ2FudmFzKG93bmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZG9tTWF0cml4ID0gZG9tTWF0cml4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRvbU1hdHJpeCA9IGRvbU1hdHJpeC5zY2FsZSgxIC8gdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVgsIDEgLyB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSBjdHguY3JlYXRlUGF0dGVybih0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLmNhbnZhcywgInJlcGVhdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRpbGluZ1BhdHRlcm4gPSBUaWxpbmdQYXR0ZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSA9IGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0VG9SR0JBID0gY29udmVydFRvUkdCQTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ3JheVRvUkdCQSA9IGdyYXlUb1JHQkE7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFRvUkdCQShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHBhcmFtcy5raW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLkdSQVlTQ0FMRV8xQlBQOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb252ZXJ0UkdCVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydEJsYWNrQW5kV2hpdGVUb1JHQkEoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgbm9uQmxhY2tDb2xvciA9IDB4ZmZmZmZmZmYsCiAgICAgICAgICAgICAgICAgICAgICAgIGludmVyc2VEZWNvZGUgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsYWNrID0gX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4gPyAweGZmMDAwMDAwIDogMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbemVyb01hcHBpbmcsIG9uZU1hcHBpbmddID0gaW52ZXJzZURlY29kZSA/IFtub25CbGFja0NvbG9yLCBibGFja10gOiBbYmxhY2ssIG5vbkJsYWNrQ29sb3JdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoSW5Tb3VyY2UgPSB3aWR0aCA+PiAzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUmVtYWluZGVyID0gd2lkdGggJiA3OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyY0xlbmd0aCA9IHNyYy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgZGVzdCA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgbGV0IGRlc3RQb3MgPSAwOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBtYXggPSBzcmNQb3MgKyB3aWR0aEluU291cmNlOyBzcmNQb3MgPCBtYXg7IHNyY1BvcysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1Bvc10gOiAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUmVtYWluZGVyID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1BvcysrXSA6IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aFJlbWFpbmRlcjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMSA8PCA3IC0gaiA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFJHQlRvUkdCQShfcmVmMikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSAwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbjMyID0gc3JjLmxlbmd0aCA+PiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYzMyID0gbmV3IFVpbnQzMkFycmF5KHNyYy5idWZmZXIsIHNyY1BvcywgbGVuMzIpOwogICAgICAgICAgICAgICAgICAgIGlmIChfdXRpbC5GZWF0dXJlVGVzdC5pc0xpdHRsZUVuZGlhbikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPj4+IDI0IHwgczIgPDwgOCB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyID4+PiAxNiB8IHMzIDw8IDE2IHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPj4+IDggfCAweGZmMDAwMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSBpICogNCwgamogPSBzcmMubGVuZ3RoOyBqIDwgamo7IGogKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW2pdIHwgc3JjW2ogKyAxXSA8PCA4IHwgc3JjW2ogKyAyXSA8PCAxNiB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPDwgMjQgfCBzMiA+Pj4gOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyIDw8IDE2IHwgczMgPj4+IDE2IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPDwgOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IGkgKiA0LCBqaiA9IHNyYy5sZW5ndGg7IGogPCBqajsgaiArPSAzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbal0gPDwgMjQgfCBzcmNbaiArIDFdIDw8IDE2IHwgc3JjW2ogKyAyXSA8PCA4IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ3JheVRvUkdCQShzcmMsIGRlc3QpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gc3JjLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbaV0gPSBzcmNbaV0gKiAweDEwMTAxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHNyYy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2ldID0gc3JjW2ldICogMHgxMDEwMTAwIHwgMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuR2xvYmFsV29ya2VyT3B0aW9ucyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IEdsb2JhbFdvcmtlck9wdGlvbnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5HbG9iYWxXb3JrZXJPcHRpb25zID0gR2xvYmFsV29ya2VyT3B0aW9uczsKICAgICAgICAgICAgICAgIEdsb2JhbFdvcmtlck9wdGlvbnMud29ya2VyUG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICBHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyA9ICIiOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBDYWxsYmFja0tpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgVU5LTk9XTjogMCwKICAgICAgICAgICAgICAgICAgICBEQVRBOiAxLAogICAgICAgICAgICAgICAgICAgIEVSUk9SOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY29uc3QgU3RyZWFtS2luZCA9IHsKICAgICAgICAgICAgICAgICAgICBVTktOT1dOOiAwLAogICAgICAgICAgICAgICAgICAgIENBTkNFTDogMSwKICAgICAgICAgICAgICAgICAgICBDQU5DRUxfQ09NUExFVEU6IDIsCiAgICAgICAgICAgICAgICAgICAgQ0xPU0U6IDMsCiAgICAgICAgICAgICAgICAgICAgRU5RVUVVRTogNCwKICAgICAgICAgICAgICAgICAgICBFUlJPUjogNSwKICAgICAgICAgICAgICAgICAgICBQVUxMOiA2LAogICAgICAgICAgICAgICAgICAgIFBVTExfQ09NUExFVEU6IDcsCiAgICAgICAgICAgICAgICAgICAgU1RBUlRfQ09NUExFVEU6IDgKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB3cmFwUmVhc29uKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgIGlmICghKHJlYXNvbiBpbnN0YW5jZW9mIEVycm9yIHx8IHR5cGVvZiByZWFzb24gPT09ICJvYmplY3QiICYmIHJlYXNvbiAhPT0gbnVsbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgnd3JhcFJlYXNvbjogRXhwZWN0ZWQgInJlYXNvbiIgdG8gYmUgYSAocG9zc2libHkgY2xvbmVkKSBFcnJvci4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyZWFzb24ubmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJBYm9ydEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWlzc2luZ1BERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlBhc3N3b3JkRXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlLCByZWFzb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVua25vd25FcnJvckV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLmRldGFpbHMpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5Vbmtub3duRXJyb3JFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UsIHJlYXNvbi50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBNZXNzYWdlSGFuZGxlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlTmFtZSwgdGFyZ2V0TmFtZSwgY29tT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlTmFtZSA9IHNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0TmFtZSA9IHRhcmdldE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqID0gY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrSWQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbUlkID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1TaW5rcyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3Rpb25IYW5kbGVyID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gZXZlbnQuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnRhcmdldE5hbWUgIT09IHRoaXMuc291cmNlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NTdHJlYW1NZXNzYWdlKGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2tJZCA9IGRhdGEuY2FsbGJhY2tJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gdGhpcy5jYWxsYmFja0NhcGFiaWxpdGllc1tjYWxsYmFja0lkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW5ub3QgcmVzb2x2ZSBjYWxsYmFjayAke2NhbGxiYWNrSWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzW2NhbGxiYWNrSWRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrID09PSBDYWxsYmFja0tpbmQuREFUQSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoZGF0YS5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuY2FsbGJhY2sgPT09IENhbGxiYWNrS2luZC5FUlJPUikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlamVjdCh3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIGNhbGxiYWNrIGNhc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9uID0gdGhpcy5hY3Rpb25IYW5kbGVyW2RhdGEuYWN0aW9uXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYlNvdXJjZU5hbWUgPSB0aGlzLnNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2JUYXJnZXROYW1lID0gZGF0YS5zb3VyY2VOYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoYWN0aW9uKGRhdGEuZGF0YSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZTogY2JUYXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tJZDogZGF0YS5jYWxsYmFja0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogcmVzdWx0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IGNiU291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uKGRhdGEuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbihhY3Rpb25OYW1lLCBoYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFoID0gdGhpcy5hY3Rpb25IYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWhbYWN0aW9uTmFtZV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVGhlcmUgaXMgYWxyZWFkeSBhbiBhY3Rpb25OYW1lIGNhbGxlZCAiJHthY3Rpb25OYW1lfSJgKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBhaFthY3Rpb25OYW1lXSA9IGhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlbmQoYWN0aW9uTmFtZSwgZGF0YSwgdHJhbnNmZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogYWN0aW9uTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEKICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VuZFdpdGhQcm9taXNlKGFjdGlvbk5hbWUsIGRhdGEsIHRyYW5zZmVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWxsYmFja0lkID0gdGhpcy5jYWxsYmFja0lkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tDYXBhYmlsaXRpZXNbY2FsbGJhY2tJZF0gPSBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lOiB0aGlzLnRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBhY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZW5kV2l0aFN0cmVhbShhY3Rpb25OYW1lLCBkYXRhLCBxdWV1ZWluZ1N0cmF0ZWd5LCB0cmFuc2ZlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RyZWFtSWQgPSB0aGlzLnN0cmVhbUlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlYWRhYmxlU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiBjb250cm9sbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFydENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRyb2xsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q2FsbDogc3RhcnRDYXBhYmlsaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdWxsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDbG9zZWQ6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246IGFjdGlvbk5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXJ0Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bGw6IGNvbnRyb2xsZXIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bGxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLnB1bGxDYWxsID0gcHVsbENhcGFiaWxpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTEwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwdWxsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogcmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImNhbmNlbCBtdXN0IGhhdmUgYSB2YWxpZCByZWFzb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW5jZWxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmNhbmNlbENhbGwgPSBjYW5jZWxDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmlzQ2xvc2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FuY2VsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCBxdWV1ZWluZ1N0cmF0ZWd5KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxmID0gdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cmVhbVNpbmsgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZmVycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGFzdERlc2lyZWRTaXplID0gdGhpcy5kZXNpcmVkU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc2lyZWRTaXplIC09IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3REZXNpcmVkU2l6ZSA+IDAgJiYgdGhpcy5kZXNpcmVkU2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2lua0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCB0cmFuc2ZlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNMT1NFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzZWxmLnN0cmVhbVNpbmtzW3N0cmVhbUlkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImVycm9yIG11c3QgaGF2ZSBhIHZhbGlkIHJlYXNvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkVSUk9SLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rQ2FwYWJpbGl0eTogKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25QdWxsOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25DYW5jZWw6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0NhbmNlbGxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogZGF0YS5kZXNpcmVkU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWR5OiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLnJlYWR5ID0gc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbVNpbmtzW3N0cmVhbUlkXSA9IHN0cmVhbVNpbms7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGFjdGlvbihkYXRhLmRhdGEsIHN0cmVhbVNpbmspKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuU1RBUlRfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc1N0cmVhbU1lc3NhZ2UoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1Db250cm9sbGVyID0gdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rID0gdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5zdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuc3RhcnRDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnN0YXJ0Q2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuZGVzaXJlZFNpemUgPSBkYXRhLmRlc2lyZWRTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoc3RyZWFtU2luay5vblB1bGwgJiYgc3RyZWFtU2luay5vblB1bGwoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVOUVVFVUU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImVucXVldWUgc2hvdWxkIGhhdmUgc3RyZWFtIGNvbnRyb2xsZXIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyZWFtQ29udHJvbGxlci5pc0Nsb3NlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jb250cm9sbGVyLmVucXVldWUoZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0xPU0U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImNsb3NlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RlbGV0ZVN0cmVhbUNvbnRyb2xsZXIoc3RyZWFtQ29udHJvbGxlciwgc3RyZWFtSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVSUk9SOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlcnJvciBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5lcnJvcih3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jYW5jZWxDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNBTkNFTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiVW5leHBlY3RlZCBzdHJlYW0gY2FzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIF9kZWxldGVTdHJlYW1Db250cm9sbGVyKHN0cmVhbUNvbnRyb2xsZXIsIHN0cmVhbUlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IFByb21pc2UuYWxsU2V0dGxlZChbc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwgJiYgc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwucHJvbWlzZSwgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnByb21pc2UsIHN0cmVhbUNvbnRyb2xsZXIuY2FuY2VsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucHJvbWlzZV0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCB0aGlzLl9vbkNvbU9iak9uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IE1lc3NhZ2VIYW5kbGVyOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBNZXRhZGF0YSB7CiAgICAgICAgICAgICAgICAgICAgI21ldGFkYXRhTWFwOwogICAgICAgICAgICAgICAgICAgICNkYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlZERhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtZXRhZGF0YU1hcCA9IHBhcnNlZERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2RhdGEgPSByYXdEYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNkYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jbWV0YWRhdGFNYXAuZ2V0KG5hbWUpID8/IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKSh0aGlzLiNtZXRhZGF0YU1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNtZXRhZGF0YU1hcC5oYXMobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IE1ldGFkYXRhOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTIgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5PcHRpb25hbENvbnRlbnRDb25maWcgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICA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zZXQuY2FsbChyZWNlaXZlciwgdmFsdWUpOyB9IGVsc2UgeyBpZiAoIWRlc2NyaXB0b3Iud3JpdGFibGUpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIHNldCByZWFkIG9ubHkgcHJpdmF0ZSBmaWVsZCIpOyB9IGRlc2NyaXB0b3IudmFsdWUgPSB2YWx1ZTsgfSB9CiAgICAgICAgICAgICAgICBjb25zdCBJTlRFUk5BTCA9IFN5bWJvbCgiSU5URVJOQUwiKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudEdyb3VwIHsKICAgICAgICAgICAgICAgICAgICAjdmlzaWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobmFtZSwgaW50ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaW50ZW50ID0gaW50ZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgdmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3Zpc2libGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRWaXNpYmxlKGludGVybmFsLCB2aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcm5hbCAhPT0gSU5URVJOQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkludGVybmFsIG1ldGhvZCBgX3NldFZpc2libGVgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiN2aXNpYmxlID0gdmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlZEdldEhhc2ggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfZ3JvdXBzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2luaXRpYWxIYXNoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX29yZGVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudENvbmZpZyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGVkR2V0SGFzaCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2dyb3VwcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaW5pdGlhbEhhc2gsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9vcmRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jcmVhdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBkYXRhLm5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3JlYXRvciA9IGRhdGEuY3JlYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9vcmRlciwgZGF0YS5vcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZ3JvdXAgb2YgZGF0YS5ncm91cHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zZXQoZ3JvdXAuaWQsIG5ldyBPcHRpb25hbENvbnRlbnRHcm91cChncm91cC5uYW1lLCBncm91cC5pbnRlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5iYXNlU3RhdGUgPT09ICJPRkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdyb3VwIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwLl9zZXRWaXNpYmxlKElOVEVSTkFMLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvbiBvZiBkYXRhLm9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KG9uKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvZmYgb2YgZGF0YS5vZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQob2ZmKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaW5pdGlhbEhhc2gsIHRoaXMuZ2V0SGFzaCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlKGdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3Vwcykuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBkZWZpbmVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ0ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoZ3JvdXAuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtncm91cC5pZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGdyb3VwLmlkKS52aXNpYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ01EIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmV4cHJlc3Npb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZXZhbHVhdGVWaXNpYmlsaXR5RXhwcmVzc2lvbiwgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKS5jYWxsKHRoaXMsIGdyb3VwLmV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5wb2xpY3kgfHwgZ3JvdXAucG9saWN5ID09PSAiQW55T24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpZCBvZiBncm91cC5pZHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtpZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGlkKS52aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnBvbGljeSA9PT0gIkFsbE9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQW55T2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQWxsT2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmdldChpZCkudmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG9wdGlvbmFsIGNvbnRlbnQgcG9saWN5ICR7Z3JvdXAucG9saWN5fS5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBncm91cCB0eXBlICR7Z3JvdXAudHlwZX0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWaXNpYmlsaXR5KGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2aXNpYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9wdGlvbmFsIGNvbnRlbnQgZ3JvdXAgbm90IGZvdW5kOiAke2lkfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLl9zZXRWaXNpYmxlKElOVEVSTkFMLCAhIXZpc2libGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGFzSW5pdGlhbFZpc2liaWxpdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEhhc2goKSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pbml0aWFsSGFzaCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9yZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vcmRlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29yZGVyKS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmtleXMoKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEdyb3VwcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplID4gMCA/ICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKShfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0R3JvdXAoaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEhhc2goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlZEdldEhhc2gpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jYWNoZWRHZXRIYXNoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNoID0gbmV3IF9tdXJtdXJoYXNoLk11cm11ckhhc2gzXzY0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2lkLCBncm91cF0gb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNoLnVwZGF0ZShgJHtpZH06JHtncm91cC52aXNpYmxlfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIGhhc2guaGV4ZGlnZXN0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuT3B0aW9uYWxDb250ZW50Q29uZmlnID0gT3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKGFycmF5KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvciA9IGFycmF5WzBdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24sIF9ldmFsdWF0ZVZpc2liaWxpdHlFeHByZXNzaW9uMikuY2FsbCh0aGlzLCBlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoZWxlbWVudCkudmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7ZWxlbWVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkFuZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiT3IiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJOb3QiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBvcGVyYXRvciA9PT0gIkFuZCI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZiwgcGRmRGF0YVJhbmdlVHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzaXZlRG9uZSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHBkZkRhdGFSYW5nZVRyYW5zcG9ydCwgJ1BERkRhdGFUcmFuc3BvcnRTdHJlYW0gLSBtaXNzaW5nIHJlcXVpcmVkICJwZGZEYXRhUmFuZ2VUcmFuc3BvcnQiIGFyZ3VtZW50LicpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lID0gcHJvZ3Jlc3NpdmVEb25lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGluaXRpYWxEYXRhID09PSBudWxsIHx8IGluaXRpYWxEYXRhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBpbml0aWFsRGF0YS5sZW5ndGgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyID0gaW5pdGlhbERhdGEgaW5zdGFuY2VvZiBVaW50OEFycmF5ICYmIGluaXRpYWxEYXRhLmJ5dGVMZW5ndGggPT09IGluaXRpYWxEYXRhLmJ1ZmZlci5ieXRlTGVuZ3RoID8gaW5pdGlhbERhdGEuYnVmZmVyIDogbmV3IFVpbnQ4QXJyYXkoaW5pdGlhbERhdGEpLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcy5wdXNoKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0ID0gcGRmRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFkaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gIWRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFJhbmdlTGlzdGVuZXIoKGJlZ2luLCBjaHVuaykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzTGlzdGVuZXIoKGxvYWRlZCwgdG90YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIoY2h1bmsgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzaXZlRG9uZUxpc3RlbmVyKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQudHJhbnNwb3J0UmVhZHkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUmVjZWl2ZURhdGEoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBjaHVuayBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgY2h1bmsuYnl0ZUxlbmd0aCA9PT0gY2h1bmsuYnVmZmVyLmJ5dGVMZW5ndGggPyBjaHVuay5idWZmZXIgOiBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmVnaW4gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIuX2VucXVldWUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvdW5kID0gdGhpcy5fcmFuZ2VSZWFkZXJzLnNvbWUoZnVuY3Rpb24gKHJhbmdlUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlUmVhZGVyLl9iZWdpbiAhPT0gYmVnaW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZVJlYWRlci5fZW5xdWV1ZShidWZmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShmb3VuZCwgIl9vblJlY2VpdmVEYXRhIC0gbm8gYFBERkRhdGFUcmFuc3BvcnRTdHJlYW1SYW5nZVJlYWRlcmAgaW5zdGFuY2UgZm91bmQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2dC50b3RhbCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JhbmdlUmVhZGVycyQsIF90aGlzJF9yYW5nZVJlYWRlcnMkJDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmFuZ2VSZWFkZXJzJCA9IHRoaXMuX3JhbmdlUmVhZGVyc1swXSkgPT09IG51bGwgfHwgX3RoaXMkX3JhbmdlUmVhZGVycyQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPSBfdGhpcyRfcmFuZ2VSZWFkZXJzJC5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yYW5nZVJlYWRlcnMkJC5jYWxsKF90aGlzJF9yYW5nZVJlYWRlcnMkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPSBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMuY2FsbChfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vblByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWE0ID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQucHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW1vdmVSYW5nZVJlYWRlcihyZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX3JhbmdlUmVhZGVycy5pbmRleE9mKHJlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGRGF0YVRyYW5zcG9ydFN0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxdWV1ZWRDaHVua3MgPSB0aGlzLl9xdWV1ZWRDaHVua3M7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlcih0aGlzLCBxdWV1ZWRDaHVua3MsIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSwgdGhpcy5fY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmQgPD0gdGhpcy5fcHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhNSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1LmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSBQREZEYXRhVHJhbnNwb3J0U3RyZWFtOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtLCBxdWV1ZWRDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzaXZlRG9uZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gcHJvZ3Jlc3NpdmVEb25lIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfZGlzcGxheV91dGlscy5pc1BkZkZpbGUpKGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lKSA/IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzID0gcXVldWVkQ2h1bmtzIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNodW5rIG9mIHRoaXMuX3F1ZXVlZENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlYWR5ID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS5fZnVsbFJlcXVlc3RSZWFkZXIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSBjaHVuay5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGVhZGVyc1JlYWR5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faGVhZGVyc1JlYWR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUmFuZ2VTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHJlYW0uX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0cmVhbS5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc3RyZWFtLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc2l2ZURvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0sIGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iZWdpbiA9IGJlZ2luOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmQgPSBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0c0NhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdHNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbS5fcmVtb3ZlUmFuZ2VSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0uX3JlbW92ZVJhbmdlUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU0ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhVGV4dCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNsYXNzIFhmYVRleHQgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0ZXh0Q29udGVudCh4ZmEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3V0cHV0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhub2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX25vZGUkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5vZGUubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYW1lID09PSAiI3RleHQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyID0gbm9kZS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVhmYVRleHQuc2hvdWxkQnVpbGRUZXh0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlICE9PSBudWxsICYmIG5vZGUgIT09IHZvaWQgMCAmJiAoX25vZGUkYXR0cmlidXRlcyA9IG5vZGUuYXR0cmlidXRlcykgIT09IG51bGwgJiYgX25vZGUkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9ub2RlJGF0dHJpYnV0ZXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLmF0dHJpYnV0ZXMudGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0ciAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2Ygbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoY2hpbGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoeGZhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNob3VsZEJ1aWxkVGV4dChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKG5hbWUgPT09ICJ0ZXh0YXJlYSIgfHwgbmFtZSA9PT0gImlucHV0IiB8fCBuYW1lID09PSAib3B0aW9uIiB8fCBuYW1lID09PSAic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5YZmFUZXh0ID0gWGZhVGV4dDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5Ob2RlRmlsdGVyRmFjdG9yeSA9IGV4cG9ydHMuTm9kZUNhbnZhc0ZhY3RvcnkgPSBleHBvcnRzLk5vZGVDTWFwUmVhZGVyRmFjdG9yeSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgZmV0Y2hEYXRhID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZEZpbGUodXJsLCAoZXJyb3IsIGRhdGEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciB8fCAhZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoZXJyb3IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHt9CiAgICAgICAgICAgICAgICBleHBvcnRzLk5vZGVGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlQ2FudmFzRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNhbnZhc0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDYW52YXMgPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIENhbnZhcy5jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ2FudmFzRmFjdG9yeSA9IE5vZGVDYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUNNYXBSZWFkZXJGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsLCBjb21wcmVzc2lvblR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpLnRoZW4oZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBEYXRhOiBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXByZXNzaW9uVHlwZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGh0dHAgPSByZXF1aXJlKCJodHRwIik7CiAgICAgICAgICAgICAgICBjb25zdCBodHRwcyA9IHJlcXVpcmUoImh0dHBzIik7CiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSByZXF1aXJlKCJ1cmwiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVVcmlSZWdleCA9IC9eZmlsZTpcL1wvXC9bYS16QS1aXTpcLy87CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBwYXJzZVVybChzb3VyY2VVcmwpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJzZWRVcmwgPSB1cmwucGFyc2Uoc291cmNlVXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VkVXJsLnByb3RvY29sID09PSAiZmlsZToiIHx8IHBhcnNlZFVybC5ob3N0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZWRVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgvXlthLXpdOlsvXFxdL2kudGVzdChzb3VyY2VVcmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwucGFyc2UoYGZpbGU6Ly8vJHtzb3VyY2VVcmx9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghcGFyc2VkVXJsLmhvc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VkVXJsLnByb3RvY29sID0gImZpbGU6IjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlZFVybDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChzb3VyY2UudXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0h0dHAgPSB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHA6IiB8fCB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNGc1VybCA9IHRoaXMudXJsLnByb3RvY29sID09PSAiZmlsZToiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmh0dHBIZWFkZXJzID0gdGhpcy5pc0h0dHAgJiYgc291cmNlLmh0dHBIZWFkZXJzIHx8IHt9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRGdWxsUmVhZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIsICJQREZOb2RlU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gdGhpcy5pc0ZzVXJsID8gbmV3IFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIodGhpcykgOiBuZXcgUERGTm9kZVN0cmVhbUZ1bGxSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmFuZ2VSZWFkZXIoc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5kIDw9IHRoaXMuX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLmlzRnNVcmwgPyBuZXcgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIodGhpcywgc3RhcnQsIGVuZCkgOiBuZXcgUERGTm9kZVN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmFuZ2VSZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmFuZ2VSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbEFsbFJlcXVlc3RzKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMi5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWFkZXIgb2YgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zbGljZSgwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gUERGTm9kZVN0cmVhbTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzb3VyY2UubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGFibGVTdHJlYW0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5fcmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9yZWRFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdGhpcy5fc3RvcmVkRXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsgPSB0aGlzLl9yZWFkYWJsZVN0cmVhbS5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IHRoaXMuX2xvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiB0aGlzLl9jb250ZW50TGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCAmJiB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oInN0cmVhbWluZyBpcyBkaXNhYmxlZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc3RvcmVkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmRlc3Ryb3kodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkID0gIXNvdXJjZS5kaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IHRoaXMuX3JlYWRhYmxlU3RyZWFtLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgKz0gY2h1bmsubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzczIgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzMi5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHRoaXMuX3N0b3JlZEVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlcXVlc3RPcHRpb25zKHBhcnNlZFVybCwgaGVhZGVycykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvY29sOiBwYXJzZWRVcmwucHJvdG9jb2wsCiAgICAgICAgICAgICAgICAgICAgICAgIGF1dGg6IHBhcnNlZFVybC5hdXRoLAogICAgICAgICAgICAgICAgICAgICAgICBob3N0OiBwYXJzZWRVcmwuaG9zdG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IHBhcnNlZFVybC5wb3J0LAogICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBwYXJzZWRVcmwucGF0aCwKICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtRnVsbFJlYWRlciBleHRlbmRzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoc3RyZWFtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFuZGxlUmVzcG9uc2UgPSByZXNwb25zZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uuc3RhdHVzQ29kZSA9PT0gNDA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXJyb3IgPSBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbihgTWlzc2luZyBQREYgIiR7dGhpcy5fdXJsfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFJlc3BvbnNlSGVhZGVyID0gbmFtZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmhlYWRlcnNbbmFtZS50b0xvd2VyQ2FzZSgpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9ICgwLCBfbmV0d29ya191dGlscy52YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllcykoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzSHR0cDogc3RyZWFtLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZUNodW5rU2l6ZTogdGhpcy5fcmFuZ2VDaHVua1NpemUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlOiB0aGlzLl9kaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGFsbG93UmFuZ2VSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdWdnZXN0ZWRMZW5ndGggfHwgdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCBzdHJlYW0uaHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0ID0gaHR0cHMucmVxdWVzdChjcmVhdGVSZXF1ZXN0T3B0aW9ucyh0aGlzLl91cmwsIHN0cmVhbS5odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0Lm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5lbmQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9odHRwSGVhZGVycyA9IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIHN0cmVhbS5odHRwSGVhZGVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBzdHJlYW0uaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzW3Byb3BlcnR5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzLlJhbmdlID0gYGJ5dGVzPSR7c3RhcnR9LSR7ZW5kIC0gMX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYW5kbGVSZXNwb25zZSA9IHJlc3BvbnNlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXNDb2RlID09PSA0MDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlcnJvciA9IG5ldyBfdXRpbC5NaXNzaW5nUERGRXhjZXB0aW9uKGBNaXNzaW5nIFBERiAiJHt0aGlzLl91cmx9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IGVycm9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCB0aGlzLl9odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwcy5yZXF1ZXN0KGNyZWF0ZVJlcXVlc3RPcHRpb25zKHRoaXMuX3VybCwgdGhpcy5faHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5vbigiZXJyb3IiLCByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0LmVuZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIgZXh0ZW5kcyBCYXNlRnVsbFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHN0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGVjb2RlVVJJQ29tcG9uZW50KHRoaXMuX3VybC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGVVcmlSZWdleC50ZXN0KHRoaXMuX3VybC5ocmVmKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCA9IHBhdGgucmVwbGFjZSgvXlwvLywgIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZzLmxzdGF0KHBhdGgsIChlcnJvciwgc3RhdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yLmNvZGUgPT09ICJFTk9FTlQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oYE1pc3NpbmcgUERGICIke3BhdGh9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdGF0LnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRlY29kZVVSSUNvbXBvbmVudCh0aGlzLl91cmwucGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlVXJpUmVnZXgudGVzdCh0aGlzLl91cmwuaHJlZikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoLnJlcGxhY2UoL15cLy8sICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBlbmQgLSAxCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IgPSBjcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yOwogICAgICAgICAgICAgICAgZXhwb3J0cy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyID0gZXh0cmFjdEZpbGVuYW1lRnJvbUhlYWRlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMgPSB2YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllczsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cyA9IHZhbGlkYXRlUmVzcG9uc2VTdGF0dXM7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9jb250ZW50X2Rpc3Bvc2l0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gdmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCByZXR1cm5WYWx1ZXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0czogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aDogdW5kZWZpbmVkCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBwYXJzZUludChnZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1MZW5ndGgiKSwgMTApOwogICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihsZW5ndGgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5zdWdnZXN0ZWRMZW5ndGggPSBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8PSAyICogcmFuZ2VDaHVua1NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldHVyblZhbHVlczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRpc2FibGVSYW5nZSB8fCAhaXNIdHRwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChnZXRSZXNwb25zZUhlYWRlcigiQWNjZXB0LVJhbmdlcyIpICE9PSAiYnl0ZXMiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnRFbmNvZGluZyA9IGdldFJlc3BvbnNlSGVhZGVyKCJDb250ZW50LUVuY29kaW5nIikgfHwgImlkZW50aXR5IjsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudEVuY29kaW5nICE9PSAiaWRlbnRpdHkiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5hbGxvd1JhbmdlUmVxdWVzdHMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBleHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKGdldFJlc3BvbnNlSGVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY29udGVudERpc3Bvc2l0aW9uID0gZ2V0UmVzcG9uc2VIZWFkZXIoIkNvbnRlbnQtRGlzcG9zaXRpb24iKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudERpc3Bvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9ICgwLCBfY29udGVudF9kaXNwb3NpdGlvbi5nZXRGaWxlbmFtZUZyb21Db250ZW50RGlzcG9zaXRpb25IZWFkZXIpKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gZGVjb2RlVVJJQ29tcG9uZW50KGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoMCwgX2Rpc3BsYXlfdXRpbHMuaXNQZGZGaWxlKShmaWxlbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3Ioc3RhdHVzLCB1cmwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09PSA0MDQgfHwgc3RhdHVzID09PSAwICYmIHVybC5zdGFydHNXaXRoKCJmaWxlOiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbignTWlzc2luZyBQREYgIicgKyB1cmwgKyAnIi4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oYFVuZXhwZWN0ZWQgc2VydmVyIHJlc3BvbnNlICgke3N0YXR1c30pIHdoaWxlIHJldHJpZXZpbmcgUERGICIke3VybH0iLmAsIHN0YXR1cyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB2YWxpZGF0ZVJlc3BvbnNlU3RhdHVzKHN0YXR1cykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IDIwMCB8fCBzdGF0dXMgPT09IDIwNjsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU4ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyID0gZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEZpbGVuYW1lRnJvbUNvbnRlbnREaXNwb3NpdGlvbkhlYWRlcihjb250ZW50RGlzcG9zaXRpb24pIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZHNFbmNvZGluZ0ZpeHVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCoiLCAiaSIpLmV4ZWMoY29udGVudERpc3Bvc2l0aW9uKTsKICAgICAgICAgICAgICAgICAgICBpZiAodG1wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHRtcFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZpbGVuYW1lID0gcmZjMjYxNnVucXVvdGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsZW5hbWUgPSB1bmVzY2FwZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjNTk4N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjMjA0N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXh1cEVuY29kaW5nKGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG1wID0gcmZjMjIzMWdldHBhcmFtKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRtcCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpeHVwRW5jb2RpbmcoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0bXAgPSB0b1BhcmFtUmVnRXhwKCJmaWxlbmFtZSIsICJpIikuZXhlYyhjb250ZW50RGlzcG9zaXRpb24pOwogICAgICAgICAgICAgICAgICAgIGlmICh0bXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gdG1wWzFdOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmlsZW5hbWUgPSByZmMyNjE2dW5xdW90ZSh0bXApOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZml4dXBFbmNvZGluZyhmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHRvUGFyYW1SZWdFeHAoYXR0cmlidXRlUGF0dGVybiwgZmxhZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZWdFeHAoIig/Ol58OylcXHMqIiArIGF0dHJpYnV0ZVBhdHRlcm4gKyAiXFxzKj1cXHMqIiArICIoIiArICdbXiI7XFxzXVteO1xcc10qJyArICJ8IiArICciKD86W14iXFxcXF18XFxcXCI/KSsiPycgKyAiKSIsIGZsYWdzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gdGV4dGRlY29kZShlbmNvZGluZywgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS9eW1x4MDAtXHhGRl0rJC8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gZGVjb2Rlci5kZWNvZGUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkc0VuY29kaW5nRml4dXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaXh1cEVuY29kaW5nKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXAgJiYgL1tceDgwLVx4ZmZdLy50ZXN0KHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSB0ZXh0ZGVjb2RlKCJ1dGYtOCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRleHRkZWNvZGUoImlzby04ODU5LTEiLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmMyMjMxZ2V0cGFyYW0oY29udGVudERpc3Bvc2l0aW9uU3RyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hdGNoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVyID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCooKD8hMFxcZClcXGQrKShcXCo/KSIsICJpZyIpOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKG1hdGNoID0gaXRlci5leGVjKGNvbnRlbnREaXNwb3NpdGlvblN0cikpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgWywgbiwgcXVvdCwgcGFydF0gPSBtYXRjaDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG4gPSBwYXJzZUludChuLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobiBpbiBtYXRjaGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hlc1tuXSA9IFtxdW90LCBwYXJ0XTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IG1hdGNoZXMubGVuZ3RoOyArK24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKG4gaW4gbWF0Y2hlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbcXVvdCwgcGFydF0gPSBtYXRjaGVzW25dOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzI2MTZ1bnF1b3RlKHBhcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHF1b3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0ID0gdW5lc2NhcGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzU5ODdkZWNvZGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydHMucHVzaChwYXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGFydHMuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzI2MTZ1bnF1b3RlKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZS5zdGFydHNXaXRoKCciJykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhcnRzID0gdmFsdWUuc2xpY2UoMSkuc3BsaXQoJ1xcIicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXJ0cy5sZW5ndGg7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHF1b3RpbmRleCA9IHBhcnRzW2ldLmluZGV4T2YoJyInKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocXVvdGluZGV4ICE9PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnNsaWNlKDAsIHF1b3RpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRzLmxlbmd0aCA9IGkgKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnJlcGxhY2VBbGwoL1xcKC4pL2csICIkMSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBwYXJ0cy5qb2luKCciJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmM1OTg3ZGVjb2RlKGV4dHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuY29kaW5nZW5kID0gZXh0dmFsdWUuaW5kZXhPZigiJyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5jb2RpbmdlbmQgPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXh0dmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5jb2RpbmcgPSBleHR2YWx1ZS5zbGljZSgwLCBlbmNvZGluZ2VuZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhbmd2YWx1ZSA9IGV4dHZhbHVlLnNsaWNlKGVuY29kaW5nZW5kICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gbGFuZ3ZhbHVlLnJlcGxhY2UoL15bXiddKicvLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZXh0ZGVjb2RlKGVuY29kaW5nLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzIwNDdkZWNvZGUodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF2YWx1ZS5zdGFydHNXaXRoKCI9PyIpIHx8IC9bXHgwMC1ceDE5XHg4MC1ceGZmXS8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWUucmVwbGFjZUFsbCgvPVw/KFtcdy1dKilcPyhbUXFCYl0pXD8oKD86W14/XXxcPyg/IT0pKSopXD89L2csIGZ1bmN0aW9uIChtYXRjaGVzLCBjaGFyc2V0LCBlbmNvZGluZywgdGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nID09PSAicSIgfHwgZW5jb2RpbmcgPT09ICJRIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoIl8iLCAiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoLz0oWzAtOWEtZkEtRl17Mn0pL2csIGZ1bmN0aW9uIChtYXRjaCwgaGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHBhcnNlSW50KGhleCwgMTYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dGRlY29kZShjaGFyc2V0LCB0ZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dCA9IGF0b2IodGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRleHRkZWNvZGUoY2hhcnNldCwgdGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1OSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERk5ldHdvcmtTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9uZXR3b3JrX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTcpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgT0tfUkVTUE9OU0UgPSAyMDA7CiAgICAgICAgICAgICAgICBjb25zdCBQQVJUSUFMX0NPTlRFTlRfUkVTUE9OU0UgPSAyMDY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih4aHIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0geGhyLnJlc3BvbnNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YSAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykoZGF0YSkuYnVmZmVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTmV0d29ya01hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYXJncyA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXJsID0gdXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3QodXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5odHRwSGVhZGVycyA9IHRoaXMuaXNIdHRwICYmIGFyZ3MuaHR0cEhlYWRlcnMgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aXRoQ3JlZGVudGlhbHMgPSBhcmdzLndpdGhDcmVkZW50aWFscyB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZXRYaHIgPSBhcmdzLmdldFhociB8fCBmdW5jdGlvbiBOZXR3b3JrTWFuYWdlcl9nZXRYaHIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VyclhocklkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nUmVxdWVzdHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXF1ZXN0UmFuZ2UoYmVnaW4sIGVuZCwgbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3AgaW4gbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzW3Byb3BdID0gbGlzdGVuZXJzW3Byb3BdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoYXJncyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3RGdWxsKGxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZXF1ZXN0KGxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3QoYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHIgPSB0aGlzLmdldFhocigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHJJZCA9IHRoaXMuY3VyclhocklkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5vcGVuKCJHRVQiLCB0aGlzLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci53aXRoQ3JlZGVudGlhbHMgPSB0aGlzLndpdGhDcmVkZW50aWFsczsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwcm9wZXJ0eSBpbiB0aGlzLmh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhoci5zZXRSZXF1ZXN0SGVhZGVyKHByb3BlcnR5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNIdHRwICYmICJiZWdpbiIgaW4gYXJncyAmJiAiZW5kIiBpbiBhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4aHIuc2V0UmVxdWVzdEhlYWRlcigiUmFuZ2UiLCBgYnl0ZXM9JHthcmdzLmJlZ2lufS0ke2FyZ3MuZW5kIC0gMX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0LmV4cGVjdGVkU3RhdHVzID0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPSBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIucmVzcG9uc2VUeXBlID0gImFycmF5YnVmZmVyIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3Mub25FcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyLm9uZXJyb3IgPSBmdW5jdGlvbiAoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJncy5vbkVycm9yKHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25yZWFkeXN0YXRlY2hhbmdlID0gdGhpcy5vblN0YXRlQ2hhbmdlLmJpbmQodGhpcywgeGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25wcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcy5iaW5kKHRoaXMsIHhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQgPSBhcmdzLm9uSGVhZGVyc1JlY2VpdmVkOwogICAgICAgICAgICAgICAgICAgICAgICBwZW5kaW5nUmVxdWVzdC5vbkRvbmUgPSBhcmdzLm9uRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25FcnJvciA9IGFyZ3Mub25FcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Qcm9ncmVzcyA9IGFyZ3Mub25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgeGhyLnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25Qcm9ncmVzcyh4aHJJZCwgZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25Qcm87CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXBlbmRpbmdSZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvblBybyA9IHBlbmRpbmdSZXF1ZXN0Lm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9wZW5kaW5nUmVxdWVzdCRvblBybyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uUHJvLmNhbGwocGVuZGluZ1JlcXVlc3QsIGV2dCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uU3RhdGVDaGFuZ2UoeGhySWQsIGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwZW5kaW5nUmVxdWVzdCA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwZW5kaW5nUmVxdWVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHBlbmRpbmdSZXF1ZXN0LnhocjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlID49IDIgJiYgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0Lm9uSGVhZGVyc1JlY2VpdmVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlICE9PSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoeGhySWQgaW4gdGhpcy5wZW5kaW5nUmVxdWVzdHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5zdGF0dXMgPT09IDAgJiYgdGhpcy5pc0h0dHApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIuY2FsbChwZW5kaW5nUmVxdWVzdCwgeGhyLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeGhyU3RhdHVzID0geGhyLnN0YXR1cyB8fCBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2tfcmVzcG9uc2Vfb25fcmFuZ2VfcmVxdWVzdCA9IHhoclN0YXR1cyA9PT0gT0tfUkVTUE9OU0UgJiYgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPT09IFBBUlRJQUxfQ09OVEVOVF9SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFva19yZXNwb25zZV9vbl9yYW5nZV9yZXF1ZXN0ICYmIHhoclN0YXR1cyAhPT0gcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvbkVycjIgPSBwZW5kaW5nUmVxdWVzdC5vbkVycm9yKSA9PT0gbnVsbCB8fCBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyLmNhbGwocGVuZGluZ1JlcXVlc3QsIHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gZ2V0QXJyYXlCdWZmZXIoeGhyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoclN0YXR1cyA9PT0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZUhlYWRlciA9IHhoci5nZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1SYW5nZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2hlcyA9IC9ieXRlcyAoXGQrKS0oXGQrKVwvKFxkKykvLmV4ZWMocmFuZ2VIZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogcGFyc2VJbnQobWF0Y2hlc1sxXSwgMTApLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNodW5rCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaHVuawogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfcGVuZGluZ1JlcXVlc3Qkb25FcnIzID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMy5jYWxsKHBlbmRpbmdSZXF1ZXN0LCB4aHIuc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZXF1ZXN0WGhyKHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF0ueGhyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpc1BlbmRpbmdSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZCBpbiB0aGlzLnBlbmRpbmdSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWJvcnRSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXS54aHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5ldHdvcmtTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zb3VyY2UgPSBzb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIgPSBuZXcgTmV0d29ya01hbmFnZXIoc291cmNlLnVybCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHR0cEhlYWRlcnM6IHNvdXJjZS5odHRwSGVhZGVycywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhDcmVkZW50aWFsczogc291cmNlLndpdGhDcmVkZW50aWFscwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VDaHVua1NpemUgPSBzb3VyY2UucmFuZ2VDaHVua1NpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25SYW5nZVJlcXVlc3RSZWFkZXJDbG9zZWQocmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGkgPSB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLmluZGV4T2YocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGTmV0d29ya1N0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIodGhpcy5fbWFuYWdlciwgdGhpcy5fc291cmNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtUmFuZ2VSZXF1ZXN0UmVhZGVyKHRoaXMuX21hbmFnZXIsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIub25DbG9zZWQgPSB0aGlzLl9vblJhbmdlUmVxdWVzdFJlYWRlckNsb3NlZC5iaW5kKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVhZGVyIG9mIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGTmV0d29ya1N0cmVhbSA9IFBERk5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1hbmFnZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uSGVhZGVyc1JlY2VpdmVkOiB0aGlzLl9vbkhlYWRlcnNSZWNlaXZlZC5iaW5kKHRoaXMpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25Eb25lOiB0aGlzLl9vbkRvbmUuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3I6IHRoaXMuX29uRXJyb3IuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uUHJvZ3Jlc3M6IHRoaXMuX29uUHJvZ3Jlc3MuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdElkID0gbWFuYWdlci5yZXF1ZXN0RnVsbChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzYWJsZVJhbmdlID0gc291cmNlLmRpc2FibGVSYW5nZSB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IHNvdXJjZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25IZWFkZXJzUmVjZWl2ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZ1bGxSZXF1ZXN0WGhySWQgPSB0aGlzLl9mdWxsUmVxdWVzdElkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsUmVxdWVzdFhociA9IHRoaXMuX21hbmFnZXIuZ2V0UmVxdWVzdFhocihmdWxsUmVxdWVzdFhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdWxsUmVxdWVzdFhoci5nZXRSZXNwb25zZUhlYWRlcihuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VnZ2VzdGVkTGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNIdHRwOiB0aGlzLl9tYW5hZ2VyLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplOiB0aGlzLl9yYW5nZUNodW5rU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxsb3dSYW5nZVJlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KGZ1bGxSZXF1ZXN0WGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Eb25lKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZGF0YS5jaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQ2h1bmtzLnB1c2goZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYWNoZWRDaHVua3MubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgb2YgdGhpcy5fcmVxdWVzdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMubGVuZ3RoID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uRXJyb3Ioc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0b3JlZEVycm9yID0gKDAsIF9uZXR3b3JrX3V0aWxzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IpKHN0YXR1cywgdGhpcy5fdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZENodW5rcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC5sZW5ndGhDb21wdXRhYmxlID8gZXZ0LnRvdGFsIDogdGhpcy5fY29udGVudExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGZpbGVuYW1lKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1JhbmdlU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNSYW5nZVN1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzU3RyZWFtaW5nU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhlYWRlcnNSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2FjaGVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fY2FjaGVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX2Z1bGxSZXF1ZXN0SWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyLmFib3J0UmVxdWVzdCh0aGlzLl9mdWxsUmVxdWVzdElkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTmV0d29ya1N0cmVhbVJhbmdlUmVxdWVzdFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWFuYWdlciwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRG9uZTogdGhpcy5fb25Eb25lLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yOiB0aGlzLl9vbkVycm9yLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvblByb2dyZXNzOiB0aGlzLl9vblByb2dyZXNzLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gbWFuYWdlci51cmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RJZCA9IG1hbmFnZXIucmVxdWVzdFJhbmdlKGJlZ2luLCBlbmQsIGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvbmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25DbG9zZWQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xvc2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRvbkNsb3NlZDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uQ2xvc2VkID0gdGhpcy5vbkNsb3NlZCkgPT09IG51bGwgfHwgX3RoaXMkb25DbG9zZWQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uQ2xvc2VkLmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vbkRvbmUoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IGRhdGEuY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmsgPSBjaHVuazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25FcnJvcihzdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSAoMCwgX25ldHdvcmtfdXRpbHMuY3JlYXRlUmVzcG9uc2VTdGF0dXNFcnJvcikoc3RhdHVzLCB0aGlzLl91cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUHJvZ3Jlc3MoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc1N0cmVhbWluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MyID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzczIuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmsgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUZldGNoT3B0aW9ucyhoZWFkZXJzLCB3aXRoQ3JlZGVudGlhbHMsIGFib3J0Q29udHJvbGxlcikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogIkdFVCIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbDogYWJvcnRDb250cm9sbGVyLnNpZ25hbCwKICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogImNvcnMiLAogICAgICAgICAgICAgICAgICAgICAgICBjcmVkZW50aWFsczogd2l0aENyZWRlbnRpYWxzID8gImluY2x1ZGUiIDogInNhbWUtb3JpZ2luIiwKICAgICAgICAgICAgICAgICAgICAgICAgcmVkaXJlY3Q6ICJmb2xsb3ciCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUhlYWRlcnMoaHR0cEhlYWRlcnMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWFkZXJzID0gbmV3IEhlYWRlcnMoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIGh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5hcHBlbmQocHJvcGVydHksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhlYWRlcnM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih2YWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmFsIGluc3RhbmNlb2YgVWludDhBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIEFycmF5QnVmZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0QXJyYXlCdWZmZXIgLSB1bmV4cGVjdGVkIGRhdGEgZm9ybWF0OiAke3ZhbH1gKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKS5idWZmZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlID0gc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3Qoc291cmNlLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaHR0cEhlYWRlcnMgPSB0aGlzLmlzSHR0cCAmJiBzb3VyY2UuaHR0cEhlYWRlcnMgfHwge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhLl9sb2FkZWQpID8/IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEZ1bGxSZWFkZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKCF0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciwgIlBERkZldGNoU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbmV3IFBERkZldGNoU3RyZWFtUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFJhbmdlUmVhZGVyKGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuZCA8PSB0aGlzLl9wcm9ncmVzc2l2ZURhdGFMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZGZXRjaFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnNsaWNlKDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gUERGRmV0Y2hTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbSA9IHN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2UgPSBzdHJlYW0uc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93aXRoQ3JlZGVudGlhbHMgPSBzb3VyY2Uud2l0aENyZWRlbnRpYWxzIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc291cmNlLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVJhbmdlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UuaGVhZGVycy5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWdnZXN0ZWRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRSZXNwb25zZUhlYWRlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHA6IHRoaXMuX3N0cmVhbS5pc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VDaHVua1NpemU6IHRoaXMuX3JhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSBhbGxvd1JhbmdlUmVxdWVzdHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfbmV0d29ya191dGlscy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKShnZXRSZXNwb25zZUhlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkICYmIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbChuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIlN0cmVhbWluZyBpcyBkaXNhYmxlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhd2FpdCB0aGlzLl9yZWFkZXIucmVhZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzcy5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IHRoaXMuX2NvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9yZWFkZXIgPSB0aGlzLl9yZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9yZWFkZXIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERkZldGNoU3RyZWFtUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0gPSBzdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhDcmVkZW50aWFscyA9IHNvdXJjZS53aXRoQ3JlZGVudGlhbHMgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzLmFwcGVuZCgiUmFuZ2UiLCBgYnl0ZXM9JHtiZWdpbn0tJHtlbmQgLSAxfWApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZWplY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGF3YWl0IHRoaXMuX3JlYWRlci5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzMiA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzczIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MyLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiB0aGlzLl9sb2FkZWQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjI7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmVhZGVyMiA9IHRoaXMuX3JlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX3JlYWRlcjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLnJlbmRlclRleHRMYXllciA9IHJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXBkYXRlVGV4dExheWVyID0gdXBkYXRlVGV4dExheWVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSID0gMTAwMDAwOwogICAgICAgICAgICAgICAgY29uc3QgREVGQVVMVF9GT05UX1NJWkUgPSAzMDsKICAgICAgICAgICAgICAgIGNvbnN0IERFRkFVTFRfRk9OVF9BU0NFTlQgPSAwLjg7CiAgICAgICAgICAgICAgICBjb25zdCBhc2NlbnRDYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN0eChzaXplLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgIGxldCBjdHg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkICYmIF91dGlsLkZlYXR1cmVUZXN0LmlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCA9IG5ldyBPZmZzY3JlZW5DYW52YXMoc2l6ZSwgc2l6ZSkuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBjdHggPSBjYW52YXMuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBjdHg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBc2NlbnQoZm9udEZhbWlseSwgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRBc2NlbnQgPSBhc2NlbnRDYWNoZS5nZXQoZm9udEZhbWlseSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNhY2hlZEFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkQXNjZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSBnZXRDdHgoREVGQVVMVF9GT05UX1NJWkUsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke0RFRkFVTFRfRk9OVF9TSVpFfXB4ICR7Zm9udEZhbWlseX1gOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1ldHJpY3MgPSBjdHgubWVhc3VyZVRleHQoIiIpOwogICAgICAgICAgICAgICAgICAgIGxldCBhc2NlbnQgPSBtZXRyaWNzLmZvbnRCb3VuZGluZ0JveEFzY2VudDsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVzY2VudCA9IE1hdGguYWJzKG1ldHJpY3MuZm9udEJvdW5kaW5nQm94RGVzY2VudCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYXRpbyA9IGFzY2VudCAvIChhc2NlbnQgKyBkZXNjZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50Q2FjaGUuc2V0KGZvbnRGYW1pbHksIHJhdGlvKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJhdGlvOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSAicmVkIjsKICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoImciLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBsZXQgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgZGVzY2VudCA9IDA7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHBpeGVscy5sZW5ndGggLSAxIC0gMzsgaSA+PSAwOyBpIC09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpeGVsc1tpXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NlbnQgPSBNYXRoLmNlaWwoaSAvIDQgLyBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoIkEiLCAwLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwaXhlbHMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGl4ZWxzW2ldID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gREVGQVVMVF9GT05UX1NJWkUgLSBNYXRoLmZsb29yKGkgLyA0IC8gREVGQVVMVF9GT05UX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICBpZiAoYXNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhdGlvID0gYXNjZW50IC8gKGFzY2VudCArIGRlc2NlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBhc2NlbnRDYWNoZS5zZXQoZm9udEZhbWlseSwgcmF0aW8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmF0aW87CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzY2VudENhY2hlLnNldChmb250RmFtaWx5LCBERUZBVUxUX0ZPTlRfQVNDRU5UKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gREVGQVVMVF9GT05UX0FTQ0VOVDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFwcGVuZFRleHQodGFzaywgZ2VvbSwgc3R5bGVzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5nbGU6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoOiAwLAogICAgICAgICAgICAgICAgICAgICAgICBoYXNUZXh0OiBnZW9tLnN0ciAhPT0gIiIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0VPTDogZ2VvbS5oYXNFT0wsCiAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRTaXplOiAwCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB0YXNrLl90ZXh0RGl2cy5wdXNoKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4ID0gX3V0aWwuVXRpbC50cmFuc2Zvcm0odGFzay5fdHJhbnNmb3JtLCBnZW9tLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFuZ2xlID0gTWF0aC5hdGFuMih0eFsxXSwgdHhbMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gc3R5bGVzW2dlb20uZm9udE5hbWVdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdHlsZS52ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICBhbmdsZSArPSBNYXRoLlBJIC8gMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udEhlaWdodCA9IE1hdGguaHlwb3QodHhbMl0sIHR4WzNdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250QXNjZW50ID0gZm9udEhlaWdodCAqIGdldEFzY2VudChzdHlsZS5mb250RmFtaWx5LCB0YXNrLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGxlZnQsIHRvcDsKICAgICAgICAgICAgICAgICAgICBpZiAoYW5nbGUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdOwogICAgICAgICAgICAgICAgICAgICAgICB0b3AgPSB0eFs1XSAtIGZvbnRBc2NlbnQ7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdICsgZm9udEFzY2VudCAqIE1hdGguc2luKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG9wID0gdHhbNV0gLSBmb250QXNjZW50ICogTWF0aC5jb3MoYW5nbGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvclN0ciA9ICJjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikqIjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZTdHlsZSA9IHRleHREaXYuc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2NvbnRhaW5lciA9PT0gdGFzay5fcm9vdENvbnRhaW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5sZWZ0ID0gYCR7KDEwMCAqIGxlZnQgLyB0YXNrLl9wYWdlV2lkdGgpLnRvRml4ZWQoMil9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLnRvcCA9IGAkeygxMDAgKiB0b3AgLyB0YXNrLl9wYWdlSGVpZ2h0KS50b0ZpeGVkKDIpfSVgOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmxlZnQgPSBgJHtzY2FsZUZhY3RvclN0cn0ke2xlZnQudG9GaXhlZCgyKX1weClgOwogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS50b3AgPSBgJHtzY2FsZUZhY3RvclN0cn0ke3RvcC50b0ZpeGVkKDIpfXB4KWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmZvbnRTaXplID0gYCR7c2NhbGVGYWN0b3JTdHJ9JHtmb250SGVpZ2h0LnRvRml4ZWQoMil9cHgpYDsKICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5mb250RmFtaWx5ID0gc3R5bGUuZm9udEZhbWlseTsKICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5mb250U2l6ZSA9IGZvbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAicHJlc2VudGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi50ZXh0Q29udGVudCA9IGdlb20uc3RyOwogICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGlyID0gZ2VvbS5kaXI7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2ZvbnRJbnNwZWN0b3JFbmFibGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGF0YXNldC5mb250TmFtZSA9IGdlb20uZm9udE5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChhbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5hbmdsZSA9IGFuZ2xlICogKDE4MCAvIE1hdGguUEkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgc2hvdWxkU2NhbGVUZXh0ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGdlb20uc3RyLmxlbmd0aCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdlb20uc3RyICE9PSAiICIgJiYgZ2VvbS50cmFuc2Zvcm1bMF0gIT09IGdlb20udHJhbnNmb3JtWzNdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic1NjYWxlWCA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzBdKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFic1NjYWxlWSA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFic1NjYWxlWCAhPT0gYWJzU2NhbGVZICYmIE1hdGgubWF4KGFic1NjYWxlWCwgYWJzU2NhbGVZKSAvIE1hdGgubWluKGFic1NjYWxlWCwgYWJzU2NhbGVZKSA+IDEuNSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkU2NhbGVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLmNhbnZhc1dpZHRoID0gc3R5bGUudmVydGljYWwgPyBnZW9tLmhlaWdodCA6IGdlb20ud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRhc2suX3RleHREaXZQcm9wZXJ0aWVzLnNldCh0ZXh0RGl2LCB0ZXh0RGl2UHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fbGF5b3V0VGV4dCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBsYXlvdXQocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICBkaXYsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZGb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHkKICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSAiIjsKICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5jYW52YXNXaWR0aCAhPT0gMCAmJiBwcm9wZXJ0aWVzLmhhc1RleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udEZhbWlseQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udFNpemUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHByb3BlcnRpZXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Rm9udFNpemUgIT09IGZvbnRTaXplIHx8IHByZXZGb250RmFtaWx5ICE9PSBmb250RmFtaWx5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke2ZvbnRTaXplICogc2NhbGV9cHggJHtmb250RmFtaWx5fWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRTaXplID0gZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRGYW1pbHkgPSBmb250RmFtaWx5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjdHgubWVhc3VyZVRleHQoZGl2LnRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gYHNjYWxlWCgke2NhbnZhc1dpZHRoICogc2NhbGUgLyB3aWR0aH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5hbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBgcm90YXRlKCR7cHJvcGVydGllcy5hbmdsZX1kZWcpICR7dHJhbnNmb3JtfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm0ubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyKHRhc2spIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5fY2FuY2VsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2cyA9IHRhc2suX3RleHREaXZzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSB0YXNrLl9jYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHREaXZzTGVuZ3RoID0gdGV4dERpdnMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2c0xlbmd0aCA+IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghdGFzay5faXNSZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHRleHREaXYgb2YgdGV4dERpdnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhc2suX2xheW91dFRleHQodGV4dERpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0TGF5ZXJSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRGb250SW5zcGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudFNvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRDb250ZW50SXRlbXNTdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UgPSB0ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSZWFkYWJsZVN0cmVhbSA9IHRleHRDb250ZW50U291cmNlIGluc3RhbmNlb2YgUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lciA9IHRoaXMuX3Jvb3RDb250YWluZXIgPSBjb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHREaXZzID0gdGV4dERpdnMgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHRDb250ZW50SXRlbXNTdHIgPSB0ZXh0Q29udGVudEl0ZW1zU3RyIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCA9IGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb250SW5zcGVjdG9yRW5hYmxlZCA9ICEhKChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dERpdlByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcyB8fCBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRTaXplOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHk6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXY6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZTogdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eDogZ2V0Q3R4KDAsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNmb3JtID0gWzEsIDAsIDAsIC0xLCAtcGFnZVgsIHBhZ2VZICsgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VXaWR0aCA9IHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUhlaWdodCA9IHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGNvbnRhaW5lciwgdmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5LnByb21pc2UuZmluYWxseSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2goKCkgPT4ge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlci5jYW5jZWwobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FwYWJpbGl0eS5yZWplY3QobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc0l0ZW1zKGl0ZW1zLCBzdHlsZUNhY2hlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBpdGVtcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uc3RyID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS50eXBlID09PSAiYmVnaW5NYXJrZWRDb250ZW50UHJvcHMiIHx8IGl0ZW0udHlwZSA9PT0gImJlZ2luTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFyZW50ID0gdGhpcy5fY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJtYXJrZWRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmlkICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuc2V0QXR0cmlidXRlKCJpZCIsIGAke2l0ZW0uaWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50LmFwcGVuZCh0aGlzLl9jb250YWluZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS50eXBlID09PSAiZW5kTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGFpbmVyID0gdGhpcy5fY29udGFpbmVyLnBhcmVudE5vZGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRJdGVtc1N0ci5wdXNoKGl0ZW0uc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZFRleHQodGhpcywgaXRlbSwgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2xheW91dFRleHQodGV4dERpdikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHRoaXMuX2xheW91dFRleHRQYXJhbXMucHJvcGVydGllcyA9IHRoaXMuX3RleHREaXZQcm9wZXJ0aWVzLmdldCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0VGV4dFBhcmFtcy5kaXYgPSB0ZXh0RGl2OwogICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQodGhpcy5fbGF5b3V0VGV4dFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuYXBwZW5kKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNFT0wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYnIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyLnNldEF0dHJpYnV0ZSgicm9sZSIsICJwcmVzZW50YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5hcHBlbmQoYnIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHlsZUNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bXAgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyLnJlYWQoKS50aGVuKF9yZWYyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKHN0eWxlQ2FjaGUsIHZhbHVlLnN0eWxlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyh2YWx1ZS5pdGVtcywgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBjYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UuZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fdGV4dENvbnRlbnRTb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl90ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyhpdGVtcywgc3R5bGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAidGV4dENvbnRlbnRTb3VyY2UiIHBhcmFtZXRlciBzcGVjaWZpZWQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVDYWNoZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuX2NhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSBUZXh0TGF5ZXJSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyVGV4dExheWVyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIGlmICghcGFyYW1zLnRleHRDb250ZW50U291cmNlICYmIChwYXJhbXMudGV4dENvbnRlbnQgfHwgcGFyYW1zLnRleHRDb250ZW50U3RyZWFtKSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoIlRoZSBUZXh0TGF5ZXJSZW5kZXIgYHRleHRDb250ZW50YC9gdGV4dENvbnRlbnRTdHJlYW1gIHBhcmFtZXRlcnMgIiArICJ3aWxsIGJlIHJlbW92ZWQgaW4gdGhlIGZ1dHVyZSwgcGxlYXNlIHVzZSBgdGV4dENvbnRlbnRTb3VyY2VgIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy50ZXh0Q29udGVudFNvdXJjZSA9IHBhcmFtcy50ZXh0Q29udGVudCB8fCBwYXJhbXMudGV4dENvbnRlbnRTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydAogICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBnZXRDb21wdXRlZFN0eWxlKGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdmlzaWJpbGl0eSA9IHN0eWxlLmdldFByb3BlcnR5VmFsdWUoInZpc2liaWxpdHkiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvciA9IHBhcnNlRmxvYXQoc3R5bGUuZ2V0UHJvcGVydHlWYWx1ZSgiLS1zY2FsZS1mYWN0b3IiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpc2liaWxpdHkgPT09ICJ2aXNpYmxlIiAmJiAoIXNjYWxlRmFjdG9yIHx8IE1hdGguYWJzKHNjYWxlRmFjdG9yIC0gdmlld3BvcnQuc2NhbGUpID4gMWUtMTUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIlRoZSBgLS1zY2FsZS1mYWN0b3JgIENTUy12YXJpYWJsZSBtdXN0IGJlIHNldCwgIiArICJ0byB0aGUgc2FtZSB2YWx1ZSBhcyBgdmlld3BvcnQuc2NhbGVgLCAiICsgImVpdGhlciBvbiB0aGUgYGNvbnRhaW5lcmAtZWxlbWVudCBpdHNlbGYgb3IgaGlnaGVyIHVwIGluIHRoZSBET00uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgVGV4dExheWVyUmVuZGVyVGFzayhwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgIHRhc2suX3JlbmRlcigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0YXNrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gdXBkYXRlVGV4dExheWVyKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdFJvdGF0ZSA9IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RSZXNjYWxlID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICBpZiAobXVzdFJvdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShjb250YWluZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSZXNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGdldEN0eCgwLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udFNpemU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udEZhbWlseTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdjogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiB0ZXh0RGl2cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLnByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcy5nZXQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5kaXYgPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTYyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvckxheWVyID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2ZyZWV0ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjMpOwogIC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ICAgICAgICAgICB2YXIgX2NyZWF0ZU5ld0VkaXRvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQW5ub3RhdGlvbkVkaXRvckxheWVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY2xlYW51cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlQW5kQWRkTmV3RWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jcmVhdGVOZXdFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NoYW5nZVBhcmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYWxsb3dDbGljaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5wb2ludGVydXAuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kUG9pbnRlcmRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMucG9pbnRlcmRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hhZFBvaW50ZXJEb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzQ2xlYW5pbmdVcCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF91aU1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9mcmVldGV4dC5GcmVlVGV4dEVkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfaW5rLklua0VkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy51aU1hbmFnZXIucmVnaXN0ZXJFZGl0b3JUeXBlcyhbX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLCBfaW5rLklua0VkaXRvcl0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3VpTWFuYWdlciwgb3B0aW9ucy51aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2VJbmRleCA9IG9wdGlvbnMucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IG9wdGlvbnMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyLCBvcHRpb25zLmFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZExheWVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuc2l6ZSA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlVG9vbGJhcihtb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS51cGRhdGVUb29sYmFyKG1vZGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbW9kZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2xlYW51cCwgX2NsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0QWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RlICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJmcmVlVGV4dEVkaXRpbmciLCBtb2RlID09PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJpbmtFZGl0aW5nIiwgbW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZElua0VkaXRvcklmTmVlZGVkKGlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZyAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuZ2V0TW9kZSgpICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTkspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRJbkJhY2tncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRDb21tYW5kcyhwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZENvbW1hbmRzKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVuYWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJhdXRvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmVuYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5wb2ludGVyRXZlbnRzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGlzYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jbGVhbnVwLCBfY2xlYW51cDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0QWN0aXZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50QWN0aXZlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEFjdGl2ZSA9PT0gZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEFjdGl2ZUVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVDbGljaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcmRvd24iLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kUG9pbnRlcmRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcnVwIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ2xpY2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXR0YWNoKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnNldChlZGl0b3IuaWQsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldGFjaChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuZGVsZXRlKGVkaXRvci5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIChfY2xhc3NQcml2YXRlRmllbGRHZXQyID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIucmVtb3ZlUG9pbnRlckluVGV4dExheWVyKGVkaXRvci5jb250ZW50RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikucmVtb3ZlRWRpdG9yKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGl2LnN0eWxlLmRpc3BsYXkgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaXNBdHRhY2hlZFRvRE9NID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQuYWN0aXZlRWxlbWVudCA9PT0gZG9jdW1lbnQuYm9keSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5mb2N1c01haW5Db250YWluZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NsZWFuaW5nVXApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IGVkaXRvci5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmlzQXR0YWNoZWRUb0RPTSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uY2VBZGRlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZShlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlRWRpdG9ySW5ET00oZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQzOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MyA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWNjZXNzaWJpbGl0eU1hbmFnZXIpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQzLm1vdmVFbGVtZW50SW5ET00odGhpcy5kaXYsIGVkaXRvci5kaXYsIGVkaXRvci5jb250ZW50RGl2LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkT3JSZWJ1aWxkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLm5lZWRzVG9CZVJlYnVpbHQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQU5ld0VkaXRvcihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFVuZG9hYmxlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbWQgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZE9yUmVidWlsZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE5leHRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXNlcmlhbGl6ZShkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5hbm5vdGF0aW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLmRlc2VyaWFsaXplKGRhdGEsIHRoaXMsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLklOSzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2luay5JbmtFZGl0b3IuZGVzZXJpYWxpemUoZGF0YSwgdGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5zZXRTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0b2dnbGVTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnRvZ2dsZVNlbGVjdGVkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuaXNTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bnNlbGVjdChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0KGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hhZFBvaW50ZXJEb3duKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFkUG9pbnRlckRvd24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbG93Q2xpY2spKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FsbG93Q2xpY2ssIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvciwgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludGVyZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oYWRQb2ludGVyRG93biwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbGxvd0NsaWNrLCAhZWRpdG9yIHx8IGVkaXRvci5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcm9wKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZXZlbnQuZGF0YVRyYW5zZmVyLmdldERhdGEoInRleHQvcGxhaW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcihpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmRyb3BFZmZlY3QgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRYID0gZXZlbnQuY2xpZW50WCAtIHJlY3QueDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5kWSA9IGV2ZW50LmNsaWVudFkgLSByZWN0Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50cmFuc2xhdGUoZW5kWCAtIGVkaXRvci5zdGFydFgsIGVuZFkgLSBlZGl0b3Iuc3RhcnRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcmFnb3ZlcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NC5wYXJlbnQpID09PSB0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuc2V0QWN0aXZlRWRpdG9yKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQ1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDUgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NS5yZW1vdmVQb2ludGVySW5UZXh0TGF5ZXIoZWRpdG9yLmNvbnRlbnREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFBhcmVudChudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pc0F0dGFjaGVkVG9ET00gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5yZW1vdmVMYXllcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0ID0gdmlld3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKHRoaXMuZGl2LCB2aWV3cG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdG9vbHMuYmluZEV2ZW50cykodGhpcywgdGhpcy5kaXYsIFsiZHJhZ292ZXIiLCAiZHJvcCJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcnModGhpcy5wYWdlSW5kZXgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlTW9kZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGUoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSB2aWV3cG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9ucykodGhpcy5kaXYsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cGRhdGVNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlRGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy52aWV3cG9ydC5yYXdEaW1zOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yTGF5ZXIgPSBBbm5vdGF0aW9uRWRpdG9yTGF5ZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hhbmdlUGFyZW50MihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciRwYXJlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5wYXJlbnQgPT09IHRoaXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIChfZWRpdG9yJHBhcmVudCA9IGVkaXRvci5wYXJlbnQpID09PSBudWxsIHx8IF9lZGl0b3IkcGFyZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZWRpdG9yJHBhcmVudC5kZXRhY2goZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UGFyZW50KHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuZGl2ICYmIGVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKGVkaXRvci5kaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jcmVhdGVOZXdFZGl0b3IyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZnJlZXRleHQuRnJlZVRleHRFZGl0b3IocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTks6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF9pbmsuSW5rRWRpdG9yKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IHRoaXMuZ2V0TmV4dElkKCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlTmV3RWRpdG9yLCBfY3JlYXRlTmV3RWRpdG9yMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudDogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGV2ZW50Lm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGV2ZW50Lm9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgIHVpTWFuYWdlcjogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNDbGVhbmluZ1VwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NsZWFuaW5nVXAsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yTGF5ZXIsICJfaW5pdGlhbGl6ZWQiLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9v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gICAgdmFyIF91cGRhdGVGb250U2l6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVDb2xvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9leHRyYWN0VGV4dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRFZGl0b3JEaW1lbnNpb25zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEVkaXRvciBleHRlbmRzIF9lZGl0b3IuQW5ub3RhdGlvbkVkaXRvciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLnBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJmcmVlVGV4dEVkaXRvciIKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3VwZGF0ZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVGb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEVkaXRvckRpdkJsdXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZWRpdG9yRGl2Qmx1ci5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZGb2N1cywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZGb2N1cy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZJbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZJbnB1dC5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZLZXlkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmVkaXRvckRpdktleWRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbG9yLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9jb250ZW50LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAiIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvckRpdklkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBgJHt0aGlzLmlkfS1lZGl0b3JgCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZm9udFNpemUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgcGFyYW1zLmNvbG9yIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9mb250U2l6ZSwgcGFyYW1zLmZvbnRTaXplIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Rm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImZyZWVfdGV4dDJfZGVmYXVsdF9jb250ZW50IiwgImVkaXRvcl9mcmVlX3RleHQyX2FyaWFfbGFiZWwiXS5tYXAoc3RyID0+IFtzdHIsIGwxMG4uZ2V0KHN0cildKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gZ2V0Q29tcHV0ZWRTdHlsZShkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlcm5hbFBhZGRpbmcgPSBwYXJzZUZsb2F0KHN0eWxlLmdldFByb3BlcnR5VmFsdWUoIi0tZnJlZXRleHQtcGFkZGluZyIpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX1NJWkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fZGVmYXVsdENvbG9yID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZUZvbnRTaXplLCBfdXBkYXRlRm9udFNpemUyKS5jYWxsKHRoaXMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZV0sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUiwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3JdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSldLCBbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1IsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29sb3IpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWy1GcmVlVGV4dEVkaXRvci5faW50ZXJuYWxQYWRkaW5nICogc2NhbGUsIC0oRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyArIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHNjYWxlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVidWlsZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kaXYgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5hZGQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQudXBkYXRlVG9vbGJhcihfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdi5jbGFzc0xpc3QucmVtb3ZlKCJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNvbnRlbnRFZGl0YWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5yZW1vdmVBdHRyaWJ1dGUoImFyaWEtYWN0aXZlZGVzY2VuZGFudCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlK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ICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5mb2N1c2luKGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LnRhcmdldCAhPT0gdGhpcy5lZGl0b3JEaXYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmZvY3VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICF0aGlzLmVkaXRvckRpdiB8fCB0aGlzLmVkaXRvckRpdi5pbm5lclRleHQudHJpbSgpID09PSAiIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuYWRkVW5kb2FibGVFZGl0b3IodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250ZW50LCBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0VGV4dCwgX2V4dHJhY3RUZXh0MikuY2FsbCh0aGlzKS50cmltRW5kKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRFZGl0b3JEaW1lbnNpb25zLCBfc2V0RWRpdG9yRGltZW5zaW9uczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5pc0luRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGJsY2xpY2soZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBrZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgPT09IHRoaXMuZGl2ICYmIGV2ZW50LmtleSA9PT0gIkVudGVyIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZLZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEZyZWVUZXh0RWRpdG9yLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVkaXRvckRpdkZvY3VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWRpdG9yRGl2Qmx1cihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZJbnB1dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5kaXYuY2xhc3NMaXN0LnRvZ2dsZSgiZnJlZVRleHRFZGl0aW5nIiwgdGhpcy5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc2V0QXR0cmlidXRlKCJyb2xlIiwgImNvbW1lbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlQXR0cmlidXRlKCJhcmlhLW11bHRpbGluZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAidGV4dGJveCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoImFyaWEtbXVsdGlsaW5lIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNsYXNzTmFtZSA9ICJpbnRlcm5hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiaWQiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvckRpdklkKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdGluZygpOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfZnJlZV90ZXh0Ml9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGVkaXRvckRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZWRpdG9yRGl2ID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJmcmVlX3RleHQyX2RlZmF1bHRfY29udGVudCIpLnRoZW4obXNnID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRlZGl0b3JEaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChfdGhpcyRlZGl0b3JEaXYyID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGVkaXRvckRpdjIuc2V0QXR0cmlidXRlKCJkZWZhdWx0LWNvbnRlbnQiLCBtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZWRpdG9yRGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSl9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLmVkaXRvckRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXlEaXYuY2xhc3NMaXN0LmFkZCgib3ZlcmxheSIsICJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLm92ZXJsYXlEaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3Rvb2xzLmJpbmRFdmVudHMpKHRoaXMsIHRoaXMuZGl2LCBbImRibGNsaWNrIiwgImtleWRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGJhc2VYICogcGFyZW50V2lkdGgsIGJhc2VZICogcGFyZW50SGVpZ2h0LCB0aGlzLndpZHRoICogcGFyZW50V2lkdGgsIHRoaXMuaGVpZ2h0ICogcGFyZW50SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRlbnQpLnNwbGl0KCJcbiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChsaW5lID8gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobGluZSkgOiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJiciIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hcHBlbmQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5jb250ZW50RWRpdGFibGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50RGl2KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBzdXBlci5kZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9mb250U2l6ZSwgZGF0YS5mb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9jb2xvciwgX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZGF0YS5jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfY29udGVudCwgZGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlcmlhbGl6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkaW5nID0gRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyAqIHRoaXMucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLmdldFJlY3QocGFkZGluZywgcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmlzQXR0YWNoZWRUb0RPTSA/IGdldENvbXB1dGVkU3R5bGUodGhpcy5lZGl0b3JEaXYpLmNvbG9yIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvblR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhULAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb250ZW50KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHRoaXMucm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gRnJlZVRleHRFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlRm9udFNpemUyKGZvbnRTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2V0Rm9udHNpemUgPSBzaXplID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc3R5bGUuZm9udFNpemUgPSBgY2FsYygke3NpemV9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRlKDAsIC0oc2l6ZSAtIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHRoaXMucGFyZW50U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2ZvbnRTaXplLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucywgX3NldEVkaXRvckRpbWVuc2lvbnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGb250c2l6ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnRzaXplKGZvbnRTaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Rm9udHNpemUoc2F2ZWRGb250c2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbG9yKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgY21kOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NvbG9yLCB0aGlzLmVkaXRvckRpdi5zdHlsZS5jb2xvciA9IGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgdGhpcy5lZGl0b3JEaXYuc3R5bGUuY29sb3IgPSBzYXZlZENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX0NPTE9SLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V4dHJhY3RUZXh0MigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZzID0gdGhpcy5lZGl0b3JEaXYuZ2V0RWxlbWVudHNCeVRhZ05hbWUoImRpdiIpOwogICAgICAgICAgICAgICAgICAgIGlmIChkaXZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXYuaW5uZXJUZXh0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiBkaXZzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGRpdi5pbm5lclRleHQucmVwbGFjZSgvXHJcbj98XG4vLCAiIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVmZmVyLmpvaW4oIlxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0RWRpdG9yRGltZW5zaW9uczIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIGxldCByZWN0OwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQXR0YWNoZWRUb0RPTSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gdGhpcy5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZERpc3BsYXkgPSBkaXYuc3R5bGUuZGlzcGxheTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLmRpc3BsYXkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLmRpdi5hcHBlbmQodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdi5zdHlsZS5kaXNwbGF5ID0gc2F2ZWREaXNwbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLndpZHRoID0gcmVjdC53aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gcmVjdC5oZWlnaHQgLyBwYXJlbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZnJlZVRleHREZWZhdWx0Q29udGVudCIsICIiKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShGcmVlVGV4dEVkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfaW50ZXJuYWxQYWRkaW5nIiwgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdENvbG9yIiwgbnVsbCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdEZvbnRTaXplIiwgMTApOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KEZyZWVUZXh0RWRpdG9yLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBfdG9vbHMuS2V5Ym9hcmRNYW5hZ2VyKFtbWyJjdHJsK0VudGVyIiwgIm1hYyttZXRhK0VudGVyIiwgIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEZyZWVUZXh0RWRpdG9yLnByb3RvdHlwZS5jb21taXRPclJlbW92ZV1dKSk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfdHlwZSIsICJmcmVldGV4dCIpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgImZpdEN1cnZlIiwgKHsKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3BkZmpzRml0Q3VydmUuZml0Q3VydmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9wZGZqc0ZpdEN1cnZlID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjUpOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnR5KG9iaiwga2V5LCB2YWx1ZSkgeyBrZXkgPSBfdG9Qcm9wZXJ0eUtleShrZXkpOyBpZiAoa2V5IGluIG9iaikgeyBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHsgdmFsdWU6IHZhbHVlLCBlbnVtZXJhYmxlOiB0cnVlLCBjb25maWd1cmFibGU6IHRydWUsIHdyaXRhYmxlOiB0cnVlIH0pOyB9IGVsc2UgeyBvYmpba2V5XSA9IHZhbHVlOyB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XZlciwgcHJpdmF0ZVNldCwgZm4pIHsgaWYgKCFwcml2YXRlU2V0LmhhcyhyZWNlaXZlcikpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIGdldCBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBmbjsgfQogICAgICAgICAgICAgICAgY29uc3QgUkVTSVpFUl9TSVpFID0gMTY7CiAgICAgICAgICAgICAgICB2YXIgX2FzcGVjdFJhdGlvID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Jhc2VIZWlnaHQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYmFzZVdpZHRoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVybGVhdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlRWRpdGluZyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0NhbnZhc0luaXRpYWxpemVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2xhc3RQb2ludCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9vYnNlcnZlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZWFsV2lkdGggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVhbEhlaWdodCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZXF1ZXN0RnJhbWVDYWxsYmFjayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVUaGlja25lc3MgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlQ29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlT3BhY2l0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRJbml0aWFsQkJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRTdHJva2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RhcnREcmF3aW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2RyYXcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RvcERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVkcmF3ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuZERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY3JlYXRlQ2FudmFzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU9ic2VydmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NldENhbnZhc0RpbXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0U2NhbGVGYWN0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlVHJhbnNmb3JtID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZVBhdGhzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2V4dHJhY3RQb2ludHNPbkJlemllciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0FsbW9zdEZsYXQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfZ2V0QmJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRQYWRkaW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2ZpdFRvQ29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRNaW5EaW1zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBJbmtFZGl0b3IgZXh0ZW5kcyBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiaW5rRWRpdG9yIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNaW5EaW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9maXRUb0NvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldFBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEJib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzQWxtb3N0RmxhdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFBvaW50c09uQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemVQYXRocyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0Q2FudmFzRGltcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NyZWF0ZUNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5kRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfcmVkcmF3KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zdG9wRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZHJhdyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc3RhcnREcmF3aW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTdHJva2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEluaXRpYWxCQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVPcGFjaXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVGhpY2tuZXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2FzcGVjdFJhdGlvLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYmFzZUhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Jhc2VXaWR0aCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcm1vdmUuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJsZWF2ZS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcnVwLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJkb3duLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kaXNhYmxlRWRpdGluZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2xhc3RQb2ludCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ic2VydmVyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbFdpZHRoLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbEhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yID0gcGFyYW1zLmNvbG9yIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gcGFyYW1zLnRoaWNrbmVzcyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBwYXJhbXMub3BhY2l0eSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJEID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZUZhY3RvciA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25YID0gdGhpcy50cmFuc2xhdGlvblkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiLCAiZWRpdG9yX2luazJfYXJpYV9sYWJlbCJdLm1hcChzdHIgPT4gW3N0ciwgbDEwbi5nZXQoc3RyKV0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1M6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRPcGFjaXR5ID0gdmFsdWUgLyAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZVRoaWNrbmVzcywgX3VwZGF0ZVRoaWNrbmVzczIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVPcGFjaXR5LCBfdXBkYXRlT3BhY2l0eTIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX1RISUNLTkVTUywgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKElua0VkaXRvci5fZGVmYXVsdE9wYWNpdHkgKiAxMDApXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1MsIHRoaXMudGhpY2tuZXNzIHx8IElua0VkaXRvci5fZGVmYXVsdFRoaWNrbmVzc10sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1IsIHRoaXMuY29sb3IgfHwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKDEwMCAqICh0aGlzLm9wYWNpdHkgPz8gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eSkpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlYnVpbGQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZU9ic2VydmVyLCBfY3JlYXRlT2JzZXJ2ZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldENhbnZhc0RpbXMsIF9zZXRDYW52YXNEaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9maXRUb0NvbnRlbnQsIF9maXRUb0NvbnRlbnQyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbnZhcyA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMud2lkdGggPSB0aGlzLmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29ic2VydmVyKS5kaXNjb25uZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0UGFyZW50KHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50ICYmIHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLnJlbW92ZVNob3VsZFJlc2NhbGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5wYXJlbnQgJiYgcGFyZW50ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkU2hvdWxkUmVzY2FsZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5zZXRQYXJlbnQocGFyZW50KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1lbnNpb25zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpIHx8IHRoaXMuY2FudmFzID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNJbkVkaXRNb2RlKCkgfHwgdGhpcy5jYW52YXMgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gIXRoaXMuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QucmVtb3ZlKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSAhdGhpcy5pc0VtcHR5KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMSAmJiB0aGlzLnBhdGhzWzBdLmxlbmd0aCA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZElua0VkaXRvcklmTmVlZGVkKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5tb3ZlRWRpdG9ySW5ET00odGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvY3VzaW4oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZm9jdXNpbihldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmJ1dHRvbiAhPT0gMCB8fCAhdGhpcy5pc0luRWRpdE1vZGUoKSB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5Gb3JlZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50eXBlICE9PSAibW91c2UiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5hZGRFdmVudExpc3RlbmVyKCJwb2ludGVybGVhdmUiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJtb3ZlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJtb3ZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0YXJ0RHJhd2luZywgX3N0YXJ0RHJhd2luZzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJtb3ZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kcmF3LCBfZHJhdzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJbkVkaXRNb2RlKCkgJiYgdGhpcy5jdXJyZW50UGF0aC5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5kRHJhd2luZywgX2VuZERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmxlYXZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2VuZERyYXdpbmcsIF9lbmREcmF3aW5nMikuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIElua0VkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfaW5rMl9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZGl2ID0gdGhpcy5kaXYpID09PSBudWxsIHx8IF90aGlzJGRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeSwgdywgaF0gPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRJbml0aWFsQkJveCwgX2dldEluaXRpYWxCQm94MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdCh4LCB5LCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVDYW52YXMsIF9jcmVhdGVDYW52YXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChiYXNlWCAqIHBhcmVudFdpZHRoLCBiYXNlWSAqIHBhcmVudEhlaWdodCwgdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoLCB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lzQ2FudmFzSW5pdGlhbGl6ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHRoaXMud2lkdGggKiBwYXJlbnRXaWR0aCwgdGhpcy5oZWlnaHQgKiBwYXJlbnRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldE1pbkRpbXMsIF9zZXRNaW5EaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QuYWRkKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIsIF9jcmVhdGVPYnNlcnZlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RGltZW5zaW9ucyh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvdW5kZWRXaWR0aCA9IE1hdGgucm91bmQod2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZGVkSGVpZ2h0ID0gTWF0aC5yb3VuZChoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsV2lkdGgpID09PSByb3VuZGVkV2lkdGggJiYgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsSGVpZ2h0KSA9PT0gcm91bmRlZEhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVhbFdpZHRoLCByb3VuZGVkV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIHJvdW5kZWRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAmJiBNYXRoLmFicyhfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAtIHdpZHRoIC8gaGVpZ2h0KSA+IDFlLTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IE1hdGguY2VpbCh3aWR0aCAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGltcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhlaWdodCA9IGhlaWdodCAvIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbCh0aGlzLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRDYW52YXNEaW1zLCBfc2V0Q2FudmFzRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnN0eWxlLnZpc2liaWxpdHkgPSAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZml4RGltcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gc3VwZXIuZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudGhpY2tuZXNzID0gZGF0YS50aGlja25lc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmRhdGEuY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BhY2l0eSA9IGRhdGEub3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF0gPSBlZGl0b3IucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gZWRpdG9yLndpZHRoICogcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBlZGl0b3IuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3IgPSBlZGl0b3IucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBkYXRhLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9hc3BlY3RSYXRpbywgd2lkdGggLyBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfZGlzYWJsZUVkaXRpbmcsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfcmVhbFdpZHRoLCBNYXRoLnJvdW5kKHdpZHRoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9yZWFsSGVpZ2h0LCBNYXRoLnJvdW5kKGhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcgogICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGRhdGEucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wYXRocy5wdXNoKHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyWzBdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcDEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbMV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2ldIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDExID0gc2NhbGVGYWN0b3IgKiAoaGVpZ2h0IC0gYmV6aWVyW2kgKyAxXSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHNjYWxlRmFjdG9yICogKGJlemllcltpICsgMl0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMjEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbaSArIDNdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2kgKyA0XSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzMSA9IHNjYWxlRmFjdG9yICogKGhlaWdodCAtIGJlemllcltpICsgNV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goW1twMCwgcDFdLCBbcDEwLCBwMTFdLCBbcDIwLCBwMjFdLCBbcDMwLCBwMzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDAgPSBwMzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDEgPSBwMzE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoMkQgPSBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKHRoaXMsIHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmJlemllclBhdGgyRC5wdXNoKHBhdGgyRCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQoZWRpdG9yLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KGVkaXRvciwgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldChlZGl0b3IsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbChlZGl0b3IsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXJpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZ2V0UmVjdCgwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5yb3RhdGlvbiAlIDE4MCA9PT0gMCA/IHJlY3RbM10gLSByZWN0WzFdIDogcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmN0eC5zdHJva2VTdHlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uVHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlja25lc3M6IHRoaXMudGhpY2tuZXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BhY2l0eTogdGhpcy5vcGFjaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aHM6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZVBhdGhzLCBfc2VyaWFsaXplUGF0aHMyKS5jYWxsKHRoaXMsIHRoaXMuc2NhbGVGYWN0b3IgLyB0aGlzLnBhcmVudFNjYWxlLCB0aGlzLnRyYW5zbGF0aW9uWCwgdGhpcy50cmFuc2xhdGlvblksIGhlaWdodCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSBJbmtFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlVGhpY2tuZXNzMih0aGlja25lc3MpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZFRoaWNrbmVzcyA9IHRoaXMudGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gdGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZml0VG9Db250ZW50LCBfZml0VG9Db250ZW50MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50aGlja25lc3MgPSBzYXZlZFRoaWNrbmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG86ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBzYXZlZENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwKICAgICAgICAgICAgICAgICAgICAgICAgb3ZlcndyaXRlSWZTYW1lVHlwZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAga2VlcFVuZG86IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF91cGRhdGVPcGFjaXR5MihvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgb3BhY2l0eSAvPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRPcGFjaXR5ID0gdGhpcy5vcGFjaXR5OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA9IG9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB1bmRvOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBzYXZlZE9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX09QQUNJVFksCiAgICAgICAgICAgICAgICAgICAgICAgIG92ZXJ3cml0ZUlmU2FtZVR5cGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGtlZXBVbmRvOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0SW5pdGlhbEJCb3gyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Um90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudERpbWVuc2lvbnM6IFt3aWR0aCwgaGVpZ2h0XQogICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAocGFyZW50Um90YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMCwgaGVpZ2h0LCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3dpZHRoLCBoZWlnaHQsIHdpZHRoLCBoZWlnaHRdOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbd2lkdGgsIDAsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0U3Ryb2tlMigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgIG9wYWNpdHksCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzcywKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50U2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlRmFjdG9yCiAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHRoaWNrbmVzcyAqIHBhcmVudFNjYWxlIC8gc2NhbGVGYWN0b3I7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAicm91bmQiOwogICAgICAgICAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9ICJyb3VuZCI7CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1pdGVyTGltaXQgPSAxMDsKICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBgJHtjb2xvcn0keygwLCBfdG9vbHMub3BhY2l0eVRvSGV4KShvcGFjaXR5KX1gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0YXJ0RHJhd2luZzIoeCwgeSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaXNDYW52YXNJbml0aWFsaXplZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRoaWNrbmVzcyB8fD0gSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yIHx8PSBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA/Pz0gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50UGF0aC5wdXNoKFt4LCB5XSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9sYXN0UG9pbnQsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldFN0cm9rZSwgX3NldFN0cm9rZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVxdWVzdEZyYW1lQ2FsbGJhY2ssICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2xhc3RQb2ludCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGVhclJlY3QoMCwgMCwgdGhpcy5jYW52YXMud2lkdGgsIHRoaXMuY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5saW5lVG8oLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9sYXN0UG9pbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RyYXcyKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGFzdFgsIGxhc3RZXSA9IHRoaXMuY3VycmVudFBhdGguYXQoLTEpOwogICAgICAgICAgICAgICAgICAgIGlmICh4ID09PSBsYXN0WCAmJiB5ID09PSBsYXN0WSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBbeCwgeV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0b3BEcmF3aW5nMih4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGgubWluKE1hdGgubWF4KHgsIDApLCB0aGlzLmNhbnZhcy53aWR0aCk7CiAgICAgICAgICAgICAgICAgICAgeSA9IE1hdGgubWluKE1hdGgubWF4KHksIDApLCB0aGlzLmNhbnZhcy5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsYXN0WCwgbGFzdFldID0gdGhpcy5jdXJyZW50UGF0aC5hdCgtMSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHggIT09IGxhc3RYIHx8IHkgIT09IGxhc3RZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgYmV6aWVyOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCAhPT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICBiZXppZXIgPSAoMCwgX3BkZmpzRml0Q3VydmUuZml0Q3VydmUpKHRoaXMuY3VycmVudFBhdGgsIDMwLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4eSA9IFt4LCB5XTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6aWVyID0gW1t4eSwgeHkuc2xpY2UoKSwgeHkuc2xpY2UoKSwgeHldXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGF0aDJEID0gX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChJbmtFZGl0b3IsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKElua0VkaXRvciwgYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzLnB1c2goYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iZXppZXJQYXRoMkQucHVzaChwYXRoMkQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZG8gPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGF0aHMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJELnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXRocy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVPYnNlcnZlciwgX2NyZWF0ZU9ic2VydmVyMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfcmVkcmF3MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTdHJva2UsIF9zZXRTdHJva2UyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGVhclJlY3QoMCwgMCwgY2FudmFzLndpZHRoLCBjYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVUcmFuc2Zvcm0sIF91cGRhdGVUcmFuc2Zvcm0yKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLmJlemllclBhdGgyRCkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKHBhdGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmREcmF3aW5nMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0b3BEcmF3aW5nLCBfc3RvcERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50Lm9mZnNldFgsIGV2ZW50Lm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJsZWF2ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybGVhdmUpKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmVFdmVudExpc3RlbmVyKCJwb2ludGVybW92ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybW92ZSkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUNhbnZhczIoKSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IHRoaXMuY2FudmFzLmhlaWdodCA9IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMuY2xhc3NOYW1lID0gImlua0VkaXRvckNhbnZhcyI7CiAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9sMTBuUHJvbWlzZS5nZXQoImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiKS50aGVuKG1zZyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkY2FudmFzID0gdGhpcy5jYW52YXMpID09PSBudWxsIHx8IF90aGlzJGNhbnZhcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY2FudmFzLnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKHRoaXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY3JlYXRlT2JzZXJ2ZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG5ldyBSZXNpemVPYnNlcnZlcihlbnRyaWVzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IGVudHJpZXNbMF0uY29udGVudFJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0LndpZHRoICYmIHJlY3QuaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldERpbWVuc2lvbnMocmVjdC53aWR0aCwgcmVjdC5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2JzZXJ2ZXIpLm9ic2VydmUodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldENhbnZhc0RpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnRXaWR0aCwgcGFyZW50SGVpZ2h0XSA9IHRoaXMucGFyZW50RGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IE1hdGguY2VpbCh0aGlzLndpZHRoICogcGFyZW50V2lkdGgpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbCh0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZXRTY2FsZUZhY3RvcjIod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JXID0gKHdpZHRoIC0gcGFkZGluZykgLyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JIID0gKGhlaWdodCAtIHBhZGRpbmcpIC8gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnNjYWxlRmFjdG9yID0gTWF0aC5taW4oc2NhbGVGYWN0b3JXLCBzY2FsZUZhY3RvckgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZVRyYW5zZm9ybTIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFkZGluZyA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2dldFBhZGRpbmcsIF9nZXRQYWRkaW5nMikuY2FsbCh0aGlzKSAvIDI7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKHRoaXMuc2NhbGVGYWN0b3IsIDAsIDAsIHRoaXMuc2NhbGVGYWN0b3IsIHRoaXMudHJhbnNsYXRpb25YICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcsIHRoaXMudHJhbnNsYXRpb25ZICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2J1aWxkUGF0aDJEKGJlemllcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGgyRCA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbZmlyc3QsIGNvbnRyb2wxLCBjb250cm9sMiwgc2Vjb25kXSA9IGJlemllcltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5tb3ZlVG8oLi4uZmlyc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5iZXppZXJDdXJ2ZVRvKGNvbnRyb2wxWzBdLCBjb250cm9sMVsxXSwgY29udHJvbDJbMF0sIGNvbnRyb2wyWzFdLCBzZWNvbmRbMF0sIHNlY29uZFsxXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoMkQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplUGF0aHMyKHMsIHR4LCB0eSwgaCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE5VTUJFUl9PRl9QT0lOVFNfT05fQkVaSUVSX0NVUlZFID0gNDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSB0aGlzLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGJ1ZmZlciwgcG9pbnRzOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmV6aWVyIG9mIHRoaXMucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gPSBiZXppZXJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMTAgPSBzICogKGZpcnN0WzBdICsgdHgpICsgcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAxMSA9IGggLSBzICogKGZpcnN0WzFdICsgdHkpIC0gcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHMgKiAoY29udHJvbDFbMF0gKyB0eCkgKyBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIxID0gaCAtIHMgKiAoY29udHJvbDFbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gcyAqIChjb250cm9sMlswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMzEgPSBoIC0gcyAqIChjb250cm9sMlsxXSArIHR5KSAtIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDAgPSBzICogKHNlY29uZFswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDEgPSBoIC0gcyAqIChzZWNvbmRbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIucHVzaChwMTAsIHAxMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocDEwLCBwMTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2gocDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0UG9pbnRzT25CZXppZXIsIF9leHRyYWN0UG9pbnRzT25CZXppZXIyKS5jYWxsKHRoaXMsIHAxMCwgcDExLCBwMjAsIHAyMSwgcDMwLCBwMzEsIHA0MCwgcDQxLCBOVU1CRVJfT0ZfUE9JTlRTX09OX0JFWklFUl9DVVJWRSwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcjogYnVmZmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZXh0cmFjdFBvaW50c09uQmV6aWVyMihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSwgbiwgcG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzQWxtb3N0RmxhdCwgX2lzQWxtb3N0RmxhdDIpLmNhbGwodGhpcywgcDEwLCBwMTEsIHAyMCwgcDIxLCBwMzAsIHAzMSwgcDQwLCBwNDEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHA0MCwgcDQxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IGkgLyBuOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTEwID0gdCAqIHAxMCArIG10ICogcDIwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTExID0gdCAqIHAxMSArIG10ICogcDIxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIwID0gdCAqIHAyMCArIG10ICogcDMwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIxID0gdCAqIHAyMSArIG10ICogcDMxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxMzAgPSB0ICogcDMwICsgbXQgKiBwNDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHEzMSA9IHQgKiBwMzEgKyBtdCAqIHA0MTsKICAgICAgICAgICAgICAgICAgICAgICAgcTEwID0gdCAqIHExMCArIG10ICogcTIwOwogICAgICAgICAgICAgICAgICAgICAgICBxMTEgPSB0ICogcTExICsgbXQgKiBxMjE7CiAgICAgICAgICAgICAgICAgICAgICAgIHEyMCA9IHQgKiBxMjAgKyBtdCAqIHEzMDsKICAgICAgICAgICAgICAgICAgICAgICAgcTIxID0gdCAqIHEyMSArIG10ICogcTMxOwogICAgICAgICAgICAgICAgICAgICAgICBxMTAgPSB0ICogcTEwICsgbXQgKiBxMjA7CiAgICAgICAgICAgICAgICAgICAgICAgIHExMSA9IHQgKiBxMTEgKyBtdCAqIHEyMTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocTEwLCBxMTEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNBbG1vc3RGbGF0MihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvbCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF4ID0gKDMgKiBwMjAgLSAyICogcDEwIC0gcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF5ID0gKDMgKiBwMjEgLSAyICogcDExIC0gcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ4ID0gKDMgKiBwMzAgLSBwMTAgLSAyICogcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5ID0gKDMgKiBwMzEgLSBwMTEgLSAyICogcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLm1heChheCwgYngpICsgTWF0aC5tYXgoYXksIGJ5KSA8PSB0b2w7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0QmJveDIoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhNaW4gPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeE1heCA9IC1JbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeU1pbiA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGxldCB5TWF4ID0gLUluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLnBhdGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gb2YgcGF0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF91dGlsLlV0aWwuYmV6aWVyQm91bmRpbmdCb3goLi4uZmlyc3QsIC4uLmNvbnRyb2wxLCAuLi5jb250cm9sMiwgLi4uc2Vjb25kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNaW4gPSBNYXRoLm1pbih4TWluLCBiYm94WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNaW4gPSBNYXRoLm1pbih5TWluLCBiYm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNYXggPSBNYXRoLm1heCh4TWF4LCBiYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNYXggPSBNYXRoLm1heCh5TWF4LCBiYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hNaW4sIHlNaW4sIHhNYXgsIHlNYXhdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2dldFBhZGRpbmcyKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSA/IE1hdGguY2VpbCh0aGlzLnRoaWNrbmVzcyAqIHRoaXMucGFyZW50U2NhbGUpIDogMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9maXRUb0NvbnRlbnQyKCkgewogICAgICAgICAgICAgICAgICAgIGxldCBmaXJzdFRpbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94ID0gX2NsYXNzUHJpdmF0ZU1ldGhvZ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IHdpZHRoIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRNaW5EaW1zLCBfc2V0TWluRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldlRyYW5zbGF0aW9uWCA9IHRoaXMudHJhbnNsYXRpb25YOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZUcmFuc2xhdGlvblkgPSB0aGlzLnRyYW5zbGF0aW9uWTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zbGF0aW9uWCA9IC1iYm94WzBdOwogICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25ZID0gLWJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZWFsV2lkdGgsIHdpZHRoKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2NhbGVkUGFkZGluZyA9IGZpcnN0VGltZSA/IHBhZGRpbmcgLyB0aGlzLnNjYWxlRmFjdG9yIC8gMiA6IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUocHJldlRyYW5zbGF0aW9uWCAtIHRoaXMudHJhbnNsYXRpb25YIC0gdW5zY2FsZWRQYWRkaW5nLCBwcmV2VHJhbnNsYXRpb25ZIC0gdGhpcy50cmFuc2xhdGlvblkgLSB1bnNjYWxlZFBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1pbkRpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pID49IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluSGVpZ2h0ID0gYCR7UkVTSVpFUl9TSVpFfXB4YDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtNYXRoLnJvdW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pICogUkVTSVpFUl9TSVpFKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtSRVNJWkVSX1NJWkV9cHhgOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5taW5IZWlnaHQgPSBgJHtNYXRoLnJvdW5kKFJFU0laRVJfU0laRSAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9kZWZhdWx0Q29sb3IiLCBudWxsKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdE9wYWNpdHkiLCAxKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdFRoaWNrbmVzcyIsIDEpOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoSW5rRWRpdG9yLCAiX3R5cGUiLCAiaW5rIik7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgZml0Q3VydmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gZml0Q3VydmU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3VydmUocG9pbnRzLCBtYXhFcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkZpcnN0IGFyZ3VtZW50IHNob3VsZCBiZSBhbiBhcnJheSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaChwb2ludCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludCkgfHwgcG9pbnQuc29tZShpdGVtID0+IHR5cGVvZiBpdGVtICE9PSAnbnVtYmVyJykgfHwgcG9pbnQubGVuZ3RoICE9PSBwb2ludHNbMF0ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcigiRWFjaCBwb2ludCBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbnVtYmVycy4gRWFjaCBwb2ludCBzaG91bGQgaGF2ZSB0aGUgc2FtZSBhbW91bnQgb2YgbnVtYmVycy4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IHBvaW50cy5maWx0ZXIoKHBvaW50LCBpKSA9PiBpID09PSAwIHx8ICFwb2ludC5ldmVyeSgodmFsLCBqKSA9PiB2YWwgPT09IHBvaW50c1tpIC0gMV1bal0pKTsKICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBwb2ludHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlZnRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbMV0sIHBvaW50c1swXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmlnaHRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbbGVuIC0gMl0sIHBvaW50c1tsZW4gLSAxXSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpdEN1YmljKHBvaW50cywgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgbWF4RXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3ViaWMocG9pbnRzLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1heEl0ZXJhdGlvbnMgPSAyMDsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsIHUsIHVQcmltZSwgbWF4RXJyb3IsIHByZXZFcnIsIHNwbGl0UG9pbnQsIHByZXZTcGxpdCwgY2VudGVyVmVjdG9yLCB0b0NlbnRlclRhbmdlbnQsIGZyb21DZW50ZXJUYW5nZW50LCBiZXppZXJzLCBkaXN0LCBpOwogICAgICAgICAgICAgICAgICAgIGlmIChwb2ludHMubGVuZ3RoID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBtYXRocy52ZWN0b3JMZW4obWF0aHMuc3VidHJhY3QocG9pbnRzWzBdLCBwb2ludHNbMV0pKSAvIDMuMDsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBbcG9pbnRzWzBdLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzBdLCBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgZGlzdCkpLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzFdLCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIGRpc3QpKSwgcG9pbnRzWzFdXTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHUgPSBjaG9yZExlbmd0aFBhcmFtZXRlcml6ZShwb2ludHMpOwogICAgICAgICAgICAgICAgICAgIFtiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCB1LCB1LCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4RXJyb3IgPT09IDAgfHwgbWF4RXJyb3IgPCBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG1heEVycm9yIDwgZXJyb3IgKiBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB1UHJpbWUgPSB1OwogICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZTcGxpdCA9IHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBNYXhJdGVyYXRpb25zOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVQcmltZSA9IHJlcGFyYW1ldGVyaXplKGJlekN1cnZlLCBwb2ludHMsIHVQcmltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbYmV6Q3VydmUsIG1heEVycm9yLCBzcGxpdFBvaW50XSA9IGdlbmVyYXRlQW5kUmVwb3J0KHBvaW50cywgdSwgdVByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhFcnJvciA8IGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNwbGl0UG9pbnQgPT09IHByZXZTcGxpdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcnJDaGFuZ2UgPSBtYXhFcnJvciAvIHByZXZFcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyckNoYW5nZSA+IC45OTk5ICYmIGVyckNoYW5nZSA8IDEuMDAwMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2U3BsaXQgPSBzcGxpdFBvaW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlemllcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBjZW50ZXJWZWN0b3IgPSBtYXRocy5zdWJ0cmFjdChwb2ludHNbc3BsaXRQb2ludCAtIDFdLCBwb2ludHNbc3BsaXRQb2ludCArIDFdKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2VudGVyVmVjdG9yLmV2ZXJ5KHZhbCA9PiB2YWwgPT09IDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlclZlY3RvciA9IG1hdGhzLnN1YnRyYWN0KHBvaW50c1tzcGxpdFBvaW50IC0gMV0sIHBvaW50c1tzcGxpdFBvaW50XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFtjZW50ZXJWZWN0b3JbMF0sIGNlbnRlclZlY3RvclsxXV0gPSBbLWNlbnRlclZlY3RvclsxXSwgY2VudGVyVmVjdG9yWzBdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIC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Vycm9yKHBvaW50cywgYmV6Q3VydmUsIHBhcmFtc09yaWcpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0NhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ2FsbGJhY2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmV6OiBiZXpDdXJ2ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50czogcG9pbnRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBwYXJhbXNPcmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4RXJyOiBtYXhFcnJvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heFBvaW50OiBzcGxpdFBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlLCBtYXhFcnJvciwgc3BsaXRQb2ludF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtZXRlcnMsIGxlZnRUYW5nZW50LCByaWdodFRhbmdlbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsCiAgICAgICAgICAgICAgICAgICAgICAgIEEsCiAgICAgICAgICAgICAgICAgICAgICAgIGEsCiAgICAgICAgICAgICAgICAgICAgICAgIEMsCiAgICAgICAgICAgICAgICAgICAgICAgIFgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSwKICAgICAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1gsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9YX0MxLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9sLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9yLAogICAgICAgICAgICAgICAgICAgICAgICBlcHNpbG9uLAogICAgICAgICAgICAgICAgICAgICAgICBzZWdMZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGksCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgdG1wLAogICAgICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgICAgICB1eCwKICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RQb2ludCA9IHBvaW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFBvaW50ID0gcG9pbnRzW3BvaW50cy5sZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICBiZXpDdXJ2ZSA9IFtmaXJzdFBvaW50LCBudWxsLCBudWxsLCBsYXN0UG9pbnRdOwogICAgICAgICAgICAgICAgICAgIEEgPSBtYXRocy56ZXJvc19YeDJ4MihwYXJhbWV0ZXJzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcGFyYW1ldGVycy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB1ID0gcGFyYW1ldGVyc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgdXggPSAxIC0gdTsKICAgICAgICAgICAgICAgICAgICAgICAgYSA9IEFbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGFbMF0gPSBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgMyAqIHUgKiAodXggKiB1eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBhWzFdID0gbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCAzICogdXggKiAodSAqIHUpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQyA9IFtbMCwgMF0sIFswLCAwXV07CiAgICAgICAgICAgICAgICAgICAgWCA9IFswLCAwXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBwb2ludHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdSA9IHBhcmFtZXRlcnNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGEgPSBBW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBDWzBdWzBdICs9IG1hdGhzLmRvdChhWzBdLCBhWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ1swXVsxXSArPSBtYXRocy5kb3QoYVswXSwgYVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENbMV1bMF0gKz0gbWF0aHMuZG90KGFbMF0sIGFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICBDWzFdWzFdICs9IG1hdGhzLmRvdChhWzFdLCBhWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWF0aHMuc3VidHJhY3QocG9pbnRzW2ldLCBiZXppZXIucShbZmlyc3RQb2ludCwgZmlyc3RQb2ludCwgbGFzdFBvaW50LCBsYXN0UG9pbnRdLCB1KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMF0gKz0gbWF0aHMuZG90KGFbMF0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMV0gKz0gbWF0aHMuZG90KGFbMV0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSA9IENbMF1bMF0gKiBDWzFdWzFdIC0gQ1sxXVswXSAqIENbMF1bMV07CiAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1ggPSBDWzBdWzBdICogWFsxXSAtIENbMV1bMF0gKiBYWzBdOwogICAgICAgICAgICAgICAgICAgIGRldF9YX0MxID0gWFswXSAqIENbMV1bMV0gLSBYWzFdICogQ1swXVsxXTsKICAgICAgICAgICAgICAgICAgICBhbHBoYV9sID0gZGV0X0MwX0MxID09PSAwID8gMCA6IGRldF9YX0MxIC8gZGV0X0MwX0MxOwogICAgICAgICAgICAgICAgICAgIGFscGhhX3IgPSBkZXRfQzBfQzEgPT09IDAgPyAwIDogZGV0X0MwX1ggLyBkZXRfQzBfQzE7CiAgICAgICAgICAgICAgICAgICAgc2VnTGVuZ3RoID0gbWF0aHMudmVjdG9yTGVuKG1hdGhzLnN1YnRyYWN0KGZpcnN0UG9pbnQsIGxhc3RQb2ludCkpOwogICAgICAgICAgICAgICAgICAgIGVwc2lsb24gPSAxLjBlLTYgKiBzZWdMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFscGhhX2wgPCBlcHNpbG9uIHx8IGFscGhhX3IgPCBlcHNpbG9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBzZWdMZW5ndGggLyAzLjApKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmVbMl0gPSBtYXRocy5hZGRBcnJheXMobGFzdFBvaW50LCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIHNlZ0xlbmd0aCAvIDMuMCkpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBhbHBoYV9sKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzJdID0gbWF0aHMuYWRkQXJyYXlzKGxhc3RQb2ludCwgbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCBhbHBoYV9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXpDdXJ2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlcGFyYW1ldGVyaXplKGJlemllciwgcG9pbnRzLCBwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcmFtZXRlcnMubWFwKChwLCBpKSA9PiBuZXd0b25SYXBoc29uUm9vdEZpbmQoYmV6aWVyLCBwb2ludHNbaV0sIHApKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG5ld3RvblJhcGhzb25Sb290RmluZChiZXosIHBvaW50LCB1KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHUpLCBwb2ludCksCiAgICAgICAgICAgICAgICAgICAgICAgIHFwcmltZSA9IGJlemllci5xcHJpbWUoYmV6LCB1KSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yID0gbWF0aHMubXVsTWF0cml4KGQsIHFwcmltZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGRlbm9taW5hdG9yID0gbWF0aHMuc3VtKG1hdGhzLnNxdWFyZUl0ZW1zKHFwcmltZSkpICsgMiAqIG1hdGhzLm11bE1hdHJpeChkLCBiZXppZXIucXByaW1lcHJpbWUoYmV6LCB1KSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlbm9taW5hdG9yID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1IC0gbnVtZXJhdG9yIC8gZGVub21pbmF0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY2hvcmRMZW5ndGhQYXJhbWV0ZXJpemUocG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHUgPSBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgY3VyclUsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZVLAogICAgICAgICAgICAgICAgICAgICAgICBwcmV2UDsKICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaCgocCwgaSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjdXJyVSA9IGkgPyBwcmV2VSArIG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChwLCBwcmV2UCkpIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgdS5wdXNoKGN1cnJVKTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlUgPSBjdXJyVTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlAgPSBwOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHUgPSB1Lm1hcCh4ID0+IHggLyBwcmV2VSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wdXRlTWF4RXJyb3IocG9pbnRzLCBiZXosIHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzdCwgbWF4RGlzdCwgc3BsaXRQb2ludCwgdiwgaSwgY291bnQsIHBvaW50LCB0OwogICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSAwOwogICAgICAgICAgICAgICAgICAgIHNwbGl0UG9pbnQgPSBNYXRoLmZsb29yKHBvaW50cy5sZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0X2Rpc3RNYXAgPSBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyhiZXosIDEwKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBjb3VudCA9IHBvaW50cy5sZW5ndGg7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ID0gcG9pbnRzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICB0ID0gZmluZF90KGJleiwgcGFyYW1ldGVyc1tpXSwgdF9kaXN0TWFwLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHQpLCBwb2ludCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSB2WzBdICogdlswXSArIHZbMV0gKiB2WzFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG1heERpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaXRQb2ludCA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFttYXhEaXN0LCBzcGxpdFBvaW50XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIHZhciBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyA9IGZ1bmN0aW9uIChiZXosIEJfcGFydHMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQl90X2N1cnI7CiAgICAgICAgICAgICAgICAgICAgdmFyIEJfdF9kaXN0ID0gWzBdOwogICAgICAgICAgICAgICAgICAgIHZhciBCX3RfcHJldiA9IGJlelswXTsKICAgICAgICAgICAgICAgICAgICB2YXIgc3VtTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8PSBCX3BhcnRzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2N1cnIgPSBiZXppZXIucShiZXosIGkgLyBCX3BhcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtTGVuICs9IG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChCX3RfY3VyciwgQl90X3ByZXYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2Rpc3QucHVzaChzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBCX3RfcHJldiA9IEJfdF9jdXJyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBCX3RfZGlzdCA9IEJfdF9kaXN0Lm1hcCh4ID0+IHggLyBzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBCX3RfZGlzdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaW5kX3QoYmV6LCBwYXJhbSwgdF9kaXN0TWFwLCBCX3BhcnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbk1heCwgbGVuTWluLCB0TWF4LCB0TWluLCB0OwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAxOyBpIDw9IEJfcGFydHM7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW0gPD0gdF9kaXN0TWFwW2ldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWluID0gKGkgLSAxKSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWF4ID0gaSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5NaW4gPSB0X2Rpc3RNYXBbaSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuTWF4ID0gdF9kaXN0TWFwW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IChwYXJhbSAtIGxlbk1pbikgLyAobGVuTWF4IC0gbGVuTWluKSAqICh0TWF4IC0gdE1pbikgKyB0TWluOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVUYW5nZW50KHBvaW50QSwgcG9pbnRCKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLm5vcm1hbGl6ZShtYXRocy5zdWJ0cmFjdChwb2ludEEsIHBvaW50QikpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgbWF0aHMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB6ZXJvc19YeDJ4Mih4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB6cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoeC0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6cy5wdXNoKFswLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHpzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgbXVsSXRlbXMoaXRlbXMsIG11bHRpcGxpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggKiBtdWx0aXBsaWVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG11bE1hdHJpeChtMSwgbTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG0xLnJlZHVjZSgoc3VtLCB4MSwgaSkgPT4gc3VtICsgeDEgKiBtMltpXSwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzdWJ0cmFjdChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLm1hcCgoeDEsIGkpID0+IHgxIC0gYXJyMltpXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhZGRBcnJheXMoYXJyMSwgYXJyMikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5tYXAoKHgxLCBpKSA9PiB4MSArIGFycjJbaV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYWRkSXRlbXMoaXRlbXMsIGFkZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICsgYWRkaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc3VtKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5yZWR1Y2UoKHN1bSwgeCkgPT4gc3VtICsgeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkb3QobTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYXRocy5tdWxNYXRyaXgobTEsIG0yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHZlY3Rvckxlbih2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmh5cG90KC4uLnYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGl2SXRlbXMoaXRlbXMsIGRpdmlzb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggLyBkaXZpc29yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNxdWFyZUl0ZW1zKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICogeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemUodikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXZJdGVtcyh2LCB0aGlzLnZlY3Rvckxlbih2KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgYmV6aWVyIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcShjdHJsUG9seSwgdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHggPSAxLjAgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcEEgPSBtYXRocy5tdWxJdGVtcyhjdHJsUG9seVswXSwgdHggKiB0eCAqIHR4KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBCID0gbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMV0sIDMgKiB0eCAqIHR4ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQyA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzJdLCAzICogdHggKiB0ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwRCA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzNdLCB0ICogdCAqIHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWF0aHMuYWRkQXJyYXlzKG1hdGhzLmFkZEFycmF5cyhwQSwgcEIpLCBtYXRocy5hZGRBcnJheXMocEMsIHBEKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBxcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gMS4wIC0gdDsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBBID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMV0sIGN0cmxQb2x5WzBdKSwgMyAqIHR4ICogdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcEIgPSBtYXRocy5tdWxJdGVtcyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVsyXSwgY3RybFBvbHlbMV0pLCA2ICogdHggKiB0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbM10sIGN0cmxQb2x5WzJdKSwgMyAqIHQgKiB0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5hZGRBcnJheXMocEEsIHBCKSwgcEMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcXByaW1lcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5tdWxJdGVtcyhtYXRocy5hZGRBcnJheXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMl0sIG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzFdLCAyKSksIGN0cmxQb2x5WzBdKSwgNiAqICgxLjAgLSB0KSksIG1hdGhzLm11bEl0ZW1zKG1hdGhzLmFkZEFycmF5cyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVszXSwgbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMl0sIDIpKSwgY3RybFBvbHlbMV0pLCA2ICogdCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZml0Q3VydmU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cy5maXRDdWJpYyA9IGZpdEN1YmljOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuY3JlYXRlVGFuZ2VudCA9IGNyZWF0ZVRhbmdlbnQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25MYXllciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fc3RvcmFnZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM5KTsKICAgICAgICAgICAgICAgIHZhciBfc2NyaXB0aW5nX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjgpOwogICAgICAgICAgICAgICAgdmFyIF94ZmFfbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2OSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHJlY2VpdmVyLCBjbGFzc0NvbnN0cnVjdG9yLCBtZXRob2QpIHsgX2NsYXNzQ2hlY2tQcml2YXRlU3RhdGljQWNjZXNzKHJlY2VpdmVyLCBj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9IDEwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBERUZBVUxUX0ZPTlRfU0laRSA9IDk7CiAgICAgICAgICAgICAgICBjb25zdCBHZXRFbGVtZW50c0J5TmFtZVNldCA9IG5ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRSZWN0RGltcyhyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGg6IHJlY3RbMl0gLSByZWN0WzBdLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQ6IHJlY3RbM10gLSByZWN0WzFdCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25FbGVtZW50RmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGNyZWF0ZShwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YnR5cGUgPSBwYXJhbWV0ZXJzLmRhdGEuYW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc3VidHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5MSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTGlua0Fubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5URVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5XSURHRVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRUeXBlID0gcGFyYW1ldGVycy5kYXRhLmZpZWxkVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGZpZWxkVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFRleHRXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQnRuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXJzLmRhdGEucmFkaW9CdXR0b24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlvQnV0dG9uV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtZXRlcnMuZGF0YS5jaGVja0JveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2hlY2tib3hXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHVzaEJ1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT1BVUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRnJlZVRleHRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVQVJFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3F1YXJlQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNJUkNMRToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENpcmNsZUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT0xZTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNBUkVUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2FyZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW5rQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQb2x5Z29uQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkhJR0hMSUdIVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEhpZ2hsaWdodEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5VTkRFUkxJTkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVbmRlcmxpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5TVFJJS0VPVVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpa2VPdXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGFtcEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5GSUxFQVRUQUNITUVOVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZpbGVBdHRhY2htZW50QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXIgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNSZW5kZXJhYmxlID0gaXNSZW5kZXJhYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEgPSBwYXJhbWV0ZXJzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGF5ZXIgPSBwYXJhbWV0ZXJzLmxheWVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2UgPSBwYXJhbWV0ZXJzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSBwYXJhbWV0ZXJzLnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmtTZXJ2aWNlID0gcGFyYW1ldGVycy5saW5rU2VydmljZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZE1hbmFnZXIgPSBwYXJhbWV0ZXJzLmRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbWFnZVJlc291cmNlc1BhdGggPSBwYXJhbWV0ZXJzLmltYWdlUmVzb3VyY2VzUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJGb3JtcyA9IHBhcmFtZXRlcnMucmVuZGVyRm9ybXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRmFjdG9yeSA9IHBhcmFtZXRlcnMuc3ZnRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZSA9IHBhcmFtZXRlcnMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlU2NyaXB0aW5nID0gcGFyYW1ldGVycy5lbmFibGVTY3JpcHRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGFzSlNBY3Rpb25zID0gcGFyYW1ldGVycy5oYXNKU0FjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZWxkT2JqZWN0cyA9IHBhcmFtZXRlcnMuZmllbGRPYmplY3RzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lciA9IHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjcmVhdGVRdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5xdWFkcmlsYXRlcmFscyA9IHRoaXMuX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKGlnbm9yZUJvcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlnbm9yZUJvcmRlciA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNlY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnNldEF0dHJpYnV0ZSgiZGF0YS1hbm5vdGF0aW9uLWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLm5vUm90YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgibm9yb3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW2RhdGEucmVjdFswXSwgcGFnZS52aWV3WzNdIC0gZGF0YS5yZWN0WzFdICsgcGFnZS52aWV3WzFdLCBkYXRhLnJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIGRhdGEucmVjdFszXSArIHBhZ2Uudmlld1sxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlnbm9yZUJvcmRlciAmJiBkYXRhLmJvcmRlclN0eWxlLndpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlcldpZHRoID0gYCR7ZGF0YS5ib3JkZXJTdHlsZS53aWR0aH1weGA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBob3Jpem9udGFsUmFkaXVzID0gZGF0YS5ib3JkZXJTdHlsZS5ob3Jpem9udGFsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGljYWxSYWRpdXMgPSBkYXRhLmJvcmRlclN0eWxlLnZlcnRpY2FsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhvcml6b250YWxSYWRpdXMgPiAwIHx8IHZlcnRpY2FsUmFkaXVzID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhZGl1cyA9IGBjYWxjKCR7aG9yaXpvbnRhbFJhZGl1c31weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke3ZlcnRpY2FsUmFkaXVzfXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJSYWRpdXMgPSByYWRpdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMgaW5zdGFuY2VvZiBSYWRpb0J1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFkaXVzID0gYGNhbGMoJHt3aWR0aH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke2hlaWdodH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyUmFkaXVzID0gcmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChkYXRhLmJvcmRlclN0eWxlLnN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLlNPTElEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuREFTSEVEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAiZGFzaGVkIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLkJFVkVMRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBib3JkZXIgc3R5bGU6IGJldmVsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLklOU0VUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuaW1wbGVtZW50ZWQgYm9yZGVyIHN0eWxlOiBpbnNldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuVU5ERVJMSU5FOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyQm90dG9tU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlckNvbG9yID0gZGF0YS5ib3JkZXJDb2xvciB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJvcmRlckNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlckNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoYm9yZGVyQ29sb3JbMF0gfCAwLCBib3JkZXJDb2xvclsxXSB8IDAsIGJvcmRlckNvbG9yWzJdIHwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJXaWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocmVjdFswXSAtIHBhZ2VYKSAvIHBhZ2VXaWR0aH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLnRvcCA9IGAkezEwMCAqIChyZWN0WzFdIC0gcGFnZVkpIC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmhhc093bkNhbnZhcyB8fCByb3RhdGlvbiA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLndpZHRoID0gYCR7MTAwICogd2lkdGggLyBwYWdlV2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogaGVpZ2h0IC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24ocm90YXRpb24sIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Um90YXRpb24oYW5nbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMudmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKHRoaXMuZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRXaWR0aCwgZWxlbWVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ2xlICUgMTgwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50V2lkdGggPSAxMDAgKiB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRIZWlnaHQgPSAxMDAgKiBoZWlnaHQgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFdpZHRoID0gMTAwICogaGVpZ2h0IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudEhlaWdodCA9IDEwMCAqIHdpZHRoIC8gcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUud2lkdGggPSBgJHtlbGVtZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5oZWlnaHQgPSBgJHtlbGVtZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc2V0QXR0cmlidXRlKCJkYXRhLW1haW4tcm90YXRpb24iLCAoMzYwIC0gYW5nbGUpICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9jb21tb25BY3Rpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXRDb2xvciA9IChqc05hbWUsIHN0eWxlTmFtZSwgZXZlbnQpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gZXZlbnQuZGV0YWlsW2pzTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuc3R5bGVbc3R5bGVOYW1lXSA9IF9zY3JpcHRpbmdfdXRpbHMuQ29sb3JDb252ZXJ0ZXJzW2Ake2NvbG9yWzBdfV9IVE1MYF0oY29sb3Iuc2xpY2UoMSkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9jb21tb25BY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhpZGRlbiA9IGV2ZW50LmRldGFpbC5kaXNwbGF5ICUgMiA9PT0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gaGlkZGVuID8gImhpZGRlbiIgOiAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXRWYWx1ZSh0aGlzLmRhdGEuaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlkZGVuLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDAgfHwgZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50OiBldmVudC5kZXRhaWwucHJpbnQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRkZW46IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gZXZlbnQuZGV0YWlsLmhpZGRlbiA/ICJoaWRkZW4iIDogInZpc2libGUiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGRlbjogZXZlbnQuZGV0YWlsLmhpZGRlbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvY3VzOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiBldmVudC50YXJnZXQuZm9jdXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2ZW50U2Nyb2xsOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyTmFtZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC50aXRsZSA9IGV2ZW50LmRldGFpbC51c2VyTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkb25seTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5kZXRhaWwucmVhZG9ubHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnNldEF0dHJpYnV0ZSgicmVhZG9ubHkiLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnJlbW92ZUF0dHJpYnV0ZSgicmVhZG9ubHkiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQ6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZXF1aXJlZChldmVudC50YXJnZXQsIGV2ZW50LmRldGFpbC5yZXF1aXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJiZ0NvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ29sb3I6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRDb2xvcigiZmlsbENvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoImZnQ29sb3IiLCAiY29sb3IiLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoInRleHRDb2xvciIsICJjb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3JkZXJDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJib3JkZXJDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJva2VDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJzdHJva2VDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuZ2xlID0gZXZlbnQuZGV0YWlsLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24oYW5nbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiBhbmdsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmtleXMoanNFdmVudC5kZXRhaWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBhY3Rpb25zW25hbWVdIHx8IGNvbW1vbkFjdGlvbnNbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24gPT09IG51bGwgfHwgYWN0aW9uID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhY3Rpb24oanNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmVuYWJsZVNjcmlwdGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlLmdldFJhd1ZhbHVlKHRoaXMuZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RvcmVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFthY3Rpb25OYW1lLCBkZXRhaWxdIG9mIE9iamVjdC5lbnRyaWVzKHN0b3JlZERhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBjb21tb25BY3Rpb25zW2FjdGlvbk5hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV2ZW50UHJveHkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW2FjdGlvbk5hbWVdOiBkZXRhaWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBlbGVtZW50CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24oZXZlbnRQcm94eSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHN0b3JlZERhdGFbYWN0aW9uTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWdub3JlQm9yZGVyID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEucXVhZFBvaW50cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcXVhZHJpbGF0ZXJhbHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRSZWN0ID0gdGhpcy5kYXRhLnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcXVhZFBvaW50IG9mIHRoaXMuZGF0YS5xdWFkUG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IFtxdWFkUG9pbnRbMl0ueCwgcXVhZFBvaW50WzJdLnksIHF1YWRQb2ludFsxXS54LCBxdWFkUG9pbnRbMV0ueV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWFkcmlsYXRlcmFscy5wdXNoKHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IHNhdmVkUmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlUG9wdXAodHJpZ2dlciwgZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29udGFpbmVyID0gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmlnZ2VyID0gdHJpZ2dlciB8fCB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGhpcy5xdWFkcmlsYXRlcmFsc1swXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRyaWdnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBUcmlnZ2VyQXJlYSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cEVsZW1lbnQgPSBuZXcgUG9wdXBFbGVtZW50KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogZGF0YS5jb2xvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlT2JqOiBkYXRhLnRpdGxlT2JqLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZTogZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IGRhdGEuY29udGVudHNPYmosCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWNoVGV4dDogZGF0YS5yaWNoVGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVXcmFwcGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cCA9IHBvcHVwRWxlbWVudC5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuc3R5bGUubGVmdCA9ICIxMDAlIjsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJRdWFkcmlsYXRlcmFscyhjbGFzc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBxdWFkcmlsYXRlcmFsIG9mIHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1YWRyaWxhdGVyYWwuY2xhc3NMaXN0LmFkZChjbGFzc05hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgQW5ub3RhdGlvbkVsZW1lbnQucmVuZGVyYCBjYWxsZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNraXBJZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9maWVsZE9iamVjdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkT2JqID0gdGhpcy5fZmllbGRPYmplY3RzW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHBvcnRWYWx1ZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYWdlID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gdHlwZW9mIGV4cG9ydFZhbHVlcyA9PT0gInN0cmluZyIgPyBleHBvcnRWYWx1ZXMgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9tRWxlbWVudCAmJiAhR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9nZXRFbGVtZW50c0J5TmFtZSAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmllbGRzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZG9tRWxlbWVudCBvZiBkb2N1bWVudC5nZXRFbGVtZW50c0J5TmFtZShuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZG9tRWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZG9tRWxlbWVudC5nZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpZWxkczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX3NldEludGVybmFsTGluayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9iaW5kU2V0T0NHU3RhdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIExpbmtBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcHRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6ICEhKG9wdGlvbnMgIT09IG51bGwgJiYgb3B0aW9ucyAhPT0gdm9pZCAwICYmIG9wdGlvbnMuaWdub3JlQm9yZGVyKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2JpbmRTZXRPQ0dTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc1Rvb2x0aXBPbmx5ID0gcGFyYW1ldGVycy5kYXRhLmlzVG9vbHRpcE9ubHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYSIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc0JvdW5kID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlua1NlcnZpY2UuYWRkTGlua0F0dHJpYnV0ZXMobGluaywgZGF0YS51cmwsIGRhdGEubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kTmFtZWRBY3Rpb24obGluaywgZGF0YS5hY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5hdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kQXR0YWNobWVudChsaW5rLCBkYXRhLmF0dGFjaG1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5zZXRPQ0dTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYmluZFNldE9DR1N0YXRlLCBfYmluZFNldE9DR1N0YXRlMikuY2FsbCh0aGlzLCBsaW5rLCBkYXRhLnNldE9DR1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuZGVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZExpbmsobGluaywgZGF0YS5kZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEuYWN0aW9ucyAmJiAoZGF0YS5hY3Rpb25zLkFjdGlvbiB8fCBkYXRhLmFjdGlvbnNbIk1vdXNlIFVwIl0gfHwgZGF0YS5hY3Rpb25zWyJNb3VzZSBEb3duIl0pICYmIHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEucmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZFJlc2V0Rm9ybUFjdGlvbihsaW5rLCBkYXRhLnJlc2V0Rm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaXNUb29sdGlwT25seSAmJiAhaXNCb3VuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2JpbmRMaW5rKGxpbmssICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0JvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5xdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlbmRlclF1YWRyaWxhdGVyYWxzKCJsaW5rQW5ub3RhdGlvbiIpLm1hcCgocXVhZHJpbGF0ZXJhbCwgaW5kZXgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rRWxlbWVudCA9IGluZGV4ID09PSAwID8gbGluayA6IGxpbmsuY2xvbmVOb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVhZHJpbGF0ZXJhbC5hcHBlbmQobGlua0VsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWFkcmlsYXRlcmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGlua0Fubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzQm91bmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChsaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kTGluayhsaW5rLCBkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldERlc3RpbmF0aW9uSGFzaChkZXN0aW5hdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZ29Ub0Rlc3RpbmF0aW9uKGRlc3RpbmF0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlc3RpbmF0aW9uIHx8IGRlc3RpbmF0aW9uID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZE5hbWVkQWN0aW9uKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldEFuY2hvclVybCgiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZU5hbWVkQWN0aW9uKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kQXR0YWNobWVudChsaW5rLCBhdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRkb3dubG9hZE1hbmFnZXIgPSB0aGlzLmRvd25sb2FkTWFuYWdlcikgPT09IG51bGwgfHwgX3RoaXMkZG93bmxvYWRNYW5hZ2VyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIub3Blbk9yRG93bmxvYWREYXRhKHRoaXMuY29udGFpbmVyLCBhdHRhY2htZW50LmNvbnRlbnQsIGF0dGFjaG1lbnQuZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRJbnRlcm5hbExpbmssIF9zZXRJbnRlcm5hbExpbmsyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKFtbIkFjdGlvbiIsICJvbmNsaWNrIl0sIFsiTW91c2UgVXAiLCAib25tb3VzZXVwIl0sIFsiTW91c2UgRG93biIsICJvbm1vdXNlZG93biJdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3Qua2V5cyhkYXRhLmFjdGlvbnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqc05hbWUgPSBtYXAuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFqc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtbanNOYW1lXSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBkYXRhLmlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxpbmsub25jbGljaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2JpbmRSZXNldEZvcm1BY3Rpb24obGluaywgcmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyQ2xpY2tBY3Rpb24gPSBsaW5rLm9uY2xpY2s7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fZmllbGRPYmplY3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9iaW5kUmVzZXRGb3JtQWN0aW9uIC0gInJlc2V0Rm9ybSIgYWN0aW9uIG5vdCBzdXBwb3J0ZWQsIGAgKyAiZW5zdXJlIHRoYXQgdGhlIGBmaWVsZE9iamVjdHNgIHBhcmFtZXRlciBpcyBwcm92aWRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG90aGVyQ2xpY2tBY3Rpb24gPT09IG51bGwgfHwgb3RoZXJDbGlja0FjdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb3RoZXJDbGlja0FjdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkczogcmVzZXRGb3JtRmllbGRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZnM6IHJlc2V0Rm9ybVJlZnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHJlc2V0Rm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFsbEZpZWxkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc2V0Rm9ybUZpZWxkcy5sZW5ndGggIT09IDAgfHwgcmVzZXRGb3JtUmVmcy5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZElkcyA9IG5ldyBTZXQocmVzZXRGb3JtUmVmcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZE5hbWUgb2YgcmVzZXRGb3JtRmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IHRoaXMuX2ZpZWxkT2JqZWN0c1tmaWVsZE5hbWVdIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgZmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZElkcy5hZGQoaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkSWRzLmhhcyhmaWVsZC5pZCkgPT09IGluY2x1ZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaChmaWVsZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaCguLi5maWVsZHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWxsSWRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGFsbEZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZmllbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsSWRzLnB1c2goaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmllbGQudHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2hlY2tib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJyYWRpb2J1dHRvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZmllbGQuZGVmYXVsdFZhbHVlID09PSBmaWVsZC5leHBvcnRWYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY29tYm9ib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJsaXN0Ym94IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFHZXRFbGVtZW50c0J5TmFtZVNldC5oYXMoZG9tRWxlbWVudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBfYmluZFJlc2V0Rm9ybUFjdGlvbiAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb21FbGVtZW50LmRpc3BhdGNoRXZlbnQobmV3IEV2ZW50KCJyZXNldGZvcm0iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogImFwcCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZHM6IGFsbElkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJSZXNldEZvcm0iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0SW50ZXJuYWxMaW5rMigpIHsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zZXRBdHRyaWJ1dGUoImRhdGEtaW50ZXJuYWwtbGluayIsICIiKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9iaW5kU2V0T0NHU3RhdGUyKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICBsaW5rLm9uY2xpY2sgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZVNldE9DR1N0YXRlKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2ggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2guc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltYWdlID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW1nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLnNyYyA9IHRoaXMuaW1hZ2VSZXNvdXJjZXNQYXRoICsgImFubm90YXRpb24tIiArIHRoaXMuZGF0YS5uYW1lLnRvTG93ZXJDYXNlKCkgKyAiLnN2ZyI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmFsdCA9ICJbe3t0eXBlfX0gQW5ub3RhdGlvbl0iOwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS5kYXRhc2V0LmwxMG5JZCA9ICJ0ZXh0X2Fubm90YXRpb25fdHlwZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmRhdGFzZXQubDEwbkFyZ3MgPSBKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmRhdGEubmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKGltYWdlLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChpbWFnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci50aXRsZSA9IHRoaXMuZGF0YS5hbHRlcm5hdGl2ZVRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0S2V5TW9kaWZpZXIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc1dpbiAmJiBldmVudC5jdHJsS2V5IHx8IGlzTWFjICYmIGV2ZW50Lm1ldGFLZXk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRFdmVudExpc3RlbmVyKGVsZW1lbnQsIGJhc2VOYW1lLCBldmVudE5hbWUsIHZhbHVlR2V0dGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYXNlTmFtZS5pbmNsdWRlcygibW91c2UiKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTMgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmUzLmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaGlmdDogZXZlbnQuc2hpZnRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmllcjogdGhpcy5fZ2V0S2V5TW9kaWZpZXIoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU0LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldEV2ZW50TGlzdGVuZXJzKGVsZW1lbnQsIG5hbWVzLCBnZXR0ZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbYmFzZU5hbWUsIGV2ZW50TmFtZV0gb2YgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkYXRhJGFjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnROYW1lID09PSAiQWN0aW9uIiB8fCAoX3RoaXMkZGF0YSRhY3Rpb25zID0gdGhpcy5kYXRhLmFjdGlvbnMpICE9PSBudWxsICYmIF90aGlzJGRhdGEkYWN0aW9ucyAhPT0gdm9pZCAwICYmIF90aGlzJGRhdGEkYWN0aW9uc1tldmVudE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcihlbGVtZW50LCBiYXNlTmFtZSwgZXZlbnROYW1lLCBnZXR0ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IHRoaXMuZGF0YS5iYWNrZ3JvdW5kQ29sb3IgfHwgbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBjb2xvciA9PT0gbnVsbCA/ICJ0cmFuc3BhcmVudCIgOiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFRleHRTdHlsZShlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFRFWFRfQUxJR05NRU5UID0gWyJsZWZ0IiwgImNlbnRlciIsICJyaWdodCJdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250Q29sb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5kZWZhdWx0QXBwZWFyYW5jZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YS5mb250U2l6ZSB8fCBERUZBVUxUX0ZPTlRfU0laRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBlbGVtZW50LnN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29tcHV0ZWRGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQk9SREVSX1NJWkUgPSAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZFRvT25lRGVjaW1hbCA9IHggPT4gTWF0aC5yb3VuZCgxMCAqIHgpIC8gMTA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEubXVsdGlMaW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLmFicyh0aGlzLmRhdGEucmVjdFszXSAtIHRoaXMuZGF0YS5yZWN0WzFdIC0gQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbnVtYmVyT2ZMaW5lcyA9IE1hdGgucm91bmQoaGVpZ2h0IC8gKF91dGlsLkxJTkVfRkFDVE9SICogZm9udFNpemUpKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZUhlaWdodCA9IGhlaWdodCAvIG51bWJlck9mTGluZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wdXRlZEZvbnRTaXplID0gTWF0aC5taW4oZm9udFNpemUsIHJvdW5kVG9PbmVEZWNpbWFsKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUikpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gTWF0aC5hYnModGhpcy5kYXRhLnJlY3RbM10gLSB0aGlzLmRhdGEucmVjdFsxXSAtIEJPUkRFUl9TSVpFKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkRm9udFNpemUgPSBNYXRoLm1pbihmb250U2l6ZSwgcm91bmRUb09uZURlY2ltYWwoaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7Y29tcHV0ZWRGb250U2l6ZX1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihmb250Q29sb3JbMF0sIGZvbnRDb2xvclsxXSwgZm9udENvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS50ZXh0QWxpZ25tZW50ICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBURVhUX0FMSUdOTUVOVFt0aGlzLmRhdGEudGV4dEFsaWdubWVudF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlcXVpcmVkKGVsZW1lbnQsIGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJyZXF1aXJlZCIsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5yZW1vdmVBdHRyaWJ1dGUoInJlcXVpcmVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImFyaWEtcmVxdWlyZWQiLCBpc1JlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0V2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zIHx8ICFwYXJhbWV0ZXJzLmRhdGEuaGFzQXBwZWFyYW5jZSAmJiAhIXBhcmFtZXRlcnMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFByb3BlcnR5T25TaWJsaW5ncyhiYXNlLCBrZXksIHZhbHVlLCBrZXlJblN0b3JhZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWxlbWVudCBvZiB0aGlzLl9nZXRFbGVtZW50c0J5TmFtZShiYXNlLm5hbWUsIGJhc2UuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5kb21FbGVtZW50W2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoZWxlbWVudC5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtrZXlJblN0b3JhZ2VdOiB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWQgPSB0aGlzLmRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRXaWRnZXRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbGVtZW50ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucmVuZGVyRm9ybXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSBzdG9yYWdlLmdldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0Q29udGVudCA9IHN0b3JlZERhdGEuZm9ybWF0dGVkVmFsdWUgfHwgc3RvcmVkRGF0YS52YWx1ZSB8fCAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heExlbiA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyTGltaXQ6IHRoaXMuZGF0YS5tYXhMZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNoYXJMaW1pdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4gJiYgdGV4dENvbnRlbnQubGVuZ3RoID4gbWF4TGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbnRlbnQgPSB0ZXh0Q29udGVudC5zbGljZSgwLCBtYXhMZW4pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudERhdGEgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlclZhbHVlOiB0ZXh0Q29udGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0Q29tbWl0dGVkVmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiAxCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgidGV4dGFyZWEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRleHRDb250ZW50ID0gdGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5kb05vdFNjcm9sbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLm92ZXJmbG93WSA9ICJoaWRkZW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImlucHV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInRleHQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJ2YWx1ZSIsIHRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmRvTm90U2Nyb2xsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUub3ZlcmZsb3dYID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZGlzYWJsZWQgPSB0aGlzLmRhdGEucmVhZE9ubHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm5hbWUgPSB0aGlzLmRhdGEuZmllbGROYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm1heExlbmd0aCA9IG1heExlbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRQcm9wZXJ0eU9uU2libGluZ3MoZWxlbWVudCwgInZhbHVlIiwgZXZlbnQudGFyZ2V0LnZhbHVlLCAidmFsdWUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVmYXVsdFZhbHVlID0gdGhpcy5kYXRhLmRlZmF1bHRGaWVsZFZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSBkZWZhdWx0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYmx1ckxpc3RlbmVyID0gZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZWxlbWVudERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcm1hdHRlZFZhbHVlICE9PSBudWxsICYmIGZvcm1hdHRlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zY3JvbGxMZWZ0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSRhY3Rpb25zMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImZvY3VzIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudERhdGEudXNlclZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdGFyZ2V0LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS5jb21taXRLZXkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9ucyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEudXNlclZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGVsZW1lbnREYXRhLnVzZXJWYWx1ZS50b1N0cmluZygpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlZFZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBmb3JtYXR0ZWRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9ybWF0dGVkVmFsdWUgIT09IG51bGwgJiYgZm9ybWF0dGVkVmFsdWUgIT09IHVuZGVmaW5lZCAmJiBldmVudC50YXJnZXQgIT09IGRvY3VtZW50LmFjdGl2ZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxSYW5nZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zZXRTZWxlY3Rpb25SYW5nZSguLi5ldmVudC5kZXRhaWwuc2VsUmFuZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJMaW1pdDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhckxpbWl0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LmRldGFpbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hhckxpbWl0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVBdHRyaWJ1dGUoIm1heExlbmd0aCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5zZXRBdHRyaWJ1dGUoIm1heExlbmd0aCIsIGNoYXJMaW1pdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdmFsdWUgfHwgdmFsdWUubGVuZ3RoIDw9IGNoYXJMaW1pdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gdmFsdWUuc2xpY2UoMCwgY2hhckxpbWl0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU1LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiB0YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxFbmQ6IHRhcmdldC5zZWxlY3Rpb25FbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kaXNwYXRjaEV2ZW50RnJvbVNhbmRib3goYWN0aW9ucywganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbW1pdEtleSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQua2V5ID09PSAiRXNjYXBlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChldmVudC5rZXkgPT09ICJFbnRlciIgJiYgIXRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZXZlbnQua2V5ID09PSAiVGFiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tbWl0S2V5ID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50RGF0YS5sYXN0Q29tbWl0dGVkVmFsdWUgPT09IHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnREYXRhLnVzZXJWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlNiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxTdGFydDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBfYmx1ckxpc3RlbmVyID0gYmx1ckxpc3RlbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsdXJMaXN0ZW5lciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJibHVyIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWV2ZW50LnJlbGF0ZWRUYXJnZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnREYXRhLmxhc3RDb21taXR0ZWRWYWx1ZSAhPT0gdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTcgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU3ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU3LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiBlbGVtZW50RGF0YS5jb21taXRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiBldmVudC50YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9ibHVyTGlzdGVuZXIoZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkZGF0YSRhY3Rpb25zMiA9IHRoaXMuZGF0YS5hY3Rpb25zKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJGFjdGlvbnMyICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRhY3Rpb25zMi5LZXlzdHJva2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJiZWZvcmVpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxTdGFydCA9IHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZCA9IHNlbGVjdGlvbkVuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZXZlbnQuaW5wdXRUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoID0gdmFsdWUuc3Vic3RyaW5nKDAsIHNlbGVjdGlvblN0YXJ0KS5tYXRjaCgvXHcqW15cd10qJC8pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2ggPSB2YWx1ZS5zdWJzdHJpbmcoc2VsZWN0aW9uU3RhcnQpLm1hdGNoKC9eW15cd10qXHcqLyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGVjdGlvblN0YXJ0ID09PSBzZWxlY3Rpb25FbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uU3RhcnQgPT09IHNlbGVjdGlvbkVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTggPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU4ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU4LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlOiBkYXRhIHx8ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQudmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsdXJMaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIGJsdXJMaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmNvbWIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZFdpZHRoID0gdGhpcy5kYXRhLnJlY3RbMl0gLSB0aGlzLmRhdGEucmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb21iV2lkdGggPSBmaWVsZFdpZHRoIC8gbWF4TGVuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZCgiY29tYiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUubGV0dGVyU3BhY2luZyA9IGBjYWxjKCR7Y29tYldpZHRofXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSAtIDFjaClgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50ZXh0Q29udGVudCA9IHRoaXMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS52ZXJ0aWNhbEFsaWduID0gIm1pZGRsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLmRpc3BsYXkgPSAidGFibGUtY2VsbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0VGV4dFN0eWxlKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDaGVja2JveFdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmV4cG9ydFZhbHVlID09PSBkYXRhLmZpZWxkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSAiT2ZmIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJjaGVja0JveCIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gImNoZWNrYm94IjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZXhwb3J0VmFsdWUiLCBkYXRhLmV4cG9ydFZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNoZWNrYm94IG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUsIGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIGNoZWNrYm94LmV4cG9ydFZhbHVlID09PSBkYXRhLmV4cG9ydFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja2JveC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrYm94LmRvbUVsZW1lbnQuY2hlY2tlZCA9IGN1ckNoZWNrZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoY2hlY2tib3guaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGN1ckNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWUgfHwgIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSA9PT0gZGF0YS5leHBvcnRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGV2ZW50LmRldGFpbC52YWx1ZSAhPT0gIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGV2ZW50LnRhcmdldC5jaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRFdmVudExpc3RlbmVycyhlbGVtZW50LCBbWyJjaGFuZ2UiLCAiVmFsaWRhdGUiXSwgWyJjaGFuZ2UiLCAiQWN0aW9uIl0sIFsiZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQuY2hlY2tlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0QmFja2dyb3VuZENvbG9yKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuYXBwZW5kKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUmFkaW9CdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIFdpZGdldEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZTogcGFyYW1ldGVycy5yZW5kZXJGb3JtcwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJidXR0b25XaWRnZXRBbm5vdGF0aW9uIiwgInJhZGlvQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmZpZWxkVmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSBkYXRhLmJ1dHRvblZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInJhZGlvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRhYkluZGV4ID0gREVGQVVMVF9UQUJfSU5ERVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiY2hhbmdlIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LnRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmFkaW8gb2YgdGhpcy5fZ2V0RWxlbWVudHNCeU5hbWUobmFtZSwgaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShyYWRpby5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSAhPT0gbnVsbCAmJiBkZWZhdWx0VmFsdWUgIT09IHVuZGVmaW5lZCAmJiBkZWZhdWx0VmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZkJ1dHRvblZhbHVlID0gZGF0YS5idXR0b25WYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb25zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hlY2tlZCA9IHBkZkJ1dHRvblZhbHVlID09PSBldmVudC5kZXRhaWwudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJhZGlvIG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKGV2ZW50LnRhcmdldC5uYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIHJhZGlvLmlkID09PSBpZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFkaW8uZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYWRpby5kb21FbGVtZW50LmNoZWNrZWQgPSBjdXJDaGVja2VkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKHJhZGlvLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjdXJDaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siY2hhbmdlIiwgIlZhbGlkYXRlIl0sIFsiY2hhbmdlIiwgIkFjdGlvbiJdLCBbImZvY3VzIiwgIkZvY3VzIl0sIFsiYmx1ciIsICJCbHVyIl0sIFsibW91c2Vkb3duIiwgIk1vdXNlIERvd24iXSwgWyJtb3VzZWVudGVyIiwgIk1vdXNlIEVudGVyIl0sIFsibW91c2VsZWF2ZSIsICJNb3VzZSBFeGl0Il0sIFsibW91c2V1cCIsICJNb3VzZSBVcCJdXSwgZXZlbnQgPT4gZXZlbnQudGFyZ2V0LmNoZWNrZWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFB1c2hCdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIExpbmtBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHBhcmFtZXRlcnMuZGF0YS5oYXNBcHBlYXJhbmNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IHN1cGVyLnJlbmRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJwdXNoQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIudGl0bGUgPSB0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmtFbGVtZW50ID0gY29udGFpbmVyLmxhc3RDaGlsZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zICYmIGxpbmtFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhsaW5rRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rRWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveCh7fSwganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNob2ljZVdpZGdldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gdGhpcy5kYXRhLmlkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxlY3RFbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIEdldEVsZW1lbnRzQnlOYW1lU2V0LmFkZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5kaXNhYmxlZCA9IHRoaXMuZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoc2VsZWN0RWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5uYW1lID0gdGhpcy5kYXRhLmZpZWxkTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYWRkQW5FbXB0eUVudHJ5ID0gdGhpcy5kYXRhLmNvbWJvICYmIHRoaXMuZGF0YS5vcHRpb25zLmxlbmd0aCA+IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmNvbWJvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnNpemUgPSB0aGlzLmRhdGEub3B0aW9ucy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLm11bHRpU2VsZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0VmFsdWUgPSB0aGlzLmRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSBvcHRpb24udmFsdWUgPT09IGRlZmF1bHRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3B0aW9uIG9mIHRoaXMuZGF0YS5vcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnRleHRDb250ZW50ID0gb3B0aW9uLmRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudmFsdWUgPSBvcHRpb24uZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZS5pbmNsdWRlcyhvcHRpb24uZXhwb3J0VmFsdWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQW5FbXB0eUVudHJ5ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFwcGVuZChvcHRpb25FbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZGRBbkVtcHR5RW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vbmVPcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC52YWx1ZSA9ICIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vbmVPcHRpb25FbGVtZW50LnNldEF0dHJpYnV0ZSgiaGlkZGVuIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnByZXBlbmQobm9uZU9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoImlucHV0IiwgcmVtb3ZlRW1wdHlFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIHJlbW92ZUVtcHR5RW50cnkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFZhbHVlID0gaXNFeHBvcnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGlzRXhwb3J0ID8gInZhbHVlIiA6ICJ0ZXh0Q29udGVudCI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHNlbGVjdEVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW11bHRpcGxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyBudWxsIDogb3B0aW9uc1tvcHRpb25zLnNlbGVjdGVkSW5kZXhdW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEFycmF5LnByb3RvdHlwZS5maWx0ZXIuY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKS5tYXAob3B0aW9uID0+IG9wdGlvbltuYW1lXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZFZhbHVlcyA9IGdldFZhbHVlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0SXRlbXMgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25zID0gZXZlbnQudGFyZ2V0Lm9wdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQXJyYXkucHJvdG90eXBlLm1hcC5jYWxsKG9wdGlvbnMsIG9wdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVZhbHVlOiBvcHRpb24udGV4dENvbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlOiBvcHRpb24udmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUVtcHR5RW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3JlbW92ZUVtcHR5RW50cnkgPSByZW1vdmVFbXB0eUVudHJ5KSA9PT0gbnVsbCB8fCBfcmVtb3ZlRW1wdHlFbnRyeSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3JlbW92ZUVtcHR5RW50cnkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWVzID0gbmV3IFNldChBcnJheS5pc0FycmF5KHZhbHVlKSA/IHZhbHVlIDogW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSB2YWx1ZXMuaGFzKG9wdGlvbi52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZVNlbGVjdGlvbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IHNlbGVjdEVsZW1lbnQub3B0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluZGV4ID0gZXZlbnQuZGV0YWlsLnJlbW92ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnNbaW5kZXhdLnNlbGVjdGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IEFycmF5LnByb3RvdHlwZS5maW5kSW5kZXguY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uc1swXS5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXM6IFtdCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNlcnQoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNwbGF5VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWwuaW5zZXJ0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VsZWN0Q2hpbGQgPSBzZWxlY3RFbGVtZW50LmNoaWxkcmVuW2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wdGlvbkVsZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudGV4dENvbnRlbnQgPSBkaXNwbGF5VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0Q2hpbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RDaGlsZC5iZWZvcmUob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdEVsZW1lbnQuYXBwZW5kKG9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcyhldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQuZGV0YWlsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BsYXlWYWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gaXRlbTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC50ZXh0Q29udGVudCA9IGRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hcHBlbmQob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0RWxlbWVudC5vcHRpb25zLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50Lm9wdGlvbnNbMF0uc2VsZWN0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRpY2VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbmRpY2VzID0gbmV3IFNldChldmVudC5kZXRhaWwuaW5kaWNlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBldmVudC50YXJnZXQub3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbi5zZWxlY3RlZCA9IGluZGljZXMuaGFzKG9wdGlvbi5pbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0YWJsZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LmRpc2FibGVkID0gIWV2ZW50LmRldGFpbC5lZGl0YWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gZ2V0VmFsdWUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmU5ID0gdGhpcy5saW5rU2VydmljZS5ldmVudEJ1cykgPT09IG51bGwgfHwgX3RoaXMkbGlua1NlcnZpY2UkZXZlOSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlOS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogIktleXN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogc2VsZWN0ZWRWYWx1ZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VFeDogZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleURvd246IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoc2VsZWN0RWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl0sIFsiaW5wdXQiLCAiQWN0aW9uIl0sIFsiaW5wdXQiLCAiVmFsaWRhdGUiXV0sIGV2ZW50ID0+IGV2ZW50LnRhcmdldC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZnVuY3Rpb24gKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0VmFsdWUodHJ1ZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuY29tYm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFRleHRTdHlsZShzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoc2VsZWN0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIElHTk9SRV9UWVBFUyA9IG5ldyBTZXQoWyJMaW5lIiwgIlNxdWFyZSIsICJDaXJjbGUiLCAiUG9seUxpbmUiLCAiUG9seWdvbiIsICJJbmsiXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RhdGEkdGl0bGVPYmosIF9kYXRhJGNvbnRlbnRzT2JqLCBfZGF0YSRyaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1ldGVyczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gIVBvcHVwQW5ub3RhdGlvbkVsZW1lbnQuSUdOT1JFX1RZUEVTLmhhcyhkYXRhLnBhcmVudFR5cGUpICYmICEhKChfZGF0YSR0aXRsZU9iaiA9IGRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9kYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkdGl0bGVPYmouc3RyIHx8IChfZGF0YSRjb250ZW50c09iaiA9IGRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9kYXRhJGNvbnRlbnRzT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkY29udGVudHNPYmouc3RyIHx8IChfZGF0YSRyaWNoVGV4dCA9IGRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9kYXRhJHJpY2hUZXh0ICE9PSB2b2lkIDAgJiYgX2RhdGEkcmljaFRleHQuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInBvcHVwQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnRFbGVtZW50cyA9IHRoaXMubGF5ZXIucXVlcnlTZWxlY3RvckFsbChgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHt0aGlzLmRhdGEucGFyZW50SWR9Il1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudEVsZW1lbnRzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gbmV3IFBvcHVwRWxlbWVudCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IHRoaXMuY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlcjogQXJyYXkuZnJvbShwYXJlbnRFbGVtZW50cyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5kYXRhLmNvbG9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGVPYmo6IHRoaXMuZGF0YS50aXRsZU9iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGU6IHRoaXMuZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IHRoaXMuZGF0YS5jb250ZW50c09iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJpY2hUZXh0OiB0aGlzLmRhdGEucmljaFRleHQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZ2UgPSB0aGlzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW3RoaXMuZGF0YS5wYXJlbnRSZWN0WzBdLCBwYWdlLnZpZXdbM10gLSB0aGlzLmRhdGEucGFyZW50UmVjdFsxXSArIHBhZ2Uudmlld1sxXSwgdGhpcy5kYXRhLnBhcmVudFJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzNdICsgcGFnZS52aWV3WzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwTGVmdCA9IHJlY3RbMF0gKyB0aGlzLmRhdGEucGFyZW50UmVjdFsyXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cFRvcCA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocG9wdXBMZWZ0IC0gcGFnZVgpIC8gcGFnZVdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS50b3AgPSBgJHsxMDAgKiAocG9wdXBUb3AgLSBwYWdlWSkgLyBwYWdlSGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQocG9wdXAucmVuZGVyKCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9wdXBFbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyID0gcGFyYW1ldGVycy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJpZ2dlciA9IHBhcmFtZXRlcnMudHJpZ2dlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IHBhcmFtZXRlcnMuY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGl0bGVPYmogPSBwYXJhbWV0ZXJzLnRpdGxlT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vZGlmaWNhdGlvbkRhdGUgPSBwYXJhbWV0ZXJzLm1vZGlmaWNhdGlvbkRhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGVudHNPYmogPSBwYXJhbWV0ZXJzLmNvbnRlbnRzT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJpY2hUZXh0ID0gcGFyYW1ldGVycy5yaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlV3JhcHBlciA9IHBhcmFtZXRlcnMuaGlkZVdyYXBwZXIgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGlubmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJHJpY2hUZXh0LCBfdGhpcyRjb250ZW50c09iajsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQkFDS0dST1VORF9FTkxJR0hUID0gMC43OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHdyYXBwZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBXcmFwcGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGlkZUVsZW1lbnQgPSB0aGlzLmhpZGVXcmFwcGVyID8gd3JhcHBlciA6IHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhpZGVFbGVtZW50LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcHVwLmNsYXNzTGlzdC5hZGQoInBvcHVwIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gdGhpcy5jb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByID0gQkFDS0dST1VORF9FTkxJR0hUICogKDI1NSAtIGNvbG9yWzBdKSArIGNvbG9yWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZyA9IEJBQ0tHUk9VTkRfRU5MSUdIVCAqICgyNTUgLSBjb2xvclsxXSkgKyBjb2xvclsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBCQUNLR1JPVU5EX0VOTElHSFQgKiAoMjU1IC0gY29sb3JbMl0pICsgY29sb3JbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyIHwgMCwgZyB8IDAsIGIgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aXRsZSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImgxIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlLmRpciA9IHRoaXMudGl0bGVPYmouZGlyOwogICAgICAgICAgICAgICAgICAgICAgICB0aXRsZS50ZXh0Q29udGVudCA9IHRoaXMudGl0bGVPYmouc3RyOwogICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5hcHBlbmQodGl0bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRlT2JqZWN0ID0gX2Rpc3BsYXlfdXRpbHMuUERGRGF0ZVN0cmluZy50b0RhdGVPYmplY3QodGhpcy5tb2RpZmljYXRpb25EYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGVPYmplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vZGlmaWNhdGlvbkRhdGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmljYXRpb25EYXRlLmNsYXNzTGlzdC5hZGQoInBvcHVwRGF0ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS50ZXh0Q29udGVudCA9ICJ7e2RhdGV9fSwge3t0aW1lfX0iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS5kYXRhc2V0LmwxMG5JZCA9ICJhbm5vdGF0aW9uX2RhdGVfc3RyaW5nIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGUuZGF0YXNldC5sMTBuQXJncyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRlOiBkYXRlT2JqZWN0LnRvTG9jYWxlRGF0ZVN0cmluZygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IGRhdGVPYmplY3QudG9Mb2NhbGVUaW1lU3RyaW5nKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKG1vZGlmaWNhdGlvbkRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkcmljaFRleHQgPSB0aGlzLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfdGhpcyRyaWNoVGV4dCAhPT0gdm9pZCAwICYmIF90aGlzJHJpY2hUZXh0LnN0ciAmJiAoISgoX3RoaXMkY29udGVudHNPYmogPSB0aGlzLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRjb250ZW50c09iaiAhPT0gdm9pZCAwICYmIF90aGlzJGNvbnRlbnRzT2JqLnN0cikgfHwgdGhpcy5jb250ZW50c09iai5zdHIgPT09IHRoaXMucmljaFRleHQuc3RyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3hmYV9sYXllci5YZmFMYXllci5yZW5kZXIoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhmYUh0bWw6IHRoaXMucmljaFRleHQuaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnQ6ICJyaWNoVGV4dCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2OiBwb3B1cAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5sYXN0Q2hpbGQuY2xhc3NMaXN0LmFkZCgicmljaFRleHQiLCAicG9wdXBDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50cyA9IHRoaXMuX2Zvcm1hdENvbnRlbnRzKHRoaXMuY29udGVudHNPYmopOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKGNvbnRlbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkodGhpcy50cmlnZ2VyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmlnZ2VyID0gW3RoaXMudHJpZ2dlcl07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIHRoaXMudHJpZ2dlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsIHRoaXMuX3RvZ2dsZS5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigibW91c2VvdmVyIiwgdGhpcy5fc2hvdy5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNlb3V0IiwgdGhpcy5faGlkZS5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYWRkRXZlbnRMaXN0ZW5lcigiY2xpY2siLCB0aGlzLl9oaWRlLmJpbmQodGhpcywgdHJ1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICB3cmFwcGVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB3cmFwcGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZm9ybWF0Q29udGVudHMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlyCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgicCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmNsYXNzTGlzdC5hZGQoInBvcHVwQ29udGVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmRpciA9IGRpcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZXMgPSBzdHIuc3BsaXQoLyg/OlxyXG4/fFxuKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBsaW5lcy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5lID0gbGluZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwLmFwcGVuZChkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShsaW5lKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA8IGlpIC0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAuYXBwZW5kKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImJyIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfdG9nZ2xlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5waW5uZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hpZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zaG93KHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zaG93KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGluID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhpZGVFbGVtZW50LmhpZGRlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCA9IHBhcnNlSW50KHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCkgKyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9oaWRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdW5waW4gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1bnBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGlkZUVsZW1lbnQuaGlkZGVuICYmICF0aGlzLnBpbm5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4ID0gcGFyc2VJbnQodGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4KSAtIDEwMD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IGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0Q29udGVudCA9IHBhcmFtZXRlcnMuZGF0YS50ZXh0Q29udGVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQuY2xhc3NMaXN0LmFkZCgiYW5ub3RhdGlvblRleHRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZSgicm9sZSIsICJjb21tZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgdGhpcy50ZXh0Q29udGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTcGFuID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVTcGFuLnRleHRDb250ZW50ID0gbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LmFwcGVuZChsaW5lU3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoY29udGVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIExpbmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250MyA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDMuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2gzID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMy5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmxpbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoIngxIiwgZGF0YS5yZWN0WzJdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgieTEiLCBkYXRhLnJlY3RbM10gLSBkYXRhLmxpbmVDb29yZGluYXRlc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUuc2V0QXR0cmlidXRlKCJ4MiIsIGRhdGEucmVjdFsyXSAtIGRhdGEubGluZUNvb3JkaW5hdGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInkyIiwgZGF0YS5yZWN0WzNdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInN0cm9rZSIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKGxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobGluZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVhcmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LCBfcGFyYW1ldGVycyRkYXRhJGNvbnQ0LCBfcGFyYW1ldGVycyRkYXRhJHJpY2g0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250NCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250NCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDQuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2g0ID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g0ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNC5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgic3F1YXJlQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZSh3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9yZGVyV2lkdGggPSBkYXRhLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcXVhcmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgieCIsIGJvcmRlcldpZHRoIC8gMik7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInkiLCBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIHdpZHRoIC0gYm9yZGVyV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCBoZWlnaHQgLSBib3JkZXJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInN0cm9rZS13aWR0aCIsIGJvcmRlcldpZHRoIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKHNxdWFyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChzcXVhcmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQ2lyY2xlQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNSwgX3BhcmFtZXRlcnMkZGF0YSRjb250NSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw1ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw1ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ1LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDUuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNpcmNsZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gZGF0YS5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzplbGxpcHNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImN4Iiwgd2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgiY3kiLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgicngiLCB3aWR0aCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJyeSIsIGhlaWdodCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJzdHJva2Utd2lkdGgiLCBib3JkZXJXaWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChjaXJjbGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAoY2lyY2xlLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNiwgX3BhcmFtZXRlcnMkZGF0YSRjb250NiwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw2ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw2ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ2LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDYuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSA9ICJwb2x5bGluZUFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5bGluZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCh0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBnZXRSZWN0RGltcyhkYXRhLnJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29vcmRpbmF0ZSBvZiBkYXRhLnZlcnRpY2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4ID0gY29vcmRpbmF0ZS54IC0gZGF0YS5yZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHggKyAiLCIgKyB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2x5bGluZSA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KHRoaXMuc3ZnRWxlbWVudE5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoInBvaW50cyIsIHBvaW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJmaWxsIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAocG9seWxpbmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9seWdvbkFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgUG9seWxpbmVBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAicG9seWdvbkFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5Z29uIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYXJldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGl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mFtZXRlcnMkZGF0YSRjb250OC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g4LnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAiaW5rQW5ub3RhdGlvbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRWxlbWVudE5hbWUgPSAic3ZnOnBvbHlsaW5lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKHRoaXMuY29udGFpbmVyQ2xhc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5rTGlzdCBvZiBkYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNvb3JkaW5hdGUgb2YgaW5rTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZGluYXRlLnggLSBkYXRhLnJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChgJHt4fSwke3l9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9seWxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCh0aGlzLnN2Z0VsZW1lbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgicG9pbnRzIiwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKHBvbHlsaW5lLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSGlnaGxpZ2h0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOSwgX3BhcmFtZXRlcnMkZGF0YSRjb250OSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw5ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw5ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ5LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDkuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygiaGlnaGxpZ2h0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImhpZ2hsaWdodEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFVuZGVybGluZUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvb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nVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInVuZGVybGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJ1bmRlcmxpbmVBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MTEgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgU3RyaWtlT3V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMiA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygic3RyaWtlb3V0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0cmlrZW91dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YW1wQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMy5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0YW1wQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGF0YS5oYXNQb3B1cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobnVsbCwgdGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgRmlsZUF0dGFjaG1lbnRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmUxMDsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5maWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGVuYW1lID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEZpbGVuYW1lRnJvbVVybCkoZmlsZW5hbWUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnQgPSBjb250ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUxMCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAuZGlzcGF0Y2goImZpbGVhdHRhY2htZW50YW5ub3RhdGlvbiIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSR0aXRsZU9iaiwgX3RoaXMkZGF0YSRjb250ZW50c09iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmaWxlQXR0YWNobWVudEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaWdnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuaGFzQXBwZWFyYW5jZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImltZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5zcmMgPSBgJHt0aGlzLmltYWdlUmVzb3VyY2VzUGF0aH1hbm5vdGF0aW9uLSR7L3BhcGVyY2xpcC9pLnRlc3QodGhpcy5kYXRhLm5hbWUpID8gInBhcGVyY2xpcCIgOiAicHVzaHBpbiJ9LnN2Z2A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5jbGFzc0xpc3QuYWRkKCJwb3B1cFRyaWdnZXJBcmVhIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuYWRkRXZlbnRMaXN0ZW5lcigiZGJsY2xpY2siLCB0aGlzLl9kb3dubG9hZC5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXAgJiYgKChfdGhpcyRkYXRhJHRpdGxlT2JqID0gdGhpcy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSR0aXRsZU9iai5zdHIgfHwgKF90aGlzJGRhdGEkY29udGVudHNPYiA9IHRoaXMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iLnN0ciB8fCB0aGlzLmRhdGEucmljaFRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cCh0cmlnZ2VyLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkb3dubG9hZE1hbmFnZXIyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZG93bmxvYWRNYW5hZ2VyMiA9IHRoaXMuZG93bmxvYWRNYW5hZ2VyKSA9PT0gbnVsbCB8fCBfdGhpcyRkb3dubG9hZE1hbmFnZXIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIyLm9wZW5PckRvd25sb2FkRGF0YSh0aGlzLmNvbnRhaW5lciwgdGhpcy5jb250ZW50LCB0aGlzLmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlcgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShkaXYsIHZpZXdwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcjogZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlOiBwYXJhbXMubGlua1NlcnZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZE1hbmFnZXI6IHBhcmFtcy5kb3dubG9hZE1hbmFnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZVJlc291cmNlc1BhdGg6IHBhcmFtcy5pbWFnZVJlc291cmNlc1BhdGggfHwgIiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJGb3JtczogcGFyYW1zLnJlbmRlckZvcm1zICE9PSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Z0ZhY3Rvcnk6IG5ldyBfZGlzcGxheV91dGlscy5ET01TVkdGYWN0b3J5KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogcGFyYW1zLmFubm90YXRpb25TdG9yYWdlIHx8IG5ldyBfYW5ub3RhdGlvbl9zdG9yYWdlLkFubm90YXRpb25TdG9yYWdlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVTY3JpcHRpbmc6IHBhcmFtcy5lbmFibGVTY3JpcHRpbmcgPT09IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnM6IHBhcmFtcy5oYXNKU0FjdGlvbnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE9iamVjdHM6IHBhcmFtcy5maWVsZE9iamVjdHMKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHpJbmRleCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGF0YSBvZiBhbm5vdGF0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubm9IVE1MKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5hbm5vdGF0aW9uVHlwZSAhPT0gX3V0aWwuQW5ub3RhdGlvblR5cGUuUE9QVVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggPD0gMCB8fCBoZWlnaHQgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50UGFyYW1zLmRhdGEgPSBkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IEFubm90YXRpb25FbGVtZW50RmFjdG9yeS5jcmVhdGUoZWxlbWVudFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQuaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZW5kZXJlZCA9IGVsZW1lbnQucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5oaWRkZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZW5kZXJlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlbmRlcmVkRWxlbWVudCBvZiByZW5kZXJlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZEVsZW1lbnQuc3R5bGUuekluZGV4ID0gekluZGV4Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQoQW5ub3RhdGlvbkxheWVyLCBBbm5vdGF0aW9uTGF5ZXIsIF9hcHBlbmRFbGVtZW50KS5jYWxsKEFubm90YXRpb25MYXllciwgcmVuZGVyZWRFbGVtZW50LCBkYXRhLmlkLCBkaXYsIGFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkLnN0eWxlLnpJbmRleCA9IHpJbmRleCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50IGluc3RhbmNlb2YgUG9wdXBBbm5vdGF0aW9uRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucHJlcGVuZChyZW5kZXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChBbm5vdGF0aW9uTGF5ZXIsIEFubm90YXRpb25MYXllciwgX2FwcGVuZEVsZW1lbnQpLmNhbGwoQW5ub3RhdGlvbkxheWVyLCByZW5kZXJlZCwgZGF0YS5pZCwgZGl2LCBhY2Nlc3NpYmlsaXR5TWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQodGhpcywgQW5ub3RhdGlvbkxheWVyLCBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcCkuY2FsbCh0aGlzLCBkaXYsIHBhcmFtcy5hbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGRpdiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHZpZXdwb3J0LnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIEFubm90YXRpb25MYXllciwgX3NldEFubm90YXRpb25DYW52YXNNYXApLmNhbGwodGhpcywgZGl2LCBhbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkxheWVyID0gQW5ub3RhdGlvbkxheWVyOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2FwcGVuZEVsZW1lbnQoZWxlbWVudCwgaWQsIGRpdiwgYWNjZXNzaWJpbGl0eU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50RWxlbWVudCA9IGVsZW1lbnQuZmlyc3RDaGlsZCB8fCBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnRFbGVtZW50LmlkID0gYCR7X2Rpc3BsYXlfdXRpbHMuQW5ub3RhdGlvblByZWZpeH0ke2lkfWA7CiAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gbnVsbCB8fCBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogYWNjZXNzaWJpbGl0eU1hbmFnZXIubW92ZUVsZW1lbnRJbkRPTShkaXYsIGVsZW1lbnQsIGNvbnRlbnRFbGVtZW50LCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcChkaXYsIGFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtpZCwgY2FudmFzXSBvZiBhbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBkaXYucXVlcnlTZWxlY3RvcihgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0Q2hpbGQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlyc3RDaGlsZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmQoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaXJzdENoaWxkLm5vZGVOYW1lID09PSAiQ0FOVkFTIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5yZXBsYWNlV2l0aChjYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5iZWZvcmUoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLmNsZWFyKCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG1ha2VDb2xvckNvbXAobikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmZsb29yKE1hdGgubWF4KDAsIE1hdGgubWluKDEsIG4pKSAqIDI1NSkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvckNvbnZlcnRlcnMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0coX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2MsIHksIG0sIGtdID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiRyIsIDEgLSBNYXRoLm1pbigxLCAwLjMgKiBjICsgMC41OSAqIG0gKyAwLjExICogeSArIGspXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIEdfQ01ZSyhfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCAwLCAwLCAwLCAxIC0gZ107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBHX1JHQihfcmVmMykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIlJHQiIsIGcsIGcsIGddOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgR19IVE1MKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbZ10gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRyA9IG1ha2VDb2xvckNvbXAoZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7R30ke0d9JHtHfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfRyhfcmVmNSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjU7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkciLCAwLjMgKiByICsgMC41OSAqIGcgKyAwLjExICogYl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfSFRNTChfcmVmNikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFIgPSBtYWtlQ29sb3JDb21wKHIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBHID0gbWFrZUNvbG9yQ29tcChnKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQiA9IG1ha2VDb2xvckNvbXAoYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7Un0ke0d9JHtCfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBUX0hUTUwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiIzAwMDAwMDAwIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIENNWUtfUkdCKF9yZWY3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbYywgeSwgbSwga10gPSBfcmVmNzsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiUkdCIiwgMSAtIE1hdGgubWluKDEsIGMgKyBrKSwgMSAtIE1hdGgubWluKDEsIG0gKyBrKSwgMSAtIE1hdGgubWluKDEsIHkgKyBrKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0hUTUwoY29tcG9uZW50cykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSB0aGlzLkNNWUtfUkdCKGNvbXBvbmVudHMpLnNsaWNlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5SR0JfSFRNTChyZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUkdCX0NNWUsoX3JlZjgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtyLCBnLCBiXSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gMSAtIHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAxIC0gZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IDEgLSBiOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrID0gTWF0aC5taW4oYywgbSwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCBjLCBtLCB5LCBrXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IENvbG9yQ29udmVydGVyczsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTY5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgY2xhc3MgWGZhTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzZXR1cFN0b3JhZ2UoaHRtbCwgaWQsIGVsZW1lbnQsIHN0b3JhZ2UsIGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZWxlbWVudC5uYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0YXJlYSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlZERhdGEudmFsdWUgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC50ZXh0Q29udGVudCA9IHN0b3JlZERhdGEudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgPT09ICJwcmludCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBldmVudC50YXJnZXQudmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJpbnB1dCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iIHx8IGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAiY2hlY2tib3giKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdG9yZWREYXRhLnZhbHVlID09PSBlbGVtZW50LmF0dHJpYnV0ZXMueGZhT24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuc2V0QXR0cmlidXRlKCJjaGVja2VkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RvcmVkRGF0YS52YWx1ZSA9PT0gZWxlbWVudC5hdHRyaWJ1dGVzLnhmYU9mZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5yZW1vdmVBdHRyaWJ1dGUoImNoZWNrZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50ID09PSAicHJpbnQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LmNoZWNrZWQgPyBldmVudC50YXJnZXQuZ2V0QXR0cmlidXRlKCJ4ZmFPbiIpIDogZXZlbnQudGFyZ2V0LmdldEF0dHJpYnV0ZSgieGZhT2ZmIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoInZhbHVlIiwgc3RvcmVkRGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudCA9PT0gInByaW50IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic2VsZWN0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBlbGVtZW50LmNoaWxkcmVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9uLmF0dHJpYnV0ZXMudmFsdWUgPT09IHN0b3JlZERhdGEudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uYXR0cmlidXRlcy5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IGV2ZW50LnRhcmdldC5vcHRpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyAiIiA6IG9wdGlvbnNbb3B0aW9ucy5zZWxlY3RlZEluZGV4XS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNldEF0dHJpYnV0ZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0hUTUxBbmNob3JFbGVtZW50ID0gaHRtbCBpbnN0YW5jZW9mIEhUTUxBbmNob3JFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzLm5hbWUgPSBgJHthdHRyaWJ1dGVzLm5hbWV9LSR7aW50ZW50fWA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMoYXR0cmlidXRlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCB8fCB2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNsYXNzIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoa2V5LCB2YWx1ZS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImRhdGFJZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImlkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic3R5bGUiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKGh0bWwuc3R5bGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAidGV4dENvbnRlbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnRleHRDb250ZW50ID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNIVE1MQW5jaG9yRWxlbWVudCB8fCBrZXkgIT09ICJocmVmIiAmJiBrZXkgIT09ICJuZXdXaW5kb3ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnNldEF0dHJpYnV0ZShrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0hUTUxBbmNob3JFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZS5hZGRMaW5rQXR0cmlidXRlcyhodG1sLCBhdHRyaWJ1dGVzLmhyZWYsIGF0dHJpYnV0ZXMubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmFnZSAmJiBhdHRyaWJ1dGVzLmRhdGFJZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXR1cFN0b3JhZ2UoaHRtbCwgYXR0cmlidXRlcy5kYXRhSWQsIGVsZW1lbnQsIHN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gcGFyYW1ldGVycy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlua1NlcnZpY2UgPSBwYXJhbWV0ZXJzLmxpbmtTZXJ2aWNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb290ID0gcGFyYW1ldGVycy54ZmFIdG1sOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnQgPSBwYXJhbWV0ZXJzLmludGVudCB8fCAiZGlzcGxheSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudChyb290Lm5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm9vdC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0dHJpYnV0ZXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWw6IHJvb3RIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQ6IHJvb3QsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFjayA9IFtbcm9vdCwgLTEsIHJvb3RIdG1sXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3REaXYgPSBwYXJhbWV0ZXJzLmRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgcm9vdERpdi5hcHBlbmQocm9vdEh0bWwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW1ldGVycy52aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtID0gYG1hdHJpeCgke3BhcmFtZXRlcnMudmlld3BvcnQudHJhbnNmb3JtLmpvaW4oIiwiKX0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc3R5bGUudHJhbnNmb3JtID0gdHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgIT09ICJyaWNoVGV4dCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc2V0QXR0cmlidXRlKCJjbGFzcyIsICJ4ZmFMYXllciB4ZmFGb250Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2hpbGQkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGksIGh0bWxdID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgKyAxID09PSBwYXJlbnQuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IHBhcmVudC5jaGlsZHJlblsrK3N0YWNrLmF0KC0xKVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gY2hpbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmFtZSA9PT0gIiN0ZXh0IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMucHVzaChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGlsZEh0bWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgIT09IG51bGwgJiYgY2hpbGQgIT09IHZvaWQgMCAmJiAoX2NoaWxkJGF0dHJpYnV0ZXMgPSBjaGlsZC5hdHRyaWJ1dGVzKSAhPT0gbnVsbCAmJiBfY2hpbGQkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9jaGlsZCRhdHRyaWJ1dGVzLnhtbG5zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKGNoaWxkLmF0dHJpYnV0ZXMueG1sbnMsIG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hcHBlbmQoY2hpbGRIdG1sKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdHRyaWJ1dGVzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbDogY2hpbGRIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50OiBjaGlsZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLmNoaWxkcmVuICYmIGNoaWxkLmNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFjay5wdXNoKFtjaGlsZCwgLTEsIGNoaWxkSHRtbF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGlsZC52YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF94ZmFfdGV4dC5YZmFUZXh0LnNob3VsZEJ1aWxkVGV4dChuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2cy5wdXNoKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwuYXBwZW5kKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWwgb2Ygcm9vdERpdi5xdWVyeVNlbGVjdG9yQWxsKCIueGZhTm9uSW50ZXJhY3RpdmUgaW5wdXQsIC54ZmFOb25JbnRlcmFjdGl2ZSB0ZXh0YXJlYSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbC5zZXRBdHRyaWJ1dGUoInJlYWRPbmx5IiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZzCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB1cGRhdGUocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm0gPSBgbWF0cml4KCR7cGFyYW1ldGVycy52aWV3cG9ydC50cmFuc2Zvcm0uam9pbigiLCIpfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzLmRpdi5zdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcnMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSBYZmFMYXllcjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcwICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuU1ZHR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGxldCBTVkdHcmFwaGljcyA9IGNsYXNzIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiTm90IGltcGxlbWVudGVkOiBTVkdHcmFwaGljcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgU1ZHX0RFRkFVTFRTID0gewogICAgICAgICAgICAgICAgICAgICAgICBmb250U3R5bGU6ICJub3JtYWwiLAogICAgICAgICAgICAgICAgICAgICAgICBmb250V2VpZ2h0OiAibm9ybWFsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZmlsbENvbG9yOiAiIzAwMDAwMCIKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhNTF9OUyA9ICJodHRwOi8vd3d3LnczLm9yZy9YTUwvMTk5OC9uYW1lc3BhY2UiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhMSU5LX05TID0gImh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IExJTkVfQ0FQX1NUWUxFUyA9IFsiYnV0dCIsICJyb3VuZCIsICJzcXVhcmUiXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNyZWF0ZU9iamVjdFVSTCA9IGZ1bmN0aW9uIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50VHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogIiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoVVJMLmNyZWF0ZU9iamVjdFVSTCAmJiB0eXBlb2YgQmxvYiAhPT0gInVuZGVmaW5lZCIgJiYgIWZvcmNlRGF0YVNjaGVtYSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFVSTC5jcmVhdGVPYmplY3RVUkwobmV3IEJsb2IoW2RhdGFdLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogY29udGVudFR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaWdpdHMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLz0iOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnVmZmVyID0gYGRhdGE6JHtjb250ZW50VHlwZX07YmFzZTY0LGA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRhdGEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjEgPSBkYXRhW2ldICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIyID0gZGF0YVtpICsgMV0gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjMgPSBkYXRhW2kgKyAyXSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkMSA9IGIxID4+IDIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZDIgPSAoYjEgJiAzKSA8PCA0IHwgYjIgPj4gNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQzID0gaSArIDEgPCBpaSA/IChiMiAmIDB4ZikgPDwgMiB8IGIzID4+IDYgOiA2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQ0ID0gaSArIDIgPCBpaSA/IGIzICYgMHgzZiA6IDY0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyICs9IGRpZ2l0c1tkMV0gKyBkaWdpdHNbZDJdICsgZGlnaXRzW2QzXSArIGRpZ2l0c1tkNF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnZlcnRJbWdEYXRhVG9QbmcgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFBOR19IRUFERVIgPSBuZXcgVWludDhBcnJheShbMHg4OSwgMHg1MCwgMHg0ZSwgMHg0NywgMHgwZCwgMHgwYSwgMHgxYSwgMHgwYV0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDSFVOS19XUkFQUEVSX1NJWkUgPSAxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3JjVGFibGUgPSBuZXcgSW50MzJBcnJheSgyNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYyA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBoID0gMDsgaCA8IDg7IGgrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjICYgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMHhlZGI4ODMyMCBeIGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYyA9IGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JjVGFibGVbaV0gPSBjOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyYzMyKGRhdGEsIHN0YXJ0LCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjcmMgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYSA9IChjcmMgXiBkYXRhW2ldKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IGNyY1RhYmxlW2FdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyYyA9IGNyYyA+Pj4gOCBeIGI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JjIF4gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd3JpdGVQbmdDaHVuayh0eXBlLCBib2R5LCBkYXRhLCBvZmZzZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwID0gb2Zmc2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuID0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3BdID0gbGVuID4+IDI0ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDFdID0gbGVuID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDJdID0gbGVuID4+IDggJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgM10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcCArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwXSA9IHR5cGUuY2hhckNvZGVBdCgwKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAxXSA9IHR5cGUuY2hhckNvZGVBdCgxKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAyXSA9IHR5cGUuY2hhckNvZGVBdCgyKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IHR5cGUuY2hhckNvZGVBdCgzKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChib2R5LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjcmMgPSBjcmMzMihkYXRhLCBvZmZzZXQgKyA0LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcF0gPSBjcmMgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMV0gPSBjcmMgPj4gMTYgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMl0gPSBjcmMgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IGNyYyAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gYWRsZXIzMihkYXRhLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGEgPSAoYSArIChkYXRhW2ldICYgMHhmZikpICUgNjU1MjE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYiA9IChiICsgYSkgJSA2NTUyMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiIDw8IDE2IHwgYTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBkZWZsYXRlU3luYyhsaXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZsYXRlU3luY1VuY29tcHJlc3NlZChsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VJbnQocHJvY2Vzcy52ZXJzaW9ucy5ub2RlKSA+PSA4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gbGl0ZXJhbHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBCdWZmZXIuZnJvbShsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG91dHB1dCA9IHJlcXVpcmUoInpsaWIiKS5kZWZsYXRlU3luYyhpbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXZlbDogOQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRwdXQgaW5zdGFuY2VvZiBVaW50OEFycmF5ID8gb3V0cHV0IDogbmV3IFVpbnQ4QXJyYXkob3V0cHV0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vdCBjb21wcmVzc2luZyBQTkcgYmVjYXVzZSB6bGliLmRlZmxhdGVTeW5jIGlzIHVuYXZhaWxhYmxlOiAiICsgZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmbGF0ZVN5bmNVbmNvbXByZXNzZWQobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTeW5jVW5jb21wcmVzc2VkKGxpdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGVuID0gbGl0ZXJhbHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4QmxvY2tMZW5ndGggPSAweGZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZsYXRlQmxvY2tzID0gTWF0aC5jZWlsKGxlbiAvIG1heEJsb2NrTGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkYXQgPSBuZXcgVWludDhBcnJheSgyICsgbGVuICsgZGVmbGF0ZUJsb2NrcyAqIDUgKyA0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHg3ODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAweDljOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobGVuID4gbWF4QmxvY2tMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MsIHBvcyArIG1heEJsb2NrTGVuZ3RoKSwgcGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpICs9IG1heEJsb2NrTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcyArPSBtYXhCbG9ja0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gbWF4QmxvY2tMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGxlbiA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSB+bGVuICYgMHhmZmZmICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAofmxlbiAmIDB4ZmZmZikgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MpLCBwaSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaSArPSBsaXRlcmFscy5sZW5ndGggLSBwb3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGxlciA9IGFkbGVyMzIobGl0ZXJhbHMsIDAsIGxpdGVyYWxzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gYWRsZXIgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGFkbGVyID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaWRhdDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBlbmNvZGUoaW1nRGF0YSwga2luZCwgZm9yY2VEYXRhU2NoZW1hLCBpc01hc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJpdERlcHRoLCBjb2xvclR5cGUsIGxpbmVTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBpbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtpbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JUeXBlID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0RGVwdGggPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lU2l6ZSA9IHdpZHRoICsgNyA+PiAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiaW52YWxpZCBmb3JtYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpdGVyYWxzID0gbmV3IFVpbnQ4QXJyYXkoKDEgKyBsaW5lU2l6ZSkgKiBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldExpdGVyYWxzID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB5ID0gMDsgeSA8IGhlaWdodDsgKyt5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGl0ZXJhbHNbb2Zmc2V0TGl0ZXJhbHMrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpdGVyYWxzLnNldChieXRlcy5zdWJhcnJheShvZmZzZXRCeXRlcywgb2Zmc2V0Qnl0ZXMgKyBsaW5lU2l6ZSksIG9mZnNldExpdGVyYWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRMaXRlcmFscyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgJiYgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHkgPSAwOyB5IDwgaGVpZ2h0OyB5KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaW5lU2l6ZTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXRlcmFsc1tvZmZzZXRMaXRlcmFscysrXSBePSAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWhkciA9IG5ldyBVaW50OEFycmF5KFt3aWR0aCA+PiAyNCAmIDB4ZmYsIHdpZHRoID4+IDE2ICYgMHhmZiwgd2lkdGggPj4gOCAmIDB4ZmYsIHdpZHRoICYgMHhmZiwgaGVpZ2h0ID4+IDI0ICYgMHhmZiwgaGVpZ2h0ID4+IDE2ICYgMHhmZiwgaGVpZ2h0ID4+IDggJiAweGZmLCBoZWlnaHQgJiAweGZmLCBiaXREZXB0aCwgY29sb3JUeXBlLCAweDAwLCAweDAwLCAweDAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZGF0ID0gZGVmbGF0ZVN5bmMobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG5nTGVuZ3RoID0gUE5HX0hFQURFUi5sZW5ndGggKyBDSFVOS19XUkFQUEVSX1NJWkUgKiAzICsgaWhkci5sZW5ndGggKyBpZGF0Lmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhBcnJheShwbmdMZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChQTkdfSEVBREVSLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ICs9IFBOR19IRUFERVIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVQbmdDaHVuaygiSUhEUiIsIGloZHIsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWhkci5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJREFUQSIsIGlkYXQsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWRhdC5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJRU5EIiwgbmV3IFVpbnQ4QXJyYXkoMCksIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlT2JqZWN0VVJMKGRhdGEsICJpbWFnZS9wbmciLCBmb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBjb252ZXJ0SW1nRGF0YVRvUG5nKGltZ0RhdGEsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBraW5kID0gaW1nRGF0YS5raW5kID09PSB1bmRlZmluZWQgPyBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgOiBpbWdEYXRhLmtpbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW5jb2RlKGltZ0RhdGEsIGtpbmQsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICAgICAgY2xhc3MgU1ZHRXh0cmFTdGF0ZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZVNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFdlaWdodCA9IFNWR19ERUZBVUxUUy5mb250V2VpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRNYXRyaXggPSBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5saW5lWCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hhclNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53b3JkU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxDb2xvciA9IFNWR19ERUZBVUxUUy5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsQWxwaGEgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVKb2luID0gIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVDYXAgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWl0ZXJMaW1pdCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhc2hBcnJheSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kYXNoUGhhc2UgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXBlbmRlbmNpZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWN0aXZlQ2xpcFVybCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBHcm91cCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hc2tJZCA9ICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5jcmVhdGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q3VycmVudFBvaW50KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSB5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wTGlzdFRvVHJlZShvcExpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9wVHJlZSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXAgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcExpc3RFbGVtZW50IG9mIG9wTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wTGlzdEVsZW1lbnQuZm4gPT09ICJzYXZlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZS5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZDogOTIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuOiAiZ3JvdXAiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogW10KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXAucHVzaChvcFRyZWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZSA9IG9wVHJlZS5hdCgtMSkuaXRlbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3BMaXN0RWxlbWVudC5mbiA9PT0gInJlc3RvcmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BUcmVlID0gdG1wLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcFRyZWUucHVzaChvcExpc3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3BUcmVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBwZih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMgPSB2YWx1ZS50b0ZpeGVkKDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzW2ldICE9PSAiMCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGktLTsKICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoc1tpXSA9PT0gIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHMuc3Vic3RyaW5nKDAsIHNbaV0gPT09ICIuIiA/IGkgOiBpICsgMSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHBtKG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bNF0gPT09IDAgJiYgbVs1XSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzBdID09PSAxICYmIG1bM10gPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHNjYWxlKCR7cGYobVswXSl9ICR7cGYobVszXSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gbVszXSAmJiBtWzFdID09PSAtbVsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBNYXRoLmFjb3MobVswXSkgKiAxODAgLyBNYXRoLlBJOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgcm90YXRlKCR7cGYoYSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gMSAmJiBtWzFdID09PSAwICYmIG1bMl0gPT09IDAgJiYgbVszXSA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgdHJhbnNsYXRlKCR7cGYobVs0XSl9ICR7cGYobVs1XSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGBtYXRyaXgoJHtwZihtWzBdKX0gJHtwZihtWzFdKX0gJHtwZihtWzJdKX0gJHtwZihtWzNdKX0gJHtwZihtWzRdKX0gYCArIGAke3BmKG1bNV0pfSlgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY2xpcENvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgbWFza0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgc2hhZGluZ0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3MgPSBjbGFzcyB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNvbW1vbk9ianMsIG9ianMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJUaGUgU1ZHIGJhY2stZW5kIGlzIG5vIGxvbmdlciBtYWludGFpbmVkIGFuZCAqbWF5KiBiZSByZW1vdmVkIGluIHRoZSBmdXR1cmUuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0ZhY3RvcnkgPSBuZXcgX2Rpc3BsYXlfdXRpbHMuRE9NU1ZHRmFjdG9yeSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IFNWR0V4dHJhU3RhdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1TdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1vbk9ianMgPSBjb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtYmVkRm9udHMgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1iZWRkZWRGb250cyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9yY2VEYXRhU2NoZW1hID0gISFmb3JjZURhdGFTY2hlbWE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcCBpbiBfdXRpbC5PUFMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZ1tfdXRpbC5PUFNbb3BdXSA9IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmFsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy50cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2xkID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG9sZC5jbG9uZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQgPSB0aGlzLmV4dHJhU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGdycCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXAoaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKGl0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWREZXBlbmRlbmNpZXMob3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXkgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm5BcnJheS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZuQXJyYXlbaV0gIT09IF91dGlsLk9QUy5kZXBlbmRlbmN5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9iaiBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBvYmouc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2JqcyA6IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KG9iaiwgcmVzb2x2ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZGVwZW5kZW5jaWVzLnB1c2gocHJvbWlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHRoaXMuY3VycmVudC5kZXBlbmRlbmNpZXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1NYXRyaXggPSBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4LCB0cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBnZXRTVkcob3BlcmF0b3JMaXN0LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3cG9ydCA9IHZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnRWxlbWVudCA9IHRoaXMuX2luaXRpYWxpemUodmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubG9hZERlcGVuZGVuY2llcyhvcGVyYXRvckxpc3QpLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY3V0ZU9wVHJlZSh0aGlzLmNvbnZlcnRPcExpc3Qob3BlcmF0b3JMaXN0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2Z0VsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0T3BMaXN0KG9wZXJhdG9yTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JJZE1hcHBpbmcgPSB0aGlzLl9vcGVyYXRvcklkTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcExpc3QgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGZuQXJyYXkubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuSWQgPSBmbkFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm46IG9wZXJhdG9ySWRNYXBwaW5nW2ZuSWRdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzOiBhcmdzQXJyYXlbaV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvcExpc3RUb1RyZWUob3BMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBleGVjdXRlT3BUcmVlKG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcFRyZWVFbGVtZW50IG9mIG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuID0gb3BUcmVlRWxlbWVudC5mbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbklkID0gb3BUcmVlRWxlbWVudC5mbklkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBvcFRyZWVFbGVtZW50LmFyZ3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChmbklkIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJlZ2luVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmRlcGVuZGVuY3k6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGVhZGluZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZyhhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExlYWRpbmdNb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaG93VGV4dChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2hvd1RleHQoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Q2hhclNwYWNpbmcoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0V29yZFNwYWNpbmc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFdvcmRTcGFjaW5nKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SFNjYWxlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRNYXRyaXg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRNYXRyaXgoYXJnc1swXSwgYXJnc1sxXSwgYXJnc1syXSwgYXJnc1szXSwgYXJnc1s0XSwgYXJnc1s1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0VGV4dFJpc2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRSaXNlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSZW5kZXJpbmdNb2RlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRUZXh0UmVuZGVyaW5nTW9kZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lV2lkdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lSm9pbjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUpvaW4oYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGluZUNhcDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRNaXRlckxpbWl0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbFJHQkNvbG9yKGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZVJHQkNvbG9yOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VSR0JDb2xvcihhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRTdHJva2VDb2xvck46CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFN0cm9rZUNvbG9yTihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsQ29sb3JOOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQ29sb3JOKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNoYWRpbmdGaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaGFkaW5nRmlsbChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXREYXNoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFJlbmRlcmluZ0ludGVudDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZsYXRuZXNzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGbGF0bmVzcyhhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRHU3RhdGU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEdTdGF0ZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5maWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW9GaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lb0ZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0ZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVvRmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0NsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludFNvbGlkQ29sb3JJbWFnZU1hc2s6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50U29saWRDb2xvckltYWdlTWFzaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50SW1hZ2VYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlWE9iamVjdChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludElubGluZUltYWdlWE9iamVjdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRJbWFnZU1hc2tYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlTWFza1hPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEJlZ2luOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEZvcm1YT2JqZWN0QmVnaW4oYXJnc1swXSwgYXJnc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEVuZDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRGb3JtWE9iamVjdEVuZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VGaWxsU3Ryb2tlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZUZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VFT0ZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmV4dExpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy50cmFuc2Zvcm06CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybShhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdLCBhcmdzWzNdLCBhcmdzWzRdLCBhcmdzWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jb25zdHJ1Y3RQYXRoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb25zdHJ1Y3RQYXRoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZFBhdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cChvcFRyZWVFbGVtZW50Lml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmltcGxlbWVudGVkIG9wZXJhdG9yICR7Zm59YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmcod29yZFNwYWNpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHdvcmRTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldENoYXJTcGFjaW5nKGNoYXJTcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBjaGFyU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoMCwgdGhpcy5jdXJyZW50LmxlYWRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeCA9IGN1cnJlbnQubGluZU1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeFNjYWxlID0gTWF0aC5oeXBvdChhLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55ID0gY3VycmVudC5saW5lWSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRFbGVtZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0ZXh0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dEVsZW1lbnQuYXBwZW5kKGN1cnJlbnQudHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggPSBjdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5saW5lTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4U2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dGV4dCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRncnAgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbW92ZVRleHQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggKz0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgKz0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1mYW1pbHkiLCBjdXJyZW50LmZvbnRGYW1pbHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1zaXplIiwgYCR7cGYoY3VycmVudC5mb250U2l6ZSl9cHhgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBwZigtY3VycmVudC55KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IGN1cnJlbnQuZm9udDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplU2NhbGUgPSBjdXJyZW50LmZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JkU3BhY2luZyA9IGN1cnJlbnQud29yZFNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250RGlyZWN0aW9uID0gY3VycmVudC5mb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNhbCA9IGZvbnQudmVydGljYWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nRGlyID0gdmVydGljYWwgPyAxIDogLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoQWR2YW5jZVNjYWxlID0gZm9udFNpemUgKiBjdXJyZW50LmZvbnRNYXRyaXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaCA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IGZvbnREaXJlY3Rpb24gKiB3b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZ2x5cGggPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZyA9IChnbHlwaC5pc1NwYWNlID8gd29yZFNwYWNpbmcgOiAwKSArIGNoYXJTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJhY3RlciA9IGdseXBoLmZvbnRDaGFyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IGdseXBoLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdng7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBnbHlwaC52bWV0cmljIHx8IGRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdnggPSBnbHlwaC52bWV0cmljID8gdm1ldHJpY1sxXSA6IHdpZHRoICogMC41OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2eCA9IC12eCAqIHdpZHRoQWR2YW5jZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2eSA9IHZtZXRyaWNbMl0gKiB3aWR0aEFkdmFuY2VTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCA9IHZ4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWSA9ICh4ICsgdnkpIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0geCAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMucHVzaChjdXJyZW50LnggKyBzY2FsZWRYKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnljb29yZHMucHVzaCgtY3VycmVudC55ICsgc2NhbGVkWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi50ZXh0Q29udGVudCArPSBjaGFyYWN0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNoYXJXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhcldpZHRoID0gd2lkdGggKiB3aWR0aEFkdmFuY2VTY2FsZSAtIHNwYWNpbmcgKiBmb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCArPSBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgY3VycmVudC54Y29vcmRzLm1hcChwZikuam9pbigiICIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBjdXJyZW50Lnljb29yZHMubWFwKHBmKS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCArPSB4ICogdGV4dEhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250U3R5bGUgIT09IFNWR19ERUZBVUxUUy5mb250U3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXN0eWxlIiwgY3VycmVudC5mb250U3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQuZm9udFdlaWdodCAhPT0gU1ZHX0RFRkFVTFRTLmZvbnRXZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXdlaWdodCIsIGN1cnJlbnQuZm9udFdlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgJiBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRV9NQVNLOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmZpbGxDb2xvciAhPT0gU1ZHX0RFRkFVTFRTLmZpbGxDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5maWxsQWxwaGEgPCAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtb3BhY2l0eSIsIGN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVXaWR0aFNjYWxlID0gMSAvIChjdXJyZW50LnRleHRNYXRyaXhTY2FsZSB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQudHNwYW4sIGxpbmVXaWR0aFNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0TWF0cml4ID0gY3VycmVudC50ZXh0TWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQudGV4dFJpc2UgIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0TWF0cml4ID0gdGV4dE1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRNYXRyaXhbNV0gKz0gY3VycmVudC50ZXh0UmlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAidHJhbnNmb3JtIiwgYCR7cG0odGV4dE1hdHJpeCl9IHNjYWxlKCR7cGYodGV4dEhTY2FsZSl9LCAtMSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhYTUxfTlMsICJ4bWw6c3BhY2UiLCAicHJlc2VydmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5hcHBlbmQoY3VycmVudC50c3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dGdycC5hcHBlbmQoY3VycmVudC50eHRFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKGN1cnJlbnQudHh0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vdmVUZXh0KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGFkZEZvbnRTdHlsZShmb250T2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZvbnRPYmouZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiYWRkRm9udFN0eWxlOiBObyBmb250IGRhdGEgYXZhaWxhYmxlLCAiICsgJ2Vuc3VyZSB0aGF0IHRoZSAiZm9udEV4dHJhUHJvcGVydGllcyIgQVBJIHBhcmFtZXRlciBpcyBzZXQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzU3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpzdHlsZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3NzU3R5bGUuc2V0QXR0cmlidXRlTlMobnVsbCwgInR5cGUiLCAidGV4dC9jc3MiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRoaXMuY3NzU3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gY3JlYXRlT2JqZWN0VVJMKGZvbnRPYmouZGF0YSwgZm9udE9iai5taW1ldHlwZSwgdGhpcy5mb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jc3NTdHlsZS50ZXh0Q29udGVudCArPSBgQGZvbnQtZmFjZSB7IGZvbnQtZmFtaWx5OiAiJHtmb250T2JqLmxvYWRlZE5hbWV9IjtgICsgYCBzcmM6IHVybCgke3VybH0pOyB9XG5gOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnQoZGV0YWlscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRPYmogPSB0aGlzLmNvbW1vbk9ianMuZ2V0KGRldGFpbHNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBkZXRhaWxzWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250ID0gZm9udE9iajsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVtYmVkRm9udHMgJiYgIWZvbnRPYmoubWlzc2luZ0ZpbGUgJiYgIXRoaXMuZW1iZWRkZWRGb250c1tmb250T2JqLmxvYWRlZE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRGb250U3R5bGUoZm9udE9iaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWJlZGRlZEZvbnRzW2ZvbnRPYmoubG9hZGVkTmFtZV0gPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJvbGQgPSAibm9ybWFsIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250T2JqLmJsYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmb250T2JqLmJvbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2xkID0gImJvbGQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRhbGljID0gZm9udE9iai5pdGFsaWMgPyAiaXRhbGljIiA6ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZSA9IC1zaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U2l6ZSA9IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRGYW1pbHkgPSBmb250T2JqLmxvYWRlZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRXZWlnaHQgPSBib2xkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U3R5bGUgPSBpdGFsaWM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieSIsIHBmKC1jdXJyZW50LnkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW5kVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY3VycmVudCR0eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuQUREX1RPX1BBVEhfRkxBRyAmJiAoX2N1cnJlbnQkdHh0RWxlbWVudCA9IGN1cnJlbnQudHh0RWxlbWVudCkgIT09IG51bGwgJiYgX2N1cnJlbnQkdHh0RWxlbWVudCAhPT0gdm9pZCAwICYmIF9jdXJyZW50JHR4dEVsZW1lbnQuaGFzQ2hpbGROb2RlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50ID0gY3VycmVudC50eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xpcCgibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRMaW5lQ2FwKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW4oc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lSm9pbiA9IExJTkVfSk9JTl9TVFlMRVNbc3R5bGVdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5taXRlckxpbWl0ID0gbGltaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQWxwaGEoc3Ryb2tlQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VBbHBoYSA9IHN0cm9rZUFscGhhOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKHIsIGcsIGIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZpbGxBbHBoYShmaWxsQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQWxwaGEgPSBmaWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLl9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbENvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gdGhpcy5fbWFrZUNvbG9yTl9QYXR0ZXJuKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy52aWV3cG9ydC53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMudmlld3BvcnQuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW52ID0gX3V0aWwuVXRpbC5pbnZlcnNlVHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbMCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCAwXSwgaW52KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVyID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbd2lkdGgsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4MCA9IE1hdGgubWluKGJsWzBdLCBiclswXSwgdWxbMF0sIHVyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkwID0gTWF0aC5taW4oYmxbMV0sIGJyWzFdLCB1bFsxXSwgdXJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDEgPSBNYXRoLm1heChibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MSA9IE1hdGgubWF4KGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCB4MCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgeTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCB4MSAtIHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuX21ha2VTaGFkaW5nUGF0dGVybihhcmdzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LmZpbGxBbHBoYSA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCB0aGlzLmN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKHJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3NbMF0gPT09ICJUaWxpbmdQYXR0ZXJuIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlVGlsaW5nUGF0dGVybihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlU2hhZGluZ1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX21ha2VUaWxpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gYXJnc1sxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IGFyZ3NbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSBhcmdzWzNdIHx8IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt4MCwgeTAsIHgxLCB5MV0gPSBhcmdzWzRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHN0ZXAgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSBhcmdzWzZdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFpbnRUeXBlID0gYXJnc1s3XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRpbGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbdHgwLCB0eTAsIHR4MSwgdHkxXSA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDAsIHkwXSwgbWF0cml4KSwgLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDEsIHkxXSwgbWF0cml4KV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3hzY2FsZSwgeXNjYWxlXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4c3RlcCA9IHhzdGVwICogeHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlzdGVwID0geXN0ZXAgKiB5c2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aWxpbmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnBhdHRlcm4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbGluZy5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCB0aWxpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInBhdHRlcm5Vbml0cyIsICJ1c2VyU3BhY2VPblVzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGlsaW5nLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ3aWR0aCIsIHR4c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHR5c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCBgJHt0eDB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBgJHt0eTB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtTWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cm9rZUNvbG9yID0gdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodHgxIC0gdHgwLCB0eTEgLSB0eTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcgPSBiYm94OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFpbnRUeXBlID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKHRoaXMuY29udmVydE9wTGlzdChvcGVyYXRvckxpc3QpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gc3ZnOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSB0cmFuc2Zvcm1NYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuYXBwZW5kKGJib3guY2hpbGROb2Rlc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRpbGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHt0aWxpbmdJZH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfbWFrZVNoYWRpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgYXJncyA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzID0gdGhpcy5vYmpzLmdldChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1swXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJhZGlhbEF4aWFsIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhZGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yU3RvcHMgPSBhcmdzWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZGllbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1sxXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiYXhpYWwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvaW50MCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9pbnQxID0gYXJnc1s1XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bGluZWFyR3JhZGllbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBzaGFkaW5nSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJncmFkaWVudFVuaXRzIiwgInVzZXJTcGFjZU9uVXNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgIngxIiwgcG9pbnQwWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieTEiLCBwb2ludDBbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4MiIsIHBvaW50MVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInkyIiwgcG9pbnQxWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInJhZGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9jYWxQb2ludCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlUG9pbnQgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvY2FsUmFkaXVzID0gYXJnc1s2XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaXJjbGVSYWRpdXMgPSBhcmdzWzddOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyYWRpYWxHcmFkaWVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJpZCIsIHNoYWRpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImdyYWRpZW50VW5pdHMiLCAidXNlclNwYWNlT25Vc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY3giLCBjaXJjbGVQb2ludFswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImN5IiwgY2lyY2xlUG9pbnRbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJyIiwgY2lyY2xlUmFkaXVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZngiLCBmb2NhbFBvaW50WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnkiLCBmb2NhbFBvaW50WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnIiLCBmb2NhbFJhZGl1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBSYWRpYWxBeGlhbCB0eXBlOiAke2FyZ3NbMV19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjb2xvclN0b3Agb2YgY29sb3JTdG9wcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6c3RvcCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAib2Zmc2V0IiwgY29sb3JTdG9wWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3Auc2V0QXR0cmlidXRlTlMobnVsbCwgInN0b3AtY29sb3IiLCBjb2xvclN0b3BbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYXBwZW5kKHN0b3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQoZ3JhZGllbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHtzaGFkaW5nSWR9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWVzaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBwYXR0ZXJuIE1lc2giKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke2FyZ3NbMF19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RGFzaChkYXNoQXJyYXksIGRhc2hQaGFzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmRhc2hBcnJheSA9IGRhc2hBcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5kYXNoUGhhc2UgPSBkYXNoUGhhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aChvcHMsIGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gY3VycmVudC55OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3Agb2Ygb3BzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChvcCB8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucmVjdGFuZ2xlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHh3ID0geCArIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWggPSB5ICsgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJNIiwgcGYoeCksIHBmKHkpLCAiTCIsIHBmKHh3KSwgcGYoeSksICJMIiwgcGYoeHcpLCBwZih5aCksICJMIiwgcGYoeCksIHBmKHloKSwgIloiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiTSIsIHBmKHgpLCBwZih5KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkwiLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkMiLCBwZihhcmdzW2pdKSwgcGYoYXJnc1tqICsgMV0pLCBwZihhcmdzW2ogKyAyXSksIHBmKGFyZ3NbaiArIDNdKSwgcGYoeCksIHBmKHkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGogKz0gNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiQyIsIHBmKHgpLCBwZih5KSwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoYXJnc1tqICsgMl0pLCBwZihhcmdzW2ogKyAzXSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8zOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJDIiwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoeCksIHBmKHkpLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiWiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGQuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0aCAmJiBvcHMubGVuZ3RoID4gMCAmJiBvcHNbMF0gIT09IF91dGlsLk9QUy5yZWN0YW5nbGUgJiYgb3BzWzBdICE9PSBfdXRpbC5PUFMubW92ZVRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGN1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpICsgZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpwYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQoY3VycmVudC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZWxlbWVudCA9IGN1cnJlbnQucGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc2V0Q3VycmVudFBvaW50KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVuZFBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5wZW5kaW5nQ2xpcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3VycmVudC5lbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcElkID0gYGNsaXBwYXRoJHtjbGlwQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcFBhdGggPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmNsaXBQYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjbGlwSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcFBhdGguc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIHBtKHRoaXMudHJhbnNmb3JtTWF0cml4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwRWxlbWVudCA9IGN1cnJlbnQuZWxlbWVudC5jbG9uZU5vZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wZW5kaW5nQ2xpcCA9PT0gImV2ZW5vZGQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImNsaXAtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXBFbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXJ1bGUiLCAibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5hcHBlbmQoY2xpcEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWZzLmFwcGVuZChjbGlwUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5hY3RpdmVDbGlwVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJldiBvZiB0aGlzLmV4dHJhU3RhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY2xpcC1wYXRoIiwgY3VycmVudC5hY3RpdmVDbGlwVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuYWN0aXZlQ2xpcFVybCA9IGB1cmwoIyR7Y2xpcElkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjbGlwKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5wYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZCA9IGAke2N1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpfVpgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmcobGVhZGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRUZXh0UmlzZSh0ZXh0UmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSaXNlID0gdGV4dFJpc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGUodGV4dFJlbmRlcmluZ01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRIU2NhbGUgPSBzY2FsZSAvIDEwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50KSB7fQogICAgICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzcyhmbGF0bmVzcykge30KICAgICAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2Ygc3RhdGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lV2lkdGgodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lSm9pbih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGFzaCh2YWx1ZVswXSwgdmFsdWVbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEZsYXRuZXNzKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Rm9udCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VBbHBoYSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQWxwaGEodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFVuaW1wbGVtZW50ZWQgZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAke2tleX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwiLCBjdXJyZW50LmZpbGxDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCBjdXJyZW50LmZpbGxBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQuZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfc2V0U3Ryb2tlQXR0cmlidXRlcyhlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGluZVdpZHRoU2NhbGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhc2hBcnJheSA9IGN1cnJlbnQuZGFzaEFycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVXaWR0aFNjYWxlICE9PSAxICYmIGRhc2hBcnJheS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFzaEFycmF5ID0gZGFzaEFycmF5Lm1hcChmdW5jdGlvbiAodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpbmVXaWR0aFNjYWxlICogdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UiLCBjdXJyZW50LnN0cm9rZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInN0cm9rZS1vcGFjaXR5IiwgY3VycmVudC5zdHJva2VBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtbWl0ZXJsaW1pdCIsIHBmKGN1cnJlbnQubWl0ZXJMaW1pdCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVjYXAiLCBjdXJyZW50LmxpbmVDYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVqb2luIiwgY3VycmVudC5saW5lSm9pbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2Utd2lkdGgiLCBwZihsaW5lV2lkdGhTY2FsZSAqIGN1cnJlbnQubGluZVdpZHRoKSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWRhc2hhcnJheSIsIGRhc2hBcnJheS5tYXAocGYpLmpvaW4oIiAiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtZGFzaG9mZnNldCIsIHBmKGxpbmVXaWR0aFNjYWxlICogY3VycmVudC5kYXNoUGhhc2UpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW9GaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGN1cnJlbnQkZWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRjdXJyZW50JGVsZW1lbnQgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjdXJyZW50JGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVvRmlsbFN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjdXJyZW50JGVsZW1lbnQyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGN1cnJlbnQkZWxlbWVudDIgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY3VycmVudCRlbGVtZW50Mi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbC1ydWxlIiwgImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlRU9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW9GaWxsU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRTb2xpZENvbG9ySW1hZ2VNYXNrKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsICIwIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQocmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZVhPYmplY3Qob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYERlcGVuZGVudCBpbWFnZSB3aXRoIG9iamVjdCBJRCAke29iaklkfSBpcyBub3QgcmVhZHkgeWV0YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhLCBtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ1NyYyA9IGNvbnZlcnRJbWdEYXRhVG9QbmcoaW1nRGF0YSwgdGhpcy5mb3JjZURhdGFTY2hlbWEsICEhbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJoZWlnaHQiLCBwZihoZWlnaHQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5lbGVtZW50ID0gY2xpcHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0VsID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzppbWFnZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMoWExJTktfTlMsICJ4bGluazpocmVmIiwgaW1nU3JjKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdFbC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIGBzY2FsZSgke3BmKDEgLyB3aWR0aCl9ICR7cGYoLTEgLyBoZWlnaHQpfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5hcHBlbmQoaW1nRWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChpbWdFbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZU1hc2tYT2JqZWN0KGltZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nRGF0YSA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJwYWludEltYWdlTWFza1hPYmplY3Q6IEltYWdlQml0bWFwIHN1cHBvcnQgaXMgbm90IGltcGxlbWVudGVkLCAiICsgImVuc3VyZSB0aGF0IHRoZSBgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWRgIEFQSSBwYXJhbWV0ZXIgaXMgZGlzYWJsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lm1hc2tJZCA9IGBtYXNrJHttYXNrQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bWFzayIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjdXJyZW50Lm1hc2tJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCBwZih3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgZmlsbENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIm1hc2siLCBgdXJsKCMke2N1cnJlbnQubWFza0lkfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQobWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChyZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSwgbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luKG1hdHJpeCwgYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0obWF0cml4WzBdLCBtYXRyaXhbMV0sIG1hdHJpeFsyXSwgbWF0cml4WzNdLCBtYXRyaXhbNF0sIG1hdHJpeFs1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gYmJveFsyXSAtIGJib3hbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsIGJib3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgYmJveFsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmVsZW1lbnQgPSBjbGlwcmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kKCkge30KICAgICAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUodmlld3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodmlld3BvcnQud2lkdGgsIHZpZXdwb3J0LmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZpbml0aW9ucyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZGVmcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChkZWZpbml0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMgPSBkZWZpbml0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RHcm91cCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh2aWV3cG9ydC50cmFuc2Zvcm0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocm9vdEdyb3VwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gcm9vdEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfZW5zdXJlQ2xpcEdyb3VwKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmN1cnJlbnQuY2xpcEdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcEdyb3VwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXBhdGgiLCB0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcuYXBwZW5kKGNsaXBHcm91cCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmNsaXBHcm91cCA9IGNsaXBHcm91cDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmN1cnJlbnQuY2xpcEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy50Z3JwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh0aGlzLnRyYW5zZm9ybU1hdHJpeCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVDbGlwR3JvdXAoKS5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Zy5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50Z3JwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KQogICAgICAgICAgICAvKioqKioqLyAJXSk7CiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIG1vZHVsZSBjYWNoZQogICAgICAgIC8qKioqKiovIAl2YXIgX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fID0ge307CiAgICAgICAgLyoqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIHJlcXVpcmUgZnVuY3Rpb24KICAgICAgICAvKioqKioqLyAJZnVuY3Rpb24gX193X3BkZmpzX3JlcXVpcmVfXyhtb2R1bGVJZCkgewogICAgICAgICAgICAvKioqKioqLyAJCS8vIENoZWNrIGlmIG1vZHVsZSBpcyBpbiBjYWNoZQogICAgICAgICAgICAvKioqKioqLyAJCXZhciBjYWNoZWRNb2R1bGUgPSBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX19bbW9kdWxlSWRdOwogICAgICAgICAgICAvKioqKioqLyAJCWlmIChjYWNoZWRNb2R1bGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgLyoqKioqKi8gCQkJcmV0dXJuIGNhY2hlZE1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9CiAgICAgICAgICAgIC8qKioqKiovIAkJLy8gQ3JlYXRlIGEgbmV3IG1vZHVsZSAoYW5kIHB1dCBpdCBpbnRvIHRoZSBjYWNoZSkKICAgICAgICAgICAgLyoqKioqKi8gCQl2YXIgbW9kdWxlID0gX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fW21vZHVsZUlkXSA9IHsKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5pZCBuZWVkZWQKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5sb2FkZWQgbmVlZGVkCiAgICAgICAgICAgICAgICAvKioqKioqLyAJCQlleHBvcnRzOiB7fQogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9OwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIEV4ZWN1dGUgdGhlIG1vZHVsZSBmdW5jdGlvbgogICAgICAgICAgICAvKioqKioqLyAJCV9fd2VicGFja19tb2R1bGVzX19bbW9kdWxlSWRdKG1vZHVsZSwgbW9kdWxlLmV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pOwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIFJldHVybiB0aGUgZXhwb3J0cyBvZiB0aGUgbW9kdWxlCiAgICAgICAgICAgIC8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAvKioqKioqLyAJfQogICAgICAgIC8qKioqKiovCiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICB2YXIgX193ZWJwYWNrX2V4cG9ydHNfXyA9IHt9OwovLyBUaGlzIGVudHJ5IG5lZWQgdG8gYmUgd3JhcHBlZCBpbiBhbiBJSUZFIGJlY2F1c2UgaXQgbmVlZCB0byBiZSBpbiBzdHJpY3QgbW9kZS4KICAgICAgICAoKCkgPT4gewogICAgICAgICAgICAidXNlIHN0cmljdCI7CiAgICAgICAgICAgIHZhciBleHBvcnRzID0gX193ZWJwYWNrX2V4cG9ydHNfXzsKCgogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFib3J0RXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9lZGl0b3JfbGF5ZXIuQW5ub3RhdGlvbkVkaXRvckxheWVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFubm90YXRpb25FZGl0b3JUeXBlIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3Rvb2xzLkFubm90YXRpb25FZGl0b3JVSU1hbmFnZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9sYXllci5Bbm5vdGF0aW9uTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTW9kZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkFubm90YXRpb25Nb2RlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQ01hcENvbXByZXNzaW9uVHlwZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJGZWF0dXJlVGVzdCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkZlYXR1cmVUZXN0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiR2xvYmFsV29ya2VyT3B0aW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiSW52YWxpZFBERkV4Y2VwdGlvbiIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkludmFsaWRQREZFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJNaXNzaW5nUERGRXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIk9QUyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLk9QUzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBERkRhdGFSYW5nZVRyYW5zcG9ydCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuUERGRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUERGRGF0ZVN0cmluZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQREZXb3JrZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLlBERldvcmtlcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBhc3N3b3JkUmVzcG9uc2VzIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuUGFzc3dvcmRSZXNwb25zZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQZXJtaXNzaW9uRmxhZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlBlcm1pc3Npb25GbGFnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUGl4ZWxzUGVySW5jaCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2g7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJTVkdHcmFwaGljcyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdmcuU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVdGlsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlZlcmJvc2l0eUxldmVsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJYZmFMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfbGF5ZXIuWGZhTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJidWlsZCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuYnVpbGQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXREb2N1bWVudCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuZ2V0RG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRQZGZGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRQZGZGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRYZmFQYWdlVmlld3BvcnQiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRYZmFQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc0RhdGFTY2hlbWUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc1BkZkZpbGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc1BkZkZpbGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJsb2FkU2NyaXB0IiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2Rpc3BsYXlfdXRpbHMubG9hZFNjcmlwdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInJlbmRlclRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNldExheWVyRGltZW5zaW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNoYWRvdyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLnNoYWRvdzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInVwZGF0ZVRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnVwZGF0ZVRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInZlcnNpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLnZlcnNpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgdmFyIF9hcGkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOCk7CiAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgdmFyIF90ZXh0X2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fZWRpdG9yX2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjIpOwogICAgICAgICAgICB2YXIgX3Rvb2xzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nyk7CiAgICAgICAgICAgIHZhciBfd29ya2VyX29wdGlvbnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OSk7CiAgICAgICAgICAgIHZhciBfc3ZnID0gX193X3BkZmpzX3JlcXVpcmVfXygxNzApOwogICAgICAgICAgICB2YXIgX3hmYV9sYXllciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTY5KTsKICAgICAgICAgICAgY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICBjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgfSkoKTsKCiAgICAgICAgLyoqKioqKi8gCXJldHVybiBfX3dlYnBhY2tfZXhwb3J0c19fOwogICAgICAgIC8qKioqKiovIH0pKCkKICAgICAgICA7Cn0pOwovLyMgc291cmNlTWFwcGluZ1VSTD1wZGYuanMubWFw",new Promise(((I,C)=>{const A=document.createElement("script");A.src=g,A.onload=function(){I({success:!0})},A.onerror=function(g){C({success:!1,error:g})},document.body.append(A)}))).then((()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc="data:text/javascript;base64,LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICoKICogICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAogKgogKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCiAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCiAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgogKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3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Q2h1bmtzID0gW107CiAgICAgIH07CiAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICBjb25zdCByZWFkQ2h1bmsgPSBmdW5jdGlvbiAoX3JlZjIpIHsKICAgICAgICAgIGxldCB7CiAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICBkb25lCiAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgaWYgKCFuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICBmbHVzaENodW5rcygpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYW5jZWxYSFJzID0gbnVsbDsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgIGlmICghZnVsbFJlcXVlc3QuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICBoYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICAgICAgICAgICAgbG9hZGVkLAogICAgICAgICAgICAgICAgdG90YWw6IE1hdGgubWF4KGxvYWRlZCwgZnVsbFJlcXVlc3QuY29udGVudExlbmd0aCB8fCAwKQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgbmV3UGRmTWFuYWdlci5zZW5kUHJvZ3Jlc3NpdmVEYXRhKHZhbHVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjYWNoZWRDaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVsbFJlcXVlc3QucmVhZCgp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uZ2V0KCJYRkEiKSB8fCBudWxsOwogICAgICAgIGxldCB4ZmFEYXRhc2V0c1JlZiA9IG51bGw7CiAgICAgICAgbGV0IGhhc1hmYURhdGFzZXRzRW50cnkgPSBmYWxzZTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh4ZmEpKSB7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB4ZmEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBpZiAoeGZhW2ldID09PSAiZGF0YXNldHMiKSB7CiAgICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4ZmFbaSArIDFdOwogICAgICAgICAgICAgIGhhc1hmYURhdGFzZXRzRW50cnkgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoeGZhRGF0YXNldHNSZWYgPT09IG51bGwpIHsKICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoeGZhKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIFhGQSB0eXBlLiIpOwogICAgICAgIH0KICAgICAgICBsZXQgbmV3WHJlZkluZm8gPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgIGlmICh4cmVmLnRyYWlsZXIpIHsKICAgICAgICAgIGNvbnN0IGluZm9PYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgY29uc3QgeHJlZkluZm8gPSB4cmVmLnRyYWlsZXIuZ2V0KCJJbmZvIikgfHwgbnVsbDsKICAgICAgICAgIGlmICh4cmVmSW5mbyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgeHJlZkluZm8uZm9yRWFjaCgoa2V5LCB2YWx1ZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBpbmZvT2JqW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgbGFzdFhSZWZTdHJlYW1Qb3MgPSB4cmVmLmxhc3RYUmVmU3RyZWFtUG9zOwogICAgICAgICAgbmV3WHJlZkluZm8gPSB7CiAgICAgICAgICAgIHJvb3RSZWY6IHhyZWYudHJhaWxlci5nZXRSYXcoIlJvb3QiKSB8fCBudWxsLAogICAgICAgICAgICBlbmNyeXB0UmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJFbmNyeXB0IikgfHwgbnVsbCwKICAgICAgICAgICAgbmV3UmVmOiB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpLAogICAgICAgICAgICBpbmZvUmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJJbmZvIikgfHwgbnVsbCwKICAgICAgICAgICAgaW5mbzogaW5mb09iaiwKICAgICAgICAgICAgZmlsZUlkczogeHJlZi50cmFpbGVyLmdldCgiSUQiKSB8fCBudWxsLAogICAgICAgICAgICBzdGFydFhSZWY6IGxhc3RYUmVmU3RyZWFtUG9zID09PSBudWxsID8gc3RhcnRYUmVmIDogbGFzdFhSZWZTdHJlYW1Qb3MsCiAgICAgICAgICAgIGZpbGVuYW1lCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuICgwLCBfd3JpdGVyLmluY3JlbWVudGFsVXBkYXRlKSh7CiAgICAgICAgICAgIG9yaWdpbmFsRGF0YTogc3RyZWFtLmJ5dGVzLAogICAgICAgICAgICB4cmVmSW5mbzogbmV3WHJlZkluZm8sCiAgICAgICAgICAgIG5ld1JlZnMsCiAgICAgICAgICAgIHhyZWYsCiAgICAgICAgICAgIGhhc1hmYTogISF4ZmEsCiAgICAgICAgICAgIHhmYURhdGFzZXRzUmVmLAogICAgICAgICAgICBoYXNYZmFEYXRhc2V0c0VudHJ5LAogICAgICAgICAgICBuZWVkQXBwZWFyYW5jZXMsCiAgICAgICAgICAgIGFjcm9Gb3JtUmVmLAogICAgICAgICAgICBhY3JvRm9ybSwKICAgICAgICAgICAgeGZhRGF0YQogICAgICAgICAgfSk7CiAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgIHhyZWYucmVzZXROZXdUZW1wb3JhcnlSZWYoKTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRPcGVyYXRvckxpc3QiLCBmdW5jdGlvbiAoZGF0YSwgc2luaykgewogICAgICBjb25zdCBwYWdlSW5kZXggPSBkYXRhLnBhZ2VJbmRleDsKICAgICAgcGRmTWFuYWdlci5nZXRQYWdlKHBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgR2V0T3BlcmF0b3JMaXN0OiBwYWdlICR7cGFnZUluZGV4fWApOwogICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICBjb25zdCBzdGFydCA9IHZlcmJvc2l0eSA+PSBfdXRpbC5WZXJib3NpdHlMZXZlbC5JTkZPUyA/IERhdGUubm93KCkgOiAwOwogICAgICAgIHBhZ2UuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIGhhbmRsZXIsCiAgICAgICAgICBzaW5rLAogICAgICAgICAgdGFzaywKICAgICAgICAgIGludGVudDogZGF0YS5pbnRlbnQsCiAgICAgICAgICBjYWNoZUtleTogZGF0YS5jYWNoZUtleSwKICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBkYXRhLmFubm90YXRpb25TdG9yYWdlCiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAob3BlcmF0b3JMaXN0SW5mbykgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldE9wZXJhdG9yTGlzdDogdGltZT1gICsgYCR7RGF0ZS5ub3coKSAtIHN0YXJ0fW1zLCBsZW49JHtvcGVyYXRvckxpc3RJbmZvLmxlbmd0aH1gKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRUZXh0Q29udGVudCIsIGZ1bmN0aW9uIChkYXRhLCBzaW5rKSB7CiAgICAgIGNvbnN0IHBhZ2VJbmRleCA9IGRhdGEucGFnZUluZGV4OwogICAgICBwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgY29uc3QgdGFzayA9IG5ldyBXb3JrZXJUYXNrKCJHZXRUZXh0Q29udGVudDogcGFnZSAiICsgcGFnZUluZGV4KTsKICAgICAgICBzdGFydFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgY29uc3Qgc3RhcnQgPSB2ZXJib3NpdHkgPj0gX3V0aWwuVmVyYm9zaXR5TGV2ZWwuSU5GT1MgPyBEYXRlLm5vdygpIDogMDsKICAgICAgICBwYWdlLmV4dHJhY3RUZXh0Q29udGVudCh7CiAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgdGFzaywKICAgICAgICAgIHNpbmssCiAgICAgICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogZGF0YS5pbmNsdWRlTWFya2VkQ29udGVudCwKICAgICAgICAgIGNvbWJpbmVUZXh0SXRlbXM6IGRhdGEuY29tYmluZVRleHRJdGVtcwogICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldFRleHRDb250ZW50OiB0aW1lPWAgKyBgJHtEYXRlLm5vdygpIC0gc3RhcnR9bXNgKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRTdHJ1Y3RUcmVlIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuZ2V0UGFnZShkYXRhLnBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIHJldHVybiBwZGZNYW5hZ2VyLmVuc3VyZShwYWdlLCAiZ2V0U3RydWN0VHJlZSIpOwogICAgICB9KTsKICAgIH0pOwogICAgaGFuZGxlci5vbigiRm9udEZhbGxiYWNrIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuZm9udEZhbGxiYWNrKGRhdGEuaWQsIGhhbmRsZXIpOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJDbGVhbnVwIiwgZnVuY3R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SA8IDI7ICsraSkgewogICAgICBpZiAoaSA9PT0gMCkgewogICAgICAgIGIgPSA2ICogeDAgLSAxMiAqIHgxICsgNiAqIHgyOwogICAgICAgIGEgPSAtMyAqIHgwICsgOSAqIHgxIC0gOSAqIHgyICsgMyAqIHgzOwogICAgICAgIGMgPSAzICogeDEgLSAzICogeDA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYiA9IDYgKiB5MCAtIDEyICogeTEgKyA2ICogeTI7CiAgICAgICAgYSA9IC0zICogeTAgKyA5ICogeTEgLSA5ICogeTIgKyAzICogeTM7CiAgICAgICAgYyA9IDMgKiB5MSAtIDMgKiB5MDsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYSkgPCAxZS0xMikgewogICAgICAgIGlmIChNYXRoLmFicyhiKSA8IDFlLTEyKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgIHR2YWx1ZXMucHVzaCh0KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgYjJhYyA9IGIgKiBiIC0gNCAqIGMgKiBhOwogICAgICBzcXJ0YjJhYyA9IE1hdGguc3FydChiMmFjKTsKICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdDEgPSAoLWIgKyBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgIH0KICAgICAgdDIgPSAoLWIgLSBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgIH0KICAgIH0KICAgIGxldCBqID0gdHZhbHVlcy5sZW5ndGgsCiAgICAgI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ICAgICAgIGxldCBwcm9wZXJ0eSA9IHByb3BlcnRpZXMuZ2V0KGtleSk7CiAgICAgICAgaWYgKHByb3BlcnR5ID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHByb3BlcnR5ID0gW107CiAgICAgICAgICBwcm9wZXJ0aWVzLnNldChrZXksIHByb3BlcnR5KTsKICAgICAgICB9IGVsc2UgaWYgKCFtZXJnZVN1YkRpY3RzIHx8ICEodmFsdWUgaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHByb3BlcnR5LnB1c2godmFsdWUpOwogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IFtuYW1lLCB2YWx1ZXNdIG9mIHByb3BlcnRpZXMpIHsKICAgICAgaWYgKHZhbHVlcy5sZW5ndGggPT09IDEgfHwgISh2YWx1ZXNbMF0gaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHZhbHVlc1swXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBzdWJEaWN0ID0gbmV3IERpY3QoeHJlZik7CiAgICAgIGZvciAoY29uc3QgZGljdCBvZiB2YWx1ZXMpIHsKICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBPYmplY3QuZW50cmllcyhkaWN0Ll9tYXApKSB7CiAgICAgICAgICBpZiAoc3ViRGljdC5fbWFwW2tleV0gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBzdWJEaWN0Ll9tYXBba2V5XSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3ViRGljdC5zaXplID4gMCkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHN1YkRpY3Q7CiAgICAgIH0KICAgIH0KICAgIHByb3BlcnRpZXMuY2xlYXIoKTsKICAgIHJldHVybiBtZXJnZWREaWN0LnNpemUgP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sKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICBpZiAocmFuZ2VSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgdGhpcy5vblByb2dyZXNzKHsKICAgICAgICAgICAgICBsb2FkZWQKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgICBjaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICByYW5nZVJlYWRlci5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgfSkudGhlbihkYXRhID0+IHsKICAgICAgaWYgKHRoaXMuYWJvcnRlZCkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aGlzLm9uUmVjZWl2ZURhdGEoewogICAgICAgIGNodW5rOiBkYXRhLAogICAgICAgIGJlZ2luCiAgICAgIH0pOwogICAgfSk7CiAgfQogIHJlcXVlc3RBbGxDaHVua3MoKSB7CiAgICBsZXQgbm9GZXRjaCA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICBpZiAoIW5vRmV0Y2gpIHsKICAgICAgY29uc3QgbWlzc2luZ0NodW5rcyA9IHRoaXMuc3RyZWFtLmdldE1pc3NpbmdDaHVua3MoKTsKICAgICAgdGhpcy5fcmVxdWVzdENodW5rcyhtaXNzaW5nQ2h1bmtzKTsKICAgIH0KICAgIHJldHVybiB0aGlzLl9sb2FkZWRTdHJlYW1DYXBhYmlsaXR5LnByb21pc2U7CiAgfQogIF9yZX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DwgMCkgewogICAgICAgIGJlZ2luQ2h1bmsgPSBjaHVuazsKICAgICAgfQogICAgICBpZiAocHJldkNodW5rID49IDAgJiYgcHJldkNodW5rICsgMSAhPT0gY2h1bmspIHsKICAgICAgICBncm91cGVkQ2h1bmtzLnB1c2goewogICAgICAgICAgYmVnaW5DaHVuaywKICAgICAgICAgIGVuZENodW5rOiBwcmV2Q2h1bmsgKyAxCiAgICAgICAgfSk7CiAgICAgICAgYmVnaW5DaHVuayA9IGNodW5rOwogICAgICB9CiAgICAgIGlmIChpICsgMSA9PT0gY2h1bmtzLmxlbmd0aCkgewogICAgICAgIGdyb3VwZWRDaHVua3MucHVzaCh7CiAgICAgICAgICBiZWdpbkNodW5rLAogICAgICAgICAgZW5kQ2h1bms6IGNodW5rICsgMQogICAgICAgIH0pOwogICAgICB9CiAgICAgIHByZXZDaHVuayA9IGNodW5rOwogICAgfQogICAgcmV0dXJuIGdyb3VwZWRDaHVua3M7CiAgfQogIG9uUHJvZ3Jlc3MoYXJncykgewogICAgdGhpcy5tc2dIYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICBsb2FkZWQ6IHRoaXMuc3RyZWFtLm51bUNodW5rc0xvYWRlZCAqIHRoaXMuY2h1bmtTaXplICsgYXJncy5sb2FkZWQsCiAgICAgIHRvdGFsOiB0aGlzLmxlbmd0aAogICAgfSk7CiAgfQogIG9uUmVjZWl2ZURhdGEoYXJncykgewogICAgY29uc3QgY2h1bmsgPSBhcmdzLmNodW5rOwogICAgY29uc3QgaXNQcm9ncmVzc2l2ZSA9IGFyZ3MuYmVnaW4gPT09IHVuZGVmaW5lZDsKICAgIGNvbnN0IGJlZ2luID0gaXNQcm9ncmVzc2l2ZSA/IHRoaXMucHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoIDogYXJncy5iZWdpbjsKICAgIGNvbnN0IGVuZCA9IGJlZ2luICsgY2h1bmsuYnl0ZUxlbmd0aDsKICAgIGNvbnN0IGJlZ2luQ2h1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KSB7CiAgICAgIHJldHVybiB0aGlzLnhmYURhdGEuYmJveDsKICAgIH0KICAgIGxldCBib3ggPSB0aGlzLl9nZXRJbmhlcml0YWJsZVByb3BlcnR5KG5hbWUsIHRydWUpOwogICAgaWYgKEFycmF5LmlzQXJyYXkoYm94KSAmJiBib3gubGVuZ3RoID09PSA0KSB7CiAgICAgIGJveCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChib3gpOwogICAgICBpZiAoYm94WzJdIC0gYm94WzBdID4gMCAmJiBib3hbM10gLSBib3hbMV0gPiAwKSB7CiAgICAgICAgcmV0dXJuIGJveDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYEVtcHR5LCBvciBpbnZhbGlkLCAvJHtuYW1lfSBlbnRyeS5gKTsKICAgIH0KICAgIHJldHVybiBudWxsOwogIH0KICBnZXQgbWVkaWFCb3goKSB7CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1lZGlhQm94IiwgdGhpcy5fZ2V0Qm91bmRpbmdCb3goIk1lZGlhQm94IikgfHwgTEVUVEVSX1NJWkVfTUVESUFCT1gpOwogIH0KICBnZXQgY3JvcEJveCgpIHsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiY3JvcEJveCIsIHRoaXMuX2dldEJvdW5kaW5nQm94KCJDcm9wQm94IikgfHwgdGhpcy5tZWRpYUJveCk7CiAgfQogIGdldCB1c2VyVW5pdCgpIHsKICAgIGxldCBvYmogPSB0aGlzLnBhZ2VEaWN0LmdldCgiVXNlclVuaXQiKTsKICAgIGlmICh0eXBlb2Ygb2JqICE9PSAibnVtYmVyIiB8fCBvYmogPD0gMCkgewogICAgICBvYmogPSBERUZBVUxUX1VTRVJfVU5JVDsKICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidXNlclVuaXQiLCBvYmopOwogIH0KICBnZXQgdmlldygpIHsKICAgIGNvbnN0IHsKICAgICAgY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2FjaGUsCiAgICAgIG9wdGlvbnM6IHRoaXMuZXZhbHVhdG9yT3B0aW9ucwogICAgfSk7CiAgICByZXR1cm4gdGhpcy5fcGFyc2VkQW5ub3RhdGlvbnMudGhlbihmdW5jdGlvbiAoYW5ub3RhdGlvbnMpIHsKICAgICAgY29uc3QgbmV3UmVmc1Byb21pc2VzID0gW107CiAgICAgIGZvciAoY29uc3QgYW5ub3RhdGlvbiBvZiBhbm5vdGF0aW9ucykgewogICAgICAgIGlmICghYW5ub3RhdGlvbi5tdXN0QmVQcmludGVkKGFubm90YXRpb25TdG9yYWdlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5ld1JlZnNQcm9taXNlcy5wdXNoKGFubm90YXRpb24uc2F2ZShwYXJ0aWFsRXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJzYXZlIC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChuZXdSZWZzUHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG5ld1JlZnMpIHsKICAgICAgICByZXR1cm4gbmV3UmVmcy5maWx0ZXIobmV3UmVmID0+ICEhbmV3UmVmKTsKICAgICAgfSk7CiAgICB9KTsKICB9CiAgbG9hZFJlc291cmNlcyhrZXlzKSB7CiAgICBpZiAoIXRoaXMucmVzb3VyY2VzUHJvbWlzZSkgewogICAgICB0aGlzLnJlc291cmNlc1Byb21pc2UgPSB0aGlzLnBkZk1hbmFnZXIuZW5zdXJlKHRoaXMsICJyZXNvdXJjZXMiKTsKICAgIH0KICAgIHJldHVybiB0aGlz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nRpYWxFdmFsdWF0b3IuaGFzQmxlbmRNb2Rlcyh0aGlzLnJlc291cmNlcywgdGhpcy5ub25CbGVuZE1vZGVzU2V0KSwKICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgIGNhY2hlS2V5CiAgICAgIH0pOwogICAgICByZXR1cm4gcGFydGlhbEV2YWx1YXRvci5nZXRPcGVyYXRvckxpc3QoewogICAgICAgIHN0cmVhbTogY29udGVudFN0cmVhbSwKICAgICAgICB0YXNrLAogICAgICAgIHJlc291cmNlczogdGhpcy5yZXNvdXJjZXMsCiAgICAgICAgb3BlcmF0b3JMaXN0OiBvcExpc3QKICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgcmV0dXJuIG9wTGlzdDsKICAgICAgfSk7CiAgICB9KTsKICAgIHJldHVybiBQcm9taXNlLmFsbChbcGFnZUxpc3RQcm9taXNlLCB0aGlzLl9wYXJzZWRBbm5vdGF0aW9ucywgbmV3QW5ub3RhdGlvbnNQcm9taXNlXSkudGhlbihmdW5jdGlvbiAoX3JlZjQpIHsKICAgICAgbGV0IFtwYWdlT3BMaXN0LCBhbm5vdGF0aW9ucywgbmV3QW5ub3RhdGlvbnNdID0gX3JlZjQ7CiAgICAgIGlmIChuZXdBbm5vdGF0aW9ucykgewogICAgICAgIGFubm90YXRpb25zID0gYW5ub3RhdGlvbnMuY29uY2F0KG5ld0Fubm90YXRpb25zKTsKICAgICAgfQogICAgICBpZiAoYW5ub3RhdGlvbnMubGVuZ3RoID09PSAwIHx8IGludGVudCAmIF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRSkgewogICAgICAgIHBhZ2VPcExpc3QuZmx1c2godHJ1ZSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0KICAgICAgY29uc3QgcmVuZGVyRm9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IGZhbHNlLAogICAgICAgICAgICAgIHNlcGFyYXRlQ2FudmFzOiBmYWxzZQogICAgICAgICAgICB9OwogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwob3BMaXN0UHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG9wTGlzdHMpIHsKICAgICAgICBsZXQgZm9ybSA9IGZhbHNlLAogICAgICAgICAgY2FudmFzID0gZmFsc2U7CiAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICBvcExpc3QsCiAgICAgICAgICBzZXBhcmF0ZUZvcm0sCiAgICAgICAgICBzZXBhcmF0ZUNhbnZhcwogICAgICAgIH0gb2Ygb3BMaXN0cykgewogICAgICAgICAgcGFnZU9wTGlzdC5hZGRPcExpc3Qob3BMaXN0KTsKICAgICAgICAgIGlmIChzZXBhcmF0ZUZvcm0pIHsKICAgICAgICAgICAgZm9ybSA9IHNlcGFyYXRlRm9ybTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzZXBhcmF0ZUNhbnZhcykgewogICAgICAgICAgICBjYW52YXMgPSBzZXBhcmF0ZUNhbnZhczsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcGFnZU9wTGlzdC5mbHVzaCh0cnVlLCB7CiAgICAgICAgICBmb3JtLAogICAgICAgICAgY2FudmFzCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0pOwogICAgfSk7CiAgfQogIGV4dHJhY3RUZXh0Q29udGVudChfcmVmNSkgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgdGFzaywKICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQsCiAgICAgIHNpbmssCiAgICAgIGNvbWJpbmVUZXh0SXRlbXMKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGNvbnRlbnRTdHJlY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oY29uc3QgYW5ub3RhdGlvblJlZiBvZiB0aGlzLmFubm90YXRpb25zKSB7CiAgICAgICAgYW5ub3RhdGlvblByb21pc2VzLnB1c2goX2Fubm90YXRpb24uQW5ub3RhdGlvbkZhY3RvcnkuY3JlYXRlKHRoaXMueHJlZiwgYW5ub3RhdGlvblJlZiwgdGhpcy5wZGZNYW5hZ2VyLCB0aGlzLl9sb2NhbElkRmFjdG9yeSwgZmFsc2UpLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgX3BhcnNlZEFubm90YXRpb25zOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0pKTsKICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwoYW5ub3RhdGlvblByb21pc2VzKS50aGVuKGZ1bmN0aW9uIChhbm5vdGF0aW9ucykgewogICAgICAgIGlmIChhbm5vdGF0aW9ucy5sZW5ndGggPT09IDApIHsKICAgICAgICAgIHJldHVybiBhbm5vdGF0aW9uczsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc29ydGVkQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICBsZXQgcG9wdXBBbm5vdGF0aW9uczsKICAgICAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgICAgIGlmICghYW5ub3RhdGlvbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhbm5vdGF0aW9uIGluc3RhbmNlb2YgX2Fubm90YXRpb24uUG9wdXBBbm5vdGF0aW9uKSB7CiAgICAgICAgICAgIGlmICghcG9wdXBBbm5vdGF0aW9ucykgewogICAgICAgICAgICAgIHBvcHVwQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3B1cEFubm90YXRpb25zLnB1c2goYW5ub3RhdGlvbik7CiAgICAgICAgICAg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vbik7CiAgfQogIGdldCBzdGFydFhSZWYoKSB7CiAgICBjb25zdCBzdHJlYW0gPSB0aGlzLnN0cmVhbTsKICAgIGxldCBzdGFydFhSZWYgPSAwOwogICAgaWYgKHRoaXMubGluZWFyaXphdGlvbikgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgICAgaWYgKGZpbmQoc3RyZWFtLCBFTkRPQkpfU0lHTkFUVVJFKSkgewogICAgICAgIHN0YXJ0WFJlZiA9IHN0cmVhbS5wb3MgKyA2IC0gc3RyZWFtLnN0YXJ0OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBzdGVwID0gMTAyNDsKICAgICAgY29uc3Qgc3RhcnRYUmVmTGVuZ3RoID0gU1RBUlRYUkVGX1NJR05BVFVSRS5sZW5ndGg7CiAgICAgIGxldCBmb3VuZCA9IGZhbHNlLAogICAgICAgIHBvcyA9IHN0cmVhbS5lbmQ7CiAgICAgIHdoaWxlICghZm91bmQgJiYgcG9zID4gMCkgewogICAgICAgIHBvcyAtPSBzdGVwIC0gc3RhcnRYUmVmTGVuZ3RoOwogICAgICAgIGlmIChwb3MgPCAwKSB7CiAgICAgICAgICBwb3MgPSAwOwogICAgICAgIH0KICAgICAgICBzdHJlYW0ucG9zID0gcG9zOwogICAgICAgIGZvdW5kID0gZmluZChzdHJlYW0sIFNUQVJUWFJFRl9TSUdOQVRVUkUsIHN0ZXAsIHRydWUpOwogICAgICB9CiAgICAgIGlmIChmb3VuZCkgewogICAgICAgIHN0cmVhbS5za2lwKDkpOwogICAgICAgIGxldCBjaDsKICAgICAgICBkbyB7CiAgICAgICAgICBjaCA9IHN0cmVhbS5nZXRCeXRlKCk7CiAgICAgICAgfSB3aGlsZSAoKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpKTsKICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgd2hpbGUgKGNoID49IDB4MjAgJiYgY2ggPD0gMHgzOSkgewogICAgICAgICAgc3RyICs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cywgInhmYURhdGFzZXRzIiwgbnVsbCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImRhdGFzZXRzIiwgInhkcDp4ZHAiXSkgewogICAgICBjb25zdCBzdHJlYW0gPSBzdHJlYW1zW2tleV07CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBzdHIgPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICAgIGNvbnN0IGRhdGEgPSB7CiAgICAgICAgICBba2V5XTogc3RyCiAgICAgICAgfTsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbmV3IF9kYXRhc2V0X3JlYWRlci5EYXRhc2V0UmVhZGVyKGRhdGEpKTsKICAgICAgfSBjYXRjaCAoXykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCB1dGYtOCBzdHJpbmcuIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAieGZhRGF0YXNldHMiLCBudWxsKTsKICB9CiAgZ2V0IHhmYURhdGEoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IGRhdGEgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgZm9yIChjb25zdCBba2V5LCBzdHJlYW1dIG9mIE9iamVjdC5lbnRyaWVzKHN0cmVhbXMpKSB7CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBkYXRhW2tleV0gPSAoMCwgX3V0aWwuc3Ry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m9udCIpOwogICAgaWYgKCEoZm9udFJlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG9wdGlvbnMgPSBPYmplY3QuYXNzaWduKE9iamVjdC5jcmVhdGUobnVsbCksIHRoaXMucGRmTWFuYWdlci5ldmFsdWF0b3JPcHRpb25zKTsKICAgIG9wdGlvbnMudXNlU3lzdGVtRm9udHMgPSBmYWxzZTsKICAgIGNvbnN0IHBhcnRpYWxFdmFsdWF0b3IgPSBuZXcgX2V2YWx1YXRvci5QYXJ0aWFsRXZhbHVhdG9yKHsKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICBoYW5kbGVyLAogICAgICBwYWdlSW5kZXg6IC0xLAogICAgICBpZEZhY3Rvcnk6IHRoaXMuX2dsb2JhbElkRmFjdG9yeSwKICAgICAgZm9udENhY2hlOiB0aGlzLmNhdGFsb2cuZm9udENhY2hlLAogICAgICBidWlsdEluQ01hcENhY2hlOiB0aGlzLmNhdGFsb2cuYnVpbHRJbkNNYXBDYWNoZSwKICAgICAgc3RhbmRhcmRGb250RGF0YUNhY2hlOiB0aGlzLmNhdGFsb2cuc3RhbmRhcmRGb250RGF0YUNhY2hlLAogICAgICBvcHRpb25zCiAgICB9KTsKICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgIGNvbnN0IHBkZkZvbnRzID0gW107CiAgICBjb25zdCBpbml0aWFsU3RhdGUgPSB7CiAgICAgIGdldCBmb250KCkgewogICAgICAgIHJldHVybiBwZGZGb250cy5hdCgtMSk7CiAgICAgIH0sCiAgICAgIHNldCBmb250KGZvbnQpIHsKICAgICAgICBwZGZGb250cy5wdXNoKGZvbnQpOwogICAgICB9LAogICAgICBjbG9uZSgpIHsKICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfQogICAgfTsKICAgIGNvbnN0IGZvbnRzID0gbmV3IE1hcCgpOwogICAgZm9udFJlcy5mb3JFYWNoKChmb250TmFtZSwgZm9udCkgPT4gewogICAgICBmb250cy5zZXQoZm9udE5hbWUsIGZvbnQpOwogICAgfSk7CiAgICBjb25zdCBwcm9taXNlcyA9IFtdOwogICAgZm9yIChjb25zdCBbZm9udE5hbWUsIGZvbnRdIG9mIGZvbnRzKSB7CiAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSBmb250LmdldCgiRm9udERlc2NyaXB0b3IiKTsKICAgICAgaWYgKCEoZGVzY3JpcHRvciBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbGV0IGZvbnRGYW1pbHkgPSBkZXNjcmlwdG9yLmdldCgiRm9udEZhbWlseSIpOwogICAgICBmb250RmFtaWx5ID0gZm9udEZhbWlseS5yZXBsYWNlQWxsKC9bIF0rKFxkKS9nLCAiJDEiKTsKICAgICAgY29uc3QgZm9udFdlaWdodCA9IGRlc2NyaXB0b3IuZ2V0KCJGb250V2VpZ2h0Iik7CiAgICAgIGNvbnN0IGl0YWxpY0FuZ2xlID0gLWRlc2NyaXB0b3IuZ2V0KCJJdGFsaWNBbmdsZSIpOwogICAgICBjb25zdCBjc3NGb250SW5mbyA9IHsKICAgICAgICBmb250RmFtaWx5LAogICAgICAgIGZvbnRXZWlnaHQsCiAgICAgICAgaXRhbGljQW5nbGUKICAgICAgfTsKICAgICAgaWYgKCEoMCwgX2NvcmVfdXRpbHMudmFsaWRhdGVDU1NGb250KShjc3NGb250SW5mbykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBwcm9taXNlcy5wdXNoKHBhcnRpYWxFdmFsdWF0b3IuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIFtfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSksIDFdLCBudWxsLCBvcGVyYXRvckxpc3QsIHRhc2ssIGluaXRpYWxTdGF0ZSwgbnVsbCwgY3NzRm9udEluZm8pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGxvYWRYZmFGb250czogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0pKTsKICAgIH0KICAgIGF3YWl0IFByb21pc2UuYWxsKHByb21pc2VzKTsKICAgIGNvbnN0IG1pc3NpbmdGb250cyA9IHRoaXMueGZhRmFjdG9yeS5zZXRGb250cyhwZGZGb250cyk7CiAgICBpZiAoIW1pc3NpbmdGb250cykgewogICAgICByZXR1cm47CiAgICB9CiAgICBvcHRpb25zLmlnbm9yZUVycm9ycyA9IHRydWU7CiAgICBwcm9taXNlcy5sZW5ndGggPSAwOwogICAgcGRmRm9udHMubGVuZ3RoID0gMDsKICAgIGNvbnN0IHJlYWxseU1pc3NpbmdGb250cyA9IG5ldyBTZXQoKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiBtaXNzaW5nRm9udHMpIHsKICAgICAgaWYgKCEoMCwgX3hmYV9mb250cy5nZXRYZmFGb250TmFtZSkoYCR7bWlzc2luZ30tUmVndWxhcmApKSB7CiAgICAgICAgcmVhbGx5TWlzc2luZ0ZvbnRzLmFkZChtaXNzaW5nKTsKICAgICAgfQogICAgfQogICAgaWYgKHJlYWxseU1pc3NpbmdGb250cy5zaXplKSB7CiAgICAgIG1pc3NpbmdGb250cy5wdXNoKCJQZGZKUy1GYWxsYmFjayIpOwogICAgfQogICAgZm9yIChjb25zdCBtaXNzaW5nIG9mIG1pc3NpbmdGb250cykgewogICAgICBpZiAocmVhbGx5TWlzc2luZ0ZvbnRzLmhhcyhtaXNzaW5nKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgZm9udEluZm8gb2YgW3sKICAgICAgICBuYW1lOiAiUmVndWxhciIsCiAgICAgICAgZm9udFdlaWdodDogNDAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZCIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiSXRhbGljIiwKICAgICAgICBmb250V2VpZ2h0OiA0MDAsCiAgICAgICAgaXRhbGljQW5nbGU6IDEyCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZEl0YWxpYyIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAxMgogICAgICB9XSkgewogICAgICAgIGNvbnN0IG5hbWUgPSBgJHttaXNzaW5nfS0ke2ZvbnRJbmZvLm5hbWV9YDsKICAgICAgICBjb25zdCBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3QpKG5hbWUpOwogICAgICAgIHByb21pc2VzLnB1c2gocGFydGlhbEV2YWx1YXRvci5oYW5kbGVTZXRGb250KHJlc291cmNlcywgW19wcmltaXRpdmVzLk5hbWUuZ2V0KG5hbWUpLCAxXSwgbnVsbCwgb3BlcmF0b3JMaXN0LCB0YXNrLCBpbml0aWFsU3RhdGUsIGRpY3QsIHsKICAgICAgICAgIGZvbnRGYW1pbHk6IG1pc3NpbmcsCiAgICAgICAgICBmb250V2VpZ2h0OiBmb250SW5mby5mb250V2VpZ2h0LAogICAgICAgICAgaXRhbGljQW5nbGU6IGZvbnRJbmZvLml0YWxpY0FuZ2xlCiAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBsb2FkWGZhRm9udHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICB9CiAgICBhd2FpdCBQcm9taXNlLmFsbChwcm9taXNlcyk7CiAgICB0aGlzLnhmYUZhY3RvcnkuYXBw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vZHVjZXIiOgogICAgICAgIGNhc2UgIkNyZWF0aW9uRGF0ZSI6CiAgICAgICAgY2FzZSAiTW9kRGF0ZSI6CiAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAic3RyaW5nIikgewogICAgICAgICAgICBkb2NJbmZvW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJUcmFwcGVkIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgZG9jSW5mb1trZXldID0gdmFsdWU7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGxldCBjdXN0b21WYWx1ZTsKICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7CiAgICAgICAgICAgIGNhc2UgInN0cmluZyI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAibnVtYmVyIjoKICAgICAgICAgICAgY2FzZSAiYm9vbGVhbiI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBjdXN0b21WYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjdXN0b21WYWx1ZSA9PT0g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hJRERFTik7CiAgfQogIG11c3RCZVByaW50ZWQoYW5ub3RhdGlvblN0b3JhZ2UpIHsKICAgIGNvbnN0IHN0b3JhZ2VFbnRyeSA9IGFubm90YXRpb25TdG9yYWdlICYmIGFubm90YXRpb25TdG9yYWdlLmdldCh0aGlzLmRhdGEuaWQpOwogICAgaWYgKHN0b3JhZ2VFbnRyeSAmJiBzdG9yYWdlRW50cnkucHJpbnQgIT09IHVuZGVmaW5lZCkgewogICAgICByZXR1cm4gc3RvcmFnZUVudHJ5LnByaW50OwogICAgfQogICAgcmV0dXJuIHRoaXMucHJpbnRhYmxlOwogIH0KICBnZXQgdmlld2FibGUoKSB7CiAgICBpZiAodGhpcy5kYXRhLnF1YWRQb2ludHMgPT09IG51bGwpIHsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgaWYgKHRoaXMuZmxhZ3MgPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICByZXR1cm4gdGhpcy5faXNWaWV3YWJsZSh0aGlzLmZsYWdzKTsKICB9CiAgZ2V0IHByaW50YWJsZSgpIHsKICAgIGlmICh0aGlzLmRhdGEucXVhZFBvaW50cyA9PT0gbnVsbCkgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAodGhpcy5mbGFncyA9PT0gMCkgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICByZXR1cm4gdGhpcy5faXNQcmludGFibGUodGhpcy5mbGFncyk7CiAgfQogIF9wYXJzZVN0cmluZ0hlbHBlcihkYXRhKSB7CiAgICBjb25zdCBzdHIgPSB0eXBlb2YgZGF0YSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRhdGEpIDogIiI7CiAgICBjb25zdCBkaXIgPSBzdHIgJiYgKDAsIF9iaWRpLmJpZGkpKHN0cikuZGlyID09PSAicnRsIiA/ICJydGwiIDogImx0ciI7CiAgICByZXR1cm4gewogICAgICBzdHIsCi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YWcpIHsKICAgIHJldHVybiB0aGlzLl9oYXNGbGFnKHRoaXMuZmxhZ3MsIGZsYWcpOwogIH0KICBzZXRSZWN0YW5nbGUocmVjdGFuZ2xlKSB7CiAgICBpZiAoQXJyYXkuaXNBcnJheShyZWN0YW5nbGUpICYmIHJlY3RhbmdsZS5sZW5ndGggPT09IDQpIHsKICAgICAgdGhpcy5yZWN0YW5nbGUgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QocmVjdGFuZ2xlKTsKICAgIH0gZWxzZSB7CiAgICAgIHRoaXMucmVjdGFuZ2xlID0gWzAsIDAsIDAsIDBdOwogICAgfQogIH0KICBzZXRDb2xvcihjb2xvcikgewogICAgdGhpcy5jb2xvciA9IGdldFJnYkNvbG9yKGNvbG9yKTsKICB9CiAgc2V0TGluZUVuZGluZ3MobGluZUVuZGluZ3MpIHsKICAgIHRoaXMubGluZUVuZGluZ3MgPSBbIk5vbmUiLCAiTm9uZSJdOwogICAgaWYgKEFycmF5LmlzQXJyYXkobGluZUVuZGluZ3MpICYmIGxpbmVFbmRpbmdzLmxlbmd0aCA9PT0gMikgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgIGNvbnN0IG9iaiA9IGxpbmVFbmRpbmdzW2ldOwogICAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBzd2l0Y2ggKG9iai5uYW1lKSB7CiAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBjYXNlICJTcXVhcmUiOgogICAgICAgICAgICBjYXNlICJDaXJjbGUiOgogICAgICAgICAgICBjYXNlICJEaWFtb25kIjoKICAgICAgICAgICAgY2FzZSAiT3BlbkFycm93IjoKICAgICAgICAgICAgY2FzZSAiQ2xvc2VkQXJyb3ciOgogICAgICAgICAgICBjYXNlICJCdXR0IjoKICAgICAgICAgICAgY2FzZSAiUk9wZW5BcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlJDbG9zZWRBcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlNsYXNoIjoKICAgICAgICAgICAgICB0aGlzLmxpbmVFbmRpbmdzW2ldID0gb2JqLm5hbWU7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3JpbmcgaW52YWxpZCBsaW5lRW5kaW5nOiAke29ian1gKTsKICAgICAgfQogICAgfQogIH0KICBzZXRSb3RhdGlvbihtaykgewogICAgdGhpcy5yb3RhdGlvbiA9IDA7CiAgICBpZiAobWsgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGxldCBhbmdsZSA9IG1rLmdldCgiUiIpIHx8IDA7CiAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKGFuZ2xlKSAmJiBhbmdsZSAhPT0gMCkgewogICAgICAgIGFuZ2xlICU9IDM2MDsKICAgICAgICBpZiAoYW5nbGUgPCAwKSB7CiAgICAgICAgICBhbmdsZSArPSAzNjA7CiAgICAgICAgfQogICAgICAgIGlmIChhbmdsZSAlIDkwID09PSAwKSB7CiAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gYW5nbGU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQogIHNldEJvcmRlckFuZEJhY2tncm91bmRDb2xvcnMobWspIHsKICAgIGlmIChtayBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgdGhpcy5ib3JkZXJDb2xvciA9IGdldFJnYkNvbG9yKG1rLmdldEFycmF5KCJCQyIpLCBudWxsKTsKICAgICAgdGhpcy5iYWNrZ3JvdW5kQ29sb3IgPSBnZXRSZ2JDb2xvcihtay5nZXRBcnJheSgiQkciKSwgbnVsbCk7CiAgICB9IGVsc2UgewogICAgICB0aGlzLmJvcmRlckNvbG9yID0gdGhpcy5iYW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ZXQoKTsKICAgIHJldHVybiB7CiAgICAgIG9wTGlzdCwKICAgICAgc2VwYXJhdGVGb3JtOiBmYWxzZSwKICAgICAgc2VwYXJhdGVDYW52YXM6IGlzVXNpbmdPd25DYW52YXMKICAgIH07CiAgfQogIGFzeW5jIHNhdmUoZXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgcmV0dXJuIG51bGw7CiAgfQogIGdldCBoYXNUZXh0Q29udGVudCgpIHsKICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZXh0cmFjdFRleHRDb250ZW50KGV2YWx1YXRvciwgdGFzaywgdmlld0JveCkgewogICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgcmVzb3VyY2VzID0gYXdhaXQgdGhpcy5sb2FkUmVzb3VyY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2JqZWN0Il0sIHRoaXMuYXBwZWFyYW5jZSk7CiAgICBjb25zdCB0ZXh0ID0gW107CiAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgIGNvbnN0IHNpbmsgPSB7CiAgICAgIGRlc2lyZWRTaXplOiBNYXRoLkluZmluaXR5LAogICAgICByZWFkeTogdHJ1ZSwKICAgICAgZW5xdWV1ZShjaHVuaywgc2l6ZSkgewogICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBjaHVuay5pdGVtcykgewogICAgICAgICAgYnVmZmVyLnB1c2goaXRlbS5zdHIpOwogICAgICAgICAgaWYgKGl0ZW0uaGFzRU9MKSB7CiAgICAgICAgICAgIHRleHQucHVzaChidWZmZXIuam9pbigiIikpOwogICAgICAgICAgICBidWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgICBhd2FpdCBldmFsdWF0b3IuZ2V0VGV4dENvbnRlbnQoewogICAgICBzdHJlYW06IHRoaXMuYXBwZWFyYW5jZSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogdHJ1ZSwKICAgICAgY29tYmluZVRleHRJdGVtczogdHJ1ZSwKICAgICAgc2luaywKICAgICAgdmlld0JveAogICAgfSk7CiAgICB0aGlzLnJlc2V0KCk7CiAgICBpZiAoYnVmZmVyLmxlbmd0aCkgewogICAgICB0ZXh0LnB1c2goYnVmZmVyLmpvaW4oIiIpKTsKICAgIH0KICAgIGlmICh0ZXh0Lmxlbmd0aCA+IDApIHsKICAgICAgdGhpcy5kYXRhLnRleHRDb250ZW50ID0gdGV4dDsKICAgIH0KICB9CiAgZ2V0RmllbGRPYmplY3QoKSB7CiAgICBpZiAodGhpcy5kYXRhLmtpZElkcykgewogICAgICByZXR1cm4gewogICAgICAgIGlkOiB0aGlzLmRhdGEuaWQsCiAgICAgICAgYWN0aW9uczogdGhpcy5kYXRhLmFjdGlvbnMsCiAgICAgICAgbmFtZTogdGhpcy5kYXRhLmZpZWxkTmFtZSwKICAgICAgICBzdHJva2VDb2xvcjogdGhpcy5kYXRhLmJvcmRlckNvbG9yLAogICAgICAgIGZpbGxDb2xvcjogdGhpcy5kYXRhLmJhY2tncm91bmRDb2xvciwKICAgICAgICB0eXBlOiAiIiwKICAgICAgICBraWRJZHM6IHRoaXMuZGF0YS5raWRJZHMsCiAgICAgICAgcGFnZTogdGhpcy5kYXRhLnBhZ2VJbmRleCwKICAgICAgICByb3RhdGlvbjogdGhpcy5yb3RhdGlvbgogICAgICB9OwogICAgfQogICAgcmV0dXJuIG51bGw7CiAgfQogIHJlc2V0KCkgewogICAgZm9yIChjb25zdCBzdHJlYW0gb2YgdGhpcy5fc3RyZWFtcykgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgIH0KICB9CiAgX2NvbnN0cnVjdEZpZWxkTmFtZShkaWN0KSB7CiAgICBpZiAoIWRpY3QuaGFzKCJUIikgJiYgIWRpY3Q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3JjZVN0eWxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBmYWxzZTsKICAgIGlmIChBcnJheS5pc0FycmF5KGRhc2hBcnJheSkgJiYgZGFzaEFycmF5Lmxlbmd0aCA+IDApIHsKICAgICAgbGV0IGlzVmFsaWQgPSB0cnVlOwogICAgICBsZXQgYWxsWmVyb3MgPSB0cnVlOwogICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgZGFzaEFycmF5KSB7CiAgICAgICAgY29uc3QgdmFsaWROdW1iZXIgPSArZWxlbWVudCA+PSAwOwogICAgICAgIGlmICghdmFsaWROdW1iZXIpIHsKICAgICAgICAgIGlzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0gZWxzZSBpZiAoZWxlbWVudCA+IDApIHsKICAgICAgICAgIGFsbFplcm9zID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChpc1ZhbGlkICYmICFhbGxaZXJvcykgewogICAgICAgIHRoaXMuZGFzaEFycmF5ID0gZGFzaEFycmF5OwogICAgICAgIGlmIChmb3JjZVN0eWxlKSB7CiAgICAgICAgICB0aGlzLnNldFN0eWxlKF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEIikpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB0aGlzLndpZHRoID0gMDsKICAgICAgfQogICAgfSBlbHNlIGlmIChkYXNoQXJyYXkpIHsKICAgICAgdGhpcy53aWR0aCA9IDA7CiAgICB9CiAgfQogIHNldEhvcml6b250YWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMuaG9yaXpvbnRhbENvcm5lclJhZGl1cyA9IHJhZGl1czsKICAgIH0KICB9CiAgc2V0VmVydGljYWxDb3JuZXJSY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JhZ2UpOwogICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgdmFsdWUgPSB0aGlzLmRhdGEuZmllbGRWYWx1ZTsKICAgICAgaWYgKCF2YWx1ZSkgewogICAgICAgIHJldHVybiBgL1R4IEJNQyBxICR7Y29sb3JzfVEgRU1DYDsKICAgICAgfQogICAgfQogICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCA9PT0gMSkgewogICAgICB2YWx1ZSA9IHZhbHVlWzBdOwogICAgfQogICAgKDAsIF91dGlsLmFzc2VydCkodHlwZW9mIHZhbHVlID09PSAic3RyaW5nIiwgIkV4cGVjdGVkIGB2YWx1ZWAgdG8gYmUgYSBzdHJpbmcuIik7CiAgICB2YWx1ZSA9IHZhbHVlLnRyaW0oKTsKICAgIGlmICh0aGlzLmRhdGEuY29tYm8pIHsKICAgICAgY29uc3Qgb3B0aW9uID0gdGhpcy5kYXRhLm9wdGlvbnMuZmluZChfcmVmMyA9PiB7CiAgICAgICAgbGV0IHsKICAgICAgICAgIGV4cG9ydFZhbHVlCiAgICAgICAgfSA9IF9yZWYzOwogICAgICAgIHJldHVybiB2YWx1ZSA9PT0gZXhwb3J0VmFsdWU7CiAgICAgIH0pOwogICAgICB2YWx1ZSA9IG9wdGlvbiAmJiBvcHRpb24uZGlzcGxheVZhbHVlIHx8IHZhbHVlOwogICAgfQogICAgaWYgKHZhbHVlID09PSAiIikgewogICAgICByZXR1cm4gYC9UeCBCTUMgcSAke2NvbG9yc31RIEVNQ2A7CiAgICB9CiAgICBpZiAocm90YXRpb24gPT09IHVuZGVmaW5lZCkgewogICAgICByb3RhdGlvbiA9IHRoaXMucm90YXRpb247CiAgICB9CiAgICBsZXQgbGluZUNvdW50ID0gLTE7CiAgICBsZXQgbGluZXM7CiAgICBpZiAodGhpcy5kYXRhLm11bHRpTGluZSkgewogICAgICBsaW5lcyA9IHZhbHVlLnNwbGl0KC9cclxuP3xcbi8pLm1hc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W5lcyA9IFtdOwogICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBsaW5lcykgewogICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGZvbnQuZW5jb2RlU3RyaW5nKGxpbmUpLmpvaW4oIiIpOwogICAgICAgICAgY29uc3QgZ2x5cGhzID0gZm9udC5jaGFyc1RvR2x5cGhzKGVuY29kZWQpOwogICAgICAgICAgY29uc3QgcG9zaXRpb25zID0gZm9udC5nZXRDaGFyUG9zaXRpb25zKGVuY29kZWQpOwogICAgICAgICAgY2FjaGVkTGluZXMucHVzaCh7CiAgICAgICAgICAgIGxpbmU6IGVuY29kZWQsCiAgICAgICAgICAgIGdseXBocywKICAgICAgICAgICAgcG9zaXRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXNUb29CaWcgPSBmc2l6ZSA9PiB7CiAgICAgICAgICBsZXQgdG90YWxIZWlnaHQgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiBjYWNoZWRMaW5lcykgewogICAgICAgICAgICBjb25zdCBjaHVua3MgPSB0aGlzLl9zcGxpdExpbmUobnVsbCwgZm9udCwgZnNpemUsIHdpZHRoLCBjYWNoZSk7CiAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IGNodW5rcy5sZW5ndGggKiBmc2l6ZTsKICAgICAgICAgICAgaWYgKHRvdGFsSGVpZ2h0ID4gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9OwogICAgICAgIG51bWJlck9mTGluZXMgPSBNYXRoLm1heChudW1iZXJPZkxpbmVzLCBsaW5lQ291bnQpOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBsaW5lSGVpZ2h0ID0gaGVpZ2h0IC8gbnVtYmVyT2ZMaW5lczsKICAgICAgICAgIGZvbnRTaXplID0gcm91bmRXaXRoVHdvRGlnaXRzKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUik7CiAgICAgICAgICBpZiAoaXNUb29CaWcoZm9udFNpemUpKSB7CiAgICAgICAgICAgIG51bWJlck9mTGluZXMrKzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9ID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YTsKICAgICAgdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UgPSAoMCwgX2RlZmF1bHRfYXBwZWFyYW5jZS5jcmVhdGVEZWZhdWx0QXBwZWFyYW5jZSkoewogICAgICAgIGZvbnRTaXplLAogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9KTsKICAgIH0KICAgIHJldHVybiBbdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UsIGZvbnRTaXplLCBoZWlnaHQgLyBudW1iZXJPZkxpbmVzXTsKICB9CiAgX3JlbmRlclRleHQodGV4dCwgZm9udCwgZm9udFNpemUsIHRvdGFsV2lkdGgsIGFsaWdubWVudCwgcHJldkluZm8sIGhQYWRkaW5nLCB2UGFkZGluZykgewogICAgbGV0IHNoaWZ0OwogICAgaWYgKGFsaWdubWVudCA9PT0gMSkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMuX2dldFRleHRXaWR0aCh0ZXh0LCBmb250KSAqIGZvbnRTaXplOwogICAgICBzaGlmdCA9ICh0b3RhbFdpZHRoIC0gd2lkdGgpIC8gMjsKICAgIH0gZWxzZSBpZiAoYWxpZ25tZW50ID09PSAyKSB7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy5fZ2V0VGV4dFdpZHRoKHRleHQsIGZvbnQpICogZm9udFNpemU7CiAgICAgIHNoaWZ0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gIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY3VycmVudFdpZHRoICsgZ2x5cGhXaWR0aCA+IHdpZHRoKSB7CiAgICAgICAgICBpZiAobGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCAhPT0gLTEpIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IGxhc3RTcGFjZVBvc0luU3RyaW5nRW5kOwogICAgICAgICAgICBpID0gbGFzdFNwYWNlUG9zICsgMTsKICAgICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgc3RhcnQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IHN0YXJ0OwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSBnbHlwaFdpZHRoOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50V2lkdGggKz0gZ2x5cGhXaWR0aDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChzdGFydENodW5rIDwgbGluZS5sZW5ndGgpIHsKICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGluZS5sZW5ndGgpKTsKICAgIH0KICAgIHJldHVybiBjaHVua3M7CiAgfQogIGdldEZpZWxkT2JqZWN0KCkgewogICAgcmV0dXJuIHsKICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlLAogICAgICBkZWZhdWx0VmFsdWU6IHRoaXMuZGF0YS5kZWZhdWx0Rm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09IDAgJiYgIWZpbGxDb2xvcikgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBjb250cm9sUG9pbnRzRGlzdGFuY2UgPSA0IC8gMyAqIE1hdGgudGFuKE1hdGguUEkgLyAoMiAqIDQpKTsKICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke3RoaXMuYm9yZGVyU3R5bGUud2lkdGh9IHdgLAogICAgICAgIHN0cm9rZUNvbG9yLAogICAgICAgIGZpbGxDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBmaWxsQWxwaGEsCiAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgY29uc3QgeDAgPSBwb2ludHNbMF0ueCArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeTAgPSBwb2ludHNbMF0ueSAtIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeDEgPSBwb2ludHNbM10ueCAtIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeTEgPSBwb2ludHNbM10ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeE1pZCA9IHgwICsgKHgxIC0geDApIC8gMjsKICAgICAgICAgIGNvbnN0IHlNaWQgPSB5MCArICh5MSAtIHkwKSAvIDI7CiAgICAgICAgICBjb25zdCB4T2Zmc2V0ID0gKHgxIC0geDApIC8gMiAqIGNvbnRyb2xQb2ludHNEaXN0YW5jZTsKICAgICAgICAgIGNvbnN0IHlPZmZzZXQgPSAoeTEgLSB5MCkgLyAyICogY29udHJvbFBvaW50c0Rpc3RhbmNlOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eE1pZH0gJHt5MX0gbWAsIGAke3hNaW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QWRqdXN0KTsKICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgIGJib3hbM10gPSBNYXRoLm1heChiYm94WzNdLCB2ZXJ0ZXgueSArIGJvcmRlckFkanVzdCk7CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB2ZXJ0aWNlcyA9IHRoaXMuZGF0YS52ZXJ0aWNlczsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHZlcnRpY2VzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7dmVydGljZXNbaV0ueH0gJHt2ZXJ0aWNlc1tpXS55fSAke2kgPT09IDAgPyAibSIgOiAibCJ9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9Cn0KY2xhc3MgUG9seWdvbkFubm90YXRpb24gZXh0ZW5kcyBQb2x5bGluZUFubm90YXRpb24gewogIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgc3VwZXIocGFyYW1zKTsKICAgIHRoaXM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9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBmb3IgKGNvbnN0IGlua0xpc3Qgb2YgdGhpcy5kYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGlua0xpc3QubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke2lua0xpc3RbaV0ueH0gJHtpbmtMaXN0W2ldLnl9ICR7aSA9PT0gMCA/ICJtIiA6ICJsIn1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9CiAgc3RhdGljIGNyZWF0ZU5ld0RpY3QoYW5ub3RhdGlvbiwgeHJlZiwgX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIGFwUmVmLAogICAgICBhcAogICAgfSA9IF9yZWY1OwogICAgY29uc3QgewogICAgICBwYXRocywKICAgICAgcmVjdCwKICAgICAgcm90YXRpb24KICAgIH0gPSBhbm5vdGF0aW9uOwogICAgY29uc3QgaW5rID0gbmV3IF9wcmltaXRpdmVzLkRpY3QoeHJlZik7CiAgICBpbmsuc2V0KCJUeXBlIiwgX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkFubm90IikpOwogICAgaW5rLnNldCgiU3VidHlwZSIsIF9wcmltaXRpdmVzLk5hbWUuZ2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pOwogICAgICAgIHRoaXMuX3NldERlZmF1bHRBcHBlYXJhbmNlKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBleHRyYTogIltdIDAgZCAxIHciLAogICAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICAgIHBvaW50c0NhbGxiYWNrOiAoYnVmZmVyLCBwb2ludHMpID0+IHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7cG9pbnRzWzJdLnh9ICR7cG9pbnRzWzJdLnl9IG1gLCBgJHtwb2ludHNbM10ueH0gJHtwb2ludHNbM10ueX0gbGAsICJTIik7CiAgICAgICAgICAgIHJldHVybiBbcG9pbnRzWzBdLngsIHBvaW50c1sxXS54LCBwb2ludHNbM10ueSwgcG9pbnRzWzFdLnldOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmRhdGEuaGFzUG9wdXAgPSBmYWxzZTsKICAgIH0KICB9Cn0KY2xhc3MgU3F1aWdnbHlBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk7CiAgICBjb25zdCBxdWFkUG9pbnRzID0gdGhpcy5kYXRhLnF1YWRQb2ludHMgPSBnZXRRdWFkUG9pbnRzKGRpY3QsIG51bGwpOwogICAgaWYgKHF1YWRQb2ludHMpIHsKICAgICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgICAgeHJlZiwKICAgICAgICAgIGV4dHJhOiAiW10gMCBkIDEgdyIsCiAgICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgICBjb25zdCBkeSA9IChwb2ludHNbMF0ueSAtIHBvaW50c1syXS55KSAvIDY7CiAgICAgICAgICAgIGxldCBzaGlmdCA9IGR5OwogICAgICAgICAgICBsZXQgeCA9IHBvaW50c1syXS54OwogICAgICAgICAgICBjb25zdCB5ID0gcG9pbnRzWzJdLnk7CiAgICAgICAgICAgIGNvbnN0IHhFbmQgPSBwb2ludHNbM10ueDsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5ICsgc2hpZnR9IG1gKTsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIHggKz0gMjsKICAgICAgICAgICAgICBzaGlmdCA9IHNoaWZ0ID09PSAwID8gZHkgOiAwOwogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke3h9ICR7eSArIHNoaWZ0fSBsYCk7CiAgICAgICAgICAgIH0gd2hpbGUgKHggPCB4RW5kKTsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIlMiKTsKICAgICAgICAgICAgcmV0dXJuIFtwb2ludHNbMl0ueCwgeEVuZCwgeSAtIDIgKiBkeSwgeSArIDIgKiBkeV07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIHRoaXMuZGF0YS5oYXNQb3B1cCA9IGZhbHNlOwogICAgfQogIH0KfQpjbGFzcyBTdHJpa2VPdXRBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW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jogMCwKICAgICAgYXJnczogW10KICAgIH07CiAgICBjb25zdCByZXN1bHQgPSB7CiAgICAgIGZvbnRTaXplOiAwLAogICAgICBmb250TmFtZTogIiIsCiAgICAgIGZvbnRDb2xvcjogbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KDMpCiAgICB9OwogICAgdHJ5IHsKICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICBvcGVyYXRpb24uYXJncy5sZW5ndGggPSAwOwogICAgICAgIGlmICghdGhpcy5yZWFkKG9wZXJhdGlvbikpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5zYXZlZFN0YXRlc0RlcHRoICE9PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgewogICAgICAgICAgZm4sCiAgICAgICAgICBhcmdzCiAgICAgICAgfSA9IG9wZXJhdGlvbjsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgY29uc3QgW2ZvbnROYW1lLCBmb250U2l6ZV0gPSBhcmdzOwogICAgICAgICAgICBpZiAoZm9udE5hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgcmVzdWx0LmZvbnROYW1lID0gZm9udE5hbWUubmFtZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIGZvbnRTaXplID09PSAibnVtYmVyIiAmJiBmb250U2l6ZSA+IDApIHsKICAgICAgICAgICAgICByZXN1bHQuZm9udFNpemUgPSBmb250U2l6ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYi5nZXRSZ2JJdGVtK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PSBNYXRoLmNlaWwobWV0cmljcy53aWR0aCk7CiAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNvZGUsIHdpZHRoKTsKICAgICAgICB0aGlzLmZpcnN0Q2hhciA9IE1hdGgubWluKGNvZGUsIHRoaXMuZmlyc3RDaGFyKTsKICAgICAgICB0aGlzLmxhc3RDaGFyID0gTWF0aC5tYXgoY29kZSwgdGhpcy5sYXN0Q2hhcik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlczsKICB9CiAgY3JlYXRlQXBwZWFyYW5jZSh0ZXh0LCByZWN0LCByb3RhdGlvbiwgZm9udFNpemUsIGJnQ29sb3IsIHN0cm9rZUFscGhhKSB7CiAgICBjb25zdCBjdHggPSB0aGlzLl9jcmVhdGVDb250ZXh0KCk7CiAgICBjb25zdCBsaW5lcyA9IFtdOwogICAgbGV0IG1heFdpZHRoID0gLUluZmluaXR5OwogICAgZm9yIChjb25zdCBsaW5lIG9mIHRleHQuc3BsaXQoL1xyXG4/fFxuLykpIHsKICAgICAgbGluZXMucHVzaChsaW5lKTsKICAgICAgY29uc3QgbGluZVdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGxpbmUpLndpZHRoOwogICAgICBtYXhXaWR0aCA9IE1hdGgubWF4KG1heFdpZHRoLCBsaW5lV2lkdGgpOwogICAgICBmb3IgKGNvbnN0IGNoYXIgb2YgbGluZS5zcGxpdCgiIikpIHsKICAgICAgICBjb25zdCBjb2RlID0gY2hhci5jaGFyQ29kZUF0KDApOwogICAgICAgIGxldCB3aWR0aCA9IHRoaXMud2lkdGhzLmdldChjb2RlKTsKICAgICAgICBpZiAod2lkdGggPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IGN0eC5tZWFzdXJlVGV4dChjaGFyKTsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKG1ldHJpY3Mud2lkdGgpOwogICAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNv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XZpY2VSR0IiKSB7CiAgICAgIGNvbnN0IGFsbENvbG9ycyA9IGJwYyA8PSA4ID8gbmV3IFVpbnQ4QXJyYXkobnVtQ29tcG9uZW50Q29sb3JzKSA6IG5ldyBVaW50MTZBcnJheShudW1Db21wb25lbnRDb2xvcnMpOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG51bUNvbXBvbmVudENvbG9yczsgaSsrKSB7CiAgICAgICAgYWxsQ29sb3JzW2ldID0gaTsKICAgICAgfQogICAgICBjb25zdCBjb2xvck1hcCA9IG5ldyBVaW50OENsYW1wZWRBcnJheShudW1Db21wb25lbnRDb2xvcnMgKiAzKTsKICAgICAgdGhpcy5nZXRSZ2JCdWZmZXIoYWxsQ29sb3JzLCAwLCBudW1Db21wb25lbnRDb2xvcnMsIGNvbG9yTWFwLCAwLCBicGMsIDApOwogICAgICBpZiAoIW5lZWRzUmVzaXppbmcpIHsKICAgICAgICBsZXQgZGVzdFBvcyA9IDA7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgKytpKSB7CiAgICAgICAgICBjb25zdCBrZXkgPSBjb21wc1tpXSAqIDM7CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gY29sb3JNYXBba2V5ICsgMV07CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXkgKyAyXTsKICAgICAgICAgIGRlc3RQb3MgKz0gYWxwaGEwMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmdiQnVmID0gbmV3IFVpbnQ4QXJyYXkoY291bnQgKiAzKTsKICAgICAgICBsZXQgcmdiUG9zID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgICAgIGNvbnN0IGtleSA9IGNvbXBzW2ldICogMzsKICAgICAgICAgIHJnYkJ1ZltyZ2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fcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXJzZShyZXNvdXJjZXNDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3MgPSByZXNvdXJjZXNDUzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnJlY29nbml6ZWQgQ29sb3JTcGFjZTogJHtjcy5uYW1lfWApOwogICAgICB9CiAgICB9CiAgICBpZiAoQXJyYXkuaXNBcnJheShjcykpIHsKICAgICAgY29uc3QgbW9kZSA9IHhyZWYuZmV0Y2hJZlJlZihjc1swXSkubmFtZTsKICAgICAgbGV0IHBhcmFtcywgbnVtQ29tcHMsIGJhc2VDUywgd2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWE7CiAgICAgIHN3aXRjaCAobW9kZSkgewogICAgICAgIGNhc2UgIkciOgogICAgICAgIGNhc2UgIkRldmljZUdyYXkiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5ncmF5OwogICAgICAgIGNhc2UgIlJHQiI6CiAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgIGNhc2UgIkNNWUsiOgogICAgICAgIGNhc2UgIkRldmljZUNNWUsiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5jbXlrOwogICAgICAgIGNhc2UgIkNhbEdyYXkiOgogICAgICAgICAgcGFyYW1zID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIHdoaXRlUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIldoaXRlUG9pbnQiKTsK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ICAgICAgICAgICAgIHJldHVybiBhbHRDUzsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIklDQ0Jhc2VkIGNvbG9yIHNwYWNlOiBJZ25vcmluZyBpbmNvcnJlY3QgL0FsdGVybmF0ZSBlbnRyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChudW1Db21wcyA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUNvbXBzID09PSAzKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgICAgfSBlbHNlIGlmIChudW1Db21wcyA9PT0gNCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmNteWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgIGJhc2VDUyA9IGNzWzFdIHx8IG51bGw7CiAgICAgICAgICBpZiAoYmFzZUNTKSB7CiAgICAgICAgICAgIGJhc2VDUyA9IHRoaXMuX3BhcnNlKGJhc2VDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBQYXR0ZXJuQ1MoYmFzZUNTKTsKICAgICAgICBjYXNlICJJIjoKICAgICAgICBjYXNlICJJbmRleGVkIjoKICAgICAgICAgIGJhc2VDUyA9IHRoaXMuX3BhcnNlKGNzWzFdLCB4cmVmLCByZXNvdXJjZXMsIHBkZkZ1bmN0aW9uRmFjdG9yeSk7CiAgICAgICAgICBjb25zdCBoaVZhbCA9IHhyZWYuZmV0Y2hJZlJlZihjc1syXSkgKyAxOwogICAgICAgICAgY29uc3QgbG9va3VwID0geHJlZi5mZXRjaElmUmVmKGNzWzNdKTsKICAgICAgICAgIHJldHVybiBuZXcgSW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YWNlIG9iamVjdDogJHtjc31gKTsKICB9CiAgc3RhdGljIGlzRGVmYXVsdERlY29kZShkZWNvZGUsIG51bUNvbXBzKSB7CiAgICBpZiAoIUFycmF5LmlzQXJyYXkoZGVjb2RlKSkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmIChudW1Db21wcyAqIDIgIT09IGRlY29kZS5sZW5ndGgpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJUaGUgZGVjb2RlIG1hcCBpcyBub3QgdGhlIGNvcnJlY3QgbGVuZ3RoIik7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGVjb2RlLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgaWYgKGRlY29kZVtpXSAhPT0gMCB8fCBkZWNvZGVbaSArIDFdICE9PSAxKSB7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgc3RhdGljIGdldCBzaW5nbGV0b25zKCkgewogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJzaW5nbGV0b25zIiwgewogICAgICBnZXQgZ3JheSgpIHsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImdyYXkiLCBuZXcgRGV2aWNlR3JheUNTKCkpOwogICAgICB9LAogICAgICBnZXQgcmdiKCkgewogICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAicmdiIiwgbmV3IERldmljZVJnYkNTKCkpOwogICAgICB9LAogICAgICBnZXQgY215aygpIHsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImNteWsiLCBuZXcgRGV2aWNlQ215a0NTKCkpOwogICAgICB9CiAgICB9KTsKICB9Cn0KZXhwb3J0cy5Db2xvclNwYWNlID0gQ29sb3JTcGFjZTsKY2xhc3MgQWx0ZXJuY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bCBvZiB2YWx1ZSkgewogICAgICBjb25zdCBtYXliZUJNID0gbm9ybWFsaXplQmxlbmRNb2RlKHZhbCwgdHJ1ZSk7CiAgICAgIGlmIChtYXliZUJNKSB7CiAgICAgICAgcmV0dXJuIG1heWJlQk07CiAgICAgIH0KICAgIH0KICAgICgwLCBfdXRpbC53YXJuKShgVW5zdXBwb3J0ZWQgYmxlbmQgbW9kZSBBcnJheTogJHt2YWx1ZX1gKTsKICAgIHJldHVybiAic291cmNlLW92ZXIiOwogIH0KICBpZiAoISh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpKSB7CiAgICBpZiAocGFyc2luZ0FycmF5KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgcmV0dXJuICJzb3VyY2Utb3ZlciI7CiAgfQogIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgY2FzZSAiTm9ybWFsIjoKICAgIGNhc2UgIkNvbXBhdGlibGUiOgogICAgICByZXR1cm4gInNvdXJjZS1vdmVyIjsKICAgIGNhc2UgIk11bHRpcGx5IjoKICAgICAgcmV0dXJuICJtdWx0aXBseSI7CiAgICBjYXNlICJTY3JlZW4iOgogICAgICByZXR1cm4gInNjcmVlbiI7CiAgICBjYXNlICJPdmVybGF5IjoKICAgICAgcmV0dXJuICJvdmVybGF5IjsKICAgIGNhc2UgIkRhcmtlbiI6CiAgICAgIHJldHVybiAiZGFya2VuIjsKICAgIGNhc2UgIkxpZ2h0ZW4iOgogICAgICByZXR1cm4gImxpZ2h0ZW4iOwogICAgY2FzZSAiQ29sb3JEb2RnZSI6CiAgICAgIHJldHVybiAiY29sb3ItZG9kZ2UiOwogICAgY2FzZSAiQ29sb3JCdXJuIjoKICAgICAgcmV0dXJuICJjb2xvci1idXJuIjsKICAgIGNhc2UgIkhhcmRMaWdodCI6CiAgICAgIHJldHVybiAiaGFyZC1saWdodCI7CiAgICBjYXNlICJTb2Z0TGlnaHQiOgogICAgICByZXR1cm4gInNvZnQt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gPSB4cmVmLmZldGNoKGdyYXBoaWNTdGF0ZSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgcHJvY2Vzc2VkLnB1dChncmFwaGljU3RhdGUpOwogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIEV4dEdTdGF0ZTogIiR7ZXh9Ii5gKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCEoZ3JhcGhpY1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZ3JhcGhpY1N0YXRlLm9iaklkKSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoZ3JhcGhpY1N0YXRlLm9iaklkKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGJtID0gZ3JhcGhpY1N0YXRlLmdldCgiQk0iKTsKICAgICAgICAgIGlmIChibSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgaWYgKGJtLm5hbWUgIT09ICJOb3JtYWwiKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYm0gIT09IHVuZGVmaW5lZCAmJiBBcnJheS5pc0FycmF5KGJtKSkgewogICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgYm0pIHsKICAgICAgICAgICAgICBpZiAoZWxlbWVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUgJiYgZWxlbWVudC5uYW1lICE9PSAiTm9ybWFsIikgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHhPYmplY3RzID0gbm9kZS5nZXQoIlhPYmplY3QiKTsKICAgICAgaWYgKCEoeE9iamVjdHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IHhPYmplY3Qgb2YgeE9iamVjdHMuZ2V0UmF3VmFsdWVzKCkpIHsKICAgICAgICBpZiAoeE9iamVjdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaWYgKHByb2Nlc3NlZC5oYXMoeE9iamVjdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cnkgewogICAgICAgICAgICB4T2JqZWN0ID0geHJlZi5mZXRjaCh4T2JqZWN0KTsKICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeE9iamVjdCk7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoISh4T2JqZWN0IGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhPYmplY3QuZGljdC5vYmpJZCkgewogICAgICAgICAgcHJvY2Vzc2VkLnB1dCh4T2JqZWN0LmRpY3Qub2JqSWQpOwogICAgICAgIH0KICAgICAgICBjb25zdCB4UmVzb3VyY2VzID0geE9iamVjdC5kaWN0LmdldCgiUmVzb3VyY2VzIik7CiAgICAgICAgaWYgKCEoeFJlc291cmNlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQgJiYgcHJvY2Vzc2VkLmhhcyh4UmVzb3VyY2VzLm9iaklkKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5vZGVzLnB1c2goeFJlc291cmNlcyk7CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQpIHsKICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeFJlc291cmNlcy5vYmpJZCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IHJlZiBvZiBwcm9jZXNzZWQpIHsKICAgICAgbm9uQmxlbmRNb2Rlc1NldC5wdXQocmVmKTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZmV0Y2hCdWlsdEluQ01hcChuYW1lKSB7CiAgICBjb25zdCBjYWNoZWREYXRhID0gdGhpcy5idWlsdEluQ01hcENhY2hlLmdldChuYW1lKTsKICAgIGlmIChjYWNoZWREYXRhKSB7CiAgICAgIHJldHVybiBjYWNoZWREYXRhOwogICAgfQogICAgbGV0IGRhdGE7CiAgICBpZiAodGhpcy5vcHRpb25zLmNNYXBVcmwgIT09IG51bGwpIHsKICAgICAgY29uc3QgdXJsID0gYCR7dGhpcy5vcHRpb25zLmNNYXBVcmx9JHtuYW1lfS5iY21hcGA7CiAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsKTsKICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgIHRocm93IG5ldyBFcnJvcihgZmV0Y2hCdWlsdEluQ01hcDogZmFpbGVkIHRvIGZldGNoIGZpbGUgIiR7dXJsfSIgd2l0aCAiJHtyZXNwb25zZS5zdGF0dXNUZXh0fSIuYCk7CiAgICAgIH0KICAgICAgZGF0YSA9IHsKICAgICAgICBjTWFwRGF0YTogbmV3IFVpbnQ4QX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3BhcXVlUGl4ZWwpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkSW1hZ2VPcHMoX3V0aWwuT1BTLnBhaW50U29saWRDb2xvckltYWdlTWFzaywgW10sIG9wdGlvbmFsQ29udGVudCk7CiAgICAgICAgaWYgKGNhY2hlS2V5KSB7CiAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUuc2V0KGNhY2hlS2V5LCBpbWFnZVJlZiwgewogICAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50U29saWRDb2xvckltYWdlTWFzaywKICAgICAgICAgICAgYXJnczogW10sCiAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBvYmpJZCA9IGBtYXNrXyR7dGhpcy5pZEZhY3RvcnkuY3JlYXRlT2JqSWQoKX1gOwogICAgICBvcGVyYXRvckxpc3QuYWRkRGVwZW5kZW5jeShvYmpJZCk7CiAgICAgIHRoaXMuX3NlbmRJbWdEYXRhKG9iaklkLCBpbWdEYXRhKTsKICAgICAgYXJncyA9IFt7CiAgICAgICAgZGF0YTogb2JqSWQsCiAgICAgICAgd2lkdGg6IGltZ0RhdGEud2lkdGgsCiAgICAgICAgaGVpZ2h0OiBpbWdEYXRhLmhlaWdodCwKICAgICAgICBpbnRlcnBvbGF0ZTogaW1nRGF0YS5pbnRlcnBvbGF0ZSwKICAgICAgICBjb3VudDogMQogICAgICB9XTsKICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKF91dGlsLk9QUy5wYWludEltYWdlTWFza1hPYmplY3QsIGFyZ3MsIG9wdGlvbmFsQ29udGVudCk7CiAgICAgIGlmIChjYWNoZUtleSkgewogICAgICAgIGxvY2FsSW1hZ2VDYWNoZS5zZXQoY2FjaGVLZXksIGltYWdlUmVmLCB7CiAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50SW1hZ2VNYXNrWE9iamVjdCwKICA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YWs7CiAgICAgICAgY2FzZSAiTFciOgogICAgICAgIGNhc2UgIkxDIjoKICAgICAgICBjYXNlICJMSiI6CiAgICAgICAgY2FzZSAiTUwiOgogICAgICAgIGNhc2UgIkQiOgogICAgICAgIGNhc2UgIlJJIjoKICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHZhbHVlXSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgIGlzU2ltcGxlR1N0YXRlID0gZmFsc2U7CiAgICAgICAgICBwcm9taXNlID0gcHJvbWlzZS50aGVuKCgpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIG51bGwsIHZhbHVlWzBdLCBvcGVyYXRvckxpc3QsIHRhc2ssIHN0YXRlTWFuYWdlci5zdGF0ZSkudGhlbihmdW5jdGlvbiAobG9hZGVkTmFtZSkgewogICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGxvYWRlZE5hbWUpOwogICAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIFtsb2FkZWROYW1lLCB2YWx1ZVsxXV1dKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJNIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIG5vcm1hbGl6ZUJsZW5kTW9kZSh2YWx1ZSldKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlNNYXNrIjoKICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh2YWx1ZSwgIk5vbmUiKSkgewogICAgICAgICAgICBnU3RhdGVPYmoucHVzaChba2V5LCBmYWxzZV0pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgaXNTaW1wbGVHU3RhdGUgPSBmYWxzZTsKICAgICAgICAgICAgcHJvbWlzZSA9IHByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU01hc2sodmFsdWUsIHJlc291cmNlcywgb3BlcmF0b3JMaXN0LCB0YXNrLCBzdGF0ZU1hbmFnZXIsIGxvY2FsQ29sb3JTcGFjZUNhY2hlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRydWVdKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5zdXBwb3J0ZWQgU01hc2sgdHlwZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiVFIiOgogICAgICAgICAgY29uc3QgdHJhbnNmZXJNYXBzID0gdGhpcy5oYW5kbGVUcmFuc2ZlckZ1bmN0aW9uKHZhbHVlKTsKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRyYW5zZmVyTWFwc10pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT1AiOgogICAgICAgIGNhc2UgIm9wIjoKICAgICAgICBjYXNlICJPUE0iOgogICAgICAgIGNhc2UgIkJHIjoKICAgICAgICBjYXNlICJCRzIiOgogICAgICAgIGNhc2UgIlVDUiI6CiAgICAgICAgY2FzZSAiVUNSMiI6CiAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgY2FzZSAiU00iOgogICAgICAgIGNhc2UgIlNBIjoKICAgICAgICBjYXNlICJBSVMiOgogICAgICAgIGNhc2UgIlRLIjoKICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiZ3J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ICAgICAgICBkaWN0OiBmb250LAogICAgICAgIGV2YWx1YXRvck9wdGlvbnM6IHRoaXMub3B0aW9ucwogICAgICB9KTsKICAgIH07CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGZvbnRSZWY7CiAgICBpZiAoZm9udCkgewogICAgICBpZiAoZm9udCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGZvbnRSZWYgPSBmb250OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmb250UmVzID0gcmVzb3VyY2VzLmdldCgiRm9udCIpOwogICAgICBpZiAoZm9udFJlcykgewogICAgICAgIGZvbnRSZWYgPSBmb250UmVzLmdldFJhdyhmb250TmFtZSk7CiAgICAgIH0KICAgIH0KICAgIGlmICghZm9udFJlZikgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gYEZvbnQgIiR7Zm9udE5hbWUgfHwgZm9udCAmJiBmb250LnRvU3RyaW5nKCl9IiBpcyBub3QgYXZhaWxhYmxlYDsKICAgICAgaWYgKCF0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzICYmICF0aGlzLnBhcnNpbmdUeXBlM0ZvbnQpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7cGFydGlhbE1zZ30uYCk7CiAgICAgICAgcmV0dXJuIGVycm9yRm9udCgpOwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKShgJHtwYXJ0aWFsTXNnfSAtLSBhdHRlbXB0aW5nIHRvIGZhbGxiYWNrIHRvIGEgZGVmYXVsdCBmb250LmApOwogICAgICBpZiAoZmFsbGJhY2tGb250RGljdCkgewogICAgICAgIGZvbnRSZWYgPSBmYWxsYmFja0ZvbnREaWN0OwogICAgICB9IGVsc2UgewogICAgICAgIGZvbnRSZWYgPSBQYXJ0aWFsRXZhbHVhdG9yLmZhbGxiYWNrRm9udERpY3Q7CiAgICAgIH0KICAgIH0KICAgIGlmICh0aGlzLnBhcnNpbmdUeX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IGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heCA9IFtNYXRoLm1pbihhcmdzWzBdLCB4KSwgTWF0aC5tYXgoYXJnc1swXSwgeCksIE1hdGgubWluKGFyZ3NbMV0sIHkpLCBNYXRoLm1heChhcmdzWzFdLCB5KV07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4ID0gW2FyZ3NbMF0sIGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMV1dOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIG1pbk1heCA9IFtJbmZpbml0eSwgLUluZmluaXR5LCBJbmZpbml0eSwgLUluZmluaXR5XTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuY29uc3RydWN0UGF0aCwgW1tmbl0sIGFyZ3MsIG1pbk1heF0pOwogICAgICBpZiAocGFyc2luZ1RleHQpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnJlc3RvcmUsIG51bGwpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBvcEFyZ3MgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5W2xhc3RJbmRleF07CiAgICAgIG9wQXJnc1swXS5wdXNoKGZuKTsKICAgICAgb3BBcmdzWzFdLnB1c2goLi4uYXJncyk7CiAgICAgIGNvbnN0IG1pbk1heCA9IG9wQXJnc1syXTsKICAgICAgc3dpdGNoIChmbikgewogICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgIGNvbnN0IHggPSBhcmdzWzBdICsgYXJnc1syXTsKICAgICAgICAgIGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heFswXSA9IE1hdGgubWluKG1pbk1heFswXSwgYXJnc1swXSwgeCk7CiAgICAgICAgICBtaW5NYXhbMV0gPSBNYXRoLm1heChtaW5NYXhbMV0sIGFyZ3NbMF0sIHgpOwogICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBhcmdzWzFdLCB5KTsKICAgICAgICAgIG1pbk1heFszXSA9IE1hdGgubWF4KG1pbk1heFszXSwgYXJnc1sxXSwgeSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4WzBdID0gTWF0aC5taW4obWluTWF4WzBdLCBhcmdzWzBdKTsKICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYXJnc1swXSk7CiAgICAgICAgICBtaW5NYXhbMl0gPSBNYXRoLm1pbihtaW5NYXhbMl0sIGFyZ3NbMV0pOwogICAgICAgICAgbWluTWF4WzNdID0gTWF0aC5tYXgobWluTWF4WzNdLCBhcmdzWzFdKTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlQ29sb3JTcGFjZShfcmVmNCkgewogICAgbGV0IHsKICAgICAgY3MsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmNDsKICAgIHJldHVybiBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlQXN5bmMoewogICAgICBjcywKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICByZXNvdXJjZXMsCiAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeTogdGhpcy5fcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgK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ICByZXR1cm47CiAgICB9CiAgICBzd2l0Y2ggKG9wZXJhdG9yLm5hbWUpIHsKICAgICAgY2FzZSAiQW5kIjoKICAgICAgY2FzZSAiT3IiOgogICAgICBjYXNlICJOb3QiOgogICAgICAgIGN1cnJlbnRSZXN1bHQucHVzaChvcGVyYXRvci5uYW1lKTsKICAgICAgICBicmVhazsKICAgICAgZGVmYXVsdDoKICAgICAgICAoMCwgX3V0aWwud2FybikoYEludmFsaWQgb3BlcmF0b3IgJHtvcGVyYXRvci5uYW1lfSBpbiB2aXNpYmlsaXR5IGV4cHJlc3Npb25gKTsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGxldCBpID0gMTsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIGNvbnN0IHJhdyA9IGFycmF5W2ldOwogICAgICBjb25zdCBvYmplY3QgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZihyYXcpOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmplY3QpKSB7CiAgICAgICAgY29uc3QgbmVzdGVkUmVzdWx0ID0gW107CiAgICAgICAgY3VycmVudFJlc3VsdC5wdXNoKG5lc3RlZFJlc3VsdCk7CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihvYmplY3QsIG5lc3RpbmdDb3VudGVyLCBuZXN0ZWRSZXN1bHQpOwogICAgICB9IGVsc2UgaWYgKHJhdyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGN1cnJlbnRSZXN1bHQucHVzaChyYXcudG9TdHJpbmcoKSk7CiAgICAgIH0KICAgIH0KICB9CiAgYXN5bmMgcGFyc2VNYXJrZWRDb250ZW50UHJvcHMoY29udGVudFByb3BlcnRpZXMsIHJlc291cmNlcykgewogICAgbGV0IG9wdGlvbmFsQ29udGVudDsKICAgIGlmIChjb250ZW50UHJvcGVydGllcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHJlc291cmNlcy5nZXQoIlByb3BlcnRpZXMiKTsKICAgICAgb3B0aW9uYWxDb250ZW50ID0gcHJvcGVydGllcy5nZXQoY29udGVudFByb3BlcnRpZXMubmFtZSk7CiAgICB9IGVsc2UgaWYgKGNvbnRlbnRQcm9wZXJ0aWVzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBvcHRpb25hbENvbnRlbnQgPSBjb250ZW50UHJvcGVydGllczsKICAgIH0gZWxzZSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiT3B0aW9uYWwgY29udGVudCBwcm9wZXJ0aWVzIG1hbGZvcm1lZC4iKTsKICAgIH0KICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudFR5cGUgPSBvcHRpb25hbENvbnRlbnQuZ2V0KCJUeXBlIikubmFtZTsKICAgIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NHIikgewogICAgICByZXR1cm4gewogICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgaWQ6IG9wdGlvbmFsQ29udGVudC5vYmpJZAogICAgICB9OwogICAgfSBlbHNlIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NNRCIpIHsKICAgICAgY29uc3QgZXhwcmVzc2lvbiA9IG9wdGlvbmFsQ29udGVudC5nZXQoIlZFIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KGV4cHJlc3Npb24pKSB7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gW107CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihleHByZXNzaW9uLCAwLCByZXN1bHQpOwogICAgICAgIGlmIChyZXN1bHQubGVuZ3RoID4gMCkgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgdHlwZTogIk9DTUQiLAogICAgICAgICAgICBleHByZXNzaW9uOiByZXN1bHQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudEdyb3VwcyA9IG9wdGlvbmFsQ29udGVudC5nZXQoIk9DR3MiKTsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkob3B0aW9uYWxDb250ZW50R3JvdXBzKSB8fCBvcHRpb25hbENvbnRlbnRHcm91cHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgY29uc3QgZ3JvdXBJZHMgPSBbXTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvcHRpb25hbENvbnRlbnRHcm91cHMpKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IG9jZyBvZiBvcHRpb25hbENvbnRlbnRHcm91cHMpIHsKICAgICAgICAgICAgZ3JvdXBJZHMucHVzaChvY2cudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGdyb3VwSWRzLnB1c2gob3B0aW9uYWxDb250ZW50R3JvdXBzLm9iaklkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZHM6IGdyb3VwSWRzLAogICAgICAgICAgcG9saWN5OiBvcHRpb25hbENvbnRlbnQuZ2V0KCJQIikgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gb3B0aW9uYWxDb250ZW50LmdldCgiUCIpLm5hbWUgOiBudWxsLAogICAgICAgICAgZXhwcmVzc2lvbjogbnVsbAogICAgICAgIH07CiAgICAgIH0gZWxzZSBpZiAob3B0aW9uYWxDb250ZW50R3JvdXBzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZDogb3B0aW9uYWxDb250ZW50R3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GluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZVhPYmplY3QsIHJlamVjdFhPYmplY3QpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlhPYmplY3QgbXVzdCBiZSByZWZlcnJlZCB0byBieSBuYW1lLiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZXQgeG9iaiA9IHhvYmpzLmdldFJhdyhuYW1lKTsKICAgICAgICAgICAgICBpZiAoeG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeVJlZih4b2JqKTsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgICAgaW5jcmVtZW50Q2FjaGVkSW1hZ2VNYXNrQ291bnQobG9jYWxJbWFnZSk7CiAgICAgICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGdsb2JhbEltYWdlID0gc2VsZi5nbG9iYWxJbWFnZUNhY2hlLmdldERhdGEoeG9iaiwgc2VsZi5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgaWYgKGdsb2JhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGdsb2JhbEltYWdlLm9iaklkKTsKICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKGdsb2JhbEltYWdlLmZuLCBnbG9iYWxJbWFnZS5hcmdzLCBnbG9iYWxJbWFnZS5vcHRpb25hbENvbnRlbnQpOwogICAgICAgICAgICAgICAgICByZXNvbHZlWE9iamVjdCgpOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB4b2JqID0geHJlZi5mZXRjaCh4b2JqKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCEoeG9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBiZSBhIHN0cmVhbSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCB0eXBlID0geG9iai5kaWN0LmdldCgiU3VidHlwZSIpOwogICAgICAgICAgICAgIGlmICghKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBoYXZlIGEgTmFtZSBzdWJ0eXBlIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICh0eXBlLm5hbWUgPT09ICJGb3JtIikgewogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICAgICAgICAgIHNlbGYuYnVpbGRGb3JtWE9iamVjdChyZXNvdXJjZXMsIHhvYmosIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCksIGxvY2FsQ29sb3JTcGFjZUNhY2hlKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIH0sIHJlamVjdFhPYmplY3QpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZS5uYW1lID09PSAiSW1hZ2UiKSB7CiAgICAgICAgICAgICAgICBzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICAgIGltYWdlOiB4b2JqLAogICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUsCiAgICAgICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgICAgICB9KS50aGVuKHJlc29sdmVYT2JqZWN0LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGUubmFtZSA9PT0gIlBTIikgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJJZ25vcmVkIFhPYmplY3Qgc3VidHlwZSBQUyIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVuaGFuZGxlZCBYT2JqZWN0IHN1YnR5cGUgJHt0eXBlLm5hbWV9YCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgWE9iamVjdDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICB2YXIgZm9udFNpemUgPSBhcmdzWzFdOwogICAgICAgICAgICBuZXh0KHNlbGYuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIGFyZ3MsIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLCBmYWxsYmFja0ZvbnREaWN0KS50aGVuKGZ1bmN0aW9uIChsb2FkZWROYW1lKSB7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZERlcGVuZGVuY3kobG9hZGVkTmFtZSk7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRGb250LCBbbG9hZGVkTmFtZSwgZm9udFNpemVdKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHBhcnNpbmdUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lbmRUZXh0OgogICAgICAgICAgICBwYXJzaW5nVGV4dCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZElubGluZUltYWdlOgogICAgICAgICAgICB2YXIgY2FjaGVLZXkgPSBhcmdzWzBdLmNhY2hlS2V5OwogICAgICAgICAgICBpZiAoY2FjaGVLZXkpIHsKICAgICAgICAgICAgICBjb25zdCBsb2NhbEltYWdlID0gbG9jYWxJbWFnZUNhY2hlLmdldEJ5TmFtZShjYWNoZUtleSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBpbWFnZTogYXJnc1swXSwKICAgICAgICAgICAgICBpc0lubGluZTogdHJ1ZSwKICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgY2FjaGVLZXksCiAgICAgICAgICAgICAgbG9jYWxJbWFnZUNhY2hlLAogICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNvbWJpbmVkR2x5cGhzID0gW107CiAgICAgICAgICAgIHZhciBzdGF0ZSA9IHN0YXRlTWFuYWdlci5zdGF0ZTsKICAgICAgICAgICAgZm9yIChjb25zdCBhcnJJdGVtIG9mIGFyZ3NbMF0pIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKC4uLnNlbGYuaGFuZGxlVGV4dChhcnJJdGVtLCBzdGF0ZSkpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKGFyckl0ZW0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzWzBdID0gY29tYmluZWRHbHlwaHM7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1B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yZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0VGV4dFJlbmRlcmluZ01vZGU6CiAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS50ZXh0UmVuZGVyaW5nTW9kZSA9IGFyZ3NbMF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yU3BhY2U6CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb25zdCBjYWNoZWRDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5nZXRDYWNoZWQoYXJnc1swXSwgeHJlZiwgbG9jYWxDb2xvclNwYWNlQ2FjaGUpOwogICAgICAgICAgICAgIGlmIChjYWNoZWRDb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuZmlsbENvbG9yU3BhY2UgPSBjYWNoZWRDb2xvclNwYWNlOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIG5leHQoc2VsZi5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgICAgY3M6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIGlmIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JTcGFjZToKICAgICAgICAgICAgewogICAgICAgICAgICAgIGNvbnN0IGNhY2hlZENvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLmdldENhY2hlZChhcmdzWzBdLCB4cmVmLCBsb2NhbENvbG9yU3BhY2VDYWNoZSk7CiAgICAgICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlID0gY2FjaGVkQ29sb3JTcGFjZTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VDb2xvclNwYWNlKHsKICAgICAgICAgICAgICAgIGNzOiBhcmdzWzBdLAogICAgICAgICAgICAgICAgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBpZiAoY29sb3JTcGFjZSkgewogICAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3Ryb2tlQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZTsKICAgICAgICAgICAgYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0RmlsbFJHQkNvbG9yOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yOgogICAgICAgICAgICBjcyA9I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gYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0U3Ryb2tlUkdCQ29sb3I7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hhZGluZ0ZpbGw6CiAgICAgICAgICAgIHZhciBzaGFkaW5nUmVzID0gcmVzb3VyY2VzLmdldCgiU2hhZGluZyIpOwogICAgICAgICAgICBpZiAoIXNoYWRpbmdSZXMpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk5vIHNoYWRpbmcgcmVzb3VyY2UgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgc2hhZGluZyA9IHNoYWRpbmdSZXMuZ2V0KGFyZ3NbMF0ubmFtZSk7CiAgICAgICAgICAgIGlmICghc2hhZGluZykgewogICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gc2hhZGluZyBvYmplY3QgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBwYXR0ZXJuSWQgPSBzZWxmLnBhcnNlU2hhZGluZyh7CiAgICAgICAgICAgICAgc2hhZGluZywKICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgICAgICAgICAgbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhcmdzID0gW3BhdHRlcm5JZF07CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNoYWRpbmdGaWxsOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxHU3RhdGVPYmogPSBsb2NhbEdTdGF0ZUNhY2hlLmdldEJ5TmFtZShuYW1lKTsKICAgICAgICAgICAgICBpZiAobG9jYWxHU3RhdGVPYmopIHsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuc2V0R1N0YXRlLCBbbG9jYWxHU3RhdGVPYmpdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGFyZ3MgPSBudWxsOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIG11c3QgYmUgcmVmZXJyZWQgdG8gYnkgbmFtZS4iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZXh0R1N0YXRlID0gcmVzb3VyY2VzLmdldCgiRXh0R1N0YXRlIik7CiAgICAgICAgICAgICAgaWYgKCEoZXh0R1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiRXh0R1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGdTdGF0ZSA9IGV4dEdTdGF0ZS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgaWYgKCEoZ1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNlbGYuc2V0R1N0YXRlKHsKICAgICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICAgIGdTdGF0ZSwKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgICAgICAgICAgIGxvY2FsR1N0YXRlQ2FjaGUsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4ocmVzb2x2ZUdTdGF0ZSwgcmVqZWN0R1N0YXRlKTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubW92ZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8yOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzM6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZVBhdGg6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5yZWN0YW5nbGU6CiAgICAgICAgICAgIHNlbGYuYnVpbGRQYXRoKG9wZXJhdG9yTGlzdCwgZm4sIGFyZ3MsIHBhcnNpbmdUZXh0KTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnQ6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnRQcm9wczoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luQ29tcGF0OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kQ29tcGF0OgogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudFByb3BzOgogICAgICAgICAgICBpZiAoIShhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEV4cGVjdGVkIG5hbWUgZm9yIGJlZ2luTWFya2VkQ29udGVudFByb3BzIGFyZzA9JHthcmdzWzBdfWApOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcmdzWzBdLm5hbWUgPT09ICJPQyIpIHsKICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VNYXJrZWRDb250ZW50UHJvcHMoYXJnc1sxXSwgcmVzb3VyY2VzKS50aGVuKGRhdGEgPT4gewogICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywgWyJPQyIsIGRhdGFdKTsKICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzID0gW2FyZ3NbMF0ubmFtZSwgYXJnc1sxXSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgPyBhcmdzWzFdLmdldCgiTUNJRCIpIDogbnVsbF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGlmIChhcmdzICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZm9yIChpID0gMCwgaWkgPSBhcmdzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChhcmdzW2ldIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGkgPCBpaSkgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBvcGVyYXRvcjogIiArIGZuKTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoZm4sIGFyZ3MpOwogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNsb3NlUGVuZGluZ1Jlc3RvcmVPUFMoKTsKICAgICAgcmVzb2x2ZSgpOwogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmICh0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBlcnJvcnMgZHVyaW5nICIke3Rhc2submFtZX0iIGAgKyBgdGFzazogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgY2xvc2VQZW5kaW5nUmVzdG9yZU9QUygpOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aHJvdyByZWFzb247CiAgICB9KTsKICB9CiAgZ2V0VGV4dENvbnRlbnQoX3JlZjcpIHsKICAgIGxldCB7CiAgICAgIHN0cmVhbSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBzdGF0ZU1hbmFnZXIgPSBudWxsLAogICAgICBjb21iaW5lVGV4dEl0ZW1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Nmb3JtKHRleHRTdGF0ZS5jdG0sIF91dGlsLlV0aWwudHJhbnNmb3JtKHRleHRTdGF0ZS50ZXh0TWF0cml4LCB0c20pKTsKICAgIH0KICAgIGZ1bmN0aW9uIGVuc3VyZVRleHRDb250ZW50SXRlbSgpIHsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5pbml0aWFsaXplZCkgewogICAgICAgIHJldHVybiB0ZXh0Q29udGVudEl0ZW07CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnQsCiAgICAgICAgbG9hZGVkTmFtZQogICAgICB9ID0gdGV4dFN0YXRlOwogICAgICBpZiAoIXNlZW5TdHlsZXMuaGFzKGxvYWRlZE5hbWUpKSB7CiAgICAgICAgc2VlblN0eWxlcy5hZGQobG9hZGVkTmFtZSk7CiAgICAgICAgdGV4dENvbnRlbnQuc3R5bGVzW2xvYWRlZE5hbWVdID0gewogICAgICAgICAgZm9udEZhbWlseTogZm9udC5mYWxsYmFja05hbWUsCiAgICAgICAgICBhc2NlbnQ6IGZvbnQuYXNjZW50LAogICAgICAgICAgZGVzY2VudDogZm9udC5kZXNjZW50LAogICAgICAgICAgdmVydGljYWw6IGZvbnQudmVydGljYWwKICAgICAgICB9OwogICAgICB9CiAgICAgIHRleHRDb250ZW50SXRlbS5mb250TmFtZSA9IGxvYWRlZE5hbWU7CiAgICAgIGNvbnN0IHRybSA9IHRleHRDb250ZW50SXRlbS50cmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICBpZiAoIWZvbnQudmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggPSB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IE1hdGguaHlwb3QodHJtWzJdLCB0cm1bM10pOwogICAgICAgIHRleHRDb250ZW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ubmVnYXRpdmVTcGFjZU1heCkgewogICAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VYKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS53aWR0aCkgewogICAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVgpID4gdGV4dENvbnRlbnRJdGVtLndpZHRoKSB7CiAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYWR2YW5jZVkgPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLm5vdEFTcGFjZSkgewogICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICB9CiAgICAgICAgaWYgKGFkdmFuY2VZIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS50cmFja2luZ1NwYWNlTWluKSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICs9IGFkdmFuY2VZOwogICAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVksIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgICBpZiAodGV4dENvbnRlbnRJdGVtLnN0ci5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RyOiAiICIsCiAgICAgICAgICAgICAgZGlyOiAibHRyIiwKICAgICAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgICAgICBoZWlnaHQ6IE1hdGguYWJzKGFkdmFuY2VZKSwKICAgICAgICAgICAgICB0cmFuc2Zvcm06IHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLAogICAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRDb250ZW50SXRlbS5oZWlnaHQgKz0gYWR2YW5jZVk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWCkgPiB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiBWRVJUSUNBTF9TSElGVF9SQVRJTykgewogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgICAgY29uc3QgYWR2YW5jZVggPSAocG9zWCAtIGxhc3RQb3NYKSAvIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICBjb25zdCBhZHZhbmNlWSA9IHBvc1kgLSBsYXN0UG9zWTsKICAgICAgY29uc3QgdGV4dE9yaWVudGF0aW9uID0gTWF0aC5zaWduKHRleHRDb250ZW50SXRlbS53aWR0aCk7CiAgICAgIGlmIChhZHZhbmNlWCA8IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5uZWdhdGl2ZVNwYWNlTWF4KSB7CiAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VZKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS5oZWlnaHQpIHsKICAgICAgICAgIGFwcGVuZEVPTCgpOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVkpID4gdGV4dENvbnRlbnRJdGVtLmhlaWdodCkgewogICAgICAgIGFwcGVuZEVPTCgpOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChhZHZhbmNlWCA8PSB0ZXh0T3JpZW50YXRpb24gKiB0ZXh0Q29udGVudEl0ZW0ubm90QVNwYWNlKSB7CiAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgfQogICAgICBpZiAoYWR2YW5jZVggPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnRyYWNraW5nU3BhY2VNaW4pIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVgsIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgIHN0cjogIiAiLAogICAgICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgICAgICB3aWR0aDogTWF0aC5hYnMoYWR2YW5jZVgpLAogICAgICAgICAgICBoZWlnaHQ6IDAsCiAgICAgICAgICAgIHRyYW5zZm9ybTogdGV4dENvbnRlbnRJdGVtLnByZXZUcmFuc2Zvcm0sCiAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgIGhhc0VPTDogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWSkgPiB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICogVkVSVElDQUxfU0hJRlRfUkFUSU8pIHsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZnVuY3Rpb24gYnVpbGRUZXh0Q29udGVudEl0ZW0oX3JlZjgpIHsKICAgICAgbGV0IHsKICAgICAgICBjaGFycywKICAgICAgICBleHRyYVNwYWNpbmcKICAgICAgfSA9IF9yZWY4OwogICAgICBjb25zdCBmb250ID0gdGV4dFN0YXRlLmZvbnQ7CiAgICAgIGlmICghY2hhcnMpIHsKICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IHRleHRTdGF0ZS5jaGFyU3BhY2luZyArIGV4dHJhU3BhY2luZzsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBnbHlwaHMgPSBmb250LmNoYXJzVG9HbHlwaHMoY2hhcnMpOwogICAgICBjb25zdCBzY2FsZSA9IHRleHRTdGF0ZS5mb250TWF0cml4WzBdICogdGV4dFN0YXRlLmZvbnRTaXplOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBnbHlwaHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgIGNvbnN0IHsKICAgICAgICAgIGNhdGVnb3J5CiAgICAgICAgfSA9IGdseXBoOwogICAgICAgIGlmIChjYXRlZ29yeS5pc0ludmlzaWJsZUZvcm1hdE1hcmspIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsZXQgY2hhclNwYWNpbmcgPSB0ZXh0U3RhdGUuY2hhclNwYWNpbmcgKyAoaSArIDEgPT09IGlpID8gZXh0cmFTcGFjaW5nIDogMCk7CiAgICAgICAgbGV0IGdseXBoV2lkdGggPSBnbHlwaC53aWR0aDsKICAgICAgICBpZiAoZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgZ2x5cGhXaWR0aCA9IGdseXBoLnZtZXRyaWMgPyBnbHlwaC52bWV0cmljWzBdIDogLWdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGxldCBzY2FsZWREaW0gPSBnbHlwaFdpZHRoICogc2NhbGU7CiAgICAgICAgaWYgKGNhdGVnb3J5LmlzV2hpdGVzcGFjZSkgewogICAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICAgIGNoYXJTcGFjaW5nICs9IHNjYWxlZERpbSArIHRleHRTdGF0ZS53b3JkU3BhY2luZzsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoY2hhclNwYWNpbmcgKiB0ZXh0U3RhdGUudGV4dEhTY2FsZSwgMCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjaGFyU3BhY2luZyArPSAtc2NhbGVkRGltICsgdGV4dFN0YXRlLndvcmRTcGFjaW5nOwogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeCgwLCAtY2hhclNwYWNpbmcpOwogICAgICAgICAgfQogICAgICAgICAgc2F2ZUxhc3RDaGFyKCIgIik7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKCFjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYyAmJiAhY29tcGFyZVdpdGhMYXN0UG9zaXRpb24oKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRleHRDaHVuayA9IGVuc3VyZVRleHRDb250ZW50SXRlbSgpOwogICAgICAgIGlmIChjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYykgewogICAgICAgICAgc2NhbGVkRGltID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICBzY2FsZWREaW0gKj0gdGV4dFN0YXRlLnRleHRIU2NhbGU7CiAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChzY2FsZWREaW0sIDApOwogICAgICAgICAgdGV4dENodW5rLndpZHRoICs9IHNjYWxlZERpbTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoMCwgc2NhbGVkRGltKTsKICAgICAgICAgIHNjYWxlZERpbSA9IE1hdGguYWJzKHNjYWxlZERpbSk7CiAgICAgICAgICB0ZXh0Q2h1bmsuaGVpZ2h0ICs9IHNjYWxlZERpbTsKICAgICAgICB9CiAgICAgICAgaWYgKHNjYWxlZERpbSkgewogICAgICAgICAgdGV4dENodW5rLnByZXZUcmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICAgIH0KICAgICAgICBjb25zdCBnbHlwaFVuaWNvZGUgPSBnbHlwaC5ub3JtYWxpemVkVW5pY29kZTsKICAgICAgICBpZiAoc2F2ZUxhc3RDaGFyKGdseXBoVW5pY29kZSkpIHsKICAgICAgICAgIHRleHRDaHVuay5zdHIucHVzaCgiICIpOwogICAgICAgIH0KICAgICAgICB0ZXh0Q2h1bmsuc3RyLnB1c2goZ2x5cGhVbmljb2RlKTsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhcHBlbmRFT0woKSB7CiAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGFzRU9MID0gdHJ1ZTsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgc3RyOiAiIiwKICAgICAgICAgIGRpcjogImx0ciIsCiAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgIGhlaWdodDogMCwKICAgICAgICAgIHRyYW5zZm9ybTogZ2V0Q3VycmVudFRleHRUcmFuc2Zvcm0oKSwKICAgICAgICAgIGZvbnROYW1lOiB0ZXh0U3RhdGUubG9hZGVkTmFtZSwKICAgICAgICAgIGhhc0VPTDogdHJ1ZQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhZGRGYWtlU3BhY2VzKHdpZHRoLCB0cmFuc2YsIHRleHRPcmllbnRhdGlvbikgewogICAgICBpZiAodGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnNwYWNlSW5GbG93TWluIDw9IHdpZHRoICYmIHdpZHRoIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5zcGFjZUluRmxvd01heCkgewogICAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uc3RyLnB1c2goIiAiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnROYW1lID0gdGV4dENvbnRlbnRJdGVtLmZvbnROYW1lOwogICAgICBsZXQgaGVpZ2h0ID0gMDsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCkgewogICAgICAgIGhlaWdodCA9IHdpZHRoOwogICAgICAgIHdpZHRoID0gMDsKICAgICAgfQogICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICByZXNldExhc3RDaGFycygpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICBzdHI6ICIgIiwKICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgIHdpZHRoOiBNYXRoLmFicyh3aWR0aCksCiAgICAgICAgaGVpZ2h0OiBNYXRoLmFicyhoZWlnaHQpLAogICAgICAgIHRyYW5zZm9ybTogdHJhbnNmIHx8IGdldEN1cnJlbnRUZXh0VHJhbnNmb3JtKCksCiAgICAgICAgZm9udE5hbWUsCiAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICB9KTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBmdW5jdGlvbiBmbHVzaFRleHRDb250ZW50SXRlbSgpIHsKICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQgfHwgIXRleHRDb250ZW50SXRlbS5zdHIpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0udmVydGljYWwpIHsKICA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gcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCkgewogICAgICBjb25zdCBuZXh0ID0gZnVuY3Rpb24gKHByb21pc2UpIHsKICAgICAgICBlbnF1ZXVlQ2h1bmsodHJ1ZSk7CiAgICAgICAgUHJvbWlzZS5hbGwoW3Byb21pc2UsIHNpbmsucmVhZHldKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCk7CiAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICByZWplY3QoZXgpOwogICAgICAgICAgfQogICAgICAgIH0sIHJlamVjdCk7CiAgICAgIH07CiAgICAgIHRhc2suZW5zdXJlTm90VGVybWluYXRlZCgpOwogICAgICB0aW1lU2xvdE1hbmFnZXIucmVzZXQoKTsKICAgICAgY29uc3Qgb3BlcmF0aW9uID0ge307CiAgICAgIGxldCBzdG9wLAogICAgICAgIGFyZ3MgPSBbXTsKICAgICAgd2hpbGUgKCEoc3RvcCA9IHRpbWVTbG90TWFuYWdlci5jaGVjaygpKSkgewogICAgICAgIGFyZ3MubGVuZ3RoID0gMDsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IGFyZ3M7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGV4dFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlOwogICAgICAgIGNvbnN0IGZuID0gb3BlcmF0aW9uLmZuOwogICAgICAgIGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgdmFyIGZvbnROYW1lQXJnID0gYXJnc1swXS5uYW1lLAogICAgICAgICAgICAgIGZvbnRTaXplQXJnID0gYXJnc1sxXTsKICAgICAgICAgICAgaWYgKHRleHRTdGF0ZS5mb250ICYmIGZvbnROYW1lQXJnID09PSB0ZXh0U3RhdGUuZm9udE5hbWUgJiYgZm9udFNpemVBcmcgPT09IHRleHRTdGF0ZS5mb250U2l6ZSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS5mb250TmFtZSA9IGZvbnROYW1lQXJnOwogICAgICAgICAgICB0ZXh0U3RhdGUuZm9udFNpemUgPSBmb250U2l6ZUFyZzsKICAgICAgICAgICAgbmV4dChoYW5kbGVTZXRGb250KGZvbnROYW1lQXJnLCBudWxsKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSaXNlOgogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dFJpc2UgPSBhcmdzWzBdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgdGV4dFN0YXRlLnRleHRIU2NhbGUgPSBhcmdzWzBdIC8gMTAwOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmc6CiAgICAgICAgICAgIHRleHRTdGF0ZS5sZWFkaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazs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lIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYLnNsaWNlKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBzcGFjZUZhY3RvciA9ICh0ZXh0U3RhdGUuZm9udC52ZXJ0aWNhbCA/IDEgOiAtMSkgKiB0ZXh0U3RhdGUuZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICBjb25zdCBlbGVtZW50cyA9IGFyZ3NbMF07CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGVsZW1lbnRzLmxlbmd0aDsgaSA8IGlpIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGVsZW1lbnRzW2ldOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0QnVmZmVyLnB1c2goaXRlbSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gIm51bWJlciIgJiYgaXRlbSAhPT0gMCkgewogICAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IGl0ZW0gKiBzcGFjZUZhY3RvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBlbGVtZW50cy5hdCgtMSk7CiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5wdXNoKGl0ZW0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgc2hvd1NwYWNlZFRleHRCdWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgICAgICBidWlsZFRleHRDb250ZW50SXRlbSh7CiAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgZXh0cmFTcGFjaW5nOiAwCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNhcnJpYWdlUmV0dXJuKCk7CiAgICAgICAgICAgIGJ1aWxkVGV4dENvbnRlbnRJdGVtKHsKICAgICAgICAgICAgICBjaGFyczogYXJnc1syXSwKICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IDAKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRYT2JqZWN0OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoIXhvYmpzKSB7CiAgICAgICAgICAgICAgeG9ianMgPSByZXNvdXJjZXMuZ2V0KCJYT2JqZWN0IikgfHwgX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgdmFyIG5hbWUgPSBhcmdzWzBdLm5hbWU7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkTmFtZSAmJiBlbXB0eVhPYmplY3RDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlWE9iamVjdCwgcmVqZWN0WE9iamVjdCkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCB4b2JqID0geG9ianMuZ2V0UmF3KG5hbWUpOwogICAgICAgICAgICAgIGlmICh4b2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHlYT2JqZWN0Q2FjaGUuZ2V0QnlSZWYoeG9iaikpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgZ2xvYmFsSW1hZ2UgPSBzZWxmLmdsb2JhbEltYWdlQ2FjaGUuZ2V0RGF0YSh4b2JqLCBzZWxmLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsSW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgeG9iaiA9IHhyZWYuZmV0Y2goeG9iaik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghKHhvYmogaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgYmUgYSBzdHJlYW0iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHhvYmouZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICAgICAgICBpZiAoISh0eXBlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgaGF2ZSBhIE5hbWUgc3VidHlwZSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZS5uYW1lICE9PSAiRm9ybSIpIHsKICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgY3VycmVudFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCk7CiAgICAgICAgICAgICAgY29uc3QgeE9ialN0YXRlTWFuYWdlciA9IG5ldyBTdGF0ZU1hbmFnZXIoY3VycmVudFN0YXRlKTsKICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSB4b2JqLmRpY3QuZ2V0QXJyYXkoIk1hdHJpeCIpOwogICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG1hdHJpeCkgJiYgbWF0cml4Lmxlbmd0aCA9PT0gNikgewogICAgICAgICAgICAgICAgeE9ialN0YXRlTWFuYWdlci50cmFuc2Zvcm0obWF0cml4KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgICAgICAgY29uc3Qgc2lua1dyYXBwZXIgPSB7CiAgICAgICAgICAgICAgICBlbnF1ZXVlSW52b2tlZDogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuZW5xdWV1ZUludm9rZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUoY2h1bmssIHNpemUpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGdldCBkZXNpcmVkU2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpbmsuZGVzaXJlZFNpemU7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZ2V0IHJlYWR5KCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gc2luay5yZWFkeTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHNlbGYuZ2V0VGV4dENvbnRlbnQoewogICAgICAgICAgICAgICAgc3RyZWFtOiB4b2JqLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHJlc291cmNlczogeG9iai5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyOiB4T2JqU3RhdGVNYW5hZ2VyLAogICAgICAgICAgICAgICAgY29tYmluZVRleHRJdGVtcywKICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50LAogICAgICAgICAgICAgICAgc2luazogc2lua1dyYXBwZXIsCiAgICAgICAgICAgICAgICBzZWVuU3R5bGVzLAogICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhCiAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoIXNpbmtXcmFwcGVyLmVucXVldWVJbnZva2VkKSB7CiAgICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICB9LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRUZXh0Q29udGVudCAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0R1N0YXRlOgogICAgICAgICAgICBpc1ZhbGlkTmFtZSA9IGFyZ3NbMF0gaW5z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ICAgICAgICAgICAgIGlmICghZ1N0YXRlRm9udCkgewogICAgICAgICAgICAgICAgZW1wdHlHU3RhdGVDYWNoZS5zZXQobmFtZSwgZ1N0YXRlLm9iaklkLCB0cnVlKTsKICAgICAgICAgICAgICAgIHJlc29sdmVHU3RhdGUoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgICB0ZXh0U3RhdGUuZm9udE5hbWUgPSBudWxsOwogICAgICAgICAgICAgIHRleHRTdGF0ZS5mb250U2l6ZSA9IGdTdGF0ZUZvbnRbMV07CiAgICAgICAgICAgICAgaGFuZGxlU2V0Rm9udChudWxsLCBnU3RhdGVGb250WzBdKS50aGVuKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0VGV4dENvbnRlbnQgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoaW5jbHVkZU1hcmtlZENvbnRlbnQpIHsKICAgICAgICAgICAgICBtYXJrZWRDb250ZW50RGF0YS5sZXZlbCsrOwogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudCIsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIGlmIChpbmNsdWRlTWFya2VkQ29udGVudCkgewogICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhLmxldmVsKys7CiAgICAgICAgICAgICAgbGV0IG1jaWQgPSBudWxsOwogICAgICAgICAgICAgIGlmIChhcmdzWzFdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgbWNpZCA9IGFyZ3NbMV0uZ2V0KCJNQ0lEIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudFByb3BzIiwKICAgICAgICAgICAgICAgIGlkOiBOdW1iZXIuaXNJbnRlZ2VyKG1jaWQpID8gYCR7c2VsZi5pZEZhY3RvcnkuZ2V0UGFnZU9iaklkKCl9X21jaWQke21jaWR9YCA6IG51bGwsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgICAgICAgICAgaWYgKG1hcmtlZENvbnRlbnREYXRhLmxldmVsID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbWFya2VkQ29udGVudERhdGEubGV2ZWwtLTsKICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICAgIHR5cGU6ICJlbmRNYXJrZWRDb250ZW50IgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoID49IHNpbmsuZGVzaXJlZFNpemUpIHsKICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgIGVucXVldWVDaHVuaygpOwogICAgICByZXNvbHZlKCk7CiAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFRleHRDb250ZW50IC0gaWdub3JpbmcgZXJyb3JzIGR1cmluZyAiJHt0YXNrLm5hbWV9IiB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29uc3QgZW50cnkgb2YgZGlmZkVuY29kaW5nKSB7CiAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB4cmVmLmZldGNoSWZSZWYoZW50cnkpOwogICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgaW5kZXggPSBkYXRhOwogICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgZGlmZmVyZW5jZXNbaW5kZXgrK10gPSBkYXRhLm5hbWU7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkIGVudHJ5IGluICdEaWZmZXJlbmNlcycgYXJyYXk6ICR7ZGF0YX1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChlbmNvZGluZyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICBiYXNlRW5jb2RpbmdOYW1lID0gZW5jb2RpbmcubmFtZTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBtc2cgPSAiRW5jb2RpbmcgaXMgbm90IGEgTmFtZSBub3IgYSBEaWN0IjsKICAgICAgICBpZiAoIXRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihtc2cpOwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikobXNnKTsKICAgICAgfQogICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAhPT0gIk1hY1JvbWFuRW5jb2RpbmciICYmIGJhc2VFbmNvZGluZ05hbWUgIT09ICJNYWNFeHBlcnRFbmNvZGluZyIgJiYgYmFzZUVuY29kaW5nTmFtZSAhPT0gIldpbkFuc2lFbmNvZGluZ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AgICB9CiAgICAgIGxldCBjb2RlID0gMDsKICAgICAgc3dpdGNoIChnbHlwaE5hbWVbMF0pIHsKICAgICAgICBjYXNlICJHIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSAzKSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSA1KSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJDIjoKICAgICAgICBjYXNlICJjIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID49IDMgJiYgZ2x5cGhOYW1lLmxlbmd0aCA8PSA0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGVTdHIgPSBnbHlwaE5hbWUuc3Vic3RyaW5nKDEpOwogICAgICAgICAgICBpZiAoZm9yY2VHbHlwaHMpIHsKICAgICAgICAgICAgICBjb2RlID0gcGFyc2VJbnQoY29kZVN0ciwgMTYpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGUgPSArY29kZVN0cjsKICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihjb2RlKSAmJiBOdW1iZXIuaXNJbnRlZ2VyKHBhcnNlSW50KGNvZGVTdHIsIDE2KSkpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2ltcGxlRm9udFRvVW5pY29kZShwcm9wZXJ0aWVzLCB0cnVlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidSI6CiAgICAgICAgICB1bmljb2RlID0gKDAsIF91bmljb2RlLmdldFVuaWNvZGVGb3JHbHlwaCkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGlmICh1bmljb2RlICE9PSAtMSkgewogICAgICAgICAgICBjb2RlID0gdW5pY29kZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzd2l0Y2ggKGdseXBoTmFtZSkgewogICAgICAgICAgICBjYXNlICJmX2giOgogICAgICAgICAgICBjYXNlICJmX3QiOgogICAgICAgICAgICBjYXNlICJUX2giOgogICAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBnbHlwaE5hbWUucmVwbGFjZUFsbCgiXyIsICIiKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChjb2RlID4gMCAmJiBjb2RlIDw9IDB4MTBmZmZmICYmIE51bWJlci5pc0ludGVnZXIoY29kZSkpIHsKICAgICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAmJiBjb2RlID09PSArY2hhcmNvZGUpIHsKICAgICAgICAgIGNvbnN0IGJhc2VFbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShiYXNlRW5jb2RpbmdOYW1lKTsKICAgICAgICAgIGlmIChiYXNlRW5jb2RpbmcgJiYgKGdseXBoTmFtZSA9IGJhc2VFbmNvZGluZ1tjaGFyY29kZV0pKSB7CiAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGdseXBoc1VuaWNvZGVNYXBbZ2x5cGhOYW1lXSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0b1VuaWNvZGVbY2hhcmNvZGVdID0gU3RyaW5nLmZyb21Db2RlUG9pbnQoY29kZSk7CiAgICAgIH0KICAgIH0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FtKSB7CiAgICAgIHJldHVybiBfY21hcC5DTWFwRmFjdG9yeS5jcmVhdGUoewogICAgICAgIGVuY29kaW5nOiBjbWFwT2JqLAogICAgICAgIGZldGNoQnVpbHRJbkNNYXA6IHRoaXMuX2ZldGNoQnVpbHRJbkNNYXBCb3VuZCwKICAgICAgICB1c2VDTWFwOiBudWxsCiAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNtYXApIHsKICAgICAgICBpZiAoY21hcCBpbnN0YW5jZW9mIF9jbWFwLklkZW50aXR5Q01hcCkgewogICAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuSWRlbnRpdHlUb1VuaWNvZGVNYXAoMCwgMHhmZmZmKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbWFwID0gbmV3IEFycmF5KGNtYXAubGVuZ3RoKTsKICAgICAgICBjbWFwLmZvckVhY2goZnVuY3Rpb24gKGNoYXJDb2RlLCB0b2tlbikgewogICAgICAgICAgaWYgKHR5cGVvZiB0b2tlbiA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KHRva2VuKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RyID0gW107CiAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHRva2VuLmxlbmd0aDsgayArPSAyKSB7CiAgICAgICAgICAgIGNvbnN0IHcxID0gdG9rZW4uY2hhckNvZGVBdChrKSA8PCA4IHwgdG9rZW4uY2hhckNvZGVBdChrICsgMSk7CiAgICAgICAgICAgIGlmICgodzEgJiAweGY4MDApICE9PSAweGQ4MDApIHsKICAgICAgICAgICAgICBzdHIucHVzaCh3MSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgayArPSAyOwogICAgICAgICAgICBjb25zdCB3MiA9IHRva2VuLmNoYXJDb2RlQXQoaykgPDwgOCB8IHRva2VuLmNoYXJDb2RlQXQoayArIDEpOwogICAgICAgICAgICBzdHIucHVzaCgoKHcxICYgMHgzZmYpIDw8IDEwKSArICh3MiAmIDB4M2ZmKSArIDB4MTAwMDApOwogICAgICAgICAgfQogICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KC4uLnN0cik7CiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuVG9Vbmljb2RlTWFwKG1hcCk7CiAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgcmVhZFRvVW5pY29kZSAtIGlnbm9yaW5nIFRvVW5pY29kZSBkYXRhOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgICB0aHJvdyByZWFzb247CiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShudWxsKTsKICB9CiAgcmVhZENpZFRvR2lkTWFwKGdseXBoc0RhdGEsIHRvVW5pY29kZSkgewogICAgY29uc3QgcmVzdWx0ID0gW107CiAgICBmb3IgKGxldCBqID0gMCwgamogPSBnbHlwaHNEYXRhLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgZ2x5cGhJRCA9IGdseXBoc0RhdGFbaisrXSA8PCA4IHwgZ2x5cGhzRGF0YVtqXTsKICAgICAgY29uc3QgY29kZSA9IGogPj4gMTsKICAgICAgaWYgKGdseXBoSUQgPT09IDAgJiYgIXRvVW5pY29kZS5oYXMoY29kZSkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByZXN1bHRbY29kZV0gPSBnbHlwaElEOwogICAgfQogICAgcmV0dXJuIHJlc3VsdDsKICB9CiAgZXh0cmFjdFdpZHRocyhkaWN0LCBkZXNjcmlwdG9yLCBwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGdseXBoc1dpZHRocyA9IFtdOwogICAgbGV0IGRlZmF1bHRXaWR0aCA9IDA7CiAgICBjb25zdCBnbHlwaHNWTWV0cmljcyA9IFtdOwogICAgbGV0IGRlZmF1bHRWTWV0cmljczsKICAgIGxldCBpLCBpaSwgaiwgamosIHN0YXJ0LCBjb2RlLCB3aWR0aHM7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgZGVmYXVsdFdpZHRoID0gZGljdC5oYXMoIkRXIikgPyBkaWN0LmdldCgiRFciKSA6IDEwMDA7CiAgICAgIHdpZHRocyA9IGRpY3QuZ2V0KCJXIik7CiAgICAgIGlmICh3aWR0aHMpIHsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBzdGFydCA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaSsrXSk7CiAgICAgICAgICBjb2RlID0geHJlZi5mZXRjaElmUmVmKHdpZHRoc1tpXSk7CiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGUubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgICAgIGdseXBoc1dpZHRoc1tzdGFydCsrXSA9IHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB4cmVmLmZldGNoSWZSZWYod2lkdGhzWysraV0pOwogICAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBjb2RlOyBqKyspIHsKICAgICAgICAgICAgICBnbHlwaHNXaWR0aHNbal0gPSB3aWR0aDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocHJvcGVydGllcy52ZXJ0aWNhbCkgewogICAgICAgIGxldCB2bWV0cmljcyA9IGRpY3QuZ2V0QXJyYXkoIkRXMiIpIHx8IFs4ODAsIC0xMDAwXTsKICAgICAgICBkZWZhdWx0Vk1ldHJpY3MgPSBbdm1ldHJpY3NbMV0sIGRlZmF1bHRXaWR0aCAqIDAuNSwgdm1ldHJpY3NbMF1dOwogICAgICAgIHZtZXRyaWNzID0gZGljdC5nZXQoIlcyIik7CiAgICAgICAgaWYgKHZtZXRyaWNzKSB7CiAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHZtZXRyaWNzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgc3RhcnQgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaSsrXSk7CiAgICAgICAgICAgIGNvZGUgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaV0pOwogICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICAgIGZvciAoaiA9IDAsIGpqID0gY29kZS5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tzdGFydCsrXSA9IFt4cmVmLmZldGNoSWZSZWYoY29kZVtqKytdKSwgeHJlZi5mZXRjaElmUmVmKGNvZGVbaisrXSksIHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBbeHJlZi5mZXRjaElmUmVmKHZtZXRyaWNzWysraV0pLCB4cmVmLmZldGNoSWZSZWYodm1ldHJp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dldCgiV2lkdGhzIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KHdpZHRocykpIHsKICAgICAgICBjb25zdCB3aWR0aHNCdWYgPSBbXTsKICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIHdpZHRocykgewogICAgICAgICAgaWYgKHR5cGVvZiBlbnRyeSA9PT0gIm51bWJlciIgfHwgZW50cnkgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goZW50cnkudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGhhc2gudXBkYXRlKHdpZHRoc0J1Zi5qb2luKCkpOwogICAgICB9CiAgICAgIGlmIChjb21wb3NpdGUpIHsKICAgICAgICBoYXNoLnVwZGF0ZSgiY29tcG9zaXRlRm9udCIpOwogICAgICAgIGNvbnN0IGNvbXBvc2l0ZVdpZHRocyA9IGRpY3QuZ2V0KCJXIikgfHwgYmFzZURpY3QuZ2V0KCJXIik7CiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoY29tcG9zaXRlV2lkdGhzKSkgewogICAgICAgICAgY29uc3Qgd2lkdGhzQnVmID0gW107CiAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGNvbXBvc2l0ZVdpZHRocykgewogICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAibnVtYmVyIiB8fCBlbnRyeSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHdpZHRoc0J1Zi5wdXNoKGVudHJ5LnRvU3RyaW5nKCkpOwogICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoZW50cnkpKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3ViV2lkdGhzQnVmID0gW107CiAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIGVudHJ5KSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVsZW1lbnQgPT09ICJudW1iZXIiIHx8IGVsZW1lbnQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICAgICAgc3ViV2lkdGhzQnVmLnB1c2goZWxlbWVudC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goYFske3N1YldpZHRoc0J1Zi5qb2luKCl9XWApOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoLnVwZGF0ZSh3aWR0aHNCdWYuam9pbigpKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2lkVG9HaWRNYXAgPSBkaWN0LmdldFJhdygiQ0lEVG9HSURNYXAiKSB8fCBiYXNlRGljdC5nZXRSYXcoIkNJRFRvR0lETWFwIik7CiAgICAgICAgaWYgKGNpZFRvR2lkTWFwIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAubmFtZSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAudG9TdHJpbmcoKSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICBoYXNoLnVwZGF0ZShjaWRUb0dpZE1hcC5wZWVrQnl0ZXMoKSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBkZXNjcmlwdG9yLAogICAgICBkaWN0LAogICAgICBiYXNlRGljdCwKICAgICAgY29tcG9zaXRlLAogICAgICB0eXBlOiB0eXBlLm5hbWUsCiAgICAgIGZpcnN0Q2hhciwKICAgICAgbGFzd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TsKICAgICAgICBjb25zdCBtZXRyaWNzID0gdGhpcy5nZXRCYXNlRm9udE1ldHJpY3MoYmFzZUZvbnROYW1lKTsKICAgICAgICBjb25zdCBmb250TmFtZVdvU3R5bGUgPSBiYXNlRm9udE5hbWUuc3BsaXQoIi0iKVswXTsKICAgICAgICBjb25zdCBmbGFncyA9ICh0aGlzLmlzU2VyaWZGb250KGZvbnROYW1lV29TdHlsZSkgPyBfZm9udHNfdXRpbHMuRm9udEZsYWdzLlNlcmlmIDogMCkgfCAobWV0cmljcy5tb25vc3BhY2UgPyBfZm9udHNfdXRpbHMuRm9udEZsYWdzLkZpeGVkUGl0Y2ggOiAwKSB8ICgoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN5bWJvbHNGb250cykoKVtmb250TmFtZVdvU3R5bGVdID8gX2ZvbnRzX3V0aWxzLkZvbnRGbGFncy5TeW1ib2xpYyA6IF9mb250c191dGlscy5Gb250RmxhZ3MuTm9uc3ltYm9saWMpOwogICAgICAgIHByb3BlcnRpZXMgPSB7CiAgICAgICAgICB0eXBlLAogICAgICAgICAgbmFtZTogYmFzZUZvbnROYW1lLAogICAgICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgICAgIHdpZHRoczogbWV0cmljcy53aWR0aHMsCiAgICAgICAgICBkZWZhdWx0V2lkdGg6IG1ldHJpY3MuZGVmYXVsdFdpZHRoLAogICAgICAgICAgaXNTaW11bGF0ZWRGbGFnczogdHJ1ZSwKICAgICAgICAgIGZsYWdzLAogICAgICAgICAgZmlyc3RDaGFyLAogICAgICAgICAgbGFzdENoYXIsCiAgICAgICAgICB0b1VuaWNvZGUsCiAgICAgICAgICB4SGVpZ2h0OiAwLAogICAgICAgICAgY2FwSGVpZ2h0OiAwLAogICAgICAgICAgaXRhbGljQW5nbGU6IDAsCiAgICAgICAgICBpc1R5cGUzRm9udAogICAgICAgIH07CiAgICAgICAgY29uc3Qgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGJhc2VGb250TmFtZSk7CiAgICAgICAgbGV0IGZpbGUgPSBudWxsOwogICAgICAgIGlmIChzdGFuZGFyZEZvbnROYW1lKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLmlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICAgIGZpbGUgPSBhd2FpdCB0aGlzLmZldGNoU3RhbmRhcmRGb250RGF0YShzdGFuZGFyZEZvbnROYW1lKTsKICAgICAgICAgIHByb3BlcnRpZXMuaXNJbnRlcm5hbEZvbnQgPSAhIWZpbGU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLmV4dHJhY3REYXRhU3RydWN0dXJlcyhkaWN0LCBkaWN0LCBwcm9wZXJ0aWVzKS50aGVuKG5ld1Byb3BlcnRpZXMgPT4gewogICAgICAgICAgaWYgKHdpZHRocykgewogICAgICAgICAgICBjb25zdCBnbHlwaFdpZHRocyA9IFtdOwogICAgICAgICAgICBsZXQgaiA9IGZpcnN0Q2hhcjsKICAgICAgICAgICAgZm9yIChjb25zdCB3aWR0aCBvZiB3aWR0aHMpIHsKICAgICAgICAgICAgICBnbHlwaFdpZHRoc1tqKytdID0gdGhpcy54cmVmLmZldGNoSWZSZWYod2lkdGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5ld1Byb3BlcnRpZXMud2lkdGhzID0gZ2x5cGhXaWR0aHM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBuZXdQcm9wZXJ0aWVzLndpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBfZm9udHMuRm9udChiYXNlRm9udE5hbWUsIGZpbGUs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9udENoYXIpIHsKICAgICAgY29uc3QgZ2x5cGhOYW1lID0gYCR7Zm9udC5sb2FkZWROYW1lfV9wYXRoXyR7Zm9udENoYXJ9YDsKICAgICAgdHJ5IHsKICAgICAgICBpZiAoZm9udC5yZW5kZXJlci5oYXNCdWlsdFBhdGgoZm9udENoYXIpKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGhhbmRsZXIuc2VuZCgiY29tbW9ub2JqIiwgW2dseXBoTmFtZSwgIkZvbnRQYXRoIiwgZm9udC5yZW5kZXJlci5nZXRQYXRoSnMoZm9udENoYXIpXSk7CiAgICAgIH0gY2F0Y2ggKHJlYXNvbikgewogICAgICAgIGlmIChldmFsdWF0b3JPcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBidWlsZEZvbnRQYXRocyAtIGlnbm9yaW5nICR7Z2x5cGhOYW1lfSBnbHlwaDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCBnbHlwaCBvZiBnbHlwaHMpIHsKICAgICAgYnVpbGRQYXRoKGdseXBoLmZvbnRDaGFyKTsKICAgICAgY29uc3QgYWNjZW50ID0gZ2x5cGguYWNjZW50OwogICAgICBpZiAoYWNjZW50ICYmIGFjY2VudC5mb250Q2hhcikgewogICAgICAgIGJ1aWxkUGF0aChhY2NlbnQuZm9udENoYXIpOwogICAgICB9CiAgICB9CiAgfQogIHN0YXRpYyBnZXQgZmFsbGJhY2tGb250RGljdCgpIHsKICAgIGNvbnN0IGRpY3QgPSBuZXcgX3ByaW1pdGl2ZXMuRGljdCgpOwogICAgZGljdC5zZXQoIkJhc2VGb250IiwgX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIlBERkpTLUZhbGxiYWNrRm9udCIpKTsKICAgIGRpY3Quc2V0KCJUeXBlIiwgX3ByaW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2V0RmlsbFJHQkNvbG9yOgogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNNWUtDb2xvcjoKICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yOgogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNoYWRpbmdGaWxsOgogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFJlbmRlcmluZ0ludGVudDoKICAgICAgICAgIG9wZXJhdG9yTGlzdC5mbkFycmF5LnNwbGljZShpLCAxKTsKICAgICAgICAgIG9wZXJhdG9yTGlzdC5hcmdzQXJyYXkuc3BsaWNlKGksIDEpOwogICAgICAgICAgaWktLTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgIGNvbnN0IFtnU3RhdGVPYmpdID0gb3BlcmF0b3JMaXN0LmFyZ3NBcnJheVtpXTsKICAgICAgICAgIGxldCBqID0gMCwKICAgICAgICAgICAgamogPSBnU3RhdGVPYmoubGVuZ3RoOwogICAgICAgICAgd2hpbGUgKGogPCBqaikgewogICAgICAgICAgICBjb25zdCBbZ1N0YXRlS2V5XSA9IGdTdGF0ZU9ialtqXTsKICAgICAgICAgICAgc3dpdGNoIChnU3RhdGVLZXkpIHsKICAgICAgICAgICAgICBjYXNlICJUUiI6CiAgICAgICAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgICAgICAgY2FzZSAiQkciOgogICAgICAgICAgICAgIGNhc2UgIkJHMiI6CiAgICAgICAgICAgICAgY2FzZSAiVUNSIjoKICAgICAgICAgICAgICBjYXNlICJVQ1IyIjoKICAgICAgICAgICAgICAgIGdTdGF0ZU9iai5zcGxpY2UoaiwgMSk7CiAgICAgICAgICAgICAgICBqai0tOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaisrOwogICAgICAgICAgfQog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ibGVGYWN0b3J5KShmdW5jdGlvbiAodCkgewogICAgICB0LncgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMaW5lV2lkdGgsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuSiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldExpbmVDYXAsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuaiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldExpbmVKb2luLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0Lk0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRNaXRlckxpbWl0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXREYXNoLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJpID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0UmVuZGVyaW5nSW50ZW50LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGbGF0bmVzcywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5ncyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEdTdGF0ZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5xID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2F2ZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5RID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVzdG9yZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5jbSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnRyYW5zZm9ybSwKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5tID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRvLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmwgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5saW5lVG8sCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuYyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8sCiAgICAgICAgbnVtQXJnczogNiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQudiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jdXJ2ZVRvMywKICAgICAgICBudW1BcmdzOiA0LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5oID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xvc2VQYXRoLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJlID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVjdGFuZ2xlLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQucyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmNsb3NlU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJmKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJCKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUZpbGxTdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHRbImIqIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5uID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW5kUGF0aCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5XID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdFsiVyoiXSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVvQ2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luVGV4dCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVuZFRleHQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UdyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFdvcmRTcGFjaW5nLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlR6ID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0SFNjYWxlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRMID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0TGVhZGluZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UZiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZvbnQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVHIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0UmVuZGVyaW5nTW9kZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UcyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFRleHRSaXNlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRkID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVEQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVG0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0TWF0cml4LAogICAgICAgIG51bUFyZ3M6IDYsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJUKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubmV4dExpbmUsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGogPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5USiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyInIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyciJ10gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aCwKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aEFuZEJvdW5kcywKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5DUyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yU3BhY2UsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuY3MgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ29sb3JTcGFjZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5TQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuU0NOID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JOLAogICAgICAgIG51bUFyZ3M6IDMzLAogICAgICAgIHZhcmlhYmxlQXJnczogdHJ1ZQogICAgICB9OwogICAgICB0LnNjID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuc2NuID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yTiwKICAgICAgICBudW1BcmdzOiAzMywKICAgICAgICB2YXJpYWJsZUFyZ3M6IHRydWUKICAgICAgfTsKICAgICAgdC5HID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlR3JheSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5nID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbEdyYXksCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuUkcgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5yZyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5LID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmsgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnNoID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2hhZGluZ0ZpbGwsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQkkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbklubGluZUltYWdlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LklEID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5JbWFnZURhdGEsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRUkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRJbmxpbmVJbWFnZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EbyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnBhaW50WE9iamVjdCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5NUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludFByb3BzLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJNQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CREMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FTUMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRNYXJrZWRDb250ZW50LAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJYID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5Db21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIH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Bjb25zdCBub25Qcm9jZXNzZWRBcmdzID0gdGhpcy5ub25Qcm9jZXNzZWRBcmdzOwogICAgICAgICAgICB3aGlsZSAoYXJnc0xlbmd0aCA+IG51bUFyZ3MpIHsKICAgICAgICAgICAgICBub25Qcm9jZXNzZWRBcmdzLnB1c2goYXJncy5zaGlmdCgpKTsKICAgICAgICAgICAgICBhcmdzTGVuZ3RoLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGFyZ3NMZW5ndGggPCBudW1BcmdzICYmIG5vblByb2Nlc3NlZEFyZ3MubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KG5vblByb2Nlc3NlZEFyZ3MucG9wKCkpOwogICAgICAgICAgICAgIGFyZ3NMZW5ndGgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGFyZ3NMZW5ndGggPCBudW1BcmdzKSB7CiAgICAgICAgICAgIGNvbnN0IHBhcnRpYWxNc2cgPSBgY29tbWFuZCAke2NtZH06IGV4cGVjdGVkICR7bnVtQXJnc30gYXJncywgYCArIGBidXQgcmVjZWl2ZWQgJHthcmdzTGVuZ3RofSBhcmdzLmA7CiAgICAgICAgICAgIGlmICh0aGlzLl9pc1BhdGhPcCAmJiArK3RoaXMuX251bUludmFsaWRQYXRoT1BTID4gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLk1BWF9JTlZBTElEX1BBVEhfT1BTKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFNraXBwaW5nICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgaWYgKGFyZ3MgIT09IG51bGwpIHsKICAgICAgICAgICAgICBhcmdzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhcmdzTGVuZ3RoID4gbnVtQXJncykgewogICAgICAgICAgKDAsIF91dGlsLmluZm8pKGBDb21tYW5kICR7Y21kfTogZXhwZWN0ZWQgWzAsICR7bnVtQXJnc31dIGFyZ3MsIGAgKyBgYnV0IHJlY2VpdmVkICR7YXJnc0xlbmd0aH0gYXJncy5gKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5wcmVwcm9jZXNzQ29tbWFuZChmbiwgYXJncyk7CiAgICAgICAgb3BlcmF0aW9uLmZuID0gZm47CiAgICAgICAgb3BlcmF0aW9uLmFyZ3MgPSBhcmdzOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAob2JqICE9PSBudWxsKSB7CiAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICB9CiAgICAgICAgYXJncy5wdXNoKG9iaik7CiAgICAgICAgaWYgKGFyZ3MubGVuZ3RoID4gMzMpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVG9vIG1hbnkgYXJndW1lbnRzIik7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQogIHByZXByb2Nlc3NDb21tYW5kKGZuLCBhcmdzKSB7CiAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICBjYXNlIF91dGlsLk9QUy5zYXZlOgogICAgICAgIHRoaXMuc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBfdXRpbC5PUFMucmVzdG9yZToKICAgICAgICB0aG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JheSh0aGlzLnBvcywgdGhpcy5wb3MgKyBzaXplICsgMSkpOwogICAgICB0aGlzLnBvcyArPSBzaXplICsgMTsKICAgIH0KICAgIHJlYWRIZXhOdW1iZXIobnVtLCBzaXplKSB7CiAgICAgIGxldCBsYXN0OwogICAgICBjb25zdCBzdGFjayA9IHRoaXMudG1wQnVmOwogICAgICBsZXQgc3AgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgYiA9IHRoaXMucmVhZEJ5dGUoKTsKICAgICAgICBpZiAoYiA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigidW5leHBlY3RlZCBFT0YgaW4gYmNtYXAiKTsKICAgICAgICB9CiAgICAgICAgbGFzdCA9ICEoYiAmIDB4ODApOwogICAgICAgIHN0YWNrW3NwKytdID0gYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgbGV0IGkgPSBzaXplLAogICAgICAgIGJ1ZmZlciA9IDAsCiAgICAgICAgYnVmZmVyU2l6ZSA9IDA7CiAgICAgIHdoaWxlIChpID49IDApIHsKICAgICAgICB3aGlsZSAoYnVmZmVyU2l6ZSA8IDggJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgYnVmZmVyIHw9IHN0YWNrWy0tc3BdIDw8IGJ1ZmZlclNpemU7CiAgICAgICAgICBidWZmZXJTaXplICs9IDc7CiAgICAgICAgfQogICAgICAgIG51bVtpXSA9IGJ1ZmZlciAmIDI1NTsKICAgICAgICBpLS07CiAgICAgICAgYnVmZmVyID4+PSA4OwogICAgICAgIGJ1ZmZlclNpemUgLT0gODsKICAgICAgfQogICAgfQogICAgcmVhZEhleFNpZ25lZChudW0sIHNpemUpIHsKICAgICAgdGhpcy5yZWFkSGV4TnVtYmVyKG51bSwgc2l6ZSk7CiAgICAgIGNvbnN0IHNpZ24gPSBudW1bc2l6ZV0gJiAxID8gMjU1IDogMDsKICAgICAgbGV0IGMgPSAwOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBzaXplOyBpKyspIHsKICAgICAgICBjID0gKGMgJiAxKSA8PCA4IHwgbnVtW2ldOwogICAgICAgIG51bVtpXSA9IGMgPj4gMSBeIHNpZ247CiAgICAgIH0KICAgIH0KICAgIHJlYWRTdHJpbmcoKSB7CiAgICAgIGNvbnN0IGxlbiA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICBsZXQgcyA9ICIiOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHRoaXMucmVhZE51bWJlcigpKTsKICAgICAgfQogICAgICByZXR1cm4gczsKICAgIH0KICB9CiAgY2xhc3MgQmluYXJ5Q01hcFJlYWRlciB7CiAgICBhc3luYyBwcm9jZXNzKGRhdGEsIGNNYXAsIGV4dGVuZCkgewogICAgICBjb25zdCBzdHJlYW0gPSBuZXcgQmluYXJ5Q01hcFN0cmVhbShkYXRhKTsKICAgICAgY29uc3QgaGVhZGVyID0gc3RyZWFtLnJlYWRCeXRlKCk7CiAgICAgIGNNYXAudmVydGljYWwgPSAhIShoZWFkZXIgJiAxKTsKICAgICAgbGV0IHVzZUNNYXAgPSBudWxsOwogICAgICBjb25zdCBzdGFydCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGVuZCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGNoYXIgPSBuZXcgVWludDhBcnJheShNQVhfTlVNX1NJWkUpOwogICAgICBjb25zdCBjaGFyQ29kZSA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IHRtcCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGxldCBjb2RlOwogICAgICBsZXQgYjsKICAgICAgd2hpbGUgKChiID0gc3RyZWFtLnJlYWRCeXRlKCkpID49IDApIHsKICAgICAgICBjb25zdCB0eXBlID0gYiA+PiA1OwogICAgICAgIGlmICh0eXBlID09PSA3KSB7CiAgICAgICAgICBzd2l0Y2ggKGIgJiAweDFmKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBzdHJlYW0ucmVhZFN0cmluZygpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgdXNlQ01hcCA9IHN0cmVhbS5yZWFkU3RyaW5nKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc2VxdWVuY2UgPSAhIShiICYgMHgxMCk7CiAgICAgICAgY29uc3QgZGF0YVNpemUgPSBiICYgMTU7CiAgICAgICAgaWYgKGRhdGFTaXplICsgMSA+IE1BWF9OVU1fU0laRSkgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCaW5hcnlDTWFwUmVhZGVyLnByb2Nlc3M6IEludmFsaWQgZGF0YVNpemUuIik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHVjczJEYXRhU2l6ZSA9IDE7CiAgICAgICAgY29uc3Qgc3ViaXRlbXNDb3VudCA9IHN0cmVhbS5yZWFkTnVtYmVyKCk7CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4KHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGlmICghc2VxdWVuY2UpIHsKICAgICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgICAgYWRkSGV4KGNoYXIsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWRTaWduZWQoKSArIChjb2RlICsgMSk7CiAgICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICBjTWFwLm1hcENpZFJhbmdlKGhleFRvSW50KHN0YXJ0LCBkYXRhU2l6ZSksIGhleFRvSW50KGVuZCwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHN0YXJ0LnNldChlbmQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICAgIGNNYXAubWFwQ2lkUmFuZ2UoaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSksIGNvZGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLm1hcE9uZShoZXhUb0ludChjaGFyLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBpZiAoIXNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcih0bXAsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoY2hhciwgdG1wLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpbmNIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleFNpZ25lZCh0bXAsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoY2hhckNvZGUsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwT25lKGhleFRvSW50KGNoYXIsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgY01hcC5tYXBCZlJhbmdlKGhleFRvSW50KHN0YXJ0LCB1Y3MyRGF0YVNpemUpLCBoZXhUb0ludChlbmQsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3RhcnQuc2V0KGVuZCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwQmZSYW5nZShoZXhUb0ludChzdGFydCwgdWNzMkRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgQmluYXJ5Q01hcFJlYWRlci5wcm9jZXNzIC0gdW5rbm93biB0eXBlOiAke3R5cGV9YCk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICh1c2VDTWFwKSB7CiAgICAgICAgcmV0dXJuIGV4dGVuZCh1c2VDTWFwKTsKICAgICAgfQogICAgICByZXR1cm4gY01hcDsKICAgIH0KICB9CiAgcmV0dXJuIEJpbmFyeUNNYXBSZWFkZXI7Cn0oKTsKY29uc3QgQ01hcEZhY3RvcnkgPSBmdW5jdGlvbiBDTWFwRmFjdG9yeUNsb3N1cmUoKSB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gfQogICAgICAgIGNNYXAubWFwQmZSYW5nZVRvQXJyYXkobG93LCBoaWdoLCBhcnJheSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBiZiByYW5nZS4iKTsKICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgImVuZGNpZGNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdEludChvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRSYW5nZShjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRjaWRyYW5nZSIpKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBsb3cgPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXh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yLmdldE9iaigpOwogICAgaWYgKE51bWJlci5pc0ludGVnZXIob2JqKSkgewogICAgICBjTWFwLnZlcnRpY2FsID0gISFvYmo7CiAgICB9CiAgfQogIGZ1bmN0aW9uIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpIHsKICAgIGNvbnN0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgY01hcC5uYW1lID0gb2JqLm5hbWU7CiAgICB9CiAgfQogIGFzeW5jIGZ1bmN0aW9uIHBhcnNlQ01hcChjTWFwLCBsZXhlciwgZmV0Y2hCdWlsdEluQ01hcCwgdXNlQ01hcCkgewogICAgbGV0IHByZXZpb3VzLCBlbWJlZGRlZFVzZUNNYXA7CiAgICBvYmpMb29wOiB3aGlsZSAodHJ1ZSkgewogICAgICB0cnkgewogICAgICAgIGNvbnN0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBpZiAob2JqLm5hbWUgPT09ICJXTW9kZSIpIHsKICAgICAgICAgICAgcGFyc2VXTW9kZShjTWFwLCBsZXhlcik7CiAgICAgICAgICB9IGVsc2UgaWYgKG9iai5uYW1lID09PSAiQ01hcE5hbWUiKSB7CiAgICAgICAgICAgIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpOwogICAgICAgICAgfQogICAgICAgICAgcHJldmlvdXMgPSBvYmo7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5DbWQpIHsKICAgICAgICAgIHN3aXRjaCAob2JqLmNtZCkgewogICAgICAgICAgICBjYXNlICJlbmRjbWFwIjoKICAgICAgICAgICAgICBicmVhayBvYmpMb29wOwogICAgICAgICAgICBjYXNlICJ1c2VjbWFwIjoKICAgICAgICAgICAgICBpZiAocHJldmlvdXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBlbWJlZGRlZFVzZUNNYXAgPSBwcmV2aW91cy5uYW1lOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5jb2Rlc3BhY2VyYW5nZSI6CiAgICAgICAgICAgICAgcGFyc2VDb2Rlc3BhY2VSYW5nZShjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luYmZjaGFyIjoKICAgICAgICAgICAgICBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luY2lkY2hhciI6CiAgICAgICAgICAgICAgcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5iZnJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUJmUmFuZ2UoY01hcCwgbGV4ZXIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJiZWdpbmNpZHJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUNpZFJhbmdlKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGV4OwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikoIkludmFsaWQgY01hcCBkYXRhOiAiICsgZXgpOwogICAgICAgI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Y29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5idWYxLm5hbWU7CiAgICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGljdC5zZXQoa2V5LCB0aGlzLmdldE9iaihjaXBoZXJUcmFuc2Zvcm0pKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLmJ1ZjEgPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAodGhpcy5yZWNvdmVyeU1vZGUpIHsKICAgICAgICAgICAgICByZXR1cm4gZGljdDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKHRoaXMuYnVmMiwgInN0cmVhbSIpKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLmFsbG93U3RyZWFtcyA/IHRoaXMubWFrZVN0cmVhbShkaWN0LCBjaXBoZXJUcmFuc2Zvcm0pIDogZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgIHJldHVybiBkaWN0OwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICByZXR1cm4gYnVmMTsKICAgICAgfQogICAgfQogICAgaWYgKE51bWJlci5pc0ludGVnZXIoYnVmMSkpIHsKICAgICAgaWYgKE51bWJlci5pc0ludGVnZXIodGhpcy5idWYxKSAmJiAoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKHRoaXMuYnVmMiwgIlIiKSkgewogICAgICAgIGNv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Qb3MgPSBzdHJlYW0ucG9zOwogICAgICAgICAgY29uc3QgZm9sbG93aW5nQnl0ZXMgPSBzdHJlYW0ucGVla0J5dGVzKG4pOwogICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm9sbG93aW5nQnl0ZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICBjaCA9IGZvbGxvd2luZ0J5dGVzW2ldOwogICAgICAgICAgICBpZiAoY2ggPT09IE5VTCAmJiBmb2xsb3dpbmdCeXRlc1tpICsgMV0gIT09IE5VTCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjaCAhPT0gTEYgJiYgY2ggIT09IENSICYmIChjaCA8IFNQQUNFIHx8IGNoID4gMHg3ZikpIHsKICAgICAgICAgICAgICBzdGF0ZSA9IDA7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZSAhPT0gMikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChsZXhlci5rbm93bkNvbW1hbmRzKSB7CiAgICAgICAgICAgIGNvbnN0IG5leHRPYmogPSBsZXhlci5wZWVrT2JqKCk7CiAgICAgICAgICAgIGlmIChuZXh0T2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuQ21kICYmICFsZXhlci5rbm93bkNvbW1hbmRzW25leHRPYmouY21kXSkgewogICAgICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZCAtIGBsZXhlci5rbm93bkNvbW1hbmRzYCBpcyB1bmRlZmluZWQuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgICAgYnJlYWs7Ci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0KICAgICAgc3dpdGNoIChzdHJlYW0uZ2V0Qnl0ZSgpKSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmOgogICAgICAgICAgc3RyZWFtLnNraXAoLTEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGQ5OgogICAgICAgICAgZm91bmRFT0kgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGMwOgogICAgICAgIGNhc2UgMHhjMToKICAgICAgICBjYXNlIDB4YzI6CiAgICAgICAgY2FzZSAweGMzOgogICAgICAgIGNhc2UgMHhjNToKICAgICAgICBjYXNlIDB4YzY6CiAgICAgICAgY2FzZSAweGM3OgogICAgICAgIGNhc2UgMHhjOToKICAgICAgICBjYXNlIDB4Y2E6CiAgICAgICAgY2FzZSAweGNiOgogICAgICAgIGNhc2UgMHhjZDoKICAgICAgICBjYXNlIDB4Y2U6CiAgICAgICAgY2FzZSAweGNmOgogICAgICAgIGNhc2UgMHhjNDoKICAgICAgICBjYXNlIDB4Y2M6CiAgICAgICAgY2FzZSAweGRhOgogICAgICAgIGNhc2UgMHhkYjoKICAgICAgICBjYXNlIDB4ZGM6CiAgICAgICAgY2FzZSAweGRkOgogICAgICAgIGNhc2UgMHhkZToKICAgICAgICBjYXNlIDB4ZGY6CiAgICAgICAgY2FzZSAweGUwOgogICAgICAgIGNhc2UgMHhlMToKICAgICAgICBjYXNlIDB4ZTI6CiAgICAgICAgY2FzZSAweGUzOgogICAgICAgIGNhc2UgMHhlNDoKICAgICAgICBjYXNlIDB4ZTU6CiAgICAgICAgY2FzZSAweGU2OgogICAgICAgIGNhc2UgMHhlNzoKICAgICAgICBjYXNlIDB4ZTg6CiAgICAgICAgY2FzZSAweGU5OgogICAgICAgIGNhc2UgMHhlYToKICAgICAgICBjYXNlIDB4ZWI6CiAgICAgICAgY2FzZSAweGVjOgogICAgICAgIGNhc2UgMHhlZDoKICAgICAg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gKTsKICAgICAgICByZXR1cm4gMDsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IobXNnKTsKICAgIH0KICAgIHNpZ24gPSBzaWduIHx8IDE7CiAgICBsZXQgYmFzZVZhbHVlID0gY2ggLSAweDMwOwogICAgbGV0IHBvd2VyVmFsdWUgPSAwOwogICAgbGV0IHBvd2VyVmFsdWVTaWduID0gMTsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDApIHsKICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzOSkgewogICAgICAgIGNvbnN0IGN1cnJlbnREaWdpdCA9IGNoIC0gMHgzMDsKICAgICAgICBpZiAoZU5vdGF0aW9uKSB7CiAgICAgICAgICBwb3dlclZhbHVlID0gcG93ZXJWYWx1ZSAqIDEwICsgY3VycmVudERpZ2l0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgICAgICAgZGl2aWRlQnkgKj0gMTA7CiAgICAgICAgICB9CiAgICAgICAgICBiYXNlVmFsdWUgPSBiYXNlVmFsdWUgKiAxMCArIGN1cnJlbnREaWdpdDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MmUpIHsKICAgICAgICBpZiAoZGl2aWRlQnkgPT09IDApIHsKICAgICAgICAgIGRpdmlkZUJ5ID0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDJkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJCYWRseSBmb3JtYXR0ZWQgbnVtYmVyOiBtaW51cyBzaWduIGluIHRoZSBtaWRkbGUiKTsKICAgICAgfSBlbHNlIGlmIChjaCA9PT0gMHg0NSB8fCBjaCA9PT0gMHg2NSkgewogICAgICAgIGNoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICAgIGlmIChjaCA9PT0gMHgyYiB8fCBjaCA9PT0gMHgyZCkgewogICAgICAgICAgcG93ZXJWYWx1ZVNpZ24gPSBjaCA9PT0gMHgyZCA/IC0xIDogMTsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB9IGVsc2UgaWYgKGNoIDwgMHgzMCB8fCBjaCA+IDB4MzkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlTm90YXRpb24gPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgYmFzZVZhbHVlIC89IGRpdmlkZUJ5OwogICAgfQogICAgaWYgKGVOb3RhdGlvbikgewogICAgICBiYXNlVmFsdWUgKj0gMTAgKiogKHBvd2VyVmFsdWVTaWduICogcG93ZXJWYWx1ZSk7CiAgICB9CiAgICByZXR1cm4gc2lnbiAqIGJhc2VWYWx1ZTsKICB9CiAgZ2V0U3RyaW5nKCkgewogICAgbGV0IG51bVBhcmVuID0gMTsKICAgIGxldCBkb25lID0gZmFsc2U7CiAgICBjb25zdCBzdHJCdWYgPSB0aGlzLnN0ckJ1ZjsKICAgIHN0ckJ1Zi5sZW5ndGggPSAwOwogICAgbGV0IGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IGNoYXJCdWZmZXJlZCA9IGZhbHNlOwogICAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICAgIGNhc2UgLTE6CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBzdHJpbmciKTsKICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI4OgogICAgICAgICAgKytudW1QYXJlbjsKICAgICAgICAgIHN0ckJ1Zi5wdXNoKCIoIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4Mjk6CiAgICAgICAgICBpZiAoLS1udW1QYXJlbiA9PT0gMCkgewogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQnVmLnB1c2goIikiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHg1YzoKICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgc3dpdGNoIChjaCkgewogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW50ZXJtaW5hdGVkIHN0cmluZyIpOwogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NmU6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxuIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg3MjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXHIiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDc0OgogICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKCJcdCIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NjI6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxiIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg2NjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXGYiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDVjOgogICAgICAgICAgICBjYXNlIDB4Mjg6CiAgICAgICAgICAgIGNhc2UgMHgyOToKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgzMDoKICAgICAgICAgICAgY2FzZSAweDMxOgogICAgICAgICAgICBjYXNlIDB4MzI6CiAgICAgICAgICAgIGNhc2UgMHgzMzoKICAgICAgICAgICAgY2FzZSAweDM0OgogICAgICAgICAgICBjYXNlIDB4MzU6CiAgICAgICAgICAgIGNhc2UgMHgzNjoKICAgICAgICAgICAgY2FzZSAweDM3OgogICAgICAgICAgICAgIGxldCB4ID0gY2ggJiAweDBmOwogICAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICAgIGNoYXJCdWZmZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzNykgewogICAgICAgICAgICAgICAgeCA9ICh4IDw8IDMpICsgKGNoICYgMHgwZik7CiAgICAgICAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA+PSAweDMwICYmIGNoIDw9IDB4MzcpIHsKICAgICAgICAgICAgICAgICAgY2hhckJ1ZmZlcmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHggPSAoeCA8PCAzKSArIChjaCAmIDB4MGYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHgpKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDBkOgogICAgICAgICAgICAgIGlmICh0aGlzLnBlZWtDaGFyKCkgPT09IDB4MGEpIHsKICAgICAgICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgwYToKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgc3RyQnVmLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjaCkpOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGRvbmUpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoIWNoYXJCdWZmZXJlZCkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXROYW1lKCkgewogICAgbGV0IGNoLCBwcmV2aW91c0NoOwogICAgY29uc3Qgc3RyQnVmID0gdGhpcy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDAgJiYgIXNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgaWYgKGNoID09PSAweDIzKSB7CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKHNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiTGV4ZXJfZ2V0TmFtZTogIiArICJOVU1CRVIgU0lHTiAoIykgc2hvdWxkIGJlIGZvbGxvd2VkIGJ5IGEgaGV4YWRlY2ltYWwgbnVtYmVyLiIpOwogICAgICAgICAgc3RyQnVmLnB1c2goIiMiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBjb25zdCB4ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgaWYgKHggIT09IC0xKSB7CiAgICAgICAgICBwcmV2aW91c0NoID0gY2g7CiAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIGNvbnN0IHgyID0gd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AgICAgICBmaXJzdERpZ2l0ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoZmlyc3REaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgc2Vjb25kRGlnaXQgPSB0b0hleERpZ2l0KGNoKTsKICAgICAgICAgIGlmIChzZWNvbmREaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoZmlyc3REaWdpdCA8PCA0IHwgc2Vjb25kRGlnaXQpKTsKICAgICAgICB9CiAgICAgICAgaXNGaXJzdEhleCA9ICFpc0ZpcnN0SGV4OwogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXRPYmooKSB7CiAgICBsZXQgY29tbWVudCA9IGZhbHNlOwogICAgbGV0IGNoID0gdGhpcy5jdXJyZW50Q2hhcjsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuRU9GOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSAhPT0gMSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgc3dpdGNoIChjaCB8IDApIHsKICAgICAgY2FzZSAweDMwOgogICAgICBjYXNlIDB4MzE6CiAgICAgIGNhc2UgMHgzMjoKICAgICAgY2FzZSAweDMzOgogICAgICBjYXNlIDB4MzQ6CiAgICAgIGNhc2UgMHgzNToKICAgICAgY2FzZSAweDM2OgogICAgICBjYXNlIDB4Mzc6CiAgICAgIGNhc2UgMHgzODoKICAgICAgY2FzZSAweDM5OgogICAgICBjYXNlIDB4MmI6CiAgICAgIGNhc2UgMHgyZDoKICAgICAgY2FzZSAweDJlOgogICAgICAgIHJldHVybiB0aGlzLmdldE51bWJlcigpOwogICAgICBjYXNlIDB4Mjg6CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgyZjoKICAgICAgICByZXR1cm4gdGhpcy5nZXROYW1lKCk7CiAgICAgIGNhc2UgMHg1YjoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIlsiKTsKICAgICAgY2FzZSAweDVkOgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiXSIpOwogICAgICBjYXNlIDB4M2M6CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKGNoID09PSAweDNjKSB7CiAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPDwiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0SGV4U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgzZToKICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCI+PiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPiIpOwogICAgICBjYXNlIDB4N2I6CiAgICAgICAgdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCJ7Iik7CiAgICAgIGNhc2UgMHg3ZDoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIn0iKTsKICAgICAgY2FzZSAweDI5OgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYElsbGVnYWwgY2hhcmFjdGVyOiAke2NofWApOwogICAgfQogICAgbGV0IHN0ciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgaWYgKGNoIDwgMHgyMCB8fCBjaCA+IDB4N2YpIHsKICAgICAgY29uc3QgbmV4dENoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICBpZiAobmV4dENoID49IDB4MjAgJiYgbmV4dENoIDw9IDB4N2YpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICAgICAgfQogICAgfQogICAgY29uc3Qga25vd25Db21tYW5kcyA9IHRoaXMua25vd25Db21tYW5kczsKICAgIGxldCBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB3aGlsZSAoKGNoID0gdGhpcy5uZXh0Q2hhcigpKSA+PSAwICYmICFzcGVjaWFsQ2hhcnNbY2hdKSB7CiAgICAgIGNvbnN0IHBvc3NpYmxlQ29tbWFuZCA9IHN0ciArIFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICBpZiAoa25vd25Db21tYW5kRm91bmQgJiYga25vd25Db21tYW5kc1twb3NzaWJsZUNvbW1hbmRdID09PSB1bmRlZmluZWQpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMTI4KSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBDb21tYW5kIHRva2VuIHRvbyBsb25nOiAke3N0ci5sZW5ndGh9YCk7CiAgICAgIH0KICAgICAgc3RyID0gcG9zc2libGVDb21tYW5kOwogICAgICBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB9CiAgICBpZiAoc3RyID09PSAidHJ1ZSIpIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBpZiAoc3RyID09PSAiZmFsc2UiKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmIChzdHIgPT09ICJudWxsIikgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGlmIChzdHIgPT09ICJCSSIpIHsKICAgICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5zdHJlYW0ucG9zOwogICAgfQogICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICB9CiAgcGVla09iaigpIHsKICAgIGNvbnN0IHN0cmVhbVBvcyA9IHRoaXMuc3RyZWFtLnBvcywKICAgICAgY3VycmVudENoYXIgPSB0aGlzLmN1cnJlbnRDaGFyLAogICAgICBiZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5iZWdpbklubGluZUltYWdlUG9zOwogICAgbGV0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tZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgIGNvbnN0IG9iaiA9IGxpbkRpY3QuZ2V0KG5hbWUpOwogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopICYmIChhbGxvd1plcm9WYWx1ZSA/IG9iaiA+PSAwIDogb2JqID4gMCkpIHsKICAgICAgICByZXR1cm4gb2JqOwogICAgICB9CiAgICAgIHRocm93IG5ldyBFcnJvcihgVGhlICIke25hbWV9IiBwYXJhbWV0ZXIgaW4gdGhlIGxpbmVhcml6YXRpb24gYCArICJkaWN0aW9uYXJ5IGlzIGludmFsaWQuIik7CiAgICB9CiAgICBmdW5jdGlvbiBnZXRIaW50cyhsaW5EaWN0KSB7CiAgICAgIGNvbnN0IGhpbnRzID0gbGluRGljdC5nZXQoIkgiKTsKICAgICAgbGV0IGhpbnRzTGVuZ3RoOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShoaW50cykgJiYgKChoaW50c0xlbmd0aCA9IGhpbnRzLmxlbmd0aCkgPT09IDIgfHwgaGludHNMZW5ndGggPT09IDQpKSB7CiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwOyBpbmRleCA8IGhpbnRzTGVuZ3RoOyBpbmRleCsrKSB7CiAgICAgICAgICBjb25zdCBoaW50ID0gaGludHNbaW5kZXhdOwogICAgICAgICAgaWYgKCEoTnVtYmVyLmlzSW50ZWdlcihoaW50KSAmJiBoaW50ID4gMCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBIaW50ICgke2luZGV4fSkgaW4gdGhlIGxpbmVhcml6YXRpb24gZGljdGlvbmFyeSBpcyBpbnZhbGlkLmApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gaGludHM7CiAgICAgIH0KICAgICAgdGhyb3cgbmV3IEVycm9yKCJIaW50IGFycmF5IGluIHRoZSBsaW5lYXJpemF0aW9uIGRpY3Rpb25hcnkgaXMgaW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gY29uc3Qgc291cmNlID0gewogICAgICBuZXh0KCkgewogICAgICAgIHJldHVybiBzdHIuZ2V0Qnl0ZSgpOwogICAgICB9CiAgICB9OwogICAgdGhpcy5jY2l0dEZheERlY29kZXIgPSBuZXcgX2NjaXR0LkNDSVRURmF4RGVjb2Rlcihzb3VyY2UsIHsKICAgICAgSzogcGFyYW1zLmdldCgiSyIpLAogICAgICBFbmRPZkxpbmU6IHBhcmFtcy5nZXQoIkVuZE9mTGluZSIpLAogICAgICBFbmNvZGVkQnl0ZUFsaWduOiBwYXJhbXMuZ2V0KCJFbmNvZGVkQnl0ZUFsaWduIiksCiAgICAgIENvbHVtbnM6IHBhcmFtcy5nZXQoIkNvbHVtbnMiKSwKICAgICAgUm93czogcGFyYW1zLmdldCgiUm93cyIpLAogICAgICBFbmRPZkJsb2NrOiBwYXJhbXMuZ2V0KCJFbmRPZkJsb2NrIiksCiAgICAgIEJsYWNrSXMxOiBwYXJhbXMuZ2V0KCJCbGFja0lzMSIpCiAgICB9KTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgd2hpbGUgKCF0aGlzLmVvZikgewogICAgICBjb25zdCBjID0gdGhpcy5jY2l0dEZheERlY29kZXIucmVhZE5leHRDaGFyKCk7CiAgICAgIGlmIChjID09PSAtMSkgewogICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgdGhpcy5lbnN1cmVCdWZmZXIodGhpcy5idWZmZXJMZW5ndGggKyAxKTsKICAgICAgdGhpcy5idWZmZXJbdGhpcy5idWZmZXJMZW5ndGgrK10gPSBjOwogICAgfQogIH0KfQpleHBvcnRzLkNDSVRURmF4U3RyZWFtID0gQ0NJVFRGYXhTdHJlYW07CgovKioqLyB9KSwKLyogMTU2ICovCi8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiJ1c2Ugc3RyaWN0IjsKCg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pIHsKICAgIGlmICh0aGlzLmVvZikgewogICAgICByZXR1cm4gLTE7CiAgICB9CiAgICBjb25zdCByZWZMaW5lID0gdGhpcy5yZWZMaW5lOwogICAgY29uc3QgY29kaW5nTGluZSA9IHRoaXMuY29kaW5nTGluZTsKICAgIGNvbnN0IGNvbHVtbnMgPSB0aGlzLmNvbHVtbnM7CiAgICBsZXQgcmVmUG9zLCBibGFja1BpeGVscywgYml0cywgaTsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPT09IDApIHsKICAgICAgaWYgKHRoaXMucm93c0RvbmUpIHsKICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9mKSB7CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIHRoaXMuZXJyID0gZmFsc2U7CiAgICAgIGxldCBjb2RlMSwgY29kZTIsIGNvZGUzOwogICAgICBpZiAodGhpcy5uZXh0TGluZTJEKSB7CiAgICAgICAgZm9yIChpID0gMDsgY29kaW5nTGluZVtpXSA8IGNvbHVtbnM7ICsraSkgewogICAgICAgICAgcmVmTGluZVtpXSA9IGNvZGluZ0xpbmVbaV07CiAgICAgICAgfQogICAgICAgIHJlZkxpbmVbaSsrXSA9IGNvbHVtbnM7CiAgICAgICAgcmVmTGluZVtpXSA9IGNvbHVtbnM7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIHJlZlBvcyA9IDA7CiAgICAgICAgYmxhY2tQaXhlbHMgPSAwOwogICAgICAgIHdoaWxlIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fZ2V0VHdvRGltQ29kZSgpOwogICAgICAgICAgc3dpdGNoIChjb2RlMSkgewogICAgICAgICAgICBjYXNlIHR3b0RpbVBhc3M6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zICsgMV0sIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBpZiAocmVmTGluZVtyZWZQb3MgKyAxXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1Ib3JpejoKICAgICAgICAgICAgICBjb2RlMSA9IGNvZGUyID0gMDsKICAgICAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTEgKz0gY29kZTMgPSB0aGlzLl9nZXRCbGFja0NvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTIgKz0gY29kZTMgPSB0aGlzLl9nZXRXaGl0ZUNvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMiArPSBjb2RlMyA9IHRoaXMuX2dldEJsYWNrQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVscyhjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSArIGNvZGUyLCBibGFja1BpeGVscyBeIDEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjM6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDMsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjE6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDEsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0MDoKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMocmVmTGluZVtyZWZQb3NdLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgdHdvRGltVmVydEwzOgogICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVsc05lZyhyZWZMaW5lW3JlZlBvc10gLSAzLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICBpZiAocmVmUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAtLXJlZlBvczsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0TDI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzTmVnKHJlZkxpbmVbcmVmUG9zXSAtIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIGlmIChyZWZQb3MgPiAwKSB7CiAgICAgICAgICAgICAgICAgIC0tcmVmUG9zOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgKytyZWZQb3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICAgcmVmUG9zICs9IDI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIHR3b0RpbVZlcnRMMToKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHNOZWcocmVmTGluZVtyZWZQb3NdIC0gMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGJsYWNrUGl4ZWxzIF49IDE7CiAgICAgICAgICAgICAgaWYgKGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgaWYgKHJlZlBvcyA+IDApIHsKICAgICAgICAgICAgICAgICAgLS1yZWZQb3M7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgY2NpdHRFT0Y6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCAyZCBjb2RlIik7CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIGJsYWNrUGl4ZWxzID0gMDsKICAgICAgICB3aGlsZSAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICBjb2RlMSA9IDA7CiAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGNvZGUxICs9IGNvZGUzID0gdGhpcy5fZ2V0QmxhY2tDb2RlKCk7CiAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICB9IHdoaWxlIChjb2RlMyA+PSA2NCk7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGdvdEVPTCA9IGZhbHNlOwogICAgICBpZiAodGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICB0aGlzLmlucHV0Qml0cyAmPSB+NzsKICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9ibG9jayAmJiB0aGlzLnJvdyA9PT0gdGhpcy5yb3dzIC0gMSkgewogICAgICAgIHRoaXMucm93c0RvbmUgPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgIGlmICh0aGlzLmVvbGluZSkgewogICAgICAgICAgd2hpbGUgKGNvZGUxICE9PSBjY2l0dEVPRiAmJiBjb2RlMSAhPT0gMSkgewogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2hpbGUgKGNvZGUxID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgZ290RU9MID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9mICYmIHRoaXMuZW5jb2RpbmcgPiAwICYmICF0aGlzLnJvd3NEb25lKSB7CiAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIXRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9ibG9jayAmJiBnb3RFT0wgJiYgdGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgIHRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPj0gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgICAgICAgY29kZTEgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgICAgICAgICAgaWYgKGNvZGUxICE9PSAxKSB7CiAgICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBydGMgY29kZTogIiArIGNvZGUxKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLl9sb29rQml0cygxKTsKICAgICAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHRoaXMuZXJyICYmIHRoaXMuZW9saW5lKSB7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTMpOwogICAgICAgICAgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlMSA+PiAxID09PSAxKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIShjb2RlMSAmIDEpOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29kaW5nTGluZVswXSA+IDApIHsKICAgICAgICB0aGlzLm91dHB1dEJpdHMgPSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zID0gMF07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyA9IDFdOwogICAgICB9CiAgICAgIHRoaXMucm93Kys7CiAgICB9CiAgICBsZXQgYzsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPj0gOCkgewogICAgICBjID0gdGhpcy5jb2RpbmdQb3MgJiAxID8gMCA6IDB4ZmY7CiAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSA4OwogICAgICBpZiAodGhpcy5vdXRwdXRCaXRzID09PSAwICYmIGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gLSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zIC0gMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGJpdHMgPSA4OwogICAgICBjID0gMDsKICAgICAgZG8gewogICAgICAgIGlmICh0eXBlb2YgdGhpcy5vdXRwdXRCaXRzICE9PSAibnVtYmVyIikgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdJbnZhbGlkIC9DQ0lUVEZheERlY29kZSBkYXRhLCAib3V0cHV0Qml0cyIgbXVzdCBiZSBhIG51bWJlci4nKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3V0cHV0Qml0cyA+IGJpdHMpIHsKICAgICAgICAgIGMgPDw9IGJpdHM7CiAgICAgICAgICBpZiAoISh0aGlzLmNvZGluZ1BvcyAmIDEpKSB7CiAgICAgICAgICAgIGMgfD0gMHhmZiA+PiA4IC0gYml0czsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSBiaXRzOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGMgPDw9IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIGlmICghKHRoaXMuY29kaW5nUG9zICYgMSkpIHsKICAgICAgICAgICAgYyB8PSAweGZmID4+IDggLSB0aGlzLm91dHB1dEJpdHM7CiAgICAgICAgICB9CiAgICAgICAgICBiaXRzIC09IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IDA7CiAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIC0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyAtIDFdOwogICAgICAgICAgfSBlbHNlIGlmIChiaXRzID4gMCkgewogICAgICAgICAgICBjIDw8PSBiaXRzOwogICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gd2hpbGUgKGJpdHMpOwogICAgfQogICAgaWYgKHRoaXMuYmxhY2spIHsKICAgICAgYyBePSAweGZmOwogICAgfQogICAgcmV0dXJuIGM7CiAgfQogIF9hZGRQaXhlbHMoYTEsIGJsYWNrUGl4ZWxzKSB7CiAgICBjb25zdCBjb2RpbmdMaW5lID0gdGhpcy5jb2R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B7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cyg3KTsKICAgICAgcCA9IHR3b0RpbVRhYmxlW2NvZGVdOwogICAgICBpZiAocCAmJiBwWzBdID4gMCkgewogICAgICAgIHRoaXMuX2VhdEJpdHMocFswXSk7CiAgICAgICAgcmV0dXJuIHBbMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGNvbnN0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgNywgdHdvRGltVGFibGUpOwogICAgICBpZiAocmVzdWx0WzBdICYmIHJlc3VsdFsyXSkgewogICAgICAgIHJldHVybiByZXN1bHRbMV07CiAgICAgIH0KICAgIH0KICAgICgwLCBfdXRpbC5pbmZvKSgiQmFkIHR3byBkaW0gY29kZSIpOwogICAgcmV0dXJuIGNjaXR0RU9GOwogIH0KICBfZ2V0V2hpdGVDb2RlKCkgewogICAgbGV0IGNvZGUgPSAwOwogICAgbGV0IHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDUgPT09IDApIHsKICAgICAgICBwID0gd2hpdGVUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcCA9IHdoaXRlVGFibGUyW2NvZGUgPj4gM107CiAgICAgIH0KICAgICAgaWYgKHBbMF0gPiAwKSB7CiAgICAgICAgdGhpcy5fZWF0Qml0cyhwWzBdKTsKICAgICAgICByZXR1cm4gcFsxXTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgOSwgd2hpdGVUYWJsZTIpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgICByZXN1bHQgPSB0aGlzLl9maW5kVGFibGVDb2RlKDExLCAxMiwgd2hpdGVUYWJsZTEpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgfQogICAgKDAsIF91dGlsLmluZm8pKCJiYWQgd2hpdGUgY29kZSIpOwogICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIHJldHVybiAxOwogIH0KICBfZ2V0QmxhY2tDb2RlKCkgewogICAgbGV0IGNvZGUsIHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMyk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDcgPT09IDApIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSBpZiAoY29kZSA+PiA5ID09PSAwICYmIGNvZGUgPj4gNyAhPT0gMCkgewogICAgICAgIHAgPSBibGFja1RhYmxlMlsoY29kZSA+PiAxKSAtIDY0XTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTNbY29kZSA+PiA3XTsKICAgICAgfQogICAgICBpZiAocFswXSA+IDApIHsKICAgICAgICB0aGlzLl9lYXRCaXRzKHBbMF0pOwogICAgICAgIHJldHVybiBwWzFdOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fZmluZFRhYmxlQ29kZSgyLCA2LCBibGFja1RhYmxlMyk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoNywgMTIsIGJsYWNrVGFibGUyLCA2NCk7CiAgICAgIGlmIChyZXN1bHRb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lbmd0aHMubGVuZ3RoOwogICAgbGV0IG1heExlbiA9IDA7CiAgICBsZXQgaTsKICAgIGZvciAoaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgaWYgKGxlbmd0aHNbaV0gPiBtYXhMZW4pIHsKICAgICAgICBtYXhMZW4gPSBsZW5ndGhzW2ldOwogICAgICB9CiAgICB9CiAgICBjb25zdCBzaXplID0gMSA8PCBtYXhMZW47CiAgICBjb25zdCBjb2RlcyA9IG5ldyBJbnQzMkFycmF5KHNpemUpOwogICAgZm9yIChsZXQgbGVuID0gMSwgY29kZSA9IDAsIHNraXAgPSAyOyBsZW4gPD0gbWF4TGVuOyArK2xlbiwgY29kZSA8PD0gMSwgc2tpcCA8PD0gMSkgewogICAgICBmb3IgKGxldCB2YWwgPSAwOyB2YWwgPCBuOyArK3ZhbCkgewogICAgICAgIGlmIChsZW5ndGhzW3ZhbF0gPT09IGxlbikgewogICAgICAgICAgbGV0IGNvZGUyID0gMDsKICAgICAgICAgIGxldCB0ID0gY29kZTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgICBjb2RlMiA9IGNvZGUyIDw8IDEgfCB0ICYgMTsKICAgICAgICAgICAgdCA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGNvZGUyOyBpIDwgc2l6ZTsgaSArPSBza2lwKSB7CiAgICAgICAgICAgIGNvZGVzW2ldID0gbGVuIDw8IDE2IHwgdmFsOwogICAgICAgICAgfQogICAgICAgICAgKytjb2RlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtjb2RlcywgbWF4TGVuXTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgbGV0IGJ1ZmZlciwgbGVuOwogICAgY29uc3Qgc3RyID0gdGhpcy5zdHI7CiAgICBsZXQgaGRyID0gdGhpcy5nZXRCaXRzKDMpOwogICAgaWYgKGhkciAmIDEpIHsKICAgICAgdGhpcy5lb2YgPS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xlbmd0aHMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuQ29kZU1hcC5sZW5ndGgpOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUNvZGVMZW5Db2RlczsgKytpKSB7CiAgICAgICAgY29kZUxlbkNvZGVMZW5ndGhzW2NvZGVMZW5Db2RlTWFwW2ldXSA9IHRoaXMuZ2V0Qml0cygzKTsKICAgICAgfQogICAgICBjb25zdCBjb2RlTGVuQ29kZVRhYiA9IHRoaXMuZ2VuZXJhdGVIdWZmbWFuVGFibGUoY29kZUxlbkNvZGVMZW5ndGhzKTsKICAgICAgbGVuID0gMDsKICAgICAgaSA9IDA7CiAgICAgIGNvbnN0IGNvZGVzID0gbnVtTGl0Q29kZXMgKyBudW1EaXN0Q29kZXM7CiAgICAgIGNvbnN0IGNvZGVMZW5ndGhzID0gbmV3IFVpbnQ4QXJyYXkoY29kZXMpOwogICAgICBsZXQgYml0c0xlbmd0aCwgYml0c09mZnNldCwgd2hhdDsKICAgICAgd2hpbGUgKGkgPCBjb2RlcykgewogICAgICAgIGNvbnN0IGNvZGUgPSB0aGlzLmdldENvZGUoY29kZUxlbkNvZGVUYWIpOwogICAgICAgIGlmIChjb2RlID09PSAxNikgewogICAgICAgICAgYml0c0xlbmd0aCA9IDI7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW47CiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAxNykgewogICAgICAgICAgYml0c0xlbmd0aCA9IDM7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW4gPSAwOwogICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gMTgpIHsKICAgICAgICAgIGJpdHNMZW5ndGggPSA3OwogICAgICAgICAgYml0c09mZnNldCA9IDExOwogICAgICAgICAgd2hhdCA9IGxlbiA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIG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gIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChjb2RlMSA9PT0gMjU2KSB7CiAgICAgICAgdGhpcy5idWZmZXJMZW5ndGggPSBwb3M7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvZGUxIC09IDI1NzsKICAgICAgY29kZTEgPSBsZW5ndGhEZWNvZGVbY29kZTFdOwogICAgICBsZXQgY29kZTIgPSBjb2RlMSA+PiAxNjsKICAgICAgaWYgKGNvZGUyID4gMCkgewogICAgICAgIGNvZGUyID0gdGhpcy5nZXRCaXRzKGNvZGUyKTsKICAgICAgfQogICAgICBsZW4gPSAoY29kZTEgJiAweGZmZmYpICsgY29kZTI7CiAgICAgIGNvZGUxID0gdGhpcy5nZXRDb2RlKGRpc3RDb2RlVGFibGUpOwogICAgICBjb2RlMSA9IGRpc3REZWNvZGVbY29kZTFdOwogICAgICBjb2RlMiA9IGNvZGUxID4+IDE2OwogICAgICBpZiAoY29kZTIgPiAwKSB7CiAgICAgICAgY29kZTIgPSB0aGlzLmdldEJpdHMoY29kZTIpOwogICAgICB9CiAgICAgIGNvbnN0IGRpc3QgPSAoY29kZTEgJiAweGZmZmYpICsgY29kZTI7CiAgICAgIGlmIChwb3MgKyBsZW4gPj0gbGltaXQpIHsKICAgICAgICBidWZmZXIgPSB0aGlzLmVuc3VyZUJ1ZmZlcihwb3MgKyBsZW4pOwogICAgICAgIGxpbWl0ID0gYnVmZmVyLmxlbmd0aDsKICAgICAgfQogICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxlbjsgKytrLCArK3BvcykgewogICAgICAgIGJ1ZmZlcltwb3NdID0gYnVmZmVyW3BvcyAtIGRpc3RdOwogICAgICB9CiAgICB9CiAgfQp9CmV4cG9ydHMuRmxhdGVTdHJlYW0gPSBGbGF0ZVN0cmVhbTsKCi8qKiovIH0pLAovKiAxNTggKi8KLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3Jlc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mVuY2U6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAwLAogICAgeTogMAogIH0sIHsKICAgIHg6IDEsCiAgICB5OiAwCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAxCiAgfSwgewogICAgeDogMCwKICAgIHk6IDEKICB9LCB7CiAgICB4OiAxLAogICAgeTogMQogIH1dCn0sIHsKICBjb2Rpbmc6IFt7CiAgICB4OiAtMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfV0sCiAgcmVmZXJlbmNlOiBbewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfSwgewogICAgeDogMCwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAxLAogICAgeTogMAogIH0sIHsKICAgIHg6IDAsCiAgICB5OiAxCiAgfSwgewogICAgeDogMSwKICAgIHk6IDEKICB9XQp9XTsKY29uc3QgUmV1c2VkQ29udGV4dHMgPSBbMHg5YjI1LCAweDA3OTUsIDB4MDBlNSwgMHgwMTk1XTsKY29uc3QgUmVmaW5lbWVudFJldXNlZENvbnRleHRzID0gWzB4MDAyMCwgMHgwMDA4XTsKZnVuY3Rpb24gZGVjb2RlQml0bWFwVGVtcGxhdGUwKHdpZHRoLCBoZWlnaHQsIGRlY29kaW5nQ29udGV4dCkgewogIGNvbnN0IGRlY29kZXIgPSBkZWNvZGluZ0NvbnRleHQuZGVjb2RlcjsKICBjb25zdCBjb250ZXh0cyA9IGRlY29kaW5nQ29udGV4dC5jb250ZXh0Q2FjaGUuZ2V0Q29udGV4dHMoIkdCIik7CiAgY29uc3QgYml0bWFwID0gW107CiAgbGV0IGNvbnRleHRMYWJlbCwgaSwgaiw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2luZ1RlbXBsYXRlWVtjXSA9IHRlbXBsYXRlW2tdLnk7CiAgICBjaGFuZ2luZ1RlbXBsYXRlQml0W2NdID0gMSA8PCB0ZW1wbGF0ZUxlbmd0aCAtIDEgLSBrOwogIH0KICBjb25zdCBzYmJfbGVmdCA9IC1taW5YOwogIGNvbnN0IHNiYl90b3AgPSAtbWluWTsKICBjb25zdCBzYmJfcmlnaHQgPSB3aWR0aCAtIG1heFg7CiAgY29uc3QgcHNldWRvUGl4ZWxDb250ZXh0ID0gUmV1c2VkQ29udGV4dHNbdGVtcGxhdGVJbmRleF07CiAgbGV0IHJvdyA9IG5ldyBVaW50OEFycmF5KHdpZHRoKTsKICBjb25zdCBiaXRtYXAgPSBbXTsKICBjb25zdCBkZWNvZGVyID0gZGVjb2RpbmdDb250ZXh0LmRlY29kZXI7CiAgY29uc3QgY29udGV4dHMgPSBkZWNvZGluZ0NvbnRleHQuY29udGV4dENhY2hlLmdldENvbnRleHRzKCJHQiIpOwogIGxldCBsdHAgPSAwLAogICAgaiwKICAgIGkwLAogICAgajAsCiAgICBjb250ZXh0TGFiZWwgPSAwLAogICAgYml0LAogICAgc2hpZnQ7CiAgZm9yIChsZXQgaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgaWYgKHByZWRpY3Rpb24pIHsKICAgICAgY29uc3Qgc2x0cCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgcHNldWRvUGl4ZWxDb250ZXh0KTsKICAgICAgbHRwIF49IHNsdHA7CiAgICAgIGlmIChsdHApIHsKICAgICAgICBiaXRtYXAucHVzaChyb3cpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICByb3cgPSBuZXcgVWludDhBcnJheShyb3cpOwogICAgYml0bWFwLnB1c2gocm93KTsKICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGlmICh1c2Vza2lwICYmIHNraXBbaV1bal0pIHsKICAgICAgICByb3dbal0gPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChqID49IHNiYl9sZWZ0ICYmIGogPCBzYmJfcmlnaHQgJiYgaSA+PSBzYmJfdG9wKSB7CiAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgJiByZXVzZU1hc2s7CiAgICAgICAgZm9yIChrID0gMDsgayA8IGNoYW5naW5nRW50cmllc0xlbmd0aDsgaysrKSB7CiAgICAgICAgICBpMCA9IGkgKyBjaGFuZ2luZ1RlbXBsYXRlWVtrXTsKICAgICAgICAgIGowID0gaiArIGNoYW5naW5nVGVtcGxhdGVYW2tdOwogICAgICAgICAgYml0ID0gYml0bWFwW2kwXVtqMF07CiAgICAgICAgICBpZiAoYml0KSB7CiAgICAgICAgICAgIGJpdCA9IGNoYW5naW5nVGVtcGxhdGVCaXRba107CiAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDA7CiAgICAgICAgc2hpZnQgPSB0ZW1wbGF0ZUxlbmd0aCAtIDE7CiAgICAgICAgZm9yIChrID0gMDsgayA8IHRlbXBsYXRlTGVuZ3RoOyBrKyssIHNoaWZ0LS0pIHsKICAgICAgICAgIGowID0gaiArIHRlbXBsYXRlWFtrXTsKICAgICAgICAgIGlmIChqMCA+PSAwICYmIGowIDwgd2lkdGgpIHsKICAgICAgICAgICAgaTAgPSBpICsgdGVtcGxhdGVZW2tdOwogICAgICAgICAgICBpZiAoaTAgPj0gMCkgewogICAgICAgICAgICAgIGJpdCA9IGJpdG1hcFtpMF1bajBdOwogICAgICAgICAgICAgIGlmIChiaXQpIHsKICAgICAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQgPDwgc2hpZnQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGN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B7CiAgICAgIGNvbnN0IHNsdHAgPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIHBzZXVkb1BpeGVsQ29udGV4dCk7CiAgICAgIGx0cCBePSBzbHRwOwogICAgICBpZiAobHRwKSB7CiAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoInByZWRpY3Rpb24gaXMgbm90IHN1cHBvcnRlZCIpOwogICAgICB9CiAgICB9CiAgICBjb25zdCByb3cgPSBuZXcgVWludDhBcnJheSh3aWR0aCk7CiAgICBiaXRtYXAucHVzaChyb3cpOwogICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGxldCBpMCwgajA7CiAgICAgIGxldCBjb250ZXh0TGFiZWwgPSAwOwogICAgICBmb3IgKGsgPSAwOyBrIDwgY29kaW5nVGVtcGxhdGVMZW5ndGg7IGsrKykgewogICAgICAgIGkwID0gaSArIGNvZGluZ1RlbXBsYXRlWVtrXTsKICAgICAgICBqMCA9IGogKyBjb2RpbmdUZW1wbGF0ZVhba107CiAgICAgICAgaWYgKGkwIDwgMCB8fCBqMCA8IDAgfHwgajAgPj0gd2lkdGgpIHsKICAgICAgICAgIGNvbnRleHRMYWJlbCA8PD0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgfCBiaXRtYXBbaTBdW2owXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChrID0gMDsgayA8IHJlZmVyZW5jZVRlbXBsYXRlTGVuZ3RoOyBrKyspIHsKICAgICAgICBpMCA9IGkgKyByZWZlcmVuY2VUZW1wbGF0ZVlba10gLSBvZmZzZXRZOwogICAgICAgIGowID0gaiArIHJlZmVyZW5jZVRlbXBsYXRlWFtrXSAtIG9mZnNldFg7CiAgICAgICAgaWYgKGkwIDwgMCB8fCBpMCA+PSByZWZlcmVuY2VIZWlnaHQgfHwgajAgPCAwIHx8IGowID49IHJlZmVyZW5jZ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2h0LCBmYWxzZSk7CiAgICAgICAgaHVmZm1hbklucHV0LmVuZCA9IG9yaWdpbmFsRW5kOwogICAgICAgIGh1ZmZtYW5JbnB1dC5wb3NpdGlvbiA9IGJpdG1hcEVuZDsKICAgICAgfQogICAgICBjb25zdCBudW1iZXJPZlN5bWJvbHNEZWNvZGVkID0gc3ltYm9sV2lkdGhzLmxlbmd0aDsKICAgICAgaWYgKGZpcnN0U3ltYm9sID09PSBudW1iZXJPZlN5bWJvbHNEZWNvZGVkIC0gMSkgewogICAgICAgIG5ld1N5bWJvbHMucHVzaChjb2xsZWN0aXZlQml0bWFwKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBsZXQgaSwKICAgICAgICAgIHksCiAgICAgICAgICB4TWluID0gMCwKICAgICAgICAgIHhNYXgsCiAgICAgICAgICBiaXRtYXBXaWR0aCwKICAgICAgICAgIHN5bWJvbEJpdG1hcDsKICAgICAgICBmb3IgKGkgPSBmaXJzdFN5bWJvbDsgaSA8IG51bWJlck9mU3ltYm9sc0RlY29kZWQ7IGkrKykgewogICAgICAgICAgYml0bWFwV2lkdGggPSBzeW1ib2xXaWR0aHNbaV07CiAgICAgICAgICB4TWF4ID0geE1pbiArIGJpdG1hcFdpZHRoOwogICAgICAgICAgc3ltYm9sQml0bWFwID0gW107CiAgICAgICAgICBmb3IgKHkgPSAwOyB5IDwgY3VycmVudEhlaWdodDsgeSsrKSB7CiAgICAgICAgICAgIHN5bWJvbEJpdG1hcC5wdXNoKGNvbGxlY3RpdmVCaXRtYXBbeV0uc3ViYXJyYXkoeE1pbiwgeE1heCkpOwogICAgICAgICAgfQogICAgICAgICAgbmV3U3ltYm9scy5wdXNoKHN5bWJvbEJpdG1hcCk7CiAgICAgICAgICB4TWluID0geE1heDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgY29uc3QgZXhwb3J0ZWRTeW1ib2xzID0gW10sCiAgICBmbGFncyA9IFtdOwogIGxldCBjdXJyZW50RmxhZyA9IGZhbHNl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PSAwOyBzMiA8IHN5bWJvbEhlaWdodDsgczIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFMgKyBzMl07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFtzMl07CiAgICAgICAgICBjb25zdCBtYXhXaWR0aCA9IE1hdGgubWluKHdpZHRoIC0gb2Zmc2V0VCwgc3ltYm9sV2lkdGgpOwogICAgICAgICAgc3dpdGNoIChjb21iaW5hdGlvbk9wZXJhdG9yKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gfD0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gXj0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoYG9wZXJhdG9yICR7Y29tYmluYXRpb25PcGVyYXRvcn0gaXMgbm90IHN1cHBvcnRlZGApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjdXJyZW50UyArPSBzeW1ib2xIZWlnaHQgLSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAodDIgPSAwOyB0MiA8IHN5bWJvbEhlaWdodDsgdDIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFQgKyB0Ml07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFt0Ml07CiAgICAgICAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSB8PSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSBePSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcihgb3BlcmF0b3IgJHtjb21iaW5hdGlvbk9wZXJhdG9yfSBpcyBub3Qgc3VwcG9ydGVkYCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGN1cnJlbnRTICs9IHN5bWJvbFdpZHRoIC0gMTsKICAgICAgfQogICAgICBpKys7CiAgICAgIGNvbnN0IGRlbHRhUyA9IGh1ZmZtYW4gPyBodWZmbWFuVGFibGVzLnRhYmxlRGVsdGFTLmRlY29kZShodWZmbWFuSW5wdXQpIDogZGVjb2RlSW50ZWdlcihjb250ZXh0Q2FjaGUsICJJQURTIiwgZGVjb2Rlcik7CiAgICAgIGlmIChkZWx0YVMgPT09IG51bGwpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjdXJyZW50UyArPSBkZWx0YVMgKyBkc09mZnNldDsKICAgIH0gd2hpbGUgKHRydWUpOwogIH0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gICAgICAgICBwYXR0ZXJuUm93ID0gcGF0dGVybkJpdG1hcFtpXTsKICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBwYXR0ZXJuV2lkdGg7IGorKykgewogICAgICAgICAgICByZWdpb25Sb3dbeCArIGpdIHw9IHBhdHRlcm5Sb3dbal07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGxldCByZWdpb25YLCByZWdpb25ZOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBwYXR0ZXJuSGVpZ2h0OyBpKyspIHsKICAgICAgICAgIHJlZ2lvblkgPSB5ICsgaTsKICAgICAgICAgIGlmIChyZWdpb25ZIDwgMCB8fCByZWdpb25ZID49IHJlZ2lvbkhlaWdodCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHJlZ2lvblJvdyA9IHJlZ2lvbkJpdG1hcFtyZWdpb25ZXTsKICAgICAgICAgIHBhdHRlcm5Sb3cgPSBwYXR0ZXJuQml0bWFwW2ldOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IHBhdHRlcm5XaWR0aDsgaisrKSB7CiAgICAgICAgICAgIHJlZ2lvblggPSB4ICsgajsKICAgICAgICAgICAgaWYgKHJlZ2lvblggPj0gMCAmJiByZWdpb25YIDwgcmVnaW9uV2lkdGgpIHsKICAgICAgICAgICAgICByZWdpb25Sb3dbcmVnaW9uWF0gfD0gcGF0dGVyblJvd1tqXTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KICByZXR1cm4gcmVnaW9uQml0bWFwOwp9CmZ1bmN0aW9uIHJlYWRTZWdtZW50SGVhZGVyKGRhdGEsIHN0YXJ0KSB7CiAgY29uc3Qgc2VnbWVudEhlYWRlciA9IHt9OwogIHNlZ21lbnRIZWFkZXIubnVtYmVyID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHN0YXJ0KTsKICBj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ZXQ7CiAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgY2FzZSAwOgogICAgICAgIGZvciAoaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgICAgICAgbWFzayA9IG1hc2swOwogICAgICAgICAgb2Zmc2V0ID0gb2Zmc2V0MDsKICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICAgIGlmIChiaXRtYXBbaV1bal0pIHsKICAgICAgICAgICAgICBidWZmZXJbb2Zmc2V0XSB8PSBtYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgIGlmICghbWFzaykgewogICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgb2Zmc2V0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldDAgKz0gcm93U2l6ZTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgIG1hc2sgPSBtYXNrMDsKICAgICAgICAgIG9mZnNldCA9IG9mZnNldDA7CiAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICBpZiAoYml0bWFwW2ldW2pdKSB7CiAgICAgICAgICAgICAgYnVmZmVyW29mZnNldF0gXj0gbWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgICBpZiAoIW1hc2spIHsKICAgICAgICAgICAgICBtYXNrID0gMTI4OwogICAgICAgICAgICAgIG9mZnNldCsrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBvZmZzZXQwICs9IHJvd1NpemU7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm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N4LnN3aXRjaEZsYWcgPT09IDEpIHsKICAgICAgICAgIGN4X21wcyA9IGQ7CiAgICAgICAgfQogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubHBzOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmNoaWdoIC09IHFlSWN4OwogICAgICBpZiAoKGEgJiAweDgwMDApICE9PSAwKSB7CiAgICAgICAgdGhpcy5hID0gYTsKICAgICAgICByZXR1cm4gY3hfbXBzOwogICAgICB9CiAgICAgIGlmIChhIDwgcWVJY3gpIHsKICAgICAgICBkID0gMSBeIGN4X21wczsKICAgICAgICBpZiAocWVUYWJsZUljeC5zd2l0Y2hGbGFnID09PSAxKSB7CiAgICAgICAgICBjeF9tcHMgPSBkOwogICAgICAgIH0KICAgICAgICBjeF9pbmRleCA9IHFlVGFibGVJY3gubmxwczsKICAgICAgfSBlbHNlIHsKICAgICAgICBkID0gY3hfbXBzOwogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubXBzOwogICAgICB9CiAgICB9CiAgICBkbyB7CiAgICAgIGlmICh0aGlzLmN0ID09PSAwKSB7CiAgICAgICAgdGhpcy5ieXRlSW4oKTsKICAgICAgfQogICAgICBhIDw8PSAxOwogICAgICB0aGlzLmNoaWdoID0gdGhpcy5jaGlnaCA8PCAxICYgMHhmZmZmIHwgdGhpcy5jbG93ID4+IDE1ICYgMTsKICAgICAgdGhpcy5jbG93ID0gdGhpcy5jbG93IDw8IDEgJiAweGZmZmY7CiAgICAgIHRoaXMuY3QtLTsKICAgIH0gd2hpbGUgKChhICYgMHg4MDAwKSA9PT0gMCk7CiAgICB0aGlzLmEgPSBhOwogICAgY29udGV4dHNbcG9zXSA9IGN4X2luZGV4IDw8IDEgfCBjeF9tcHM7CiAgICByZXR1cm4gZDsKICB9Cn0KZXhwb3J0cy5Bcml0aG1ldGljRGVjb2RlciA9IEFyaXRobWV0aWNEZWNvZGVyOwoKLyoqKi8gfSksCi8qIDE2MSAqLw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DApIHsKICAgICAgbiA9IG4gPDwgMSB8IHJlYWRCaXQoKTsKICAgICAgbGVuZ3RoLS07CiAgICB9CiAgICByZXR1cm4gbjsKICB9CiAgZnVuY3Rpb24gcmVjZWl2ZUFuZEV4dGVuZChsZW5ndGgpIHsKICAgIGlmIChsZW5ndGggPT09IDEpIHsKICAgICAgcmV0dXJuIHJlYWRCaXQoKSA9PT0gMSA/IDEgOiAtMTsKICAgIH0KICAgIGNvbnN0IG4gPSByZWNlaXZlKGxlbmd0aCk7CiAgICBpZiAobiA+PSAxIDw8IGxlbmd0aCAtIDEpIHsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZXR1cm4gbiArICgtMSA8PCBsZW5ndGgpICsgMTsKICB9CiAgZnVuY3Rpb24gZGVjb2RlQmFzZWxpbmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29uc3QgdCA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZURDKTsKICAgIGNvbnN0IGRpZmYgPSB0ID09PSAwID8gMCA6IHJlY2VpdmVBbmRFeHRlbmQodCk7CiAgICBjb21wb25lbnQuYmxvY2tEYXRhW2Jsb2NrT2Zmc2V0XSA9IGNvbXBvbmVudC5wcmVkICs9IGRpZmY7CiAgICBsZXQgayA9IDE7CiAgICB3aGlsZSAoayA8IDY0KSB7CiAgICAgIGNvbnN0IHJzID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlQUMpOwogICAgICBjb25zdCBzID0gcnMgJiAxNSwKICAgICAgICByID0gcnMgPj4gNDsKICAgICAgaWYgKHMgPT09IDApIHsKICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0R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BlbHNlIHsKICAgICAgICAgICAgICByID0gMTY7CiAgICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAocyAhPT0gMSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoImludmFsaWQgQUNuIGVuY29kaW5nIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlID0gcmVjZWl2ZUFuZEV4dGVuZChzKTsKICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSByID8gMiA6IDM7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjYXNlIDE6CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaWYgKGNvbXBvbmVudC5ibG9ja0RhdGFbb2Zmc2V0Wl0pIHsKICAgICAgICAgICAgY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSArPSBzaWduICogKHJlYWRCaXQoKSA8PCBzdWNjZXNzaXZlKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHItLTsKICAgICAgICAgICAgaWYgKHIgPT09IDApIHsKICAgICAgICAgICAgICBzdWNjZXNzaXZlQUNTdGF0ZSA9IHN1Y2Nlc3NpdmVBQ1N0YXRlID09PSAyID8gMyA6IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIGlmIChjb21wb25lbnQuYmxvY2tEYXRhW29mZnNldFpdKSB7CiAgICAgICAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbb2Zmc2V0Wl0gKz0gc2lnbiAqIChyZWFkQml0KCkgPDwgc3VjY2Vzc2l2ZSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb21wb25lbnQuYmxvY2tEYXRhW29mZnNldFpdID0g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XQgaCwgdjsKICB3aGlsZSAobWN1IDw9IG1jdUV4cGVjdGVkKSB7CiAgICBjb25zdCBtY3VUb1JlYWQgPSByZXNldEludGVydmFsID8gTWF0aC5taW4obWN1RXhwZWN0ZWQgLSBtY3UsIHJlc2V0SW50ZXJ2YWwpIDogbWN1RXhwZWN0ZWQ7CiAgICBpZiAobWN1VG9SZWFkID4gMCkgewogICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0xlbmd0aDsgaSsrKSB7CiAgICAgICAgY29tcG9uZW50c1tpXS5wcmVkID0gMDsKICAgICAgfQogICAgICBlb2JydW4gPSAwOwogICAgICBpZiAoY29tcG9uZW50c0xlbmd0aCA9PT0gMSkgewogICAgICAgIGNvbXBvbmVudCA9IGNvbXBvbmVudHNbMF07CiAgICAgICAgZm9yIChuID0gMDsgbiA8IG1jdVRvUmVhZDsgbisrKSB7CiAgICAgICAgICBkZWNvZGVCbG9jayhjb21wb25lbnQsIGRlY29kZUZuLCBtY3UpOwogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobiA9IDA7IG4gPCBtY3VUb1JlYWQ7IG4rKykgewogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGNvbXBvbmVudHNMZW5ndGg7IGkrKykgewogICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRzW2ldOwogICAgICAgICAgICBoID0gY29tcG9uZW50Lmg7CiAgICAgICAgICAgIHYgPSBjb21wb25lbnQudjsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHY7IGorKykgewogICAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPCBoOyBrKyspIHsKICAgICAgICAgICAgICAgIGRlY29kZU1jdShjb21wb25lbnQsIGRlY29kZUZuLCBtY3UsIGosIGspOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgIC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MjA0OCA+PiAxMjsKICAgIHY0ID0gdjQgKiBkY3RDb3MzIC0gdjcgKiBkY3RTaW4zICsgMjA0OCA+PiAxMjsKICAgIHY3ID0gdDsKICAgIHQgPSB2NSAqIGRjdFNpbjEgKyB2NiAqIGRjdENvczEgKyAyMDQ4ID4+IDEyOwogICAgdjUgPSB2NSAqIGRjdENvczEgLSB2NiAqIGRjdFNpbjEgKyAyMDQ4ID4+IDEyOwogICAgdjYgPSB0OwogICAgcDAgPSB2MCArIHY3OwogICAgcDcgPSB2MCAtIHY3OwogICAgcDEgPSB2MSArIHY2OwogICAgcDYgPSB2MSAtIHY2OwogICAgcDIgPSB2MiArIHY1OwogICAgcDUgPSB2MiAtIHY1OwogICAgcDMgPSB2MyArIHY0OwogICAgcDQgPSB2MyAtIHY0OwogICAgaWYgKHAwIDwgMTYpIHsKICAgICAgcDAgPSAwOwogICAgfSBlbHNlIGlmIChwMCA+PSA0MDgwKSB7CiAgICAgIHAwID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDAgPj49IDQ7CiAgICB9CiAgICBpZiAocDEgPCAxNikgewogICAgICBwMSA9IDA7CiAgICB9IGVsc2UgaWYgKHAxID49IDQwODApIHsKICAgICAgcDEgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwMSA+Pj0gNDsKICAgIH0KICAgIGlmIChwMiA8IDE2KSB7CiAgICAgIHAyID0gMDsKICAgIH0gZWxzZSBpZiAocDIgPj0gNDA4MCkgewogICAgICBwMiA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHAyID4+PSA0OwogICAgfQogICAgaWYgKHAzIDwgMTYpIHsKICAgICAgcDMgPSAwOwogICAgfSBlbHNlIGlmIChwMyA+PSA0MDgwKSB7CiAgICAgIHAzID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDMgPj49IDQ7CiAgICB9CiAgICBpZiAocDQgPCAxNikgewogICAgICBwNCA9IDA7CiAgICB9IGVsc2UgaWYgKHA0ID49IDQwODApIHs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E2KShkYXRhLCBjdXJyZW50UG9zKTsKICBpZiAoY3VycmVudE1hcmtlciA+PSAweGZmYzAgJiYgY3VycmVudE1hcmtlciA8PSAweGZmZmUpIHsKICAgIHJldHVybiB7CiAgICAgIGludmFsaWQ6IG51bGwsCiAgICAgIG1hcmtlcjogY3VycmVudE1hcmtlciwKICAgICAgb2Zmc2V0OiBjdXJyZW50UG9zCiAgICB9OwogIH0KICBsZXQgbmV3TWFya2VyID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIG5ld1Bvcyk7CiAgd2hpbGUgKCEobmV3TWFya2VyID49IDB4ZmZjMCAmJiBuZXdNYXJrZXIgPD0gMHhmZmZlKSkgewogICAgaWYgKCsrbmV3UG9zID49IG1heFBvcykgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIG5ld01hcmtlciA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBuZXdQb3MpOwogIH0KICByZXR1cm4gewogICAgaW52YWxpZDogY3VycmVudE1hcmtlci50b1N0cmluZygxNiksCiAgICBtYXJrZXI6IG5ld01hcmtlciwKICAgIG9mZnNldDogbmV3UG9zCiAgfTsKfQpjbGFzcyBKcGVnSW1hZ2UgewogIGNvbnN0cnVjdG9yKCkgewogICAgbGV0IHsKICAgICAgZGVjb2RlVHJhbnNmb3JtID0gbnVsbCwKICAgICAgY29sb3JUcmFuc2Zvcm0gPSAtMQogICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICB0aGlzLl9kZWNvZGVUcmFuc2Zvcm0gPSBkZWNvZGVUcmFuc2Zvcm07CiAgICB0aGlzLl9jb2xvclRyYW5zZm9ybSA9IGNvbG9yVHJhbnNmb3JtOwogIH0KICBwYXJzZShkYXRhKSB7CiAgICBsZXQgewogICAgICBkbmxTY2FuTGluZXMgPSBudWxsCiAg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PSAwOwogICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzID0gW107CiAgICBjb25zdCBodWZmbWFuVGFibGVzQUMgPSBbXSwKICAgICAgaHVmZm1hblRhYmxlc0RDID0gW107CiAgICBsZXQgZmlsZU1hcmtlciA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgb2Zmc2V0ICs9IDI7CiAgICBpZiAoZmlsZU1hcmtlciAhPT0gMHhmZmQ4KSB7CiAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIlNPSSBub3QgZm91bmQiKTsKICAgIH0KICAgIGZpbGVNYXJrZXIgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgIG9mZnNldCArPSAyOwogICAgbWFya2VyTG9vcDogd2hpbGUgKGZpbGVNYXJrZXIgIT09IDB4ZmZkOSkgewogICAgICBsZXQgaSwgaiwgbDsKICAgICAgc3dpdGNoIChmaWxlTWFya2VyKSB7CiAgICAgICAgY2FzZSAweGZmZTA6CiAgICAgICAgY2FzZSAweGZmZTE6CiAgICAgICAgY2FzZSAweGZmZTI6CiAgICAgICAgY2FzZSAweGZmZTM6CiAgICAgICAgY2FzZSAweGZmZTQ6CiAgICAgICAgY2FzZSAweGZmZTU6CiAgICAgICAgY2FzZSAweGZmZTY6CiAgICAgICAgY2FzZSAweGZmZTc6CiAgICAgICAgY2FzZSAweGZmZTg6CiAgICAgICAgY2FzZSAweGZmZTk6CiAgICAgICAgY2FzZSAweGZmZWE6CiAgICAgICAgY2FzZSAweGZmZWI6CiAgICAgICAgY2FzZSAweGZmZWM6CiAgICAgICAgY2FzZSAweGZmZWQ6CiAgICAgICAgY2FzZSAweGZmZWU6CiAgICAgICAgY2FzZSAweGZmZWY6CiAgICAgICAgY2FzZSAweGZmZmU6CiAgICAgICAgICBjb25zdCBhcHBEYXRhID0gcmVhZERhdGFCbG9jaygpOwogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlMCkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0YSAmJiBhcHBEYXRhWzFdID09PSAweDQ2ICYmIGFwcERhdGFbMl0gPT09IDB4NDkgJiYgYXBwRGF0YVszXSA9PT0gMHg0NiAmJiBhcHBEYXRhWzRdID09PSAwKSB7CiAgICAgICAgICAgICAgamZpZiA9IHsKICAgICAgICAgICAgICAgIHZlcnNpb246IHsKICAgICAgICAgICAgICAgICAgbWFqb3I6IGFwcERhdGFbNV0sCiAgICAgICAgICAgICAgICAgIG1pbm9yOiBhcHBEYXRhWzZdCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZGVuc2l0eVVuaXRzOiBhcHBEYXRhWzddLAogICAgICAgICAgICAgICAgeERlbnNpdHk6IGFwcERhdGFbOF0gPDwgOCB8IGFwcERhdGFbOV0sCiAgICAgICAgICAgICAgICB5RGVuc2l0eTogYXBwRGF0YVsxMF0gPDwgOCB8IGFwcERhdGFbMTFdLAogICAgICAgICAgICAgICAgdGh1bWJXaWR0aDogYXBwRGF0YVsxMl0sCiAgICAgICAgICAgICAgICB0aHVtYkhlaWdodDogYXBwRGF0YVsxM10sCiAgICAgICAgICAgICAgICB0aHVtYkRhdGE6IGFwcERhdGEuc3ViYXJyYXkoMTQsIDE0ICsgMyAqIGFwcERhdGFbMTJdICogYXBwRGF0YVsxM10pCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlZSkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0MSAmJiBhcHBEYXRhWzFdID09PSAweDY0ICYmIGFwcERhdGFbMl0gPT09IDB4NmYgJiYgYXBwRGF0YVszXSA9PT0gMHg2MiAmJiBhcHBEYXRhWzRdID09PSAweDY1KSB7CiAgICAgICAgICAgICAgYWRvYmUgPSB7CiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBhcHBEYXRhWzVdIDw8IDggfCBhcHBEYXRhWzZdLAogICAgICAgICAgICAgICAgZmxhZ3MwOiBhcHBEYXRhWzddIDw8IDggfCBhcHBEYXRhWzhdLAogICAgICAgICAgICAgICAgZmxhZ3MxOiBhcHBEYXRhWzldIDw8IDggfCBhcHBEYXRhWzEwXSwKICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNvZGU6IGFwcERhdGFbMTFdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGI6CiAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZXNMZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzRW5kID0gcXVhbnRpemF0aW9uVGFibGVzTGVuZ3RoICsgb2Zmc2V0IC0gMjsKICAgICAgICAgIGxldCB6OwogICAgICAgICAgd2hpbGUgKG9mZnNldCA8IHF1YW50aXphdGlvblRhYmxlc0VuZCkgewogICAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZVNwZWMgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgY29uc3QgdGFibGVEYXRhID0gbmV3IFVpbnQxNkFycmF5KDY0KTsKICAgICAgICAgICAgaWYgKHF1YW50aXphdGlvblRhYmxlU3BlYyA+PiA0ID09PSAwKSB7CiAgICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyBqKyspIHsKICAgICAgICAgICAgICAgIHogPSBkY3RaaWdaYWdbal07CiAgICAgICAgICAgICAgICB0YWJsZURhdGFbel0gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSBpZiAocXVhbnRpemF0aW9uVGFibGVTcGVjID4+IDQgPT09IDEpIHsKICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7IGorKykgewogICAgICAgICAgICAgICAgeiA9IGRjdFppZ1phZ1tqXTsKICAgICAgICAgICAgICAgIHRhYmxlRGF0YVt6XSA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIkRRVCAtIGludmFsaWQgdGFibGUgc3BlYyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlc1txdWFudGl6YXRpb25UYWJsZVNwZWMgJiAxNV0gPSB0YWJsZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZjMDoKICAgICAgICBjYXNlIDB4ZmZjMToKICAgICAgICBjYXNlIDB4ZmZjMjoKICAgICAgICAgIGlmIChmcmFtZSkgewogICAgICAgICAgICB0aHJvdyBuZXcgSnBlZ0Vycm9yKCJPbmx5IHNpbmdsZSBmcmFtZSBKUEVHcyBzdXBwb3J0ZWQiKTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUgPSB7fTsKICAgICAgICAgIGZyYW1lLmV4dGVuZGVkID0gZmlsZU1hcmtlciA9PT0gMHhmZmMxOwogICAgICAgICAgZnJhbWUucHJvZ3Jlc3NpdmUgPSBmaWxlTWFya2VyID09PSAweGZmYzI7CiAgICAgICAgICBmcmFtZS5wcmVjaXNpb24gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGNvbnN0IHNvZlNjYW5MaW5lcyA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmcmFtZS5zY2FuTGluZXMgPSBkbmxTY2FuTGluZXMgfHwgc29mU2NhbkxpbmVzOwogICAgICAgICAgZnJhbWUuc2FtcGxlc1BlckxpbmUgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50cyA9IFtdOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50SWRzID0ge307CiAgICAgICAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGxldCBtYXhIID0gMCwKICAgICAgICAgICAgbWF4ViA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3QgY29tcG9uZW50SWQgPSBkYXRhW29mZnNldF07CiAgICAgICAgICAgIGNvbnN0IGggPSBkYXRhW29mZnNldCArIDFdID4+IDQ7CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhW29mZnNldCArIDFdICYgMTU7CiAgICAgICAgICAgIGlmIChtYXhIIDwgaCkgewogICAgICAgICAgICAgIG1heEggPSBoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtYXhWIDwgdikgewogICAgICAgICAgICAgIG1heFYgPSB2OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHFJZCA9IGRhdGFbb2Zmc2V0ICsgMl07CiAgICAgICAgICAgIGwgPSBmcmFtZS5jb21wb25lbnRzLnB1c2goewogICAgICAgICAgICAgIGgsCiAgICAgICAgICAgICAgdiwKICAgICAgICAgICAgICBxdWFudGl6YXRpb25JZDogcUlkLAogICAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlOiBudWxsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBmcmFtZS5jb21wb25lbnRJZHNbY29tcG9uZW50SWRdID0gbCAtIDE7CiAgICAgICAgICAgIG9mZnNldCArPSAzOwogICAgICAgICAgfQogICAgICAgICAgZnJhbWUubWF4SCA9IG1heEg7CiAgICAgICAgICBmcmFtZS5tYXhWID0gbWF4VjsKICAgICAgICAgIHByZXBhcmVDb21wb25lbnRzKGZyYW1lKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmM0OgogICAgICAgICAgY29uc3QgaHVmZm1hbkxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmb3IgKGkgPSAyOyBpIDwgaHVmZm1hbkxlbmd0aDspIHsKICAgICAgICAgICAgY29uc3QgaHVmZm1hblRhYmxlU3BlYyA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb2RlTGVuZ3RocyA9IG5ldyBVaW50OEFycmF5KDE2KTsKICAgICAgICAgICAgbGV0IGNvZGVMZW5ndGhTdW0gPSAwOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgMTY7IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBjb2RlTGVuZ3RoU3VtICs9IGNvZGVMZW5ndGhzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGh1ZmZtYW5WYWx1ZXMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuZ3RoU3VtKTsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IGNvZGVMZW5ndGhTdW07IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBodWZmbWFuVmFsdWVzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGkgKz0gMTcgKyBjb2RlTGVuZ3RoU3VtOwogICAgICAgICAgICAoaHVmZm1hblRhYmxlU3BlYyA+PiA0ID09PSAwID8gaHVmZm1hblRhYmxlc0RDIDogaHVmZm1hblRhYmxlc0FDKVtodWZmbWFuVGFibGVTcGVjICYgMTVdID0gYnVpbGRIdWZmbWFuVGFibGUoY29kZUxlbmd0aHMsIGh1ZmZtYW5WYWx1ZXMpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGQ6CiAgICAgICAgICBvZmZzZXQgKz0gMjsKICAgICAgICAgIHJlc2V0SW50ZXJ2YWwgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGE6CiAgICAgICAgICBjb25zdCBwYXJzZUROTE1hcmtlciA9ICsrbnVtU09TTWFya2VycyA9PT0gMSAmJiAhZG5sU2NhbkxpbmVzOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBjb25zdCBzZWxlY3RvcnNDb3VudCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBjb21wb25lbnRzID0gW107CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2VsZWN0b3JzQ291bnQ7IGkrKykgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb21wb25lbnRJbmRleCA9IGZyYW1lLmNvbXBvbmVudElkc1tpbmRleF07CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudCA9IGZyYW1lLmNvbXBvbmVudHNbY29tcG9uZW50SW5kZXhdOwogICAgICAgICAgICBjb21wb25lbnQuaW5kZXggPSBpbmRleDsKICAgICAgICAgICAgY29uc3QgdGFibGVTcGVjID0gZGF0YVtvZmZzZXQrK107CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVEQyA9IGh1ZmZtYW5UYWJsZXNEQ1t0YWJsZVNwZWMgPj4gNF07CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyA9IGh1ZmZtYW5UYWJsZXNBQ1t0YWJsZVNwZWMgJiAxNV07CiAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3BlY3RyYWxTdGFydCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzcGVjdHJhbEVuZCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzdWNjZXNzaXZlQXBwcm94aW1hdGlvbiA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkID0gZGVjb2RlU2NhbihkYXRhLCBvZmZzZXQsIGZyYW1lLCBjb21wb25lbnRzLCByZXNldEludGVydmFsLCBzcGVjdHJhbFN0YXJ0LCBzcGVjdHJhbEVuZCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gPj4gNCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gJiAxNSwgcGFyc2VETkxNYXJrZXIpOwogICAgICAgICAgICBvZmZzZXQgKz0gcHJvY2Vzc2VkOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgRE5MTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gYXR0ZW1wdGluZyB0byByZS1wYXJzZSB0aGUgSlBFRyBpbWFnZS5gKTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZShkYXRhLCB7CiAgICAgICAgICAgICAgICBkbmxTY2FuTGluZXM6IGV4LnNjYW5MaW5lcwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgRU9JTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gaWdub3JpbmcgdGhlIHJlc3Qgb2YgdGhlIGltYWdlIGRhdGEuYCk7CiAgICAgICAgICAgICAgYnJlYWsgbWFya2VyTG9vcDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmRjOgogICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZmZjoKICAgICAgICAgIGlmIChkYXRhW29mZnNldF0gIT09IDB4ZmYpIHsKICAgICAgICAgICAgb2Zmc2V0LS07CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgY29uc3QgbmV4dEZpbGVNYXJrZXIgPSBmaW5kTmV4dEZpbGVNYXJrZXIoZGF0YSwgb2Zmc2V0IC0gMiwgb2Zmc2V0IC0gMyk7CiAgICAgICAgICBpZiAobmV4dEZpbGVNYXJrZXIgJiYgbmV4dEZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHVuZXhwZWN0ZWQgZGF0YSwgY3VycmVudCBtYXJrZXIgaXM6ICIgKyBuZXh0RmlsZU1hcmtlci5pbnZhbGlkKTsKICAgICAgICAgICAgb2Zmc2V0ID0gbmV4dEZpbGVNYXJrZXIub2Zmc2V0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghbmV4dEZpbGVNYXJrZXIgfHwgb2Zmc2V0ID49IGRhdGEubGVuZ3RoIC0gMSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHJlYWNoZWQgdGhlIGVuZCBvZiB0aGUgaW1hZ2UgZGF0YSAiICsgIndpdGhvdXQgZmluZGluZyBhbiBFT0kgbWFya2VyICgweEZGRDkpLiIpOwogICAgICAgICAgICBicmVhayBtYXJrZXJMb29wOwogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IEpwZWdFcnJvcigiSnBlZ0ltYWdlLnBhcnNlIC0gdW5rbm93biBtYXJrZXI6ICIgKyBmaWxlTWFya2VyLnRvU3RyaW5nKDE2KSk7CiAgICAgIH0KICAgICAgZmlsZU1hcmtlciA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICBvZmZzZXQgKz0gMjsKICAgIH0KICAgIHRoaXMud2lkdGggPSBmcmFtZS5zYW1wbGVzUGVyTGluZTsKICAgIHRoaXMuaGVpZ2h0ID0gZnJhbWUuc2NhbkxpbmVzOwogICAgdGhpcy5qZmlmID0gamZpZjsKICAgIHRoaXMuYWRvYmUgPSBhZG9iZTsKICAgIHRoaXMuY29tcG9uZW50cyA9IFtdOwogICAgZm9yIChjb25zdCBjb21wb25lbnQgb2YgZnJhbWUuY29tcG9uZW50cykgewogICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZSA9IHF1YW50aXphdGlvblRhYmxlc1tjb21wb25lbnQucXVhbnRpemF0aW9uSWRdOwogICAgICBpZiAocXVhbnRpemF0aW9uVGFibGUpIHsKICAgICAgICBjb21wb25lbnQucXVhbnRpemF0aW9uVGFibGUgPSBxdWFudGl6YXRpb25UYWJsZTsKICAgICAgfQogICAgICB0aGlzLmNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgaW5kZXg6IGNvbXBvbmVudC5pbmRleCwKICAgICAgICBvdXRwdXQ6IGJ1aWxkQ29tcG9uZW50RGF0YShmcmFtZSwgY29tcG9uZW50KSwKICAgICAgICBzY2FsZVg6IGNvbXBvbmVudC5oIC8gZnJhbWUubWF4SCwKICAgICAgICBzY2FsZVk6IGNvbXBvbmVudC52IC8gZnJhbWUubWF4ViwKICAgICAgICBibG9ja3NQZXJMaW5lOiBjb21wb25lbnQuYmxvY2tz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AgY29tcG9uZW50ID0gdGhpcy5jb21wb25lbnRzW2ldOwogICAgICBjb21wb25lbnRTY2FsZVggPSBjb21wb25lbnQuc2NhbGVYICogc2NhbGVYOwogICAgICBjb21wb25lbnRTY2FsZVkgPSBjb21wb25lbnQuc2NhbGVZICogc2NhbGVZOwogICAgICBvZmZzZXQgPSBpOwogICAgICBvdXRwdXQgPSBjb21wb25lbnQub3V0cHV0OwogICAgICBibG9ja3NQZXJTY2FubGluZSA9IGNvbXBvbmVudC5ibG9ja3NQZXJMaW5lICsgMSA8PCAzOwogICAgICBpZiAoY29tcG9uZW50U2NhbGVYICE9PSBsYXN0Q29tcG9uZW50U2NhbGVYKSB7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGogPSAwIHwgeCAqIGNvbXBvbmVudFNjYWxlWDsKICAgICAgICAgIHhTY2FsZUJsb2NrT2Zmc2V0W3hdID0gKGogJiBtYXNrM0xTQikgPDwgMyB8IGogJiA3OwogICAgICAgIH0KICAgICAgICBsYXN0Q29tcG9uZW50U2NhbGVYID0gY29tcG9uZW50U2NhbGVYOwogICAgICB9CiAgICAgIGZvciAoeSA9IDA7IHkgPCBoZWlnaHQ7IHkrKykgewogICAgICAgIGogPSAwIHwgeSAqIGNvbXBvbmVudFNjYWxlWTsKICAgICAgICBpbmRleCA9IGJsb2Nrc1BlclNjYW5saW5lICogKGogJiBtYXNrM0xTQikgfCAoaiAmIDcpIDw8IDM7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGRhdGFbb2Zmc2V0XSA9IG91dHB1dFtpbmRleCArIHhTY2FsZUJsb2NrT2Zmc2V0W3hdXTsKICAgICAgICAgIG9mZnNldCArPSBudW1Db21wb25lbnRzOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbGV0IHRyYW5zZm9ybSA9IHRoaXMuX2RlY29kZVRyYW5zZm9ybTsKICAgIGlmICghaXNTb3VyY2VQREYgJiYgbnVtQ29tcG9uZW50cyA9PT0gNCAmJiAhdHJhbnNmb3JtKSB7CiAgICAgIHRyYW5zZm9ybSA9IG5ldyBJbnQzMkFycmF5KFstMjU2LCAyNTUsIC0yNTYsIDI1NSwgLTI1NiwgMjU1LCAtMjU2LCAyNTVdKTsKICAgIH0KICAgIGlmICh0cmFuc2Zvcm0pIHsKICAgICAgZm9yIChpID0gMDsgaSA8IGRhdGFMZW5ndGg7KSB7CiAgICAgICAgZm9yIChqID0gMCwgayA9IDA7IGogPCBudW1Db21wb25lbnRzOyBqKyssIGkrKywgayArPSAyKSB7CiAgICAgICAgICBkYXRhW2ldID0gKGRhdGFbaV0gKiB0cmFuc2Zvcm1ba10gPj4gOCkgKyB0cmFuc2Zvcm1bayArIDFdOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGRhdGE7CiAgfQogIGdldCBfaXNDb2xvckNvbnZlcnNpb25OZWVkZWQoKSB7CiAgICBpZiAodGhpcy5hZG9iZSkgewogICAgICByZXR1cm4gISF0aGlzLmFkb2JlLnRyYW5zZm9ybUNvZGU7CiAgICB9CiAgICBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSAzKSB7CiAgICAgIGlmICh0aGlzLl9jb2xvclRyYW5zZm9ybSA9PT0gMCkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfSBlbHNlIGlmICh0aGlzLmNvbXBvbmVudHNbMF0uaW5kZXggPT09IDB4NTIgJiYgdGhpcy5jb21wb25lbnRzWzFdLmluZGV4ID09PSAweDQ3ICYmIHRoaXMuY29tcG9uZW50c1syXS5pbmRleCA9PT0gMHg0MikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmICh0aGlzLl9jb2xvclRyYW5zZm9ybSA9PT0gMSkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiA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cG9zaXRpb24gKz0gaGVhZGVyU2l6ZTsKICAgICAgaWYgKGxib3ggPT09IDEpIHsKICAgICAgICBsYm94ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKSAqIDQyOTQ5NjcyOTYgKyAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyA0KTsKICAgICAgICBwb3NpdGlvbiArPSA4OwogICAgICAgIGhlYWRlclNpemUgKz0gODsKICAgICAgfQogICAgICBpZiAobGJveCA9PT0gMCkgewogICAgICAgIGxib3ggPSBsZW5ndGggLSBwb3NpdGlvbiArIGhlYWRlclNpemU7CiAgICAgIH0KICAgICAgaWYgKGxib3ggPCBoZWFkZXJTaXplKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIGJveCBmaWVsZCBzaXplIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUxlbmd0aCA9IGxib3ggLSBoZWFkZXJTaXplOwogICAgICBsZXQganVtcERhdGFMZW5ndGggPSB0cnVlOwogICAgICBzd2l0Y2ggKHRib3gpIHsKICAgICAgICBjYXNlIDB4NmE3MDMyNjg6CiAgICAgICAgICBqdW1wRGF0YUxlbmd0aCA9IGZhbHNlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDYzNmY2YzcyOgogICAgICAgICAgY29uc3QgbWV0aG9kID0gZGF0YVtwb3NpdGlvbl07CiAgICAgICAgICBpZiAobWV0aG9kID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yc3BhY2UgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzKTsKICAgICAgICAgICAgc3dpdGNoIChjb2xvcnNwYWNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxNjoKICAgICAgICAgICAgICBjYXNlIDE3OgogICAgICAgICAgICAgIGNhc2UgMTg6CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmtub3duIGNvbG9yc3BhY2UgIiArIGNvbG9yc3BhY2UpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAobWV0aG9kID09PSAyKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSUNDIHByb2ZpbGUgbm90IHN1cHBvcnRlZCIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNzAzMjYzOgogICAgICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgcG9zaXRpb24sIHBvc2l0aW9uICsgZGF0YUxlbmd0aCk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4NmE1MDIwMjA6CiAgICAgICAgICBpZiAoKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKSAhPT0gMHgwZDBhODcwYSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkludmFsaWQgSlAyIHNpZ25hdHVyZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNTAxYTFhOgogICAgICAgIGNhc2UgMHg2Njc0Nzk3MDoKICAgICAgICBjYXNlIDB4NzI3MjY1NzE6CiAgICAgICAgY2FzZSAweDcyNjU3MzIwOgogICAgICAgIGNhc2UgMHg2OTY4NjQ3MjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBjb25zdCBoZWFkZXJUeXBlID0gU3RyaW5nLmZyb21DaGFyQ29kZSh0Ym94ID4+IDI0ICYgMHhmZiwgdGJveCA+PiAxNiAmIDB4ZmYsIHRib3ggPj4gOCAmIDB4ZmYsIHRib3ggJiAweGZmKTsKICAgICAgICAgIC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R1cm47CiAgICAgIH0KICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiTm8gc2l6ZSBtYXJrZXIgZm91bmQgaW4gSlBYIHN0cmVhbSIpOwogIH0KICBwYXJzZUNvZGVzdHJlYW0oZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgY29udGV4dCA9IHt9OwogICAgbGV0IGRvTm90UmVjb3ZlciA9IGZhbHNlOwogICAgdHJ5IHsKICAgICAgbGV0IHBvc2l0aW9uID0gc3RhcnQ7CiAgICAgIHdoaWxlIChwb3NpdGlvbiArIDEgPCBlbmQpIHsKICAgICAgICBjb25zdCBjb2RlID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIGxldCBsZW5ndGggPSAwLAogICAgICAgICAgaiwKICAgICAgICAgIHNxY2QsCiAgICAgICAgICBzcHFjZHMsCiAgICAgICAgICBzcHFjZFNpemUsCiAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQsCiAgICAgICAgICB0aWxlOwogICAgICAgIHN3aXRjaCAoY29kZSkgewogICAgICAgICAgY2FzZSAweGZmNGY6CiAgICAgICAgICAgIGNvbnRleHQubWFpbkhlYWRlciA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmZDk6CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTE6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHNpeiA9IHt9OwogICAgICAgICAgICBzaXouWHNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICBzaXouWXNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDgpOwogICAgICAgICAgICBzaXouWE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAxMik7CiAgICAgICAgICAgIHNpei5ZT3NpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDE2KTsKICAgICAgICAgICAgc2l6LlhUc2l6ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uICsgMjApOwogICAgICAgICAgICBzaXouWVRzaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyNCk7CiAgICAgICAgICAgIHNpei5YVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyOCk7CiAgICAgICAgICAgIHNpei5ZVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzMik7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDM2KTsKICAgICAgICAgICAgc2l6LkNzaXogPSBjb21wb25lbnRzQ291bnQ7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHMgPSBbXTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMzg7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB7CiAgICAgICAgICAgICAgICBwcmVjaXNpb246IChkYXRhW2pdICYgMHg3ZikgKyAxLAogICAgICAgICAgICAgICAgaXNTaWduZWQ6ICEhKGRhdGFbal0gJiAweDgwKSwKICAgICAgICAgICAgICAgIFhSc2l6OiBkYXRhW2ogKyAxXSwKICAgICAgICAgICAgICAgIFlSc2l6OiBkYXRhW2ogKyAyXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgaiArPSAzOwogICAgICAgICAgICAgIGNhbGN1bGF0ZUNvbXBvbmVudERpbWVuc2lvbnMoY29tcG9uZW50LCBzaXopOwogICAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRleHQuU0laID0gc2l6OwogICAgICAgICAgICBjb250ZXh0LmNvbXBvbmVudHMgPSBjb21wb25lbnRzOwogICAgICAgICAgICBjYWxjdWxhdGVUaWxlR3JpZHMoY29udGV4dCwgY29tcG9uZW50cyk7CiAgICAgICAgICAgIGNvbnRleHQuUUNDID0gW107CiAgICAgICAgICAgIGNvbnRleHQuQ09DID0gW107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNWM6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHFjZCA9IHt9OwogICAgICAgICAgICBqID0gcG9zaXRpb24gKyAyOwogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Qubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjZC5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjZC5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2QuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0QgPSBxY2Q7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0QgPSBxY2Q7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0MgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMHhmZjVkOgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBjb25zdCBxY2MgPSB7fTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMjsKICAgICAgICAgICAgbGV0IGNxY2M7CiAgICAgICAgICAgIGlmIChjb250ZXh0LlNJWi5Dc2l6IDwgMjU3KSB7CiAgICAgICAgICAgICAgY3FjYyA9IGRhdGFbaisrXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjcWNjID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIGopOwogICAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Mubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjYy5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjYy5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2MuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDB4ZmY1MjoKICAgICAgICAgICAgbGVuZ3RoID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICAgICAgY29uc3QgY29kID0ge307CiAgICAgICAgICAgIGogPSBwb3NpdGlvbiArIDI7CiAgICAgICAgICAgIGNvbnN0IHNjb2QgPSBkYXRhW2orK107CiAgICAgICAgICAgIGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzID0gISEoc2NvZCAmIDEpOwogICAgICAgICAgICBjb2Quc29wTWFya2VyVXNlZCA9ICEhKHNjb2QgJiAyKTsKICAgICAgICAgICAgY29kLmVwaE1hcmtlclVzZWQgPSAhIShzY29kICYgNCk7CiAgICAgICAgICAgIGNvZC5wcm9ncmVzc2lvbk9yZGVyID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QubGF5ZXJzQ291bnQgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgaik7CiAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgY29kLm11bHRpcGxlQ29tcG9uZW50VHJhbnNmb3JtID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QueGNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb2QueWNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb25zdCBibG9ja1N0eWxlID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2Quc2VsZWN0aXZlQXJpdGhtZXRpY0NvZGluZ0J5cGFzcyA9ICEhKGJsb2NrU3R5bGUgJiAxKTsKICAgICAgICAgICAgY29kLnJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMgPSAhIShibG9ja1N0eWxlICYgMik7CiAgICAgICAgICAgIGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MgPSAhIShibG9ja1N0eWxlICYgNCk7CiAgICAgICAgICAgIGNvZC52ZXJ0aWNhbGx5U3RyaXBlID0gISEoYmxvY2tTdHlsZSAmIDgpOwogICAgICAgICAgICBjb2QucHJlZGljdGFibGVUZXJtaW5hdGlvbiA9ICEhKGJsb2NrU3R5bGUgJiAxNik7CiAgICAgICAgICAgIGNvZC5zZWdtZW50YXRpb25TeW1ib2xVc2VkID0gISEoYmxvY2tTdHlsZSAmIDMyKTsKICAgICAgICAgICAgY29kLnJldmVyc2libGVUcmFuc2Zvcm1hdGlvbiA9IGRhdGFbaisrXTsKICAgICAgICAgICAgaWYgKGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzKSB7CiAgICAgICAgICAgICAgY29uc3QgcHJlY2luY3RzU2l6ZXMgPSBbXTsKICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwcmVjaW5jdHNTaXplID0gZGF0YVtqKytdOwogICAgICAgICAgICAgICAgcHJlY2luY3RzU2l6ZXMucHVzaCh7CiAgICAgICAgICAgICAgICAgIFBQeDogcHJlY2luY3RzU2l6ZSAmIDB4ZiwKICAgICAgICAgICAgICAgICAgUFB5OiBwcmVjaW5jdHNTaXplID4+IDQKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2QucHJlY2luY3RzU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCB1bnN1cHBvcnRlZCA9IFtdOwogICAgICAgICAgICBpZiAoY29kLnNlbGVjdGl2ZUFyaXRobWV0aWNDb2RpbmdCeXBhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJzZWxlY3RpdmVBcml0aG1ldGljQ29kaW5nQnlwYXNzIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ0ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kLnZlcnRpY2FsbHlTdHJpcGUpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ2ZXJ0aWNhbGx5U3RyaXBlIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC5wcmVkaWN0YWJsZVRlcm1pbmF0aW9uKSB7CiAgICAgICAgICAgICAgdW5zdXBwb3J0ZWQucHVzaCgicHJlZGljdGFibGVUZXJtaW5hdGlvbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgZG9Ob3RSZWNvdmVyID0gdHJ1ZTsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEpQWDogVW5zdXBwb3J0ZWQgQ09EIG9wdGlvbnMgKCR7dW5zdXBwb3J0ZWQuam9pbigiLCAiKX0pLmApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb250ZXh0Lm1haW5IZWFkZXIpIHsKICAgICAgICAgICAgICBjb250ZXh0LkNPRCA9IGNvZDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPRCA9IGNvZDsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPQyA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTA6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIHRpbGUgPSB7fTsKICAgICAgICAgICAgdGlsZS5pbmRleCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDIpOwogICAgICAgICAgICB0aWxlLmxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICB0aWxlLmRhdGFFbmQgPSB0aWxlLmxlbmd0aCArIHBvc2l0aW9uIC0gMjsKICAgICAgICAgICAgdGlsZS5wYXJ0SW5kZXggPSBkYXRhW3Bvc2l0aW9uICsgOF07CiAgICAgICAgICAgIHRpbGUucGFydHNDb3VudCA9IGRhdGFbcG9zaXRpb24gKyA5XTsKICAgICAgICAgICAgY29udGV4dC5tYWluSGVhZGVyID0gZmFsc2U7CiAgICAgICAgICAgIGlmICh0aWxlLnBhcnRJbmRleCA9PT0gMCkgewogICAgICAgICAgICAgIHRpbGUuQ09EID0gY29udGV4dC5DT0Q7CiAgICAgICAgICAgICAgdGlsZS5DT0MgPSBjb250ZXh0LkNPQy5zbGljZSgwKTsKICAgICAgICAgICAgICB0aWxlLlFDRCA9IGNvbnRleHQuUUNEOwogICAgICAgICAgICAgIHRpbGUuUUNDID0gY29udGV4dC5RQ0Muc2xpY2UoMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZSA9IHRpbGU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTM6CiAgICAgICAgICAgIHRpbGUgPSBjb250ZXh0LmN1cnJlbnRUaWxlOwogICAgICAgICAgICBpZiAodGlsZS5wYXJ0SW5kZXggPT09IDApIHsKICAgICAgICAgICAgICBpbml0aWFsaXplVGlsZShjb250ZXh0LCB0aWxlLmluZGV4KTsKICAgICAgICAgICAgICBidWlsZFBhY2tldHMoY29udGV4dCk7CiAgICAgICA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CiAgICBmb3IgKGxldCBwID0gMDsgcCA8IG51bVh0aWxlczsgcCsrKSB7CiAgICAgIHRpbGUgPSB7fTsKICAgICAgdGlsZS50eDAgPSBNYXRoLm1heChzaXouWFRPc2l6ICsgcCAqIHNpei5YVHNpeiwgc2l6LlhPc2l6KTsKICAgICAgdGlsZS50eTAgPSBNYXRoLm1heChzaXouWVRPc2l6ICsgcSAqIHNpei5ZVHNpeiwgc2l6LllPc2l6KTsKICAgICAgdGlsZS50eDEgPSBNYXRoLm1pbihzaXouWFRPc2l6ICsgKHAgKyAxKSAqIHNpei5YVHNpeiwgc2l6LlhzaXopOwogICAgICB0aWxlLnR5MSA9IE1hdGgubWluKHNpei5ZVE9zaXogKyAocSArIDEpICogc2l6LllUc2l6LCBzaXouWXNpeik7CiAgICAgIHRpbGUud2lkdGggPSB0aWxlLnR4MSAtIHRpbGUudHgwOwogICAgICB0aWxlLmhlaWdodCA9IHRpbGUudHkxIC0gdGlsZS50eTA7CiAgICAgIHRpbGUuY29tcG9uZW50cyA9IFtdOwogICAgICB0aWxlcy5wdXNoKHRpbGUpOwogICAgfQogIH0KICBjb250ZXh0LnRpbGVzID0gdGlsZXM7CiAgY29uc3QgY29tcG9uZW50c0NvdW50ID0gc2l6LkNzaXo7CiAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29tcG9uZW50c0NvdW50OyBpIDwgaWk7IGkrKykgewogICAgY29uc3QgY29tcG9uZW50ID0gY29tcG9uZW50c1tpXTsKICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHRpbGVzLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgdGlsZUNvbXBvbmVudCA9IHt9OwogICAgICB0aWxlID0gdGlsZXNbal07CiAgICAgIHRpbGVDb21wb25lbnQudGN4MCA9IE1hdGguY2VpbCh0aWxlLnR4MCAvIGNvbXBvbmVudC5YUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN5MCA9IE1hdGguY2VpbCh0aWxlLnR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iAgICAgICAgY2J5OiBqLAogICAgICAgIHRieDA6IGNvZGVibG9ja1dpZHRoICogaSwKICAgICAgICB0YnkwOiBjb2RlYmxvY2tIZWlnaHQgKiBqLAogICAgICAgIHRieDE6IGNvZGVibG9ja1dpZHRoICogKGkgKyAxKSwKICAgICAgICB0YnkxOiBjb2RlYmxvY2tIZWlnaHQgKiAoaiArIDEpCiAgICAgIH07CiAgICAgIGNvZGVibG9jay50YngwXyA9IE1hdGgubWF4KHN1YmJhbmQudGJ4MCwgY29kZWJsb2NrLnRieDApOwogICAgICBjb2RlYmxvY2sudGJ5MF8gPSBNYXRoLm1heChzdWJiYW5kLnRieTAsIGNvZGVibG9jay50YnkwKTsKICAgICAgY29kZWJsb2NrLnRieDFfID0gTWF0aC5taW4oc3ViYmFuZC50YngxLCBjb2RlYmxvY2sudGJ4MSk7CiAgICAgIGNvZGVibG9jay50YnkxXyA9IE1hdGgubWluKHN1YmJhbmQudGJ5MSwgY29kZWJsb2NrLnRieTEpOwogICAgICBjb25zdCBwaSA9IE1hdGguZmxvb3IoKGNvZGVibG9jay50YngwXyAtIHN1YmJhbmQudGJ4MCkgLyBwcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RXaWR0aEluU3ViYmFuZCk7CiAgICAgIGNvbnN0IHBqID0gTWF0aC5mbG9vcigoY29kZWJsb2NrLnRieTBfIC0gc3ViYmFuZC50YnkwKSAvIHByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdEhlaWdodEluU3ViYmFuZCk7CiAgICAgIHByZWNpbmN0TnVtYmVyID0gcGkgKyBwaiAqIHByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHN3aWRlOwogICAgICBjb2RlYmxvY2sucHJlY2luY3ROdW1iZXIgPSBwcmVjaW5jdE51bWJlcjsKICAgICAgY29kZWJsb2NrLnN1YmJhbmRUeXBlID0gc3ViYmFuZC50eXBlOwogICAgICBjb2RlYmxvY2suTGJsb2NrID0gMzsKICAgICAgaWYgKGNvZGVibG9jay50YngxXyA8PSBjb2RlYmxvY2sudGJ4MF8gfHwgY29kZWJsb2NrLnRieTFfIDw9IGNvZGVibG9jay50YnkwXykgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvZGVibG9ja3MucHVzaChjb2RlYmxvY2spOwogICAgICBsZXQgcHJlY2luY3QgPSBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdOwogICAgICBpZiAocHJlY2luY3QgIT09IHVuZGVmaW5lZCkgewogICAgICAgIGlmIChpIDwgcHJlY2luY3QuY2J4TWluKSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnhNaW4gPSBpOwogICAgICAgIH0gZWxzZSBpZiAoaSA+IHByZWNpbmN0LmNieE1heCkgewogICAgICAgICAgcHJlY2luY3QuY2J4TWF4ID0gaTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPCBwcmVjaW5jdC5jYnlNaW4pIHsKICAgICAgICAgIHByZWNpbmN0LmNieE1pbiA9IGo7CiAgICAgICAgfSBlbHNlIGlmIChqID4gcHJlY2luY3QuY2J5TWF4KSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnlNYXggPSBqOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdID0gcHJlY2luY3QgPSB7CiAgICAgICAgICBjYnhNaW46IGksCiAgICAgICAgICBjYnlNaW46IGosCiAgICAgICAgICBjYnhNYXg6IGksCiAgICAgICAgICBjYnlNYXg6IGoKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvZGVibG9jay5wcmVjaW5jdCA9IHByZWNpbmN0OwogICAgfQogIH0KICBzdWJiYW5kLmNvZGVibG9ja1BhcmFtZXRlcnMgPSB7CiAgICBjb2RlYmxvY2tXaWR0aDogeGNiXywKICAgIGNvZGVibG9ja0hlaWdodDogeWNiXywKICAgIG51bWNvZGVibG9ja3dpZGU6IGNieDEgLSBjYngwICsgMSwKICAgIG51bWNvZGVib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3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICByID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25MYXllckNvbXBvbmVudFBvc2l0aW9uSXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBsZXQgbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gMDsKICBmb3IgKGxldCBxID0gMDsgcSA8IGNvbXBvbmVudHNDb3VudDsgcSsrKSB7CiAgICBtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBNYXRoLm1heChtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQsIHRpbGUuY29tcG9uZW50c1txXS5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KTsKICB9CiAgbGV0IHIgPSAwLAogICAgbCA9IDAsCiAgICBpID0gMCwKICAgIGsgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgciA8PSBtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQ7IHIrKykgewogICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OyBsKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICBsID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25Qb3NpdGlvbkNvbXBvbmVudExheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGN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MubnVtcHJlY2luY3RzKTsKICAgICAgfQogICAgfQogICAgbWF4TnVtUHJlY2luY3RzSW5MZXZlbFtyXSA9IG1heE51bVByZWNpbmN0czsKICB9CiAgbCA9IDA7CiAgciA9IDA7CiAgYyA9IDA7CiAgcCA9IDA7CiAgdGhpcy5uZXh0UGFja2V0ID0gZnVuY3Rpb24gSnB4SW1hZ2VfbmV4dFBhY2tldCgpIHsKICAgIGZvciAoOyByIDw9IG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgIGZvciAoOyBwIDwgbWF4TnVtUHJlY2luY3RzSW5MZXZlbFtyXTsgcCsrKSB7CiAgICAgICAgZm9yICg7IGMgPCBjb21wb25lbnRzQ291bnQ7IGMrKykgewogICAgICAgICAgY29uc3QgY29tcG9uZW50ID0gdGlsZS5jb21wb25lbnRzW2NdOwogICAgICAgICAgaWYgKHIgPiBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICBjb25zdCBudW1wcmVjaW5jdHMgPSByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHM7CiAgICAgICAgICBpZiAocCA+PSBudW1wcmVjaW5jdHMpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcCwgbCk7CiAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGwgPSAwOwogICAgICAgIH0KICAgICAgICBjID0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b25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdLnJlc29sdXRpb25zW3JdOwogICAgICAgICAgICBjb25zdCBrID0gZ2V0UHJlY2luY3RJbmRleElmRXhpc3QocHgsIHB5LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcywgcmVzb2x1dGlvbik7CiAgICAgICAgICAgIGlmIChrID09PSBudWxsKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICg7IGwgPCBsYXllcnNDb3VudDspIHsKICAgICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgICAgbCsrOwogICAgICAgICAgICAgIHJldHVybiBwYWNrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgYyA9IDA7CiAgICAgIH0KICAgICAgcHggPSAwOwogICAgfQogICAgdGhyb3cgbmV3IEpweEVycm9yKCJPdXQgb2YgcGFja2V0cyIpOwogIH07Cn0KZnVuY3Rpb24gQ29tcG9uZW50UG9zaXRpb25SZXNvbHV0aW9uTGF5ZXJJdGVyYXRvcihjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pb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hbGUgPSBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgICAgY29uc3QgayA9IGdldFByZWNpbmN0SW5kZXhJZkV4aXN0KHB4LCBweSwgc2l6ZUluSW1hZ2VTY2FsZSwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMsIHJlc29sdXRpb24pOwogICAgICAgICAgICBpZiAoayA9PT0gbnVsbCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoOyBsIDwgbGF5ZXJzQ291bnQ7KSB7CiAgICAgICAgICAgICAgY29uc3QgcGFja2V0ID0gY3JlYXRlUGFja2V0KHJlc29sdXRpb24sIGssIGwpOwogICAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgICByZXR1cm4gcGFja2V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGwgPSAwOwogICAgICAgICAgfQogICAgICAgICAgciA9IDA7CiAgICAgICAgfQogICAgICAgIHB4ID0gMDsKICAgICAgfQogICAgICBweSA9IDA7CiAgICB9CiAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIk91dCBvZiBwYWNrZXRzIik7CiAgfTsKfQpmdW5jdGlvbiBnZXRQcmVjaW5jdEluZGV4SWZFeGlzdChweEluZGV4LCBweUluZGV4LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdEl0ZXJhdGlvblNpemVzLCByZXNvbHV0aW9uKSB7CiAgY29uc3QgcG9zWCA9IHB4SW5kZXggKiBwcmVjaW5jdEl0ZXJhdGlvblNpemVzLm1pbldpZHRoOwogIGNvbnN0IHBvc1kgPSBweUluZGV4ICogcHJlY2luY3RJdGVyYXRpb25TaXplcy5taW5IZWlnaHQ7CiAgaWYgKHBvc1ggJSBzaXplSW5JbWFnZVNjYWxlLndpZHRoICE9PSAwIHx8IHBvc1kgJSBzaXplSW5JbWFnZVNjYWxlLmhlaWdodCAhPT0gMCkgewogICAgcmV0d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gPSB7CiAgICAgICAgd2lkdGg6IHdpZHRoQ3VycmVudFJlc29sdXRpb24sCiAgICAgICAgaGVpZ2h0OiBoZWlnaHRDdXJyZW50UmVzb2x1dGlvbgogICAgICB9OwogICAgICBzY2FsZSA8PD0gMTsKICAgIH0KICAgIG1pbldpZHRoID0gTWF0aC5taW4obWluV2lkdGgsIG1pbldpZHRoQ3VycmVudENvbXBvbmVudCk7CiAgICBtaW5IZWlnaHQgPSBNYXRoLm1pbihtaW5IZWlnaHQsIG1pbkhlaWdodEN1cnJlbnRDb21wb25lbnQpOwogICAgbWF4TnVtV2lkZSA9IE1hdGgubWF4KG1heE51bVdpZGUsIG1heE51bVdpZGVDdXJyZW50Q29tcG9uZW50KTsKICAgIG1heE51bUhpZ2ggPSBNYXRoLm1heChtYXhOdW1IaWdoLCBtYXhOdW1IaWdoQ3VycmVudENvbXBvbmVudCk7CiAgICBzaXplUGVyQ29tcG9uZW50W2NdID0gewogICAgICByZXNvbHV0aW9uczogc2l6ZVBlclJlc29sdXRpb24sCiAgICAgIG1pbldpZHRoOiBtaW5XaWR0aEN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1pbkhlaWdodDogbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCwKICAgICAgbWF4TnVtV2lkZTogbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1heE51bUhpZ2g6IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50CiAgICB9OwogIH0KICByZXR1cm4gewogICAgY29tcG9uZW50czogc2l6ZVBlckNvbXBvbmVudCwKICAgIG1pbldpZHRoLAogICAgbWluSGVpZ2h0LAogICAgbWF4TnVtV2lkZSwKICAgIG1heE51bUhpZ2gKICB9Owp9CmZ1bmN0aW9uIGJ1aWxkUGFja2V0cyhjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleD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dodCwgbGF5ZXJOdW1iZXIpOwogICAgICAgICAgemVyb0JpdFBsYW5lc1RyZWUgPSBuZXcgVGFnVHJlZSh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgIHByZWNpbmN0LmluY2x1c2lvblRyZWUgPSBpbmNsdXNpb25UcmVlOwogICAgICAgICAgcHJlY2luY3QuemVyb0JpdFBsYW5lc1RyZWUgPSB6ZXJvQml0UGxhbmVzVHJlZTsKICAgICAgICAgIGZvciAobGV0IGwgPSAwOyBsIDwgbGF5ZXJOdW1iZXI7IGwrKykgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkgIT09IDApIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIkludmFsaWQgdGFnIHRyZWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoaW5jbHVzaW9uVHJlZS5yZXNldChjb2RlYmxvY2tDb2x1bW4sIGNvZGVibG9ja1JvdywgbGF5ZXJOdW1iZXIpKSB7CiAgICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkpIHsKICAgICAgICAgICAgICB2YWx1ZVJlYWR5ID0gIWluY2x1c2lvblRyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgICAgaWYgKHZhbHVlUmVhZHkpIHsKICAgICAgICAgICAgICAgIGNvZGVibG9jay5pbmNsdWRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9IGZpcnN0VGltZUluY2x1c2lvbiA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaW5jbHVzaW9uVHJlZS5pbmNyZW1lbnRWYWx1ZShsYXllck51bWJlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFjb2RlYmxvY2tJbmNsdWRlZCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChmaXJzdFRpbWVJbmNsdXNpb24pIHsKICAgICAgICB6ZXJvQml0UGxhbmVzVHJlZSA9IHByZWNpbmN0Lnplcm9CaXRQbGFuZXNUcmVlOwogICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLnJlc2V0KGNvZGVibG9ja0NvbHVtbiwgY29kZWJsb2NrUm93KTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgaWYgKHJlYWRCaXRzKDEpKSB7CiAgICAgICAgICAgIHZhbHVlUmVhZHkgPSAhemVyb0JpdFBsYW5lc1RyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgIGlmICh2YWx1ZVJlYWR5KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLmluY3JlbWVudFZhbHVlKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvZGVibG9jay56ZXJvQml0UGxhbmVzID0gemVyb0JpdFBsYW5lc1RyZWUudmFsdWU7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzID0gcmVhZENvZGluZ3Bhc3NlcygpOwogICAgICB3aGlsZSAocmVhZEJpdHMoMSkpIHsKICAgICAgICBjb2RlYmxvY2suTGJsb2NrKys7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzTG9nMiA9ICgwLCBfY29yZV91dGlscy5sb2cyKShjb2RpbmdwYXNzZXMpOwogICAgICBjb25zdCBiaXRzID0gKGNvZGluZ3Bhc3NlcyA8IDEgPDwgY29kaW5ncGFzc2VzTG9nMiA/IGNvZGluZ3Bhc3Nlc0xvZzIgLSAxIDogY29kaW5ncGFzc2VzTG9nMikgKyBjb2RlYmxvY2suTGJsb2NrOw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W9kZWwucnVuTWFnbml0dWRlUmVmaW5lbWVudFBhc3MoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIGJpdE1vZGVsLnJ1bkNsZWFudXBQYXNzKCk7CiAgICAgICAgICBpZiAoc2VnbWVudGF0aW9uU3ltYm9sVXNlZCkgewogICAgICAgICAgICBiaXRNb2RlbC5jaGVja1NlZ21lbnRhdGlvblN5bWJvbCgpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMpIHsKICAgICAgICBiaXRNb2RlbC5yZXNldCgpOwogICAgICB9CiAgICAgIGN1cnJlbnRDb2RpbmdwYXNzVHlwZSA9IChjdXJyZW50Q29kaW5ncGFzc1R5cGUgKyAxKSAlIDM7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gY29kZWJsb2NrLnRieDBfIC0geDAgKyAoY29kZWJsb2NrLnRieTBfIC0geTApICogd2lkdGg7CiAgICBjb25zdCBzaWduID0gYml0TW9kZWwuY29lZmZpY2VudHNTaWduOwogICAgY29uc3QgbWFnbml0dWRlID0gYml0TW9kZWwuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgICBjb25zdCBiaXRzRGVjb2RlZCA9IGJpdE1vZGVsLmJpdHNEZWNvZGVkOwogICAgY29uc3QgbWFnbml0dWRlQ29ycmVjdGlvbiA9IHJldmVyc2libGUgPyAwIDogMC41OwogICAgbGV0IGssIG4sIG5iOwogICAgcG9zaXRpb24gPSAwOwogICAgY29uc3QgaW50ZXJsZWF2ZSA9IHN1YmJhbmQudHlwZSAhPT0gIkxMIjsKICAgIGZvciAoaiA9IDA7IGogPCBibG9ja0hlaWdodDsgaisrKSB7CiAgICAgIGNvbnN0IHJvdyA9IG9mZnNldCAvIHdpZHRoIHwgMDsKICAgICAgY29uc3QgbGV2ZWxPZmZzZXQgPSAyICogcm93ICogKGxldmVsV2lkdGggLSB3aWR0aCkgKyByaWdodCArIGJvdHRvbTsKICAgICAgZm9yIChrID0gMDsgayA8IGJsb2NrV2lkdGg7IGsrKykgewogICAgICAgIG4gPSBtYWduaXR1ZGVbcG9zaXRpb25dOwogICAgICAgIGlmIChuICE9PSAwKSB7CiAgICAgICAgICBuID0gKG4gKyBtYWduaXR1ZGVDb3JyZWN0aW9uKSAqIGRlbHRhOwogICAgICAgICAgaWYgKHNpZ25bcG9zaXRpb25dICE9PSAwKSB7CiAgICAgICAgICAgIG4gPSAtbjsKICAgICAgICAgIH0KICAgICAgICAgIG5iID0gYml0c0RlY29kZWRbcG9zaXRpb25dOwogICAgICAgICAgY29uc3QgcG9zID0gaW50ZXJsZWF2ZSA/IGxldmVsT2Zmc2V0ICsgKG9mZnNldCA8PCAxKSA6IG9mZnNldDsKICAgICAgICAgIGlmIChyZXZlcnNpYmxlICYmIG5iID49IG1iKSB7CiAgICAgICAgICAgIGNvZWZmaWNpZW50c1twb3NdID0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGNvZWZmaWNpZW50c1twb3NdID0gbiAqICgxIDw8IG1iIC0gbmIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvZmZzZXQrKzsKICAgICAgICBwb3NpdGlvbisrOwogICAgICB9CiAgICAgIG9mZnNldCArPSB3aWR0aCAtIGJsb2NrV2lkdGg7CiAgICB9CiAgfQp9CmZ1bmN0aW9uIHRyYW5zZm9ybVRpbGUoY29udGV4dCwgdGlsZSwgYykgewogIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICBjb25zdCBjb2RpbmdTdHlsZVBhcmFtZXRlcnMgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzOwogIGNvbnN0IHF1YW50aXphdGlvblBhcmFtZXRlcnMgPSBjb21wb25lbnQucXVhbnRpemF0aW9uUGFyYW1ldGVyczsKICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2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ZvciAoaiA9IDA7IGogPCBqajsgaisrLCBwb3MgKz0gYWxwaGEwMSkgewogICAgICAgICAgeTAgPSB5MGl0ZW1zW2pdICsgb2Zmc2V0OwogICAgICAgICAgeTEgPSB5MWl0ZW1zW2pdOwogICAgICAgICAgeTIgPSB5Mml0ZW1zW2pdOwogICAgICAgICAgb3V0W3BvcysrXSA9IHkwICsgMS40MDIgKiB5MiA+PiBzaGlmdDsKICAgICAgICAgIG91dFtwb3MrK10gPSB5MCAtIDAuMzQ0MTMgKiB5MSAtIDAuNzE0MTQgKiB5MiA+PiBzaGlmdDsKICAgICAgICAgIG91dFtwb3MrK10gPSB5MCArIDEuNzcyICogeTEgPj4gc2hpZnQ7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAoaiA9IDA7IGogPCBqajsgaisrLCBwb3MgKz0gYWxwaGEwMSkgewogICAgICAgICAgeTAgPSB5MGl0ZW1zW2pdICsgb2Zmc2V0OwogICAgICAgICAgeTEgPSB5MWl0ZW1zW2pdOwogICAgICAgICAgeTIgPSB5Mml0ZW1zW2pdOwogICAgICAgICAgY29uc3QgZyA9IHkwIC0gKHkyICsgeTEgPj4gMik7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkyID4+IHNoaWZ0OwogICAgICAgICAgb3V0W3BvcysrXSA9IGcgPj4gc2hpZnQ7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkxID4+IHNoaWZ0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZm91ckNvbXBvbmVudHMpIHsKICAgICAgICBmb3IgKGogPSAwLCBwb3MgPSAzOyBqIDwgamo7IGorKywgcG9zICs9IDQpIHsKICAgICAgICAgIG91dFtwb3NdID0geTNpdGVtc1tqXSArIG9mZnNldCA+PiBzaGlmdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgICAg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gICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldmVsLmluZGV4ID0gaW5kZXg7CiAgICAgIGkgPj49IDE7CiAgICAgIGogPj49IDE7CiAgICAgIGN1cnJlbnRMZXZlbCsrOwogICAgfQogICAgY3VycmVudExldmVsLS07CiAgICBsZXZlbCA9IHRoaXMubGV2ZWxzW2N1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0gPSB2YWx1ZTsKICAgIHRoaXMuY3VycmVudExldmVsID0gY3VycmVudExldmVsOwogICAgZGVsZXRlIHRoaXMudmFsdWU7CiAgfQogIGluY3JlbWVudFZhbHVlKCkgewogICAgY29uc3QgbGV2ZWwgPSB0aGlzLmxldmVsc1t0aGlzLmN1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0rKzsKICB9CiAgbmV4dExldmVsKCkgewogICAgbGV0IGN1cnJlbnRMZXZlbCA9IHRoaXMuY3VycmVudExldmVsOwogICAgbGV0IGxldmVsID0gdGhpcy5sZXZlbHNbY3VycmVudExldmVsXTsKICAgIGNvbnN0IHZhbHVlID0gbGV2ZWwuaXRlbXNbbGV2ZWwuaW5kZXhdOwogICAgY3VycmVudExldmVsLS07CiAgICBpZiAoY3VycmVudExldmVsIDwgMCkgewogICAgICB0aGlzLnZhbHVlID0gdmFsdWU7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIHRoaXMuY3VycmVudExldmVsID0gY3VycmVudExldmVsOwogICAgbGV2ZWwgPSB0aGlzLmxldmVsc1tjdXJyZW50TGV2ZWxdOwogICAgbGV2ZWwuaXRlbXNbbGV2ZWwuaW5kZXhdID0gdmFsdWU7CiAgICByZXR1cm4gdHJ1ZTsKICB9Cn0KY2xhc3MgSW5jbHVzaW9uVHJlZSB7CiAgY29uc3RydWN0b3Iod2lkdGgsIGhlaWdodCwgZGVmYXVsdFZhbHVlKSB7CiAgICBjb25zdCBsZXZlbHNMZW5ndGggP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hBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgdGhpcy5jb2VmZmljZW50c1NpZ24gPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgbGV0IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICBpZiAobWIgPiAxNCkgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQzMkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgaWYgKG1iID4gNikgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQxNkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQ4QXJyYXkoY29lZmZpY2llbnRDb3VudCk7CiAgICAgIH0KICAgICAgdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZSA9IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICB0aGlzLnByb2Nlc3NpbmdGbGFncyA9IG5ldyBVaW50OEFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICBjb25zdCBiaXRzRGVjb2RlZCA9IG5ldyBVaW50OEFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICBpZiAoemVyb0JpdFBsYW5lcyAhPT0gMCkgewogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29lZmZpY2llbnRDb3VudDsgaSsrKSB7CiAgICAgICAgICBiaXRzRGVjb2RlZFtpXSA9IHplcm9CaXRQbGFuZXM7CiAgICAgICAgfQogICAgICB9CiAgICAgIHRoaXMuYml0c0RlY29kZWQgPSBiaXRzRGVjb2RlZDsKICAgICAgdGhpcy5yZXNldCgpOwogICAgfQogICAgc2V0RGVjb2RlcihkZWNvZGVyKSB7CiAgICAgIHRoaXMuZGVjb2RlciA9IGRlY29kZXI7CiAgICB9CiAgICByZXNldCgpIHsKICAgICAgdGhpcy5jb250ZXh0cyA9IG5ldyBJbnQ4QXJyYXkoMTkpOwogICAgICB0aGlzLmNvbnRleHRzWzBdID0gNCA8PCAxIHwgMDsKICAgICAgdGhpcy5jb250ZXh0c1tVTklGT1JNX0NPTlRFWFRdID0gNDYgPDwgMSB8IDA7CiAgICAgIHRoaXMuY29udGV4dHNbUlVOTEVOR1RIX0NPTlRFWFRdID0gMyA8PCAxIHwgMDsKICAgIH0KICAgIHNldE5laWdoYm9yc1NpZ25pZmljYW5jZShyb3csIGNvbHVtbiwgaW5kZXgpIHsKICAgICAgY29uc3QgbmVpZ2hib3JzU2lnbmlmaWNhbmNlID0gdGhpcy5uZWlnaGJvcnNTaWduaWZpY2FuY2U7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCwKICAgICAgICBoZWlnaHQgPSB0aGlzLmhlaWdodDsKICAgICAgY29uc3QgbGVmdCA9IGNvbHVtbiA+IDA7CiAgICAgIGNvbnN0IHJpZ2h0ID0gY29sdW1uICsgMSA8IHdpZHRoOwogICAgICBsZXQgaTsKICAgICAgaWYgKHJvdyA+IDApIHsKICAgICAgICBpID0gaW5kZXggLSB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKHJvdyArIDEgPCBoZWlnaHQpIHsKICAgICAgICBpID0gaW5kZXggKyB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocml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rID0gfjE7CiAgICAgIGNvbnN0IHByb2Nlc3NlZE1hc2sgPSAxOwogICAgICBjb25zdCBmaXJzdE1hZ25pdHVkZUJpdE1hc2sgPSAyOwogICAgICBmb3IgKGxldCBpMCA9IDA7IGkwIDwgaGVpZ2h0OyBpMCArPSA0KSB7CiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICBsZXQgaW5kZXggPSBpMCAqIHdpZHRoICsgajsKICAgICAgICAgIGZvciAobGV0IGkxID0gMDsgaTEgPCA0OyBpMSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBjb25zdCBpID0gaTAgKyBpMTsKICAgICAgICAgICAgaWYgKGkgPj0gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmPSBwcm9jZXNzZWRJbnZlcnNlTWFzazsKICAgICAgICAgICAgaWYgKGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSB8fCAhbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGNvbnRleHRMYWJlbCA9IGxhYmVsc1tuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdXTsKICAgICAgICAgICAgY29uc3QgZGVjaXNpb24gPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIGNvbnRleHRMYWJlbCk7CiAgICAgICAgICAgIGlmIChkZWNpc2lvbikgewogICAgICAgICAgICAgIGNvbnN0IHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzU2lnbltpbmRleF0gPSBzaWduOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSA9IDE7CiAgICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gZmlyc3RNYWduaXR1ZGVCaXRNYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4XSsrOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IHByb2Nlc3NlZE1hc2s7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBkZWNvZGVTaWduQml0KHJvdywgY29sdW1uLCBpbmRleCkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0dWRlID0gdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZTsKICAgICAgY29uc3QgY29lZmZpY2VudHNTaWduID0gdGhpcy5jb2VmZmljZW50c1NpZ247CiAgICAgIGxldCBjb250cmlidXRpb24sIHNpZ24wLCBzaWduMSwgc2lnbmlmaWNhbmNlMTsKICAgICAgbGV0IGNvbnRleHRMYWJlbCwgZGVjb2RlZDsKICAgICAgc2lnbmlmaWNhbmNlMSA9IGNvbHVtbiA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSAxXSAhPT0gMDsKICAgICAgaWYgKGNvbHVtbiArIDEgPCB3aWR0aCAmJiBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleCArIDFdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyAxXTsKICAgICAgICBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgICAgc2lnbjAgPSBjb2VmZmljZW50c1NpZ25baW5kZXggLSAxXTsKICAgICAgICAgIGNvbnRyaWJ1dGlvbiA9IDEgLSBzaWduMSAtIHNpZ24wOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gMV07CiAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24wIC0gc2lnbjA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gMDsKICAgICAgfQogICAgICBjb25zdCBob3Jpem9udGFsQ29udHJpYnV0aW9uID0gMyAqIGNvbnRyaWJ1dGlvbjsKICAgICAgc2lnbmlmaWNhbmNlMSA9IHJvdyA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSB3aWR0aF0gIT09IDA7CiAgICAgIGlmIChyb3cgKyAxIDwgaGVpZ2h0ICYmIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4ICsgd2lkdGhdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyB3aWR0aF07CiAgICAgICAgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gd2lkdGhdOwogICAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24xIC0gc2lnbjAgKyBob3Jpem9udGFsQ29udHJpYnV0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMSArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICBzaWduMCA9IGNvZWZmaWNlbnRzU2lnbltpbmRleCAtIHdpZHRoXTsKICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjAgLSBzaWduMCArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gaG9yaXpvbnRhbENvbnRyaWJ1dGlvbjsKICAgICAgfQogICAgICBpZiAoY29udHJpYnV0aW9uID49IDApIHsKICAgICAgICBjb250ZXh0TGFiZWwgPSA5ICsgY29udHJpYnV0aW9uOwogICAgICAgIGRlY29kZWQgPSB0aGlzLmRlY29kZXIucmVhZEJpdCh0aGlzLmNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDkgLSBjb250cmlidXRpb247CiAgICAgICAgZGVjb2RlZCA9IHRoaXMuZGVjb2Rlci5yZWFkQml0KHRoaXMuY29udGV4dHMsIGNvbnRleHRMYWJlbCkgXiAxOwogICAgICB9CiAgICAgIHJldHVybiBkZWNvZGVkOwogICAgfQogICAgcnVuTWFnbml0dWRlUmVmaW5lbWVudFBhc3MoKSB7CiAgICAgIGNvbnN0IGRlY29kZXIgPSB0aGlzLmRlY29kZXI7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCwKICAgICAgICBoZWlnaHQgPSB0aGlzLmhlaWdodDsKICAgICAgY29uc3QgY29lZmZpY2VudHNNYWduaXR1ZGUgPSB0aGlzLmNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICBjb25zdCBuZWlnaGJvcnNTaWduaWZpY2FuY2UgPSB0aGlzLm5laWdoYm9yc1NpZ25pZmljYW5jZTsKICAgICAgY29uc3QgY29udGV4dHMgPSB0aGlzLmNvbnRleHRzOwogICAgICBjb25zdCBiaXRzRGVjb2RlZCA9IHRoaXMuYml0c0RlY29kZWQ7CiAgICAgIGNvbnN0IHByb2Nlc3NpbmdGbGFncyA9IHRoaXMucHJvY2Vzc2luZ0ZsYWdzOwogICAgICBjb25zdCBwcm9jZXNzZWRNYXNrID0gMTsKICAgICAgY29uc3QgZmlyc3RNYWduaXR1ZGVCaXRNYXNrID0gMjsKICAgICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQ7CiAgICAgIGNvbnN0IHdpZHRoNCA9IHdpZHRoICogNDsKICAgICAgZm9yIChsZXQgaW5kZXgwID0gMCwgaW5kZXhOZXh0OyBpbmRleDAgPCBsZW5ndGg7IGluZGV4MCA9IGluZGV4TmV4dCkgewogICAgICAgIGluZGV4TmV4dCA9IE1hdGgubWluKGxlbmd0aCwgaW5kZXgwICsgd2lkdGg0KTsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGluZGV4ID0gaW5kZXgwICsgajsgaW5kZXggPCBpbmRleE5leHQ7IGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgIGlmICghY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgY29udGV4dExhYmVsID0gMTY7CiAgICAgICAgICAgIGlmICgocHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmIGZpcnN0TWFnbml0dWRlQml0TWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIF49IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgICBjb25zdCBzaWduaWZpY2FuY2UgPSBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdICYgMTI3OwogICAgICAgICAgICAgIGNvbnRleHRMYWJlbCA9IHNpZ25pZmljYW5jZSA9PT0gMCA/IDE1IDogMTQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgYml0ID0gZGVjb2Rlci5yZWF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AgICAgICAgICBpZiAoYWxsRW1wdHkpIHsKICAgICAgICAgICAgY29uc3QgaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBSVU5MRU5HVEhfQ09OVEVYVCk7CiAgICAgICAgICAgIGlmICghaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50KSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwXSsrOwogICAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4MCArIG9uZVJvd0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdHdvUm93c0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0rKzsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpMSA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAxIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpOwogICAgICAgICAgICBpZiAoaTEgIT09IDApIHsKICAgICAgICAgICAgICBpID0gaTAgKyBpMTsKICAgICAgICAgICAgICBpbmRleCArPSBpMSAqIHdpZHRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdID0gMTsKICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgaW5kZXggPSBpbmRleDA7CiAgICAgICAgICAgIGZvciAobGV0IGkyID0gaTA7IGkyIDw9IGk7IGkyKyssIGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaTErKzsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGkwICsgaTE7IGkgPCBpTmV4dDsgaSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBpZiAoY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBjb250ZXh0TGFiZWwgPSBsYWJlbHNbbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XV07CiAgICAgICAgICAgIGNvbnN0IGRlY2lzaW9uID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBpZiAoZGVjaXNpb24gPT09IDEpIHsKICAgICAgICAgICAgICBzaWduID0gdGhpcy5kZWNvZGVTaWduQml0KGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSAxOwogICAgICAgICAgICAgIHRoaXMuc2V0TmVpZ2hib3JzU2lnbmlmaWNhbmNlKGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaXRzRGVjb2RlZFtpbmRleF0rKzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICA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IH0KICAgIGxldCBiLAogICAgICBjdXJyZW50QnVmZmVyID0gMDsKICAgIGxsID0gYnVmZmVyUGFkZGluZyArIGhlaWdodDsKICAgIGlmIChoZWlnaHQgPT09IDEpIHsKICAgICAgaWYgKCh2MCAmIDEpICE9PSAwKSB7CiAgICAgICAgZm9yICh1ID0gMDsgdSA8IHdpZHRoOyB1KyspIHsKICAgICAgICAgIGl0ZW1zW3VdICo9IDAuNTsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAodSA9IDA7IHUgPCB3aWR0aDsgdSsrKSB7CiAgICAgICAgaWYgKGN1cnJlbnRCdWZmZXIgPT09IDApIHsKICAgICAgICAgIG51bUJ1ZmZlcnMgPSBNYXRoLm1pbih3aWR0aCAtIHUsIG51bUJ1ZmZlcnMpOwogICAgICAgICAgZm9yIChrID0gdSwgbCA9IGJ1ZmZlclBhZGRpbmc7IGwgPCBsbDsgayArPSB3aWR0aCwgbCsrKSB7CiAgICAgICAgICAgIGZvciAoYiA9IDA7IGIgPCBudW1CdWZmZXJzOyBiKyspIHsKICAgICAgICAgICAgICBjb2xCdWZmZXJzW2JdW2xdID0gaXRlbXNbayArIGJdOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBjdXJyZW50QnVmZmVyID0gbnVtQnVmZmVyczsKICAgICAgICB9CiAgICAgICAgY3VycmVudEJ1ZmZlci0tOwogICAgICAgIGNvbnN0IGJ1ZmZlciA9IGNvbEJ1ZmZlcnNbY3VycmVudEJ1ZmZlcl07CiAgICAgICAgdGhpcy5leHRlbmQoYnVmZmVyLCBidWZmZXJQYWRkaW5nLCBoZWlnaHQpOwogICAgICAgIHRoaXMuZmlsdGVyKGJ1ZmZlciwgYnVmZmVyUGFkZGluZywgaGVpZ2h0KTsKICAgICAgICBpZiAoY3VycmVudEJ1ZmZlciA9PT0gMCkgewogICAgICAgICAgayA9IHUgLSBudW1CdWZmZXJzICsgMTsKICAgICAgICAgIGZvciAob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Y3VycmVudCAtIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGRlbHRhICogeFtqICsgMV07CiAgICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGogPSBvZmZzZXQgLSAxOwogICAgY3VycmVudCA9IGdhbW1hICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAyOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSAtPSBjdXJyZW50ICsgbmV4dDsKICAgICAgaWYgKG4tLSkgewogICAgICAgIGogKz0gMjsKICAgICAgICBjdXJyZW50ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBqID0gb2Zmc2V0OwogICAgY3VycmVudCA9IGJldGEgKiB4W2ogLSAxXTsKICAgIGZvciAobiA9IGxlbiArIDE7IG4tLTsgaiArPSAyKSB7CiAgICAgIG5leHQgPSBiZXRhICogeFtqICsgMV07CiAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGJldGEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAobGVuICE9PSAwKSB7CiAgICAgIGogPSBvZmZzZXQgKyAxOwogICAgICBjdXJyZW50ID0gYWxwaGEgKiB4W2ogLSAxXTsKICAgICAgZm9yIChuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICAgIG5leHQgPSBhbHBoYSAqIHhbaiArIDFdOwogICAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgICAgaWYgKG4tLSkgewogICAgICAgICAgaiArPSAyOwogICAgICAgICAgY3VycmVudCA9IGFscGhhICogeFtqICsgMV07CiAgICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9Cn0KY2xhc3MgUmV2ZXJzaWJsZVRyYW5zZm9ybSBleHRlbmRzIFRyYW5zZm9ybSB7CiAgZmlsdGVyKHgsIG9mZnNldCwgbGVuZ3RoKSB7CiAgICBjb25zdCBsZW4gPSBsZW5ndGggPj4gMTsKICAgIG9mZnNldCB8PSAwOwogICAgbGV0IGosIG47CiAgICBmb3IgKGogPSBvZmZzZXQsIG4gPSBsZW4gKyAxOyBuLS07IGogKz0gMikgewogICAgICB4W2pdIC09IHhbaiAtIDFdICsgeFtqICsgMV0gKyAyID4+IDI7CiAgICB9CiAgICBmb3IgKGogPSBvZmZzZXQgKyAxLCBuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICB4W2pdICs9IHhbaiAtIDFdICsgeFtqICsgMV0gPj4gMTsKICAgIH0KICB9Cn0KCi8qKiovIH0pLAovKiAxNjYgKi8KLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKInVzZSBzdHJpY3QiOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpleHBvcnRzLkxaV1N0cmVhbSA9IHZvaWQgMDsKdmFyIF9kZWNvZGVfc3RyZWFtID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTMpOwpjbGFzcyBMWldTdHJlYW0gZXh0ZW5kcyBfZGVjb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gICAgIGN1cnJlbnRTZXF1ZW5jZVtqXSA9IGRpY3Rpb25hcnlWYWx1ZXNbcV07CiAgICAgICAgICAgIHEgPSBkaWN0aW9uYXJ5UHJldkNvZGVzW3FdOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50U2VxdWVuY2VbY3VycmVudFNlcXVlbmNlTGVuZ3RoKytdID0gY3VycmVudFNlcXVlbmNlWzBdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAyNTYpIHsKICAgICAgICBjb2RlTGVuZ3RoID0gOTsKICAgICAgICBuZXh0Q29kZSA9IDI1ODsKICAgICAgICBjdXJyZW50U2VxdWVuY2VMZW5ndGggPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5sendTdGF0ZTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoaGFzUHJldikgewogICAgICAgIGRpY3Rpb25hcnlQcmV2Q29kZXNbbmV4dENvZGVdID0gcHJldkNvZGU7CiAgICAgICAgZGljdGlvbmFyeUxlbmd0aHNbbmV4dENvZGVdID0gZGljdGlvbmFyeUxlbmd0aHNbcHJldkNvZGVdICsgMTsKICAgICAgICBkaWN0aW9uYXJ5VmFsdWVzW25leHRDb2RlXSA9IGN1cnJlbnRTZXF1ZW5jZVswXTsKICAgICAgICBuZXh0Q29kZSsrOwogICAgICAgIGNvZGVMZW5ndGggPSBuZXh0Q29kZSArIGVhcmx5Q2hhbmdlICYgbmV4dENvZGUgKyBlYXJseUNoYW5nZSAtIDEgPyBjb2RlTGVuZ3RoIDogTWF0aC5taW4oTWF0aC5sb2cobmV4dENvZGUgKyBlYXJseUNoYW5nZSkgLyAwLjY5MzE0NzE4MDU1OTk0NTMgKyAxLCAxMikgfCAwOwogICAgICB9CiAgICAgIHByZXZDb2RlID0gY29kZTsKICAgICAgZG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sKICAgICAgICBidWZmZXJbcG9zKytdID0gc3VtICYgMHhmZjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgY29uc3QgY29tcEFycmF5ID0gbmV3IFVpbnQ4QXJyYXkoY29sb3JzICsgMSk7CiAgICAgIGNvbnN0IGJpdE1hc2sgPSAoMSA8PCBiaXRzKSAtIDE7CiAgICAgIGxldCBqID0gMCwKICAgICAgICBrID0gYnVmZmVyTGVuZ3RoOwogICAgICBjb25zdCBjb2x1bW5zID0gdGhpcy5jb2x1bW5zOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29sdW1uczsgKytpKSB7CiAgICAgICAgZm9yIChsZXQga2sgPSAwOyBrayA8IGNvbG9yczsgKytraykgewogICAgICAgICAgaWYgKGluYml0cyA8IGJpdHMpIHsKICAgICAgICAgICAgaW5idWYgPSBpbmJ1ZiA8PCA4IHwgcmF3Qnl0ZXNbaisrXSAmIDB4ZmY7CiAgICAgICAgICAgIGluYml0cyArPSA4OwogICAgICAgICAgfQogICAgICAgICAgY29tcEFycmF5W2trXSA9IGNvbXBBcnJheVtra10gKyAoaW5idWYgPj4gaW5iaXRzIC0gYml0cykgJiBiaXRNYXNrOwogICAgICAgICAgaW5iaXRzIC09IGJpdHM7CiAgICAgICAgICBvdXRidWYgPSBvdXRidWYgPDwgYml0cyB8IGNvbXBBcnJheVtra107CiAgICAgICAgICBvdXRiaXRzICs9IGJpdHM7CiAgICAgICAgICBpZiAob3V0Yml0cyA+PSA4KSB7CiAgICAgICAgICAgIGJ1ZmZlcltrKytdID0gb3V0YnVmID4+IG91dGJpdHMgLSA4ICYgMHhmZjsKICAgICAgICAgICAgb3V0Yml0cyAtPSA4OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAob3V0Yml0cyA+IDApIHsKICAgICAgICBidWZmZXJbaysrXSA9IChvdXRidWYgPDwgOCAtIG91dGJpdHMpICsgKGluYnVmICYgKDEgPDwgOCAtIG91dGJpdHMpIC0gMSk7CiAg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IGJ1ZmZlcltqKytdID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgfQogICAgICAgIGZvciAoOyBpIDwgcm93Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2pdID0gYnVmZmVyW2ogLSBwaXhCeXRlc10gKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcHJldlJvd1tpXSArIHJhd0J5dGVzW2ldICYgMHhmZjsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMzoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcGl4Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2orK10gPSAocHJldlJvd1tpXSA+PiAxKSArIHJhd0J5dGVzW2ldOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqXSA9IChwcmV2Um93W2ldICsgYnVmZmVyW2ogLSBwaXhCeXRlc10gPj4gMSkgKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDQ6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGMgPSByYXdCeXRlc1tpXTsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gdXAgKyBjOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGNvbnN0IHVwTGVmdCA9IHByZXZSb3dbaSAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IGxlZnQgPSBidWZmZXJbaiAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IHAgPSBsZWZ0ICsgdXAgLSB1cExlZnQ7CiAgICAgICAgICBsZXQgcGEgPSBwIC0gbGVmdDsKICAgICAgICAgIGlmIChwYSA8IDApIHsKICAgICAgICAgICAgcGEgPSAtcGE7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcGIgPSBwIC0gdXA7CiAgICAgICAgICBpZiAocGIgPCAwKSB7CiAgICAgICAgICAgIHBiID0gLXBiOwogICAgICAgICAgfQogICAgICAgICAgbGV0IHBjID0gcCAtIHVwTGVmdDsKICAgICAgICAgIGlmIChwYyA8IDApIHsKICAgICAgICAgICAgcGMgPSAtcGM7CiAgICAgICAgICB9CiAgICAgICAgICBjID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgICBpZiAocGEgPD0gcGIgJiYgcGEgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSBsZWZ0ICsgYzsKICAgICAgICAgIH0gZWxzZSBpZiAocGIgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSB1cCArIGM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWZmZXJbaisrXSA9IHVwTGVmdCArIGM7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5zdXBwb3J0ZWQgcHJlZGljdG9yOiAke3ByZWRpY3Rvcn1gKTsKICAgIH0KICAgIHRoaXMuYnVmZmVyTGVuZ3RoICs9IHJvd0J5dGVzOwogIH0KfQpleHBvcnRzLlByZWRpY3RvclN0cmVhbSA9IFByZWRpY3RvclN0cmVhbTsKCi8qKiovIH0pLAovKiAxNjggKi8KLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhw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CBnbHlwaElkXSBvZiB0b1VuaWNvZGVFeHRyYU1hcCkgewogICAgICBpZiAoZ2x5cGhJZCA+PSBudW1HbHlwaHMpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb2Rlcy5wdXNoKHsKICAgICAgICBmb250Q2hhckNvZGU6IHVuaWNvZGUsCiAgICAgICAgZ2x5cGhJZAogICAgICB9KTsKICAgIH0KICB9CiAgaWYgKGNvZGVzLmxlbmd0aCA9PT0gMCkgewogICAgY29kZXMucHVzaCh7CiAgICAgIGZvbnRDaGFyQ29kZTogMCwKICAgICAgZ2x5cGhJZDogMAogICAgfSk7CiAgfQogIGNvZGVzLnNvcnQoZnVuY3Rpb24gZm9udEdldFJhbmdlc1NvcnQoYSwgYikgewogICAgcmV0dXJuIGEuZm9udENoYXJDb2RlIC0gYi5mb250Q2hhckNvZGU7CiAgfSk7CiAgY29uc3QgcmFuZ2VzID0gW107CiAgY29uc3QgbGVuZ3RoID0gY29kZXMubGVuZ3RoOwogIGZvciAobGV0IG4gPSAwOyBuIDwgbGVuZ3RoOykgewogICAgY29uc3Qgc3RhcnQgPSBjb2Rlc1tuXS5mb250Q2hhckNvZGU7CiAgICBjb25zdCBjb2RlSW5kaWNlcyA9IFtjb2Rlc1tuXS5nbHlwaElkXTsKICAgICsrbjsKICAgIGxldCBlbmQgPSBzdGFydDsKICAgIHdoaWxlIChuIDwgbGVuZ3RoICYmIGVuZCArIDEgPT09IGNvZGVzW25dLmZvbnRDaGFyQ29kZSkgewogICAgICBjb2RlSW5kaWNlcy5wdXNoKGNvZGVzW25dLmdseXBoSWQpOwogICAgICArK2VuZDsKICAgICAgKytuOwogICAgICBpZiAoZW5kID09PSAweGZmZmYpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgcmFuZ2VzLnB1c2goW3N0YXJ0LCBlbmQsIGNvZGVJbmRpY2VzXSk7CiAgfQogIHJldHVybiByYW5nZXM7Cn0KZnVuY3Rpb24gY3JlYXRlQ21h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ICIiOwogIGxldCBnbHlwaHNJZHMgPSAiIjsKICBsZXQgYmlhcyA9IDA7CiAgbGV0IHJhbmdlLCBzdGFydCwgZW5kLCBjb2RlczsKICBmb3IgKGkgPSAwLCBpaSA9IGJtcExlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgIHJhbmdlID0gcmFuZ2VzW2ldOwogICAgc3RhcnQgPSByYW5nZVswXTsKICAgIGVuZCA9IHJhbmdlWzFdOwogICAgc3RhcnRDb3VudCArPSBzdHJpbmcxNihzdGFydCk7CiAgICBlbmRDb3VudCArPSBzdHJpbmcxNihlbmQpOwogICAgY29kZXMgPSByYW5nZVsyXTsKICAgIGxldCBjb250aWd1b3VzID0gdHJ1ZTsKICAgIGZvciAoaiA9IDEsIGpqID0gY29kZXMubGVuZ3RoOyBqIDwgamo7ICsraikgewogICAgICBpZiAoY29kZXNbal0gIT09IGNvZGVzW2ogLSAxXSArIDEpIHsKICAgICAgICBjb250aWd1b3VzID0gZmFsc2U7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGlmICghY29udGlndW91cykgewogICAgICBjb25zdCBvZmZzZXQgPSAoc2VnQ291bnQgLSBpKSAqIDIgKyBiaWFzICogMjsKICAgICAgYmlhcyArPSBlbmQgLSBzdGFydCArIDE7CiAgICAgIGlkRGVsdGFzICs9IHN0cmluZzE2KDApOwogICAgICBpZFJhbmdlT2Zmc2V0cyArPSBzdHJpbmcxNihvZmZzZXQpOwogICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBnbHlwaHNJZHMgKz0gc3RyaW5nMTYoY29kZXNbal0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBzdGFydENvZGUgPSBjb2Rlc1swXTsKICAgICAgaWREZWx0YXMgKz0gc3RyaW5nMTYoc3RhcnRDb2RlIC0gc3RhcnQgJiAweGZmZmYpOwogICAgICBpZFJhbmdlT2Zmc2V0cy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KCJNTVR5cGUxIGZvbnQgKCIgKyBuYW1lICsgIiksIGZhbGxpbmcgYmFjayB0byBUeXBlMS4iKTsKICAgICAgICBjYXNlICJUeXBlMSI6CiAgICAgICAgY2FzZSAiQ0lERm9udFR5cGUwIjoKICAgICAgICAgIHRoaXMubWltZXR5cGUgPSAiZm9udC9vcGVudHlwZSI7CiAgICAgICAgICBjb25zdCBjZmYgPSBzdWJ0eXBlID09PSAiVHlwZTFDIiB8fCBzdWJ0eXBlID09PSAiQ0lERm9udFR5cGUwQyIgPyBuZXcgX2NmZl9mb250LkNGRkZvbnQoZmlsZSwgcHJvcGVydGllcykgOiBuZXcgX3R5cGUxX2ZvbnQuVHlwZTFGb250KG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgYWRqdXN0V2lkdGhzKHByb3BlcnRpZXMpOwogICAgICAgICAgZGF0YSA9IHRoaXMuY29udmVydChuYW1lLCBjZmYsIHByb3BlcnRpZXMpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT3BlblR5cGUiOgogICAgICAgIGNhc2UgIlRydWVUeXBlIjoKICAgICAgICBjYXNlICJDSURGb250VHlwZTIiOgogICAgICAgICAgdGhpcy5taW1ldHlwZSA9ICJmb250L29wZW50eXBlIjsKICAgICAgICAgIGRhdGEgPSB0aGlzLmNoZWNrQW5kUmVwYWlyKG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgaWYgKHRoaXMuaXNPcGVuVHlwZSkgewogICAgICAgICAgICBhZGp1c3RXaWR0aHMocHJvcGVydGllcyk7CiAgICAgICAgICAgIHR5cGUgPSAiT3BlblR5cGUiOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgRm9udCAke3R5cGV9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgICAgfQogICAgfSBjYXRjaCAoZS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ICJoZWFkIiwgImhoZWEiLCAiaG10eCIsICJtYXhwIiwgIm5hbWUiLCAicG9zdCIsICJsb2NhIiwgImdseWYiLCAiZnBnbSIsICJwcmVwIiwgImN2dCAiLCAiQ0ZGICJdOwogICAgZnVuY3Rpb24gcmVhZFRhYmxlcyhmaWxlLCBudW1UYWJsZXMpIHsKICAgICAgY29uc3QgdGFibGVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgdGFibGVzWyJPUy8yIl0gPSBudWxsOwogICAgICB0YWJsZXMuY21hcCA9IG51bGw7CiAgICAgIHRhYmxlcy5oZWFkID0gbnVsbDsKICAgICAgdGFibGVzLmhoZWEgPSBudWxsOwogICAgICB0YWJsZXMuaG10eCA9IG51bGw7CiAgICAgIHRhYmxlcy5tYXhwID0gbnVsbDsKICAgICAgdGFibGVzLm5hbWUgPSBudWxsOwogICAgICB0YWJsZXMucG9zdCA9IG51bGw7CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtVGFibGVzOyBpKyspIHsKICAgICAgICBjb25zdCB0YWJsZSA9IHJlYWRUYWJsZUVudHJ5KGZpbGUpOwogICAgICAgIGlmICghVkFMSURfVEFCTEVTLmluY2x1ZGVzKHRhYmxlLnRhZykpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGFibGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdGFibGVzW3RhYmxlLnRhZ10gPSB0YWJsZTsKICAgICAgfQogICAgICByZXR1cm4gdGFibGVzOwogICAgfQogICAgZnVuY3Rpb24gcmVhZFRhYmxlRW50cnkoZmlsZSkgewogICAgICBjb25zdCB0YWcgPSBmaWxlLmdldFN0cmluZyg0KTsKICAgICAgY29uc3QgY2hlY2tzdW0gPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4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VzdCBiZSBhIFRydWVUeXBlIENvbGxlY3Rpb24gZm9udC4iKTsKICAgICAgY29uc3QgbWFqb3JWZXJzaW9uID0gdHRjLmdldFVpbnQxNigpOwogICAgICBjb25zdCBtaW5vclZlcnNpb24gPSB0dGMuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IG51bUZvbnRzID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldFRhYmxlID0gW107CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtRm9udHM7IGkrKykgewogICAgICAgIG9mZnNldFRhYmxlLnB1c2godHRjLmdldEludDMyKCkgPj4+IDApOwogICAgICB9CiAgICAgIGNvbnN0IGhlYWRlciA9IHsKICAgICAgICB0dGNUYWcsCiAgICAgICAgbWFqb3JWZXJzaW9uLAogICAgICAgIG1pbm9yVmVyc2lvbiwKICAgICAgICBudW1Gb250cywKICAgICAgICBvZmZzZXRUYWJsZQogICAgICB9OwogICAgICBzd2l0Y2ggKG1ham9yVmVyc2lvbikgewogICAgICAgIGNhc2UgMToKICAgICAgICAgIHJldHVybiBoZWFkZXI7CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaGVhZGVyLmRzaWdUYWcgPSB0dGMuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGhlYWRlci5kc2lnTGVuZ3RoID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgICBoZWFkZXIuZHNpZ09mZnNldCA9IHR0Yy5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgcmV0dXJuIGhlYWRlcjsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEludmFsaWQgVHJ1ZVR5cGUgQ29sbGVjdGlvbiBtYWpvclZlcnNpb246ICR7bWFqb3JWZXJzaW9ufS5gKTsKICAgIH0KICAgIGZ1bmN0aW9uIHJlYWRUcnVlVHlwZUNvbGxlY3Rpb25EYXRhKHR0YywgZm9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ICAgICAgICAgICBpZiAoIW5hbWVFbnRyeSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IGZvbnROYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGhlYWRlcjogcG90ZW50aWFsSGVhZGVyLAogICAgICAgICAgICAgICAgdGFibGVzOiBwb3RlbnRpYWxUYWJsZXMKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb250TmFtZVBhcnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IgKGNvbnN0IHBhcnQgb2YgZm9udE5hbWVQYXJ0cykgewogICAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IHBhcnQpIHsKICAgICAgICAgICAgICAgIGZhbGxiYWNrRGF0YSA9IHsKICAgICAgICAgICAgICAgICAgbmFtZTogcGFydCwKICAgICAgICAgICAgICAgICAgaGVhZGVyOiBwb3RlbnRpYWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgIHRhYmxlczogcG90ZW50aWFsVGFibGVzCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZmFsbGJhY2tEYXRhKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUcnVlVHlwZSBDb2xsZWN0aW9uIGRvZXMgbm90IGNvbnRhaW4gIiR7Zm9udE5hbWV9IiBmb250LCBgICsgYGZhbGxpbmcgYmFjayB0byAiJHtmYWxsYmFja0RhdGEubmFtZX0iIGZvbnQgaW5zdGVhZC5gKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgaGVhZGVyOiBmYWxsYmFja0RhdGEuaGVhZGVyLAogICAgICAgICAgdGFibGVzOiBmYWxsYmFja0RhdGEudGFibGVzCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFRydWVUeXBlIENvbGxlY3Rpb24gZG9lcyBub3QgY29udGFpbiAiJHtmb250TmFtZX0iIGZvbnQuYCk7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkQ21hcFRhYmxlKGNtYXAsIGZpbGUsIGlzU3ltYm9saWNGb250LCBoYXNFbmNvZGluZykgewogICAgICBpZiAoIWNtYXApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vIGNtYXAgdGFibGUgYXZhaWxhYmxlLiIpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBwbGF0Zm9ybUlkOiAtMSwKICAgICAgICAgIGVuY29kaW5nSWQ6IC0xLAogICAgICAgICAgbWFwcGluZ3M6IFtdLAogICAgICAgICAgaGFzU2hvcnRDbWFwOiBmYWxzZQogICAgICAgIH07CiAgICAgIH0KICAgICAgbGV0IHNlZ21lbnQ7CiAgICAgIGxldCBzdGFydCA9IChmaWxlLnN0YXJ0IHx8IDApICsgY21hcC5vZmZzZXQ7CiAgICAgIGZpbGUucG9zID0gc3RhcnQ7CiAgICAgIGZpbGUuc2tpcCgyKTsKICAgICAgY29uc3QgbnVtVGFibGVzID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgbGV0IHBvdGVudGlhbFRhYmxlOwogICAgICBsZXQgY2FuQnJlYWsgPSBmYWxzZTsKICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBudW1UYWJsZXM7IGkrKykgewogICAgICAgIGNvbnN0IHBsYXRmb3JtSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVuY29kaW5nSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICBsZXQgdXNlVGFibGUgPSBmYWxzZTsKICAgICAgICBpZiA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AgICAgaWYgKG5leHRQbGF0Zm9ybUlkIDwgcGxhdGZvcm1JZCkgewogICAgICAgICAgICAgIGNvcnJlY3RseVNvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29ycmVjdGx5U29ydGVkKSB7CiAgICAgICAgICAgIGNhbkJyZWFrID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVzZVRhYmxlKSB7CiAgICAgICAgICBwb3RlbnRpYWxUYWJsZSA9IHsKICAgICAgICAgICAgcGxhdGZvcm1JZCwKICAgICAgICAgICAgZW5jb2RpbmdJZCwKICAgICAgICAgICAgb2Zmc2V0CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBpZiAoY2FuQnJlYWspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocG90ZW50aWFsVGFibGUpIHsKICAgICAgICBmaWxlLnBvcyA9IHN0YXJ0ICsgcG90ZW50aWFsVGFibGUub2Zmc2V0OwogICAgICB9CiAgICAgIGlmICghcG90ZW50aWFsVGFibGUgfHwgZmlsZS5wZWVrQnl0ZSgpID09PSAtMSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiQ291bGQgbm90IGZpbmQgYSBwcmVmZXJyZWQgY21hcCB0YWJsZS4iKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGxldCBoYXNTaG9ydENtYXAgPSBmYWxzZTsKICAgICAgY29uc3QgbWFwcGluZ3MgPSBbXTsKICAgICAgbGV0IGosIGdseXBoSWQ7CiAgICAgIGlmIChmb3JtYXQgPT09IDApIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAyNTY7IGorKykgewogICAgICAgICAgY29uc3QgaW5kZXggPSBmaWxlLmdldEJ5dGUoKTsKICAgICAgICAgIGlmICghaW5kZXgpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgIGdseXBoSWQ6IGluZGV4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzU2hvcnRDbWFwID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmIChmb3JtYXQgPT09IDIpIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGNvbnN0IHN1YkhlYWRlcktleXMgPSBbXTsKICAgICAgICBsZXQgbWF4U3ViSGVhZGVyS2V5ID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzdWJIZWFkZXJLZXkgPSBmaWxlLmdldFVpbnQxNigpID4+IDM7CiAgICAgICAgICBzdWJIZWFkZXJLZXlzLnB1c2goc3ViSGVhZGVyS2V5KTsKICAgICAgICAgIG1heFN1YkhlYWRlcktleSA9IE1hdGgubWF4KHN1YkhlYWRlcktleSwgbWF4U3ViSGVhZGVyS2V5KTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc3ViSGVhZGVycyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFN1YkhlYWRlcktleTsgaSsrKSB7CiAgICAgICAgICBzdWJIZWFkZXJzLnB1c2goewogICAgICAgICAgICBmaXJzdENvZGU6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGVudHJ5Q291bnQ6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGlkRGVsdGE6IHNpZ25lZEludDE2KGZpbGUuZ2V0Qnl0ZSgpLCBmaWxlLmdldEJ5dGUoKSksCiAgICAgICAgICAgIGlkUmFuZ2VQb3M6IGZpbGUucG9zICsgZmlsZS5nZXRVaW50MTYoKQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgIGlmIChzdWJIZWFkZXJLZXlzW2ldID09PSAwKSB7CiAgICAgICAgICAgIGZpbGUucG9zID0gc3ViSGVhZGVyc1swXS5pZFJhbmdlUG9zICsgMiAqIGk7CiAgICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBjaGFyQ29kZTogaSwKICAgICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgcyA9IHN1YkhlYWRlcnNbc3ViSGVhZGVyS2V5c1tpXV07CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBzLmVudHJ5Q291bnQ7IGorKykgewogICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0gKGkgPDwgOCkgKyBqICsgcy5maXJzdENvZGU7CiAgICAgICAgICAgICAgZmlsZS5wb3MgPSBzLmlkUmFuZ2VQb3MgKyAyICogajsKICAgICAgICAgICAgICBnbHlwaElkID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgICAgICBpZiAoZ2x5cGhJZCAhPT0gMCkgewogICAgICAgICAgICAgICAgZ2x5cGhJZCA9IChnbHlwaElkICsgcy5pZERlbHRhKSAlIDY1NTM2OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gNCkgewogICAgICAgIGZpbGUuc2tpcCgyICsgMik7CiAgICAgICAgY29uc3Qgc2VnQ291bnQgPSBmaWxlLmdldFVpbnQxNigpID4+IDE7CiAgICAgICAgZmlsZS5za2lwKDYpOwogICAgICAgIGNvbnN0IHNlZ21lbnRzID0gW107CiAgICAgICAgbGV0IHNlZ0luZGV4OwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50cy5wdXNoKHsKICAgICAgICAgICAgZW5kOiBmaWxlLmdldFVpbnQxNigpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgZmlsZS5za2lwKDIpOwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50c1tzZWdJbmRleF0uc3RhcnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIH0KICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudHNbc2VnSW5kZXhdLmRlbHRhID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICB9CiAgICAgICAgbGV0IG9mZnNldHNDb3VudCA9IDAsCiAgICAgICAgICBvZmZzZXRJbmRleDsKICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudCA9IHNlZ21lbnRzW3NlZ0luZGV4XTsKICAgICAgICAgIGNvbnN0IHJhbmdlT2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmICghcmFuZ2VPZmZzZXQpIHsKICAgICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IC0xOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldEluZGV4ID0gKHJhbmdlT2Zmc2V0ID4+IDEpIC0gKHNlZ0NvdW50IC0gc2VnSW5kZXgpOwogICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IG9mZnNldEluZGV4OwogICAgICAgICAgb2Zmc2V0c0NvdW50ID0gTWF0aC5tYXgob2Zmc2V0c0NvdW50LCBvZmZzZXRJbmRleCArIHNlZ21lbnQuZW5kIC0gc2VnbWVudC5zdGFydCArIDEpOwogICAgICAgIH0KICAgICAgICBjb25zdCBvZmZzZXRzID0gW107CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG9mZnNldHNDb3VudDsgaisrKSB7CiAgICAgICAgICBvZmZzZXRzLnB1c2goZmlsZS5nZXRVaW50MTYoKSk7CiAgICAgICAgfQogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50ID0gc2VnbWVudHNbc2VnSW5kZXhdOwogICAgICAgICAgc3RhcnQgPSBzZWdtZW50LnN0YXJ0OwogICAgICAgICAgY29uc3QgZW5kID0gc2VnbWVudC5lbmQ7CiAgICAgICAgICBjb25zdCBkZWx0YSA9IHNlZ21lbnQuZGVsdGE7CiAgICAgICAgICBvZmZzZXRJbmRleCA9IHNlZ21lbnQub2Zmc2V0SW5kZXg7CiAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBlbmQ7IGorKykgewogICAgICAgICAgICBpZiAoaiA9PT0gMHhmZmZmKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhJZCA9IG9mZnNldEluZGV4IDwgMCA/IGogOiBvZmZzZXRzW29mZnNldEluZGV4ICsgaiAtIHN0YXJ0XTsKICAgICAgICAgICAgZ2x5cGhJZCA9IGdseXBoSWQgKyBkZWx0YSAmIDB4ZmZmZjsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSA2KSB7CiAgICAgICAgZmlsZS5za2lwKDIgKyAyKTsKICAgICAgICBjb25zdCBmaXJzdENvZGUgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVudHJ5Q291bnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCBlbnRyeUNvdW50OyBqKyspIHsKICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgY29uc3QgY2hhckNvZGUgPSBmaXJzdENvZGUgKyBqOwogICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgICAgIGZpbGUuc2tpcCgyICsgNCArIDQpOwogICAgICAgIGNvbnN0IG5Hcm91cHMgPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG5Hcm91cHM7IGorKykgewogICAgICAgICAgY29uc3Qgc3RhcnRDaGFyQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGNvbnN0IGVuZENoYXJDb2RlID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgbGV0IGdseXBoQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGZvciAobGV0IGNoYXJDb2RlID0gc3RhcnRDaGFyQ29kZTsgY2hhckNvZGUgPD0gZW5kQ2hhckNvZGU7IGNoYXJDb2RlKyspIHsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGUsCiAgICAgICAgICAgICAgZ2x5cGhJZDogZ2x5cGhDb2RlKysKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiY21hcCB0YWJsZSBoYXMgdW5zdXBwb3J0ZWQgZm9ybWF0OiAiICsgZm9ybWF0KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIG1hcHBpbmdzLnNvcnQoZnVuY3Rpb24gKGEsIGIpIHsKICAgICAgICByZXR1cm4gYS5jaGFyQ29kZSAtIGIuY2hhckNvZGU7CiAgICAgIH0pOwogICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG1hcHBpbmdzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgaWYgKG1hcHBpbmdzW2kgLSAxXS5jaGFyQ29kZSA9PT0gbWFwcGluZ3NbaV0uY2hhckNvZGUpIHsKICAgICAgICAgIG1hcHBpbmdzLnNwbGljZShpLCAxKTsKICAgICAgICAgIGktLTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICBwbGF0Zm9ybUlkOiBwb3RlbnRpYWxUYWJsZS5wbGF0Zm9ybUlkLAogICAgICAgIGVuY29kaW5nSWQ6IHBvdGVudGlhbFRhYmxlLmVuY29kaW5nSWQsCiAgICAgICAgbWFwcGluZ3MsCiAgICAgICAgaGFzU2hvcnRDbWFwCiAgICAgIH07CiAgICB9CiAgICBmdW5jdGlvbiBzYW5pdGl6ZU1ldHJpY3MoZmlsZSwgaGVhZGVyLCBtZXRyaWNzLCBoZWFkVGFibGUsIG51bUdseXBocywgZHVwRmlyc3RFbnRyeSkgewogICAgICBpZiAoIWhlYWRlcikgewogICAgICAgIGlmIChtZXRyaWNzKSB7CiAgICAgICAgICBtZXRyaWNzLmRhdGEgPSBudWxsOwogICAgICAgIH0KICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgZmlsZS5wb3MgPSAoZmlsZS5zdGFydCB8fCAwKSArIGhlYWRlci5vZmZzZXQ7CiAgICAgIGZpbGUucG9zICs9IDQ7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGNvbnN0IGNhcmV0T2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgZmlsZS5wb3MgKz0gODsKICAgICAgZmlsZS5wb3MgKz0gMjsKICAgICAgbGV0IG51bU9mTWV0cmljcyA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGlmIChjYXJldE9mZnNldCAhPT0gMCkgewogICAgICAgIGNvbnN0IG1hY1N0eWxlID0gaW50MTYoaGVhZFRhYmxlLmRhdGFbNDRdLCBoZWFkVGFibGUuZGF0YVs0NV0pOwogICAgICAgIGlmICghKG1hY1N0eWxlICYgMikpIHsKICAgICAgICAgIGhlYWRlci5kYXRhWzIyXSA9IDA7CiAgICAgICAgICBoZWFkZXIuZGF0YVsyM10gPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAobnVtT2ZNZXRyaWNzID4gbnVtR2x5cGhzKSB7CiAgICAgICAgKDAsIF91dGlsLmluZm8pKGBUaGUgbnVtT2ZNZXRyaWNzICgke251bU9mTWV0cmljc30pIHNob3VsZCBub3QgYmUgYCArIGBncmVhdGVyIHRoYW4gdGhlIG51bUdseXBocyAoJHtudW1HbHlwaHN9KS5gKTsKICAgICAgICBudW1PZk1ldHJpY3MgPSBudW1HbHlwaHM7CiAgICAgICAgaGVhZGVyLmRhdGFbMzRdID0gKG51bU9mTWV0cmljcyAmIDB4ZmYwMCkgPj4gODsKICAgICAgICBoZWFkZXIuZGF0YVszNV0gPSBudW1PZk1ldHJpY3MgJiAweDAwZmY7CiAgICAgIH0KICAgICAgY29uc3QgbnVtT2ZTaWRlYmVhcmluZ3MgPSBudW1HbHlwaHMgLSBudW1PZk1ldHJpY3M7CiAgICAgIGNvbnN0IG51bU1pc3NpbmcgPSBudW1PZlNpZGViZWFyaW5ncyAtIChtZXRyaWNzLmxlbmd0aCAtIG51bU9mTWV0cmljcyAqIDQgPj4gMSk7CiAgICAgIGlmIChudW1NaXNzaW5nID4gMCkgewogICAgICAgIGNvbnN0IGVudHJpZXMgPSBuZXcgVWludDhBcnJheShtZXRyaWNzLmxlbmd0aCArIG51bU1pc3NpbmcgKiAyKTsKICAgICAgICBlbnRyaWVzLnNldChtZXRyaWNzLmRhdGEpOwogICAgICAgIGlmIChkdXBGaXJzdEVudHJ5KSB7CiAgICAgICAgICBlbnRyaWVzW21ldHJpY3MubGVuZ3RoXSA9IG1ldHJpY3MuZGF0YVsyXTsKICAgICAgICAgIGVudHJpZXNbbWV0cmljcy5sZW5ndGggKyAxXSA9IG1ldHJpY3MuZGF0YVszXTsKICAgICAgICB9CiAgICAgICAgbWV0cmljcy5kYXRhID0gZW50cmllczsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVHbHlwaChzb3VyY2UsIHNvdXJjZVN0YXJ0LCBzb3VyY2VFbmQsIGRlc3QsIGRlc3RTdGFydCwgaGludHNWYWxpZCkgewogICAgICBjb25zdCBnbHlwaFByb2ZpbGUgPSB7CiAgICAgICAgbGVuZ3RoOiAwLAogICAgICAgIHNpemVPZkluc3RydWN0aW9uczogMAogICAgICB9OwogICAgICBpZiAoc291cmNlRW5kIC0gc291cmNlU3RhcnQgPD0gMTIpIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGNvbnN0IGdseWYgPSBzb3VyY2Uuc3ViYXJyYXkoc291cmNlU3RhcnQsIHNvdXJjZUVuZCk7CiAgICAgIGxldCBjb250b3Vyc0NvdW50ID0gc2lnbmVkSW50MTYoZ2x5ZlswXSwgZ2x5ZlsxXSk7CiAgICAgIGlmIChjb250b3Vyc0NvdW50IDwgMCkgewogICAgICAgIGNvbnRvdXJzQ291bnQgPSAtMTsKICAgICAgICB3cml0ZVNpZ25lZEludDE2KGdseWYsIDAsIGNvbnRvdXJzQ291bnQpOwogICAgICAgIGRlc3Quc2V0KGdseWYsIGRlc3RTdGFydCk7CiAgICAgICAgZ2x5cGhQcm9maWxlLmxlbmd0aCA9IGdseWYubGVuZ3RoOwogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgbGV0IGksCiAgICAgICAgaiA9IDEwLAogICAgICAgIGZsYWdzQ291bnQgPSAwOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29udG91cnNDb3VudDsgaSsrKSB7CiAgICAgICAgY29uc3QgZW5kUG9pbnQgPSBnbHlmW2pdIDw8IDggfCBnbHlmW2ogKyAxXTsKICAgICAgICBmbGFnc0NvdW50ID0gZW5kUG9pbnQgKyAxOwogICAgICAgIGogKz0gMjsKICAgICAgfQogICAgICBjb25zdCBpbnN0cnVjdGlvbnNTdGFydCA9IGo7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0xlbmd0aCA9IGdseWZbal0gPDwgOCB8IGdseWZbaiArIDFdOwogICAgICBnbHlwaFByb2ZpbGUuc2l6ZU9mSW5zdHJ1Y3Rpb25zID0gaW5zdHJ1Y3Rpb25zTGVuZ3RoOwogICAgICBqICs9IDIgKyBpbnN0cnVjdGlvbnNMZW5ndGg7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0VuZCA9IGo7CiAgICAgIGxldCBjb29yZGluYXRlc0xlbmd0aCA9IDA7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBmbGFnc0NvdW50OyBpKyspIHsKICAgICAgICBjb25zdCBmbGFnID0gZ2x5ZltqKytdOwogICAgICAgIGlmIChmbGFnICYgMHhjMCkgewogICAgICAgICAgZ2x5ZltqIC0gMV0gPSBmbGFnICYgMHgzZjsKICAgICAgICB9CiAgICAgICAgbGV0IHhMZW5ndGggPSAyOwogICAgICAgIGlmIChmbGFnICYgMikgewogICAgICAgICAgeExlbmd0aCA9IDE7CiAgICAgICAgfSBlbHNlIGlmIChmbGFnICYgMTYpIHsKICAgICAgICAgIHhMZW5ndGggPSAwOwogICAgICAgIH0KICAgICAgICBsZXQgeUxlbmd0aCA9IDI7CiAgICAgICAgaWYgKGZsYWcgJiA0KSB7CiAgICAgICAgICB5TGVuZ3RoID0gMTsKICAgICAgICB9IGVsc2UgaWYgKGZsYWcgJiAzMikgewogICAgICAgICAgeUxlbmd0aCA9IDA7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHh5TGVuZ3RoID0geExlbmd0aCArIHlMZW5ndGg7CiAgICAgICAgY29vcmRpbmF0ZXNMZW5ndGggKz0geHlMZW5ndGg7CiAgICAgICAgaWYgKGZsYWcgJiA4KSB7CiAgICAgICAgICBjb25zdCByZXBlYXQgPSBnbHlmW2orK107CiAgICAgICAgICBpICs9IHJlcGVhdDsKICAgICAgICAgIGNvb3JkaW5hdGVzTGVuZ3RoICs9IHJlcGVhdCAqIHh5TGVuZ3RoOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29vcmRpbmF0ZXNMZW5ndGggPT09IDApIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGxldCBnb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vbGRHbHlmRGF0YUxlbmd0aCA9IG9sZEdseWZEYXRhLmxlbmd0aDsKICAgICAgY29uc3QgbmV3R2x5ZkRhdGEgPSBuZXcgVWludDhBcnJheShvbGRHbHlmRGF0YUxlbmd0aCk7CiAgICAgIGxldCBpLCBqOwogICAgICBjb25zdCBsb2NhRW50cmllcyA9IFtdOwogICAgICBmb3IgKGkgPSAwLCBqID0gMDsgaSA8IG51bUdseXBocyArIDE7IGkrKywgaiArPSBpdGVtU2l6ZSkgewogICAgICAgIGxldCBvZmZzZXQgPSBpdGVtRGVjb2RlKGxvY2FEYXRhLCBqKTsKICAgICAgICBpZiAob2Zmc2V0ID4gb2xkR2x5ZkRhdGFMZW5ndGgpIHsKICAgICAgICAgIG9mZnNldCA9IG9sZEdseWZEYXRhTGVuZ3RoOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllcy5wdXNoKHsKICAgICAgICAgIGluZGV4OiBpLAogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0OiAwCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgbG9jYUVudHJpZXMuc29ydCgoYSwgYikgPT4gewogICAgICAgIHJldHVybiBhLm9mZnNldCAtIGIub2Zmc2V0OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgbG9jYUVudHJpZXNbaV0uZW5kT2Zmc2V0ID0gbG9jYUVudHJpZXNbaSArIDFdLm9mZnNldDsKICAgICAgfQogICAgICBsb2NhRW50cmllcy5zb3J0KChhLCBiKSA9PiB7CiAgICAgICAgcmV0dXJuIGEuaW5kZXggLSBiLmluZGV4OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0CiAgICAgICAgfSA9IGxvY2FFbnRyaWVzW2ldOwogICAgICAgIGl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zdCBudW1HbHlwaHMgPSBmb250LmdldFVpbnQxNigpOwogICAgICAgICAgaWYgKG51bUdseXBocyAhPT0gbWF4cE51bUdseXBocykgewogICAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGdseXBoTmFtZUluZGV4ZXMgPSBbXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1HbHlwaHM7ICsraSkgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgICAgICAgIGlmIChpbmRleCA+PSAzMjc2OCkgewogICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhOYW1lSW5kZXhlcy5wdXNoKGluZGV4KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjdXN0b21OYW1lcyA9IFtdLAogICAgICAgICAgICBzdHJCdWYgPSBbXTsKICAgICAgICAgIHdoaWxlIChmb250LnBvcyA8IGVuZCkgewogICAgICAgICAgICBjb25zdCBzdHJpbmdMZW5ndGggPSBmb250LmdldEJ5dGUoKTsKICAgICAgICAgICAgc3RyQnVmLmxlbmd0aCA9IHN0cmluZ0xlbmd0aDsKICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHN0cmluZ0xlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgc3RyQnVmW2ldID0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldEJ5dGUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VzdG9tTmFtZXMucHVzaChzdHJCdWYuam9pbigiIikpOwogICAgICAgICAgfQogICAgICAgICAgZ2x5cGhOYW1lcyA9IFtdOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgKytpKSB7CiAgICAgICAgICAgIGNvbnN0IGogPSBnbHlwaE5hbWVJbmRleGVzW2ldOwogICAgICAgICAgICBpZiAoaiA8IDI1OCkgewogICAgICAgICAgICAgIGdseXBoTmFtZXMucHVzaChfZm9udHNfdXRpbHMuTWFjU3RhbmRhcmRHbHlwaE9yZGVyaW5nW2pdKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBnbHlwaE5hbWVzLnB1c2goY3VzdG9tTmFtZXNbaiAtIDI1OF0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDAwMDMwMDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5rbm93bi91bnN1cHBvcnRlZCBwb3N0IHRhYmxlIHZlcnNpb24gIiArIHZlcnNpb24pOwogICAgICAgICAgdmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGlmIChwcm9wZXJ0aWVzT2JqLmRlZmF1bHRFbmNvZGluZykgewogICAgICAgICAgICBnbHlwaE5hbWVzID0gcHJvcGVydGllc09iai5kZWZhdWx0RW5jb2Rpbmc7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwcm9wZXJ0aWVzT2JqLmdseXBoTmFtZXMgPSBnbHlwaE5hbWVzOwogICAgICByZXR1cm4gdmFsaWQ7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkTmFtZVRhYmxlKG5hbWVUYWJsZSkgewogICAgICBjb25zdCBzdGFydCA9IChmb250LnN0YXJ0IHx8IDApICsgbmFtZVRhYmxlLm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbmFtZXMgPSBbW10sIFtdXSwKICAgICAgICByZWNvcmRzID0gW107CiAgICAgIGNvbnN0IGxlbmd0aCA9IG5hbWVUYWJsZS5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IEZPUk1BVF8wX0hFQURFUl9MRU5HVEggPSA2OwogICAgICBpZiAoZm9ybWF0ICE9PSAwIHx8IGxlbmd0aCA8IEZPUk1BVF8wX0hFQURFUl9MRU5HVEgpIHsKICAgICAgICByZXR1cm4gW25hbWVzLCByZWNvcmRzXTsKICAgICAgfQogICAgICBjb25zdCBudW1SZWNvcmRzID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3Qgc3RyaW5nc1N0YXJ0ID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3QgTkFNRV9SRUNPUkRfTEVOR1RIID0gMTI7CiAgICAgIGxldCBpLCBpaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bVJlY29yZHMgJiYgZm9udC5wb3MgKyBOQU1FX1JFQ09SRF9MRU5HVEggPD0gZW5kOyBpKyspIHsKICAgICAgICBjb25zdCByID0gewogICAgICAgICAgcGxhdGZvcm06IGZvbnQuZ2V0VWludDE2KCksCiAgICAgICAgICBlbmNvZGluZzogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxhbmd1YWdlOiBmb250LmdldFVpbnQxNigpLAogICAgICAgICAgbmFtZTogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxlbmd0aDogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIG9mZnNldDogZm9udC5nZXRVaW50MTYoKQogICAgICAgIH07CiAgICAgICAgaWYgKGlzTWFjTmFtZVJlY29yZChyKSB8fCBpc1dpbk5hbWVSZWNvcmQocikpIHsKICAgICAgICAgIHJlY29yZHMucHVzaChyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChpID0gMCwgaWkgPSByZWNvcmRzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCByZWNvcmQgPSByZWNvcmRzW2ldOwogICAgICAgIGlmIChyZWNvcmQubGVuZ3RoIDw9IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBwb3MgPSBzdGFydCArIHN0cmluZ3NTdGFydCArIHJlY29yZC5vZmZzZXQ7CiAgICAgICAgaWYgKHBvcyArIHJlY29yZC5sZW5ndGggPiBlbmQpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBmb250LnBvcyA9IHBvczsKICAgICAgICBjb25zdCBuYW1lSW5kZXggPSByZWNvcmQubmFtZTsKICAgICAgICBpZiAocmVjb3JkLmVuY29kaW5nKSB7CiAgICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgICBmb3IgKGxldCBqID0gMCwgamogPSByZWNvcmQubGVuZ3RoOyBqIDwgamo7IGogKz0gMikgewogICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldFVpbnQxNigpKTsKICAgICAgICAgIH0KICAgICAgICAgIG5hbWVzWzFdW25hbWVJbmRleF0gPSBzdHI7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIG5hbWVzWzBdW25hbWVJbmRleF0gPSBmb250LmdldFN0cmluZyhyZWNvcmQubGVuZ3RoKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIFtuYW1lcywgcmVjb3Jkc107CiAgICB9CiAgICBjb25zdCBUVE9wc1N0YWNrRGVsdGFzID0gWzAsIDAsIDAsIDAsIDAsIDAsIDAsIDAsIC0yLCAtMiwgLTIsIC0yLCAwLCAwLCAtMiwgLTUsIC0xLCAtMSwgLTEsIC0xLCAtMSwgLTEsIC0xLCAtMSwgMCwgMCwgLTEsIDAsIC0xLCAtMSwgLTEsIC0xLCAxLCAtMSwgLTk5OSwgMCwgMSwgMCwgLTEsIC0yLCAwLCAtMSwgLTIsIC0xLCAtMSwgMCwgLTEsIC0xLCAwLCAwLCAtOTk5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md0aDsgaSA8IGlpOykgewogICAgICAgIGNvbnN0IG9wID0gZGF0YVtpKytdOwogICAgICAgIGlmIChvcCA9PT0gMHg0MCkgewogICAgICAgICAgbiA9IGRhdGFbaSsrXTsKICAgICAgICAgIGlmIChpbkZERUYgfHwgaW5FTFNFKSB7CiAgICAgICAgICAgIGkgKz0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBzdGFjay5wdXNoKGRhdGFbaSsrXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDQxKSB7CiAgICAgICAgICBuID0gZGF0YVtpKytdOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjApIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjAgKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IG47IGorKykgewogICAgICAgICAgICAgIHN0YWNrLnB1c2goZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjgpIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjggKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmIgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKCFpbkZERUYgJiYgIWluRUxTRSkgewogICAgICAgICAgICBmdW5jSWQgPSBzdGFjay5hdCgtMSk7CiAgICAgICAgICAgIGlmIChpc05hTihmdW5jSWQpKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUVDogQ0FMTCBlbXB0eSBzdGFjayAob3IgaW52YWxpZCBlbnRyeSkuIik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1VzZWRbZnVuY0lkXSA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGZ1bmNJZCBpbiB0dENvbnRleHQuZnVuY3Rpb25zU3RhY2tEZWx0YXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG5ld1N0YWNrTGVuZ3RoID0gc3RhY2subGVuZ3RoICsgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF07CiAgICAgICAgICAgICAgICBpZiAobmV3U3RhY2tMZW5ndGggPCAwKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IENBTEwgaW52YWxpZCBmdW5jdGlvbnMgc3RhY2sgZGVsdGEuIik7CiAgICAgICAgICAgICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YWNrLmxlbmd0aCA9IG5ld1N0YWNrTGVuZ3RoOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoZnVuY0lkIGluIHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkICYmICFmdW5jdGlvbnNDYWxsZWQuaW5jbHVkZXMoZnVuY0lkKSkgewogICAgICAgICAgICAgICAgY2FsbHN0YWNrLnB1c2goewogICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICBpLAogICAgICAgICAgICAgICAgICBzdGFja1RvcDogc3RhY2subGVuZ3RoIC0gMQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbnNDYWxsZWQucHVzaChmdW5jSWQpOwogICAgICAgICAgICAgICAgcGMgPSB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdOwogICAgICAgICAgICAgICAgaWYgKCFwYykgewogICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBDQUxMIG5vbi1leGlzdGVudCBmdW5jdGlvbiIpOwogICAgICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBkYXRhID0gcGMuZGF0YTsKICAgICAgICAgICAgICAgIGkgPSBwYy5pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmMgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogbmVzdGVkIEZERUZzIG5vdCBhbGxvd2VkIik7CiAgICAgICAgICAgIHRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucyA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpbkZERUYgPSB0cnVlOwogICAgICAgICAgbGFzdERlZmYgPSBpOwogICAgICAgICAgZnVuY0lkID0gc3RhY2sucG9wKCk7CiAgICAgICAgICB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdID0gewogICAgICAgICAgICBkYXRhLAogICAgICAgICAgICBpCiAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmQpIHsKICAgICAgICAgIGlmIChpbkZERUYpIHsKICAgICAgICAgICAgaW5GREVGID0gZmFsc2U7CiAgICAgICAgICAgIGxhc3RFbmRmID0gaTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBjID0gY2FsbHN0YWNrLnBvcCgpOwogICAgICAgICAgICBpZiAoIXBjKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogRU5ERiBiYWQgc3RhY2siKTsKICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jSWQgPSBmdW5jdGlvbnNDYWxsZWQucG9wKCk7CiAgICAgICAgICAgIGRhdGEgPSBwYy5kYXRhOwogICAgICAgICAgICBpID0gcGMuaTsKICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF0gPSBzdGFjay5sZW5ndGggLSBwYy5zdGFja1RvcDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDg5KSB7CiAgICAgICAgICBpZiAoaW5GREVGIHx8IGluRUxTRSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBuZXN0ZWQgSURFRnMgbm90IGFsbG93ZWQiKTsKICAgICAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGluRkRFRiA9IHRydWU7CiAgICAgICAgICBsYXN0RGVmZiA9IGk7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OCkgewogICAgICAgICAgKytpZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWIpIHsKICAgICAgICAgIGluRUxTRSA9IGlmTGV2ZWw7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OSkgewogICAgICAgICAgaWYgKGluRUxTRSA9PT0gaWZMZXZlbCkgewogICAgICAgICAgICBpbkVMU0UgPSAwOwogICAgICAgICAgfQogICAgICAgICAgLS1pZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWMpIHsKICAgICAgICAgIGlmICghaW5GREVGICYmICFpbkVMU0UpIHsKICAgICAgICAgICAgY29uc3Qgb2Zmc2V0ID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICBpZiAob2Zmc2V0ID4gMCkgewogICAgICAgICAgICAgIGkgKz0gb2Zmc2V0IC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIWluRkRFRiAmJiAhaW5FTFNFKSB7CiAgICAgICAgICBsZXQgc3RhY2tEZWx0YSA9IDA7CiAgICAgICAgICBpZiAob3AgPD0gMHg4ZSkgewogICAgICAgICAgICBzdGFja0RlbHRhID0gVFRPcHNTdGFja0RlbHRhc1tvcF07CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4YzAgJiYgb3AgPD0gMHhkZikgewogICAgICAgICAgICBzdGFja0RlbHRhID0gLTE7CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4ZTApIHsKICAgICAgICAgICAgc3RhY2tEZWx0YSA9IC0yOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wID49IDB4NzEgJiYgb3AgPD0gMHg3NSkgewogICAgICAgICAgICBuID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghaXNOYU4obikpIHsKICAgICAgICAgICAgICBzdGFja0RlbHRhID0gLW4gKiAyOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2tEZWx0YSA8IDAgJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgICAgc3RhY2tEZWx0YSsrOwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN0YWNrRGVsdGEgPiAwKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goTmFOKTsKICAgICAgICAgICAgc3RhY2tEZWx0YS0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBjb25zdCBjb250ZW50ID0gW2RhdGFdOwogICAgICBpZiAoaSA+IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgY29udGVudC5wdXNoKG5ldyBVaW50OEFycmF5KGkgLSBkYXRhLmxlbmd0aCkpOwogICAgICB9CiAgICAgIGlmIChsYXN0RGVmZiA+IGxhc3RFbmRmKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogY29tcGxlbWVudGluZyBhIG1pc3NpbmcgZnVuY3Rpb24gdGFpbCIpOwogICAgICAgIGNvbnRlbnQucHVzaChuZXcgVWludDhBcnJheShbMHgyMiwgMHgyZF0pKTsKICAgICAgfQogICAgICBmb2xkVFRUYWJsZSh0YWJsZSwgY29udGVudCk7CiAgICB9CiAgICBmdW5jdGlvbiBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpIHsKICAgICAgaWYgKHR0Q29udGV4dC50b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkLmxlbmd0aCA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IG1vcmUgZnVuY3Rpb25zIGRlZmluZWQgdGhhbiBleHBlY3RlZCIpOwogICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICBpZiAoaiA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogaW52YWxpZCBmdW5jdGlvbiBpZDogIiArIGopOwogICAgICAgICAgdHRDb250ZXh0LmhpbnRzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkW2pdICYmICF0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtqXSkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogdW5kZWZpbmVkIGZ1bmN0aW9uOiAiICsgaik7CiAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gZm9sZFRUVGFibGUodGFibGUsIGNvbnRlbnQpIHsKICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMSkgewogICAgICAgIGxldCBuZXdMZW5ndGggPSAwOwogICAgICAgIGxldCBqLCBqajsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgbmV3TGVuZ3RoICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBuZXdMZW5ndGggPSBuZXdMZW5ndGggKyAzICYgfjM7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobmV3TGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgcmVzdWx0LnNldChjb250ZW50W2pdLCBwb3MpOwogICAgICAgICAgcG9zICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0YWJsZS5kYXRhID0gcmVzdWx0OwogICAgICAgIHRhYmxlLmxlbmd0aCA9IG5ld0xlbmd0aDsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVUVFByb2dyYW1zKGZwZ20sIHByZXAsIGN2dCwgbWF4RnVuY3Rpb25EZWZzKSB7CiAgICAgIGNvbnN0IHR0Q29udGV4dCA9IHsKICAgICAgICBmdW5jdGlvbnNEZWZpbmVkOiBbXSwKICAgICAgICBmdW5jdGlvbnNVc2VkOiBbXSwKICAgICAgICBmdW5jdGlvbnNTdGFja0RlbHRhczogW10sCiAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOiBmYWxzZSwKICAgICAgICBoaW50c1ZhbGlkOiB0cnVlCiAgICAgIH07CiAgICAgIGlmIChmcGdtKSB7CiAgICAgICAgc2FuaXRpemVUVFByb2dyYW0oZnBnbSwgdHRDb250ZXh0KTsKICAgICAgfQogICAgICBpZiAocHJlcCkgewogICAgICAgIHNhbml0aXplVFRQcm9ncmFtKHByZXAsIHR0Q29udGV4dCk7CiAgICAgIH0KICAgICAgaWYgKGZwZ20pIHsKICAgICAgICBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpOwogICAgICB9CiAgICAgIGlm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ghdGFibGVzLm1heHApIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdSZXF1aXJlZCAibWF4cCIgdGFibGUgaXMgbm90IGZvdW5kJyk7CiAgICB9CiAgICBmb250LnBvcyA9IChmb250LnN0YXJ0IHx8IDApICsgdGFibGVzLm1heHAub2Zmc2V0OwogICAgY29uc3QgdmVyc2lvbiA9IGZvbnQuZ2V0SW50MzIoKTsKICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICBpZiAocHJvcGVydGllcy5zY2FsZUZhY3RvcnMgJiYgcHJvcGVydGllcy5zY2FsZUZhY3RvcnMubGVuZ3RoID09PSBudW1HbHlwaHMgJiYgaXNUcnVlVHlwZSkgewogICAgICBjb25zdCB7CiAgICAgICAgc2NhbGVGYWN0b3JzCiAgICAgIH0gPSBwcm9wZXJ0aWVzOwogICAgICBjb25zdCBpc0dseXBoTG9jYXRpb25zTG9uZyA9IGludDE2KHRhYmxlcy5oZWFkLmRhdGFbNTBdLCB0YWJsZXMuaGVhZC5kYXRhWzUxXSk7CiAgICAgIGNvbnN0IGdseXBocyA9IG5ldyBfZ2x5Zi5HbHlmVGFibGUoewogICAgICAgIGdseWZUYWJsZTogdGFibGVzLmdseWYuZGF0YSwKICAgICAgICBpc0dseXBoTG9jYXRpb25zTG9uZywKICAgICAgICBsb2NhVGFibGU6IHRhYmxlcy5sb2NhLmRhdGEsCiAgICAgICAgbnVtR2x5cGhzCiAgICAgIH0pOwogICAgICBnbHlwaHMuc2NhbGUoc2NhbGVGYWN0b3JzKTsKICAgICAgY29uc3QgewogICAgICAgIGdseWYsCiAgICAgICAgbG9jYSwKICAgICAgICBpc0xvY2F0aW9uTG9uZwogICAgICB9ID0gZ2x5cGhzLndyaXRlKCk7CiAgICAgIHRhYmxlcy5nbHlmLmRhdGEgPSBnbHlmOwogICAgICB0YWJsZXMubG9jYS5kYXRhID0gbG9jYTsKICAgICAgaWYgKGlzTG9jY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B9CiAgICBsZXQgbWF4RnVuY3Rpb25EZWZzID0gMDsKICAgIGxldCBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSAwOwogICAgaWYgKHZlcnNpb24gPj0gMHgwMDAxMDAwMCAmJiB0YWJsZXMubWF4cC5sZW5ndGggPj0gMjIpIHsKICAgICAgZm9udC5wb3MgKz0gODsKICAgICAgY29uc3QgbWF4Wm9uZXMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBpZiAobWF4Wm9uZXMgPiAyKSB7CiAgICAgICAgdGFibGVzLm1heHAuZGF0YVsxNF0gPSAwOwogICAgICAgIHRhYmxlcy5tYXhwLmRhdGFbMTVdID0gMjsKICAgICAgfQogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhGdW5jdGlvbkRlZnMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSBmb250LmdldFVpbnQxNigpOwogICAgfQogICAgdGFibGVzLm1heHAuZGF0YVs0XSA9IG51bUdseXBoc091dCA+PiA4OwogICAgdGFibGVzLm1heHAuZGF0YVs1XSA9IG51bUdseXBoc091dCAmIDI1NTsKICAgIGNvbnN0IGhpbnRzVmFsaWQgPSBzYW5pdGl6ZVRUUHJvZ3JhbXModGFibGVzLmZwZ20sIHRhYmxlcy5wcmVwLCB0YWJsZXNbImN2dCAiXSwgbWF4RnVuY3Rpb25EZWZzKTsKICAgIGlmICghaGludHNWYWxpZCkgewogICAgICBkZWxldGUgdGFibGVzLmZwZ207CiAgICAgIGRlbGV0ZSB0YWJsZXMucHJlcDsKICAgICAgZGVsZXRlIHRhYmxlc1siY3Z0ICJdOwogICAgfQogICAgc2FuaXRpemVNZXRyaWNzKGZvbnQsIHRhYmxlcy5oaGVhLCB0YWJsZXMuaG10eCwgdGFibGVzLmhlYWQsIG51bUdseXBoc091dCwgZHVwRmlyc3RFbnRyeSk7CiAgICBpZiAoIXRhYmxlcy5oZWFk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ICAgICAgICAgaWYgKCFnbHlwaE5hbWUpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBzdGFuZGFyZEdseXBoTmFtZSA9ICgwLCBfZm9udHNfdXRpbHMucmVjb3ZlckdseXBoTmFtZSkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGxldCB1bmljb2RlT3JDaGFyQ29kZTsKICAgICAgICAgIGlmIChjbWFwUGxhdGZvcm1JZCA9PT0gMyAmJiBjbWFwRW5jb2RpbmdJZCA9PT0gMSkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IGdseXBoc1VuaWNvZGVNYXBbc3RhbmRhcmRHbHlwaE5hbWVdOwogICAgICAgICAgfSBlbHNlIGlmIChjbWFwUGxhdGZvcm1JZCA9PT0gMSAmJiBjbWFwRW5jb2RpbmdJZCA9PT0gMCkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IF9lbmNvZGluZ3MuTWFjUm9tYW5FbmNvZGluZy5pbmRleE9mKHN0YW5kYXJkR2x5cGhOYW1lKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh1bmljb2RlT3JDaGFyQ29kZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgIGlmICghcHJvcGVydGllcy5nbHlwaE5hbWVzICYmIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgJiYgISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICAgICAgICBjb25zdCB1bmljb2RlID0gdGhpcy50b1VuaWNvZGUuZ2V0KGNoYXJDb2RlKTsKICAgICAgICAgICAgICBpZiAodW5pY29kZSkgewogICAgICAgICAgICAgICAgdW5pY29kZU9yQ2hhckNvZGUgPSB1bmljb2RlLmNvZGVQb2ludEF0KDApOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodW5pY29kZU9yQ2hhckNvZGUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGNvbnN0IG1hcHBpbmcgb2YgY21hcE1hcHBpbmdzKSB7CiAgICAgICAgICAgIGlmIChtYXBwaW5nLmNoYXJDb2RlICE9PSB1bmljb2RlT3JDaGFyQ29kZSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSA9IG1hcHBpbmcuZ2x5cGhJZDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNtYXBQbGF0Zm9ybUlkID09PSAwKSB7CiAgICAgICAgZm9yIChjb25zdCBtYXBwaW5nIG9mIGNtYXBNYXBwaW5ncykgewogICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbbWFwcGluZy5jaGFyQ29kZV0gPSBtYXBwaW5nLmdseXBoSWQ7CiAgICAgICAgfQogICAgICAgIGZvcmNlUG9zdFRhYmxlID0gdHJ1ZTsKICAgICAgfSBlbHNlIHsKICAgICAgICBmb3IgKGNvbnN0IG1hcHBpbmcgb2YgY21hcE1hcHBpbmdzKSB7CiAgICAgICAgICBsZXQgY2hhckNvZGUgPSBtYXBwaW5nLmNoYXJDb2RlOwogICAgICAgICAgaWYgKGNtYXBQbGF0Zm9ybUlkID09PSAzICYmIGNoYXJDb2RlID49IDB4ZjAwMCAmJiBjaGFyQ29kZSA8PSAweGYwZmYpIHsKICAgICAgICAgICAgY2hhckNvZGUgJj0gMHhmZjsKICAgICAgICAgIH0KICAgICAgICAgIGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSA9IG1hcHBpbmcuZ2x5cGhJZDsKICAgICAgIC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bGVyLmNvbXBpbGUoKTsKICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiRmFpbGVkIHRvIGNvbXBpbGUgZm9udCAiICsgcHJvcGVydGllcy5sb2FkZWROYW1lKTsKICAgICAgfQogICAgfQogICAgaWYgKCF0YWJsZXMubmFtZSkgewogICAgICB0YWJsZXMubmFtZSA9IHsKICAgICAgICB0YWc6ICJuYW1lIiwKICAgICAgICBkYXRhOiBjcmVhdGVOYW1lVGFibGUodGhpcy5uYW1lKQogICAgICB9OwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgW25hbWVQcm90b3R5cGUsIG5hbWVSZWNvcmRzXSA9IHJlYWROYW1lVGFibGUodGFibGVzLm5hbWUpOwogICAgICB0YWJsZXMubmFtZS5kYXRhID0gY3JlYXRlTmFtZVRhYmxlKG5hbWUsIG5hbWVQcm90b3R5cGUpOwogICAgICB0aGlzLnBzTmFtZSA9IG5hbWVQcm90b3R5cGVbMF1bNl0gfHwgbnVsbDsKICAgICAgaWYgKCFwcm9wZXJ0aWVzLmNvbXBvc2l0ZSkgewogICAgICAgIGFkanVzdFRydWVUeXBlVG9Vbmljb2RlKHByb3BlcnRpZXMsIHRoaXMuaXNTeW1ib2xpY0ZvbnQsIG5hbWVSZWNvcmRzKTsKICAgICAgfQogICAgfQogICAgY29uc3QgYnVpbGRlciA9IG5ldyBfb3BlbnR5cGVfZmlsZV9idWlsZGVyLk9wZW5UeXBlRmlsZUJ1aWxkZXIoaGVhZGVyLnZlcnNpb24pOwogICAgZm9yIChjb25zdCB0YWJsZVRhZyBpbiB0YWJsZXMpIHsKICAgICAgYnVpbGRlci5hZGRUYWJsZSh0YWJsZVRhZywgdGFibGVzW3RhYmxlVGFnXS5kYXRhKTsKICAgIH0KICAgIHJldHVybiBidWlsZGVyLnRvQXJyYXkoKTsKICB9CiAgY29udmVydChmb250TmFtZSwgZm9udCwgcHJvcGVydGllcykgewogICAgcHJvcGVydGllcy5maXhlZFB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b2RlIGluIGNoYXJDb2RlVG9HbHlwaElkKSB7CiAgICAgICAgaWYgKGdseXBoSWQgPT09IGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSkgewogICAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgICAgY2hhckNvZGVzID0gW107CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZXMucHVzaChjaGFyQ29kZSB8IDApOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gY2hhckNvZGVzOwogICAgfQogICAgZnVuY3Rpb24gY3JlYXRlQ2hhckNvZGUoY2hhckNvZGVUb0dseXBoSWQsIGdseXBoSWQpIHsKICAgICAgZm9yIChjb25zdCBjaGFyQ29kZSBpbiBjaGFyQ29kZVRvR2x5cGhJZCkgewogICAgICAgIGlmIChnbHlwaElkID09PSBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0pIHsKICAgICAgICAgIHJldHVybiBjaGFyQ29kZSB8IDA7CiAgICAgICAgfQogICAgICB9CiAgICAgIG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWRbbmV3TWFwcGluZy5uZXh0QXZhaWxhYmxlRm9udENoYXJDb2RlXSA9IGdseXBoSWQ7CiAgICAgIHJldHVybiBuZXdNYXBwaW5nLm5leHRBdmFpbGFibGVGb250Q2hhckNvZGUrKzsKICAgIH0KICAgIGNvbnN0IHNlYWNzID0gZm9udC5zZWFjczsKICAgIGlmIChuZXdNYXBwaW5nICYmIF9mb250c191dGlscy5TRUFDX0FOQUxZU0lTX0VOQUJMRUQgJiYgc2VhY3MgJiYgc2VhY3MubGVuZ3RoKSB7CiAgICAgIGNvbnN0IG1hdHJpeCA9IHByb3BlcnRpZXMuZm9udE1hdHJpeCB8fCBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWDsKICAgICAgY29uc3QgY2hhcnNldCA9IGZvbnQuZ2V0Q2hhcnNldCgpOwogICAgICBjb25zdCBzZWFjTWFwID0gT2JqZW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nJvbUNvZGVQb2ludChzZWFjLmFjY2VudEZvbnRDaGFyQ29kZSksCiAgICAgICAgb2Zmc2V0OiBzZWFjLmFjY2VudE9mZnNldAogICAgICB9OwogICAgfQogICAgbGV0IGZvbnRDaGFyID0gIiI7CiAgICBpZiAodHlwZW9mIGZvbnRDaGFyQ29kZSA9PT0gIm51bWJlciIpIHsKICAgICAgaWYgKGZvbnRDaGFyQ29kZSA8PSAweDEwZmZmZikgewogICAgICAgIGZvbnRDaGFyID0gU3RyaW5nLmZyb21Db2RlUG9pbnQoZm9udENoYXJDb2RlKTsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGNoYXJUb0dseXBoIC0gaW52YWxpZCBmb250Q2hhckNvZGU6ICR7Zm9udENoYXJDb2RlfWApOwogICAgICB9CiAgICB9CiAgICBnbHlwaCA9IG5ldyBHbHlwaChjaGFyY29kZSwgZm9udENoYXIsIHVuaWNvZGUsIGFjY2VudCwgd2lkdGgsIHZtZXRyaWMsIG9wZXJhdG9yTGlzdElkLCBpc1NwYWNlLCBpc0luRm9udCk7CiAgICByZXR1cm4gdGhpcy5fZ2x5cGhDYWNoZVtjaGFyY29kZV0gPSBnbHlwaDsKICB9CiAgY2hhcnNUb0dseXBocyhjaGFycykgewogICAgbGV0IGdseXBocyA9IHRoaXMuX2NoYXJzQ2FjaGVbY2hhcnNdOwogICAgaWYgKGdseXBocykgewogICAgICByZXR1cm4gZ2x5cGhzOwogICAgfQogICAgZ2x5cGhzID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpLAogICAgICAgIGlpID0gY2hhcnMubGVuZ3RoOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgICB0aGlzLmNNYXAucmVhZENoYXJDb2RlKGNoYXJzLCBpLCBjKTsKICAgICAgICBjb25zdCB7CiAgICAgICAgICBjaGFyY29k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ICsraSkgewogICAgICAgIHBvc2l0aW9ucy5wdXNoKFtpLCBpICsgMV0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zaXRpb25zOwogIH0KICBnZXQgZ2x5cGhDYWNoZVZhbHVlcygpIHsKICAgIHJldHVybiBPYmplY3QudmFsdWVzKHRoaXMuX2dseXBoQ2FjaGUpOwogIH0KICBlbmNvZGVTdHJpbmcoc3RyKSB7CiAgICBjb25zdCBidWZmZXJzID0gW107CiAgICBjb25zdCBjdXJyZW50QnVmID0gW107CiAgICBjb25zdCBoYXNDdXJyZW50QnVmRXJyb3JzID0gKCkgPT4gYnVmZmVycy5sZW5ndGggJSAyID09PSAxOwogICAgY29uc3QgZ2V0Q2hhckNvZGUgPSB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCA/IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZih1bmljb2RlKSA6IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZihTdHJpbmcuZnJvbUNvZGVQb2ludCh1bmljb2RlKSk7CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdHIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB1bmljb2RlID0gc3RyLmNvZGVQb2ludEF0KGkpOwogICAgICBpZiAodW5pY29kZSA+IDB4ZDdmZiAmJiAodW5pY29kZSA8IDB4ZTAwMCB8fCB1bmljb2RlID4gMHhmZmZkKSkgewogICAgICAgIGkrKzsKICAgICAgfQogICAgICBpZiAodGhpcy50b1VuaWNvZGUpIHsKICAgICAgICBjb25zdCBjaGFyQ29kZSA9IGdldENoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGlmIChjaGFyQ29kZSAhPT0gLTEpIHsKICAgICAgICAgIGlmIChoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICAgICAgYnVmZmV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sb29rdXAgPSBbIjAiLCAiMSIsICIyIiwgIjMiLCAiNCIsICI1IiwgIjYiLCAiNyIsICI4IiwgIjkiLCAiLiIsICJFIiwgIkUtIiwgbnVsbCwgIi0iXTsKICAgICAgY29uc3QgbGVuZ3RoID0gZGljdC5sZW5ndGg7CiAgICAgIHdoaWxlIChwb3MgPCBsZW5ndGgpIHsKICAgICAgICBjb25zdCBiID0gZGljdFtwb3MrK107CiAgICAgICAgY29uc3QgYjEgPSBiID4+IDQ7CiAgICAgICAgY29uc3QgYjIgPSBiICYgMTU7CiAgICAgICAgaWYgKGIxID09PSBlb2YpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHIgKz0gbG9va3VwW2IxXTsKICAgICAgICBpZiAoYjIgPT09IGVvZikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHN0ciArPSBsb29rdXBbYjJdOwogICAgICB9CiAgICAgIHJldHVybiBwYXJzZUZsb2F0KHN0cik7CiAgICB9CiAgICBsZXQgb3BlcmFuZHMgPSBbXTsKICAgIGNvbnN0IGVudHJpZXMgPSBbXTsKICAgIHBvcyA9IDA7CiAgICBjb25zdCBlbmQgPSBkaWN0Lmxlbmd0aDsKICAgIHdoaWxlIChwb3MgPCBlbmQpIHsKICAgICAgbGV0IGIgPSBkaWN0W3Bvc107CiAgICAgIGlmIChiIDw9IDIxKSB7CiAgICAgICAgaWYgKGIgPT09IDEyKSB7CiAgICAgICAgICBiID0gYiA8PCA4IHwgZGljdFsrK3Bvc107CiAgICAgICAgfQogICAgICAgIGVudHJpZXMucHVzaChbYiwgb3BlcmFuZHNdKTsKICAgICAgICBvcGVyYW5kcyA9IFtdOwogICAgICAgICsrcG9zOwogICAgICB9IGVsc2UgewogICAgICAgIG9wZXJhbmRzLnB1c2gocGFyc2VPcGVyYW5kKCkpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW50cmllczsKICB9CiAgcGFyc2VJbmRleChwb3MpIHsKICAgI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gbGVuZ3RoID0gZGF0YS5sZW5ndGg7CiAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxlbmd0aDspIHsKICAgICAgY29uc3QgdmFsdWUgPSBkYXRhW2orK107CiAgICAgIGxldCB2YWxpZGF0aW9uQ29tbWFuZCA9IG51bGw7CiAgICAgIGlmICh2YWx1ZSA9PT0gMTIpIHsKICAgICAgICBjb25zdCBxID0gZGF0YVtqKytdOwogICAgICAgIGlmIChxID09PSAwKSB7CiAgICAgICAgICBkYXRhW2ogLSAyXSA9IDEzOTsKICAgICAgICAgIGRhdGFbaiAtIDFdID0gMjI7CiAgICAgICAgICBzdGFja1NpemUgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YTEyW3FdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMjgpIHsKICAgICAgICBzdGFja1tzdGFja1NpemVdID0gKGRhdGFbal0gPDwgMjQgfCBkYXRhW2ogKyAxXSA8PCAxNikgPj4gMTY7CiAgICAgICAgaiArPSAyOwogICAgICAgIHN0YWNrU2l6ZSsrOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxNCkgewogICAgICAgIGlmIChzdGFja1NpemUgPj0gNCkgewogICAgICAgICAgc3RhY2tTaXplIC09IDQ7CiAgICAgICAgICBpZiAodGhpcy5zZWFjQW5hbHlzaXNFbmFibGVkKSB7CiAgICAgICAgICAgIHN0YXRlLnNlYWMgPSBzdGFjay5zbGljZShzdGFja1NpemUsIHN0YWNrU2l6ZSArIDQpOwogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHZhbGlkYXRpb25Db21tYW5kID0gQ2hhcnN0cmluZ1ZhbGlkYXRpb25EYXRhW3ZhbHVlXTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA+PSAzMiAmJiB2YWx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2JhbFN1YnJJbmRleDsKICAgICAgICB9CiAgICAgICAgaWYgKCFzdWJyc0luZGV4KSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk1pc3Npbmcgc3VicnNJbmRleCBmb3IgIiArIHZhbGlkYXRpb25Db21tYW5kLmlkKTsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgbGV0IGJpYXMgPSAzMjc2ODsKICAgICAgICBpZiAoc3VicnNJbmRleC5jb3VudCA8IDEyNDApIHsKICAgICAgICAgIGJpYXMgPSAxMDc7CiAgICAgICAgfSBlbHNlIGlmIChzdWJyc0luZGV4LmNvdW50IDwgMzM5MDApIHsKICAgICAgICAgIGJpYXMgPSAxMTMxOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdWJyTnVtYmVyID0gc3RhY2tbLS1zdGFja1NpemVdICsgYmlhczsKICAgICAgICBpZiAoc3Vick51bWJlciA8IDAgfHwgc3Vick51bWJlciA+PSBzdWJyc0luZGV4LmNvdW50IHx8IGlzTmFOKHN1YnJOdW1iZXIpKSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk91dCBvZiBib3VuZHMgc3VickluZGV4IGZvciAiICsgdmFsaWRhdGlvbkNvbW1hbmQuaWQpOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5zdGFja1NpemUgPSBzdGFja1NpemU7CiAgICAgICAgc3RhdGUuY2FsbERlcHRoKys7CiAgICAgICAgY29uc3QgdmFsaWQgPSB0aGlzLnBhcnNlQ2hhclN0cmluZyhzdGF0ZSwgc3VicnNJbmRleC5nZXQoc3Vick51bWJlciksIGxvY2FsU3VickluZGV4LCBnbG9iYWxTdWJySW5kZXgpOwogICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUuY2FsbERlcHRoLS07CiAgICAgICAgc3RhY2tTaXplID0gc3RhdGUuc3RhY2tTaXplOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxMSkgewogICAgICAgIHN0YXRlLnN0YWNrU2l6ZSA9IHN0YWNrU2l6ZTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMCAmJiBqID09PSBkYXRhLmxlbmd0aCkgewogICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgdmFsaWRhdGlvbkNvbW1hbmQgPSBDaGFyc3RyaW5nVmFsaWRhdGlvbkRhdGFbMTRdOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSA5KSB7CiAgICAgICAgZGF0YS5jb3B5V2l0aGluKGogLSAxLCBqLCAtMSk7CiAgICAgICAgaiAtPSAxOwogICAgICAgIGxlbmd0aCAtPSAxOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHZhbGlkYXRpb25Db21tYW5kID0gQ2hhcnN0cmluZ1ZhbGlkYXRpb25EYXRhW3ZhbHVlXTsKICAgICAgfQogICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQuc3RlbSkgewogICAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgICBpZiAodmFsdWUgPT09IDMgfHwgdmFsdWUgPT09IDIzKSB7CiAgICAgICAgICAgIHN0YXRlLmhhc1ZTdGVtcyA9IHRydWU7CiAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhhc1ZTdGVtcyAmJiAodmFsdWUgPT09IDEgfHwgdmFsdWUgPT09IDE4KSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkNGRiBzdGVtIGhpbnRzIGFyZSBpbiB3cm9uZyBvcmRlciIpOwogICAgICAgICAgICBkYXRhW2ogLSAxXSA9IHZhbHVlID09PSAxID8gMyA6IDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIm1pbiIgaW4gdmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICAgIGlmICghc3RhdGUudW5kZWZTdGFjayAmJiBzdGFja1NpemUgPCB2YWxpZGF0aW9uQ29tbWFuZC5taW4pIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJOb3QgZW5vdWdoIHBhcmFtZXRlcnMgZm9yICIgKyB2YWxpZGF0aW9uQ29tbWFuZC5pZCArICI7IGFjdHVhbDogIiArIHN0YWNrU2l6ZSArICIsIGV4cGVjdGVkOiAiICsgdmFsaWRhdGlvbkNvbW1hbmQubWluKTsKICAgICAgICAgICAgaWYgKHN0YWNrU2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUuZmlyc3RTdGFja0NsZWFyaW5nICYmIHZhbGlkYXRpb25Db21tYW5kLnN0YWNrQ2xlYXJpbmcpIHsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgICAgc3RhY2tTaXplIC09IHZhbGlkYXRpb25Db21tYW5kLm1pbjsKICAgICAgICAgIGlmIChzdGFja1NpemUgPj0gMiAmJiB2YWxpZGF0aW9uQ29tbWFuZC5zdGVtKSB7CiAgICAgICAgICAgIHN0YWNrU2l6ZSAlPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdGFja1NpemUgPiAxKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRm91bmQgdG9vIG1hbnkgcGFyYW1ldGVycyBmb3Igc3RhY2stY2xlYXJpbmcgY29tbWFuZCIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0YWNrU2l6ZSA+IDApIHsKICAgICAgICAgICAgc3RhdGUud2lkdGggPSBzdGFja1tzdGFja1NpemUgLSAxXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKCJzdGFja0RlbHRhIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgaWYgKCJzdGFja0ZuIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZC5zdGFja0ZuKHN0YWNrLCBzdGFja1NpemUpOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2tTaXplICs9IHZhbGlkYXRpb25Db21tYW5kLnN0YWNrRGVsdGE7CiAgICAgICAgfSBlbHNlIGlmICh2YWxpZGF0aW9uQ29tbWFuZC5zdGFja0NsZWFyaW5nKSB7CiAgICAgICAgICBzdGFja1NpemUgPSAwOwogICAgICAgIH0gZWxzZSBpZiAodmFsaWRhdGlvbkNvbW1hbmQucmVzZXRTdGFjaykgewogICAgICAgICAgc3RhY2tTaXplID0gMDsKICAgICAgICAgIHN0YXRlLnVuZGVmU3RhY2sgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgaWYgKHZhbGlkYXRpb25Db21tYW5kLnVuZGVmU3RhY2spIHsKICAgICAgICAgIHN0YWNrU2l6ZSA9IDA7CiAgICAgICAgICBzdGF0ZS51bmRlZlN0YWNrID0gdHJ1ZTsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgaWYgKGxlbmd0aCA8IGRhdGEubGVuZ3RoKSB7CiAgICAgIGRhdGEuZmlsbCg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AgICAgICAgIGlkID0gYnl0ZXNbcG9zKytdIDw8IDggfCBieXRlc1twb3MrK107CiAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQgOiBzdHJpbmdzLmdldChpZCkpOwogICAgICAgIH0KICAgICAgICBicmVhazsKICAgICAgY2FzZSAxOgogICAgICAgIHdoaWxlIChjaGFyc2V0Lmxlbmd0aCA8PSBsZW5ndGgpIHsKICAgICAgICAgIGlkID0gYnl0ZXNbcG9zKytdIDw8IDggfCBieXRlc1twb3MrK107CiAgICAgICAgICBjb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICB3aGlsZSAoY2hhcnNldC5sZW5ndGggPD0gbGVuZ3RoKSB7CiAgICAgICAgICBpZCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgICAgICAgY291bnQgPSBieXRlc1twb3MrK10gPDwgOCB8IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIGNoYXJzZXQgZm9ybWF0Iik7CiAgICB9CiAgICBjb25zdCBlbmQgPSBwb3M7CiAgICBjb25zdCByYXcgPSBieXRlcy5zdWJhcnJheShzdGFydCwgZW5kKTsKICAgIHJldHVybiBuZXcgQ0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HsKICAgICAgICAgIGVuY29kaW5nW2luZGV4XSA9IGk7CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhU3RhcnQgPSBwb3M7CiAgICAgIGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgICAgc3dpdGNoIChmb3JtYXQgJiAweDdmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgY29uc3QgZ2x5cGhzQ291bnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICBmb3IgKGkgPSAxOyBpIDw9IGdseXBoc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgZW5jb2RpbmdbYnl0ZXNbcG9zKytdXSA9IGk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDE6CiAgICAgICAgICBjb25zdCByYW5nZXNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGxldCBnaWQgPSAxOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJhbmdlc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc3RhcnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGZvciAobGV0IGogPSBzdGFydDsgaiA8PSBzdGFydCArIGxlZnQ7IGorKykgewogICAgICAgICAgICAgIGVuY29kaW5nW2pdID0gZ2lkKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVua25vd24gZW5jb2RpbmcgZm9ybWF0OiAke2Zvcm1hdH0gaW4gQ0ZGYCk7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUVuZCA9IHBvczsKICAgICAgaWYgKGZvcm1hdCAmIDB4ODApIHsKICAgICAgICBieXRlc1tkYXRhU3RhcnRdICY9IDB4N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0dXJuIHRoaXMuZGVmYXVsdHNba2V5XTsKICAgIH0KICAgIHJldHVybiB0aGlzLnZhbHVlc1trZXldOwogIH0KICByZW1vdmVCeU5hbWUobmFtZSkgewogICAgZGVsZXRlIHRoaXMudmFsdWVzW3RoaXMubmFtZVRvS2V5TWFwW25hbWVdXTsKICB9CiAgc3RhdGljIGNyZWF0ZVRhYmxlcyhsYXlvdXQpIHsKICAgIGNvbnN0IHRhYmxlcyA9IHsKICAgICAga2V5VG9OYW1lTWFwOiB7fSwKICAgICAgbmFtZVRvS2V5TWFwOiB7fSwKICAgICAgZGVmYXVsdHM6IHt9LAogICAgICB0eXBlczoge30sCiAgICAgIG9wY29kZXM6IHt9LAogICAgICBvcmRlcjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGxheW91dCkgewogICAgICBjb25zdCBrZXkgPSBBcnJheS5pc0FycmF5KGVudHJ5WzBdKSA/IChlbnRyeVswXVswXSA8PCA4KSArIGVudHJ5WzBdWzFdIDogZW50cnlbMF07CiAgICAgIHRhYmxlcy5rZXlUb05hbWVNYXBba2V5XSA9IGVudHJ5WzFdOwogICAgICB0YWJsZXMubmFtZVRvS2V5TWFwW2VudHJ5WzFdXSA9IGtleTsKICAgICAgdGFibGVzLnR5cGVzW2tleV0gPSBlbnRyeVsyXTsKICAgICAgdGFibGVzLmRlZmF1bHRzW2tleV0gPSBlbnRyeVszXTsKICAgICAgdGFibGVzLm9wY29kZXNba2V5XSA9IEFycmF5LmlzQXJyYXkoZW50cnlbMF0pID8gZW50cnlbMF0gOiBbZW50cnlbMF1dOwogICAgICB0YWJsZXMub3JkZXIucHVzaChrZXkpOwogICAgfQogICAgcmV0dXJuIHRhYmxlczsKICB9Cn0KY29uc3QgQ0ZGVG9wRGljdExheW91dCA9IFtbWzEyLCAzMF0sICJST1MiLCBbInNpZCIsICJzaWQiLCAibnVtIl0sIG51bGxdLCBbWzEyLCAyMF0sICJTeW50aGV0aWNCYXNlIiwgIm51bSI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0ZSIsIFtwcml2YXRlRGljdERhdGEubGVuZ3RoLCBvdXRwdXRMZW5ndGhdLCBvdXRwdXQpOwogICAgICBvdXRwdXQuYWRkKHByaXZhdGVEaWN0RGF0YSk7CiAgICAgIGlmIChwcml2YXRlRGljdC5zdWJyc0luZGV4ICYmIHByaXZhdGVEaWN0Lmhhc05hbWUoIlN1YnJzIikpIHsKICAgICAgICBjb25zdCBzdWJycyA9IHRoaXMuY29tcGlsZUluZGV4KHByaXZhdGVEaWN0LnN1YnJzSW5kZXgpOwogICAgICAgIHByaXZhdGVEaWN0VHJhY2tlci5zZXRFbnRyeUxvY2F0aW9uKCJTdWJycyIsIFtwcml2YXRlRGljdERhdGEubGVuZ3RoXSwgb3V0cHV0KTsKICAgICAgICBvdXRwdXQuYWRkKHN1YnJzKTsKICAgICAgfQogICAgfQogIH0KICBjb21waWxlRGljdChkaWN0LCBvZmZzZXRUcmFja2VyKSB7CiAgICBjb25zdCBvdXQgPSBbXTsKICAgIGZvciAoY29uc3Qga2V5IG9mIGRpY3Qub3JkZXIpIHsKICAgICAgaWYgKCEoa2V5IGluIGRpY3QudmFsdWVzKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCB2YWx1ZXMgPSBkaWN0LnZhbHVlc1trZXldOwogICAgICBsZXQgdHlwZXMgPSBkaWN0LnR5cGVzW2tleV07CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh0eXBlcykpIHsKICAgICAgICB0eXBlcyA9IFt0eXBlc107CiAgICAgIH0KICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlcykpIHsKICAgICAgICB2YWx1ZXMgPSBbdmFsdWVzXTsKICAgICAgfQogICAgICBpZiAodmFsdWVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR5cGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBjb25zdCB0eXBlID0gdHlwZXNbal07CiAgICAgICAgY29uc3QgdmFsdWUgPSB2YWx1ZXNbal07CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlICJudW0iOgogICAgICAgICAgY2FzZSAic2lkIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJvZmZzZXQiOgogICAgICAgICAgICBjb25zdCBuYW1lID0gZGljdC5rZXlUb05hbWVNYXBba2V5XTsKICAgICAgICAgICAgaWYgKCFvZmZzZXRUcmFja2VyLmlzVHJhY2tpbmcobmFtZSkpIHsKICAgICAgICAgICAgICBvZmZzZXRUcmFja2VyLnRyYWNrKG5hbWUsIG91dC5sZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG91dC5wdXNoKDB4MWQsIDAsIDAsIDAsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgImFycmF5IjoKICAgICAgICAgIGNhc2UgImRlbHRhIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDEsIGtrID0gdmFsdWVzLmxlbmd0aDsgayA8IGtrOyArK2spIHsKICAgICAgICAgICAgICBvdXQucHVzaCguLi50aGlzLmVuY29kZU51bWJlcih2YWx1ZXNba10pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5rbm93biBkYXRhIHR5cGUgb2YgJHt0eXBlfWApOwogICAgICAgIH0KICAgICAgfQogICAgICBvdXQucHVzaCguLi5kaWN0Lm9wY29kZXNba2V5XSk7CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0KICBjb21waWxlU3RyaW5nSW5k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IG51bUdseXBocyAtIDE7CiAgICBpZiAoaXNDSURGb250KSB7CiAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KFsyLCAwLCAwLCBudW1HbHlwaHNMZXNzTm90RGVmID4+IDggJiAweGZmLCBudW1HbHlwaHNMZXNzTm90RGVmICYgMHhmZl0pOwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgbGVuZ3RoID0gMSArIG51bUdseXBoc0xlc3NOb3REZWYgKiAyOwogICAgICBvdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICBvdXRbMF0gPSAwOwogICAgICBsZXQgY2hhcnNldEluZGV4ID0gMDsKICAgICAgY29uc3QgbnVtQ2hhcnNldHMgPSBjaGFyc2V0LmNoYXJzZXQubGVuZ3RoOwogICAgICBsZXQgd2FybmVkID0gZmFsc2U7CiAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgb3V0Lmxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgbGV0IHNpZCA9IDA7CiAgICAgICAgaWYgKGNoYXJzZXRJbmRleCA8IG51bUNoYXJzZXRzKSB7CiAgICAgICAgICBjb25zdCBuYW1lID0gY2hhcnNldC5jaGFyc2V0W2NoYXJzZXRJbmRleCsrXTsKICAgICAgICAgIHNpZCA9IHN0cmluZ3MuZ2V0U0lEKG5hbWUpOwogICAgICAgICAgaWYgKHNpZCA9PT0gLTEpIHsKICAgICAgICAgICAgc2lkID0gMDsKICAgICAgICAgICAgaWYgKCF3YXJuZWQpIHsKICAgICAgICAgICAgICB3YXJuZWQgPSB0cnVlOwogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQ291bGRuJ3QgZmluZCAke25hbWV9IGluIENGRiBzdHJpbmdzYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0W2ldID0gc2lkID4+IDggJiAweGZmOwogICAgICAgIG91dFtpICsgMV0gPSBzaWQgJiAweGZmOwogICAgICB9CiAgICB9CiAgICByZXR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iwgIiIsICIiLCAiIiwgIiIsICIiLCAiIiwgIiIsICIiLCAiIiwgIiIsICIiLCAiIiwgIiIsICIiLCAiYTEwMSIsICJhMTAyIiwgImExMDMiLCAiYTEwNCIsICJhMTA2IiwgImExMDciLCAiYTEwOCIsICJhMTEyIiwgImExMTEiLCAiYTExMCIsICJhMTA5IiwgImExMjAiLCAiYTEyMSIsICJhMTIyIiwgImExMjMiLCAiYTEyNCIsICJhMTI1IiwgImExMjYiLCAiYTEyNyIsICJhMTI4IiwgImExMjkiLCAiYTEzMCIsICJhMTMxIiwgImExMzIiLCAiYTEzMyIsICJhMTM0IiwgImExMzUiLCAiYTEzNiIsICJhMTM3IiwgImExMzgiLCAiYTEzOSIsICJhMTQwIiwgImExNDEiLCAiYTE0MiIsICJhMTQzIiwgImExNDQiLCAiYTE0NSIsICJhMTQ2IiwgImExNDciLCAiYTE0OCIsICJhMTQ5IiwgImExNTAiLCAiYTE1MSIsICJhMTUyIiwgImExNTMiLCAiYTE1NCIsICJhMTU1IiwgImExNTYiLCAiYTE1NyIsICJhMTU4IiwgImExNTkiLCAiYTE2MCIsICJhMTYxIiwgImExNjMiLCAiYTE2NCIsICJhMTk2IiwgImExNjUiLCAiYTE5MiIsICJhMTY2IiwgImExNjciLCAiYTE2OCIsICJhMTY5IiwgImExNzAiLCAiYTE3MSIsICJhMTcyIiwgImExNzMiLCAiYTE2MiIsICJhMTc0IiwgImExNzUiLCAiYTE3NiIsICJhMTc3IiwgImExNzgiLCAiYTE3OSIsICJhMTkzIiwgImExODAiLCAiYTE5OSIsICJhMTgxIiwgImEyMDAiLCAiYTE4MiIsICIiLCAiYTIwMSIsICJhMTgzIiwgImExODQiLCAiYTE5NyIsICJhMTg1IiwgImExOTQiLCAiYTE5OCIsICJhMTg2IiwgImExOTUiLCAiYTE4NyIsICJhMTg4IiwgImExODkiLCAiYTE5MCIsICJhMTkxIiwgIiJdOwpleHBvcnRzLlphcGZEaW5nYmF0c0VuY29kaW5nID0gWmFwZk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HgwMDE4LAogICJjb250cm9sQ1IiLAogIDB4MDAwZCwKICAiY29udHJvbERDMSIsCiAgMHgwMDExLAogICJjb250cm9sREMyIiwKICAweDAwMTIsCiAgImNvbnRyb2xEQzMiLAogIDB4MDAxMywKICAiY29udHJvbERDNCIsCiAgMHgwMDE0LAogICJjb250cm9sREVMIiwKICAweDAwN2YsCiAgImNvbnRyb2xETEUiLAogIDB4MDAxMCwKICAiY29udHJvbEVNIiwKICAweDAwMTksCiAgImNvbnRyb2xFTlEiLAogIDB4MDAwNSwKICAiY29udHJvbEVPVCIsCiAgMHgwMDA0LAogICJjb250cm9sRVNDIiwKICAweDAwMWIsCiAgImNvbnRyb2xFVEIiLAogIDB4MDAxNywKICAiY29udHJvbEVUWCIsCiAgMHgwMDAzLAogICJjb250cm9sRkYiLAogIDB4MDAwYywKICAiY29udHJvbEZTIiwKICAweDAwMWMsCiAgImNvbnRyb2xHUyIsCiAgMHgwMDFkLAogICJjb250cm9sSFQiLAogIDB4MDAwOSwKICAiY29udHJvbExGIiwKICAweDAwMGEsCiAgImNvbnRyb2xOQUsiLAogIDB4MDAxNSwKICAiY29udHJvbE5VTEwiLAogIDB4MDAwMCwKICAiY29udHJvbFJTIiwKICAweDAwMWUsCiAgImNvbnRyb2xTSSIsCiAgMHgwMDBmLAogICJjb250cm9sU08iLAogIDB4MDAwZSwKICAiY29udHJvbFNPVCIsCiAgMHgwMDAyLAogICJjb250cm9sU1RYIiwKICAweDAwMDEsCiAgImNvbnRyb2xTVUIiLAogIDB4MDAxYSwKICAiY29udHJvbFNZTiIsCiAgMHgwMDE2LAogICJjb250cm9sVVMiLAogIDB4MDAxZiwKICAiY29udHJvbFZUIiwKICAweDAwMGIsCiAgImNvcHlyaWdodCIsCiAgMHgwMGE5LAogICJjb3B5cmlnaHRzYW5zIiwKICAweGY4ZTksCiAgImNvcHlyaWdodHNlcmlmIiwKICAweGY2ZDksCiAgImNvcm5lcmJyYWNrZXRsZWZ0IiwKICAweDMwMGMsCi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MDViNCwKICAiaGlyaXF3aWRlaGVicmV3IiwKICAweDA1YjQsCiAgImhsaW5lYmVsb3ciLAogIDB4MWU5NiwKICAiaG1vbm9zcGFjZSIsCiAgMHhmZjQ4LAogICJob2FybWVuaWFuIiwKICAweDA1NzAsCiAgImhvaGlwdGhhaSIsCiAgMHgwZTJiLAogICJob2hpcmFnYW5hIiwKICAweDMwN2IsCiAgImhva2F0YWthbmEiLAogIDB4MzBkYiwKICAiaG9rYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjhlLAogICJob2xhbSIsCiAgMHgwNWI5LAogICJob2xhbTE5IiwKICAweDA1YjksCiAgImhvbGFtMjYiLAogIDB4MDViOSwKICAiaG9sYW0zMiIsCiAgMHgwNWI5LAogICJob2xhbWhlYnJldyIsCiAgMHgwNWI5LAogICJob2xhbW5hcnJvd2hlYnJldyIsCiAgMHgwNWI5LAogICJob2xhbXF1YXJ0ZXJoZWJyZXciLAogIDB4MDViOSwKICAiaG9sYW13aWRlaGVicmV3IiwKICAweDA1YjksCiAgImhvbm9raHVrdGhhaSIsCiAgMHgwZTJlLAogICJob29rYWJvdmVjb21iIiwKICAweDAzMDksCiAgImhvb2tjbWIiLAogIDB4MDMwOSwKICAiaG9va3BhbGF0YWxpemVkYmVsb3djbWIiLAogIDB4MDMyMSwKICAiaG9va3JldHJvZmxleGJlbG93Y21iIiwKICAweDAzMjIsCiAgImhvb25zcXVhcmUiLAogIDB4MzM0MiwKICAiaG9yaWNvcHRpYyIsCiAgMHgwM2U5LAogICJob3Jpem9udGFsYmFyIiwKICAweDIwMTUsCiAgImhvcm5jbWIiLAogIDB4MDMxYiwKICAiaG90c3ByaW5ncyIsCiAgMHgyNjY4LAogICJob3VzZSIsCiAgMHgyMzAyLAogICJocGFyZW4iLAogIDB4MjRhMywKICAiaHN1cGVyaW9yIiwKICAweDAyYjAsCiAgImh0dXJuZWQiLAogIDB4MDI2NSwKICAiaHVoaXJhZ2FuYSIsCiAgMHgzMDc1LAogICJod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DA5NDAsCiAgImlpdm93ZWxzaWduZ3VqYXJhdGkiLAogIDB4MGFjMCwKICAiaWoiLAogIDB4MDEzMywKICAiaWthdGFrYW5hIiwKICAweDMwYTQsCiAgImlrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjcyLAogICJpa29yZWFuIiwKICAweDMxNjMsCiAgImlsZGUiLAogIDB4MDJkYywKICAiaWx1eWhlYnJldyIsCiAgMHgwNWFjLAogICJpbWFjcm9uIiwKICAweDAxMmIsCiAgImltYWNyb25jeXJpbGxpYyIsCiAgMHgwNGUzLAogICJpbWFnZW9yYXBwcm94aW1hdGVseWVxdWFsIiwKICAweDIyNTMsCiAgImltYXRyYWd1cm11a2hpIiwKICAweDBhM2YsCiAgImltb25vc3BhY2UiLAogIDB4ZmY0OSwKICAiaW5jcmVtZW50IiwKICAweDIyMDYsCiAgImluZmluaXR5IiwKICAweDIyMWUsCiAgImluaWFybWVuaWFuIiwKICAweDA1NmIsCiAgImludGVncmFsIiwKICAweDIyMmIsCiAgImludGVncmFsYm90dG9tIiwKICAweDIzMjEsCiAgImludGVncmFsYnQiLAogIDB4MjMyMSwKICAiaW50ZWdyYWxleCIsCiAgMHhmOGY1LAogICJpbnRlZ3JhbHRvcCIsCiAgMHgyMzIwLAogICJpbnRlZ3JhbHRwIiwKICAweDIzMjAsCiAgImludGVyc2VjdGlvbiIsCiAgMHgyMjI5LAogICJpbnRpc3F1YXJlIiwKICAweDMzMDUsCiAgImludmJ1bGxldCIsCiAgMHgyNWQ4LAogICJpbnZjaXJjbGUiLAogIDB4MjVkOSwKICAiaW52c21pbGVmYWNlIiwKICAweDI2M2IsCiAgImlvY3lyaWxsaWMiLAogIDB4MDQ1MSwKICAiaW9nb25layIsCiAgMHgwMTJmLAogICJpb3RhIiwKICAweDAzYjksCiAgImlvdGFkaWVyZXNpcyIsCiAgMHgwM2NhLAogICJpb3RhZGllcmVzaXN0b25vcyIsCiAgMHgwMzkwLAogICJpb3RhbGF0aW4iLAogIDB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iAgImpjcm9zc2VkdGFpbCIsCiAgMHgwMjlkLAogICJqZG90bGVzc3N0cm9rZSIsCiAgMHgwMjVmLAogICJqZWN5cmlsbGljIiwKICAweDA0NTgsCiAgImplZW1hcmFiaWMiLAogIDB4MDYyYywKICAiamVlbWZpbmFsYXJhYmljIiwKICAweGZlOWUsCiAgImplZW1pbml0aWFsYXJhYmljIiwKICAweGZlOWYsCiAgImplZW1tZWRpYWxhcmFiaWMiLAogIDB4ZmVhMCwKICAiamVoYXJhYmljIiwKICAweDA2OTgsCiAgImplaGZpbmFsYXJhYmljIiwKICAweGZiOGIsCiAgImpoYWJlbmdhbGkiLAogIDB4MDk5ZCwKICAiamhhZGV2YSIsCiAgMHgwOTFkLAogICJqaGFndWphcmF0aSIsCiAgMHgwYTlkLAogICJqaGFndXJtdWtoaSIsCiAgMHgwYTFkLAogICJqaGVoYXJtZW5pYW4iLAogIDB4MDU3YiwKICAiamlzIiwKICAweDMwMDQsCiAgImptb25vc3BhY2UiLAogIDB4ZmY0YSwKICAianBhcmVuIiwKICAweDI0YTUsCiAgImpzdXBlcmlvciIsCiAgMHgwMmIyLAogICJrIiwKICAweDAwNmIsCiAgImthYmFzaGtpcmN5cmlsbGljIiwKICAweDA0YTEsCiAgImthYmVuZ2FsaSIsCiAgMHgwOTk1LAogICJrYWN1dGUiLAogIDB4MWUzMSwKICAia2FjeXJpbGxpYyIsCiAgMHgwNDNhLAogICJrYWRlc2NlbmRlcmN5cmlsbGljIiwKICAweDA0OWIsCiAgImthZGV2YSIsCiAgMHgwOTE1LAogICJrYWYiLAogIDB4MDVkYiwKICAia2FmYXJhYmljIiwKICAweDA2NDMsCiAgImthZmRhZ2VzaCIsCiAgMHhmYjNiLAogICJrYWZkYWdlc2hoZWJyZXciLAogIDB4ZmIzYiwKICAia2FmZmluYWxhcmFiaWMiLAogIDB4ZmVkYSwKICAia2FmaGVicmV3IiwKICAweDA1ZGIsCiAgImthZmluaXRpYWxhcmFiaWMiLAogIDB4ZmVk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xZTksCiAgImtjZWRpbGxhIiwKICAweDAxMzcsCiAgImtjaXJjbGUiLAogIDB4MjRkYSwKICAia2NvbW1hYWNjZW50IiwKICAweDAxMzcsCiAgImtkb3RiZWxvdyIsCiAgMHgxZTMzLAogICJrZWhhcm1lbmlhbiIsCiAgMHgwNTg0LAogICJrZWhpcmFnYW5hIiwKICAweDMwNTEsCiAgImtla2F0YWthbmEiLAogIDB4MzBiMSwKICAia2VrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjc5LAogICJrZW5hcm1lbmlhbiIsCiAgMHgwNTZmLAogICJrZXNtYWxsa2F0YWthbmEiLAogIDB4MzBmNiwKICAia2dyZWVubGFuZGljIiwKICAweDAxMzgsCiAgImtoYWJlbmdhbGkiLAogIDB4MDk5NiwKICAia2hhY3lyaWxsaWMiLAogIDB4MDQ0NSwKICAia2hhZGV2YSIsCiAgMHgwOTE2LAogICJraGFndWphcmF0aSIsCiAgMHgwYTk2LAogICJraGFndXJtdWtoaSIsCiAgMHgwYTE2LAogICJraGFoYXJhYmljIiwKICAweDA2MmUsCiAgImtoYWhmaW5hbGFyYWJpYyIsCiAgMHhmZWE2LAogICJraGFoaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWE3LAogICJraGFobWVkaWFsYXJhYmljIiwKICAweGZlYTgsCiAgImtoZWljb3B0aWMiLAogIDB4MDNlNywKICAia2hoYWRldmEiLAogIDB4MDk1OSwKICAia2hoYWd1cm11a2hpIiwKICAweDBhNTksCiAgImtoaWV1a2hhY2lyY2xla29yZWFuIiwKICAweDMyNzgsCiAgImtoaWV1a2hhcGFyZW5rb3JlYW4iLAogIDB4MzIxOCwKICAia2hpZXVraGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZhLAogICJraGlldWtoa29yZWFuIiwKICAweDMxNGIsCiAgImtoaWV1a2hwYXJlbmtvcmVhbiIsCiAgMHgzMjBhLAogICJraG9raGFpdGhhaSIsCiAgMHgwZTAyLAogICJraG9raG9udGhhaSIsCiAgMHgwZTA1LAogICJraG9raHVhdHRoYWkiLAogIDB4MGUwMywKICAia2hva2h3YWl0aGFpIiwKICAweDBlMDQsCiAgImtob211dHRoYWkiLAogIDB4MGU1YiwKICAia2hvb2siLAogIDB4MDE5OSwKICAia2hvcmFraGFuZ3RoYWkiLAogIDB4MGUwNiwKICAia2h6c3F1YXJlIiwKICAweDMzOTEsCiAgImtpaGlyYWdhbmEiLAogIDB4MzA0ZCwKICAia2lrYXRha2FuYSIsCiAgMHgzMGFkLAogICJraWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzcsCiAgImtpcm9ndXJhbXVzcXVhcmUiLAogIDB4MzMxNSwKICAia2lyb21lZXRvcnVzcXVhcmUiLAogIDB4MzMxNiwKICAia2lyb3NxdWFyZSIsCiAgMHgzMzE0LAogICJraXllb2thY2lyY2xla29yZWFuIiwKICAweDMyNmUsCiAgImtpeWVva2FwYXJlbmtvcmVhbiIsCiAgMHgzMjBlLAogICJraXllb2tjaXJjbGVrb3JlYW4iLAogIDB4MzI2MCwKICAia2l5ZW9ra29yZWFuIiwKICAweDMxMzEsCiAgImtpeWVva3BhcmVua29yZWFuIiwKICAweDMyMDAsCiAgImtpeWVva3Npb3Nrb3JlYW4iLAogIDB4MzEzMywKICAia2plY3lyaWxsaWMiLAogIDB4MDQ1YywKICAia2xpbmViZWxvdyIsCiAgMHgxZTM1LAogICJrbHNxdWFyZSIsCiAgMHgzMzk4LAogICJrbWN1YmVkc3F1YXJlIiwKICAweDMzYTYsCiAgImttb25vc3BhY2UiLAogIDB4ZmY0YiwKICAia21zcXVhcmVkc3F1YXJlIiwKICAweDMzYTIsCiAgImtvaGlyYWdhbmEiLAogIDB4MzA1MywKICAia29obXNxdWFyZSIsCiAgMHgzM2MwLAogICJrb2thaXRoYWkiLAogIDB4MGUwMSwKICAia29rYXRha2FuYSIsCiAgMHgzMGIzLAogICJrb2thdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2EsCiAgImtvb3Bvc3F1YXJlIiw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AweDIyNmUsCiAgIm5vdGxlc3Nub3JlcXVhbCIsCiAgMHgyMjcwLAogICJub3RwYXJhbGxlbCIsCiAgMHgyMjI2LAogICJub3RwcmVjZWRlcyIsCiAgMHgyMjgwLAogICJub3RzdWJzZXQiLAogIDB4MjI4NCwKICAibm90c3VjY2VlZHMiLAogIDB4MjI4MSwKICAibm90c3VwZXJzZXQiLAogIDB4MjI4NSwKICAibm93YXJtZW5pYW4iLAogIDB4MDU3NiwKICAibnBhcmVuIiwKICAweDI0YTksCiAgIm5zc3F1YXJlIiwKICAweDMzYjEsCiAgIm5zdXBlcmlvciIsCiAgMHgyMDdmLAogICJudGlsZGUiLAogIDB4MDBmMSwKICAibnUiLAogIDB4MDNiZCwKICAibnVoaXJhZ2FuYSIsCiAgMHgzMDZjLAogICJudWthdGFrYW5hIiwKICAweDMwY2MsCiAgIm51a2F0YWthbmFoYWxmd2lkdGgiLAogIDB4ZmY4NywKICAibnVrdGFiZW5nYWxpIiwKICAweDA5YmMsCiAgIm51a3RhZGV2YSIsCiAgMHgwOTNjLAogICJudWt0YWd1amFyYXRpIiwKICAweDBhYmMsCiAgIm51a3RhZ3VybXVraGkiLAogIDB4MGEzYywKICAibnVtYmVyc2lnbiIsCiAgMHgwMDIzLAogICJudW1iZXJzaWdubW9ub3NwYWNlIiwKICAweGZmMDMsCiAgIm51bWJlcnNpZ25zbWFsbCIsCiAgMHhmZTVmLAogICJudW1lcmFsc2lnbmdyZWVrIiwKICAweDAzNzQsCiAgIm51bWVyYWxzaWdubG93ZXJncmVlayIsCiAgMHgwMzc1LAogICJudW1lcm8iLAogIDB4MjExNiwKICAibnVuIiwKICAweDA1ZTAsCiAgIm51bmRhZ2VzaCIsCiAgMHhmYjQwLAogICJudW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0MCwKICAibnVuaGVicmV3IiwKICAweDA1ZTAsCiAgIm52c3F1YXJlIiwKICAweDMzYjUsCiAgIm53c3F1YXJlIiwKICAweDMzYmIsCiAgIm55YW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3YiwKICAib21lZ2F0aXRsb2N5cmlsbGljIiwKICAweDA0N2QsCiAgIm9tZWdhdG9ub3MiLAogIDB4MDNjZSwKICAib21ndWphcmF0aSIsCiAgMHgwYWQwLAogICJvbWljcm9uIiwKICAweDAzYmYsCiAgIm9taWNyb250b25vcyIsCiAgMHgwM2NjLAogICJvbW9ub3NwYWNlIiwKICAweGZmNGYsCiAgIm9uZSIsCiAgMHgwMDMxLAogICJvbmVhcmFiaWMiLAogIDB4MDY2MSwKICAib25lYmVuZ2FsaSIsCiAgMHgwOWU3LAogICJvbmVjaXJjbGUiLAogIDB4MjQ2MCwKICAib25lY2lyY2xlaW52ZXJzZXNhbnNzZXJpZiIsCiAgMHgyNzhhLAogICJvbmVkZXZhIiwKICAweDA5NjcsCiAgIm9uZWRvdGVubGVhZGVyIiwKICAweDIwMjQsCiAgIm9uZWVpZ2h0aCIsCiAgMHgyMTViLAogICJvbmVmaXR0ZWQiLAogIDB4ZjZkYywKICAib25lZ3VqYXJhdGkiLAogIDB4MGFlNywKICAib25lZ3VybXVraGkiLAogIDB4MGE2NywKICAib25laGFja2FyYWJpYyIsCiAgMHgwNjYxLAogICJvbmVoYWxmIiwKICAweDAwYmQsCiAgIm9uZWhhbmd6aG91IiwKICAweDMwMjEsCiAgIm9uZWlkZW9ncmFwaGljcGFyZW4iLAogIDB4MzIyMCwKICAib25laW5mZXJpb3IiLAogIDB4MjA4MSwKICAib25lbW9ub3NwYWNlIiwKICAweGZmMTEsCiAgIm9uZW51bWVyYXRvcmJlbmdhbGkiLAogIDB4MDlmNCwKICAib25lb2xkc3R5bGUiLAogIDB4ZjczMSwKICAib25lcGFyZW4iLAogIDB4MjQ3NCwKICAib25lcGVyaW9kIiwKICAweDI0ODgsCiAgIm9uZXBlcnNpYW4iLAogIDB4MDZmMSwKICAib25lcXVhcnRlciIsCiAgMHgwMGJjLAogICJvbmVyb21hbiIsCiAgMHgyMTcwLAogICJvbmVzdXBlcmlvciIsCiAgMHgwMGI5LAogIC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3JlZWtjbWIiLAogIDB4MDM0MiwKICAicGVycGVuZGljdWxhciIsCiAgMHgyMmE1LAogICJwZXJ0aG91c2FuZCIsCiAgMHgyMDMwLAogICJwZXNldGEiLAogIDB4MjBhNywKICAicGZzcXVhcmUiLAogIDB4MzM4YSwKICAicGhhYmVuZ2FsaSIsCiAgMHgwOWFiLAogICJwaGFkZXZhIiwKICAweDA5MmIsCiAgInBoYWd1amFyYXRpIiwKICAweDBhYWIsCiAgInBoYWd1cm11a2hpIiwKICAweDBhMmIsCiAgInBoaSIsCiAgMHgwM2M2LAogICJwaGkxIiwKICAweDAzZDUsCiAgInBoaWV1cGhhY2lyY2xla29yZWFuIiwKICAweDMyN2EsCiAgInBoaWV1cGhhcGFyZW5rb3JlYW4iLAogIDB4MzIxYSwKICAicGhpZXVwaGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZjLAogICJwaGlldXBoa29yZWFuIiwKICAweDMxNGQsCiAgInBoaWV1cGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBjLAogICJwaGlsYXRpbiIsCiAgMHgwMjc4LAogICJwaGludGh1dGhhaSIsCiAgMHgwZTNhLAogICJwaGlzeW1ib2xncmVlayIsCiAgMHgwM2Q1LAogICJwaG9vayIsCiAgMHgwMWE1LAogICJwaG9waGFudGhhaSIsCiAgMHgwZTFlLAogICJwaG9waHVuZ3RoYWkiLAogIDB4MGUxYywKICAicGhvc2FtcGhhb3RoYWkiLAogIDB4MGUyMCwKICAicGkiLAogIDB4MDNjMCwKICAicGlldXBhY2lyY2xla29yZWFuIiwKICAweDMyNzMsCiAgInBpZXVwYXBhcmVua29yZWFuIiwKICAweDMyMTMsCiAgInBpZXVwY2lldWNrb3JlYW4iLAogIDB4MzE3NiwKICAicGlldXBjaXJjbGVrb3JlYW4iLAogIDB4MzI2NSwKICAicGlldXBraXllb2trb3JlYW4iLAogIDB4MzE3MiwKICAicGlldXBrb3JlYW4iLAogIDB4MzE0MiwKICAicGlldXBwYXJlbmtvcmVhb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LAogIDB4MjRhYiwKICAicHJlY2VkZXMiLAogIDB4MjI3YSwKICAicHJlc2NyaXB0aW9uIiwKICAweDIxMWUsCiAgInByaW1lbW9kIiwKICAweDAyYjksCiAgInByaW1lcmV2ZXJzZWQiLAogIDB4MjAzNSwKICAicHJvZHVjdCIsCiAgMHgyMjBmLAogICJwcm9qZWN0aXZlIiwKICAweDIzMDUsCiAgInByb2xvbmdlZGthbmEiLAogIDB4MzBmYywKICAicHJvcGVsbG9yIiwKICAweDIzMTgsCiAgInByb3BlcnN1YnNldCIsCiAgMHgyMjgyLAogICJwcm9wZXJzdXBlcnNldCIsCiAgMHgyMjgzLAogICJwcm9wb3J0aW9uIiwKICAweDIyMzcsCiAgInByb3BvcnRpb25hbCIsCiAgMHgyMjFkLAogICJwc2kiLAogIDB4MDNjOCwKICAicHNpY3lyaWxsaWMiLAogIDB4MDQ3MSwKICAicHNpbGlwbmV1bWF0YWN5cmlsbGljY21iIiwKICAweDA0ODYsCiAgInBzc3F1YXJlIiwKICAweDMzYjAsCiAgInB1aGlyYWdhbmEiLAogIDB4MzA3NywKICAicHVrYXRha2FuYSIsCiAgMHgzMGQ3LAogICJwdnNxdWFyZSIsCiAgMHgzM2I0LAogICJwd3NxdWFyZSIsCiAgMHgzM2JhLAogICJxIiwKICAweDAwNzEsCiAgInFhZGV2YSIsCiAgMHgwOTU4LAogICJxYWRtYWhlYnJldyIsCiAgMHgwNWE4LAogICJxYWZhcmFiaWMiLAogIDB4MDY0MiwKICAicWFmZmluYWxhcmFiaWMiLAogIDB4ZmVkNiwKICAicWFmaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWQ3LAogICJxYWZtZWRpYWxhcmFiaWMiLAogIDB4ZmVkOCwKICAicWFtYXRzIiwKICAweDA1YjgsCiAgInFhbWF0czEwIiwKICAweDA1YjgsCiAgInFhbWF0czFhIiwKICAweDA1YjgsCiAgInFhbWF0czFjIiwKICAweDA1YjgsCiAgInFhbWF0czI3IiwKICAweDA1YjgsCiAgInFhbWF0czI5IiwKICAweDA1YjgsCiAgInFhbWF0czMzIiwKICAweDA1YjgsCiAgInFhbWF0c2RlIiwKICAweDA1YjgsCiAgInFhbWF0c2hlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNuYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5oZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5uYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5xdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3FhdGFud2lkZWhlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNxdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3dpZGVoZWJyZXciLAogIDB4MDViOCwKICAicWFybmV5cGFyYWhlYnJldyIsCiAgMHgwNTlmLAogICJxYm9wb21vZm8iLAogIDB4MzExMSwKICAicWNpcmNsZSIsCiAgMHgyNGUwLAogICJxaG9vayIsCiAgMHgwMmEwLAogICJxbW9ub3NwYWNlIiwKICAweGZmNTEsCiAgInFvZiIsCiAgMHgwNWU3LAogICJxb2ZkYWdlc2giLAogIDB4ZmI0NywKICAicW9mZGFnZXNoaGVicmV3IiwKICAweGZiNDcsCiAgInFvZmhlYnJldyIsCiAgMHgwNWU3LAogICJxcGFyZW4iLAogIDB4MjRhYywKICAicXVhcnRlcm5vdGUiLAogIDB4MjY2OSwKICAicXVidXRzIiwKICAweDA1YmIsCiAgInF1YnV0czE4IiwKICAweDA1YmIsCiAgInF1YnV0czI1IiwKICAweDA1YmIsCiAgInF1YnV0czMxIiwKICAweDA1YmIsCiAgInF1YnV0c2hlYnJldyIsCiAgMHgwNWJiLAogICJxdWJ1dHNuYXJyb3doZWJyZXciLAogIDB4MDViYiwKICAicXVidXRzcXVhcnRlcmhlYnJldyIsCiAgMHgwNWJiLAogICJxdWJ1dHN3aWRlaGVicmV3IiwKICAweDA1YmIsCiAgInF1ZXN0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LAogIDB4MWU2OSwKICAic2VhZ3VsbGJlbG93Y21iIiwKICAweDAzM2MsCiAgInNlY29uZCIsCiAgMHgyMDMzLAogICJzZWNvbmR0b25lY2hpbmVzZSIsCiAgMHgwMmNhLAogICJzZWN0aW9uIiwKICAweDAwYTcsCiAgInNlZW5hcmFiaWMiLAogIDB4MDYzMywKICAic2VlbmZpbmFsYXJhYmljIiwKICAweGZlYjIsCiAgInNlZW5pbml0aWFsYXJhYmljIiwKICAweGZlYjMsCiAgInNlZW5tZWRpYWxhcmFiaWMiLAogIDB4ZmViNCwKICAic2Vnb2wiLAogIDB4MDViNiwKICAic2Vnb2wxMyIsCiAgMHgwNWI2LAogICJzZWdvbDFmIiwKICAweDA1YjYsCiAgInNlZ29sMmMiLAogIDB4MDViNiwKICAic2Vnb2xoZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xuYXJyb3doZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xxdWFydGVyaGVicmV3IiwKICAweDA1YjYsCiAgInNlZ29sdGFoZWJyZXciLAogIDB4MDU5MiwKICAic2Vnb2x3aWRlaGVicmV3IiwKICAweDA1YjYsCiAgInNlaGFybWVuaWFuIiwKICAweDA1N2QsCiAgInNlaGlyYWdhbmEiLAogIDB4MzA1YiwKICAic2VrYXRha2FuYSIsCiAgMHgzMGJiLAogICJzZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2UsCiAgInNlbWljb2xvbiIsCiAgMHgwMDNiLAogICJzZW1pY29sb25hcmFiaWMiLAogIDB4MDYxYiwKICAic2VtaWNvbG9ubW9ub3NwYWNlIiwKICAweGZmMWIsCiAgInNlbWljb2xvbnNtYWxsIiwKICAweGZlNTQsCiAgInNlbWl2b2ljZWRtYXJra2FuYSIsCiAgMHgzMDljLAogICJzZW1pdm9pY2VkbWFya2thbmFoYWxmd2lkdGgiLAogIDB4ZmY5ZiwKICAic2VudGlzcXVhcmUiLAogIDB4MzMyMiwKICAic2VudG9zcXVhcmUiLAogIDB4Mz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DY1MSwKICAic2hhZGRhZGFtbWFhcmFiaWMiLAogIDB4ZmM2MSwKICAic2hhZGRhZGFtbWF0YW5hcmFiaWMiLAogIDB4ZmM1ZSwKICAic2hhZGRhZmF0aGFhcmFiaWMiLAogIDB4ZmM2MCwKICAic2hhZGRha2FzcmFhcmFiaWMiLAogIDB4ZmM2MiwKICAic2hhZGRha2FzcmF0YW5hcmFiaWMiLAogIDB4ZmM1ZiwKICAic2hhZGUiLAogIDB4MjU5MiwKICAic2hhZGVkYXJrIiwKICAweDI1OTMsCiAgInNoYWRlbGlnaHQiLAogIDB4MjU5MSwKICAic2hhZGVtZWRpdW0iLAogIDB4MjU5MiwKICAic2hhZGV2YSIsCiAgMHgwOTM2LAogICJzaGFndWphcmF0aSIsCiAgMHgwYWI2LAogICJzaGFndXJtdWtoaSIsCiAgMHgwYTM2LAogICJzaGFsc2hlbGV0aGVicmV3IiwKICAweDA1OTMsCiAgInNoYm9wb21vZm8iLAogIDB4MzExNSwKICAic2hjaGFjeXJpbGxpYyIsCiAgMHgwNDQ5LAogICJzaGVlbmFyYWJpYyIsCiAgMHgwNjM0LAogICJzaGVlbmZpbmFsYXJhYmljIiwKICAweGZlYjYsCiAgInNoZWVuaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWI3LAogICJzaGVlbm1lZGlhbGFyYWJpYyIsCiAgMHhmZWI4LAogICJzaGVpY29wdGljIiwKICAweDAzZTMsCiAgInNoZXFlbCIsCiAgMHgyMGFhLAogICJzaGVxZWxoZWJyZXciLAogIDB4MjBhYSwKICAic2hldmEiLAogIDB4MDViMCwKICAic2hldmExMTUiLAogIDB4MDViMCwKICAic2hldmExNSIsCiAgMHgwNWIwLAogICJzaGV2YTIyIiwKICAweDA1YjAsCiAgInNoZXZhMmUiLAogIDB4MDViMCwKICAic2hldmFoZWJyZXciLAogIDB4MDViMCwKICAic2hldmFuYXJyb3doZWJyZXciLAogIDB4MDViMCwKICAic2hldmFxdWFydGVyaGVicmV3IiwKICAweDA1YjAsCiAgInNoZXZhd2lkZWhlYnJldyIsCiAgMHgwNWIwLAogICJzaGhhY3lyaWxsaWMiLAogIDB4MDRiYiwKICAic2hpbWFjb3B0aWMiLAogIDB4MDNlZCwKICAic2hpbiIsCiAgMHgwNWU5LAogICJzaGluZGFnZXNoIiwKICAweGZiNDksCiAgInNoaW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0OSwKICAic2hpbmRhZ2VzaHNoaW5kb3QiLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNoaW5kb3RoZWJyZXciLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNpbmRvdCIsCiAgMHhmYjJkLAogICJzaGluZGFnZXNoc2luZG90aGVicmV3IiwKICAweGZiMmQsCiAgInNoaW5kb3RoZWJyZXciLAogIDB4MDVjMSwKICAic2hpbmhlYnJldyIsCiAgMHgwNWU5LAogICJzaGluc2hpbmRvdCIsCiAgMHhmYjJhLAogICJzaGluc2hpbmRvdGhlYnJldyIsCiAgMHhmYjJhLAogICJzaGluc2luZG90IiwKICAweGZiMmIsCiAgInNoaW5zaW5kb3RoZWJyZXciLAogIDB4ZmIyYiwKICAic2hvb2siLAogIDB4MDI4MiwKICAic2lnbWEiLAogIDB4MDNjMywKICAic2lnbWExIiwKICAweDAzYzIsCiAgInNpZ21hZmluYWwiLAogIDB4MDNjMiwKICAic2lnbWFsdW5hdGVzeW1ib2xncmVlayIsCiAgMHgwM2YyLAogICJzaWhpcmFnYW5hIiwKICAweDMwNTcsCiAgInNpa2F0YWthbmEiLAogIDB4MzBiNywKICAic2lrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjdjLAogICJzaWx1cWhlYnJldyIsCiAgMHgwNWJkLAogICJzaWx1cWxlZnRoZWJyZXciLAogIDB4MDViZCwKICAic2ltaWxhciIsCiAgMHgyMjNjLAogICJzaW5kb3RoZWJyZXciLAogIDB4MDVjMiwKICAic2lvc2FjaXJjbGVrb3JlYW4iLAogIDB4MzI3NCwKICAic2lvc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ldXRoa29yZWFuIiwKICAweDMxNGMsCiAgInRoaWV1dGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBiLAogICJ0aGlydGVlbmNpcmNsZSIsCiAgMHgyNDZjLAogICJ0aGlydGVlbnBhcmVuIiwKICAweDI0ODAsCiAgInRoaXJ0ZWVucGVyaW9kIiwKICAweDI0OTQsCiAgInRob25hbmdtb250aG90aGFpIiwKICAweDBlMTEsCiAgInRob29rIiwKICAweDAxYWQsCiAgInRob3BodXRoYW90aGFpIiwKICAweDBlMTIsCiAgInRob3JuIiwKICAweDAwZmUsCiAgInRob3RoYWhhbnRoYWkiLAogIDB4MGUxNywKICAidGhvdGhhbnRoYWkiLAogIDB4MGUxMCwKICAidGhvdGhvbmd0aGFpIiwKICAweDBlMTgsCiAgInRob3RodW5ndGhhaSIsCiAgMHgwZTE2LAogICJ0aG91c2FuZGN5cmlsbGljIiwKICAweDA0ODIsCiAgInRob3VzYW5kc3NlcGFyYXRvcmFyYWJpYyIsCiAgMHgwNjZjLAogICJ0aG91c2FuZHNzZXBhcmF0b3JwZXJzaWFuIiwKICAweDA2NmMsCiAgInRocmVlIiwKICAweDAwMzMsCiAgInRocmVlYXJhYmljIiwKICAweDA2NjMsCiAgInRocmVlYmVuZ2FsaSIsCiAgMHgwOWU5LAogICJ0aHJlZWNpcmNsZSIsCiAgMHgyNDYyLAogICJ0aHJlZWNpcmNsZWludmVyc2VzYW5zc2VyaWYiLAogIDB4Mjc4YywKICAidGhyZWVkZXZhIiwKICAweDA5NjksCiAgInRocmVlZWlnaHRocyIsCiAgMHgyMTVjLAogICJ0aHJlZWd1amFyYXRpIiwKICAweDBhZTksCiAgInRocmVlZ3VybXVraGkiLAogIDB4MGE2OSwKICAidGhyZWVoYWNrYXJhYmljIiwKICAweDA2NjMsCiAgInRocmVlaGFuZ3pob3UiLAogIDB4MzAyMywKICAidGhyZWVpZGVvZ3JhcGhpY3BhcmVuIiwKICAweDMyMjIsCiAgInRocmVlaW5mZXJpb3IiLA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VfdXRpbHNfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfXy5nZXRBcnJheUxvb2t1cFRhYmxlRmFjdG9yeSkoZnVuY3Rpb24gKCkgewogcmV0dXJuIFsKICAic3BhY2UiLAogIDB4MDAyMCwKICAiYTEiLAogIDB4MjcwMSwKICAiYTIiLAogIDB4MjcwMiwKICAiYTIwMiIsCiAgMHgyNzAzLAogICJhMyIsCiAgMHgyNzA0LAogICJhNCIsCiAgMHgyNjBlLAogICJhNSIsCiAgMHgyNzA2LAogICJhMTE5IiwKICAweDI3MDcsCiAgImExMTgiLAogIDB4MjcwOCwKICAiYTExNyIsCiAgMHgyNzA5LAogICJhMTEiLAogIDB4MjYxYiwKICAiYTEyIiwKICAweDI2MWUsCiAgImExMyIsCiAgMHgyNzBjLAogICJhMTQiLAogIDB4MjcwZCwKICAiYTE1IiwKICAweDI3MGUsCiAgImExNiIsCiAgMHgyNzBmLAogICJhMTA1IiwKICAweDI3MTAsCiAgImExNyIsCiAgMHgyNzExLAogICJhMTgiLAogIDB4MjcxMiwKICAiYTE5IiwKICAweDI3MTMsCiAgImEyMCIsCiAgMHgyNzE0LAogICJhMjEiLAogIDB4MjcxNSwKICAiYTIyIiwKICAweDI3MTYsCiAgImEyMyIsCiAgMHgyNzE3LAogICJhMjQiLAogIDB4MjcxOCwKICAiYTI1IiwKICAweDI3MTksCiAgImEyNiIsCiAgMHgyNzFhLAogICJhMjciLAogIDB4MjcxYiwKICAiYTI4IiwKICAweDI3MWMsCiAgImE2IiwKICAweDI3MWQsCiAgImE3IiwKICAweDI3MWUsCiAgImE4IiwKICAweDI3MWYsCiAgImE5IiwKICAweDI3MjAsCiAgImExMCIsCiAgMHgyNzIxLAogICJhMjkiLAogIDB4MjcyMiwKICAiYTMwIiwKICAweDI3MjMsCiAgImEzMSIsCiAgMHgyNzI0LAogICJhMzIiLAogIDB4MjcyNSwKICAiYTMzIiwKICAweDI3MjYsCiAgImEzNCIsCiAgMHgyNzI3LA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AgImExNDEiLAogIDB4Mjc4MSwKICAiYTE0MiIsCiAgMHgyNzgyLAogICJhMTQzIiwKICAweDI3ODMsCiAgImExNDQiLAogIDB4Mjc4NCwKICAiYTE0NSIsCiAgMHgyNzg1LAogICJhMTQ2IiwKICAweDI3ODYsCiAgImExNDciLAogIDB4Mjc4NywKICAiYTE0OCIsCiAgMHgyNzg4LAogICJhMTQ5IiwKICAweDI3ODksCiAgImExNTAiLAogIDB4Mjc4YSwKICAiYTE1MSIsCiAgMHgyNzhiLAogICJhMTUyIiwKICAweDI3OGMsCiAgImExNTMiLAogIDB4Mjc4ZCwKICAiYTE1NCIsCiAgMHgyNzhlLAogICJhMTU1IiwKICAweDI3OGYsCiAgImExNTYiLAogIDB4Mjc5MCwKICAiYTE1NyIsCiAgMHgyNzkxLAogICJhMTU4IiwKICAweDI3OTIsCiAgImExNTkiLAogIDB4Mjc5MywKICAiYTE2MCIsCiAgMHgyNzk0LAogICJhMTYxIiwKICAweDIxOTIsCiAgImExNjMiLAogIDB4MjE5NCwKICAiYTE2NCIsCiAgMHgyMTk1LAogICJhMTk2IiwKICAweDI3OTgsCiAgImExNjUiLAogIDB4Mjc5OSwKICAiYTE5MiIsCiAgMHgyNzlhLAogICJhMTY2IiwKICAweDI3OWIsCiAgImExNjciLAogIDB4Mjc5YywKICAiYTE2OCIsCiAgMHgyNzlkLAogICJhMTY5IiwKICAweDI3OWUsCiAgImExNzAiLAogIDB4Mjc5ZiwKICAiYTE3MSIsCiAgMHgyN2EwLAogICJhMTcyIiwKICAweDI3YTEsCiAgImExNzMiLAogIDB4MjdhMiwKICAiYTE2MiIsCiAgMHgyN2EzLAogICJhMTc0IiwKICAweDI3YTQsCiAgImExNzUiLAogIDB4MjdhNSwKICAiYTE3NiIsCiAgMHgyN2E2LAogICJhMTc3IiwKICAweDI3YTcsCiAgImExNzgiLAogIDB4MjdhOCwKICAiYTE3OSIsCiAgMHgyN2E5LAogICJhMTkzIiwKICAweDI3YWEsCiAgImExODAiL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AodmFsdWUgPj0gcmFuZ2UuYmVnaW4gJiYgdmFsdWUgPCByYW5nZS5lbmQpIHsKICByZXR1cm4gdHJ1ZTsKIH0KIHJldHVybiBmYWxzZTsKfQpjb25zdCBnZXROb3JtYWxpemVkVW5pY29kZXMgPSAoMCxfY29yZV91dGlsc19qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fLmdldEFycmF5TG9va3VwVGFibGVGYWN0b3J5KShmdW5jdGlvbiAoKSB7CiByZXR1cm4gWwogICJcdTAwQTgiLAogICJcdTAwMjBcdTAzMDgiLAogICJcdTAwQUYiLAogICJcdTAwMjBcdTAzMDQiLAogICJcdTAwQjQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAwQjUiLAogICJcdTAzQkMiLAogICJcdTAwQjgiLAogICJcdTAwMjBcdTAzMjciLAogICJcdTAxMzIiLAogICJcdTAwNDlcdTAwNEEiLAogICJcdTAxMzMiLAogICJcdTAwNjlcdTAwNkEiLAogICJcdTAxM0YiLAogICJcdTAwNENcdTAwQjciLAogICJcdTAxNDAiLAogICJcdTAwNkNcdTAwQjciLAogICJcdTAxNDkiLAogICJcdTAyQkNcdTAwNkUiLAogICJcdTAxN0YiLAogICJcdTAwNzMiLAogICJcdTAxQzQiLAogICJcdTAwNDRcdTAxN0QiLAogICJcdTAxQzUiLAogICJcdTAwNDRcdTAxN0UiLAogICJcdTAxQzYiLAogICJcdTAwNjRcdTAxN0UiLAogICJcdTAxQzciLAogICJcdTAwNENcdTAwNEEiLAogICJcdTAxQzgiLAogICJcdTAwNENcdTAwNkEiLAogICJcdTAxQzkiLAogICJcdTAwNkNcdTAwNkEiLAogICJcdTAxQ0EiLAogICJcdTAwNEVcdTAwNEEiLAogICJcdTAxQ0IiLAogICJcdTAwNEVcdTAwNkEiLAogICJcdTAxQ0MiLAogICJcdTAwNkVcdTAwNkEiLAogICJcdTAxRjEiLAogICJcdTAwNDRcdTAwNUEiLAogICJcdTAxRjIiLAogICJcdTAwNDRcdTAwN0EiLAogICJcdTAxRjMiLAogICJcdTAwNjRcdTAwN0EiLAogICJcdTAyRDgiLAogICJcdTAwMjBcdTAzMDYiLAogICJcdTAyRDkiLAogICJcdTAwMjBcdTAzMDciLAogICJcdTAyREEiLAogICJcdTAwMjBcdTAzMEEiLAogICJcdTAyREIiLAogICJcdTAwMjBcdTAzMjgiLAogICJcdTAyREMiLAogICJcdTAwMjBcdTAzMDMiLAogICJcdTAyREQiLAogICJcdTAwMjBcdTAzMEIiLAogICJcdTAzN0EiLAogICJcdTAwMjBcdTAzNDUiLAogICJcdTAzODQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAzRDAiLAogICJcdTAzQjIiLAogICJcdTAzRDEiLAogICJcdTAzQjgiLAogICJcdTAzRDIiLAogICJcdTAzQTUiLAogICJcdTAzRDUiLAogICJcdTAzQzYiLAogICJcdTAzRDYiLAogICJcdTAzQzAiLAogICJcdTAzRjAiLAogICJcdTAzQkEiLAogICJcdTAzRjEiLAogICJcdTAzQzEiLAogICJcdTAzRjIiLAogICJcdTAzQzIiLAogICJcdTAzRjQiLAogICJcdTAzOTgiLAogICJcdTAzRjUiLAogICJcdTAzQjUiLAogICJcdTAzRjkiLAogICJcdTAzQTMiLAogICJcdTA1ODciLAogICJcdTA1NjVcdTA1ODIiLAogICJcdTA2NzUiLAogICJcdTA2MjdcdTA2NzQiLAogICJcdTA2NzYiLAogICJcdTA2NDhcdTA2NzQiLAogICJcdTA2NzciLAogICJcdTA2QzdcdTA2NzQiLAogICJcdTA2NzgiLAogICJcdTA2NEFcdTA2NzQiLAogICJcdTBFMzMiLAogICJcdTBFNERcdTBFMzIiLAogICJcdTBFQjMiLAogICJcdTBFQ0RcdTBFQjIiLAogICJcdTBFREMiLAogICJcdTBFQUJcdTBFOTkiLAogICJcdTBFREQiLAogICJcdTBFQUJcdTBFQTEiLAogICJcdTBGNzciLAogICJcdTBGQjJcdTBGODEiLAogICJcdTBGNzkiLAogICJcdTBGQjNcdTBGODEiLAogICJcdTFFOUEiLAogICJcdTAwNjFcdTAyQkUiLAogICJcdTFGQkQiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQkYiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQzAiLAogICJcdTAwMjBcdTAzNDIiLAogICJcdTFGRkUiLAogICJcdTAwMjBcdTAzMTQiLAogICJcdTIwMDIiLAogICJcdTAwMjAiLAogICJcdTIwMDMiLAogICJcdTAwMjAiLAogICJcdTIwMDQiLAogICJcdTAwMjAiLAogICJcdTIwMDUiLAogICJcdTAwMjAiLAogICJcdTIwMDYiLAogICJcdTAwMjAiLAogICJcdTIwMDgiLAogICJcdTAwMjAiLAogICJcdTIwMDkiLAogICJcdTAwMjAiLAogICJcdTIwMEEiLAogICJcdTAwMjAiLAogICJcdTIwMTciLAogICJcdTAwMjBcdTAzMzMiLAogICJcdTIwMjQiLAogICJcdTAwMkUiLAogICJcdTIwMjUiLAogICJcdTAwMkVcdTAwMkUiLAogICJcdTIwMjYiLAogICJcdTAwMkVcdTAwMkVcdTAwMkUiLAogICJcdTIwMzMiLAogICJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzQiLAogICJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzYiLAogICJcdTIwMzVcdTIwMzUiLAogICJcdTIwMzciLAogICJcdTIwMzVcdTIwMzVcdTIwMzUiLAogICJcdTIwM0MiLAogICJcdTAwMjFcdTAwMjEiLAogICJcdTIwM0UiLAogICJcdTAwMjBcdTAzMDUiLAogICJcdTIwNDciLAogICJcdTAwM0ZcdTAwM0YiLAogICJcdTIwNDgiLAogICJcdTAwM0ZcdTAwMjEiLAogICJcdTIwNDkiLAogICJcdTAwMjFcdTAwM0YiLAogICJcdTIwNTciLAogICJcdTIwMzJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwNUYiLAogICJcdTAwMjAiLAogICJcdTIwQTgiLAogICJcdTAwNTJcdTAwNzMiLAogICJcdTIxMDAiLAogICJcdTAwNjFcdTAwMkZcdTAwNjMiLAogICJcdTIxMDEiLAogICJcdTAwNjFcdTAwMkZcdTAwNzMiLAogICJcdTIxMDMiLAogICJcdTAwQjBcdTAwNDMiLAogICJcdTIxMDUiLAogICJcdTAwNjNcdTAwMkZcdTAwNkYiLAogICJcdTIxMDYiLAogICJcdTAwNjNcdTAwMkZcdTAwNzUiLAogICJcdTIxMDciLAogICJcdTAxOTAiLAogICJcdTIxMDkiLAogICJcdTAwQjBcdTAwNDYiLAogICJcdTIxMTYiLAogICJcdTAwNEVcdTAwNkYiLAogICJcdTIxMjEiLAogICJcdTAwNTRcdTAwNDVcdTAwNEMiLAogICJcdTIxMzUiLAogICJcdTA1RDAiLAogICJcdTIxMzYiLAogICJcdTA1RDEiLAogICJcdTIxMzciLAogICJcdTA1RDIiLAogICJcdTIxMzgiLAogICJcdTA1RDMiLAogICJcdTIxM0IiLAogICJcdTAwNDZcdTAwNDFcdTAwNTgiLAogICJcdTIxNjAiLAogICJcdTAwNDkiLAogICJcdTIxNjEiLAogICJcdTAwNDlcdTAwNDkiLAogICJcdTIxNjIiLAogICJcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjMiLAogICJcdTAwNDlcdTAwNTYiLAogICJcdTIxNjQiLAogICJcdTAwNTYiLAogICJcdTIxNjUiLAogICJcdTAwNTZcdTAwNDkiLAogICJcdTIxNjYiLAogICJcdTAwNTZcdTAwNDlcdTAwNDkiLAogICJcdTIxNjciLAogICJcdTAwNTZcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjgiLAogICJcdTAwNDlcdTAwNTgiLAogICJcdTIxNjkiLAogICJcdTAwNTgiLAogICJcdTIxNkEiLAogICJcdTAwNThcdTAwNDkiLAogICJcdTIxNkIiLAogICJcdTAwNThcdTAwNDlcdTAwNDkiLAogICJcdTIxNkMiLAogICJcdTAwNEMiLAogICJcdTIxNkQiLAogICJcdTAwNDMiLAogICJcdTIxNkUiLAogICJcdTAwNDQiLAogICJcdTIxNkYiLAogICJcdTAwNEQiLAogICJcdTIxNzAiLAogICJcdTAwNjkiLAogICJcdTIxNzEiLAogICJcdTAwNjlcdTAwNjkiLAogICJcdTIxNzIiLAogICJcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzMiLAogICJcdTAwNjlcdTAwNzYiLAogICJcdTIxNzQiLAogICJcdTAwNzYiLAogICJcdTIxNzUiLAogICJcdTAwNzZcdTAwNjkiLAogICJcdTIxNzYiLAogICJcdTAwNzZcdTAwNjlcdTAwNjkiLAogICJcdTIxNzciLAogICJcdTAwNzZcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzgiLAogICJcdTAwNjlcdTAwNzgiLAogICJcdTIxNzkiLAogICJcdTAwNzgiLAogICJcdTIxN0EiLAogICJcdTAwNzhcdTAwNjkiLAogICJcdTIxN0IiLAogICJcdTAwNzhcdTAwNjlcdTAwNjkiLAogICJcdTIxN0MiLAogICJcdTAwNkMiLAogICJcdTIxN0QiLAogICJcdTAwNjMiLAogICJcdTIxN0UiLAogICJcdTAwNjQiLAogICJcdTIxN0YiLAogICJcdTAwNkQiLAogICJcdTIyMkMiLAogICJcdTIyMkJcdTIyMkIiLAogICJcdTIyMkQiLAogICJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTIyMkYiLAogICJcdTIyMkVcdTIyMkUiLAogICJcdTIyMzAiLAogICJcdTIyMkVcdTIyMkVcdTIyMkUiLAogICJcdTI0NzQiLAogICJcdTAwMjhcdTAwMzFcdTAwMjkiLAogICJcdTI0NzUiLAogICJcdTAwMjhcdTAwMzJcdTAwMjkiLAogICJcdTI0NzYiLAogICJcdTAwMjhcdTAwMzNcdTAwMjkiLAogICJcdTI0NzciLAogICJcdTAwMjhcdTAwMzRcdTAwMjkiLAogICJcdTI0NzgiLAogICJcdTAwMjhcdTAwMzVcdTAwMjkiLAogICJcdTI0NzkiLAogICJcdTAwMjhcdTAwMzZcdTAwMjkiLAogICJcdTI0N0EiLAogICJcdT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kRcdTAwMjkiLAogICJcdTI0QTkiLAogICJcdTAwMjhcdTAwNkVcdTAwMjkiLAogICJcdTI0QUEiLAogICJcdTAwMjhcdTAwNkZcdTAwMjkiLAogICJcdTI0QUIiLAogICJcdTAwMjhcdTAwNzBcdTAwMjkiLAogICJcdTI0QUMiLAogICJcdTAwMjhcdTAwNzFcdTAwMjkiLAogICJcdTI0QUQiLAogICJcdTAwMjhcdTAwNzJcdTAwMjkiLAogICJcdTI0QUUiLAogICJcdTAwMjhcdTAwNzNcdTAwMjkiLAogICJcdTI0QUYiLAogICJcdTAwMjhcdTAwNzRcdTAwMjkiLAogICJcdTI0QjAiLAogICJcdTAwMjhcdTAwNzVcdTAwMjkiLAogICJcdTI0QjEiLAogICJcdTAwMjhcdTAwNzZcdTAwMjkiLAogICJcdTI0QjIiLAogICJcdTAwMjhcdTAwNzdcdTAwMjkiLAogICJcdTI0QjMiLAogICJcdTAwMjhcdTAwNzhcdTAwMjkiLAogICJcdTI0QjQiLAogICJcdTAwMjhcdTAwNzlcdTAwMjkiLAogICJcdTI0QjUiLAogICJcdTAwMjhcdTAwN0FcdTAwMjkiLAogICJcdTJBMEMiLAogICJcdTIyMkJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTJBNzQiLAogICJcdTAwM0FcdTAwM0FcdTAwM0QiLAogICJcdTJBNzUiLAogICJcdTAwM0RcdTAwM0QiLAogICJcdTJBNzYiLAogICJcdTAwM0RcdTAwM0RcdTAwM0QiLAogICJcdTJFOUYiLAogICJcdTZCQ0QiLAogICJcdTJFRjMiLAogICJcdTlGOUYiLAogICJcdTJGMDAiLAogICJcdTRFMDAiLAogICJcdTJGMDEiLAogICJcdTRFMjgiLAogICJcdTJGMDIiLAogICJcdTRFMzYiLAogICJcdTJGMDMiLAogICJcdTRFM0YiLAogICJcdTJGMDQiLAogICJcdTRFNTkiLAogICJcdTJGMDUiLAogICJcdTRFODUiLAogICJcdTJGMDYiLAogICJcdTRFOEMiLAogICJcdTJGMDciLAogICJcdTRFQTAiLAogICJcdTJGMDgiLAogICJcdTRFQkEiLAogICJcdTJGMDkiLAogICJcdTUxM0YiLAogICJcdTJGMEEiLAogICJcdTUxNjUiLAogICJcdTJGMEIiLAogICJcdTUxNkIiLAogICJcdTJGMEMiLAogICJcdTUxODIiLAogICJcdTJGMEQiLAogICJcdTUxOTYiLAogICJcdTJGMEUiLAogICJcdTUxQUIiLAogICJcdTJGMEYiLAogICJcdTUxRTAiLAogICJcdTJGMTAiLAogICJcdTUxRjUiLAogICJcdTJGMTEiLAogICJcdTUyMDAiLAogICJcdTJGMTIiLAogICJcdTUyOUIiLAogICJcdTJGMTMiLAogICJcdTUyRjkiLAogICJcdTJGMTQiLAogICJcdTUzMTUiLAogICJcdTJGMTUiLAogICJcdTUzMUEiLAogICJcdTJGMTYiLAogICJcdTUzMzgiLAogICJcdTJGMTciLAogICJcdTUzNDEiLAogICJcdTJGMTgiLAogICJcdTUzNUMiLAogICJcdTJGMTkiLAogICJcdTUzNjkiLAogICJcdTJGMUEiLAogICJcdTUzODIiLAogICJcdTJGMUIiLAogICJcdTUzQjYiLAogICJcdTJGMUMiLAogICJcdTUzQzgiLAogICJcdTJGMUQiLAogICJcdTUzRTMiLAogICJcdTJGMUUiLAogICJcdTU2RDciLAogICJcdTJGMUYiLAogICJcdTU3MUYiLAogICJcdTJGMjAiLAogICJcdTU4RUIiLAogICJcdTJGMjEiLAogICJcdTU5MDIiLAogICJcdTJGMjIiLAogICJcdTU5MEEiLAogICJcdTJGMjMiLAogICJcdTU5MTUiLAogICJcdTJGMjQiLAogICJcdTU5MjciLAogICJcdTJGMjUiLAogICJcdTU5NzMiLAogICJcdTJGMjYiLAogICJcdTVCNTAiLAogICJcdTJGMjciLAogICJcdTVCODAiLAogICJcdTJGMjgiLAogICJcdTVCRjgiLAogICJcdTJGMjkiLAogICJcdTVDMEYiLAogICJcdTJGMkEiLAogICJcdTVDMjIiLAogICJcdTJGMkIiLAogICJcdTVDMzgiLAogICJcdTJGMkMiLAogICJcdTVDNkUiLAogICJcdTJGMkQiLAogICJcdTVDNzEiLAogICJcdTJGMkUiLAogICJcdTVEREIiLAogICJcdTJGMkYiLAogICJcdTVERTUiLAogICJcdTJGMzAiLAogICJcdTVERjEiLAogICJcdTJGMzEiLAogICJcdTVERkUiLAogICJcdTJGMzIiLAogICJcdTVFNzIiLAogICJcdTJGMzMiLAogICJcdTVFN0EiLAogICJcdTJGMzQiLAogICJcdTVFN0YiLAogICJcdTJGMzUiLAogICJcdTVFRjQiLAogICJcdTJGMzYiLAogICJcdTVFRkUiLAogICJcdTJGMzciLAogICJcdTVGMEIiLAogICJcdTJGMzgiLAogICJcdTVGMTMiLAogICJcdTJGMzkiLAogICJcdTVGNTAiLAogICJcdTJGM0EiLAogICJcdTVGNjEiLAogICJcdTJGM0IiLAogICJcdTVGNzMiLAogICJcdTJGM0MiLAogICJcdTVGQzMiLAogICJcdTJGM0QiLAogICJcdTYyMDgiLAogICJcdTJGM0UiLAogICJcdTYyMzYiLAogICJcdTJGM0YiLAogICJcdTYyNEIiLAogICJcdTJGNDAiLAogICJcdTY1MkYiLAogICJcdTJGNDEiLAogICJcdTY1MzQiLAogICJcdTJGNDIiLAogICJcdTY1ODciLAogICJcdTJGNDMiLAogICJcdTY1OTciLAogICJcdTJGNDQiLAogICJcdTY1QTQiLAogICJcdTJGNDUiLAogICJcdTY1QjkiLAogICJcdTJGNDYiLAogICJcdTY1RTAiLAogICJcdTJGNDciLAogICJcdTY1RTUiLAogICJcdTJGNDgiLAogICJcdTY2RjAiLAogICJcdTJGNDkiLAogICJcdTY3MDgiLAogICJcdTJGNEEiLAogICJcdTY3MjgiLAogICJcdTJGNEIiLAogICJcdTZCMjAiLAogICJcdTJGNEMiLAogICJcdTZCNjIiLAogICJcdTJGNEQiLAogICJcdTZCNzkiLAogICJcdTJGNEUiLAogICJcdTZCQjMiLAogICJcdTJGNEYiLAogICJcdTZCQ0IiLAogICJcdTJGNTAiLAogICJcdTZCRDQiLAogICJcdTJGNTEiLAogICJcdTZCREIiLAogICJcdTJGNTIiLAogICJcdTZDMEYiLAogICJcdTJGNTMiLAogICJcdTZDMTQiLAogICJcdTJGNTQiLAogICJcdTZDMzQiLAogICJcdTJGNTUiLAogICJcdTcwNkIiLAogICJcdTJGNTYiLAogICJcdTcyMkEiLAogICJcdTJGNTciLAogICJcdTcyMzYiLAogICJcdTJGNTgiLAogICJcdTcyM0IiLAogICJcdTJGNTkiLAogICJcdTcyM0YiLAogICJcdTJGNUEiLAogICJcdTcyNDciLAogICJcdTJGNUIiLAogICJcdTcyNTkiLAogICJcdTJGNUMiLAogICJcdTcyNUIiLAogICJcdTJGNUQiLAogICJcdTcyQUMiLAogICJcdTJGNUUiLAogICJcdTczODQiLAogICJcdTJGNUYiLAogICJcdTczODkiLAogICJcdTJGNjAiLAogICJcdTc0REMiLAogICJcdTJGNjEiLAogICJcdTc0RTYiLAogICJcdTJGNjIiLAogICJcdTc1MTgiLAogICJcdTJGNjMiLAogICJcdTc1MUYiLAogICJcdTJGNjQiLAogICJcdTc1MjgiLAogICJcdTJGNjUiLAogICJcdTc1MzAiLAogICJcdTJGNjYiLAogICJcdTc1OEIiLAogICJcdTJGNjciLAogICJcdTc1OTIiLAogICJcdTJGNjgiLAogICJcdTc2NzYiLAogICJcdTJGNjkiLAogICJcdTc2N0QiLAogICJcdTJGNkEiLAogICJcdTc2QUUiLAogICJcdTJGNkIiLAogICJcdTc2QkYiLAogICJcdTJGNkMiLAogICJcdTc2RUUiLAogICJcdTJGNkQiLAogICJcdTc3REIiLAogICJcdTJGNkUiLAogICJcdTc3RTIiLAogICJcdTJGNkYiLAogICJcdTc3RjMiLAogICJcdTJGNzAiLAogICJcdTc5M0EiLAogICJcdTJGNzEiLAogICJcdTc5QjgiLAogICJcdTJGNzIiLAogICJcdTc5QkUiLAogICJcdTJGNzMiLAogICJcdTdBNzQiLAogICJcdTJGNzQiLAogICJcdTdBQ0IiLAogICJcdTJGNzUiLAogICJcdTdBRjkiLAogICJcdTJGNzYiLAogICJcdTdDNzMiLAogICJcdTJGNzciLAogICJcdTdDRjgiLAogICJcdTJGNzgiLAogICJcdTdGMzYiLAogICJcdTJGNzkiLAogICJcdTdGNTEiLAogICJcdTJGN0EiLAogICJcdTdGOEEiLAogICJcdTJGN0IiLAogICJcdTdGQkQiLAogICJcdTJGN0MiLAogICJcdTgwMDEiLAogICJcdTJGN0QiLAogICJcdTgwMEMiLAogICJcdTJGN0UiLAogICJcdTgwMTIiLAogICJcdTJGN0YiLAogICJcdTgwMzMiLAogICJcdTJGODAiLAogICJcdTgwN0YiLAogICJcdTJGODEiLAogICJcdTgwODkiLAogICJcdTJGODIiLAogICJcdTgxRTMiLAogICJcdTJGODMiLAogICJcdTgxRUEiLAogICJcdTJGODQiLAogICJcdTgxRjMiLAogICJcdTJGODUiLAogICJcdTgxRkMiLAogICJcdTJGODYiLAogICJcdTgyMEMiLAogICJcdTJGODciLAogICJcdTgyMUIiLAogICJcdTJGODgiLAogICJcdTgyMUYiLAogICJcdTJGODkiLAogICJcdTgyNkUiLAogICJcdTJGOEEiLAogICJcdTgyNzIiLAogICJcdTJGOEIiLAogICJcdTgyNzgiLAogICJcdTJGOEMiLAogICJcdTg2NEQiLAogICJcdTJGOEQiLAogICJcdTg2NkIiLAogICJcdTJGOEUiLAogICJcdTg4NDAiLAogICJcdTJGOEYiLAogICJcdTg4NEMiLAogICJcdTJGOTAiLAogICJcdTg4NjMiLAogICJcdTJGOTEiLAogICJcdTg5N0UiLAogICJcdTJGOTIiLAogICJcdTg5OEIiLAogICJcdTJGOTMiLAogICJcdTg5RDIiLAogICJcdTJGOTQiLAogICJcdThBMDAiLAogICJcdTJGOTUiLAogICJcdThDMzciLAogICJcdTJGOTYiLAogICJcdThDNDYiLAogICJcdTJGOTciLAogICJcdThDNTUiLAogICJcdTJGOTgiLAogICJcdThDNzgiLAogICJcdTJGOTkiLAogICJcdThDOUQiLAogICJcdTJGOUEiLAogICJcdThENjQiLAogICJcdTJGOUIiLAogICJcdThENzAiLAogICJcdTJGOUMiLAogICJcdThEQjMiLAogICJcdTJGOUQiLAogICJcdThFQUIiLAogICJcdTJGOUUiLAogICJcdThFQ0EiLAogICJcdTJGOUYiLAogICJcdThGOUIiLAogICJcdTJGQTAiLAogICJcdThGQjAiLAogICJcdTJGQTEiLAogICJcdThGQjUiLAogICJcdTJGQTIiLAogICJcdTkwOTEiLAogICJcdTJGQTMiLAogICJcdTkxNDkiLAogICJcdTJGQTQiLAogICJcdTkxQzYiLAogICJcdTJGQTUiLAogICJcdTkxQ0MiLAogICJcdTJGQTYiLAogICJcdTkxRDEiLAogICJcdTJGQTciLAogICJcdTk1NzciLAogICJcdTJGQTgiLAogICJcdTk1ODAiLAogICJcdTJGQTkiLAogICJcdTk2MUMiLAogICJcdTJGQUEiLAogICJcdTk2QjYiLAogICJcdTJGQUIiLAogICJcdTk2QjkiLAogICJcdTJGQUMiLAogICJcdTk2RTgiLAogICJcdTJGQUQiLAogICJcdTk3NTEiLAogICJcdTJGQUUiLAogICJcdTk3NUUiLAogICJcdTJGQUYiLAogICJcdTk3NjIiLAogICJcdTJGQjAiLAogICJcdTk3NjkiLAogICJcdTJGQjEiLAogICJcdTk3Q0IiLAogICJcdTJGQjIiLAogICJcdTk3RUQiLAogICJcdTJGQjMiLAogICJcdTk3RjMiLAogICJcdTJGQjQiLAogICJcdTk4MDEiLAogICJcdTJGQjUiLAogICJcdTk4QTgiLAogICJcdTJGQjYiLAogICJcdTk4REIiLAogICJcdTJGQjciLAogICJcdTk4REYiLAogICJcdTJGQjgiLAogICJcdTk5OTYiLAogICJcdTJGQjkiLAogICJcdTk5OTkiLAogICJcdTJGQkEiLAogICJcdTk5QUMiLAogICJcdTJGQkIiLAogICJcdTlBQTgiLAogICJcdTJGQkMiLAogICJcdTlBRDgiLAogICJcdTJGQkQiLAogICJcdTlBREYiLAogICJcdTJGQkUiLAogICJcdTlCMjUiLAogICJcdTJGQkYiLAogICJcdTlCMkYiLAogICJcdTJGQzAiLAogICJcdTlCMzIiLAogICJcdTJGQzEiLAogICJcdTlCM0MiLAogICJcdTJGQzIiLAogICJcdTlCNUEiLAogICJcdTJGQzMiLAogICJcdTlDRTUiLAogICJcdTJGQzQiLAogICJcdTlFNzUiLAogICJcdTJGQzUiLAogICJcdTlFN0YiLAogICJcdTJGQzYiLAogICJcdTlFQTUiLAogICJcdTJGQzciLAogICJcdTlFQkIiLAogICJcdTJGQzgiLAogICJcdTlFQzMiLAogICJcdTJGQzkiLAogICJcdTlFQ0QiLAogICJcdTJGQ0EiLAogICJcdTlFRDEiLAogICJcdTJGQ0IiLAogICJcdTlFRjkiLAogICJcdTJGQ0MiLAogICJcdTlFRkQiLAogICJcdTJGQ0QiLAogICJcdTlGMEUiLAogICJcdTJGQ0UiLAogICJcdTlGMTMiLAogICJcdTJGQ0YiLAogICJcdTlGMjAiLAogICJcdTJGRDAiLAogICJcdTlGM0IiLAogICJcdTJGRDEiLAogICJcdTlGNEEiLAogICJcdTJGRDIiLAogICJcdTlGNTIiLAogICJcdTJGRDMiLAogICJcdTlGOEQiLAogICJcdTJGRDQiLAogICJcdTlGOUMiLAogICJcdTJGRDUiLAogICJcdTlGQTAiLAogICJcdTMwMzYiLAogICJcdTMwMTIiLAogICJcdTMwMzgiLAogICJcdTUzNDEiLAogICJcdTMwMzkiLAogICJcdTUzNDQiLAogICJcdTMwM0EiLAogICJcdTUzNDUiLAogICJcdTMwOUIiLAogICJcdTAwMjBcdTMwOTkiLAogICJcdTMwOUMiLAogICJcdTAwMjBcdTMwOUEiLAogICJcdTMxMzEiLAogICJcdTExMDAiLAogICJcdTMxMzIiLAogICJcdTExMDEiLAogICJcdTMxMzMiLAogICJcdTExQUEiLAogICJcdTMxMzQiLAogICJcdTExMDIiLAogICJcdTMxMzUiLAogICJcdTExQUMiLAogICJcdTMxMzYiLAogICJcdTExQUQiLAogICJcdTMxMzciLAogICJcdTExMDMiLAogICJcdTMxMzgiLAogICJcdTExMDQiLAogICJcdTMxMzkiLAogICJcdTExMDUiLAogICJcdTMxM0EiLAogICJcdTExQjAiLAogICJcdTMxM0IiLAogICJcdTExQjEiLAogICJcdTMxM0MiLAogICJcdTExQjIiLAogICJcdTMxM0QiLAogICJcdTExQjMiLAogICJcdTMxM0UiLAogICJcdTExQjQiLAogICJcdTMxM0YiLAogICJcdTExQjUiLAogICJcdTMxNDAiLAogICJcdTExMUEiLAogICJcdTMxNDEiLAogICJcdTExMDYiLAogICJcdTMxNDIiLAogICJcdTExMDciLAogICJcdTMxNDMiLAogICJcdTExMDgiLAogICJcdTMxNDQiLAogICJcdTExMjEiLAogICJcdTMxNDUiLAogICJcdTExMDkiLAogICJcdTMxNDYiLAogICJcdTExMEEiLAogICJcdTMxNDciLAogICJcdTExMEIiLAogICJcdTMxNDgiLAogICJcdTExMEMiLAogICJcdTMxNDkiLAogICJcdTExMEQiLAogICJcdTMxNEEiLAogICJcdTExMEUiLAogICJcdTMxNEIiLAogICJcdTExMEYiLAogICJcdTMxNEMiLAogICJcdTExMTAiLAogICJcdTMxNEQiLAogICJcdTExMTEiLAogICJcdTMxNEUiLAogICJcdTExMTIiLAogICJcdTMxNEYiLAogICJcdTExNjEiLAogICJcdTMxNTAiLAogICJcdTExNjIiLAogICJcdTMxNTEiLAogICJcdTExNjMiLAogICJcdTMxNTIiLAogICJcdTExNjQiLAogICJcdTMxNTMiLAogICJcdTExNjUiLAogICJcdTMxNTQiLAogICJcdTExNjYiLAogICJcdTMxNTUiLAogICJcdTExNjciLAogICJcdTMxNTYiLAogICJcdTExNjgiLAogICJcdTMxNTciLAogICJcdTExNjkiLAogICJcdTMxNTgiLAogICJcdTExNkEiLAogICJcdTMxNTkiLAogICJcdTExNkIiLAogICJcdTMxNUEiLAogICJcdTExNkMiLAogICJcdTMxNUIiLAogICJcdTExNkQiLAogICJcdTMxNUMiLAogICJcdTExNkUiLAogICJcdTMxNUQiLAogICJcdTExNkYiLAogICJcdTMxNUUiLAogICJcdTExNzAiLAogICJcdTMxNUYiLAogICJcdTExNzEiLAogICJcdTMxNjAiLAogICJcdTExNzIiLAogICJcdTMxNjEiLAogICJcdTExNzMiLAogICJcdTMxNjIiLAogICJcdTExNzQiLAogICJcdTMxNjMiLAogICJcdTExNzUiLAogICJcdTMxNjQiLAogICJcdTExNjAiLAogICJcdTMxNjUiLAogICJcdTExMTQiLAogICJcdTMxNjYiLAogICJcdTExMTUiLAogICJcdTMxNjciLAogICJcdTExQzciLAogICJcdTMxNjgiLAogICJcdTExQzgiLAogICJcdTMxNjkiLAogICJcdTExQ0MiLAogICJcdTMxNkEiLAogICJcdTExQ0UiLAogICJcdTMxNkIiLAogICJcdTExRDMiLAogICJcdTMxNkMiLAogICJcdTExRDciLAogICJcdTMxNkQiLAogICJcdTExRDkiLAogICJcdTMxNkUiLAogICJcdTExMUMiLAogICJcdTMxNkYiLAogICJcdTExREQiLAogICJcdTMxNzAiLAogICJcdTExREYiLAogICJcdTMxNzEiLAogICJcdTExMUQiLAogICJcdTMxNzIiLAogICJcdTExMUUiLAogICJcdTMxNzMiLAogICJcdTExMjAiLAogICJcdTMxNzQiLAogICJcdTExMjIiLAogICJcdTMxNzUiLAogICJcdTExMjMiLAogICJcdTMxNzYiLAogICJcdTExMjciLAogICJcdTMxNzciLAogICJcdTExMjkiLAogICJcdTMxNzgiLAogICJcdTExMkIiLAogICJcdTMxNzkiLAogICJcdTExMkMiLAogICJcdTMxN0EiLAogICJcdTExMkQiLAogICJcdTMxN0IiLAogICJcdTExMkUiLAogICJcdTMxN0MiLAogICJcdTExMkYiLAogICJcdTMxN0QiLAogICJcdTExMzIiLAogICJcdTMxN0UiLAogICJcdTExMzYiLAogICJcdTMxN0YiLAogICJcdTExNDAiLAogICJcdTMxODAiLAogICJcdTExNDciLAogICJcdTMxODEiLAogICJcdTExNEMiLAogICJcdTMxODIiLAogICJcdTExRjEiLAogICJcdTMxODMiLAogICJcdTExRjIiLAogICJcdTMxODQiLAogICJcdTExNTciLAogICJcdTMxODUiLAogICJcdTExNTgiLAogICJcdTMxODYiLAogICJcdTExNTkiLAogICJcdTMxODciLAogICJcdTExODQiLAogICJcdTMxODgiLAogICJcdTExODUiLAogICJcdTMxODkiLAogICJcdTExODgiLAogICJcdTMxOEEiLAogICJcdTExOTEiLAogICJcdTMxOEIiLAogICJcdTExOTIiLAogICJcdTMxOEMiLAogICJcdTExOTQiLAogICJcdTMxOEQiLAogICJcdTExOUUiLAogICJcdTMxOEUiLAogICJcdTExQTEiLAogICJcdTMyMDAiLAogICJcdTAwMjhcdTExMDBcdTAwMjkiLAogICJcdTMyMDEiLAogICJcdTAwMjhcdTExMDJcdTAwMjkiLAogICJcdTMyMDIiLAogICJcdTAwMjhcdTExMDNcdTAwMjkiLAogICJcdTMyMDMiLAogICJcdTAwMjhcdTExMDVcdTAwMjkiLAogICJcdTMyMDQiLAogICJcdTAwMjhcdTExMDZcdTAwMjkiLAogICJcdTMyMDUiLAogICJcdTAwMjhcdTExMDdcdTAwMjkiLAogICJcdTMyMDYiLAogICJcdTAwMjhcdTExMDlcdTAwMjkiLAogICJcdTMyMDciLAogICJcdTAwMjhcdTExMEJcdTAwMjkiLAogICJcdTMyMDgiLAogICJcdTAwMjhcdTExMENcdTAwMjkiLAogICJcdTMyMDkiLAogICJcdTAwMjhcdTExMEVcdTAwMjkiLAogICJcdTMyMEEiLAogICJcdTAwMjhcdTExMEZcdTAwMjkiLAogICJcdTMyMEIiLAogICJcdTAwMjhcdTExMTBcdTAwMjkiLAogICJcdTMyMEMiLAogICJcdTAwMjhcdTExMTFcdTAwMjkiLAogICJcdTMyMEQiLAogICJcdTAwMjhcdTExMTJcdTAwMjkiLAogICJcdTMyMEUiLAogICJcdTAwMjhcdTExMDBcdTExNjFcdTAwMjkiLAogICJcdTMyMEYiLAogICJcdTAwMjhcdTExMDJcdTExNjFcdTAwMjkiLAogICJcdTMyMTAiLAogICJcdTAwMjhcdTExMDNcdTExNjFcdTAwMjkiLAogICJcdTMyMTEiLAogICJcdTAwMjhcdTExMDVcdTExNjFcdTAwMjkiLAogICJcdTMyMTIiLAogICJcdTAwMjhcdTExMDZcdTExNjFcdTAwMjkiLAogICJcdTMyMTMiLAogICJcdTAwMjhcdTExMDdcdTExNjFcdTAwMjkiLAogICJcdTMyMTQiLAogICJcdTAwMjhcdTExMDlcdTExNjFcdTAwMjkiLAogICJcdTMyMTUiLAogICJcdTAwMjhcdTExMEJcdTExNjFcdTAwMjkiLAogICJcdTMyMTYiLAogICJcdTAwMjhcdTExMENcdTExNjFcdTAwMjkiLAogICJcdTMyMTciLAogICJcdTAwMjhcdTExMEVcdTExNjFcdTAwMjkiLAogICJcdTMyMTgiLAogICJcdTAwMjhcdTExMEZcdTExNjFcdTAwMjkiLAogICJcdTMyMTkiLAogICJcdTAwMjhcdTExMTBcdTExNjFcdTAwMjkiLAogICJcdTMyMUEiLAogICJcdTAwMjhcdTExMTFcdTExNjFcdTAwMjkiLAogICJcdTMyMUIiLAogICJcdTAwMjhcdTExMTJcdTExNjFcdTAwMjkiLAogICJcdTMyMUMiLAogICJcdTAwMjhcdTExMENcdTExNkVcdTAwMjkiLAogICJcdTMyMUQiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMENcdTExNjVcdTExQUJcdTAwMjkiLAogICJcdTMyMUUiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMTJcdTExNkVcdTAwMjkiLAogICJcdTMyMjAiLAogICJcdTAwMjhcdTRFMDBcdTAwMjkiLAogICJcdTMyMjEiLAogICJcdTAwMjhcdTRFOENcdTAwMjkiLAogICJcdTMyMjIiLAogICJcdTAwMjhcdTRFMDlcdTAwMjkiLAogICJcdTMyMjMiLAogICJcdTAwMjhcdTU2REJcdTAwMjkiLAogICJcdTMyMjQiLAogICJcdTAwMjhcdTRFOTRcdTAwMjkiLAogICJcdTMyMjUiLAogICJcdTAwMjhcdTUxNkRcdTAwMjkiLAogICJcdTMyMjYiLAogICJcdTAwMjhcdTRFMDNcdTAwMjkiLAogICJcdTMyMjciLAogICJcdTAwMjh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AogICJcdTMyM0YiLAogICJcdTAwMjhcdTUzNTRcdTAwMjkiLAogICJcdTMyNDAiLAogICJcdTAwMjhcdTc5NkRcdTAwMjkiLAogICJcdTMyNDEiLAogICJcdTAwMjhcdTRGMTFcdTAwMjkiLAogICJcdTMyNDIiLAogICJcdTAwMjhcdTgxRUFcdTAwMjkiLAogICJcdTMyNDMiLAogICJcdTAwMjhcdTgxRjNcdTAwMjkiLAogICJcdTMyQzAiLAogICJcdTAwMzFcdTY3MDgiLAogICJcdTMyQzEiLAogICJcdTAwMzJcdTY3MDgiLAogICJcdTMyQzIiLAogICJcdTAwMzNcdTY3MDgiLAogICJcdTMyQzMiLAogICJcdTAwMzRcdTY3MDgiLAogICJcdTMyQzQiLAogICJcdTAwMzVcdTY3MDgiLAogICJcdTMyQzUiLAogICJcdTAwMzZcdTY3MDgiLAogICJcdTMyQzYiLAogICJcdTAwMzdcdTY3MDgiLAogICJcdTMyQzciLAogICJcdTAwMzhcdTY3MDgiLAogICJcdTMyQzgiLAogICJcdTAwMzlcdTY3MDgiLAogICJcdTMyQzkiLAogICJcdTAwMzFcdTAwMzBcdTY3MDgiLAogICJcdTMyQ0EiLAogICJcdTAwMzFcdTAwMzFcdTY3MDgiLAogICJcdTMyQ0IiLAogICJcdTAwMzFcdTAwMzJcdTY3MDgiLAogICJcdTMzNTgiLAogICJcdTAwMzBcdTcwQjkiLAogICJcdTMzNTkiLAogICJcdTAwMzFcdTcwQjkiLAogICJcdTMzNUEiLAogICJcdTAwMzJcdTcwQjkiLAogICJcdTMzNUIiLAogICJcdTAwMzNcdTcwQjkiLAogICJcdTMzNUMiLAogICJcdTAwMzRcdTcwQjkiLAogICJcdTMzNUQiLAogICJcdTAwMzVcdTcwQjkiLAogICJcdTMzNUUiLAogICJcdTAwMzZcdTcwQjkiLAogICJcdTMzNUYiLAogICJcdTAwMzdcdTcwQjkiLAogICJcdTMzNjAiLAogICJcdTAwMzhcdTcwQjkiLAogICJcdTMzNjEiLAogICJcdTAw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AogICJcdTAwNjZcdTAwNkMiLAogICJcdUZCMDMiLAogICJcdTAwNjZcdTAwNjZcdTAwNjkiLAogICJcdUZCMDQiLAogICJcdTAwNjZcdTAwNjZcdTAwNkMiLAogICJcdUZCMDUiLAogICJcdTAxN0ZcdTAwNzQiLAogICJcdUZCMDYiLAogICJcdTAwNzNcdTAwNzQiLAogICJcdUZCMTMiLAogICJcdTA1NzRcdTA1NzYiLAogICJcdUZCMTQiLAogICJcdTA1NzRcdTA1NjUiLAogICJcdUZCMTUiLAogICJcdTA1NzRcdTA1NkIiLAogICJcdUZCMTYiLAogICJcdTA1N0VcdTA1NzYiLAogICJcdUZCMTciLAogICJcdTA1NzRcdTA1NkQiLAogICJcdUZCNEYiLAogICJcdTA1RDBcdTA1REMiLAogICJcdUZCNTAiLAogICJcdTA2NzEiLAogICJcdUZCNTEiLAogICJcdTA2NzEiLAogICJcdUZCNTIiLAogICJcdTA2N0IiLAogICJcdUZCNTMiLAogICJcdTA2N0IiLAogICJcdUZCNTQiLAogICJcdTA2N0IiLAogICJcdUZCNTUiLAogICJcdTA2N0IiLAogICJcdUZCNTYiLAogICJcdTA2N0UiLAogICJcdUZCNTciLAogICJcdTA2N0UiLAogICJcdUZCNTgiLAogICJcdTA2N0UiLAogICJcdUZCNTkiLAogICJcdTA2N0UiLAogICJcdUZCNUEiLAogICJcdTA2ODAiLAogICJcdUZCNUIiLAogICJcdTA2ODAiLAogICJcdUZCNUMiLAogICJcdTA2ODAiLAogICJcdUZCNUQiLAogICJcdTA2ODAiLAogICJcdUZCNUUiLAogICJcdTA2N0EiLAogICJcdUZCNUYiLAogICJcdTA2N0EiLAogICJcdUZCNjAiLAogICJcdTA2N0EiLAogICJcdUZCNjEiLAogICJcdTA2N0EiLAogICJcdUZCNjIiLAogICJcdTA2N0YiLAogICJcdUZCNjMiLAogICJcdTA2N0YiLAogICJcdUZCNjQiLAogICJcdTA2N0YiLAogICJcdUZCNjUiLAogICJcdTA2N0YiLAogICJcdUZCNjYiLAogICJcdTA2NzkiLAogICJcdUZCNjciLAogICJcdTA2NzkiLAogICJcdUZCNjgiLAogICJcdTA2NzkiLAogICJcdUZCNjkiLAogICJcdTA2NzkiLAogICJcdUZCNkEiLAogICJcdTA2QTQiLAogICJcdUZCNkIiLAogICJcdTA2QTQiLAogICJcdUZCNkMiLAogICJcdTA2QTQiLAogICJcdUZCNkQiLAogICJcdTA2QTQiLAogICJcdUZCNkUiLAogICJcdTA2QTYiLAogICJcdUZCNkYiLAogICJcdTA2QTYiLAogICJcdUZCNzAiLAogICJcdTA2QTYiLAogICJcdUZCNzEiLAogICJcdTA2QTYiLAogICJcdUZCNzIiLAogICJcdTA2ODQiLAogICJcdUZCNzMiLAogICJcdTA2ODQiLAogICJcdUZCNzQiLAogICJcdTA2ODQiLAogICJcdUZCNzUiLAogICJcdTA2ODQiLAogICJcdUZCNzYiLAogICJcdTA2ODMiLAogICJcdUZCNzciLAogICJcdTA2ODMiLAogICJcdUZCNzgiLAogICJcdTA2ODMiLAogICJcdUZCNzkiLAogICJcdTA2ODMiLAogICJcdUZCN0EiLAogICJcdTA2ODYiLAogICJcdUZCN0IiLAogICJcdTA2ODYiLAogICJcdUZCN0MiLAogICJcdTA2ODYiLAogICJcdUZCN0QiLAogICJcdTA2ODYiLAogICJcdUZCN0UiLAogICJcdTA2ODciLAogICJcdUZCN0YiLAogICJcdTA2ODciLAogICJcdUZCODAiLAogICJcdTA2ODciLAogICJcdUZCODEiLAogICJcdTA2ODciLAogICJcdUZCODIiLAogICJcdTA2OEQiLAogICJcdUZCODMiLAogICJcdTA2OEQiLAogICJcdUZCODQiLAogICJcdTA2OEMiLAogICJcdUZCODUiLAogICJcdTA2OEMiLAogICJcdUZCODYiLAogICJcdTA2OEUiLAogICJcdUZCODciLAogICJcdTA2OEUiLAogICJcdUZCODgiLAogICJcdTA2ODgiLAogICJcdUZCODkiLAogICJcdTA2ODgiLAogICJcdUZCOEEiLAogICJcdTA2OTgiLAogICJcdUZCOEIiLAogICJcdTA2OTgiLAogICJcdUZCOEMiLAogICJcdTA2OTEiLAogICJcdUZCOEQiLAogICJcdTA2OTEiLAogICJcdUZCOEUiLAogICJcdTA2QTkiLAogICJcdUZCOEYiLAogICJcdTA2QTkiLAogICJcdUZCOTAiLAogICJcdTA2QTkiLAogICJcdUZCOTEiLAogICJcdTA2QTkiLAogICJcdUZCOTIiLAogICJcdTA2QUYiLAogICJcdUZCOTMiLAogICJcdTA2QUYiLAogICJcdUZCOTQiLAogICJcdTA2QUYiLAogICJcdUZCOTUiLAogICJcdTA2QUYiLAogICJcdUZCOTYiLAogICJcdTA2QjMiLAogICJcdUZCOTciLAogICJcdTA2QjMiLAogICJcdUZCOTgiLAogICJcdTA2QjMiLAogICJcdUZCOTkiLAogICJcdTA2QjMiLAogICJcdUZCOUEiLAogICJcdTA2QjEiLAogICJcdUZCOUIiLAogICJcdTA2QjEiLAogICJcdUZCOUMiLAogICJcdTA2QjEiLAogICJcdUZCOUQiLAogICJcdTA2QjEiLAogICJcdUZCOUUiLAogICJcdTA2QkEiLAogICJcdUZCOUYiLAogICJcdTA2QkEiLAogICJcdUZCQTAiLAogICJcdTA2QkIiLAogICJcdUZCQTEiLAogICJcdTA2QkIiLAogICJcdUZCQTIiLAogICJcdTA2QkIiLAogICJcdUZCQTMiLAogICJcdTA2QkIiLAogICJcdUZCQTQiLAogICJcdTA2QzAiLAogICJcdUZCQTUiLAogICJcdTA2QzAiLAogICJcdUZCQTYiLAogICJcdTA2QzEiLAogICJcdUZCQTciLAogICJcdTA2QzEiLAogICJcdUZCQTgiLAogICJcdTA2QzEiLAogICJcdUZCQTkiLAogICJcdTA2QzEiLAogICJcdUZCQUEiLAogICJcdTA2QkUiLAogICJcdUZCQUIiLAogICJcdTA2QkUiLAogICJcdUZCQUMiLAogICJcdTA2QkUiLAogICJcdUZCQUQiLAogICJcdTA2QkUiLAogICJcdUZCQUUiLAogICJcdTA2RDIiLAogICJcdUZCQUYiLAogICJcdTA2RDIiLAogICJcdUZCQjAiLAogICJcdTA2RDMiLAogICJcdUZCQjEiLAogICJcdTA2RDMiLAogICJcdUZCRDMiLAogICJcdTA2QUQiLAogICJcdUZCRDQiLAogICJcdTA2QUQiLAogICJcdUZCRDUiLAogICJcdTA2QUQiLAogICJcdUZCRDYiLAogICJcdTA2QUQiLAogICJcdUZCRDciLAogICJcdTA2QzciLAogICJcdUZCRDgiLAogICJcdTA2QzciLAogICJcdUZCRDkiLAogICJcdTA2QzYiLAogICJcdUZCREEiLAogICJcdTA2QzYiLAogICJcdUZCREIiLAogICJcdTA2QzgiLAogICJcdUZCREMiLAogICJcdTA2QzgiLAogICJcdUZCREQiLAogICJcdTA2NzciLAogICJcdUZCREUiLAogICJcdTA2Q0IiLAogICJcdUZCREYiLAogICJcdTA2Q0IiLAogICJcdUZCRTAiLAogICJcdTA2QzUiLAogICJcdUZCRTEiLAogICJcdTA2QzUiLAogICJcdUZCRTIiLAogICJcdTA2QzkiLAogICJcdUZCRTMiLAogICJcdTA2QzkiLAogICJcdUZCRTQiLAogICJcdTA2RDAiLAogICJcdUZCRTUiLAogICJcdTA2RDAiLAogICJcdUZCRTYiLAogICJcdTA2RDAiLAogICJcdUZCRTciLAogICJcdTA2RDAiLAogICJcdUZCRTgiLAogICJcdTA2NDkiLAogICJcdUZCRTkiLAogICJcdTA2NDkiLAogICJcdUZCRUEiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUIiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUMiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUQiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUUiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRUYiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRjAiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjEiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjIiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjMiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjQiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjUiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjYiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjciLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjgiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjkiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkEiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkIiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkMiLAogICJcdTA2Q0MiLAogICJcdUZCRkQiLAogICJcdTA2Q0MiLAogICJcdUZCRkUiLAogICJcdTA2Q0MiLAogICJcdUZCRkYiLAogICJcdTA2Q0MiLAogICJcdUZDMDAiLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDMDEiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDMDIiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDMDMiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDMDQiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDMDUiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDMDYiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDMDciLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDMDgiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDMDkiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDMEEiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDMEIiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDMEMiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDMEQiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDMEUiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDMEYiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDMTAiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDMTEiLAogICJcdTA2MkJcdTA2MkMiLAogICJcdUZDMTIiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDMTMiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDMTQiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDMTUiLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDMTYiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDMTciLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDMTgiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDMTkiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDMUEiLAogICJcdTA2MkVcdTA2MkQiLAogICJcdUZDMUIiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDMUMiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDMUQiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDMUUiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDMUYiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDMjAiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDMjEiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDMjIiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDMjMiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDMjQiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDMjUiLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDMjYiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDMjciLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZDMjgiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDMjkiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDMkEiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDMkIiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDMkMiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDMkQiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDMkUiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDMkYiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDMzAiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDMzEiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDMzIiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDMzMiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDMzQiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDMzUiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDMzYiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDMzciLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDMzgiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDMzkiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDM0EiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDM0IiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDM0MiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDM0QiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDM0UiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDM0YiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDNDAiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDNDEiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDNDIiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDNDMiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDNDQiLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDNDUiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDNDYiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDNDciLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDNDgiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDNDkiLAogICJcdTA2NDVcdTA2NDkiLAogICJcdUZDNEEiLAogICJcdTA2NDVcdTA2NEEiLAogICJcdUZDNEIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDNEMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDNEQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDNEUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDNEYiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDNTAiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDNTEiLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDNTIiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDNTMiLAogICJcdTA2NDdcdTA2NDkiLAogICJcdUZDNTQiLAogICJcdTA2NDdcdTA2NEEiLAogICJcdUZDNTUiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDNTYiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDNTciLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDNTgiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDNTkiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDNUEiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDNUIiLAogICJcdTA2MzBcdTA2NzAiLAogICJcdUZDNUMiLAogICJcdTA2MzFcdTA2NzAiLAogICJcdUZDNUQiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDNUUiLAogICJcdTAwMjBcdTA2NENcdTA2NTEiLAogICJcdUZDNUYiLAogICJcdTAwMjBcdTA2NERcdTA2NTEiLAogICJcdUZDNjAiLAogICJcdTAwMjBcdTA2NEVcdTA2NTEiLAogICJcdUZDNjEiLAogICJcdTAwMjBcdTA2NEZcdTA2NTEiLAogICJcdUZDNjIiLAogICJcdTAwMjBcdTA2NTBcdTA2NTEiLAogICJcdUZDNjMiLAogICJcdTAwMjBcdTA2NTFcdTA2NzAiLAogICJcdUZDNjQiLAogICJcdTA2MjZcdTA2MzEiLAogICJcdUZDNjUiLAogICJcdTA2MjZcdTA2MzIiLAogICJcdUZDNjYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDNjciLAogICJcdTA2MjZcdTA2NDYiLAogICJcdUZDNjgiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDNjkiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDNkEiLAogICJcdTA2MjhcdTA2MzEiLAogICJcdUZDNkIiLAogICJcdTA2MjhcdTA2MzIiLAogICJcdUZDNkMiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDNkQiLAogICJcdTA2MjhcdTA2NDYiLAogICJcdUZDNkUiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDNkYiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDNzAiLAogICJcdTA2MkFcdTA2MzEiLAogICJcdUZDNzEiLAogICJcdTA2MkFcdTA2MzIiLAogICJcdUZDNzIiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDNzMiLAogICJcdTA2MkFcdTA2NDYiLAogICJcdUZDNzQiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDNzUiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDNzYiLAogICJcdTA2MkJcdTA2MzEiLAogICJcdUZDNzciLAogICJcdTA2MkJcdTA2MzIiLAogICJcdUZDNzgiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDNzkiLAogICJcdTA2MkJcdTA2NDYiLAogICJcdUZDN0EiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDN0IiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDN0MiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDN0QiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDN0UiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDN0YiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDODAiLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDODEiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDODIiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDODMiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDODQiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDODUiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDODYiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDODciLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDODgiLAogICJcdTA2NDVcdTA2MjciLAogICJcdUZDODkiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDOEEiLAogICJcdTA2NDZcdTA2MzEiLAogICJcdUZDOEIiLAogICJcdTA2NDZcdTA2MzIiLAogICJcdUZDOEMiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDOEQiLAogICJcdTA2NDZcdTA2NDYiLAogICJcdUZDOEUiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDOEYiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDOTAiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDOTEiLAogICJcdTA2NEFcdTA2MzEiLAogICJcdUZDOTIiLAogICJcdTA2NEFcdTA2MzIiLAogICJcdUZDOTMiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDOTQiLAogICJcdTA2NEFcdTA2NDYiLAogICJcdUZDOTUiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDOTYiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDOTciLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDOTgiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDOTkiLAogICJcdTA2MjZcdTA2MkUiLAogICJcdUZDOUEiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDOUIiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDOUMiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDOUQiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDOUUiLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDOUYiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDQTAiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDQTEiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDQTIiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDQTMiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDQTQiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDQTUiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDQTYiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDQTciLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDQTgiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDQTkiLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDQUEiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDQUIiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDQUMiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDQUQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDQUUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDQUYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDQjAiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDQjEiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDQjIiLAogICJcdTA2MzVcdTA2MkUiLAogICJcdUZDQjMiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDQjQiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDQjUiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDQjYiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDQjciLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDQjgiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDQjkiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDQkEiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDQkIiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDQkMiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDQkQiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDQkUiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDQkYiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDQzAiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDQzEiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDQzIiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDQzMiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDQzQiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDQzUiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDQzYiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDQzciLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDQzgiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDQzkiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDQ0EiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDQ0IiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDQ0MiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDQ0QiLAogICJcdTA2NDRcdTA2NDciLAogICJcdUZDQ0UiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDQ0YiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDRDAiLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDRDEiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDRDIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDRDMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDRDQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDRDUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRDYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRDciLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDRDgiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDRDkiLAogICJcdTA2NDdcdTA2NzAiLAogICJcdUZDREEiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDREIiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDREMiLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDREQiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDREUiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDREYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDRTAiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDRTEiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDRTIiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDRTMiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDRTQiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDRTUiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDRTYiLAogICJcdTA2MkJcdTA2NDciLAogICJcdUZDRTciLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDRTgiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZDRTkiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZDRUEiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZDRUIiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDRUMiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDRUQiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDRUUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRUYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRjAiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDRjEiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDRjIiLAogICJcdTA2NDBcdTA2NEVcdTA2NTEiLAogICJcdUZDRjMiLAogICJcdTA2NDBcdTA2NEZcdTA2NTEiLAogICJcdUZDRjQiLAogICJcdTA2NDBcdTA2NTBcdTA2NTEiLAogICJcdUZDRjUiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZDRjYiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZDRjciLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZDRjgiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZDRjkiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZDRkEiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZDRkIiLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZDRkMiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZDRkQiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZDRkUiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZDRkYiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMDAiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMDEiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMDIiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMDMiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMDQiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMDUiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMDYiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMDciLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMDgiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMDkiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMEEiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMEIiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMEMiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMEQiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMEUiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMEYiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMTAiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMTEiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZEMTIiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZEMTMiLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZEMTQiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZEMTUiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZEMTYiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZEMTciLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZEMTgiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZEMTkiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZEMUEiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZEMUIiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMUMiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMUQiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMUUiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMUYiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMjAiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMjEiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMjIiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMjMiLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMjQiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMjUiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMjYiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMjciLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMjgiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMjkiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMkEiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMkIiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMkMiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMkQiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMkUiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMkYiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMzAiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMzEiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZEMzIiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZEMzMiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEMzQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZEMzUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZEMzYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZEMzciLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMzgiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMzkiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEM0EiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEM0IiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZEM0MiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZEM0QiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZENTAiLAogICJcdTA2MkFcdTA2MkNcdTA2NDUiLAogICJcdUZENTEiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTIiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTMiLAogICJcdTA2MkFcdTA2MkRcdTA2NDUiLAogICJcdUZENTQiLAogICJcdTA2MkFcdTA2MkVcdTA2NDUiLAogICJcdUZENTUiLAogICJcdTA2MkFcdTA2NDVcdTA2MkMiLAogICJcdUZENTYiLAogICJcdTA2MkFcdTA2NDVcdTA2MkQiLAogICJcdUZENTciLAogICJcdTA2MkFcdTA2NDVcdTA2MkUiLAogICJcdUZENTgiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENTkiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENUEiLAogICJcdTA2MkRcdTA2NDVcdTA2NEEiLAogICJcdUZENUIiLAogICJcdTA2MkRcdTA2NDVcdTA2NDkiLAogICJcdUZENUMiLAogICJcdTA2MzNcdTA2MkRcdTA2MkMiLAogICJcdUZENUQiLAogICJcdTA2MzNcdTA2MkNcdTA2MkQiLAogICJcdUZENUUiLAogICJcdTA2MzNcdTA2MkNcdTA2NDkiLAogICJcdUZENUYiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjAiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjEiLAogICJcdTA2MzNcdTA2NDVcdTA2MkMiLAogICJcdUZENjIiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjMiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjQiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjUiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjYiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZENjciLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjgiLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjkiLAogICJcdTA2MzRcdTA2MkNcdTA2NEEiLAogICJcdUZENkEiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkIiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkMiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkQiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkUiLAogICJcdTA2MzZcdTA2MkRcdTA2NDkiLAogICJcdUZENkYiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzAiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzEiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzIiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzMiLAogICJcdTA2MzdcdTA2NDVcdTA2NDUiLAogICJcdUZENzQiLAogICJcdTA2MzdcdTA2NDVcdTA2NEEiLAogICJcdUZENzUiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZENzYiLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzciLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzgiLAogICJcdTA2MzlcdTA2NDVcdTA2NDkiLAogICJcdUZENzkiLAogICJcdTA2M0FcdTA2NDVcdTA2NDUiLAogICJcdUZEN0EiLAogICJcdTA2M0FcdTA2NDVcdTA2NEEiLAogICJcdUZEN0IiLAogICJcdTA2M0FcdTA2NDVcdTA2NDkiLAogICJcdUZEN0MiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0QiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0UiLAogICJcdTA2NDJcdTA2NDVcdTA2MkQiLAogICJcdUZEN0YiLAogICJcdTA2NDJcdTA2NDVcdTA2NDUiLAogICJcdUZEODAiLAogICJcdTA2NDRcdTA2MkRcdTA2NDUiLAogICJcdUZEODEiLAogICJcdTA2NDRcdTA2MkRcdTA2NEEiLAogICJcdUZEODIiLAogICJcdTA2NDRcdTA2MkRcdTA2NDkiLAogICJcdUZEODMiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODQiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODUiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODYiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODciLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODgiLAogICJcdTA2NDRcdTA2NDVcdTA2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NDVcdTA2MkVcdTA2NEEiLAogICJcdUZEQkEiLAogICJcdTA2NDRcdTA2MkNcdTA2NDUiLAogICJcdUZEQkIiLAogICJcdTA2NDNcdTA2NDVcdTA2NDUiLAogICJcdUZEQkMiLAogICJcdTA2NDRcdTA2MkNcdTA2NDUiLAogICJcdUZEQkQiLAogICJcdTA2NDZcdTA2MkNcdTA2MkQiLAogICJcdUZEQkUiLAogICJcdTA2MkNcdTA2MkRcdTA2NEEiLAogICJcdUZEQkYiLAogICJcdTA2MkRcdTA2MkNcdTA2NEEiLAogICJcdUZEQzAiLAogICJcdTA2NDVcdTA2MkNcdTA2NEEiLAogICJcdUZEQzEiLAogICJcdTA2NDFcdTA2NDVcdTA2NEEiLAogICJcdUZEQzIiLAogICJcdTA2MjhcdTA2MkRcdTA2NEEiLAogICJcdUZEQzMiLAogICJcdTA2NDNcdTA2NDVcdTA2NDUiLAogICJcdUZEQzQiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZEQzUiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZEQzYiLAogICJcdTA2MzNcdTA2MkVcdTA2NEEiLAogICJcdUZEQzciLAogICJcdTA2NDZcdTA2MkNcdTA2NEEiLAogICJcdUZFNDkiLAogICJcdTIwM0UiLAogICJcdUZFNEEiLAogICJcdTIwM0UiLAogICJcdUZFNEIiLAogICJcdTIwM0UiLAogICJcdUZFNEMiLAogICJcdTIwM0UiLAogICJcdUZFNEQiLAogICJcdTAwNUYiLAogICJcdUZFNEUiLAogICJcdTAwNUYiLAogICJcdUZFNEYiLAogICJcdTAwNUYiLAogICJcdUZFODAiLAogICJcdTA2MjEiLAogICJcdUZFODEiLAogICJcdTA2MjIiLAogICJcdUZFODIiLAogICJcdTA2MjIiLAogICJcdUZFODMiLAogICJcdTA2MjMiLAogICJcdUZFODQiLAogICJcdTA2MjMiLAogICJcdUZFODUiLAogICJcdTA2MjQiLAogICJcdUZFODYiLAogICJcdTA2MjQiLAogICJcdUZFODciLAogICJcdTA2MjUiLAogICJcdUZFODgiLAogICJcdTA2MjUiLAogICJcdUZFODkiLAogICJcdTA2MjYiLAogICJcdUZFOEEiLAogICJcdTA2MjYiLAogICJcdUZFOEIiLAogICJcdTA2MjYiLAogICJcdUZFOEMiLAogICJcdTA2MjYiLAogICJcdUZFOEQiLAogICJcdTA2MjciLAogICJcdUZFOEUiLAogICJcdTA2MjciLAogICJcdUZFOEYiLAogICJcdTA2MjgiLAogICJcdUZFOTAiLAogICJcdTA2MjgiLAogICJcdUZFOTEiLAogICJcdTA2MjgiLAogICJcdUZFOTIiLAogICJcdTA2MjgiLAogICJcdUZFOTMiLAogICJcdTA2MjkiLAogICJcdUZFOTQiLAogICJcdTA2MjkiLAogICJcdUZFOTUiLAogICJcdTA2MkEiLAogICJcdUZFOTYiLAogICJcdTA2MkEiLAogICJcdUZFOTciLAogICJcdTA2MkEiLAogICJcdUZFOTgiLAogICJcdTA2MkEiLAogICJcdUZFOTkiLAogICJcdTA2MkIiLAogICJcdUZFOUEiLAogICJcdTA2MkIiLAogICJcdUZFOUIiLAogICJcdTA2MkIiLAogICJcdUZFOUMiLAogICJcdTA2MkIiLAogICJcdUZFOUQiLAogICJcdTA2MkMiLAogICJcdUZFOUUiLAogICJcdTA2MkMiLAogICJcdUZFOUYiLAogICJcdTA2MkMiLAogICJcdUZFQTAiLAogICJcdTA2MkMiLAogICJcdUZFQTEiLAogICJcdTA2MkQiLAogICJcdUZFQTIiLAogICJcdTA2MkQiLAogICJcdUZFQTMiLAogICJcdTA2MkQiLAogICJcdUZFQTQiLAogICJcdTA2MkQiLAogICJcdUZFQTUiLAogICJcdTA2MkUiLAogICJcdUZFQTYiLAogICJcdTA2MkUiLAogICJcdUZFQTciLAogICJcdTA2MkUiLAogICJcdUZFQTgiLAogICJcdTA2MkUiLAogICJcdUZFQTkiLAogICJcdTA2MkYiLAogICJcdUZFQUEiLAogICJcdTA2MkYiLAogICJcdUZFQUIiLAogICJcdTA2MzAiLAogICJcdUZFQUMiLAogICJcdTA2MzAiLAogICJcdUZFQUQiLAogICJcdTA2MzEiLAogICJcdUZFQUUiLAogICJcdTA2MzEiLAogICJcdUZFQUYiLAogICJcdTA2MzIiLAogICJcdUZFQjAiLAogICJcdTA2MzIiLAogICJcdUZFQjEiLAogICJcdTA2MzMiLAogICJcdUZFQjIiLAogICJcdTA2MzMiLAogICJcdUZFQjMiLAogICJcdTA2MzMiLAogICJcdUZFQjQiLAogICJcdTA2MzMiLAogICJcdUZFQjUiLAogICJcdTA2MzQiLAogICJcdUZFQjYiLAogICJcdTA2MzQiLAogICJcdUZFQjciLAogICJcdTA2MzQiLAogICJcdUZFQjgiLAogICJcdTA2MzQiLAogICJcdUZFQjkiLAogICJcdTA2MzUiLAogICJcdUZFQkEiLAogICJcdTA2MzUiLAogICJcdUZFQkIiLAogICJcdTA2MzUiLAogICJcdUZFQkMiLAogICJcdTA2MzUiLAogICJcdUZFQkQiLAogICJcdTA2MzYiLAogICJcdUZFQkUiLAogICJcdTA2MzYiLAogICJcdUZFQkYiLAogICJcdTA2MzYiLAogICJcdUZFQzAiLAogICJcdTA2MzYiLAogICJcdUZFQzEiLAogICJcdTA2MzciLAogICJcdUZFQzIiLAogICJcdTA2MzciLAogICJcdUZFQzMiLAogICJcdTA2MzciLAogICJcdUZFQzQiLAogICJcdTA2MzciLAogICJcdUZFQzUiLAogICJcdTA2MzgiLAogICJcdUZFQzYiLAogICJcdTA2MzgiLAogICJcdUZFQzciLAogICJcdTA2MzgiLAogICJcdUZFQzgiLAogICJcdTA2MzgiLAogICJcdUZFQzkiLAogICJcdTA2MzkiLAogICJcdUZFQ0EiLAogICJcdTA2MzkiLAogICJcdUZFQ0IiLAogICJcdTA2MzkiLAogICJcdUZFQ0MiLAogICJcdTA2MzkiLAogICJcdUZFQ0QiLAogICJcdTA2M0EiLAogICJcdUZFQ0UiLAogICJcdTA2M0EiLAogICJcdUZFQ0YiLAogICJcdTA2M0EiLAogICJcdUZFRDAiLAogICJcdTA2M0EiLAogICJcdUZFRDEiLAogICJcdTA2NDEiLAogICJcdUZFRDIiLAogICJcdTA2NDEiLAogICJcdUZFRDMiLAogICJcdTA2NDEiLAogICJcdUZFRDQiLAogICJcdTA2NDEiLAogICJcdUZFRDUiLAogICJcdTA2NDIiLAogICJcdUZFRDYiLAogICJcdTA2NDIiLAogICJcdUZFRDciLAogICJcdTA2NDIiLAogICJcdUZFRDgiLAogICJcdTA2NDIiLAogICJcdUZFRDkiLAogICJcdTA2NDMiLAogICJcdUZFREEiLAogICJcdTA2NDMiLAogICJcdUZFREIiLAogICJcdTA2NDMiLAogICJcdUZFREMiLAogICJcdTA2NDMiLAogICJcdUZFREQiLAogICJcdTA2NDQiLAogICJcdUZFREUiLAogICJcdTA2NDQiLAogICJcdUZFREYiLAogICJcdTA2NDQiLAogICJcdUZFRTAiLAogICJcdTA2NDQiLAogICJcdUZFRTEiLAogICJcdTA2NDUiLAogICJcdUZFRTIiLAogICJcdTA2NDUiLAogICJcdUZFRTMiLAogICJcdTA2NDUiLAogICJcdUZFRTQiLAogICJcdTA2NDUiLAogICJcdUZFRTUiLAogICJcdTA2NDYiLAogICJcdUZFRTYiLAogICJcdTA2NDYiLAogICJcdUZFRTciLAogICJcdTA2NDYiLAogICJcdUZFRTgiLAogICJcdTA2NDYiLAogICJcdUZFRTkiLAogICJcdTA2NDciLAogICJcdUZFRUEiLAogICJcdTA2NDciLAogICJcdUZFRUIiLAogICJcdTA2NDciLAogICJcdUZFRUMiLAogICJcdTA2NDciLAogICJcdUZFRUQiLAogICJcdTA2NDgiLAogICJcdUZFRUUiLAogICJcdTA2NDgiLAogICJcdUZFRUYiLAogICJcdTA2NDkiLAogICJcdUZFRjAiLAogICJcdTA2NDkiLAogICJcdUZFRjEiLAogICJcdTA2NEEiLAogICJcdUZFRjIiLAogICJcdTA2NEEiLAogICJcdUZFRjMiLAogICJcdTA2NEEiLAogICJcdUZFRjQiLAogICJcdTA2NEEiLAogICJcdUZFRjUiLA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0LmNyZWF0ZShudWxsKTsKICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjaWRUb0dpZE1hcC5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBjb25zdCBnaWQgPSBjaWRUb0dpZE1hcFtpXTsKICAgICAgICAgIGlmIChnaWQgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBpbnZDaWRUb0dpZE1hcFtnaWRdID0gaTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgY2hhckNvZGU7CiAgICAgIGlmIChjZmYuaXNDSURGb250KSB7CiAgICAgICAgZm9yIChnbHlwaElkID0gMDsgZ2x5cGhJZCA8IGNoYXJzZXRzLmxlbmd0aDsgZ2x5cGhJZCsrKSB7CiAgICAgICAgICBjb25zdCBjaWQgPSBjaGFyc2V0c1tnbHlwaElkXTsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGNpZCk7CiAgICAgICAgICBpZiAoaW52Q2lkVG9HaWRNYXAgJiYgaW52Q2lkVG9HaWRNYXBbY2hhckNvZGVdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgY2hhckNvZGUgPSBpbnZDaWRUb0dpZE1hcFtjaGFyQ29kZV07CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBmb3IgKGdseXBoSWQgPSAwOyBnbHlwaElkIDwgY2ZmLmNoYXJTdHJpbmdzLmNvdW50OyBnbHlwaElkKyspIHsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGdseXBoSWQpOwogICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgIC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gICAgIGkgKz0gNDsKICAgICAgbGV0IGFyZzEsIGFyZzI7CiAgICAgIGlmIChmbGFncyAmIDB4MDEpIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBhcmcyID0gZ2V0SW50MTYoY29kZSwgaSArIDIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBhcmcxID0gZ2V0VWludDE2KGNvZGUsIGkpOwogICAgICAgICAgYXJnMiA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgICAgfQogICAgICAgIGkgKz0gNDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50OChjb2RlLCBpKyspOwogICAgICAgICAgYXJnMiA9IGdldEludDgoY29kZSwgaSsrKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYXJnMSA9IGNvZGVbaSsrXTsKICAgICAgICAgIGFyZzIgPSBjb2RlW2krK107CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChmbGFncyAmIDB4MDIpIHsKICAgICAgICB4ID0gYXJnMTsKICAgICAgICB5ID0gYXJnMjsKICAgICAgfSBlbHNlIHsKICAgICAgICB4ID0gMDsKICAgICAgICB5ID0gMDsKICAgICAgfQogICAgICBsZXQgc2NhbGVYID0gMSwKICAgICAgICBzY2FsZVkgPSAxLAogICAgICAgIHNjYWxlMDEgPSAwLAogICAgICAgIHNjYWxlMTAgPSAwOwogICAgICBpZiAoZmxhZ3MgJiAweDA4KSB7CiAgICAgICAgc2NhbGVYID0gc2NhbGVZID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgaSArPSAyOwogICAgICB9IGVsc2UgaWYgKGZsYWdzICYgMHg0MCkgewogICAgICAgIHNjYWxlWCA9IGdldEZsb2F0MjE0KGNvZGUsIGkpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0gZWxzZSBpZiAoZmxhZ3MgJiAweDgwKSB7CiAgICAgICAgc2NhbGVYID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgc2NhbGUwMSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBzY2FsZTEwID0gZ2V0RmxvYXQyMTQoY29kZSwgaSArIDQpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyA2KTsKICAgICAgICBpICs9IDg7CiAgICAgIH0KICAgICAgY29uc3Qgc3ViZ2x5cGggPSBmb250LmdseXBoc1tnbHlwaEluZGV4XTsKICAgICAgaWYgKHN1YmdseXBoKSB7CiAgICAgICAgY21kcy5wdXNoKHsKICAgICAgICAgIGNtZDogInNhdmUiCiAgICAgICAgfSwgewogICAgICAgICAgY21kOiAidHJhbnNmb3JtIiwKICAgICAgICAgIGFyZ3M6IFtzY2FsZVgsIHNjYWxlMDEsIHNjYWxlMTAsIHNjYWxlWSwgeCwgeV0KICAgICAgICB9KTsKICAgICAgICBpZiAoIShmbGFncyAmIDB4MDIpKSB7fQogICAgICAgIGNvbXBpbGVHbHlmKHN1YmdseXBoLCBjbWRzLCBmb250KTsKICAgICAgICBjbWRzLnB1c2goewogICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICB9KTsKICAgICAgfQogICAgfSB3aGlsZSAoZmxhZ3MgJiAweDIwKTsKICB9IGVsc2UgewogICAgY29uc3QgZW5kUHRzT2ZDb250b3VycyA9IFtdOwogICAgbGV0IGosIGpqOwogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mQ29udG91cnM7IGorKykgewogICAgICBlbmRQdHNPZkNvbnRvdXJzLnB1c2goZ2V0VWludDE2KGNvZGUsIGkpKTsKICAgICAgaSArPSAyOwogICAgfQogICAgY29uc3QgaW5zdHJ1Y3Rpb25MZW5ndGggPSBnZXRVaW50MTYoY29kZSwgaSk7CiAgICBpICs9IDIgKyBpbnN0cnVjdGlvbkxlbmd0aDsKICAgIGNvbnN0IG51bWJlck9mUG9pbnRzID0gZW5kUHRzT2ZDb250b3Vycy5hdCgtMSkgKyAxOwogICAgY29uc3QgcG9pbnRzID0gW107CiAgICB3aGlsZSAocG9pbnRzLmxlbmd0aCA8IG51bWJlck9mUG9pbnRzKSB7CiAgICAgIGZsYWdzID0gY29kZVtpKytdOwogICAgICBsZXQgcmVwZWF0ID0gMTsKICAgICAgaWYgKGZsYWdzICYgMHgwOCkgewogICAgICAgIHJlcGVhdCArPSBjb2RlW2krK107CiAgICAgIH0KICAgICAgd2hpbGUgKHJlcGVhdC0tID4gMCkgewogICAgICAgIHBvaW50cy5wdXNoKHsKICAgICAgICAgIGZsYWdzCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIGZvciAoaiA9IDA7IGogPCBudW1iZXJPZlBvaW50czsgaisrKSB7CiAgICAgIHN3aXRjaCAocG9pbnRzW2pdLmZsYWdzICYgMHgxMikgewogICAgICAgIGNhc2UgMHgwMDoKICAgICAgICAgIHggKz0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBpICs9IDI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDI6CiAgICAgICAgICB4IC09IGNvZGVbaSsrXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgxMjoKICAgICAgICAgIHggKz0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgcG9pbnRzW2pdLnggPSB4OwogICAgfQogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mUG9pbnRzOyBqKyspIHsKICAgICAgc3dpdGNoIChwb2ludHNbal0uZmxhZ3MgJiAweDI0KSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgeSArPSBnZXRJbnQxNihjb2RlLCBpKTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgwNDoKICAgICAgICAgIHkgLT0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI0OgogICAgICAgICAgeSArPSBjb2RlW2krK107CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwb2ludHNbal0ueSA9IHk7CiAgICB9CiAgICBsZXQgc3RhcnRQb2ludCA9IDA7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyT2ZDb250b3VyczsgaSsrKSB7CiAgICAgIGNvbnN0IGVuZFBvaW50ID0gZW5kUHRzT2ZDb250b3Vyc1tpXTsKICAgICAgY29uc3QgY29udG91ciA9IHBvaW50cy5zbGljZShzdGFydFBvaW50LCBlbmRQb2ludCArIDEpOwogICAgICBpZiAoY29udG91clswXS5mbGFncyAmIDEpIHsKICAgICAgICBjb250b3VyLnB1c2goY29udG91clswXSk7CiAgICAgIH0gZWxzZSBpZiAoY29udG91ci5hdCgtMSkuZmxhZ3MgJiAxKSB7CiAgICAgICAgY29udG91ci51bnNoaWZ0KGNvbnRvdXIuYXQoLTEpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBwID0gewogICAgICAgICAgZmxhZ3M6IDEsCiAgICAgICAgICB4OiAoY29udG91clswXS54ICsgY29udG91ci5hdCgtMSkueCkgLyAyLAogICAgICAgICAgeTogKGNvbnRvdXJbMF0ueSArIGNvbnRvdXIuYXQoLTEpLnkpIC8gMgogICAgICAgIH07CiAgICAgICAgY29udG91ci51bnNoaWZ0KHApOwogICAgICAgIGNvbnRvdXIucHVzaChwKTsKICAgICAgfQogICAgICBtb3ZlVG8oY29udG91clswXS54LCBjb250b3VyWzBdLnkpOwogICAgICBmb3IgKGogPSAxLCBqaiA9IGNvbnRvdXIubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgIGlmIChjb250b3VyW2pdLmZsYWdzICYgMSkgewogICAgICAgICAgbGluZVRvKGNvbnRvdXJbal0ueCwgY29udG91cltqXS55KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbnRvdXJbaiArIDFdLmZsYWdzICYgMSkgewogICAgICAgICAgcXVhZHJhdGljQ3VydmVUbyhjb250b3VyW2pdLngsIGNvbnRvdXJbal0ueSwgY29udG91cltqICsgMV0ueCwgY29udG91cltqICsgMV0ueSk7CiAgICAgICAgICBqKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHF1YWRyYXRpY0N1cnZlVG8oY29udG91cltqXS54LCBjb250b3VyW2pdLnksIChjb250b3VyW2pdLnggKyBjb250b3VyW2ogKyAxXS54KSAvIDIsIChjb250b3VyW2pdLnkgKyBjb250b3VyW2ogKyAxXS55KSAvIDIpOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGFydFBvaW50ID0gZW5kUG9pbnQgKyAxOwogICAgfQogIH0KfQpmdW5jdGlvbiBjb21waWxlQ2hhclN0cmluZyhjaGFyU3RyaW5nQ29kZSwgY21kcywgZm9udCwgZ2x5cGhJZCkgewogIGZ1bmN0aW9uIG1vdmVUbyh4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJtb3ZlVG8iLAogICAgICBhcmdzOiBbeCwgeV0KICAgIH0pOwogIH0KICBmdW5jdGlvbiBsaW5lVG8oeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAibGluZVRvIiwKICAgICAgYXJnczogW3gsIHldCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gYmV6aWVyQ3VydmVUbyh4MSwgeTEsIHgyLCB5MiwgeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAiYmV6aWVyQ3VydmVUbyIsCiAgICAgIGFyZ3M6IFt4MSwgeTEsIHgyLCB5MiwgeCwgeV0KICAgIH0pOwogIH0KICBjb25zdCBzdGFjayA9IFtdOwogIGxldCB4ID0gMCwKICAgIHkgPSAwOwogIGxldCBzdGVtcyA9IDA7CiAgZnVuY3Rpb24gcGFyc2UoY29kZSkgewogICAgbGV0IGkgPSAwOwogICAgd2hpbGUgKGkgPCBjb2RlLmxlbmd0aCkgewogICAgICBsZXQgc3RhY2tDbGVhbiA9IGZhbHNlOwogICAgICBsZXQgdiA9IGNvZGVbaSsrXTsKICAgICAgbGV0IHhhLCB4YiwgeWEsIHliLCB5MSwgeTIsIHkzLCBuLCBzdWJyQ29kZTsKICAgICAgc3dpdGNoICh2KSB7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgc3RlbXMgKz0gc3RhY2subGVuZ3RoID4+IDE7CiAgICAgICAgICBzdGFja0NsZWFuID0gdHJ1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDQ6CiAgICAgICAgICB5ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA2OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNzoKICAgICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDg6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMDoKICAgICAgICAgIG4gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN1YnJDb2RlID0gbnVsbDsKICAgICAgICAgIGlmIChmb250LmlzQ0ZGQ0lERm9udCkgewogICAgICAgICAgICBjb25zdCBmZEluZGV4ID0gZm9udC5mZFNlbGVjdC5nZXRGREluZGV4KGdseXBoSWQpOwogICAgICAgICAgICBpZiAoZmRJbmRleCA+PSAwICYmIGZkSW5kZXggPCBmb250LmZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgY29uc3QgZm9udERpY3QgPSBmb250LmZkQXJyYXlbZmRJbmRleF07CiAgICAgICAgICAgICAgbGV0IHN1YnJzOwogICAgICAgICAgICAgIGlmIChmb250RGljdC5wcml2YXRlRGljdCAmJiBmb250RGljdC5wcml2YXRlRGljdC5zdWJyc0luZGV4KSB7CiAgICAgICAgICAgICAgICBzdWJycyA9IGZvbnREaWN0LnByaXZhdGVEaWN0LnN1YnJzSW5kZXgub2JqZWN0czsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHN1YnJzKSB7CiAgICAgICAgICAgICAgICBuICs9IGdldFN1YnJvdXRpbmVCaWFzKHN1YnJzKTsKICAgICAgICAgICAgICAgIHN1YnJDb2RlID0gc3VicnNbbl07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSW52YWxpZCBmZCBpbmRleCBmb3IgZ2x5cGggaW5kZXguIik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN1YnJDb2RlID0gZm9udC5zdWJyc1tuICsgZm9udC5zdWJyc0JpYXNdOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTE6CiAgICAgICAgICByZXR1cm47CiAgICAgICAgY2FzZSAxMjoKICAgICAgICAgIHYgPSBjb2RlW2krK107CiAgICAgICAgICBzd2l0Y2ggKHYpIHsKICAgICAgICAgICAgY2FzZSAzNDoKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkxID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5LCB4YiwgeTEsIHgsIHkxKTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5LCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNToKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzY6CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5MSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkyID0geTEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5MiwgeCwgeTIpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeTMgPSB5MiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5MiwgeGIsIHkzLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNzoKICAgICAgICAgICAgICBjb25zdCB4MCA9IHgsCiAgICAgICAgICAgICAgICB5MCA9IHk7CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICAgIHkgPSB5YjsKICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoeCAtIHgwKSA+IE1hdGguYWJzKHkgLSB5MCkpIHsKICAgICAgICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgeSArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYHVua25vd24gb3BlcmF0b3I6IDEyICR7dn1gKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTQ6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID49IDQpIHsKICAgICAgICAgICAgY29uc3QgYWNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgYmNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgeSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICB4ID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAic2F2ZSIKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGNtZDogInRyYW5zbGF0ZSIsCiAgICAgICAgICAgICAgYXJnczogW3gsIHldCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBsZXQgY21hcCA9IGxvb2t1cENtYXAoZm9udC5jbWFwLCBTdHJpbmcuZnJvbUNoYXJDb2RlKGZvbnQuZ2x5cGhOYW1lTWFwW19lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZ1thY2hhcl1dKSk7CiAgICAgICAgICAgIGNvbXBpbGVDaGFyU3RyaW5nKGZvbnQuZ2x5cGhzW2NtYXAuZ2x5cGhJZF0sIGNtZHMsIGZvbnQsIGNtYXAuZ2x5cGhJZCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNtYXAgPSBsb29rdXBDbWFwKGZvbnQuY21hcCwgU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdseXBoTmFtZU1hcFtfZW5jb2RpbmdzLlN0YW5kYXJkRW5jb2RpbmdbYmNoYXJdXSkpOwogICAgICAgICAgICBjb21waWxlQ2hhclN0cmluZyhmb250LmdseXBoc1tjbWFwLmdseXBoSWRdLCBjbWRzLCBmb250LCBjbWFwLmdseXBoSWQpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgMTg6CiAgICAgICAgICBzdGVtcyArPSBzdGFjay5sZW5ndGggPj4gMTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOToKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMDoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMToKICAgICAgICAgIHkgKz0gc3RhY2sucG9wKCk7CiAgICAgICAgICB4ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDIyOgogICAgICAgICAgeCArPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG1vdmVUbyh4LCB5KTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI0OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDIpIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gNikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjY6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjc6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjg6CiAgICAgICAgICBzdGFjay5wdXNoKChjb2RlW2ldIDw8IDI0IHwgY29kZVtpICsgMV0gPDwgMTYpID4+IDE2KTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjk6CiAgICAgICAgICBuID0gc3RhY2sucG9wKCkgKyBmb250LmdzdWJyc0JpYXM7CiAgICAgICAgICBzdWJyQ29kZSA9IGZvbnQuZ3N1YnJzW25dOwogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzA6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMxOgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5OwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeGEgPSB4OwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmICh2IDwgMzIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGB1bmtub3duIG9wZXJhdG9yOiAke3Z9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodiA8IDI0NykgewogICAgICAgICAgICBzdGFjay5wdXNoKHYgLSAxMzkpOwogICAgICAgICAgfSBlbHNlIGlmICh2IDwgMjUxKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goKHYgLSAyNDcpICogMjU2ICsgY29kZVtpKytdICsgMTA4KTsKICAgICAgICAgIH0gZWxzZSBpZiAodiA8IDI1NSkgewogICAgICAgICAgICBzdGFjay5wdXNoKC0odiAtIDI1MSkgKiAyNTYgLSBjb2RlW2krK10gLSAxMDgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaCgoY29kZVtpXSA8PCAyNCB8IGNvZGVbaSArIDFdIDw8IDE2IHwgY29kZVtpICsgMl0gPDwgOCB8IGNvZGVbaSArIDNdKSAvIDY1NTM2KTsKICAgICAgICAgICAgaSArPSA0OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHN0YWNrQ2xlYW4pIHsKICAgICAgICBzdGFjay5sZW5ndGggPSAwOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlKGNoYXJTdHJpbmdDb2RlKTsKfQpjb25zdCBOT09QID0gW107CmNsYXNzIENvbXBpbGVkRm9udCB7CiAgY29uc3RydWN0b3IoZm9udE1hdHJpeCkgewogICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IENvbXBpbGVkRm9udCkgewogICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJDYW5ub3QgaW5pdGlhbGl6ZSBDb21waWxlZEZvbnQuIik7CiAgICB9CiAgICB0aGlzLmZvbnRNYXRyaXggPSBmb250TWF0cml4OwogICAgdGhpcy5jb21waWxlZEdseXBocyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIH0KICBnZXRQYXRoSnModW5pY29kZSkgewogICAgY29uc3QgewogICAgICBjaGFyQ29kZSwKICAgICAgZ2x5cGhJZAogICAgfSA9IGxvb2t1cENtYXAodGhpcy5jbWFwLCB1bmljb2RlKTsKICAgIGxldCBmbiA9IHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF07CiAgICBpZiAoIWZuKSB7CiAgICAgIHRyeSB7CiAgICAgICAgZm4gPSB0aGlzLmNvbXBpbGVHbHlwaCh0aGlzLmdseXBoc1tnbHlwaElkXSwgZ2x5cGhJZCk7CiAgICAgICAgdGhpcy5jb21waWxlZEdseXBoc1tnbHlwaElkXSA9IGZuOwogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF0gPSBOT09QOwogICAgICAgIGlmICh0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPT09IHVuZGVmaW5lZCkgewogICAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgIH0KICAgIHJldHVybiBmbjsKICB9CiAgY29tcGlsZUdseXBoKGNvZGUsIGdseXBoSWQpIHsKICAgIGlmICghY29kZSB8fCBjb2RlLmxlbmd0aCA9PT0gMCB8fCBjb2RlWzBdID09PSAxNCkgewogICAgICByZXR1cm4gTk9PUDsKICAgIH0KICAgIGxldCBmb250TWF0cml4ID0gdGhpcy5mb250TWF0cml4OwogICAgaWYgKHRoaXMuaXNDRkZDSURGb250KSB7CiAgICAgIGNvbnN0IGZkSW5kZXggPSB0aGlzLmZkU2VsZWN0LmdldEZESW5kZXgoZ2x5cGhJZCk7CiAgICAgIGlmIChmZEluZGV4ID49IDAgJiYgZmRJbmRleCA8IHRoaXMuZmRBcnJheS5sZW5ndGgpIHsKICAgICAgICBjb25zdCBmb250RGljdCA9IHRoaXMuZmRBcnJheVtmZEluZGV4XTsKICAgICAgICBmb250TWF0cml4ID0gZm9udERpY3QuZ2V0QnlOYW1lKCJGb250TWF0cml4IikgfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgfQogICAgfQogICAgY29uc3QgY21kcyA9IFt7CiAgICAgIGNtZDogInNhdmUiCiAgICB9LCB7CiAgICAgIGNtZDogInRyYW5zZm9ybSIsCiAgICAgIGFyZ3M6IGZvbnRNYXRyaXguc2xpY2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C5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTAwOwogICAgdC5LID0gNjY3OwogICAgdC5MID0gNTU2OwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDI3ODsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAyNzg7CiAgICB0LmFzY2lpY2lyY3VtID0gNDY5OwogICAgdC51bmRlcnNjb3JlID0gNTU2OwogICAgdC5xdW90ZWxlZnQgPSAyMjI7CiAgICB0LmEgPSA1NTY7CiAgICB0LmIgPSA1NTY7CiAgICB0LmMgPSA1MDA7CiAgICB0LmQgPSA1NTY7CiAgICB0LmUgPSA1NTY7CiAgICB0LmYgPSAyNzg7CiAgICB0LmcgPSA1NTY7CiAgICB0LmggPSA1NTY7CiAgICB0LmkgPSAyMjI7CiAgICB0LmogPSAyMjI7CiAgICB0LmsgPSA1MDA7CiAgICB0LmwgPSAyMjI7CiAgICB0Lm0gPSA4MzM7CiAgICB0Lm4gPSA1NTY7CiAgICB0Lm8gPSA1NTY7CiAgICB0LnAgPSA1NTY7CiAgICB0LnEgPSA1NTY7CiAgICB0LnIgPSAzMzM7CiAgICB0LnMgPSA1MDA7CiAgICB0LnQgPSAyNzg7CiAgICB0LnUgPSA1NTY7CiAgICB0LnYgPSA1MDA7CiAgICB0LncgPSA3MjI7CiAgICB0LnggPSA1MDA7CiAgICB0LnkgPSA1MDA7CiAgICB0LnogPSA1MDA7CiAgICB0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gMjc4OwogICAgdC5KID0gNTU2OwogICAgdC5LID0gNzIyOwogICAgdC5MID0gNjExOwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDMzMzsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAzMzM7CiAgICB0LmFzY2lpY2lyY3VtID0gNTg0OwogICAgdC51bmRlcnNjb3JlID0gNTU2OwogICAgdC5xdW90ZWxlZnQgPSAyNzg7CiAgICB0LmEgPSA1NTY7CiAgICB0LmIgPSA2MTE7CiAgICB0LmMgPSA1NTY7CiAgICB0LmQgPSA2MTE7CiAgICB0LmUgPSA1NTY7CiAgICB0LmYgPSAzMzM7CiAgICB0LmcgPSA2MTE7CiAgICB0LmggPSA2MTE7CiAgICB0LmkgPSAyNzg7CiAgICB0LmogPSAyNzg7CiAgICB0LmsgPSA1NTY7CiAgICB0LmwgPSAyNzg7CiAgICB0Lm0gPSA4ODk7CiAgICB0Lm4gPSA2MTE7CiAgICB0Lm8gPSA2MTE7CiAgICB0LnAgPSA2MTE7CiAgICB0LnEgPSA2MTE7CiAgICB0LnIgPSAzODk7CiAgICB0LnMgPSA1NTY7CiAgICB0LnQgPSAzMzM7CiAgICB0LnUgPSA2MTE7CiAgICB0LnYgPSA1NTY7CiAgICB0LncgPSA3Nzg7CiAgICB0LnggPSA1NTY7CiAgICB0LnkgPSA1NTY7CiAgICB0LnogPSA1MDA7CiAgICB0LmJyYWNlbGVmdCA9IDM4OTsKICAgIHQuYmFyID0gMjgwOwogICAgdC5icmFjZ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xMTsKICAgIHQuTSA9IDgzMzsKICAgIHQuTiA9IDcyMjsKICAgIHQuTyA9IDc3ODsKICAgIHQuUCA9IDY2NzsKICAgIHQuUSA9IDc3ODsKICAgIHQuUiA9IDcyMjsKICAgIHQuUyA9IDY2NzsKICAgIHQuVCA9IDYxMTsKICAgIHQuVSA9IDcyMjsKICAgIHQuViA9IDY2NzsKICAgIHQuVyA9IDk0NDsKICAgIHQuWCA9IDY2NzsKICAgIHQuWSA9IDY2NzsKICAgIHQuWiA9IDYxMTsKICAgIHQuYnJhY2tldGxlZnQgPSAzMzM7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzMzOwogICAgdC5hc2NpaWNpcmN1bSA9IDU4NDsKICAgIHQudW5kZXJzY29yZSA9IDU1NjsKICAgIHQucXVvdGVsZWZ0ID0gMjc4OwogICAgdC5hID0gNTU2OwogICAgdC5iID0gNjExOwogICAgdC5jID0gNTU2OwogICAgdC5kID0gNjExOwogICAgdC5lID0gNTU2OwogICAgdC5mID0gMzMzOwogICAgdC5nID0gNjExOwogICAgdC5oID0gNjExOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNTU2OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gODg5OwogICAgdC5uID0gNjExOwogICAgdC5vID0gNjExOwogICAgdC5wID0gNjExOwogICAgdC5xID0gNjExOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gNTU2OwogICAgdC50ID0gMzMzOwogICAgdC51ID0gNjExOwogICAgdC52ID0gNTU2OwogICAgdC53ID0gNzc4OwogICAgdC54ID0gNTU2OwogICAgdC55ID0gNTU2OwogICAgdC56ID0gNTAwOwogICAgdC5icmFjZWxlZnQgPSAzODk7CiAgICB0LmJhciA9IDI4MDsKICAgIHQuYnJhY2VyaWdodCA9IDM4OTsKICAgIHQuYXNjaWl0aWxkZSA9IDU4NDsKICAgIHQuZXhjbGFtZG93biA9IDMzMzsK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udGlhbCA9IDU0OTsKICAgIHQucGVyY2VudCA9IDgzMzsKICAgIHQuYW1wZXJzYW5kID0gNzc4OwogICAgdC5zdWNodGhhdCA9IDQzOTsKICAgIHQucGFyZW5sZWZ0ID0gMzMzOwogICAgdC5wYXJlbnJpZ2h0ID0gMzMzOwogICAgdC5hc3Rlcmlza21hdGggPSA1MDA7CiAgICB0LnBsdXMgPSA1NDk7CiAgICB0LmNvbW1hID0gMjUwOwogICAgdC5taW51cyA9IDU0OTsKICAgIHQucGVyaW9kID0gMjUwOwogICAgdC5zbGFzaCA9IDI3ODsKICAgIHQuemVybyA9IDUwMDsKICAgIHQub25lID0gNTAwOwogICAgdC50d28gPSA1MDA7CiAgICB0LnRocmVlID0gNTAwOwogICAgdC5mb3VyID0gNTAwOwogICAgdC5maXZlID0gNTAwOwogICAgdC5zaXggPSA1MDA7CiAgICB0LnNldmVuID0gNTAwOwogICAgdC5laWdodCA9IDUwMDsKICAgIHQubmluZSA9IDUwMDsKICAgIHQuY29sb24gPSAyNzg7CiAgICB0LnNlbWljb2xvbiA9IDI3ODsKICAgIHQubGVzcyA9IDU0OTsKICAgIHQuZXF1YWwgPSA1NDk7CiAgICB0LmdyZWF0ZXIgPSA1NDk7CiAgICB0LnF1ZXN0aW9uID0gNDQ0OwogICAgdC5jb25ncnVlbnQgPSA1NDk7CiAgICB0LkFscGhhID0gNzIyOwogICAgdC5CZXRhID0gNjY3OwogICAgdC5DaGkgPSA3MjI7CiAgICB0LkRlbHRhID0gNjEyOwogICAgdC5FcHNpbG9uID0gNjExOwogICAgdC5QaGkgPSA3NjM7CiAgICB0LkdhbW1hID0gNjAzOwogICAgdC5FdGEgPSA3MjI7CiAgICB0LklvdGEgPSAzMzM7CiAgICB0LnRoZXRhMSA9IDYzMTsKICAgIHQuS2FwcGEgPSA3MjI7CiAgICB0LkxhbWJkYSA9IDY4NjsKICAgIHQuTXUgPSA4ODk7CiAgICB0Lk51ID0gNzIyOwogICAgdC5PbWljcm9uID0gNz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DY2NzsKICAgIHQuTyA9IDcyMjsKICAgIHQuUCA9IDYxMTsKICAgIHQuUSA9IDcyMjsKICAgIHQuUiA9IDYxMTsKICAgIHQuUyA9IDUwMDsKICAgIHQuVCA9IDU1NjsKICAgIHQuVSA9IDcyMjsKICAgIHQuViA9IDYxMTsKICAgIHQuVyA9IDgzMzsKICAgIHQuWCA9IDYxMTsKICAgIHQuWSA9IDU1NjsKICAgIHQuWiA9IDU1NjsKICAgIHQuYnJhY2tldGxlZnQgPSAzODk7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzg5OwogICAgdC5hc2NpaWNpcmN1bSA9IDQyMjsKICAgIHQudW5kZXJzY29yZSA9IDUwMDsKICAgIHQucXVvdGVsZWZ0ID0gMzMzOwogICAgdC5hID0gNTAwOwogICAgdC5iID0gNTAwOwogICAgdC5jID0gNDQ0OwogICAgdC5kID0gNTAwOwogICAgdC5lID0gNDQ0OwogICAgdC5mID0gMjc4OwogICAgdC5nID0gNTAwOwogICAgdC5oID0gNTAwOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNDQ0OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gNzIyOwogICAgdC5uID0gNTAwOwogICAgdC5vID0gNTAwOwogICAgdC5wID0gNTAwOwogICAgdC5xID0gNTAwOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gMzg5OwogICAgdC50ID0gMjc4OwogICAgdC51ID0gNTAwOwogICAgdC52ID0gNDQ0OwogICAgdC53ID0gNjY3OwogICAgdC54ID0gNDQ0OwogICAgdC55ID0gNDQ0OwogICAgdC56ID0gMzg5OwogICAgdC5icmFjZWxlZnQgPSA0MDA7CiAgICB0LmJhciA9IDI3NTsKICAgIHQuYnJhY2VyaWdodCA9IDQwMDsKICAgIHQuYXNjaWl0aWxkZSA9IDU0MTsKICAgIHQuZXhjbGFtZG93biA9IDM4OTsKICAgIHQuY2VudCA9IDUwMD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kgewogICAgICAgIHhDb29yZGluYXRlcyA9IGFsbFhDb29yZGluYXRlc1tlbmRQdHNPZkNvbnRvdXJzSW5kZXhdOwogICAgICAgIGVuZFB0c09mQ29udG91cnNJbmRleCsrOwogICAgICAgIGNvbnRvdXJzLnB1c2gobmV3IENvbnRvdXIoewogICAgICAgICAgZmxhZ3M6IHBvaW50RmxhZ3MsCiAgICAgICAgICB4Q29vcmRpbmF0ZXMsCiAgICAgICAgICB5Q29vcmRpbmF0ZXMKICAgICAgICB9KSk7CiAgICAgICAgeUNvb3JkaW5hdGVzID0gW107CiAgICAgICAgcG9pbnRGbGFncyA9IFtdOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbmV3IFNpbXBsZUdseXBoKHsKICAgICAgY29udG91cnMsCiAgICAgIGluc3RydWN0aW9ucwogICAgfSk7CiAgfQogIGdldFNpemUoKSB7CiAgICBsZXQgc2l6ZSA9IHRoaXMuY29udG91cnMubGVuZ3RoICogMiArIDIgKyB0aGlzLmluc3RydWN0aW9ucy5sZW5ndGg7CiAgICBsZXQgbGFzdFggPSAwOwogICAgbGV0IGxhc3RZID0gMDsKICAgIGZvciAoY29uc3QgY29udG91ciBvZiB0aGlzLmNvbnRvdXJzKSB7CiAgICAgIHNpemUgKz0gY29udG91ci5mbGFncy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGNvbnRvdXIueENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCB4ID0gY29udG91ci54Q29vcmRpbmF0ZXNbaV07CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGxldCBhYnMgPSBNYXRoLmFicyh4IC0gbGFzdFgpOwogICAgICAgIGlmIChhYnMgPiAyNTUpIHsKICAgICAgICAgIHNpemUgKz0gMjsKICAgICAgICB9IGVsc2UgaWYgKGFicyA+IDApIHsKICAgICAgICAgIHNpemUgKz0gMTsKICAgICAgICB9CiAgICAgICAgbGFzdFggPSB4OwogICAgICAgIGFicyA9IE1hdGguYWJzKHkgLSBsYXN0WSk7CiAgICAgICAgaWYgKGFicyA+IDI1NSkgewogICAgICAgICAgc2l6ZSArPSAyOwogICAgICAgIH0gZWxzZSBpZiAoYWJzID4gMCkgewogICAgICAgICAgc2l6ZSArPSAxOwogICAgICAgIH0KICAgICAgICBsYXN0WSA9IHk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzaXplOwogIH0KICB3cml0ZShwb3MsIGJ1ZikgewogICAgY29uc3Qgc3BvcyA9IHBvczsKICAgIGNvbnN0IHhDb29yZGluYXRlcyA9IFtdOwogICAgY29uc3QgeUNvb3JkaW5hdGVzID0gW107CiAgICBjb25zdCBmbGFncyA9IFtdOwogICAgbGV0IGxhc3RYID0gMDsKICAgIGxldCBsYXN0WSA9IDA7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjb250b3VyLnhDb29yZGluYXRlcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgbGV0IGZsYWcgPSBjb250b3VyLmZsYWdzW2ldOwogICAgICAgIGNvbnN0IHggPSBjb250b3VyLnhDb29yZGluYXRlc1tpXTsKICAgICAgICBsZXQgZGVsdGEgPSB4IC0gbGFzdFg7CiAgICAgICAgaWYgKGRlbHRhID09PSAwKSB7CiAgICAgICAgICBmbGFnIHw9IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgIHhDb29yZGluYXRlcy5wdXNoKDApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBhYnMgPSBNYXRoLmFicyhkZWx0YSk7CiAgICAgICAgICBpZiAoYWJzIDw9IDI1NSkgewogICAgICAgICAgICBmbGFnIHw9IGRlbHRhID49IDAgPyBYX1NIT1JUX1ZFQ1RPUiB8IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUiA6IFhfU0hPUlRfVkVDVE9SOwogICAgICAgICAgICB4Q29vcmRpbmF0ZXMucHVzaChhYnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgeENvb3JkaW5hdGVzLnB1c2goZGVsdGEpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsYXN0WCA9IHg7CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGRlbHRhID0geSAtIGxhc3RZOwogICAgICAgIGlmIChkZWx0YSA9PT0gMCkgewogICAgICAgICAgZmxhZyB8PSBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1I7CiAgICAgICAgICB5Q29vcmRpbmF0ZXMucHVzaCgwKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgYWJzID0gTWF0aC5hYnMoZGVsdGEpOwogICAgICAgICAgaWYgKGFicyA8PSAyNTUpIHsKICAgICAgICAgICAgZmxhZyB8PSBkZWx0YSA+PSAwID8gWV9TSE9SVF9WRUNUT1IgfCBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1IgOiBZX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgICAgeUNvb3JkaW5hdGVzLnB1c2goYWJzKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHlDb29yZGluYXRlcy5wdXNoKGRlbHRhKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgbGFzdFkgPSB5OwogICAgICAgIGZsYWdzLnB1c2goZmxhZyk7CiAgICAgIH0KICAgICAgYnVmLnNldFVpbnQxNihwb3MsIHhDb29yZGluYXRlcy5sZW5ndGggLSAxKTsKICAgICAgcG9zICs9IDI7CiAgICB9CiAgICBidWYuc2V0VWludDE2KHBvcywgdGhpcy5pbnN0cnVjdGlvbnMubGV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SkgewogICAgICAgIGJ1Zi5zZXRJbnQxNihwb3MsIHkpOwogICAgICAgIHBvcyArPSAyOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zIC0gc3BvczsKICB9CiAgc2NhbGUoeCwgZmFjdG9yKSB7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBpZiAoY29udG91ci54Q29vcmRpbmF0ZXMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29udG91ci54Q29vcmRpbmF0ZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnRvdXIueENvb3JkaW5hdGVzW2ldID0gTWF0aC5yb3VuZCh4ICsgKGNvbnRvdXIueENvb3JkaW5hdGVzW2ldIC0geCkgKiBmYWN0b3IpOwogICAgICB9CiAgICB9CiAgfQp9CmNsYXNzIENvbXBvc2l0ZUdseXBoIHsKICBjb25zdHJ1Y3RvcihfcmVmNikgewogICAgbGV0IHsKICAgICAgZmxhZ3MsCiAgICAgIGdseXBoSW5kZXgsCiAgICAgIGFyZ3VtZW50MSwKICAgICAgYXJndW1lbnQyLAogICAgICB0cmFuc2YsCiAgICAgIGluc3RydWN0aW9ucwogICAgfSA9IF9yZWY2OwogICAgdGhpcy5mbGFncyA9IGZsYWdzOwogICAgdGhpcy5nbHlwaEluZGV4ID0gZ2x5cGhJbmRleDsKICAgIHRoaXMuYXJndW1lbnQxID0gYXJndW1lbnQxOwogICAgdGhpcy5hcmd1bWVudDIgPSBhcmd1bWVudDI7CiAgICB0aGlzLnRyYW5zZiA9IHRyYW5zZjsKICAgIHRoaXMuaW5zdHJ1Y3Rpb25zID0gaW5zdHJ1Y3Rpb25zOwogIH0KICBzdGF0aWMgcGFyc2UocG9zLCBnbHlmKSB7CiAgICBjb25zdCBzcG9zID0gcG9zOwogICAgY29uc3QgdHJhbnNmID0gW107CiAgIC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ICAgdGhpcy53aWR0aCA9IDA7CiAgICB0aGlzLmxzYiA9IDA7CiAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgIHRoaXMub3V0cHV0ID0gW107CiAgICB0aGlzLnN0YWNrID0gW107CiAgfQogIGNvbnZlcnQoZW5jb2RlZCwgc3VicnMsIHNlYWNBbmFseXNpc0VuYWJsZWQpIHsKICAgIGNvbnN0IGNvdW50ID0gZW5jb2RlZC5sZW5ndGg7CiAgICBsZXQgZXJyb3IgPSBmYWxzZTsKICAgIGxldCB3eCwgc2J4LCBzdWJyTnVtYmVyOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgIGxldCB2YWx1ZSA9IGVuY29kZWRbaV07CiAgICAgIGlmICh2YWx1ZSA8IDMyKSB7CiAgICAgICAgaWYgKHZhbHVlID09PSAxMikgewogICAgICAgICAgdmFsdWUgPSAodmFsdWUgPDwgOCkgKyBlbmNvZGVkWysraV07CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAodmFsdWUpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLmhzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC52c3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMSkgewogICAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGR5ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCwgZHkpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bW92ZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5ybGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC5obGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDg6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg2LCBDT01NQU5EX01BUC5ycmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgOToKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMTA6CiAgICAgICAgICAgIGlmICh0aGlzLnN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3Vick51bWJlciA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghc3VicnNbc3Vick51bWJlcl0pIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmNvbnZlcnQoc3VicnNbc3Vick51bWJlcl0sIHN1YnJzLCBzZWFjQW5hbHlzaXNFbmFibGVkKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDExOgogICAgICAgICAgICByZXR1cm4gZXJyb3I7CiAgICAgICAgICBjYXNlIDEzOgogICAgICAgICAgICBpZiAodGhpcy5zdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHd4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgc2J4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgdGhpcy5sc2IgPSBzYng7CiAgICAgICAgICAgIHRoaXMud2lkdGggPSB3eDsKICAgICAgICAgICAgdGhpcy5zdGFjay5wdXNoKHd4LCBzYngpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMiwgQ09NTUFORF9NQVAuaG1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxNDoKICAgICAgICAgICAgdGhpcy5vdXRwdXQucHVzaChDT01NQU5EX01BUC5lbmRjaGFyWzBdKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDIxOgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnJtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjI6CiAgICAgICAgICAgIGlmICh0aGlzLmZsZXhpbmcpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEsIENPTU1BTkRfTUFQLmhtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzA6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC52aGN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzE6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5odmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMDoKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnZzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDI6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5oc3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyA2OgogICAgICAgICAgICBpZiAoc2VhY0FuYWx5c2lzRW5hYmxlZCkgewogICAgICAgICAgICAgIGNvbnN0IGFzYiA9IHRoaXMuc3RhY2suYXQoLTUpOwogICAgICAgICAgICAgIHRoaXMuc2VhYyA9IHRoaXMuc3RhY2suc3BsaWNlKC00LCA0KTsKICAgICAgICAgICAgICB0aGlzLnNlYWNbMF0gKz0gdGhpcy5sc2IgLSBhc2I7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDAsIENPTU1BTkRfTUFQLmVuZGNoYXIpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5lbmRjaGFyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgNzoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgNCkgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnN0YWNrLnBvcCgpOwogICAgICAgICAgICB3eCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNvbnN0IHNieSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHNieCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMubHNiID0gc2J4OwogICAgICAgICAgICB0aGlzLndpZHRoID0gd3g7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaCh3eCwgc2J4LCBzYnkpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMywgQ09NTUFORF9NQVAucm1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxMjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBudW0yID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtMSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChudW0xIC8gbnVtMik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxNjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdWJyTnVtYmVyID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtQXJncyA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmIChzdWJyTnVtYmVyID09PSAwICYmIG51bUFyZ3MgPT09IDMpIHsKICAgICAgICAgICAgICBjb25zdCBmbGV4QXJncyA9IHRoaXMuc3RhY2suc3BsaWNlKC0xNywgMTcpOwogICAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChmbGV4QXJnc1syXSArIGZsZXhBcmdzWzBdLCBmbGV4QXJnc1szXSArIGZsZXhBcmdzWzFdLCBmbGV4QXJnc1s0XSwgZmxleEFyZ3NbNV0sIGZsZXhBcmdzWzZdLCBmbGV4QXJnc1s3XSwgZmxleEFyZ3NbOF0sIGZsZXhBcmdzWzldLCBmbGV4QXJnc1sxMF0sIGZsZXhBcmdzWzExXSwgZmxleEFyZ3NbMTJdLCBmbGV4QXJnc1sxM10sIGZsZXhBcmdzWzE0XSk7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEzLCBDT01NQU5EX01BUC5mbGV4LCB0cnVlKTsKICAgICAgICAgICAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goZmxleEFyZ3NbMTVdLCBmbGV4QXJnc1sxNl0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKHN1YnJOdW1iZXIgPT09IDEgJiYgbnVtQXJncyA9PT0gMCkgewogICAgICAgICAgICAgIHRoaXMuZmxleGluZyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDE3OgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMzM6CiAgICAgICAgICAgIHRoaXMuc3RhY2sgPSBbXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoJ1Vua25vd24gdHlwZSAxIGNoYXJzdHJpbmcgY29tbWFuZCBvZiAiJyArIHZhbHVlICsgJyInKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChlcnJvcikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlIDw9IDI0NikgewogICAgICAgIHZhbHVlIC09IDEzOTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA8PSAyNTApIHsKICAgICAgICB2YWx1ZSA9ICh2YWx1ZSAtIDI0NykgKiAyNTYg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ICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgaWYgKGlzU3BlY2lhbChjaCkpIHsKICAgICAgdGhpcy5uZXh0Q2hhcigpOwogICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICB9CiAgICBsZXQgdG9rZW4gPSAiIjsKICAgIGRvIHsKICAgICAgdG9rZW4gKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfSB3aGlsZSAoY2ggPj0gMCAmJiAhKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpICYmICFpc1NwZWNpYWwoY2gpKTsKICAgIHJldHVybiB0b2tlbjsKICB9CiAgcmVhZENoYXJTdHJpbmdzKGJ5dGVzLCBsZW5JVikgewogICAgaWYgKGxlbklWID09PSAtMSkgewogICAgICByZXR1cm4gYnl0ZXM7CiAgICB9CiAgICByZXR1cm4gZGVjcnlwdChieXRlcywgQ0hBUl9TVFJTX0VOQ1JZUFRfS0VZLCBsZW5JVik7CiAgfQogIGV4dHJhY3RGb250UHJvZ3JhbShwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCBzdHJlYW0gPSB0aGlzLnN0cmVhbTsKICAgIGNvbnN0IHN1YnJzID0gW10sCiAgICAgIGNoYXJzdHJpbmdzID0gW107CiAgICBjb25zdCBwcml2YXRlRGF0YSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBwcml2YXRlRGF0YS5sZW5JViA9IDQ7CiAgICBjb25zdCBwcm9ncmFtID0gewogICAgICBzdWJyczogW10sCiAgICAgIGNoYXJzdHJpbmdzOiBbXSwKICAgICAgcHJvcGVydGllczogewogICAgICAgIHByaXZhdGVEYXRhCiAgICAgIH0KICAgIH07CiAgICBsZXQgdG9rZW4sIGxlbmd0aCwgZGF0YSwgbGVuSVY7CiAgICB3aGlsZSAoKHRva2VuID0gdGhpcy5nZXRUb2tlbigpKSAhPT0gbnVsbCkgewogICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICBzd2l0Y2ggKHRva2VuKSB7CiAgICAgICAgY2FzZSAiQ2hhclN0cmluZ3MiOgogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gbnVsbCB8fCB0b2tlbiA9PT0gImVuZCIpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09ICIvIikgewogICAgICAgICAgICAgIHRoaXMucHJldkNoYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGFyc3RyaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBnbHlwaCwKICAgICAgICAgICAgICBlbmNvZGVkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU3VicnMiOgogICAgICAgICAgdGhpcy5yZWFkSW50KCk7CiAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICB3aGlsZSAodGhpcy5nZXRUb2tlbigpID09PSAiZHVwIikgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IHRoaXMucmVhZEludCgpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VicnNbaW5kZXhdID0gZW5jb2RlZDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVWYWx1ZXMiOgogICAgICAgIGNhc2UgIk90aGVyQmx1ZXMiOgogICAgICAgIGNhc2UgIkZhbWlseUJsdWVzIjoKICAgICAgICBjYXNlICJGYW1pbHlPdGhlckJsdWVzIjoKICAgICAgICAgIGNvbnN0IGJsdWVBcnJheSA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBpZiAoYmx1ZUFycmF5Lmxlbmd0aCA+IDAgJiYgYmx1ZUFycmF5Lmxlbmd0aCAlIDIgPT09IDAgJiYgSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSBibHVlQXJyYXk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJTdGVtU25hcEgiOgogICAgICAgIGNhc2UgIlN0ZW1TbmFwViI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlN0ZEhXIjoKICAgICAgICBjYXNlICJTdGRWVyI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKVswXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVTaGlmdCI6CiAgICAgICAgY2FzZSAibGVuSVYiOgogICAgICAgIGNhc2UgIkJsdWVGdXp6IjoKICAgICAgICBjYXNlICJCbHVlU2NhbGUiOgogICAgICAgIGNhc2UgIkxhbmd1YWdlR3JvdXAiOgogICAgICAgICAgcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhW3Rva2VuXSA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRXhwYW5zaW9uRmFjdG9yIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWROdW1iZXIoKSB8fCAwLjA2OwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9yY2VCb2xkIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWRCb29sZWFuKCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIGVuY29kZWQsCiAgICAgIGdseXBoCiAgICB9IG9mIGNoYXJzdHJpbmdzKSB7CiAgICAgIGNvbnN0IGNoYXJTdHJpbmcgPSBuZXcgVHlwZTFDaGFyU3RyaW5nKCk7CiAgICAgIGNvbnN0IGVycm9yID0gY2hhclN0cmluZy5jb252ZXJ0KGVuY29kZWQsIHN1YnJzLCB0aGlzLnNlYWNBbmFseXNpc0VuYWJsZWQpOwogICAgICBsZXQgb3V0cHV0ID0gY2hhclN0cmluZy5vdXRwdXQ7CiAgICAgIGlmIChlcnJvcikgewogICAgICAgIG91dHB1dCA9IFsxNF07CiAgICAgIH0KICAgICAgY29uc3QgY2hhclN0cmluZ09iamVjdCA9IHsKICAgICAgICBnbHlwaE5hbWU6IGdseXBoLAogICAgICAgIGNoYXJzdHJpbmc6IG91dHB1dCwKICAgICAgICB3aWR0aDogY2hhclN0cmluZy53aWR0aCwKICAgICAgICBsc2I6IGNoYXJTdHJpbmcubHNiLAogICAgICAgIHNlYWM6IGNoYXJTdHJpbmcuc2VhYwogICAgICB9OwogICAgICBpZiAoZ2x5cGggPT09ICIubm90ZGVmIikgewogICAgICAgIHByb2dyYW0uY2hhcnN0cmluZ3MudW5zaGlmdChjaGFyU3RyaW5nT2JqZWN0KTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwcm9ncmFtLmNoYXJzdHJpbmdzLnB1c2goY2hhclN0cmluZ09iamVjdCk7CiAgICAgIH0KICAgICAgaWYgKHByb3BlcnRpZXMuYnVpbHRJbkVuY29kaW5nKSB7CiAgICAgICAgY29uc3QgaW5kZXggPSBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZy5pbmRleE9mKGdseXBoKTsKICAgICAgICBpZiAoaW5kZXggPiAtMSAmJiBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPT09IHVuZGVmaW5lZCAmJiBpbmRleCA+PSBwcm9wZXJ0aWVzLmZpcnN0Q2hhciAmJiBpbmRleCA8PSBwcm9wZXJ0aWVzLmxhc3RDaGFyKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPSBjaGFyU3RyaW5nLndpZHRoOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIHByb2dyYW07CiAgfQogIGV4dHJhY3RGb250SGVhZGVyKHByb3BlcnRpZXMpIHsKICAgIGxldCB0b2tlbjsKICAgIHdoaWxlICgodG9rZW4gPSB0aGlzLmdldFRva2VuKCkpICE9PSBudWxsKSB7CiAgICAgIGlmICh0b2tlbiAhPT0gIi8iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgIHN3aXRjaCAodG9rZW4pIHsKICAgICAgICBjYXNlICJGb250TWF0cml4IjoKICAgICAgICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBwcm9wZXJ0aWVzLmZvbnRNYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJFbmNvZGluZyI6CiAgICAgICAgICBjb25zdCBlbmNvZGluZ0FyZyA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgIGxldCBlbmNvZGluZzsKICAgICAgICAgIGlmICghL15cZCskLy50ZXN0KGVuY29kaW5nQXJnKSkgewogICAgICAgICAgICBlbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShlbmNvZGluZ0FyZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlbmNvZGluZyA9IFtdOwogICAgICAgICAgICBjb25zdCBzaXplID0gcGFyc2VJbnQoZW5jb2RpbmdBcmcsIDEwKSB8IDA7CiAgICAgICAgICAgIHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBzaXplOyBqKyspIHsKICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICB3aGlsZSAodG9rZW4gIT09ICJkdXAiICYmIHRva2VuICE9PSAiZGVmIikgewogICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBpZiAodG9rZW4gPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodG9rZW4gPT09ICJkZWYiKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgY29uc3QgZ2x5cGggPSB0aGl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9IFtdOwogICAgbGV0IHZlcnRpY2VzTGVmdCA9IDA7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBjb25zdCBjb29yZCA9IHJlYWRlci5yZWFkQ29vcmRpbmF0ZSgpOwogICAgICBjb25zdCBjb2xvciA9IHJlYWRlci5yZWFkQ29tcG9uZW50cygpOwogICAgICBpZiAodmVydGljZXNMZWZ0ID09PSAwKSB7CiAgICAgICAgaWYgKCEoMCA8PSBmICYmIGYgPD0gMikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNCBmbGFnIik7CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoZikgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICB2ZXJ0aWNlc0xlZnQgPSAzOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgcHMucHVzaChwcy5hdCgtMiksIHBzLmF0KC0xKSk7CiAgICAgICAgICAgIHZlcnRpY2VzTGVmdCA9IDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBwcy5wdXNoKHBzLmF0KC0zKSwgcHMuYXQoLTEpKTsKICAgICAgICAgICAgdmVydGljZXNMZWZ0ID0gMTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9ycy5wdXNoKGYpOwogICAgICB9CiAgICAgIHBzLnB1c2goY29vcmRzLmxlbmd0aCk7CiAgICAgIGNvb3Jkcy5wdXNoKGNvb3JkKTsKICAgICAgY29sb3JzLnB1c2goY29sb3IpOwogICAgICB2ZXJ0aWNlc0xlZnQtLTsKICAgICAgcmVhZGVyLmFsaWduKCk7CiAgICB9CiAgICB0aGlzLmZpZ3VyZXMucHVzaCh7CiAgICAgIHR5cGU6ICJ0cmlhbmdsZXMiLAogICAgICBjb29yZHM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgY29sb3JzOiBuZXcgSW50MzJBcnJheShwcykKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTVTaGFkaW5nKHJlYWRlciwgdmVydGljZXNQZXJSb3cpIHsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzOwogICAgY29uc3QgY29sb3JzID0gdGhpcy5jb2xvcnM7CiAgICBjb25zdCBwcyA9IFtdOwogICAgd2hpbGUgKHJlYWRlci5oYXNEYXRhKSB7CiAgICAgIGNvbnN0IGNvb3JkID0gcmVhZGVyLnJlYWRDb29yZGluYXRlKCk7CiAgICAgIGNvbnN0IGNvbG9yID0gcmVhZGVyLnJlYWRDb21wb25lbnRzKCk7CiAgICAgIHBzLnB1c2goY29vcmRzLmxlbmd0aCk7CiAgICAgIGNvb3Jkcy5wdXNoKGNvb3JkKTsKICAgICAgY29sb3JzLnB1c2goY29sb3IpOwogICAgfQogICAgdGhpcy5maWd1cmVzLnB1c2goewogICAgICB0eXBlOiAibGF0dGljZSIsCiAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICBjb2xvcnM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgdmVydGljZXNQZXJSb3cKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTZTaGFkaW5nKHJlYWRlcikgewogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBzID0gbmV3IEludDMyQXJyYXkoMTYpOwogICAgY29uc3QgY3MgPSBuZXcgSW50MzJBcnJheSg0KTsKICAgIHdoaWxlIChyZWFkZXIuaGFzRGF0YSkgewogICAgICBjb25zdCBmID0gcmVhZGVyLnJlYWRGbGFnKCk7CiAgICAgIGlmICghKDAgPD0gZiAmJiBmIDw9IDMpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIHR5cGU2IGZsYWciKTsKICAgICAgfQogICAgICBjb25zdCBwaSA9IGNvb3Jkcy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGYgIT09IDAgPyA4IDogMTI7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29vcmRzLnB1c2gocmVhZGVyLnJlYWRDb29yZGluYXRlKCkpOwogICAgICB9CiAgICAgIGNvbnN0IGNpID0gY29sb3JzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZiAhPT0gMCA/IDIgOiA0OyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbG9ycy5wdXNoKHJlYWRlci5yZWFkQ29tcG9uZW50cygpKTsKICAgICAgfQogICAgICBsZXQgdG1wMSwgdG1wMiwgdG1wMywgdG1wNDsKICAgICAgc3dpdGNoIChmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgcHNbMTJdID0gcGkgKyAzOwogICAgICAgICAgcHNbMTNdID0gcGkgKyA0OwogICAgICAgICAgcHNbMTRdID0gcGkgKyA1OwogICAgICAgICAgcHNbMTVdID0gcGkgKyA2OwogICAgICAgICAgcHNbOF0gPSBwaSArIDI7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbN10gPSBwaSArIDQ7CiAgICAgICAgICBwc1swXSA9IHRtcDE7CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICB0bXAxID0gY3NbMl07CiAgICAgICAgICB0bXAyID0gY3NbM107CiAgICAgICAgICBjc1syXSA9IHRtcDI7CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICB0bXAxID0gcHNbMTVdOwogICAgICAgICAgdG1wMiA9IHBzWzExXTsKICAgICAgICAgIHBzWzEyXSA9IHBzWzNdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1s3XTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gdG1wMjsKICAgICAgICAgIHBzWzddID0gcGkgKyA0OwogICAgICAgICAgcHNbMF0gPSB0bXAxOwogICAgICAgICAgcHNbMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1syXSA9IHBpICsgNjsKICAgICAgICAgIHBzWzNdID0gcGkgKyA1OwogICAgICAgICAgdG1wMSA9IGNzWzNdOwogICAgICAgICAgY3NbMl0gPSBjc1sxXTsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHBzWzEyXSA9IHBzWzBdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1sxXTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gcHNbMl07CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHBzWzVdID0gY29vcmRzLmxlbmd0aDsKICAgICAgY29vcmRzLnB1c2goWygtNCAqIGNvb3Jkc1twc1swXV1bMF0gLSBjb29yZHNbcHNbMTVdXVswXSArIDYgKiAoY29vcmRzW3BzWzRdXVswXSArIGNvb3Jkc1twc1sxXV1bMF0pIC0gMiAqIChjb29yZHNbcHNbMTJdXVswXSArIGNvb3Jkc1twc1szXV1bMF0pICsgMyAqIChjb29yZHNbcHNbMTNdXVswXSArIGNvb3Jkc1twc1s3XV1bMF0pKSAvIDksICgtNCAq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y5jb2xvcnM7CiAgICBjb25zdCBwcyA9IG5ldyBJbnQzMkFycmF5KDE2KTsKICAgIGNvbnN0IGNzID0gbmV3IEludDMyQXJyYXkoNCk7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBpZiAoISgwIDw9IGYgJiYgZiA8PSAzKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNyBmbGFnIik7CiAgICAgIH0KICAgICAgY29uc3QgcGkgPSBjb29yZHMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMTIgOiAxNjsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb29yZHMucHVzaChyZWFkZXIucmVhZENvb3JkaW5hdGUoKSk7CiAgICAgIH0KICAgICAgY29uc3QgY2kgPSBjb2xvcnMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMiA6IDQ7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29sb3JzLnB1c2gocmVhZGVyLnJlYWRDb21wb25lbnRzKCkpOwogICAgICB9CiAgICAgIGxldCB0bXAxLCB0bXAyLCB0bXAzLCB0bXA0OwogICAgICBzd2l0Y2ggKGYpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBwc1sxMl0gPSBwaSArIDM7CiAgICAgICAgICBwc1sxM10gPSBwaSArIDQ7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDU7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDY7CiAgICAgICAgICBwc1s4XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzldID0gcGkgKyAxMzsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTQ7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzVdID0gcGkgKyAxMjsKICAgICAgICAgIHBzWzZdID0gcGkgKyAxNTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1syXTsKICAgICAgICAgIHRtcDIgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gdG1wMjsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIHRtcDEgPSBwc1sxNV07CiAgICAgICAgICB0bXAyID0gcHNbMTFdOwogICAgICAgICAgcHNbMTJdID0gcHNbM107CiAgICAgICAgICBwc1sxM10gPSBwaSArIDA7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDE7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDI7CiAgICAgICAgICBwc1s4XSA9IHBzWzddOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gY3NbMV07CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICBwc1sxMl0gPSBwc1swXTsKICAgICAgICAgIHBzWzEzXSA9IHBpICsgMDsKICAgICAgICAgIHBzWzE0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzE1XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzhdID0gcHNbMV07CiAgICAgICAgICBwc1s5XSA9IHBpICsgOTsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTA7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDM7CiAgICAgICAgICBwc1s0XSA9IHBzWzJdOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMuZmlndXJlcy5wdXNoKHsKICAgICAgICB0eXBlOiAicGF0Y2giLAogICAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICAgIGNvbG9yczogbmV3IEludDMyQXJyYXkoY3MpCiAgICAgIH0pOwogICAgfQogIH0KICBfYnVpbGRGaWd1cmVGcm9tUGF0Y2goaW5kZXgpIHsKICAgIGNvbnN0IGZpZ3VyZSA9IHRoaXMuZmlndXJlc1tpbmRleF07CiAgICAoMCwgX3V0aWwuYXNzZXJ0KShmaWd1cmUudHlwZSA9PT0gInBhdGNoIiwgIlVuZXhwZWN0ZWQgcGF0Y2ggbWVzaCBmaWd1cmUiKTsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzLAogICAgICBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBpID0gZmlndXJlLmNvb3JkczsKICAgIGNvbnN0IGNpID0gZmlndXJlLmNvbG9yczsKICAgIGNvbnN0IGZpZ3VyZU1pblggPSBNYXRoLm1pbihjb29yZHNbcG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SAqIHJvdykgLyBzcGxpdFlCeSB8IDA7CiAgICAgIGNyWzFdID0gKGMxWzFdICogKHNwbGl0WUJ5IC0gcm93KSArIGMzWzFdICogcm93KSAvIHNwbGl0WUJ5IHwgMDsKICAgICAgY3JbMl0gPSAoYzFbMl0gKiAoc3BsaXRZQnkgLSByb3cpICsgYzNbMl0gKiByb3cpIC8gc3BsaXRZQnkgfCAwOwogICAgICBmb3IgKGxldCBjb2wgPSAwOyBjb2wgPD0gc3BsaXRYQnk7IGNvbCsrLCBrKyspIHsKICAgICAgICBpZiAoKHJvdyA9PT0gMCB8fCByb3cgPT09IHNwbGl0WUJ5KSAmJiAoY29sID09PSAwIHx8IGNvbCA9PT0gc3BsaXRYQnkpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgbGV0IHggPSAwLAogICAgICAgICAgeSA9IDA7CiAgICAgICAgbGV0IHEgPSAwOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IDM7IGkrKykgewogICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPD0gMzsgaisrLCBxKyspIHsKICAgICAgICAgICAgY29uc3QgbSA9IGJSb3dbcm93XVtpXSAqIGJDb2xbY29sXVtqXTsKICAgICAgICAgICAgeCArPSBjb29yZHNbcGlbcV1dWzBdICogbTsKICAgICAgICAgICAgeSArPSBjb29yZHNbcGlbcV1dWzFdICogbTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZmlndXJlQ29vcmRzW2tdID0gY29vcmRzLmxlbmd0aDsKICAgICAgICBjb29yZHMucHVzaChbeCwgeV0pOwogICAgICAgIGZpZ3VyZUNvbG9yc1trXSA9IGNvbG9ycy5sZW5ndGg7CiAgICAgICAgY29uc3QgbmV3Q29sb3IgPSBuZXcgVWludDhBcnJheSgzKTsKICAgICAgICBuZXdDb2xvclswXSA9IChjbFswXSAqIChzcGxpdFhCeSAtIGNvbCkgKyBjclswXSAqIGNvbCkgLyBzcGxpdFhCeSB8I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yW2ldICE9PSAibnVtYmVyIikgewogICAgICBjb25zdCByZXN1bHQgPSBuZXcgQXJyYXkobGVuZ3RoKTsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBsZW5ndGg7IGorKykgewogICAgICAgIHJlc3VsdFtqXSA9ICthcnJbal07CiAgICAgIH0KICAgICAgcmV0dXJuIHJlc3VsdDsKICAgIH0KICB9CiAgcmV0dXJuIGFycjsKfQpjbGFzcyBQREZGdW5jdGlvbiB7CiAgc3RhdGljIGdldFNhbXBsZUFycmF5KHNpemUsIG91dHB1dFNpemUsIGJwcywgc3RyZWFtKSB7CiAgICBsZXQgaSwgaWk7CiAgICBsZXQgbGVuZ3RoID0gMTsKICAgIGZvciAoaSA9IDAsIGlpID0gc2l6ZS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGxlbmd0aCAqPSBzaXplW2ldOwogICAgfQogICAgbGVuZ3RoICo9IG91dHB1dFNpemU7CiAgICBjb25zdCBhcnJheSA9IG5ldyBBcnJheShsZW5ndGgpOwogICAgbGV0IGNvZGVTaXplID0gMDsKICAgIGxldCBjb2RlQnVmID0gMDsKICAgIGNvbnN0IHNhbXBsZU11bCA9IDEuMCAvICgyLjAgKiogYnBzIC0gMSk7CiAgICBjb25zdCBzdHJCeXRlcyA9IHN0cmVhbS5nZXRCeXRlcygobGVuZ3RoICogYnBzICsgNykgLyA4KTsKICAgIGxldCBzdHJJZHggPSAwOwogICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHdoaWxlIChjb2RlU2l6ZSA8IGJwcykgewogICAgICAgIGNvZGVCdWYgPDw9IDg7CiAgICAgICAgY29kZUJ1ZiB8PSBzdHJCeXRlc1tzdHJJZHgrK107CiAgICAgICAgY29kZVNpemUgKz0gODsKICAgICAgfQogICAgICBjb2RlU2l6ZSAtPSBicHM7CiAgICAgIGFycmF5W2ldID0gKGNvZGVCdWYgPj4gY29kZVNpemUpICogc2FtcGxlTXVsOwogICAgICBjb2RlQnVmICY9ICgxIDw8IGNvZGVTaXplKSAtIDE7CiAgICB9CiAgICByZXR1cm4gYXJyYXk7CiAgfQogIHN0YXRpYyBwYXJzZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBmbgogICAgfSA9IF9yZWYyOwogICAgY29uc3QgZGljdCA9IGZuLmRpY3QgfHwgZm47CiAgICBjb25zdCB0eXBlTnVtID0gZGljdC5nZXQoIkZ1bmN0aW9uVHlwZSIpOwogICAgc3dpdGNoICh0eXBlTnVtKSB7CiAgICAgIGNhc2UgMDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTYW1wbGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgICAgY2FzZSAxOgogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0SW50ZXJwb2xhdGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgMzoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTdGljaGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgNDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RQb3N0U2NyaXB0KHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgIH0KICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFc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PSBvdXRwdXRTaXplLAogICAgICAgIHBvcyA9IDE7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBpbnB1dFNpemU7ICsraSkgewogICAgICAgIGNvbnN0IGRvbWFpbl8yaSA9IGRvbWFpbltpXVswXTsKICAgICAgICBjb25zdCBkb21haW5fMmlfMSA9IGRvbWFpbltpXVsxXTsKICAgICAgICBjb25zdCB4aSA9IE1hdGgubWluKE1hdGgubWF4KHNyY1tzcmNPZmZzZXQgKyBpXSwgZG9tYWluXzJpKSwgZG9tYWluXzJpXzEpOwogICAgICAgIGxldCBlID0gaW50ZXJwb2xhdGUoeGksIGRvbWFpbl8yaSwgZG9tYWluXzJpXzEsIGVuY29kZVtpXVswXSwgZW5jb2RlW2ldWzFdKTsKICAgICAgICBjb25zdCBzaXplX2kgPSBzaXplW2ldOwogICAgICAgIGUgPSBNYXRoLm1pbihNYXRoLm1heChlLCAwKSwgc2l6ZV9pIC0gMSk7CiAgICAgICAgY29uc3QgZTAgPSBlIDwgc2l6ZV9pIC0gMSA/IE1hdGguZmxvb3IoZSkgOiBlIC0gMTsKICAgICAgICBjb25zdCBuMCA9IGUwICsgMSAtIGU7CiAgICAgICAgY29uc3QgbjEgPSBlIC0gZTA7CiAgICAgICAgY29uc3Qgb2Zmc2V0MCA9IGUwICogazsKICAgICAgICBjb25zdCBvZmZzZXQxID0gb2Zmc2V0MCArIGs7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGN1YmVWZXJ0aWNlczsgaisrKSB7CiAgICAgICAgICBpZiAoaiAmIHBvcykgewogICAgICAgICAgICBjdWJlTltqXSAqPSBuMTsKICAgICAgICAgICAgY3ViZVZlcnRleFtqXSArPSBvZmZzZXQxOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3ViZU5bal0gKj0gbjA7CiAgICAgICAgICAgIGN1YmVWZXJ0ZXhbal0gKz0gb2Zmc2V0MDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgayAqPSBzaXplX2k7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7CiAgICAgIGNvbnN0IHggPSBuID09PSAxID8gc3JjW3NyY09mZnNldF0gOiBzcmNbc3JjT2Zmc2V0XSAqKiBuOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxlbmd0aDsgKytqKSB7CiAgICAgICAgZGVzdFtkZXN0T2Zmc2V0ICsgal0gPSBjMFtqXSArIHggKiBkaWZmW2pdOwogICAgICB9CiAgICB9OwogIH0KICBzdGF0aWMgY29uc3RydWN0U3RpY2hlZChfcmVmNikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBkaWN0CiAgICB9ID0gX3JlZjY7CiAgICBjb25zdCBkb21haW4gPSB0b051bWJlckFycmF5KGRpY3QuZ2V0QXJyYXkoIkRvbWFpbiIpKTsKICAgIGlmICghZG9tYWluKSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gZG9tYWluIik7CiAgICB9CiAgICBjb25zdCBpbnB1dFNpemUgPSBkb21haW4ubGVuZ3RoIC8gMjsKICAgIGlmIChpbnB1dFNpemUgIT09IDEpIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgZG9tYWluIGZvciBzdGljaGVkIGZ1bmN0aW9uIik7CiAgICB9CiAgICBjb25zdCBmbnMgPSBbXTsKICAgIGZvciAoY29uc3QgZm4gb2YgZGljdC5nZXQoIkZ1bmN0aW9ucyIpKSB7CiAgICAgIGZucy5wdXNoKHRoaXMucGFyc2UoewogICAgICAgIHhyZWYsCiAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgIGZuOiB4cmVmLmZldGNoSWZSZWYoZm4pCiAgICAgIH0pKTsKICAgIH0KICAgIGNvbnN0IGJvdW5kcyA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQm91bmRzIikpOwogICAgY29uc3QgZW5jb2RlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJFbmNvZGUiKSk7CiAgICBjb25zdCB0bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KDEpOwogICAgcmV0dXJuIGZ1bmN0aW9uIGNvbnN0cnVjdFN0aWNoZWRGbihzcmMsIHNyY09mZnNldCwgZGVzdCwgZGVzdE9mZnNldCkgewogICAgICBjb25zdCBjbGlwID0gZnVuY3Rpb24gY29uc3RydWN0U3RpY2hlZEZyb21JUkNsaXAodiwgbWluLCBtYXgpIHsKICAgICAgICBpZiAodiA+IG1heCkgewogICAgICAgICAgdiA9IG1heDsKICAgICAgICB9IGVsc2UgaWYgKHYgPCBtaW4pIHsKICAgICAgICAgIHYgPSBtaW47CiAgICAgICAgfQogICAgICAgIHJldHVybiB2OwogICAgICB9OwogICAgICBjb25zdCB2ID0gY2xpcChzcmNbc3JjT2Zmc2V0XSwgZG9tYWluWzBdLCBkb21haW5bMV0pOwogICAgICBjb25zdCBsZW5ndGggPSBib3VuZHMubGVuZ3RoOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgaWYgKHYgPCBib3VuZHNbaV0pIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBsZXQgZG1pbiA9IGRvbWFpblswXTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgZG1pbiA9IGJvdW5kc1tpIC0gMV07CiAgICAgIH0KICAgICAgbGV0IGRtYXggPSBkb21haW5bMV07CiAgICAgIGlmIChpIDwgYm91bmRzLmxlbmd0aCkgewogICAgICAgIGRtYXggPSBib3VuZHNbaV07CiAgICAgIH0KICAgICAgY29uc3Qgcm1pbiA9IGVuY29kZVsyICogaV07CiAgICAgIGNvbnN0IHJtYXggPSBlbmNvZGVbMiAqIGkgKyAxXTsKICAgICAgdG1wQnVmWzBdID0gZG1pbiA9PT0gZG1heCA/IHJtaW4gOiBybWluICsgKHYgLSBkbWluKSAqIChybWF4IC0gcm1pbikg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G9hdDMyQXJyYXkobnVtT3V0cHV0cyk7CiAgICAgIGNvbnN0IHN0YWNrID0gZXZhbHVhdG9yLmV4ZWN1dGUoaW5wdXQpOwogICAgICBjb25zdCBzdGFja0luZGV4ID0gc3RhY2subGVuZ3RoIC0gbnVtT3V0cHV0czsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bU91dHB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3RhY2tbc3RhY2tJbmRleCArIGldOwogICAgICAgIGxldCBib3VuZCA9IHJhbmdlW2kgKiAyXTsKICAgICAgICBpZiAodmFsdWUgPCBib3VuZCkgewogICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYm91bmQgPSByYW5nZVtpICogMiArIDFdOwogICAgICAgICAgaWYgKHZhbHVlID4gYm91bmQpIHsKICAgICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgIH0KICAgICAgaWYgKGNhY2hlX2F2YWlsYWJsZSA+IDApIHsKICAgICAgICBjYWNoZV9hdmFpbGFibGUtLTsKICAgICAgICBjYWNoZVtrZXldID0gb3V0cHV0OwogICAgICB9CiAgICAgIGRlc3Quc2V0KG91dHB1dCwgZGVzdE9mZnNldCk7CiAgICB9OwogIH0KfQpmdW5jdGlvbiBpc1BERkZ1bmN0aW9uKHYpIHsKICBsZXQgZm5EaWN0OwogIGlmICh2IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgZm5EaWN0ID0gdjsKICB9IGVsc2UgaWYgKHYgaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkgewogICAgZm5EaWN0ID0gdi5kaWN0OwogIH0gZWxzZSB7CiAgICByZXR1cm4gZmFsc2U7CiAgfQogIHJldHVybiBmbkRpY3QuaGFzKCJGdW5jdGlvblR5cGUiKTsKfQpjbGFzcy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md0aCA9IG9wZXJhdG9ycy5sZW5ndGg7CiAgICBsZXQgb3BlcmF0b3IsIGEsIGI7CiAgICB3aGlsZSAoY291bnRlciA8IGxlbmd0aCkgewogICAgICBvcGVyYXRvciA9IG9wZXJhdG9yc1tjb3VudGVyKytdOwogICAgICBpZiAodHlwZW9mIG9wZXJhdG9yID09PSAibnVtYmVyIikgewogICAgICAgIHN0YWNrLnB1c2gob3BlcmF0b3IpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICBjYXNlICJqeiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoIWEpIHsKICAgICAgICAgICAgY291bnRlciA9IGI7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJqIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGNvdW50ZXIgPSBhOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWJzIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5hYnMoYSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSArIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYW5kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGlmICh0eXBlb2YgYSA9PT0gImJvb2xlYW4iICYmIHR5cGVvZiBiID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYmIGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYgYik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJhdGFuIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBNYXRoLmF0YW4yKGEsIGIpIC8gTWF0aC5QSSAqIDE4MDsKICAgICAgICAgIGlmIChhIDwgMCkgewogICAgICAgICAgICBhICs9IDM2MDsKICAgICAgICAgIH0KICAgICAgICAgIHN0YWNrLnB1c2goYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJiaXRzaGlmdCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoYSA+IDApIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhIDw8IGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhID4+IGIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY2VpbGluZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguY2VpbChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3B5IjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLmNvcHkoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3MiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLmNvcyhhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZpIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKSB8IDA7CiAgICAgICAgICBzdGFjay5wdXNoKGEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZyIjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImRpdiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgLyBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImR1cCI6CiAgICAgICAgICBzdGFjay5jb3B5KDEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXEiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhID09PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4Y2giOgogICAgICAgICAgc3RhY2sucm9sbCgyLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4cCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgKiogYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmYWxzZSI6CiAgICAgICAgICBzdGFjay5wdXNoKGZhbHNlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZsb29yIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5mbG9vcihhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPj0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPiBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImlkaXYiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC8gYiB8IDApOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiaW5kZXgiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2suaW5kZXgoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPD0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsbiI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImxvZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpIC8gTWF0aC5MTjEwKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImx0IjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSA8IGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibW9kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAlIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibXVsIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAqIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibmUiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhICE9PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5lZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKC1hKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5vdCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKCFhKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2gofmEpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAib3IiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKHR5cGVvZiBhID09PSAiYm9vbGVhbiIgJiYgdHlwZW9mIGIgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfHwgYik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfCBiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInBvcCI6CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvbGwiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucm9sbChhLCBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvdW5kIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5yb3VuZChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzaW4iOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLnNpbihhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAic3FydCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguc3FydChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzdWIiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVlIjoKICAgICAgICAgIHN0YWNrLnB1c2godHJ1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVuY2F0ZSI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gYSA8IDAgPyBNYXRoLmNlaWwoYSkgOiBNYXRoLmZsb29yKGEpOwogICAgICAgICAgc3RhY2sucHVzaChhKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInhvciI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIiAmJiB0eXBlb2YgYiA9PT0gImJvb2xlYW4iKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goYSAhPT0gYik7CiAgICAgICAgICB9IGVsc2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iAgdmlzaXRNaW4obWF4KSB7CiAgICB0aGlzLnBhcnRzLnB1c2goIk1hdGgubWluKCIpOwogICAgbWF4LmFyZy52aXNpdCh0aGlzKTsKICAgIHRoaXMucGFydHMucHVzaCgiLCAiLCBtYXgubWF4LCAiKSIpOwogIH0KICB0b1N0cmluZygpIHsKICAgIHJldHVybiB0aGlzLnBhcnRzLmpvaW4oIiIpOwogIH0KfQpmdW5jdGlvbiBidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSB7CiAgaWYgKG51bTIudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIubnVtYmVyID09PSAwKSB7CiAgICByZXR1cm4gbnVtMTsKICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTEubnVtYmVyID09PSAwKSB7CiAgICByZXR1cm4gbnVtMjsKICB9CiAgaWYgKG51bTIudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgKyBudW0yLm51bWJlcik7CiAgfQogIHJldHVybiBuZXcgQXN0QmluYXJ5T3BlcmF0aW9uKCIrIiwgbnVtMSwgbnVtMiwgbnVtMS5taW4gKyBudW0yLm1pbiwgbnVtMS5tYXggKyBudW0yLm1heCk7Cn0KZnVuY3Rpb24gYnVpbGRNdWxPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbCgwKTsKICAgIH0gZWxzZSBpZiAobnVtMi5udW1iZXIgPT09IDEpIHsKICAgICAgcmV0dXJuIG51bTE7CiAgICB9IGVsc2UgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbChudW0xLm51bWJlciAqIG51bTIubnVtYmVyKTsKICAgIH0KICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICBpZiAobnVtMS5udW1iZXIgPT09IDApIHsKICAgICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKDApOwogICAgfSBlbHNlIGlmIChudW0xLm51bWJlciA9PT0gMSkgewogICAgICByZXR1cm4gbnVtMjsKICAgIH0KICB9CiAgY29uc3QgbWluID0gTWF0aC5taW4obnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgY29uc3QgbWF4ID0gTWF0aC5tYXgobnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgcmV0dXJuIG5ldyBBc3RCaW5hcnlPcGVyYXRpb24oIioiLCBudW0xLCBudW0yLCBtaW4sIG1heCk7Cn0KZnVuY3Rpb24gYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBudW0xOwogICAgfSBlbHNlIGlmIChudW0xLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgLSBudW0yLm51bWJlcik7CiAgICB9CiAgfQogIGlmIChudW0yLnR5cGUgPT09ICJiaW5hcnkiICYmIG51bTIub3AgPT09ICItIiAmJiBudW0xLnR5cGUgPT09ICJsaXRlcmFsIiAmJiBudW0xLm51bWJlciA9PT0gMSAmJiBudW0yLmFyZzEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIuYXJnMS5udW1iZXIgPT09IDEpIHsKICAg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XJhbChpdGVtKSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChpdGVtKSB7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjdnIiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtdWwiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBudW0yID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBudW0xID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTXVsT3BlcmF0aW9uKG51bTEsIG51bTIpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInN1YiI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIG51bTIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG51bTEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXhjaCI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIGFzdDEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGFzdDIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYXN0MSwgYXN0Mik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJwb3AiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImluZGV4IjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKG4pIHx8IHN0YWNrLmxlbmd0aCA8IG4pIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gbiAtIDFdOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSBuIC0gMV0gPSB0bXBWYXI7CiAgICAgICAgICBzdGFjay5wdXNoKHRtcFZhcik7CiAgICAgICAgICBpbnN0cnVjdGlvbnMucHVzaChuZXcgQXN0VmFyaWFibGVEZWZpbml0aW9uKHRtcFZhciwgYXN0MSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZHVwIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBjb2RlW2kgKyAxXSA9PT0gIm51bWJlciIgJiYgY29kZVtpICsgMl0gPT09ICJndCIgJiYgY29kZVtpICsgM10gPT09IGkgKyA3ICYmIGNvZGVbaSArIDRdID09PSAianoiICYmIGNvZGVbaSArIDVdID09PSAicG9wIiAmJiBjb2RlW2kgKyA2XSA9PT0gY29kZVtpICsgMV0pIHsKICAgICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTWluT3BlcmF0aW9uKG51bTEsIGNvZGVbaSArIDFdKSk7CiAgICAgICAgICAgIGkgKz0gNjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSAxXSA9IHRtcFZhcjsKICAgICAgICAgIHN0YWNrLnB1c2godG1wVmFyKTsKICAgICAgICAgIGluc3RydWN0aW9ucy5wdXNoKG5ldyBBc3RWYXJpYWJsZURlZmluaXRpb24odG1wVmFyLCBhc3QxKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyb2xsIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTIudHlwZSAhPT0gImxpdGVyYWwiIHx8IG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IG51bTIubnVtYmVyOwogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPD0gMCB8fCAhTnVtYmVyLmlzSW50ZWdlcihuKSB8fCAhTnVtYmVyLmlzSW50ZWdlcihqKSB8fCBzdGFjay5sZW5ndGggPCBuKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IChqICUgbiArIG4pICUgbjsKICAgICAgICAgIGlmIChqID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2sucHVzaCguLi5zdGFjay5zcGxpY2Uoc3RhY2subGVuZ3RoIC0gbiwgbiAtIGopKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgfQogICAgaWYgKHN0YWNrLmxlbmd0aCAhPT0gb3V0cHV0U2l6ZSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IHJlc3VsdCA9IFtdOwogICAgZm9yIChjb25zdCBpbnN0cnVjdGlvbiBvZiBpbnN0cnVjdGlvbnMpIHsKICAgICAg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Z3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiRU4iKSB7CiAgICAgIHR5cGVzW2ldID0gbGFzdFR5cGUgPT09ICJBTCIgPyAiQU4iIDogIkVOIjsKICAgIH0gZWxzZSBpZiAodCA9PT0gIlIiIHx8IHQgPT09ICJMIiB8fCB0ID09PSAiQUwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkFMIikgewogICAgICB0eXBlc1tpXSA9ICJSIjsKICAgIH0KICB9CiAgZm9yIChpID0gMTsgaSA8IHN0ckxlbmd0aCAtIDE7ICsraSkgewogICAgaWYgKHR5cGVzW2ldID09PSAiRVMiICYmIHR5cGVzW2kgLSAxXSA9PT0gIkVOIiAmJiB0eXBlc1tpICsgMV0gPT09ICJFTiIpIHsKICAgICAgdHlwZXNbaV0gPSAiRU4iOwogICAgfQogICAgaWYgKHR5cGVzW2ldID09PSAiQ1MiICYmICh0eXBlc1tpIC0gMV0gPT09ICJFTiIgfHwgdHlwZXNbaSAtIDFdID09PSAiQU4iKSAmJiB0eXBlc1tpICsgMV0gPT09IHR5cGVzW2kgLSAxXSkgewogICAgICB0eXBlc1tpXSA9IHR5cGVzW2kgLSAxXTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJFTiIpIHsKICAgICAgZm9yIChsZXQgaiA9IGkgLSAxOyBqID49IDA7IC0taikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gaSArIDE7IGogPCBzdHJMZW5ndGg7ICsraikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgfQogIH0KICBmb3IgKGkgPSAwOyBpIDwgc3RyTGVuZ3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiV1MiIHx8IHQgPT09ICJFUyIgfHwgdCA9PT0gIkVUIiB8fCB0ID09PSAiQ1MiKSB7CiAgICAgIHR5cGVzW2ldID0gIk9OIjsKICAgIH0KICB9CiAgbGFzdFR5cGUgPSBzb3I7CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkVOIikgewogICAgICB0eXBlc1tpXSA9IGxhc3RUeXBlID09PSAiTCIgPyAiTCIgOiAiRU4iOwogICAgfSBlbHNlIGlmICh0ID09PSAiUiIgfHwgdCA9PT0gIkwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJPTiIpIHsKICAgICAgY29uc3QgZW5kID0gZmluZFVuZXF1YWwodHlwZXMsIGkgKyAxLCAiT04iKTsKICAgICAgbGV0IGJlZm9yZSA9IHNvcjsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYmVmb3JlID0gdHlwZXNbaSAtIDFdOwogICAgICB9CiAgICAgIGxldCBhZnRlciA9IGVvcjsKICAgICAgaWYgKGVuZCArIDEgPCBzdHJMZW5ndGgpIHsKICAgICAgICBhZnRlciA9IHR5cGVzW2VuZCArIDFdOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgIT09ICJMIikgewogICAgICAgIGJlZm9yZSA9ICJSIjsKICAgICAgfQogICAgICBpZiAoYWZ0ZXIgIT09ICJMIikgewog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N3aXRjaCAoa2luZCkgewogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICB7CiAgICAgICAgICBiaXRQZXJQaXhlbCA9IDE7CiAgICAgICAgICBjb2xvclRhYmxlID0gbmV3IFVpbnQ4QXJyYXkodGhpcy5faXNNYXNrID8gWzI1NSwgMjU1LCAyNTUsIDI1NSwgMCwgMCwgMCwgMF0gOiBbMCwgMCwgMCwgMCwgMjU1LCAyNTUsIDI1NSwgMjU1XSk7CiAgICAgICAgICBjb25zdCByb3dMZW4gPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgIGNvbnN0IHJvd1NpemUgPSByb3dMZW4gKyAzICYgLTQ7CiAgICAgICAgICBpZiAocm93TGVuICE9PSByb3dTaXplKSB7CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4sIGsgKz0gcm93U2l6ZSkgewogICAgICAgICAgICAgIG5ld0RhdGEuc2V0KGRhdGEuc3ViYXJyYXkoaSwgaSArIHJvd0xlbiksIGspOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgewogICAgICAgICAgYml0UGVyUGl4ZWwgPSAyNDsKICAgICAgICAgIGlmICh3aWR0aCAmIDMpIHsKICAgICAgICAgICAgY29uc3Qgcm93TGVuID0gMyAqIHdpZHRoOwogICAgICAgICAgICBjb25zdCByb3dTaXplID0gcm93TGVuICsgMyAmIC00OwogICAgICAgICAgICBjb25zdCBleHRyYUxlbiA9IHJvd1NpemUgLSByb3dMZW47CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4pIHsKICAgICAgICAgICAgICBjb25zdCByb3cgPSBkYXRhLnN1YmFycmF5KGksIGkgKyByb3dMZW4pOwogICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgcm93TGVuOyBqICs9IDMpIHsKICAgICAgICAgICAgICAgIG5ld0RhdGFbaysrXSA9IHJvd1tqICsgMl07CiAgICAgICAgICAgICAgICBuZXdEYXRhW2srK10gPSByb3dbaiArIDFdOwogICAgICAgICAgICAgICAgbmV3RGF0YVtrKytdID0gcm93W2pdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBrICs9IGV4dHJhTGVuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGF0YS5sZW5ndGg7IGkgPCBpaTsgaSArPSAzKSB7CiAgICAgICAgICAgICAgY29uc3QgdG1wID0gZGF0YVtpXTsKICAgICAgICAgICAgICBkYXRhW2ldID0gZGF0YVtpICsgMl07CiAgICAgICAgICAgICAgZGF0YVtpICsgMl0gPSB0bXA7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgY2FzZSBfdXRpbC5JbWFnZUtpbmQuUkdCQV8zMkJQUDoKICAgICAgICBiaXRQZXJQaXhlbCA9IDMyOwogICAgICAgIGNvbXByZXNzaW9uID0gMzsKICAgICAgICBtYXNrVGFibGUgPSBuZXcgVWludDhBcnJheSg0ICsgNCArIDQgKyA0ICsgNTIpOwog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CBpID0gMDsgaSA8IGJsb2NrQ291bnRzOyBpKyspIHsKICAgICAgaWYgKGkgJiAxKSB7CiAgICAgICAgazEgPSBkYXRhVWludDMyW2ldOwogICAgICAgIGsxID0gazEgKiBDMSAmIE1BU0tfSElHSCB8IGsxICogQzFfTE9XICYgTUFTS19MT1c7CiAgICAgICAgazEgPSBrMSA8PCAxNSB8IGsxID4+PiAxNzsKICAgICAgICBrMSA9IGsxICogQzIgJiBNQVNLX0hJR0ggfCBrMSAqIEMyX0xPVyAmIE1BU0tfTE9XOwogICAgICAgIGgxIF49IGsxOwogICAgICAgIGgxID0gaDEgPDwgMTMgfCBoMSA+Pj4gMTk7CiAgICAgICAgaDEgPSBoMSAqIDUgKyAweGU2NTQ2YjY0OwogICAgICB9IGVsc2UgewogICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICBoMiBePSBrMjsKICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgfQogICAgfQogICAgazEgPSAwOwogICAgc3dpdGNoICh0YWlsTGVuZ3RoKSB7CiAgICAgIGNhc2UgMzoKICAgICAgICBrMSBePSBkYXRhW2Jsb2NrQ291bnRzICogNCArIDJdIDw8IDE2OwogICAgICBjYXNlIDI6CiAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDQgKyAxXSA8PCA4OwogICAgICBjYXNlIDE6CiAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDRdOwogICAgICAgIGsxID0gazEgKiBDMSAmIE1B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IgLSAxOwogIGNvbnN0IGNvdW50ID0gTWF0aC5taW4oTWF0aC5mbG9vcigoaSAtIGlGaXJzdFNhdmUpIC8gNCksIE1BWF9JTUFHRVNfSU5fSU5MSU5FX0lNQUdFU19CTE9DSyk7CiAgaWYgKGNvdW50IDwgTUlOX0lNQUdFU19JTl9JTkxJTkVfSU1BR0VTX0JMT0NLKSB7CiAgICByZXR1cm4gaSAtIChpIC0gaUZpcnN0U2F2ZSkgJSA0OwogIH0KICBsZXQgbWF4WCA9IDA7CiAgY29uc3QgbWFwID0gW107CiAgbGV0IG1heExpbmVIZWlnaHQgPSAwOwogIGxldCBjdXJyZW50WCA9IElNQUdFX1BBRERJTkcsCiAgICBjdXJyZW50WSA9IElNQUdFX1BBRERJTkc7CiAgZm9yIChsZXQgcSA9IDA7IHEgPCBjb3VudDsgcSsrKSB7CiAgICBjb25zdCB0cmFuc2Zvcm0gPSBhcmdzQXJyYXlbaUZpcnN0VHJhbnNmb3JtICsgKHEgPDwgMildOwogICAgY29uc3QgaW1nID0gYXJnc0FycmF5W2lGaXJzdFBJSVhPICsgKHEgPDwgMildWzBdOwogICAgaWYgKGN1cnJlbnRYICsgaW1nLndpZHRoID4gTUFYX1dJRFRIKSB7CiAgICAgIG1heFggPSBNYXRoLm1heChtYXhYLCBjdXJyZW50WCk7CiAgICAgIGN1cnJlbnRZICs9IG1heExpbmVIZWlnaHQgKyAyICogSU1BR0VfUEFERElORzsKICAgICAgY3VycmVudFggPSAwOwogICAgICBtYXhMaW5lSGVpZ2h0ID0gMDsKICAgIH0KICAgIG1hcC5wdXNoKHsKICAgICAgdHJhbnNmb3JtLAogICAgICB4OiBjdXJyZW50WCwKICAgICAgeTogY3VycmVudFksCiAgICAgIHc6IGltZy53aWR0aCwKICAgICAgaDogaW1nLmhlaWdodAogICAgfSk7CiAgICBjdXJyZW50WCArPSBpbWcud2lkdGggKyAyICogSU1BR0VfUEFERElORzsKICAgIG1heExpbmVIZWlnaHQgPSBNYXRoLm1heCht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oaXMuaW1hZ2VNYXNrfWApOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgdGhpcy5icGMgPSBiaXRzUGVyQ29tcG9uZW50OwogICAgaWYgKCF0aGlzLmltYWdlTWFzaykgewogICAgICBsZXQgY29sb3JTcGFjZSA9IGRpY3QuZ2V0UmF3KCJDUyIpIHx8IGRpY3QuZ2V0UmF3KCJDb2xvclNwYWNlIik7CiAgICAgIGlmICghY29sb3JTcGFjZSkgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSlBYIGltYWdlcyAod2hpY2ggZG8gbm90IHJlcXVpcmUgY29sb3Igc3BhY2VzKSIpOwogICAgICAgIHN3aXRjaCAoaW1hZ2UubnVtQ29tcHMpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VHcmF5Iik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBjb2xvclNwYWNlID0gX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkRldmljZVJHQiIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VDTVlLIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBKUFggaW1hZ2VzIHdpdGggJHtpbWFnZS5udW1Db21wc30gY29sb3IgY29tcG9uZW50cyBub3Qgc3VwcG9ydGVkLmApOwogICAgICAgIH0KICAgICAgfQogICAgICB0aGlzLmNvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlKHsKICAgICAgICBjczogY29sb3JTcGFjZSwKICAgICAgICB4cmVmLAogICAgICAgIHJlc291cmNlczogaXNJbmxpbmUgPyByZX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IDogZG1heCAtIGRtaW47CiAgICAgICAgdGhpcy5kZWNvZGVBZGRlbmRzW2pdID0gaXNJbmRleGVkID8gZG1pbiA6IG1heCAqIGRtaW47CiAgICAgIH0KICAgIH0KICAgIGlmIChzbWFzaykgewogICAgICB0aGlzLnNtYXNrID0gbmV3IFBERkltYWdlKHsKICAgICAgICB4cmVmLAogICAgICAgIHJlcywKICAgICAgICBpbWFnZTogc21hc2ssCiAgICAgICAgaXNJbmxpbmUsCiAgICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgIH0pOwogICAgfSBlbHNlIGlmIChtYXNrKSB7CiAgICAgIGlmIChtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBtYXNrRGljdCA9IG1hc2suZGljdCwKICAgICAgICAgIGltYWdlTWFzayA9IG1hc2tEaWN0LmdldCgiSU0iLCAiSW1hZ2VNYXNrIik7CiAgICAgICAgaWYgKCFpbWFnZU1hc2spIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSWdub3JpbmcgL01hc2sgaW4gaW1hZ2Ugd2l0aG91dCAvSW1hZ2VNYXNrLiIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aGlzLm1hc2sgPSBuZXcgUERGSW1hZ2UoewogICAgICAgICAgICB4cmVmLAogICAgICAgICAgICByZXMsCiAgICAgICAgICAgIGltYWdlOiBtYXNrLAogICAgICAgICAgICBpc0lubGluZSwKICAgICAgICAgICAgaXNNYXNrOiB0cnVlLAogICAgICAgICAgICBwZGZGdW5jdGlvbkZhY3RvcnksCiAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5tYXNrID0gbWFzazsKICAgICAgfQogICAgfQogIH0KICBzdGF0aWMgYXN5bmMgYnVpbGRJbWFnZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgcmVzLAogICAgICBpbWFnZSwKICAgICAgaXNJbmxpbmUgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWYyOwogICAgY29uc3QgaW1hZ2VEYXRhID0gaW1hZ2U7CiAgICBsZXQgc21hc2tEYXRhID0gbnVsbDsKICAgIGxldCBtYXNrRGF0YSA9IG51bGw7CiAgICBjb25zdCBzbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJTTWFzayIpOwogICAgY29uc3QgbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJNYXNrIik7CiAgICBpZiAoc21hc2spIHsKICAgICAgaWYgKHNtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBzbWFza0RhdGEgPSBzbWFzazsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIC9TTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAobWFzaykgewogICAgICBpZiAobWFzayBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtIHx8IEFycmF5LmlzQXJyYXkobWFzaykpIHsKICAgICAgICBtYXNrRGF0YSA9IG1hc2s7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbnN1cHBvcnRlZCAvTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBuZXcgUERGSW1hZ2UoewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWdlOiBpbWFnZURhdGEsCiAgICAgIGlzSW5saW5lLAogICAgICBzbWFzazogc21hc2tEYXRhLAogICAgICBtYXNrOiBtYXNrRGF0YSwKICA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bnZlcnNlRGVjb2RlCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIF9pbWFnZV9yZXNpemVyLkltYWdlUmVzaXplci5jcmVhdGVJbWFnZSh7CiAgICAgICAgICBraW5kOiBfdXRpbC5JbWFnZUtpbmQuUkdCQV8zMkJQUCwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICB3aWR0aCwKICAgICAgICAgIGhlaWdodCwKICAgICAgICAgIGludGVycG9sYXRlCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uc3QgY2FudmFzID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgY29uc3QgY3R4ID0gY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAoMCwgX2ltYWdlX3V0aWxzLmNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKSh7CiAgICAgICAgc3JjOiBpbWdBcnJheSwKICAgICAgICBkZXN0OiBpbWdEYXRhLmRhdGEsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgaW52ZXJzZURlY29kZQogICAgICB9KTsKICAgICAgY3R4LnB1dEltYWdlRGF0YShpbWdEYXRhLCAwLCAwKTsKICAgICAgY29uc3QgYml0bWFwID0gY2FudmFzLnRyYW5zZmVyVG9JbWFnZUJpdG1hcCgpOwogICAgICByZXR1cm4gewogICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGJpdG1hcAogICAgICB9OwogICAgfQogICAgcmV0dXJuIHRoaXMuY3JlYXRlUmF3TWFzayh7CiAgICAgIGltZ0FycmF5LAogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0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AgICAgICAgYnVmZmVyW2luZGV4XSA9IGRlY29kZUFuZENsYW1wKGJ1ZmZlcltpbmRleF0sIGRlY29kZUFkZGVuZHNbal0sIGRlY29kZUNvZWZmaWNpZW50c1tqXSwgbWF4KTsKICAgICAgICBpbmRleCsrOwogICAgICB9CiAgICB9CiAgfQogIGdldENvbXBvbmVudHMoYnVmZmVyKSB7CiAgICBjb25zdCBicGMgPSB0aGlzLmJwYzsKICAgIGlmIChicGMgPT09IDgpIHsKICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgIH0KICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDsKICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0OwogICAgY29uc3QgbnVtQ29tcHMgPSB0aGlzLm51bUNvbXBzOwogICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiBudW1Db21wczsKICAgIGxldCBidWZmZXJQb3MgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGlmIChicGMgPD0gOCkgewogICAgICBvdXRwdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgfSBlbHNlIGlmIChicGMgPD0gMTYpIHsKICAgICAgb3V0cHV0ID0gbmV3IFVpbnQxNkFycmF5KGxlbmd0aCk7CiAgICB9IGVsc2UgewogICAgICBvdXRwdXQgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICAgIH0KICAgIGNvbnN0IHJvd0NvbXBzID0gd2lkdGggKiBudW1Db21wczsKICAgIGNvbnN0IG1heCA9ICgxIDw8IGJwYykgLSAxOwogICAgbGV0IGkgPSAwLAogICAgICBpaSwKICAgICAgYnVmOwogICAgaWYgKGJwYyA9PT0gMSkgewogICAgICBsZXQgbWFzaywgbG9vcDFFbmQsIGxvb3AyRW5kOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGhlaWdodDsgaisrKSB7CiAgICAgICAgbG9vcDFFbmQgPSBpICsgKHJvd0NvbXBzICYgfjcpOwogICAgICAgIGxvb3AyRW5kID0gaSArIHJvd0NvbXBzOwogICAgICAgIHdoaWxlIChpIDwgbG9vcDFFbmQpIHsKICAgICAgICAgIGJ1ZiA9IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBvdXRwdXRbaV0gPSBidWYgPj4gNyAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDFdID0gYnVmID4+IDYgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyAyXSA9IGJ1ZiA+PiA1ICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgM10gPSBidWYgPj4gNCAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDRdID0gYnVmID4+IDMgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyA1XSA9IGJ1ZiA+PiAyICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgNl0gPSBidWYgPj4gMSAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDddID0gYnVmICYgMTsKICAgICAgICAgIGkgKz0gODsKICAgICAgICB9CiAgICAgICAgaWYgKGkgPCBsb29wMkVuZCkgewogICAgICAgICAgYnVmID0gYnVmZmVyW2J1ZmZlclBvcysrXTsKICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICB3aGlsZSAoaSA8IGxvb3AyRW5kKSB7CiAgICAgICAgICAgIG91dHB1dFtpKytdID0gKyEhKGJ1ZiAmIG1hc2spOwogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IGJpdHMgPSAwOwogICAgICBidWYgPSAwOwogICAgICBmb3IgKGkgPSAwLCBpaSA9IGxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgICBpZiAoaSAlIHJvd0NvbXBzID09PSAwKSB7CiAgICAgICAgICBidWYgPSAwOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChiaXRzIDwgYnBjKSB7CiAg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sKICAgICAgfQogICAgfSBlbHNlIGlmIChtYXNrKSB7CiAgICAgIGlmIChtYXNrIGluc3RhbmNlb2YgUERGSW1hZ2UpIHsKICAgICAgICBzdyA9IG1hc2sud2lkdGg7CiAgICAgICAgc2ggPSBtYXNrLmhlaWdodDsKICAgICAgICBhbHBoYUJ1ZiA9IG5ldyBVaW50OENsYW1wZWRBcnJheShzdyAqIHNoKTsKICAgICAgICBtYXNrLm51bUNvbXBzID0gMTsKICAgICAgICBtYXNrLmZpbGxHcmF5QnVmZmVyKGFscGhhQnVmKTsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHN3ICogc2g7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgICBhbHBoYUJ1ZltpXSA9IDI1NSAtIGFscGhhQnVmW2ldOwogICAgICAgIH0KICAgICAgICBpZiAoc3cgIT09IHdpZHRoIHx8IHNoICE9PSBoZWlnaHQpIHsKICAgICAgICAgIGFscGhhQnVmID0gcmVzaXplSW1hZ2VNYXNrKGFscGhhQnVmLCBtYXNrLmJwYywgc3csIHNoLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShtYXNrKSkgewogICAgICAgIGFscGhhQnVmID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0KTsKICAgICAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICAgICAgZm9yIChpID0gMCwgaWkgPSB3aWR0aCAqIGhlaWdodDsgaSA8IGlpOyArK2kpIHsKICAgICAgICAgIGxldCBvcGFjaXR5ID0gMDsKICAgICAgICAgIGNvbnN0IGltYWdlT2Zmc2V0ID0gaSAqIG51bUNvbXBzOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IG51bUNvbXBzOyArK2opIHsKICAgICAgICAgICAgY29uc3QgY29sb3IgPSBpbWFnZVtpbWFnZU9mZnNldCArIGpdOwogICAgICAgICAgICBjb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idWZmZXJbaV0gXj0gMHhmZjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGltZ0RhdGE7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuaW1hZ2UgaW5zdGFuY2VvZiBfanBlZ19zdHJlYW0uSnBlZ1N0cmVhbSAmJiAhdGhpcy5zbWFzayAmJiAhdGhpcy5tYXNrKSB7CiAgICAgICAgbGV0IGltYWdlTGVuZ3RoID0gb3JpZ2luYWxIZWlnaHQgKiByb3dCeXRlczsKICAgICAgICBpZiAoaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQgJiYgIW11c3RCZVJlc2l6ZWQpIHsKICAgICAgICAgIGxldCBpc0hhbmRsZWQgPSBmYWxzZTsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gNDsKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VSR0IiOgogICAgICAgICAgICAgIGltYWdlTGVuZ3RoID0gaW1hZ2VMZW5ndGggLyAzICogNDsKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VDTVlLIjoKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGlzSGFuZGxlZCkgewogICAgICAgICAgICBjb25zdCByZ2JhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKGltYWdlTGVuZ3RoLCB7CiAgICAgICAgICAgICAgZHJhd1dpZHRoLAogICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgZm9yY2VSR0JBOiB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RyaW5nKHMpIHsKICBmb3IgKGxldCBpID0gMCwgaWkgPSBzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgIGlmICghaXNXaGl0ZXNwYWNlKHMsIGkpKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICB9CiAgcmV0dXJuIHRydWU7Cn0KY2xhc3MgWE1MUGFyc2VyQmFzZSB7CiAgX3Jlc29sdmVFbnRpdGllcyhzKSB7CiAgICByZXR1cm4gcy5yZXBsYWNlQWxsKC8mKFteO10rKTsvZywgKGFsbCwgZW50aXR5KSA9PiB7CiAgICAgIGlmIChlbnRpdHkuc3Vic3RyaW5nKDAsIDIpID09PSAiI3giKSB7CiAgICAgICAgcmV0dXJuIFN0cmluZy5mcm9tQ29kZVBvaW50KHBhcnNlSW50KGVudGl0eS5zdWJzdHJpbmcoMiksIDE2KSk7CiAgICAgIH0gZWxzZSBpZiAoZW50aXR5LnN1YnN0cmluZygwLCAxKSA9PT0gIiMiKSB7CiAgICAgICAgcmV0dXJuIFN0cmluZy5mcm9tQ29kZVBvaW50KHBhcnNlSW50KGVudGl0eS5zdWJzdHJpbmcoMSksIDEwKSk7CiAgICAgIH0KICAgICAgc3dpdGNoIChlbnRpdHkpIHsKICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICByZXR1cm4gIjwiOwogICAgICAgIGNhc2UgImd0IjoKICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgY2FzZSAiYW1wIjoKICAgICAgICAgIHJldHVybiAiJiI7CiAgICAgICAgY2FzZSAicXVvdCI6CiAgICAgICAgICByZXR1cm4gJyInOwogICAgICAgIGNhc2UgImFwb3MiOgogICAgICAgICAgcmV0dXJuICInIjsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5vblJlc29sdmVFbnRpdHkoZW50aXR5KTsKICAgIH0pOwogIH0KICBfcGFyc2VDb250ZW50KHMsIHN0YXJ0KSB7CiAgICBjb25zdCBhdHRyaWJ1dGVzID0gW107CiAgICBsZXQgcG9zID0gc3RhcnQ7CiAgICBmdW5jdGlvbiBza2lwV3MoKSB7CiAgICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiBpc1doaXRlc3BhY2UocywgcG9zKSkgewogICAgICAgICsrcG9zOwogICAgICB9CiAgICB9CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj4iICYmIHNbcG9zXSAhPT0gIi8iKSB7CiAgICAgICsrcG9zOwogICAgfQogICAgY29uc3QgbmFtZSA9IHMuc3Vic3RyaW5nKHN0YXJ0LCBwb3MpOwogICAgc2tpcFdzKCk7CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiLyIgJiYgc1twb3NdICE9PSAiPyIpIHsKICAgICAgc2tpcFdzKCk7CiAgICAgIGxldCBhdHRyTmFtZSA9ICIiLAogICAgICAgIGF0dHJWYWx1ZSA9ICIiOwogICAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj0iKSB7CiAgICAgICAgYXR0ck5hbWUgKz0gc1twb3NdOwogICAgICAgICsrcG9zOwogICAgICB9CiAgICAgIHNraXBXcygpOwogICAgICBpZiAoc1twb3NdICE9PSAiPSIpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICArK3BvczsKICAgICAgc2tpcFdzKCk7CiAgICAgIGNvbnN0IGF0dHJFbmRDaGFyID0gc1twb3NdOwogICAgICBpZiAoYXR0ckVuZENoYXIgIT09ICciJyAmJiBhdHRyRW5kQ2hhciAhPT0gIiciKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgY29uc3QgYXR0ckVuZEluZGV4ID0gcy5pbmRleE9mKGF0dHJFbmRDaGFyLCArK3Bvcyk7CiAgICAgIG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JpbmcoYXR0clN0YXJ0LCBwb3MpOwogICAgcmV0dXJuIHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUsCiAgICAgIHBhcnNlZDogcG9zIC0gc3RhcnQKICAgIH07CiAgfQogIHBhcnNlWG1sKHMpIHsKICAgIGxldCBpID0gMDsKICAgIHdoaWxlIChpIDwgcy5sZW5ndGgpIHsKICAgICAgY29uc3QgY2ggPSBzW2ldOwogICAgICBsZXQgaiA9IGk7CiAgICAgIGlmIChjaCA9PT0gIjwiKSB7CiAgICAgICAgKytqOwogICAgICAgIGNvbnN0IGNoMiA9IHNbal07CiAgICAgICAgbGV0IHE7CiAgICAgICAgc3dpdGNoIChjaDIpIHsKICAgICAgICAgIGNhc2UgIi8iOgogICAgICAgICAgICArK2o7CiAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqKTsKICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkVuZEVsZW1lbnQocy5zdWJzdHJpbmcoaiwgcSkpOwogICAgICAgICAgICBqID0gcSArIDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiPyI6CiAgICAgICAgICAgICsrajsKICAgICAgICAgICAgY29uc3QgcGkgPSB0aGlzLl9wYXJzZVByb2Nlc3NpbmdJbnN0cnVjdGlvbihzLCBqKTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBwaS5wYXJzZWQsIGogKyBwaS5wYXJzZWQgKyAyKSAhPT0gIj8+IikgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuVW50ZXJtaW5hdGVkWG1sRGVjbGFyYXRpb24pOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLm9uUGkocGkubmFtZSwgcGkudmFsdWUpOwogICAgICAgICAgICBqICs9IHBpLnBhcnNlZCArIDI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiISI6CiAgICAgICAgICAgIGlmIChzLnN1YnN0cmluZyhqICsgMSwgaiArIDMpID09PSAiLS0iKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiLS0+IiwgaiArIDMpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDb21tZW50KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNvbW1lbnQocy5zdWJzdHJpbmcoaiArIDMsIHEpKTsKICAgICAgICAgICAgICBqID0gcSArIDM7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIDEsIGogKyA4KSA9PT0gIltDREFUQVsiKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiXV0+IiwgaiArIDgpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDZGF0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNkYXRhKHMuc3Vic3RyaW5nKGogKyA4LCBxKSk7CiAgICAgICAgICAgICAgaiA9IHEgKyAzOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMuc3Vic3RyaW5nKGogKyAxLCBqICsgOCkgPT09ICJET0NUWVBFIikgewogICAgICAgICAgICAgIGNvbnN0IHEyID0gcy5pbmRleE9mKCJbIiwgaiArIDgpOwogICAgICAgICAgICAgIGxldCBjb21wbGV4RG9jdHlwZSA9IGZhbHNlOwogICAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqICsgOCk7CiAgICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChxMiA+IDAgJiYgcSA+IHEyKSB7CiAgICAgICAgICAgICAgICBxID0gcy5pbmRleE9mKCJdPiIsIGogKyA4KTsKICAgICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbXBsZXhEb2N0eXBlID0gdHJ1ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZG9jdHlwZUNvbnRlbnQgPSBzLnN1YnN0cmluZyhqICsgOCwgcSArIChjb21wbGV4RG9jdHlwZSA/IDEgOiAwKSk7CiAgICAgICAgICAgICAgdGhpcy5vbkRvY3R5cGUoZG9jdHlwZUNvbnRlbnQpOwogICAgICAgICAgICAgIGogPSBxICsgKGNvbXBsZXhEb2N0eXBlID8gMiA6IDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuTWFsZm9ybWVkRWxlbWVudCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuX3BhcnNlQ29udGVudChzLCBqKTsKICAgICAgICAgICAgaWYgKGNvbnRlbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLk1hbGZvcm1lZEVsZW1lbnQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaXNDbG9zZWQgPSBmYWxzZTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBjb250ZW50LnBhcnNlZCwgaiArIGNvbnRlbnQucGFyc2VkICsgMikgPT09ICIvPiIpIHsKICAgICAgICAgICAgICBpc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIGNvbnRlbnQucGFyc2VkLCBqICsgY29udGVudC5wYXJzZWQgKyAxKSAhPT0gIj4iKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkJlZ2luRWxlbWVudChjb250ZW50Lm5hbWUsIGNvbnRlbnQuYXR0cmlidXRlcywgaXNDbG9zZWQpOwogICAgICAgICAgICBqICs9IGNvbnRlbnQucGFyc2VkICsgKGlzQ2xvc2VkID8gMiA6IDEpOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgd2hpbGUgKGogPCBzLmxlbmd0aCAmJiBzW2pdICE9PSAiPCIpIHsKICAgICAgICAgIGorKzsKICAgICAgICB9CiAgICAgICAgY29uc3QgdGV4dCA9IHMuc3Vic3RyaW5nKGksIGopOwogICAgICAgIHRoaXMub25UZXh0KHRoaXMuX3Jlc29sdmVFbnRpdGllcyh0ZXh0KSk7CiAgICAgIH0KICAgICAgaSA9IGo7CiAgICB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0KICAgIHJldHVybiBjaGlsZE5vZGVzW2luZGV4ICsgMV07CiAgfQogIGdldCB0ZXh0Q29udGVudCgpIHsKICAgIGlmICghdGhpcy5jaGlsZE5vZGVzKSB7CiAgICAgIHJldHVybiB0aGlzLm5vZGVWYWx1ZSB8fCAiIjsKICAgIH0KICAgIHJldHVybiB0aGlzLmNoaWxkTm9kZXMubWFwKGZ1bmN0aW9uIChjaGlsZCkgewogICAgICByZXR1cm4gY2hpbGQudGV4dENvbnRlbnQ7CiAgICB9KS5qb2luKCIiKTsKICB9CiAgZ2V0IGNoaWxkcmVuKCkgewogICAgcmV0dXJuIHRoaXMuY2hpbGROb2RlcyB8fCBbXTsKICB9CiAgaGFzQ2hpbGROb2RlcygpIHsKICAgIHJldHVybiB0aGlzLmNoaWxkTm9kZXMgJiYgdGhpcy5jaGlsZE5vZGVzLmxlbmd0aCA+IDA7CiAgfQogIHNlYXJjaE5vZGUocGF0aHMsIHBvcykgewogICAgaWYgKHBvcyA+PSBwYXRocy5sZW5ndGgpIHsKICAgICAgcmV0dXJuIHRoaXM7CiAgICB9CiAgICBjb25zdCBjb21wb25lbnQgPSBwYXRoc1twb3NdOwogICAgY29uc3Qgc3RhY2sgPSBbXTsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjb21wb25lbnQubmFtZSA9PT0gbm9kZS5ub2RlTmFtZSkgewogICAgICAgIGlmIChjb21wb25lbnQucG9zID09PSAwKSB7CiAgICAgICAgICBjb25zdCByZXMgPSBub2RlLnNlYXJjaE5vZGUocGF0aHMsIHBvcyArIDEpOwogICAgICAgICAgaWYgKHJlcyAhPT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgW3BhcmVudF0gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGxldCBzaWJsaW5nUG9zID0gMDsKICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgcGFyZW50LmNoaWxkTm9kZXMpIHsKICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5uYW1lID09PSBjaGlsZC5ub2RlTmFtZSkgewogICAgICAgICAgICAgIGlmIChzaWJsaW5nUG9zID09PSBjb21wb25lbnQucG9zKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY2hpbGQuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNpYmxpbmdQb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5vZGUuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChub2RlLmNoaWxkTm9kZXMgJiYgbm9kZS5jaGlsZE5vZGVzLmxlbmd0aCAhPT0gMCkgewogICAgICAgIHN0YWNrLnB1c2goW25vZGUsIDBdKTsKICAgICAgICBub2RlID0gbm9kZS5jaGlsZE5vZGVzWzBdOwogICAgICB9IGVsc2UgaWYgKHN0YWNrLmxlbmd0aCA9PT0gMCkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9IGVsc2UgewogICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGN1cnJlbnRQb3NdID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBjb25zdCBuZXdQb3MgPSBjdXJyZW50UG9zICsgMTsKICAgICAgICAgIGlmIChuZXdQb3MgPCBwYXJlbnQuY2hpbGROb2Rlcy5sZW5ndGgpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChbcGFyZW50LCBuZXdQb3NdKTsKICAgICAgICAgICAgbm9kZSA9IHBhcmVudC5jaGlsZE5vZGVzW25ld1Bvc107CiA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SA9IDB4ODA7CiAgICBjb25zdCBuID0gcGFkZGVkTGVuZ3RoIC0gODsKICAgIHdoaWxlIChpIDwgbikgewogICAgICBwYWRkZWRbaSsrXSA9IDA7CiAgICB9CiAgICBwYWRkZWRbaSsrXSA9IGxlbmd0aCA8PCAzICYgMHhmZjsKICAgIHBhZGRlZFtpKytdID0gbGVuZ3RoID4+IDUgJiAweGZmOwogICAgcGFkZGVkW2krK10gPSBsZW5ndGggPj4gMTMgJiAweGZmOwogICAgcGFkZGVkW2krK10gPSBsZW5ndGggPj4gMjEgJiAweGZmOwogICAgcGFkZGVkW2krK10gPSBsZW5ndGggPj4+IDI5ICYgMHhmZjsKICAgIHBhZGRlZFtpKytdID0gMDsKICAgIHBhZGRlZFtpKytdID0gMDsKICAgIHBhZGRlZFtpKytdID0gMDsKICAgIGNvbnN0IHcgPSBuZXcgSW50MzJBcnJheSgxNik7CiAgICBmb3IgKGkgPSAwOyBpIDwgcGFkZGVkTGVuZ3RoOykgewogICAgICBmb3IgKGogPSAwOyBqIDwgMTY7ICsraiwgaSArPSA0KSB7CiAgICAgICAgd1tqXSA9IHBhZGRlZFtpXSB8IHBhZGRlZFtpICsgMV0gPDwgOCB8IHBhZGRlZFtpICsgMl0gPDwgMTYgfCBwYWRkZWRbaSArIDNdIDw8IDI0OwogICAgICB9CiAgICAgIGxldCBhID0gaDAsCiAgICAgICAgYiA9IGgxLAogICAgICAgIGMgPSBoMiwKICAgICAgICBkID0gaDMsCiAgICAgICAgZiwKICAgICAgICBnOwogICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7ICsraikgewogICAgICAgIGlmIChqIDwgMTYpIHsKICAgICAgICAgIGYgPSBiICYgYyB8IH5iICYgZDsKICAgICAgICAgIGcgPSBqOwogICAgICAgIH0gZWxzZSBpZiAoaiA8IDMyKSB7CiAgICAgICAgICBmID0gZCAmIGIgfCB+ZCAmIGM7CiAgICAgICAgICBnID0gNSAqIGogKyAxICYgMTU7CiAgICAgICAgfSBlbHNlI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5ldyBVaW50MzJBcnJheSg2NCk7CiAgICBmb3IgKGkgPSAwOyBpIDwgcGFkZGVkTGVuZ3RoOykgewogICAgICBmb3IgKGogPSAwOyBqIDwgMTY7ICsraikgewogICAgICAgIHdbal0gPSBwYWRkZWRbaV0gPDwgMjQgfCBwYWRkZWRbaSArIDFdIDw8IDE2IHwgcGFkZGVkW2kgKyAyXSA8PCA4IHwgcGFkZGVkW2kgKyAzXTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0KICAgICAgZm9yIChqID0gMTY7IGogPCA2NDsgKytqKSB7CiAgICAgICAgd1tqXSA9IGxpdHRsZVNpZ21hUHJpbWUod1tqIC0gMl0pICsgd1tqIC0gN10gKyBsaXR0bGVTaWdtYSh3W2ogLSAxNV0pICsgd1tqIC0gMTZdIHwgMDsKICAgICAgfQogICAgICBsZXQgYSA9IGgwLAogICAgICAgIGIgPSBoMSwKICAgICAgICBjID0gaDIsCiAgICAgICAgZCA9IGgzLAogICAgICAgIGUgPSBoNCwKICAgICAgICBmID0gaDUsCiAgICAgICAgZyA9IGg2LAogICAgICAgIGggPSBoNywKICAgICAgICB0MSwKICAgICAgICB0MjsKICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyArK2opIHsKICAgICAgICB0MSA9IGggKyBzaWdtYVByaW1lKGUpICsgY2goZSwgZiwgZykgKyBrW2pdICsgd1tqXTsKICAgICAgICB0MiA9IHNpZ21hKGEpICsgbWFqKGEsIGIsIGMpOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGUgPSBkICsgdDEgfCAwOwogICAgICAgIGQgPSBjOwogICAgICAgIGMgPSBiOwogICAgICAgIGIgPSBhOwogICAgICAgIGEgPSB0MSArIHQyIHwgMDsKICAgICAgfQogICAgICBoMCA9IGgwICsgYSB8IDA7CiAgICAgIGgxID0gaDEgKyBiIHwgMDsKICAgICAgaDIgPSBoMiArIGMgfCAwOwogICAgICBoMyA9IGgzICsgZCB8I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iAgICAgICAgd1tqXS5sb3cgPSBwYWRkZWRbaSArIDRdIDw8IDI0IHwgcGFkZGVkW2kgKyA1XSA8PCAxNiB8IHBhZGRlZFtpICsgNl0gPDwgOCB8IHBhZGRlZFtpICsgN107CiAgICAgICAgaSArPSA4OwogICAgICB9CiAgICAgIGZvciAoaiA9IDE2OyBqIDwgODA7ICsraikgewogICAgICAgIHRtcDMgPSB3W2pdOwogICAgICAgIGxpdHRsZVNpZ21hUHJpbWUodG1wMywgd1tqIC0gMl0sIHRtcDIpOwogICAgICAgIHRtcDMuYWRkKHdbaiAtIDddKTsKICAgICAgICBsaXR0bGVTaWdtYSh0bXAxLCB3W2ogLSAxNV0sIHRtcDIpOwogICAgICAgIHRtcDMuYWRkKHRtcDEpOwogICAgICAgIHRtcDMuYWRkKHdbaiAtIDE2XSk7CiAgICAgIH0KICAgICAgYS5hc3NpZ24oaDApOwogICAgICBiLmFzc2lnbihoMSk7CiAgICAgIGMuYXNzaWduKGgyKTsKICAgICAgZC5hc3NpZ24oaDMpOwogICAgICBlLmFzc2lnbihoNCk7CiAgICAgIGYuYXNzaWduKGg1KTsKICAgICAgZy5hc3NpZ24oaDYpOwogICAgICBoLmFzc2lnbihoNyk7CiAgICAgIGZvciAoaiA9IDA7IGogPCA4MDsgKytqKSB7CiAgICAgICAgdDEuYXNzaWduKGgpOwogICAgICAgIHNpZ21hUHJpbWUodG1wMSwgZSwgdG1wMik7CiAgICAgICAgdDEuYWRkKHRtcDEpOwogICAgICAgIGNoKHRtcDEsIGUsIGYsIGcsIHRtcDIpOwogICAgICAgIHQxLmFkZCh0bXAxKTsKICAgICAgICB0MS5hZGQoa1tqXSk7CiAgICAgICAgdDEuYWRkKHdbal0pOwogICAgICAgIHNpZ21hKHQyLCBhLCB0bXAyKTsKICAgICAgICBtYWoodG1wMSwgYSwgYiwgYywgdG1wMik7CiAgICAgICAgdDIuYWRkKHRtcDEpOwogICAgICAgIHRtcDMgPSBoOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGQuYWRkKHQxKTsKICAgICAgICBlID0gZDsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYTsKICAgICAgICB0bXAzLmFzc2lnbih0MSk7CiAgICAgICAgdG1wMy5hZGQodDIpOwogICAgICAgIGEgPSB0bXAzOwogICAgICB9CiAgICAgIGgwLmFkZChhKTsKICAgICAgaDEuYWRkKGIpOwogICAgICBoMi5hZGQoYyk7CiAgICAgIGgzLmFkZChkKTsKICAgICAgaDQuYWRkKGUpOwogICAgICBoNS5hZGQoZik7CiAgICAgIGg2LmFkZChnKTsKICAgICAgaDcuYWRkKGgpOwogICAgfQogICAgbGV0IHJlc3VsdDsKICAgIGlmICghbW9kZTM4NCkgewogICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheSg2NCk7CiAgICAgIGgwLmNvcHlUbyhyZXN1bHQsIDApOwogICAgICBoMS5jb3B5VG8ocmVzdWx0LCA4KTsKICAgICAgaDIuY29weVRvKHJlc3VsdCwgMTYpOwogICAgICBoMy5jb3B5VG8ocmVzdWx0LCAyNCk7CiAgICAgIGg0LmNvcHlUbyhyZXN1bHQsIDMyKTsKICAgICAgaDUuY29weVRvKHJlc3VsdCwgNDApOwogICAgICBoNi5jb3B5VG8ocmVzdWx0LCA0OCk7CiAgICAgIGg3LmNvcHlUbyhyZXN1bHQsIDU2KTsKICAgIH0gZWxzZSB7CiAgICAgIHJlc3VsdCA9IG5ldyBVaW50OEFycmF5KDQ4KTsKICAgICAgaDAuY29weVRvKHJlc3VsdCwgMCk7CiAgICAgIGgxLmNvcHlUbyhyZXN1bHQsIDgpOwogICAgICBoMi5jb3B5VG8ocmVzdWx0LCAxNik7CiAgICAgIGgzLmNvcHlUbyhyZXN1bHQsIDI0KTsKICAgICAgaDQuY29weVRvKHJlc3VsdCwgMzIpOwogICAgICBoNS5jb3B5VG8ocmVzdWx0LCA0MCk7CiAgICB9CiAgICByZX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bMTBdOwogICAgICBzdGF0ZVs2XSA9IHN0YXRlWzE0XTsKICAgICAgc3RhdGVbMTBdID0gdjsKICAgICAgc3RhdGVbMTRdID0gdTsKICAgICAgdiA9IHN0YXRlWzNdOwogICAgICB1ID0gc3RhdGVbN107CiAgICAgIHQgPSBzdGF0ZVsxMV07CiAgICAgIHN0YXRlWzNdID0gc3RhdGVbMTVdOwogICAgICBzdGF0ZVs3XSA9IHY7CiAgICAgIHN0YXRlWzExXSA9IHU7CiAgICAgIHN0YXRlWzE1XSA9IHQ7CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7IGogKz0gNCkgewogICAgICAgIGNvbnN0IHMwID0gc3RhdGVbaiArIDBdOwogICAgICAgIGNvbnN0IHMxID0gc3RhdGVbaiArIDFdOwogICAgICAgIGNvbnN0IHMyID0gc3RhdGVbaiArIDJdOwogICAgICAgIGNvbnN0IHMzID0gc3RhdGVbaiArIDNdOwogICAgICAgIHQgPSBzMCBeIHMxIF4gczIgXiBzMzsKICAgICAgICBzdGF0ZVtqICsgMF0gXj0gdCBeIHRoaXMuX21peENvbFtzMCBeIHMxXTsKICAgICAgICBzdGF0ZVtqICsgMV0gXj0gdCBeIHRoaXMuX21peENvbFtzMSBeIHMyXTsKICAgICAgICBzdGF0ZVtqICsgMl0gXj0gdCBeIHRoaXMuX21peENvbFtzMiBeIHMzXTsKICAgICAgICBzdGF0ZVtqICsgM10gXj0gdCBeIHRoaXMuX21peENvbFtzMyBeIHMwXTsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gMCwgayA9IGkgKiAxNjsgaiA8IDE2OyArK2osICsraykgewogICAgICAgIHN0YXRlW2pdIF49IGtleVtrXTsKICAgICAgfQogICAgfQogICAgZm9yIChsZXQgaiA9IDA7IGogPCAxNjsgKytqKSB7CiAgICAgIHN0YXRlW2pdID0gc1tzdGF0ZVtqXV07CiAgICB9CiAgICB2ID0gc3RhdGVbMV07CiAgICBzdGF0ZVsxXSA9IHN0YXRlWzVdO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lbmd0aCA9IDE2ICogcmVzdWx0Lmxlbmd0aDsKICAgIGNvbnN0IG91dHB1dCA9IG5ldyBVaW50OEFycmF5KG91dHB1dExlbmd0aCk7CiAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGlpOyArK2ksIGogKz0gMTYpIHsKICAgICAgb3V0cHV0LnNldChyZXN1bHRbaV0sIGopOwogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9Cn0KY2xhc3MgQUVTMTI4Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTA7CiAgICB0aGlzLl9rZXlTaXplID0gMTYwOwogICAgdGhpcy5fcmNvbiA9IG5ldyBVaW50OEFycmF5KFsweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkXSk7CiAgICB0aGlzLl9rZXkgPSB0aGlzLl9leHBhbmRLZXkoa2V5KTsKICB9CiAgX2V4cGFuZEtleShjaXBoZXJLZXkpIHsKICAgIGNvbnN0IGIgPSAxNzY7CiAgICBjb25zdCBzID0gdGhpcy5fczsKICAgIGNvbnN0IHJjb24gPSB0aGlzLl9yY29uOwogICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkoYik7CiAgICByZXN1bHQuc2V0KGNpcGhlcktleSk7CiAgICBmb3IgKGxldCBqID0gMTYsIGkgPSAxOyBqIDwgYjsgKytpKSB7CiAgICAgIGxldCB0MSA9IHJlc3VsdFtqIC0gM107CiAgICAgIGxldCB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgIGxldCB0MyA9IHJlc3VsdFtqIC0gMV07CiAgICAgIGxldCB0NCA9IHJlc3VsdFtqIC0gNF07CiAgICAgIHQxID0gc1t0MV07CiAgICAgIHQyID0gc1t0Ml07CiAgICAgIHQzID0gc1t0M107CiAgICAgIHQ0ID0gc1t0NF07CiAgICAgIHQxIF49IHJjb25baV07CiAgICAgIGZvciAobGV0IG4gPSAwOyBuIDwgNDsgKytuKSB7CiAgICAgICAgcmVzdWx0W2pdID0gdDEgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQyIF49IHJlc3VsdFtqIC0gMTZdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0MyBePSByZXN1bHRbaiAtIDE2XTsKICAgICAgICBq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IuYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1ldGFkYXRhIiwgbWV0YWRhdGEpOwogIH0KICBnZXQgbWFya0luZm8oKSB7CiAgICBsZXQgbWFya0luZm8gPSBudWxsOwogICAgdHJ5IHsKICAgICAgbWFya0luZm8gPSB0aGlzLl9yZWFkTWFya0luZm8oKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmFibGUgdG8gcmVhZCBtYXJrIGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1hcmtJbmZvIiwgbWFya0luZm8pOwogIH0KICBfcmVhZE1hcmtJbmZvKCkgewogICAgY29uc3Qgb2JqID0gdGhpcy5fY2F0RGljdC5nZXQoIk1hcmtJbmZvIik7CiAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IG1hcmtJbmZvID0gewogICAgICBNYXJrZWQ6IGZhbHNlLAogICAgICBVc2VyUHJvcGVydGllczogZmFsc2UsCiAgICAgIFN1c3BlY3RzOiBmYWxzZQogICAgfTsKICAgIGZvciAoY29uc3Qga2V5IGluIG1hcmtJbmZvKSB7CiAgICAgIGNvbnN0IHZhbHVlID0gb2JqLmdldChrZXkpOwogICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAiYm9vbGVhbiIpIHsKICAgICAgICBtYXJrSW5mb1trZXldID0gdmFsdWU7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXJrSW5mbzsKICB9CiAgZ2V0IHN0cnVjdFRyZWVSb290KCkgewogICAgbGV0IHN0cnVj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VldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBpID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29uc3Qgb3V0bGluZURpY3QgPSB4cmVmLmZldGNoSWZSZWYoaS5vYmopOwogICAgICBpZiAob3V0bGluZURpY3QgPT09IG51bGwpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIW91dGxpbmVEaWN0LmhhcygiVGl0bGUiKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBvdXRsaW5lIGl0ZW0gZW5jb3VudGVyZWQuIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YSA9IHsKICAgICAgICB1cmw6IG51bGwsCiAgICAgICAgZGVzdDogbnVsbCwKICAgICAgICBhY3Rpb246IG51bGwKICAgICAgfTsKICAgICAgQ2F0YWxvZy5wYXJzZURlc3REaWN0aW9uYXJ5KHsKICAgICAgICBkZXN0RGljdDogb3V0bGluZURpY3QsCiAgICAgICAgcmVzdWx0T2JqOiBkYXRhLAogICAgICAgIGRvY0Jhc2VVcmw6IHRoaXMucGRmTWFuYWdlci5kb2NCYXNlVXJsLAogICAgICAgIGRvY0F0dGFjaG1lbnRzOiB0aGlzLmF0dGFjaG1lbnRzCiAgICAgIH0pOwogICAgICBjb25zdCB0aXRsZSA9IG91dGxpbmVEaWN0LmdldCgiVGl0bGUiKTsKICAgICAgY29uc3QgZmxhZ3MgPSBvdXRsaW5lRGljdC5nZXQoIkYiKSB8fCAwOwogICAgICBjb25zdCBjb2xvciA9IG91dGxpbmVEaWN0LmdldEFycmF5KCJDIik7CiAgICAgIGNvbnN0IGNvdW50ID0gb3V0bGluZURpY3QuZ2V0KCJDb3VudCIpOwogICAgICBsZXQgcmdiQ29sb3IgPSBibGFja0NvbG9yOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2xvcikgJiYgY29sb3IubGVuZ3RoID09PSAzICYmIChjb2xvclswXSAhPT0gMCB8fCBjb2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vYmopOwogICAgICB9CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiTmV4dCIpOwogICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmICYmICFwcm9jZXNzZWQuaGFzKG9iaikpIHsKICAgICAgICBxdWV1ZS5wdXNoKHsKICAgICAgICAgIG9iaiwKICAgICAgICAgIHBhcmVudDogaS5wYXJlbnQKICAgICAgICB9KTsKICAgICAgICBwcm9jZXNzZWQucHV0KG9iaik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByb290Lml0ZW1zLmxlbmd0aCA+IDAgPyByb290Lml0ZW1zIDogbnVsbDsKICB9CiAgZ2V0IHBlcm1pc3Npb25zKCkgewogICAgbGV0IHBlcm1pc3Npb25zID0gbnVsbDsKICAgIHRyeSB7CiAgICAgIHBlcm1pc3Npb25zID0gdGhpcy5fcmVhZFBlcm1pc3Npb25zKCk7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoZXggaW5zdGFuY2VvZiBfY29yZV91dGlscy5NaXNzaW5nRGF0YUV4Y2VwdGlvbikgewogICAgICAgIHRocm93IGV4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5hYmxlIHRvIHJlYWQgcGVybWlzc2lvbnMuIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInBlcm1pc3Npb25zIiwgcGVybWlzc2lvbnMpOwogIH0KICBfcmVhZFBlcm1pc3Npb25zKCkgewogICAgY29uc3QgZW5jcnlwdCA9IHRoaXMueHJlZi50cmFpbGVyLmdldCgiRW5jcnlwdCIpOwogICAgaWYgKCEoZW5jcnlwdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IGZsYWdzID0gZW5jcnlwdC5nZXQoIlAiKTsKICAgIGlmICh0eXBlb2YgZmxhZ3MgIT09ICJudW1iZXIiKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgZmxhZ3MgKz0gMiAqKiAzMjsKICAgIGNvbnN0IHBlcm1pc3Npb25zID0gW107CiAgICBmb3IgKGNvbnN0IGtleSBpbiBfdXRpbC5QZXJtaXNzaW9uRmxhZykgewogICAgICBjb25zdCB2YWx1ZSA9IF91dGlsLlBlcm1pc3Npb25GbGFnW2tleV07CiAgICAgIGlmIChmbGFncyAmIHZhbHVlKSB7CiAgICAgICAgcGVybWlzc2lvbnMucHVzaCh2YWx1ZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBwZXJtaXNzaW9uczsKICB9CiAgZ2V0IG9wdGlvbmFsQ29udGVudENvbmZpZygpIHsKICAgIGxldCBjb25maWcgPSBudWxsOwogICAgdHJ5IHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPQ1Byb3BlcnRpZXMiKTsKICAgICAgaWYgKCFwcm9wZXJ0aWVzKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBkZWZhdWx0Q29uZmlnID0gcHJvcGVydGllcy5nZXQoIkQiKTsKICAgICAgaWYgKCFkZWZhdWx0Q29uZmlnKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHNEYXRhID0gcHJvcGVydGllcy5nZXQoIk9DR3MiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGdyb3Vwc0RhdGEpKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHMgPSBbXTsKICAgICAgY29uc3QgZ3JvdXBSZWZzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgZ3JvdXBzRGF0YSkgewogICAgICAgIGlmICghKGdyb3VwUmVmIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGdyb3VwUmVmcy5wdXNoKGdyb3VwUmVmKTsKICAgICAgICBjb25zdCBncm91cCA9IHRoaXMueHJlZi5mZXRjaElmUmVmKGdyb3VwUmVmKTsKICAgICAgICBncm91cHMucHVzaCh7CiAgICAgICAgICBpZDogZ3JvdXBSZWYudG9TdHJpbmcoKSwKICAgICAgICAgIG5hbWU6IHR5cGVvZiBncm91cC5nZXQoIk5hbWUiKSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGdyb3VwLmdldCgiTmFtZSIpKSA6IG51bGwsCiAgICAgICAgICBpbnRlbnQ6IHR5cGVvZiBncm91cC5nZXQoIkludGVudCIpID09PSAic3RyaW5nIiA/ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoZ3JvdXAuZ2V0KCJJbnRlbnQiKSkgOiBudWxsCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uZmlnID0gdGhpcy5fcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhkZWZhdWx0Q29uZmlnLCBncm91cFJlZnMpOwogICAgICBjb25maWcuZ3JvdXBzID0gZ3JvdXBzOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFVuYWJsZSB0byByZWFkIG9wdGlvbmFsIGNvbnRlbnQgY29uZmlnOiAke2V4fWApOwogICAgfQogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBjb25maWcpOwogIH0KICBfcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhjb25maWcsIGNvbnRlbnRHcm91cFJlZnMpIHsKICAgIGZ1bmN0aW9uIHBhcnNlT25PZmYocmVmcykgewogICAgICBjb25zdCBvblBhcnNlZCA9IFtdOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShyZWZzKSkgewogICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgcmVmcykgewogICAgICAgICAgaWYgKCEodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbnRlbnRHcm91cFJlZnMuaW5jbHVkZXModmFsdWUpKSB7CiAgICAgICAgICAgIG9uUGFyc2VkLnB1c2godmFsdWUudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvblBhcnNlZDsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlT3JkZXIocmVmcykgewogICAgICBsZXQgbmVzdGVkTGV2ZWxzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmVmcykpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBvcmRlciA9IFtdOwogICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHJlZnMpIHsKICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYgJiYgY29udGVudEdyb3VwUmVmcy5pbmNsdWRlcyh2YWx1ZSkpIHsKICAgICAgICAgIHBhcnNlZE9yZGVyUmVmcy5wdXQodmFsdWUpOwogICAgICAgICAgb3JkZXIucHVzaCh2YWx1ZS50b1N0cmluZygpKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBuZXN0ZWRPcmRlciA9IHBhcnNlTmVzdGVkT3JkZXIodmFsdWUsIG5lc3RlZExldmVscyk7CiAgICAgICAgaWYgKG5lc3RlZE9yZGVyKSB7CiAgICAgICAgICBvcmRlci5wdXNoKG5lc3RlZE9yZGVyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKG5lc3RlZExldmVscyA+IDApIHsKICAgICAgICByZXR1cm4gb3JkZXI7CiAgICAgIH0KICAgICAgY29uc3QgaGlkZGVuR3JvdXBzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgY29udGVudEdyb3VwUmVmcykgewogICAgICAgIGlmIChwYXJzZWRPcmRlclJlZnMuaGFzKGdyb3VwUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGhpZGRlbkdyb3Vwcy5wdXNoKGdyb3VwUmVmLnRvU3RyaW5nKCkpOwogICAgICB9CiAgICAgIGlmIChoaWRkZW5Hcm91cHMubGVuZ3RoKSB7CiAgICAgICAgb3JkZXIucHVzaCh7CiAgICAgICAgICBuYW1lOiBudWxsLAogICAgICAgICAgb3JkZXI6IGhpZGRlbkdyb3VwcwogICAgICAgIH0pOwogICAgICB9CiAgICAgIHJldHVybiBvcmRlcjsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlTmVzdGVkT3JkZXIocmVmLCBuZXN0ZWRMZXZlbHMpIHsKICAgICAgaWYgKCsrbmVzdGVkTGV2ZWxzID4gTUFYX05FU1RFRF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoInBhcnNlTmVzdGVkT3JkZXIgLSByZWFjaGVkIE1BWF9ORVNURURfTEVWRUxTLiIpOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGNvbnN0IHZhbHVlID0ge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hpcy5fcGFnZXNDb3VudDsKICB9CiAgZ2V0IGRlc3RpbmF0aW9ucygpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMuX3JlYWREZXN0cygpLAogICAgICBkZXN0cyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBpZiAob2JqIGluc3RhbmNlb2YgX25hbWVfbnVtYmVyX3RyZWUuTmFtZVRyZWUpIHsKICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2Ygb2JqLmdldEFsbCgpKSB7CiAgICAgICAgY29uc3QgZGVzdCA9IGZldGNoRGVzdGluYXRpb24odmFsdWUpOwogICAgICAgIGlmIChkZXN0KSB7CiAgICAgICAgICBkZXN0c1soMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGtleSldID0gZGVzdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBvYmouZm9yRWFjaChmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgIGNvbnN0IGRlc3QgPSBmZXRjaERlc3RpbmF0aW9uKHZhbHVlKTsKICAgICAgICBpZiAoZGVzdCkgewogICAgICAgICAgZGVzdHNba2V5XSA9IGRlc3Q7CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiZGVzdGluYXRpb25zIiwgZGVzdHMpOwogIH0KICBnZXREZXN0aW5hdGlvbihpZCkgewogICAgY29uc3Qgb2JqID0gdGhpcy5fcmVhZERlc3RzKCk7CiAgICBpZiAob2JqIGluc3RhbmNlb2YgX25hbWVfbnVtYmVyX3RyZWUuTmFtZVRyZWUpIHsKICAgICAgY29uc3QgZGVzdCA9IGZldGNoRGVzdGluYXRpb24ob2JqLmdldChpZCkpOwogICAgICBpZiAoZGVzdCkgewogICAgICAgIHJldHVybiBkZXN0OwogICAgICB9CiAgICAgIG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iVHlwZSIpLCAiUGFnZUxhYmVsIikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCB0eXBlIGluIFBhZ2VMYWJlbCBkaWN0aW9uYXJ5LiIpOwogICAgICAgIH0KICAgICAgICBpZiAobGFiZWxEaWN0LmhhcygiUyIpKSB7CiAgICAgICAgICBjb25zdCBzID0gbGFiZWxEaWN0LmdldCgiUyIpOwogICAgICAgICAgaWYgKCEocyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdHlsZSBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIHN0eWxlID0gcy5uYW1lOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBzdHlsZSA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmIChsYWJlbERpY3QuaGFzKCJQIikpIHsKICAgICAgICAgIGNvbnN0IHAgPSBsYWJlbERpY3QuZ2V0KCJQIik7CiAgICAgICAgICBpZiAodHlwZW9mIHAgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBwcmVmaXggaW4gUGFnZUxhYmVsIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICB9CiAgICAgICAgICBwcmVmaXggPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcmVmaXggPSAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGxhYmVsRGljdC5oYXMoIlN0IikpIHsKICAgICAgICAgIGNvbnN0IHN0ID0gbGFiZWxEaWN0LmdldCgiU3QiKTsKICAgICAgICAgIGlmICghKE51bWJlci5pc0ludGVnZXIoc3QpICYmIHN0ID49IDEpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdGFydCBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50SW5kZXggPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICBzd2l0Y2ggKHN0eWxlKSB7CiAgICAgICAgY2FzZSAiRCI6CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjdXJyZW50SW5kZXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJSIjoKICAgICAgICBjYXNlICJyIjoKICAgICAgICAgIGN1cnJlbnRMYWJlbCA9ICgwLCBfY29yZV91dGlscy50b1JvbWFuTnVtZXJhbHMpKGN1cnJlbnRJbmRleCwgc3R5bGUgPT09ICJyIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJBIjoKICAgICAgICBjYXNlICJhIjoKICAgICAgICAgIGNvbnN0IExJTUlUID0gMjY7CiAgICAgICAgICBjb25zdCBBX1VQUEVSX0NBU0UgPSAweDQxLAogICAgICAgICAgICBBX0xPV0VSX0NBU0UgPSAweDYxOwogICAgICAgICAgY29uc3QgYmFzZUNoYXJDb2RlID0gc3R5bGUgPT09ICJhIiA/IEFfTE9XRVJfQ0FTRSA6IEFfVVBQRVJfQ0FTRTsKICAgICAgICAgIGNvbnN0IGxldHRlckluZGV4ID0gY3VycmVudEluZGV4IC0gMTsKICAgICAgICAgIGNvbnN0IGNoYXJhY3RlciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoYmFzZUNoYXJDb2RlICsgbGV0dGVySW5kZXggJSBMSU1JVCk7CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjaGFyYWN0ZXIucmVwZWF0KE1hdGguZmxvb3IobGV0dGVySW5kZXggLyBMSU1JVCkgKyAxKTsKICAgICAgICAgIGJ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RG9jVGl0bGUiOgogICAgICAgIGNhc2UgIlBpY2tUcmF5QnlQREZTaXplIjoKICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk5vbkZ1bGxTY3JlZW5QYWdlTW9kZSI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlVzZU5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU91dGxpbmVzIjoKICAgICAgICAgICAgICBjYXNlICJVc2VUaHVtYnMiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU9DIjoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlLm5hbWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gIlVzZU5vbmUiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJEaXJlY3Rpb24iOgogICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICBzd2l0Y2ggKHZhbHVlLm5hbWUpIHsKICAgICAgICAgICAgICBjYXNlICJMMlIiOgogICAgICAgICAgICAgIGNhc2UgIlIyTCI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJMMlIiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJWaWV3QXJlYSI6CiAgICAgICAgY2FzZSAiVmlld0NsaXAiOgogICAgICAgIGNhc2UgIlByaW50QXJlYSI6CiAgICAgICAgY2FzZSAiUHJpbnRDbGlwIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS5uYW1lKSB7CiAgICAgICAgICAgICAgY2FzZSAiTWVkaWFCb3giOgogICAgICAgICAgICAgIGNhc2UgIkNyb3BCb3giOgogICAgICAgICAgICAgIGNhc2UgIkJsZWVkQm94IjoKICAgICAgICAgICAgICBjYXNlICJUcmltQm94IjoKICAgICAgICAgICAgICBjYXNlICJBcnRCb3giOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQ3JvcEJveCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlByaW50U2NhbGluZyI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIkFwcERlZmF1bHQiOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQXBwRGVmYXVsdCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkR1cGxleCI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlNpbXBsZXgiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBTaG9ydEVkZ2UiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBMb25nRWRnZSI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJOb25lIjsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiUHJpbnRQYWdlUmFuZ2UiOgogICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCAlIDIgPT09IDApIHsKICAgICAgICAgICAgY29uc3QgaXNWYWxpZCA9IHZhbHVlLmV2ZXJ5KChwYWdlLCBpLCBhcnIpID0+IHsKICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyLmlzSW50ZWdlcihwYWdlKSAmJiBwYWdlID4gMCAmJiAoaSA9PT0gMCB8fCBwYWdlID49IGFycltpIC0gMV0pICYmIHBhZ2UgPD0gdGhpcy5udW1QYWdlczsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkKSB7CiAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk51bUNvcGllcyI6CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkgJiYgdmFsdWUgPiAwKSB7CiAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3Jpbmcgbm9uLXN0YW5kYXJkIGtleSBpbiBWaWV3ZXJQcmVmZXJlbmNlczogJHtrZXl9LmApOwogICAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByZWZWYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBCYWQgdmFsdWUsIGZvciBrZXkgIiR7a2V5fSIsIGluIFZpZXdlclByZWZlcmVuY2VzOiAke3ZhbHVlfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIXByZWZzKSB7CiAgICAgICAgcHJlZnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICB9CiAgICAgIHByZWZzW2tleV0gPSBwcmVmVmFsdWU7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInZpZXdlclByZWZlcmVuY2VzIiwgcHJlZnMpOwogIH0KICBnZXQgb3BlbkFjdGlvbigpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPcGVuQWN0aW9uIik7CiAgICBjb25zdCBvcGVuQWN0aW9uID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGNvbnN0IGRlc3REaWN0ID0gbmV3IF9wcmltaXRpdmVzLkRpY3QodGhpcy54cmVmKTsKICAgICAgZGVzdERpY3Quc2V0KCJBIiwgb2JqKTsKICAgICAgY29uc3QgcmVzdWx0T2JqID0gewogICAgICAgIHVybDogbnVsbCwKICAgICAgICBkZXN0OiBudWxsLAogICAgICAgIGFjdGlvbjogbnVsbAogICAgICB9OwogICAgICBDYXRhbG9nLnBhcnNlRGV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s9IGNvdW50OwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh2aXNpdGVkTm9kZXMuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKTsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChjdXJyZW50Tm9kZSk7CiAgICAgICAgY29uc3Qgb2JqID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGN1cnJlbnROb2RlKTsKICAgICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgbGV0IHR5cGUgPSBvYmouZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc05hbWUpKHR5cGUsICJQYWdlIikgfHwgIW9iai5oYXMoIktpZHMiKSkgewogICAgICAgICAgICBpZiAoIXBhZ2VLaWRzQ291bnRDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUtpZHNDb3VudENhY2hlLnB1dChjdXJyZW50Tm9kZSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCFwYWdlSW5kZXhDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUluZGV4Q2FjaGUucHV0KGN1cnJlbnROb2RlLCBjdXJyZW50UGFnZUluZGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY3VycmVudFBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgcmV0dXJuIFtvYmosIGN1cnJlbnROb2RlXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyZW50UGFnZUluZGV4Kys7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChvYmopOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWQgcmVmZXJlbmNlIHBvaW50cyB0byB3cm9uZyB0eXBlIG9mIG9iamVjdC4iKTsKICAgICAgfQogICAgICBjb25zdCB7CiAgICAgICAgb2JqSWQKICAgICAgfSA9IGN1cnJlbnROb2RlOwogICAgICBsZXQgY291bnQgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIkNvdW50Iik7CiAgICAgIGlmIChjb3VudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGNvdW50ID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGNvdW50KTsKICAgICAgfQogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgJiYgY291bnQgPj0gMCkgewogICAgICAgIGlmIChvYmpJZCAmJiAhcGFnZUtpZHNDb3VudENhY2hlLmhhcyhvYmpJZCkpIHsKICAgICAgICAgIHBhZ2VLaWRzQ291bnRDYWNoZS5wdXQob2JqSWQsIGNvdW50KTsKICAgICAgICB9CiAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggKyBjb3VudCA8PSBwYWdlSW5kZXgpIHsKICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXggKz0gY291bnQ7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGtpZHMgPSBjdXJ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AgICBpZiAoZXJyb3IgaW5zdGFuY2VvZiBfY29yZV91dGlscy5YUmVmRW50cnlFeGNlcHRpb24gJiYgIXJlY292ZXJ5TW9kZSkgewogICAgICAgIHRocm93IGVycm9yOwogICAgICB9CiAgICAgIGlmIChyZWNvdmVyeU1vZGUgJiYgaWdub3JlRXJyb3JzICYmIHBhZ2VJbmRleCA9PT0gMCkgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0QWxsUGFnZURpY3RzIC0gU2tpcHBpbmcgaW52YWxpZCBmaXJzdCBwYWdlOiAiJHtlcnJvcn0iLmApOwogICAgICAgIGVycm9yID0gX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgfQogICAgICBtYXAuc2V0KHBhZ2VJbmRleCsrLCBbZXJyb3IsIG51bGxdKTsKICAgIH0KICAgIHdoaWxlIChxdWV1ZS5sZW5ndGggPiAwKSB7CiAgICAgIGNvbnN0IHF1ZXVlSXRlbSA9IHF1ZXVlLmF0KC0xKTsKICAgICAgY29uc3QgewogICAgICAgIGN1cnJlbnROb2RlLAogICAgICAgIHBvc0luS2lkcwogICAgICB9ID0gcXVldWVJdGVtOwogICAgICBsZXQga2lkcyA9IGN1cnJlbnROb2RlLmdldFJhdygiS2lkcyIpOwogICAgICBpZiAoa2lkcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGFkZFBhZ2VFcnJvcihuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChwb3NJbktpZHMgPj0ga2lkcy5sZW5ndGgpIHsKICAgICAgICBxdWV1ZS5wb3AoKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBraWRPYmogPSBraWRzW3Bvc0luS2lkc107CiAgICAgIGxldCBvYmo7CiAgICAgIGlmIChraWRPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodmlzaXRlZE5vZGVzLmhhcyhraWRPYmopKSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChraWRPYmopOwogICAgICAgIHRyeSB7CiAgICAgICAgICBvYmogPSBhd2FpdCB4cmVmLmZldGNoQXN5bmMoa2lkT2JqKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgYWRkUGFnZUVycm9yKGV4KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBvYmogPSBraWRPYmo7CiAgICAgIH0KICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlIGRpY3Rpb25hcnkga2lkIHJlZmVyZW5jZSBwb2ludHMgdG8gd3JvbmcgdHlwZSBvZiBvYmplY3QuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldCB0eXBlID0gb2JqLmdldFJhdygiVHlwZSIpOwogICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBhZGRQYWdlRGljdChvYmosIGtpZE9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiA/IGtpZE9iaiA6IG51bGwpOwogICAgICB9IGVsc2UgewogICAgICAgIHF1ZXVlLnB1c2goewogICAgICAgICAgY3VycmVudE5vZGU6IG9iaiwKICAgICAgICAgIHBvc0luS2lkczogMAogICAgICAgIH0pOwogICAgICB9CiAgICAgIHF1ZXVlSXRlbS5wb3NJbktpZHMrKzsKICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldFBhZ2VJbmRleChwYWdlUmVmKSB7CiAgICBjb25zdCBjYWNoZWRQYWdlSW5kZXggPSB0aGlzLnBhZ2VJbmRleENhY2hlLmdldChwYWdlUmVmKTsKICAgIGlmIChjYWNoZWRQYWdlSW5kZXggIT09IHVuZGVmaW5lZCkgewogICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKGNhY2hlZFBhZ2VJbmRleCk7CiAgICB9CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgZnVuY3Rpb24gcGFnZXNCZWZvcmVSZWYoa2lkUmVmKSB7CiAgICAgIGxldCB0b3RhbCA9IDAsCiAgICAgICAgcGFyZW50UmVmOwogICAgICByZXR1cm4geHJlZi5mZXRjaEFzeW5jKGtpZFJlZikudGhlbihmdW5jdGlvbiAobm9kZSkgewogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNSZWZzRXF1YWwpKGtpZFJlZiwgcGFnZVJlZikgJiYgISgwLCBfcHJpbWl0aXZlcy5pc0RpY3QpKG5vZGUsICJQYWdlIikgJiYgIShub2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCAmJiAhbm9kZS5oYXMoIlR5cGUiKSAmJiBub2RlLmhhcygiQ29udGVudHMiKSkpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVGhlIHJlZmVyZW5jZSBkb2VzIG5vdCBwb2ludCB0byBhIC9QYWdlIGRpY3Rpb25hcnkuIik7CiAgICAgICAgfQogICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICghKG5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJOb2RlIG11c3QgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgIH0KICAgICAgICBwYXJlbnRSZWYgPSBub2RlLmdldFJhdygiUGFyZW50Iik7CiAgICAgICAgcmV0dXJuIG5vZGUuZ2V0QXN5bmMoIlBhcmVudCIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChwYXJlbnQpIHsKICAgICAgICBpZiAoIXBhcmVudCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICghKHBhcmVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhcmVudCBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmVudC5nZXRBc3luYygiS2lkcyIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChraWRzKSB7CiAgICAgICAgaWYgKCFraWRzKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3Qga2lkUHJvbWlzZXMgPSBbXTsKICAgICAgICBsZXQgZm91bmQgPSBmYWxzZTsKICAgICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgICBpZiAoIShraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiS2lkIG11c3QgYmUgYSByZWZlcmVuY2UuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzUmVmc0VxdWFsKShraWQsIGtpZFJlZikpIHsKICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGtpZFByb21pc2VzLnB1c2goeHJlZi5mZXRjaEFzeW5jKGtpZCkudGhlbihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJLaWQgbm9kZSBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAob2JqLmhhcygiQ291bnQiKSkgewogICAgICAgICAgICAgIHRvdGFsICs9IG9iai5nZXQoIkNvdW50Iik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdG90YWwrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIktpZCByZWZlcmVuY2Ugbm90IGZvdW5kIGluIHBhcmVudCdzIGtpZHMuIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBQcm9taXNlLmFsbChraWRQcm9taXNlcykudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICByZXR1cm4gW3RvdGFsLCBwYXJlbnRSZWZdOwogICAgICAgIH0pOwogICAgICB9KTsKICAgIH0KICAgIGxldCB0b3RhbCA9IDA7CiAgICBjb25zdCBuZXh0ID0gcmVmID0+IHBhZ2VzQmVmb3JlUmVmKHJlZikudGhlbihhcmdzID0+IHsKICAgICAgaWYgKCFhcmdzKSB7CiAgICAgICAgdGhpcy5wYWdlSW5kZXhDYWNoZS5wdXQocGFnZVJlZiwgdG90YWwpOwogICAgICAgIHJldHVybiB0b3RhbDsKICAgICAgfQogICAgICBjb25zdCBbY291bnQsIHBhcmVudFJlZl0gPSBhcmdzOwogICAgICB0b3RhbCArPSBjb3VudDsKICAgICAgcmV0dXJuIG5leHQocGFyZW50UmVmKTsKICAgIH0pOwogICAgcmV0dXJuIG5leHQocGFnZVJlZik7CiAgfQogIGdldCBiYXNlVXJsKCkgewogICAgY29uc3QgdXJpID0gdGhpcy5fY2F0RGljdC5nZXQoIlVSSSIpOwogICAgaWYgKHVyaSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgY29uc3QgYmFzZSA9IHVyaS5nZXQoIkJhc2UiKTsKICAgICAgaWYgKHR5cGVvZiBiYXNlID09PSAic3RyaW5nIikgewogICAgICAgIGNvbnN0IGFic29sdXRlVXJsID0gKDAsIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmwpKGJhc2UsIG51bGwsIHsKICAgICAgICAgIHRyeUNvbnZlcnRFbmNvZGluZzogdHJ1ZQogICAgICAgIH0pOwogICAgICAgIGlmIChhYnNvbHV0ZVVybCkgewogICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJiYXNlVXJsIiwgYWJzb2x1dGVVcmwuaHJlZik7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGh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iAoYWN0aW9uLmhhcygiRCIpKSB7CiAgICAgICAgICAgIGFjdGlvbiA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLmhhcygiVSIpKSB7CiAgICAgICAgICAgIGFjdGlvbiA9IGFjdGlvbi5nZXQoIlUiKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChhY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGNvbnN0IGFjdGlvblR5cGUgPSBhY3Rpb24uZ2V0KCJTIik7CiAgICAgIGlmICghKGFjdGlvblR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgicGFyc2VEZXN0RGljdGlvbmFyeTogSW52YWxpZCB0eXBlIGluIEFjdGlvbiBkaWN0aW9uYXJ5LiIpOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBhY3Rpb25OYW1lID0gYWN0aW9uVHlwZS5uYW1lOwogICAgICBzd2l0Y2ggKGFjdGlvbk5hbWUpIHsKICAgICAgICBjYXNlICJSZXNldEZvcm0iOgogICAgICAgICAgY29uc3QgZmxhZ3MgPSBhY3Rpb24uZ2V0KCJGbGFncyIpOwogICAgICAgICAgY29uc3QgaW5jbHVkZSA9ICgodHlwZW9mIGZsYWdzID09PSAibnVtYmVyIiA/IGZsYWdzIDogMCkgJiAxKSA9PT0gMDsKICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IFtdOwogICAgICAgICAgY29uc3QgcmVmcyA9IFtdOwogICAgICAgICAgZm9yIChjb25zdCBvYmogb2YgYWN0aW9uLmdldCgiRmllbGRzIikgfHwgW10pIHsKICAgICAgICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHJlZnMucHVzaChvYmoudG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBmaWVsZHMucHVzaCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG9iaikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHRPYmoucmVzZXRGb3JtID0gewogICAgICAgICAgICBmaWVsZHMsCiAgICAgICAgICAgIHJlZnMsCiAgICAgICAgICAgIGluY2x1ZGUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJVUkkiOgogICAgICAgICAgdXJsID0gYWN0aW9uLmdldCgiVVJJIik7CiAgICAgICAgICBpZiAodXJsIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICB1cmwgPSAiLyIgKyB1cmwubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkdvVG8iOgogICAgICAgICAgZGVzdCA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkxhdW5jaCI6CiAgICAgICAgY2FzZSAiR29Ub1IiOgogICAgICAgICAgY29uc3QgdXJsRGljdCA9IGFjdGlvbi5nZXQoIkYiKTsKICAgICAgICAgIGlmICh1cmxEaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0LmdldCgiRiIpIHx8IG51bGw7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB1cmxEaWN0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0OwogICAgICAgICAgfQogICAgICAgICAgbGV0IHJlbW90ZURlc3QgPSBhY3Rpb24uZ2V0KCJEIik7CiAgICAgICAgICBpZiAocmVtb3RlRGVzdCkgewogICAgICAgICAgICBpZiAocmVtb3RlRGVzdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICByZW1vdGVEZXN0ID0gcmVtb3RlRGVzdC5uYW1lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdXJsID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgIGNvbnN0IGJhc2VVcmwgPSB1cmwuc3BsaXQoIiMiKVswXTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbW90ZURlc3QgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICB1cmwgPSBiYXNlVXJsICsgIiMiICsgcmVtb3RlRGVzdDsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkocmVtb3RlRGVzdCkpIHsKICAgICAgICAgICAgICAgIHVybCA9IGJhc2VVcmwgKyAiIyIgKyBKU09OLnN0cmluZ2lmeShyZW1vdGVEZXN0KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG5ld1dpbmRvdyA9IGFjdGlvbi5nZXQoIk5ld1dpbmRvdyIpOwogICAgICAgICAgaWYgKHR5cGVvZiBuZXdXaW5kb3cgPT09ICJib29sZWFuIikgewogICAgICAgICAgICByZXN1bHRPYmoubmV3V2luZG93ID0gbmV3V2luZG93OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiR29Ub0UiOgogICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYWN0aW9uLmdldCgiVCIpOwogICAgICAgICAgbGV0IGF0dGFjaG1lbnQ7CiAgICAgICAgICBpZiAoZG9jQXR0YWNobWVudHMgJiYgdGFyZ2V0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICBjb25zdCByZWxhdGlvbnNoaXAgPSB0YXJnZXQuZ2V0KCJSIik7CiAgICAgICAgICAgIGNvbnN0IG5hbWUgPSB0YXJnZXQuZ2V0KCJOIik7CiAgICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKShyZWxhdGlvbnNoaXAsICJDIikgJiYgdHlwZW9mIG5hbWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgYXR0YWNobWVudCA9IGRvY0F0dGFjaG1lbnRzWygwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykobmFtZSldOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXR0YWNobWVudCkgewogICAgICAgICAgICByZXN1bHRPYmouYXR0YWNobWVudCA9IGF0dGFjaG1lbnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVzdERpY3Rpb25hcnkgLSB1bmltcGxlbWVudGVkICJHb1RvRSIgYWN0aW9uLmApOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTmFtZWQiOgogICAgICAgICAgY29uc3QgbmFtZWRBY3Rpb24gPSBhY3Rpb24uZ2V0KCJOIik7CiAgICAgICAgICBpZiAobmFtZWRBY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHJlc3VsdE9iai5hY3Rpb24gPSBuYW1lZEFjdGlvbi5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU2V0T0NHU3RhdGUiOgogICAgICAgICAgY29uc3Qgc3RhdGUgPSBhY3Rpb24uZ2V0KCJTdGF0ZSIpOwogICAgICAgICAgY29uc3QgcHJlc2VydmVSQiA9IGFjdGlvbi5nZXQoIlByZXNlcnZlUkIiKTsKICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShzdGF0ZSkgfHwgc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RhdGVBcnIgPSBbXTsKICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBzdGF0ZSkgewogICAgICAgICAgICBpZiAoZWxlbSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICBzd2l0Y2ggKGVsZW0ubmFtZSkgewogICAgICAgICAgICAgICAgY2FzZSAiT04iOgogICAgICAgICAgICAgICAgY2FzZSAiT0ZGIjoKICAgICAgICAgICAgICAgIGNhc2UgIlRvZ2dsZSI6CiAgICAgICAgICAgICAgICAgIHN0YXRlQXJyLnB1c2goZWxlbS5uYW1lKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgaWYgKGVsZW0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICBzdGF0ZUFyci5wdXNoKGVsZW0udG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZUFyci5sZW5ndGggIT09IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdE9iai5zZXRPQ0dTdGF0ZSA9IHsKICAgICAgICAgICAgc3RhdGU6IHN0YXRlQXJyLAogICAgICAgICAgICBwcmVzZXJ2ZVJCOiB0eXBlb2YgcHJlc2VydmVSQiA9PT0gImJvb2xlYW4iID8gcHJlc2VydmVSQiA6IHRydWUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJKYXZhU2NyaXB0IjoKICAgICAgICAgIGNvbnN0IGpzQWN0aW9uID0gYWN0aW9uLmdldCgiSlMiKTsKICAgICAgICAgIGxldCBqczsKICAgICAgICAgIGlmIChqc0FjdGlvbiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICAgIGpzID0ganNBY3Rpb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AgICBxdWV1ZS5wdXNoKGtpZCk7CiAgICAgICAgICBwcm9jZXNzZWQucHV0KGtpZCk7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGVudHJpZXMgPSBvYmouZ2V0KHRoaXMuX3R5cGUpOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZW50cmllcykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBlbnRyaWVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBtYXAuc2V0KHhyZWYuZmV0Y2hJZlJlZihlbnRyaWVzW2ldKSwgeHJlZi5mZXRjaElmUmVmKGVudHJpZXNbaSArIDFdKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldChrZXkpIHsKICAgIGlmICghdGhpcy5yb290KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3QgeHJlZiA9IHRoaXMueHJlZjsKICAgIGxldCBraWRzT3JFbnRyaWVzID0geHJlZi5mZXRjaElmUmVmKHRoaXMucm9vdCk7CiAgICBsZXQgbG9vcENvdW50ID0gMDsKICAgIGNvbnN0IE1BWF9MRVZFTFMgPSAxMDsKICAgIHdoaWxlIChraWRzT3JFbnRyaWVzLmhhcygiS2lkcyIpKSB7CiAgICAgIGlmICgrK2xvb3BDb3VudCA+IE1BWF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFNlYXJjaCBkZXB0aCBsaW1pdCByZWFjaGVkIGZvciAiJHt0aGlzLl90eXBlfSIgdHJlZS5gKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBraWRzID0ga2lkc09yRW50cmllcy5nZXQoIktpZHMiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGtpZHMpKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgbGV0IGwgPSAwLAogICAgICAgIHIgPSBraWRzLmxlbmd0aCAtIDE7CiAgICAgIHdoaWxlIChsIDw9IHIpIHsKICAgICAgICBjb25zdCBtID0gbCArIHIgPj4gMTsKICAgICAgICBjb25zdCBraWQgPSB4cmVmLmZldGNoSWZSZWYoa2lkc1ttXSk7CiAgICAgICAgY29uc3QgbGltaXRzID0ga2lkLmdldCgiTGltaXRzIik7CiAgICAgICAgaWYgKGtleSA8IHhyZWYuZmV0Y2hJZlJlZihsaW1pdHNbMF0pKSB7CiAgICAgICAgICByID0gbSAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChrZXkgPiB4cmVmLmZldGNoSWZSZWYobGltaXRzWzFdKSkgewogICAgICAgICAgbCA9IG0gKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBraWRzT3JFbnRyaWVzID0ga2lkOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChsID4gcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICB9CiAgICBjb25zdCBlbnRyaWVzID0ga2lkc09yRW50cmllcy5nZXQodGhpcy5fdHlwZSk7CiAgICBpZiAoQXJyYXkuaXNBcnJheShlbnRyaWVzKSkgewogICAgICBsZXQgbCA9IDAsCiAgICAgICAgciA9IGVudHJpZXMubGVuZ3RoIC0gMjsKICAgICAgd2hpbGUgKGwgPD0gcikgewogICAgICAgIGNvbnN0IHRtcCA9IGwgKyByID4+IDEsCiAgICAgICAgICBtID0gdG1wICsgKHRtcCAmIDEpOwogICAgICAgIGNvbnN0IGN1cnJlbnRLZXkgPSB4cmVmLmZldGNoSWZSZWYoZW50cmllc1ttXSk7CiAgICAgICAgaWYgKGtleSA8IGN1cnJlbnRLZXkpIHsKICAgICAgICAgIHIgPSBtIC0gMjsKICAgICAgICB9IGVsc2UgaWYgKGtleSA+IGN1cnJlbnRLZXkpIHsKICAgICAgICAgIGwgPSBtICsgMjsKICAgICAgICB9IG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AgICAgICAgY2FzZSAiYXBvcyI6CiAgICAgICAgICAgIHJldHVybiAiJyI7CiAgICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICAgIHJldHVybiAiPCI7CiAgICAgICAgICBjYXNlICJxdW90IjoKICAgICAgICAgICAgcmV0dXJuICciJzsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBfcmVwYWlyOiAke25hbWV9IGlzbid0IGRlZmluZWQuYCk7CiAgICAgIH0pOwogICAgICBjb25zdCBjaGFyQnVmID0gWyI+Il07CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBjb25zdCBjb2RlID0gYnl0ZXMuY2hhckNvZGVBdChpKSAqIDI1NiArIGJ5dGVzLmNoYXJDb2RlQXQoaSArIDEpOwogICAgICAgIGlmIChjb2RlID49IDMyICYmIGNvZGUgPCAxMjcgJiYgY29kZSAhPT0gNjAgJiYgY29kZSAhPT0gNjIgJiYgY29kZSAhPT0gMzgpIHsKICAgICAgICAgIGNoYXJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY2hhckJ1Zi5wdXNoKCImI3giICsgKDB4MTAwMDAgKyBjb2RlKS50b1N0cmluZygxNikuc3Vic3RyaW5nKDEpICsgIjsiKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIGNoYXJCdWYuam9pbigiIik7CiAgICB9KTsKICB9CiAgX2dldFNlcXVlbmNlKGVudHJ5KSB7CiAgICBjb25zdCBuYW1lID0gZW50cnkubm9kZU5hbWU7CiAgICBpZiAobmFtZSAhPT0gInJkZjpiYWciICYmIG5hbWUgIT09ICJyZGY6c2VxIiAmJiBuYW1lICE9PSAicmRmOmFsdCIpIHsKICAgICAgcmV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W50LCBtYXAsIGxldmVsICsgMSk7CiAgICBpZiAoIXBhcmVudE5vZGUpIHsKICAgICAgcmV0dXJuIGVsZW1lbnQ7CiAgICB9CiAgICBsZXQgc2F2ZSA9IGZhbHNlOwogICAgZm9yIChjb25zdCBraWQgb2YgcGFyZW50Tm9kZS5raWRzKSB7CiAgICAgIGlmIChraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuRUxFTUVOVCAmJiBraWQuZGljdCA9PT0gZGljdCkgewogICAgICAgIGtpZC5wYXJlbnROb2RlID0gZWxlbWVudDsKICAgICAgICBzYXZlID0gdHJ1ZTsKICAgICAgfQogICAgfQogICAgaWYgKCFzYXZlKSB7CiAgICAgIG1hcC5kZWxldGUoZGljdCk7CiAgICB9CiAgICByZXR1cm4gZWxlbWVudDsKICB9CiAgYWRkVG9wTGV2ZWxOb2RlKGRpY3QsIGVsZW1lbnQpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMucm9vdERpY3QuZ2V0KCJLIik7CiAgICBpZiAoIW9iaikgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBpZiAob2JqLm9iaklkICE9PSBkaWN0Lm9iaklkKSB7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIHRoaXMubm9kZXNbMF0gPSBlbGVtZW50OwogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmICghQXJyYXkuaXNBcnJheShvYmopKSB7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgbGV0IHNhdmUgPSBmYWxzZTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgb2JqLmxlbmd0aDsgaSsrKSB7CiAgICAgIGNvbnN0IGtpZFJlZiA9IG9ialtpXTsKICAgICAgaWYgKGtpZFJlZiAmJiBraWRSZWYudG9TdHJpbmcoKSA9PT0gZGljdC5vYmpJZCkgewogICAgICAg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BraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuRUxFTUVOVCA/IGtpZC5wYXJlbnROb2RlIDogbnVsbDsKICAgICAgICBpZiAoa2lkRWxlbWVudCkgewogICAgICAgICAgbm9kZVRvU2VyaWFsaXphYmxlKGtpZEVsZW1lbnQsIG9iaiwgbGV2ZWwgKyAxKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLlBBR0VfQ09OVEVOVCB8fCBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuU1RSRUFNX0NPTlRFTlQpIHsKICAgICAgICAgIG9iai5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgdHlwZTogImNvbnRlbnQiLAogICAgICAgICAgICBpZDogYHBhZ2Uke2tpZC5wYWdlT2JqSWR9X21jaWQke2tpZC5tY2lkfWAKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLk9CSkVDVCkgewogICAgICAgICAgb2JqLmNoaWxkcmVuLnB1c2goewogICAgICAgICAgICB0eXBlOiAib2JqZWN0IiwKICAgICAgICAgICAgaWQ6IGtpZC5yZWZPYmpJZAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBjb25zdCByb290ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIHJvb3QuY2hpbGRyZW4gPSBbXTsKICAgIHJvb3Qucm9sZSA9ICJSb290IjsKICAgIGZvciAoY29uc3QgY2hpbGQgb2YgdGhpcy5ub2RlcykgewogICAgICBpZiAoIWNoaWxkKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbm9kZVRvU2VyaWFsaXphYmxlKGNoaWxkLCByb290KTsKICAgIH0KICAgIHJldHVybiByb290OwogIH0KfQpleHBvcnRzLlN0cnVjdFRyZWVQYW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XNpdC5sZW5ndGgpIHsKICAgICAgbGV0IGN1cnJlbnROb2RlID0gbm9kZXNUb1Zpc2l0LnBvcCgpOwogICAgICBpZiAoY3VycmVudE5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodGhpcy5yZWZTZXQuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnJlZlNldC5wdXQoY3VycmVudE5vZGUpOwogICAgICAgICAgY3VycmVudE5vZGUgPSB0aGlzLnhyZWYuZmV0Y2goY3VycmVudE5vZGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBpZiAoIShleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9iamVjdExvYWRlci5fd2FsayAtIHJlcXVlc3RpbmcgYWxsIGRhdGE6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIHRoaXMucmVmU2V0ID0gbnVsbDsKICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgIG1hbmFnZXIKICAgICAgICAgICAgfSA9IHRoaXMueHJlZi5zdHJlYW07CiAgICAgICAgICAgIHJldHVybiBtYW5hZ2VyLnJlcXVlc3RBbGxDaHVua3MoKTsKICAgICAgICAgIH0KICAgICAgICAgIG5vZGVzVG9SZXZpc2l0LnB1c2goY3VycmVudE5vZGUpOwogICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICBiZWdpbjogZXguYmVnaW4sCiAgICAgICAgICAgIGVuZDogZXguZW5kCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBiYXNlU3RyZWFtcyA9IGN1cnJlbnROb2RlLmdldEJhc2VTdHJlYW1zKCk7CiAgICAgICAgaWYgKGJhc2VTdHJlYW1zKSB7CiAgICAgICAgICBsZXQgZm91bmRNaXNzaW5nRGF0YSA9IGZhbHNlOwogICAgICAgICAgZm9yIChjb25zdCBzdHJlYW0gb2YgYmFzZVN0cmVhbXMpIHsKICAgICAgICAgICAgaWYgKHN0cmVhbS5pc0RhdGFMb2FkZWQpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3VuZE1pc3NpbmdEYXRhID0gdHJ1ZTsKICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICAgIGJlZ2luOiBzdHJlYW0uc3RhcnQsCiAgICAgICAgICAgICAgZW5kOiBzdHJlYW0uZW5kCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGZvdW5kTWlzc2luZ0RhdGEpIHsKICAgICAgICAgICAgbm9kZXNUb1JldmlzaXQucHVzaChjdXJyZW50Tm9kZSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGFkZENoaWxkcmVuKGN1cnJlbnROb2RlLCBub2Rlc1RvVmlzaXQpOwogICAgfQogICAgaWYgKHBlbmRpbmdSZXF1ZXN0cy5sZW5ndGgpIHsKICAgICAgYXdhaXQgdGhpcy54cmVmLnN0cmVhbS5tYW5hZ2VyLnJlcXVlc3RSYW5nZXMocGVuZGluZ1JlcXVlc3RzKTsKICAgICAgZm9yIChjb25zdCBub2RlIG9mIG5vZGVzVG9SZXZpc2l0KSB7CiAgICAgICAgaWYgKG5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgIHRoaXMucmVmU2V0LnJlbW92ZShub2RlKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIHRoaXMuX3dhbGsobm9kZXNUb1Jld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gICAgY29uc3QgYXR0cmlidXRlcyA9IHByb3RvLl9hdHRyaWJ1dGVzID0gbmV3IFNldCgpOwogICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgICBpZiAodGhpc1tuYW1lXSA9PT0gbnVsbCB8fCB0aGlzW25hbWVdIGluc3RhbmNlb2YgWEZBT2JqZWN0IHx8IHRoaXNbbmFtZV0gaW5zdGFuY2VvZiBYRkFPYmplY3RBcnJheSkgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGF0dHJpYnV0ZXMuYWRkKG5hbWUpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgX2F0dHJpYnV0ZU5hbWVzLCBwcm90by5fYXR0cmlidXRlcyk7CiAgfQogIFskaXNEZXNjZW5kZW50XShwYXJlbnQpIHsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlIChub2RlKSB7CiAgICAgIGlmIChub2RlID09PSBwYXJlbnQpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBub2RlID0gbm9kZVskZ2V0UGFyZW50XSgpOwogICAgfQogICAgcmV0dXJuIGZhbHNlOwogIH0KICBbJGdldFBhcmVudF0oKSB7CiAgICByZXR1cm4gdGhpc1tfcGFyZW50XTsKICB9CiAgWyRnZXRTdWJmb3JtUGFyZW50XSgpIHsKICAgIHJldHVybiB0aGlzWyRnZXRQYXJlbnRdKCk7CiAgfQogIFskZ2V0Q2hpbGRyZW5dKCkgewogICAgbGV0IG5hbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IG51bGw7CiAgICBpZiAoIW5hbWUpIHsKICAgICAgcmV0dXJuIHRoaXNbX2NoaWxkcmVuXTsKICAgIH0KICAgIHJldHVybiB0aG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gICAgICB0aGlzW19jaGlsZHJlbl0ucHVzaChjaGlsZCk7CiAgICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCkgewogICAgICAgIHZhbHVlWyRyZXNvbHZlUHJvdG90eXBlc10oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIGlmIChwcm90b1ZhbHVlKSB7CiAgICAgICAgICB2YWx1ZVtfYXBwbHlQcm90b3R5cGVdKHByb3RvVmFsdWUsIGlkcywgYW5jZXN0b3JzKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByb3RvVmFsdWUgIT09IG51bGwpIHsKICAgICAgICBjb25zdCBjaGlsZCA9IHByb3RvVmFsdWVbJGNsb25lXSgpOwogICAgICAgIGNoaWxkW19wYXJlbnRdID0gdGhpczsKICAgICAgICB0aGlzW25hbWVdID0gY2hpbGQ7CiAgICAgICAgdGhpc1tfY2hpbGRyZW5dLnB1c2goY2hpbGQpOwogICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICB9CiAgICB9CiAgfQogIHN0YXRpYyBbX2Nsb25lQXR0cmlidXRlXShvYmopIHsKICAgIGlmIChBcnJheS5pc0FycmF5KG9iaikpIHsKICAgICAgcmV0dXJuIG9iai5tYXAoeCA9PiBYRkFPYmplY3RbX2Nsb25lQXR0cmlidXRlXSh4KSk7CiAgICB9CiAgICBpZiAodHlwZW9mIG9iaiA9PT0gIm9iamVjdCIgJiYgb2JqICE9PSBudWxsKSB7CiAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKHt9LCBvYmopOwogICAgfQ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dpdGNoIChleHByLmNoYXJBdChwb3MpKSB7CiAgICAgIGNhc2UgIi4iOgogICAgICAgIGlmICghZG90RG90QWxsb3dlZCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIHBvcysrOwogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdERvdDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiIyI6CiAgICAgICAgcG9zKys7CiAgICAgICAgb3BlcmF0b3IgPSBvcGVyYXRvcnMuZG90SGFzaDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiWyI6CiAgICAgICAgaWYgKG5vRXhwcikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBTT00gZXhwcmVzc2lvbiBjb250YWlucyBhIEZvcm1DYWxjIHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdEJyYWNrZXQ7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIigiOgogICAgICAgIGlmIChub0V4cHIpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gU09NIGV4cHJlc3Npb24gY29udGFpbnMgYSBKYXZhU2NyaXB0IHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdFBhcmVuOwogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdDsKICAgICAgICBicmVhazsKICAgIH0KICAgIG1hdGNoID0gZXhwci5zbGljZShwb3MpLm1hdGNoKG5hbWVQYXR0ZXJuKTsKICA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lW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5Q2xhc3NdKG5hbWUpOwogICAgICAgICAgICBpZiAoY2hpbGRyZW4gaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSkgewogICAgICAgICAgICAgIGNoaWxkcmVuID0gY2hpbGRyZW4uY2hpbGRyZW47CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY2hpbGRyZW4gPSBbY2hpbGRyZW5dOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICh1c2VDYWNoZSkgewogICAgICAgICAgY2FjaGVkLnNldChjYWNoZU5hbWUsIGNoaWxkcmVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICBub2Rlcy5wdXNoKGNoaWxkcmVuKTsKICAgICAgfQogICAgfQogICAgaWYgKG5vZGVzLmxlbmd0aCA9PT0gMCAmJiAhaXNRdWFsaWZpZWQgJiYgaSA9PT0gMCkgewogICAgICBjb25zdCBwYXJlbnQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgICAgY29udGFpbmVyID0gcGFyZW50OwogICAgICBpZiAoIWNvbnRhaW5lcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGkgPSAtMTsKICAgICAgcm9vdCA9IFtjb250YWluZXJdOwogICAgICBjb250aW51ZTsKICAgIH0KICAgIGlmIChpc0Zpbml0ZShpbmRleCkpIHsKICAgICAgcm9vdCA9IG5vZGVzLmZpbHRlcihub2RlID0+IGluZGV4IDwgbm9kZS5sZW5ndGgpLm1hcChub2RlID0+IG5vZGVbaW5kZXhdKTsKICAgIH0gZWxzZSB7CiAgICAgIHJvb3QgPSBub2Rlcy5mbGF0KCk7CiAgICB9C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XMpOwogICAgZm9yIChjb25zdCB7CiAgICAgIHJlZiwKICAgICAgbGFiZWxSZWYsCiAgICAgIHZhbHVlUmVmLAogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLmJpbmRJdGVtcy5jaGlsZHJlbikgewogICAgICBpZiAoY29ubmVjdGlvbikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghcmVmKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3Qgbm9kZXMgPSAoMCwgX3NvbS5zZWFyY2hOb2RlKSh0aGlzLnJvb3QsIGRhdGFOb2RlLCByZWYsIGZhbHNlLCBmYWxzZSk7CiAgICAgIGlmICghbm9kZXMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgcmVmZXJlbmNlOiAke3JlZn0uYCk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBub2RlIG9mIG5vZGVzKSB7CiAgICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YXNldHMpKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgcmVmICgke3JlZn0pOiBtdXN0IGJlIGEgZGF0YXNldHMgY2hpbGQuYCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbGFiZWxOb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgbm9kZSwgbGFiZWxSZWYsIHRydWUsIGZhbHNlKTsKICAgICAgICBpZiAoIWxhYmVsTm9kZXMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCBsYWJlbDogJHtsYWJlbFJlZn0uYCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgW2xhYmVsTm9kZV0gPSB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F0YUNoaWxkID0gY2hpbGRbX3hmYV9vYmplY3QuJGRhdGFdID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBjaGlsZC5uYW1lIHx8ICJyb290Iik7CiAgICAgICAgICBkYXRhTm9kZVtfeGZhX29iamVjdC4kYXBwZW5kQ2hpbGRdKGRhdGFDaGlsZCk7CiAgICAgICAgICB0aGlzLl9iaW5kRWxlbWVudChjaGlsZCwgZGF0YUNoaWxkKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFjaGlsZFtfeGZhX29iamVjdC4kaXNCaW5kYWJsZV0oKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCBnbG9iYWwgPSBmYWxzZTsKICAgICAgbGV0IHBpY3R1cmUgPSBudWxsOwogICAgICBsZXQgcmVmID0gbnVsbDsKICAgICAgbGV0IG1hdGNoID0gbnVsbDsKICAgICAgaWYgKGNoaWxkLmJpbmQpIHsKICAgICAgICBzd2l0Y2ggKGNoaWxkLmJpbmQubWF0Y2gpIHsKICAgICAgICAgIGNhc2UgIm5vbmUiOgogICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgY2FzZSAiZ2xvYmFsIjoKICAgICAgICAgICAgZ2xvYmFsID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJkYXRhUmVmIjoKICAgICAgICAgICAgaWYgKCFjaGlsZC5iaW5kLnJlZikgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gcmVmIGlzIGVtcHR5IGluIG5vZGUgJHtjaGlsZFtfeGZhX29iamVjdC4kbm9kZU5hbWVdfS5gKTsKICAgICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVmID0gY2hpbGQuYmluZC5yZWY7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChjaGlsZC5iaW5kLnBpY3R1cmUpIHsKICAgICAgICAgIHBpY3R1cmUgPSBjaGlsZC5iaW5kLnBpY3R1cmVbX3hmYV9vYmplY3QuJGNvbnRlbnRdOwogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBbbWluLCBtYXhdID0gdGhpcy5fZ2V0T2NjdXJJbmZvKGNoaWxkKTsKICAgICAgaWYgKHJlZikgewogICAgICAgIG1hdGNoID0gKDAsIF9zb20uc2VhcmNoTm9kZSkodGhpcy5yb290LCBkYXRhTm9kZSwgcmVmLCB0cnVlLCBmYWxzZSk7CiAgICAgICAgaWYgKG1hdGNoID09PSBudWxsKSB7CiAgICAgICAgICBtYXRjaCA9ICgwLCBfc29tLmNyZWF0ZURhdGFOb2RlKSh0aGlzLmRhdGEsIGRhdGFOb2RlLCByZWYpOwogICAgICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgICAgbWF0Y2hbX3hmYV9vYmplY3QuJGNvbnN1bWVkXSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHRoaXMuX2lzQ29uc3VtZURhdGEoKSkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLmZpbHRlcihub2RlID0+ICFub2RlW194ZmFfb2JqZWN0LiRjb25zdW1lZF0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG1hdGNoLmxlbmd0aCA+IG1heCkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLnNsaWNlKDAsIG1heCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICBtYXRjaCA9IG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobWF0Y2ggJiYgdGhpcy5faXNDb25zdW1lRGF0YSgpKSB7CiAgICAgICAgICAgIG1hdGNoLmZvckVhY2gobm9kZSA9PiB7CiAgICAgICAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICghY2hpbGQubmFtZSkgewogICAgICAgICAgdGhpcy5fc2V0QW5kQmluZChjaGlsZCwgZGF0YU5vZGUpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgIHdoaWxlIChtYXRjaGVzLmxlbmd0aCA8IG1heCkgewogICAgICAgICAgICBjb25zdCBmb3VuZCA9IHRoaXMuX2ZpbmREYXRhQnlOYW1lVG9Db25zdW1lKGNoaWxkLm5hbWUsIGNoaWxkW194ZmFfb2JqZWN0LiRoYXNTZXR0YWJsZVZhbHVlXSgpLCBkYXRhTm9kZSwgZ2xvYmFsKTsKICAgICAgICAgICAgaWYgKCFmb3VuZCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvdW5kW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICBtYXRjaGVzLnB1c2goZm91bmQpOwogICAgICAgICAgfQogICAgICAgICAgbWF0Y2ggPSBtYXRjaGVzLmxlbmd0aCA+IDAgPyBtYXRjaGVzIDogbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbWF0Y2ggPSBkYXRhTm9kZVtfeGZhX29iamVjdC4kZ2V0UmVhbENoaWxkcmVuQnlOYW1lSXRdKGNoaWxkLm5hbWUsIGZhbHNlLCB0aGlzLmVtcHR5TWVyZ2UpLm5leHQoKS52YWx1ZTsKICAgICAgICAgIGlmICghbWF0Y2gpIHsKICAgICAgICAgICAgaWYgKG1pbiA9PT0gMCkgewogICAgICAgICAgICAgIHVzZWxlc3NOb2Rlcy5wdXNoKGNoaWxkKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBuc0lkID0gZGF0YU5vZGVbX3hmYV9vYmplY3QuJG5hbWVzcGFjZUlkXSA9PT0gTlNfREFUQVNFVFMgPyAtMSA6IGRhdGFOb2RlW194ZmFfb2JqZWN0LiRuYW1lc3BhY2VJZF07CiAgICAgICAgICAgIG1hdGNoID0gY2hpbGRbX3hmYV9vYmplY3QuJGRhdGFdID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBjaGlsZC5uYW1lKTsKICAgICAgICAgICAgaWYgKHRoaXMuZW1wdHlNZXJnZSkgewogICAgICAgICAgICAgIG1hdGNoW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGFOb2RlW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0obWF0Y2gpOwogICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW1wdHlNZXJnZSkgewogICAgICAgICAgICBtYXRjaFtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIG1hdGNoID0gW21hdGNoXTsKICAgICAgICB9CiAgICAg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0ZXM6IHsKICAgICAgICBpZDogdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICBjbGFzczogWyJ4ZmFCdXR0b24iXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW46IFtdCiAgICB9OwogICAgZm9yIChjb25zdCBldmVudCBvZiBncmFuZHBhLmV2ZW50LmNoaWxkcmVuKSB7CiAgICAgIGlmIChldmVudC5hY3Rpdml0eSAhPT0gImNsaWNrIiB8fCAhZXZlbnQuc2NyaXB0KSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QganNVUkwgPSAoMCwgX2NvcmVfdXRpbHMucmVjb3ZlckpzVVJMKShldmVudC5zY3JpcHRbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgaWYgKCFqc1VSTCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGhyZWYgPSAoMCwgX2h0bWxfdXRpbHMuZml4VVJMKShqc1VSTC51cmwpOwogICAgICBpZiAoIWhyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBodG1sQnV0dG9uLmNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICJhIiwKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBpZDogImxpbmsiICsgdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGhyZWYsCiAgICAgICAgICBuZXdXaW5kb3c6IGpzVVJMLm5ld1dpbmRvdywKICAgICAgICAgIGNsYXNzOiBbInhmYUxpbmsiXSwKICAgICAgICAgIHN0eWxlOiB7fQogICAgICAgIH0sCiAgICAgICAgY2hpbGRyZW46IFtdCiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LnN1Y2Nlc3MoaHRtbEJ1dHRvbik7CiAgfQp9CmNsYXNzIENhbGN1bGF0ZSBleHRlbmRzIF94ZmFfb2JqZWN0L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hpcywgewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodAogICAgICB9KTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV07CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgaWYgKCF0aGlzLnZhbHVlKSB7CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5FTVBUWTsKICAgIH0KICAgIHRoaXNbX3hmYV9vYmplY3QuJHB1c2hQYXJhXSgpOwogICAgY29uc3QgdmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKS5odG1sOwogICAgaWYgKCF2YWx1ZSkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuRU1QVFk7CiAgICB9CiAgICBjb25zdCBzYXZlZFJlc2VydmUgPSB0aGlzLnJlc2VydmU7CiAgICBpZiAodGhpcy5yZXNlcnZlIDw9IDApIHsKICAgICAgY29uc3QgewogICAgICAgIHcsCiAgICAgICAgaAogICAgICB9ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0RXh0cmFdKGF2YWlsYWJsZVNwYWNlKTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgdGhpcy5yZXNlcnZlID0gdzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInRvcCI6CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHRoaXMucmVzZXJ2ZSA9IGg7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgY29uc3QgY2hpbGRyZW4gPSBbXTsKICAgIGlmICh0eXBlb2YgdmFsdW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B7CiAgICAgIGdyb3VwSWQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJHVpZF07CiAgICAgIHR5cGUgPSAicmFkaW8iOwogICAgICBjbGFzc05hbWUgPSAieGZhUmFkaW8iOwogICAgICBkYXRhSWQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGRhdGFdICYmIGNvbnRhaW5lcltfeGZhX29iamVjdC4kZGF0YV1bX3hmYV9vYmplY3QuJHVpZF0gfHwgY29udGFpbmVyW194ZmFfb2JqZWN0LiR1aWRdOwogICAgfSBlbHNlIHsKICAgICAgdHlwZSA9ICJjaGVja2JveCI7CiAgICAgIGNsYXNzTmFtZSA9ICJ4ZmFDaGVja2JveCI7CiAgICAgIGRhdGFJZCA9IGZpZWxkW194ZmFfb2JqZWN0LiRkYXRhXSAmJiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV1bX3hmYV9vYmplY3QuJHVpZF0gfHwgZmllbGRbX3hmYV9vYmplY3QuJHVpZF07CiAgICB9CiAgICBjb25zdCBpbnB1dCA9IHsKICAgICAgbmFtZTogImlucHV0IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBbY2xhc3NOYW1lXSwKICAgICAgICBzdHlsZSwKICAgICAgICBmaWVsZElkLAogICAgICAgIGRhdGFJZCwKICAgICAgICB0eXBlLAogICAgICAgIGNoZWNrZWQsCiAgICAgICAgeGZhT246IGV4cG9ydGVkVmFsdWUub24sCiAgICAgICAgeGZhT2ZmOiBleHBvcnRlZFZhbHVlLm9mZiwKICAgICAgICAiYXJpYS1sYWJlbCI6IGFyaWFMYWJlbChmaWVsZCksCiAgICAgICAgImFyaWEtcmVxdWlyZWQiOiBmYWxzZQogICAgICB9CiAgICB9OwogICAgaWYgKGdyb3VwSWQpIHsKICAgICAgaW5wdXQuYXR0cmlidXRlcy5uYW1lID0gZ3JvdXBJZDsKICAgIH0KICAgIGlmIChpc1JlcXVpcmVkKGZpZWxkKSkgewogICAgICBpbnB1dC5hdHRyaW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YWx1ZXMgPSBpdGVtcy5jaGlsZHJlbltzYXZlSW5kZXhdW194ZmFfb2JqZWN0LiR0b0hUTUxdKCkuaHRtbDsKICAgICAgbGV0IHNlbGVjdGVkID0gZmFsc2U7CiAgICAgIGNvbnN0IHZhbHVlID0gZmllbGQudmFsdWUgJiYgZmllbGQudmFsdWVbX3hmYV9vYmplY3QuJHRleHRdKCkgfHwgIiI7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRpc3BsYXllZC5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29uc3Qgb3B0aW9uID0gewogICAgICAgICAgbmFtZTogIm9wdGlvbiIsCiAgICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICAgIHZhbHVlOiB2YWx1ZXNbaV0gfHwgZGlzcGxheWVkW2ldLAogICAgICAgICAgICBzdHlsZTogb3B0aW9uU3R5bGUKICAgICAgICAgIH0sCiAgICAgICAgICB2YWx1ZTogZGlzcGxheWVkW2ldCiAgICAgICAgfTsKICAgICAgICBpZiAodmFsdWVzW2ldID09PSB2YWx1ZSkgewogICAgICAgICAgb3B0aW9uLmF0dHJpYnV0ZXMuc2VsZWN0ZWQgPSBzZWxlY3RlZCA9IHRydWU7CiAgICAgICAgfQogICAgICAgIGNoaWxkcmVuLnB1c2gob3B0aW9uKTsKICAgICAgfQogICAgICBpZiAoIXNlbGVjdGVkKSB7CiAgICAgICAgY2hpbGRyZW4uc3BsaWNlKDAsIDAsIHsKICAgICAgICAgIG5hbWU6ICJvcHRpb24iLAogICAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgICBoaWRkZW46IHRydWUsCiAgICAgICAgICAgIHNlbGVjdGVkOiB0cnVlCiAgICAgICAgICB9LAogICAgICAgICAgdmFsdWU6ICIgIgogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBjb25zdCBzZWxlY3RBdHRyaWJ1dGVzID0gewogICAgICBjbGFzczogWyJ4ZmFTZWxlY3QiXSwKIC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XMudXNlaHJlZiB8fCAiIjsKICAgIHRoaXMuY29sb3IgPSBudWxsOwogICAgdGhpcy5leHRyYXMgPSBudWxsOwogIH0KICBbX3hmYV9vYmplY3QuJHRvU3R5bGVdKCkgewogICAgY29uc3Qgc3R5bGUgPSAoMCwgX2h0bWxfdXRpbHMudG9TdHlsZSkodGhpcywgInZpc2liaWxpdHkiKTsKICAgIE9iamVjdC5hc3NpZ24oc3R5bGUsIHsKICAgICAgbGluZWNhcDogdGhpcy5jYXAsCiAgICAgIHdpZHRoOiAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSh0aGlzLnRoaWNrbmVzcyksCiAgICAgIGNvbG9yOiB0aGlzLmNvbG9yID8gdGhpcy5jb2xvcltfeGZhX29iamVjdC4kdG9TdHlsZV0oKSA6ICIjMDAwMDAwIiwKICAgICAgc3R5bGU6ICIiCiAgICB9KTsKICAgIGlmICh0aGlzLnByZXNlbmNlICE9PSAidmlzaWJsZSIpIHsKICAgICAgc3R5bGUuc3R5bGUgPSAibm9uZSI7CiAgICB9IGVsc2UgewogICAgICBzd2l0Y2ggKHRoaXMuc3Ryb2tlKSB7CiAgICAgICAgY2FzZSAic29saWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAic29saWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaGVkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gImRhc2hlZCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJkb3R0ZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAiZG90dGVkIjsKICAgICAgICAg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lU3BhY2UpIHsKICAgIHNldFRhYkluZGV4KHRoaXMpOwogICAgaWYgKCF0aGlzLnVpKSB7CiAgICAgIHRoaXMudWkgPSBuZXcgVWkoe30pOwogICAgICB0aGlzLnVpW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXSA9IHRoaXNbX3hmYV9vYmplY3QuJGdsb2JhbERhdGFdOwogICAgICB0aGlzW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0odGhpcy51aSk7CiAgICAgIGxldCBub2RlOwogICAgICBzd2l0Y2ggKHRoaXMuaXRlbXMuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgbm9kZSA9IG5ldyBUZXh0RWRpdCh7fSk7CiAgICAgICAgICB0aGlzLnVpLnRleHRFZGl0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIG5vZGUgPSBuZXcgQ2hlY2tCdXR0b24oe30pOwogICAgICAgICAgdGhpcy51aS5jaGVja0J1dHRvbiA9IG5vZGU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICBub2RlID0gbmV3IENob2ljZUxpc3Qoe30pOwogICAgICAgICAgdGhpcy51aS5jaG9pY2VMaXN0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMudWlbX3hmYV9vYmplY3QuJGFwcGVuZENoaWxkXShub2RlKTsKICAgIH0KICAgIGlmICghdGhpcy51aSB8fCB0aGlzLnByZXNlbmNlID09PSAiaGlkZGVuIiB8fCB0aGlzLnByZXNlbmNlID09PSAiaW5hY3RpdmUiIHx8IHRoaXMuaCA9PT0gMCB8fCB0aGlzLncgPT09IDApIHsKICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkVNUFRZOwogICAgfQogICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICBkZWxldGUgdGhpcy5jYXB0aW9uW194ZmF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KICAgICAgICAgIHVpSCA9ICgwLCBfZm9udHMuZ2V0TWV0cmljcykodGhpcy5mb250LCB0cnVlKS5saW5lTm9HYXA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGJvcmRlckRpbXMgPSBnZXRCb3JkZXJEaW1zKHRoaXMudWlbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpKTsKICAgICAgdWlXICs9IGJvcmRlckRpbXMudzsKICAgICAgdWlIICs9IGJvcmRlckRpbXMuaDsKICAgICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICAgIGNvbnN0IHsKICAgICAgICAgIHcsCiAgICAgICAgICBoLAogICAgICAgICAgaXNCcm9rZW4KICAgICAgICB9ID0gdGhpcy5jYXB0aW9uW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oYXZhaWxhYmxlU3BhY2UpOwogICAgICAgIGlmIChpc0Jyb2tlbiAmJiB0aGlzW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpW194ZmFfb2JqZWN0LiRpc1RoZXJlTW9yZVdpZHRoXSgpKSB7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICAgICAgfQogICAgICAgIHdpZHRoID0gdzsKICAgICAgICBoZWlnaHQgPSBoOwogICAgICAgIHN3aXRjaCAodGhpcy5jYXB0aW9uLnBsYWNlbWVudCkgewogICAgICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgICB3aWR0aCArPSB1aVc7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgICAgIGhlaWdodCArPSB1aUg7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBl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luc3RhbmNlb2YgVWkpIHsKICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSAid2hpdGUiOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgUmVjdGFuZ2xlIHx8IHBhcmVudCBpbnN0YW5jZW9mIEFyYykgewogICAgICBwcm9wTmFtZSA9IGFsdFByb3BOYW1lID0gImZpbGwiOwogICAgICBzdHlsZS5maWxsID0gIndoaXRlIjsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImV4dHJhcyIgfHwgbmFtZSA9PT0gImNvbG9yIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBjb2xvciA9IG9ialtfeGZhX29iamVjdC4kdG9TdHlsZV0odGhpcy5jb2xvcik7CiAgICAgIGlmIChjb2xvcikgewogICAgICAgIHN0eWxlW2NvbG9yLnN0YXJ0c1dpdGgoIiMiKSA/IHByb3BOYW1lIDogYWx0UHJvcE5hbWVdID0gY29sb3I7CiAgICAgIH0KICAgICAgcmV0dXJuIHN0eWxlOwogICAgfQogICAgaWYgKHRoaXMuY29sb3IgJiYgdGhpcy5jb2xvci52YWx1ZSkgewogICAgICBjb25zdCBjb2xvciA9IHRoaXMuY29sb3JbX3hmYV9vYmplY3QuJHRvU3R5bGVdKCk7CiAgICAgIHN0eWxlW2NvbG9yLnN0YXJ0c1dpdGgoIiMiKSA/IHByb3BOYW1lIDogYWx0UHJvcE5hbWVdID0gY29sb3I7CiAgICB9CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEZpbHRlciB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ZXh0RGVjb3JhdGlvbiA9ICJsaW5lLXRocm91Z2giOwogICAgICBpZiAodGhpcy5saW5lVGhyb3VnaCA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMub3ZlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAib3ZlcmxpbmUiOwogICAgICBpZiAodGhpcy5vdmVybGluZSA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgc3R5bGUuZm9udFN0eWxlID0gdGhpcy5wb3N0dXJlOwogICAgc3R5bGUuZm9udFNpemUgPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSgwLjk5ICogdGhpcy5zaXplKTsKICAgICgwLCBfaHRtbF91dGlscy5zZXRGb250RmFtaWx5KSh0aGlzLCB0aGlzLCB0aGlzW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXS5mb250RmluZGVyLCBzdHlsZSk7CiAgICBpZiAodGhpcy51bmRlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAidW5kZXJsaW5lIjsKICAgICAgaWYgKHRoaXMudW5kZXJsaW5lID09PSAyKSB7CiAgICAgICAgc3R5bGUudGV4dERlY29yYXRpb25TdHlsZSA9ICJkb3VibGUiOwogICAgICB9CiAgICB9CiAgICBzdHlsZS5mb250V2VpZ2h0ID0gdGhpcy53ZWlnaHQ7CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEZvcm1hdCBleHRlbmRzIF94ZmFfb2JqZWN0LlhGQU9iamVjdCB7CiAgY29uc3RydWN0b3IoYXR0cmlidXRlcykgewogICAgc3VwZXIoVEVNUExBVEVfTlNfSUQsICJmb3JtYXQiLCB0cnVlKTsKICAgIHRoaX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zLnNsb3BlID09PSAiXFwiKSB7CiAgICAgICAgW3gxLCB5MSwgeDIsIHkyXSA9IFswLCAwLCAiMTAwJSIsICIxMDAlIl07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgW3gxLCB5MSwgeDIsIHkyXSA9IFswLCAiMTAwJSIsICIxMDAlIiwgMF07CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGxpbmUgPSB7CiAgICAgIG5hbWU6ICJsaW5lIiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIHhtbG5zOiBTVkdfTlMsCiAgICAgICAgeDEsCiAgICAgICAgeTEsCiAgICAgICAgeDIsCiAgICAgICAgeTIsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbbGluZV0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBzdHlsZTogewogICAgICAgICAgb3ZlcmZsb3c6ICJ2aXNpYmxlIgogICAgICAgIH0KICAgICAgfQogICAgfTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgc3R5bGU6IHsKICAgICAgICAgICAgZGlzcGxheTogImlubGluZSIsCiAgICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBjaGlsZHJlbjogW3N2Z10KICAgICAgfSk7CiAgICB9CiAgICBzdmcuYXR0cmlidXRlcy5zdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICByZXR1cm4gX3V0aWx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eG1sbnM6IFNWR19OUywKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiLAogICAgICAgIHg6IDAsCiAgICAgICAgeTogMCwKICAgICAgICByeDogY29ybmVyU3R5bGUucmFkaXVzLAogICAgICAgIHJ5OiBjb3JuZXJTdHlsZS5yYWRpdXMsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbcmVjdF0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICBvdmVyZmxvdzogInZpc2libGUiCiAgICAgICAgfSwKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgIH0KICAgIH07CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKClbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgc3R5bGU6IHsKICAgICAgICAgICAgZGlzcGxheTogImlubGluZSIsCiAgICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBjaGlsZHJlbjogW3N2Z10KICAgICAgfSk7CiAgICB9CiAgICBzdmcuYXR0cmlidXRlcy5zdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2VzcyhzdmcpOwogIH0KfQpjbG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ICAgICAgICAgIGh0bWxDb250ZW50QXJlYXNbaW5kZXhdLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCwgaWkgPSBjb250ZW50QXJlYXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGNvbnRlbnRBcmVhID0gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb250ZW50QXJlYSA9IGNvbnRlbnRBcmVhc1tpXTsKICAgICAgICBjb25zdCBzcGFjZSA9IHsKICAgICAgICAgIHdpZHRoOiBjb250ZW50QXJlYS53LAogICAgICAgICAgaGVpZ2h0OiBjb250ZW50QXJlYS5oCiAgICAgICAgfTsKICAgICAgICBzdGFydEluZGV4ID0gMDsKICAgICAgICBpZiAobGVhZGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2gobGVhZGVyW194ZmFfb2JqZWN0LiR0b0hUTUxdKHNwYWNlKS5odG1sKTsKICAgICAgICAgIGxlYWRlciA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICh0cmFpbGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2godHJhaWxlcltfeGZhX29iamVjdC4kdG9IVE1MXShzcGFjZSkuaHRtbCk7CiAgICAgICAgICB0cmFpbGVyID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3QgaHRtbCA9IHJvb3RbX3hmYV9vYmplY3QuJHRvSFRNTF0oc3BhY2UpOwogICAgICAgIGlmIChodG1sLnN1Y2Nlc3MpIHsKICAgICAgICAgIGlmIChodG1sLmh0bWwpIHsKICAgICAgICAgICAgaGFzU29tZXRoaW5nID0gaGFzU29tZXRoaW5nIHx8IGh0bWwuaHRtbC5jaGlsZHJlbiAmJiBodG1sLmh0bWwuY2hpbGRyZW4ubGVuZ3RoICE9PSAwOwogICAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2goaHRtbC5odG1sKTsKICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc1NvbWV0aGluZyAmJiBtYWluSHRtbC5jaGlsZHJlbi5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgIG1haW5IdG1sLmNoaWxkcmVuLnBvcCgpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG1haW5IdG1sOwogICAgICAgIH0KICAgICAgICBpZiAoaHRtbC5pc0JyZWFrKCkpIHsKICAgICAgICAgIGNvbnN0IG5vZGUgPSBodG1sLmJyZWFrTm9kZTsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gImF1dG8iKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUubGVhZGVyKSB7CiAgICAgICAgICAgIGxlYWRlciA9IHRoaXNbX3hmYV9vYmplY3QuJHNlYXJjaE5vZGVdKG5vZGUubGVhZGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICBsZWFkZXIgPSBsZWFkZXIgPyBsZWFkZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudHJhaWxlcikgewogICAgICAgICAgICB0cmFpbGVyID0gdGhpc1tfeGZhX29iamVjdC4kc2VhcmNoTm9kZV0obm9kZS50cmFpbGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICB0cmFpbGVyID0gdHJhaWxlciA/IHRyYWlsZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gInBhZ2VBcmVhIikgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IG5vZGVbX3hmYV9vYmplY3QuJG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pbml0eTsKICAgICAgICAgIGlmICh0YXJnZXQgaW5zdGFuY2VvZiBQYWdlQXJlYSkgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IHRhcmdldDsKICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgQ29udGVudEFyZWEpIHsKICAgICAgICAgICAgY29uc3QgaW5kZXggPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7CiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gY3VycmVudEluZGV4KSB7CiAgICAgICAgICAgICAgICBpID0gaW5kZXggLSAxOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaW5kZXg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IHRhcmdldFBhZ2VBcmVhLmNvbnRlbnRBcmVhLmNoaWxkcmVuLmluZGV4T2YodGFyZ2V0KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZsdXNoKGkpOwogICAgICB9CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5wYWdlTnVtYmVyICs9IDE7CiAgICAgIGlmICh0YXJnZXRQYWdlQXJlYSkgewogICAgICAgIGlmICh0YXJnZXRQYWdlQXJlYVtfeGZhX29iamVjdC4kaXNVc2FibGVdKCkpIHsKICAgICAgICAgIHRhcmdldFBhZ2VBcmVhW194ZmFfb2JqZWN0LiRleHRyYV0ubnVtYmVyT2ZVc2UgKz0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGFyZ2V0UGFnZUFyZWEgPSBudWx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gdHJ1ZTsKICAgIH0KICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCBjb250ZW50IGluIFRleHQ6ICR7Y2hpbGRbX3hmYV9vYmplY3QuJG5vZGVOYW1lXX0uYCk7CiAgICByZXR1cm4gZmFsc2U7CiAgfQogIFtfeGZhX29iamVjdC4kb25UZXh0XShzdHIpIHsKICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XSBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkgewogICAgICByZXR1cm47CiAgICB9CiAgICBzdXBlcltfeGZhX29iamVjdC4kb25UZXh0XShzdHIpOwogIH0KICBbX3hmYV9vYmplY3QuJGZpbmFsaXplXSgpIHsKICAgIGlmICh0eXBlb2YgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID0gdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0ucmVwbGFjZUFsbCgiXHJcbiIsICJcbiIpOwogICAgfQogIH0KICBbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpIHsKICAgIGlmICh0eXBlb2YgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOVx1MjAyOFxuXS8pLnJlZHVjZSgoYWNjLCBsaW5lKSA9PiB7CiAgICAgICAgaWYgKGxpbmUpIHsKICAgICAgICAgIGFjYy5wdXNoKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYWNjOwogICAgICB9LCBbXSkuam9pbigiXG4iKTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBpZiAodHlwZW9mIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID09PSAic3RyaW5nIikgewogICAgICBjb25zdCBodG1sID0gdmFsdWVUb0h0bWwodGhpc1tfeGZhX29iamVjdC4kY29udGVudF0pLmh0bWw7CiAgICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5pbmNsdWRlcygiXHUyMDI5IikpIHsKICAgICAgICBodG1sLm5hbWUgPSAiZGl2IjsKICAgICAgICBodG1sLmNoaWxkcmVuID0gW107CiAgICAgICAgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0uc3BsaXQoIlx1MjAyOSIpLm1hcChwYXJhID0+IHBhcmEuc3BsaXQoL1tcdTIwMjhcbl0vKS5yZWR1Y2UoKGFjYywgbGluZSkgPT4gewogICAgICAgICAgYWNjLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIGFjYzsKICAgICAgICB9LCBbXSkpLmZvckVhY2gobGluZXMgPT4gewogICAgICAgICAgaHRtbC5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgbmFtZTogInAiLAogICAgICAgICAgICBjaGlsZHJlbjogbGluZXMKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKC9bXHUyMDI4XG5dLy50ZXN0KHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdKSkgewogICAgICAgIGh0bWwubmFtZSA9ICJkaXYiOwogICAgICAgIGh0bWwuY2hpbGRyZW4gPSBbXTsKICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOFxuXS8pLmZvckVhY2gobGluZSA9PiB7CiAgICAgICAgICBodG1sLmNoaWxk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AgIGZpZWxkSWQ6IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgY2xhc3M6IFsieGZhVGV4dGZpZWxkIl0sCiAgICAgICAgICBzdHlsZSwKICAgICAgICAgICJhcmlhLWxhYmVsIjogYXJpYUxhYmVsKGZpZWxkKSwKICAgICAgICAgICJhcmlhLXJlcXVpcmVkIjogZmFsc2UKICAgICAgICB9CiAgICAgIH07CiAgICB9IGVsc2UgewogICAgICBodG1sID0gewogICAgICAgIG5hbWU6ICJpbnB1dCIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgdHlwZTogInRleHQiLAogICAgICAgICAgZGF0YUlkOiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV0gJiYgZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdW194ZmFfb2JqZWN0LiR1aWRdIHx8IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgZmllbGRJZDogZmllbGRbX3hmYV9vYmplY3QuJHVpZF0sCiAgICAgICAgICBjbGFzczogWyJ4ZmFUZXh0ZmllbGQiXSwKICAgICAgICAgIHN0eWxlLAogICAgICAgICAgImFyaWEtbGFiZWwiOiBhcmlhTGFiZWwoZmllbGQpLAogICAgICAgICAgImFyaWEtcmVxdWlyZWQiOiBmYWxzZQogICAgICAgIH0KICAgICAgfTsKICAgIH0KICAgIGlmIChpc1JlcXVpcmVkKGZpZWxkKSkgewogICAgICBodG1sLmF0dHJpYnV0ZXNbImFyaWEtcmVxdWlyZWQiXSA9IHRydWU7CiAgICAgIGh0bWwuYXR0cmlidXRlcy5yZXF1aXJlZCA9IHRydWU7CiAgICB9CiAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgIG5hbWU6ICJsYWJlbCIsCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICBjbGFzczogWyJ4ZmFMYWJlbCJdCiAgICAgIH0sCiAgICAgIGNoaWxkcmVuOiBba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Ghpcy5jaGVja0J1dHRvbiA9IG51bGw7CiAgICB0aGlzLmNob2ljZUxpc3QgPSBudWxsOwogICAgdGhpcy5kYXRlVGltZUVkaXQgPSBudWxsOwogICAgdGhpcy5kZWZhdWx0VWkgPSBudWxsOwogICAgdGhpcy5pbWFnZUVkaXQgPSBudWxsOwogICAgdGhpcy5udW1lcmljRWRpdCA9IG51bGw7CiAgICB0aGlzLnBhc3N3b3JkRWRpdCA9IG51bGw7CiAgICB0aGlzLnNpZ25hdHVyZSA9IG51bGw7CiAgICB0aGlzLnRleHRFZGl0ID0gbnVsbDsKICB9CiAgW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oKSB7CiAgICBpZiAodGhpc1tfeGZhX29iamVjdC4kZXh0cmFdID09PSB1bmRlZmluZWQpIHsKICAgICAgZm9yIChjb25zdCBuYW1lIG9mIE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzKHRoaXMpKSB7CiAgICAgICAgaWYgKG5hbWUgPT09ICJleHRyYXMiIHx8IG5hbWUgPT09ICJwaWN0dXJlIikgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3hmYV9vYmplY3QuWEZBT2JqZWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXSA9IG9iajsKICAgICAgICByZXR1cm4gb2JqOwogICAgICB9CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXSA9IG51bGw7CiAgICB9CiAgICByZXR1cm4gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdOwogIH0KICBbX3hmYV9vYmplY3QuJHRvSFRNTF0oYXZhaWxhYmxlU3BhY2UpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXNbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpOwogICAgaWYgK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RoaXMuZXhEYXRhW194ZmFfb2JqZWN0LiRjb250ZW50XSA9PT0gInN0cmluZyIpIHsKICAgICAgICByZXR1cm4gdGhpcy5leERhdGFbX3hmYV9vYmplY3QuJGNvbnRlbnRdLnRyaW0oKTsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5leERhdGFbX3hmYV9vYmplY3QuJGNvbnRlbnRdW194ZmFfb2JqZWN0LiR0ZXh0XSgpLnRyaW0oKTsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImltYWdlIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3QpIHsKICAgICAgICByZXR1cm4gKG9ialtfeGZhX29iamVjdC4kY29udGVudF0gfHwgIiIpLnRvU3RyaW5nKCkudHJpbSgpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbnVsbDsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgY29uc3Qgb2JqID0gdGhpc1tuYW1lXTsKICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3hmYV9vYmplY3QuWEZBT2JqZWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHJldHVybiBvYmpbX3hmYV9vYmplY3QuJHRvSFRNTF0oYXZhaWxhYmxlU3BhY2UpOwogICAgfQogICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkVNUFRZOwogIH0KfQpleHBvcnRzLlZhbHVlID0gVmFsdWU7CmNsYXNzIFZhcmlhYmxlcyB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bmUgPSBjcmVhdGVMaW5lKG5vZGUsIFtdKTsKICAgICAgICBleHRyYS5jaGlsZHJlbi5wdXNoKGV4dHJhLmxpbmUpOwogICAgICAgIGV4dHJhLm51bWJlckluTGluZSA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEubnVtYmVySW5MaW5lICs9IDE7CiAgICAgIGV4dHJhLmxpbmUuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgaWYgKGV4dHJhLmF0dGVtcHQgPT09IDApIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGV4dHJhLnByZXZIZWlnaHQgKyBoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggPSB3OwogICAgICAgIGV4dHJhLnByZXZIZWlnaHQgPSBleHRyYS5oZWlnaHQ7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuYXR0ZW1wdCA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEud2lkdGggPSBNYXRoLm1heChleHRyYS53aWR0aCwgZXh0cmEuY3VycmVudFdpZHRoKTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgewogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgZXh0cmEud2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGgpOwogICAgICAgIGNvbnN0IGhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKGV4dHJhLmhlaWdodCk7CiAgICAgICAgZm9yIChjb25zdCBjaGlsZCBvZiBleHRyYS5jaGlsZHJlbikgewogICAgICAgICAgY2hpbGQuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICBjYXNlICJ0YWJsZSI6CiAgICAgIHsKICAgICAgICBleHRyYS53aWR0aCA9IE1hdGgubWluKGF2YWlsYWJsZVNwYWNlLndpZHRoLCBNYXRoLm1heChleHRyYS53aWR0aCwgdykpOwogICAgICAgIGV4dHJhLmhlaWdodCArPSBoOwogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIGNhc2UgInRiIjoKICAgICAgewogICAgICAgIGV4dHJhLndpZHRoID0gTWF0aC5taW4oYXZhaWxhYmxlU3BhY2Uud2lkdGgsIE1hdGgubWF4KGV4dHJhLndpZHRoLCB3KSk7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogIH0KfQpmdW5jdGlvbiBnZXRBdmFpbGFibGVTcGFjZShub2RlKSB7CiAgY29uc3QgYXZhaWxhYmxlU3BhY2UgPSBub2RlW194ZmFfb2JqZWN0LiRleHRyYV0uYXZhaWxhYmxlU3BhY2U7CiAgY29uc3QgbWFyZ2luViA9IG5vZGUubWFyZ2luID8gbm9kZS5tYXJnaW4udG9wSW5zZXQgKyBub2RlLm1hcmdpbi5ib3R0b21JbnNldCA6IDA7CiAgY29uc3QgbWFyZ2luSCA9IG5vZGUubWFyZ2luID8gbm9kZS5tYXJnaW4ubGVmdEluc2V0ICsgbm9kZS5tYXJnaW4ucmlnaHRJbnNldCA6IDA7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAibHItdGIiOgogICAgY2FzZSAicmwtdGIiOgogICAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLmF0dGVtcHQgPT09IDApIHsKICAgICAgICByZXR1cm4gewogICAgICAgICAgd2lkdGg6IGF2YWlsYW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vbiBnZXRUcmFuc2Zvcm1lZEJCb3gobm9kZSkgewogIGxldCB3ID0gbm9kZS53ID09PSAiIiA/IE5hTiA6IG5vZGUudzsKICBsZXQgaCA9IG5vZGUuaCA9PT0gIiIgPyBOYU4gOiBub2RlLmg7CiAgbGV0IFtjZW50ZXJYLCBjZW50ZXJZXSA9IFswLCAwXTsKICBzd2l0Y2ggKG5vZGUuYW5jaG9yVHlwZSB8fCAiIikgewogICAgY2FzZSAiYm90dG9tQ2VudGVyIjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3cgLyAyLCBoXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJib3R0b21MZWZ0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gWzAsIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgImJvdHRvbVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUNlbnRlciI6CiAgICAgIFtjZW50ZXJYLCBjZW50ZXJZXSA9IFt3IC8gMiwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUxlZnQiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbMCwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGggLyAyXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJ0b3BDZW50ZXIiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbdyAvIDIsIDBdOwogICAgICBicmVhazsKICAgIGNhc2UgInRvcFJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIDBdOwogICAgICBicmVhazsKICB9CiAgbGV0IHgsIHk7CiAgc3dpdGNoIChub2RlLnJvdGF0ZSB8fCAwKSB7CiAgICBjYXNlIDA6CiAgICAgIFt4LCB5XSA9I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sYXlvdXQpIHsKICAgIGNhc2UgImxyLXRiIjoKICAgIGNhc2UgInJsLXRiIjoKICAgICAgaWYgKGF0dGVtcHQgPT09IDApIHsKICAgICAgICBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgICAgaWYgKG5vZGUuaCAhPT0gIiIgJiYgTWF0aC5yb3VuZChoIC0gc3BhY2UuaGVpZ2h0KSA+IEVSUk9SKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChub2RlLncgIT09ICIiKSB7CiAgICAgICAgICAgIGlmIChNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocGFyZW50W194ZmFfb2JqZWN0LiRleHRyYV0ubnVtYmVySW5MaW5lID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzcGFjZS53aWR0aCA+IEVSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAobm9kZS53ICE9PSAiIikgewogICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQodyAtIHNwYWNlLndpZHRoKSA8PSBFUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHNwYWNlLndpZHRoID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICA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cCBsZWZ0IjsKICAgIH0KICB9LAogIHByZXNlbmNlKG5vZGUsIHN0eWxlKSB7CiAgICBzd2l0Y2ggKG5vZGUucHJlc2VuY2UpIHsKICAgICAgY2FzZSAiaW52aXNpYmxlIjoKICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhpZGRlbiI6CiAgICAgIGNhc2UgImluYWN0aXZlIjoKICAgICAgICBzdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICAgIGJyZWFrOwogICAgfQogIH0sCiAgaEFsaWduKG5vZGUsIHN0eWxlKSB7CiAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdID09PSAicGFyYSIpIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImp1c3RpZnlBbGwiOgogICAgICAgICAgc3R5bGUudGV4dEFsaWduID0gImp1c3RpZnktYWxsIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJhZGl4IjoKICAgICAgICAgIHN0eWxlLnRleHRBbGlnbiA9ICJsZWZ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBub2RlLmhBbGlnbjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgICAgc3R5bGUuYWxpZ25TZWxmID0gInN0YXJ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImNlbnRlciI6CiAgICAgICAgICBzdHlsZS5hbGlnblNlbGYgPSAiY2VudGVyIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICAgIHN0eWxlLmFsaWduU2VsZiA9ICJlbmQiOwogICAgICAgICAgYnJlYWs7CiAgICAgI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IHdpZHRoID0gcmVzLndpZHRoOwogICAgICBoZWlnaHQgPSByZXMuaGVpZ2h0OwogICAgICBpc0Jyb2tlbiA9IHJlcy5pc0Jyb2tlbjsKICAgIH0gZWxzZSB7CiAgICAgIGNvbnN0IHRleHQgPSBub2RlLnZhbHVlW194ZmFfb2JqZWN0LiR0ZXh0XSgpOwogICAgICBpZiAodGV4dCkgewogICAgICAgIGNvbnN0IHJlcyA9IGxheW91dFRleHQodGV4dCwgZm9udCwgbWFyZ2luLCBsaW5lSGVpZ2h0LCBmb250RmluZGVyLCBtYXhXaWR0aCk7CiAgICAgICAgd2lkdGggPSByZXMud2lkdGg7CiAgICAgICAgaGVpZ2h0ID0gcmVzLmhlaWdodDsKICAgICAgICBpc0Jyb2tlbiA9IHJlcy5pc0Jyb2tlbjsKICAgICAgfQogICAgfQogICAgaWYgKHdpZHRoICE9PSBudWxsICYmICFub2RlLncpIHsKICAgICAgd2lkdGggKz0gbWFyZ2luSDsKICAgIH0KICAgIGlmIChoZWlnaHQgIT09IG51bGwgJiYgIW5vZGUuaCkgewogICAgICBoZWlnaHQgKz0gbWFyZ2luVjsKICAgIH0KICB9CiAgcmV0dXJuIHsKICAgIHc6IHdpZHRoLAogICAgaDogaGVpZ2h0LAogICAgaXNCcm9rZW4KICB9Owp9CmZ1bmN0aW9uIGNvbXB1dGVCYm94KG5vZGUsIGh0bWwsIGF2YWlsYWJsZVNwYWNlKSB7CiAgbGV0IGJib3g7CiAgaWYgKG5vZGUudyAhPT0gIiIgJiYgbm9kZS5oICE9PSAiIikgewogICAgYmJveCA9IFtub2RlLngsIG5vZGUueSwgbm9kZS53LCBub2RlLmhdOwogIH0gZWxzZSB7CiAgICBpZiAoIWF2YWlsYWJsZVNwYWNlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IHdpZHRoID0gbm9kZS53OwogICAgaWYgKHdpZHRoID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhXID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQudyAhPT0gIiIpIHsKICAgICAgICAgIHdpZHRoID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2lkdGggPSBub2RlLm1pblc7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHdpZHRoID0gTWF0aC5taW4obm9kZS5tYXhXLCBhdmFpbGFibGVTcGFjZS53aWR0aCk7CiAgICAgIH0KICAgICAgaHRtbC5hdHRyaWJ1dGVzLnN0eWxlLndpZHRoID0gbWVhc3VyZVRvU3RyaW5nKHdpZHRoKTsKICAgIH0KICAgIGxldCBoZWlnaHQgPSBub2RlLmg7CiAgICBpZiAoaGVpZ2h0ID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhIID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQuaCAhPT0gIiIpIHsKICAgICAgICAgIGhlaWdodCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGhlaWdodCA9IG5vZGUubWluSDsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgaGVpZ2h0ID0gTWF0aC5taW4obm9kZS5tYXhILCBhdmFpbGFibGVTcGFjZS5oZWlnaHQpOwogICAgICB9CiAgICAgIGh0bWwuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBtZWFzdXJlVG9TdHJpbmcoaGVpZ2h0KTsKICAgIH0KICAgIGJib3ggPSBbbm9kZS54LCBub2RlLnksIHdpZHRoLCBoZWlnaHRdOwogIH0KICByZXR1cm4gYmJveDsKfQpmdW5jdGlv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RlLmxheW91dCkgewogICAgY2FzZSAicG9zaXRpb24iOgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICAgIGNhc2UgImxyLXRiIjoKICAgICAgcmV0dXJuICJ4ZmFMclRiIjsKICAgIGNhc2UgInJsLXJvdyI6CiAgICAgIHJldHVybiAieGZhUmxSb3ciOwogICAgY2FzZSAicmwtdGIiOgogICAgICByZXR1cm4gInhmYVJsVGIiOwogICAgY2FzZSAicm93IjoKICAgICAgcmV0dXJuICJ4ZmFSb3ciOwogICAgY2FzZSAidGFibGUiOgogICAgICByZXR1cm4gInhmYVRhYmxlIjsKICAgIGNhc2UgInRiIjoKICAgICAgcmV0dXJuICJ4ZmFUYiI7CiAgICBkZWZhdWx0OgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICB9Cn0KZnVuY3Rpb24gdG9TdHlsZShub2RlKSB7CiAgY29uc3Qgc3R5bGUgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBuYW1lcyA9IG5ldyBBcnJheShfbGVuID4gMSA/IF9sZW4gLSAxIDogMCksIF9rZXkgPSAxOyBfa2V5IDwgX2xlbjsgX2tleSsrKSB7CiAgICBuYW1lc1tfa2V5IC0gMV0gPSBhcmd1bWVudHNbX2tleV07CiAgfQogIGZvciAoY29uc3QgbmFtZSBvZiBuYW1lcykgewogICAgY29uc3QgdmFsdWUgPSBub2RlW25hbWVdOwogICAgaWYgKHZhbHVlID09PSBudWxsKSB7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgaWYgKGNvbnZlcnRlcnMuaGFzT3duUHJvcGVydHkobmFtZSkpIHsKICAgICAgY29udmVydGVyc1tuYW1lXShub2RlLCBzdHlsZSk7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3hmYV9vYmplY3QuWEZBT2JqZWN0KSB7CiAgICAgIGNvbnN0IG5ld1N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AgICAgY2FzZSAiZXZlbiI6CiAgICAgICAgdG9wIC09IHdpZHRoc1swXSAvIDI7CiAgICAgICAgbGVmdCAtPSB3aWR0aHNbM10gLyAyOwogICAgICAgIHdpZHRoID0gYGNhbGMoMTAwJSArICR7KHdpZHRoc1sxXSArIHdpZHRoc1szXSkgLyAyIC0gaW5zZXRzV31weClgOwogICAgICAgIGhlaWdodCA9IGBjYWxjKDEwMCUgKyAkeyh3aWR0aHNbMF0gKyB3aWR0aHNbMl0pIC8gMiAtIGluc2V0c0h9cHgpYDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgdG9wIC09IHdpZHRoc1swXTsKICAgICAgICBsZWZ0IC09IHdpZHRoc1szXTsKICAgICAgICB3aWR0aCA9IGBjYWxjKDEwMCUgKyAke3dpZHRoc1sxXSArIHdpZHRoc1szXSAtIGluc2V0c1d9cHgpYDsKICAgICAgICBoZWlnaHQgPSBgY2FsYygxMDAlICsgJHt3aWR0aHNbMF0gKyB3aWR0aHNbMl0gLSBpbnNldHNIfXB4KWA7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICB3aWR0aCA9IGluc2V0c1cgPyBgY2FsYygxMDAlIC0gJHtpbnNldHNXfXB4KWAgOiAiMTAwJSI7CiAgICAgICAgaGVpZ2h0ID0gaW5zZXRzSCA/IGBjYWxjKDEwMCUgLSAke2luc2V0c0h9cHgpYCA6ICIxMDAlIjsKICAgICAgICBicmVhazsKICAgIH0KICAgIGNvbnN0IGNsYXNzTmFtZXMgPSBbInhmYUJvcmRlciJdOwogICAgaWYgKGlzUHJpbnRPbmx5KG5vZGUuYm9yZGVyKSkgewogICAgICBjbGFzc05hbWVzLnB1c2goInhmYVByaW50T25seSIpOwogICAgfQogICAgY29uc3QgYm9yZGVyID0gewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBjbGFzc05hbWVzLAogICA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AwKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG15cmlhZCA9IHRoaXMuZm9udHMuZ2V0KCJQZGZKUy1GYWxsYmFjay1QZGZKUy1YRkEiKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiByZWFsbHlNaXNzaW5nRm9udHMpIHsKICAgICAgdGhpcy5mb250cy5zZXQobWlzc2luZywgbXlyaWFkKTsKICAgIH0KICB9CiAgYWRkUGRmRm9udChwZGZGb250KSB7CiAgICBjb25zdCBjc3NGb250SW5mbyA9IHBkZkZvbnQuY3NzRm9udEluZm87CiAgICBjb25zdCBuYW1lID0gY3NzRm9udEluZm8uZm9udEZhbWlseTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoIWZvbnQpIHsKICAgICAgZm9udCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgIHRoaXMuZm9udHMuc2V0KG5hbWUsIGZvbnQpOwogICAgICBpZiAoIXRoaXMuZGVmYXVsdEZvbnQpIHsKICAgICAgICB0aGlzLmRlZmF1bHRGb250ID0gZm9udDsKICAgICAgfQogICAgfQogICAgbGV0IHByb3BlcnR5ID0gIiI7CiAgICBjb25zdCBmb250V2VpZ2h0ID0gcGFyc2VGbG9hdChjc3NGb250SW5mby5mb250V2VpZ2h0KTsKICAgIGlmIChwYXJzZUZsb2F0KGNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSAhPT0gMCkgewogICAgICBwcm9wZXJ0eSA9IGZvbnRXZWlnaHQgPj0gNzAwID8gImJvbGRpdGFsaWMiIDogIml0YWxpYyI7CiAgICB9IGVsc2UgaWYgKGZvbnRXZWlnaHQgPj0gNzAwKSB7CiAgICAgIHByb3BlcnR5ID0gImJvbGQiOwogICAgfQogICAgaWYgKCFwcm9wZXJ0eSkgewogICAgICBpZiAocGRmRm9udC5uYW1lLmluY2x1ZGVzKCJCb2xkIikgfHwgcGRmRm9udC5wc05hbWUgJiYgcGRmR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AgIHJldHVybiBmb250OwogICAgfQogICAgbmFtZSA9IG5hbWUudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IG1heWJlID0gW107CiAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgIGlmIChmYW1pbHkucmVwbGFjZUFsbChwYXR0ZXJuLCAiIikudG9Mb3dlckNhc2UoKS5zdGFydHNXaXRoKG5hbWUpKSB7CiAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgfQogICAgfQogICAgaWYgKG1heWJlLmxlbmd0aCA9PT0gMCkgewogICAgICBmb3IgKGNvbnN0IFssIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPT09IDApIHsKICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZUFsbCgvcHNtdHxtdC9naSwgIiIpOwogICAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKGZhbWlseS5yZXBsYWNlQWxsKHBhdHRlcm4sICIiKS50b0xvd2VyQ2FzZSgpLnN0YXJ0c1dpdGgobmFtZSkpIHsKICAgICAgICAgIG1heWJlLnB1c2gocGRmRm9udCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAobWF5YmUubGVuZ3RoID09PSAwKSB7CiAgICAgIGZvciAoY29uc3QgcGRmRm9udCBvZiB0aGlzLmZvbnRzLnZhbHVlcyg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wogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSAwOwogICAgICAgICAgaXNCcm9rZW4gPSB0cnVlOwogICAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSBjdXJyZW50TGluZVdpZHRoOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gaTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnRMaW5lV2lkdGggKyBnbHlwaFdpZHRoID4gbWF4V2lkdGgpIHsKICAgICAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQ7CiAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICBpZiAobGFzdFNwYWNlUG9zICE9PSAtMSkgewogICAgICAgICAgaSA9IGxhc3RTcGFjZVBvczsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGxhc3RTcGFjZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgICBsYXN0U3BhY2VXaWR0aCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGN1cnJlbnRMaW5lV2lkdGgpOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCA9IGdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGlzQnJva2VuID0gdHJ1ZTsKICAgICAgICBpc0ZpcnN0TGluZSA9IGZhbHNlOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9Ci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aXRoKCJ4bWxuczoiKSkgewogICAgICAgIGNvbnN0IHByZWZpeCA9IG5hbWUuc3Vic3RyaW5nKCJ4bWxuczoiLmxlbmd0aCk7CiAgICAgICAgaWYgKCFwcmVmaXhlcykgewogICAgICAgICAgcHJlZml4ZXMgPSBbXTsKICAgICAgICB9CiAgICAgICAgcHJlZml4ZXMucHVzaCh7CiAgICAgICAgICBwcmVmaXgsCiAgICAgICAgICB2YWx1ZQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGkgPSBuYW1lLmluZGV4T2YoIjoiKTsKICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgIGF0dHJpYnV0ZU9ialtuYW1lXSA9IHZhbHVlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZXQgbnNBdHRycyA9IGF0dHJpYnV0ZU9ialtfeGZhX29iamVjdC4kbnNBdHRyaWJ1dGVzXTsKICAgICAgICAgIGlmICghbnNBdHRycykgewogICAgICAgICAgICBuc0F0dHJzID0gYXR0cmlidXRlT2JqW194ZmFfb2JqZWN0LiRuc0F0dHJpYnV0ZXNdID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IFtucywgYXR0ck5hbWVdID0gW25hbWUuc2xpY2UoMCwgaSksIG5hbWUuc2xpY2UoaSArIDEpXTsKICAgICAgICAgIGxldCBhdHRycyA9IG5zQXR0cnNbbnNdOwogICAgICAgICAgaWYgKCFhdHRycykgewogICAgICAgICAgICBhdHRycyA9IG5zQXR0cnNbbnNdID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgIH0KICAgICAgICAgIGF0dHJzW2F0dHJOYW1lXSA9IHZhbHVlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtuYW1lc3BhY2UsIHByZWZpeGVzLCBhdHRyaWJ1dGVPYmpdOwogIH0KICBfZ2V0TmFtZUFuZFByZWZpeChuYW1l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XJjaE5hbWVzcGFjZShuc05hbWUpIHsKICAgIGxldCBucyA9IHRoaXMuX25hbWVzcGFjZXMuZ2V0KG5zTmFtZSk7CiAgICBpZiAobnMpIHsKICAgICAgcmV0dXJuIG5zOwogICAgfQogICAgZm9yIChjb25zdCBbbmFtZSwgewogICAgICBjaGVjawogICAgfV0gb2YgT2JqZWN0LmVudHJpZXMoX25hbWVzcGFjZXMuTmFtZXNwYWNlSWRzKSkgewogICAgICBpZiAoY2hlY2sobnNOYW1lKSkgewogICAgICAgIG5zID0gX3NldHVwLk5hbWVzcGFjZVNldFVwW25hbWVdOwogICAgICAgIGlmIChucykgewogICAgICAgICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICAgICAgICByZXR1cm4gbnM7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBucyA9IG5ldyBfdW5rbm93bi5Vbmtub3duTmFtZXNwYWNlKCsrdGhpcy5fbmV4dE5zSWQpOwogICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICByZXR1cm4gbnM7CiAgfQogIF9hZGROYW1lc3BhY2VQcmVmaXgocHJlZml4ZXMpIHsKICAgIGZvciAoY29uc3QgewogICAgICBwcmVmaXgsCiAgICAgIHZhbHVlCiAgICB9IG9mIHByZWZpeGVzKSB7CiAgICAgIGNvbnN0IG5hbWVzcGFjZSA9IHRoaXMuX3NlYXJjaE5hbWVzcGFjZSh2YWx1ZSk7CiAgICAgIGxldCBwcmVmaXhTdGFjayA9IHRoaXMuX25hbWVzcGFjZVByZWZpeGVzLmdldChwcmVmaXgpOwogICAgICBpZiAoIXByZWZpeFN0YWNrKSB7CiAgICAgICAgcHJlZml4U3RhY2sgPSBbXTsKICAgICAgICB0aGlzLl9uYW1lc3BhY2VQcmVmaXhlcy5zZXQocHJlZml4LCBwcmVmaXhTdGFjayk7CiAgICAgIH0KICAgICAgcHJlZml4U3RhY2sucHVz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JvdHRvbTogTmFOLAogICAgICBsZWZ0OiBOYU4sCiAgICAgIHJpZ2h0OiBOYU4KICAgIH07CiAgICBsZXQgbGluZUhlaWdodCA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiB0aGlzLnN0eWxlLnNwbGl0KCI7IikubWFwKHMgPT4gcy5zcGxpdCgiOiIsIDIpKSkgewogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgImZvbnQtZmFtaWx5IjoKICAgICAgICAgIHhmYUZvbnQudHlwZWZhY2UgPSAoMCwgX3V0aWxzLnN0cmlwUXVvdGVzKSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmb250LXNpemUiOgogICAgICAgICAgeGZhRm9udC5zaXplID0gKDAsIF91dGlscy5nZXRNZWFzdXJlbWVudCkodmFsdWUpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZm9udC13ZWlnaHQiOgogICAgICAgICAgeGZhRm9udC53ZWlnaHQgPSB2YWx1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZvbnQtc3R5bGUiOgogICAgICAgICAgeGZhRm9udC5wb3N0dXJlID0gdmFsdWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZXR0ZXItc3BhY2luZyI6CiAgICAgICAgICB4ZmFGb250LmxldHRlclNwYWNpbmcgPSAoMCwgX3V0aWxzLmdldE1lYXN1cmVtZW50KSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtYXJnaW4iOgogICAgICAgICAgY29uc3QgdmFsdWVzID0gdmFsdWUuc3BsaXQoLyBcdC8pLm1hcCh4ID0+ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHgpKTsKICAgICAgICAgIHN3aXRjaCAodmFsdWVzLmxlbmd0aCkgewogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IG1hcmdpbi5ib3R0b20gPSBtYXJnaW4ubGVmdCA9IG1hcmdpbi5yaWdodCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIG1hcmdpbi50b3AgPSBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzBdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4ubGVmdCA9IHZhbHVlc1sxXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5yaWdodCA9IHZhbHVlc1szXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1hcmdpbi10b3AiOgogICAgICAgICAgbWFyZ2luLnRvcCA9ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHZhbHVlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1hcmdpbi1ib3R0b20iOgogICAgICAgICAgbWFyZ2luLmJvdHRvbSA9ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHZhbHVlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1hcm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AgICAgICAgfQogICAgICAgICAgZ2VuZXJhdGlvbiA9IGdlbmVyYXRpb24gPDwgOCB8IGdlbmVyYXRpb25CeXRlOwogICAgICAgIH0KICAgICAgICBjb25zdCBlbnRyeSA9IHt9OwogICAgICAgIGVudHJ5Lm9mZnNldCA9IG9mZnNldDsKICAgICAgICBlbnRyeS5nZW4gPSBnZW5lcmF0aW9uOwogICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICBlbnRyeS5mcmVlID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgIGVudHJ5LnVuY29tcHJlc3NlZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgSW52YWxpZCBYUmVmIGVudHJ5IHR5cGU6ICR7dHlwZX1gKTsKICAgICAgICB9CiAgICAgICAgaWYgKCF0aGlzLmVudHJpZXNbZmlyc3QgKyBpXSkgewogICAgICAgICAgdGhpcy5lbnRyaWVzW2ZpcnN0ICsgaV0gPSBlbnRyeTsKICAgICAgICB9CiAgICAgIH0KICAgICAgc3RyZWFtU3RhdGUuZW50cnlOdW0gPSAwOwogICAgICBzdHJlYW1TdGF0ZS5zdHJlYW1Qb3MgPSBzdHJlYW0ucG9zOwogICAgICBlbnRyeVJhbmdlcy5zcGxpY2UoMCwgMik7CiAgICB9CiAgfQogIGluZGV4T2JqZWN0cygpIHsKICAgIGNvbnN0IFRBQiA9IDB4OSwKICAgICAgTEYgPSAweGEsCiAgICAgIENSID0gMHhkLAogICAgICBTUEFDRSA9IDB4MjA7CiAgICBjb25zdCBQRVJDRU5UID0gMHgyNSwKICAgICAgTFQgPSAweDNjOwogICAgZnVuY3Rpb24gcmVhZFRva2VuKGRhdGEsIG9mZnNldCkgewogICAgICBsZXQgdG9rZW4gPSAiIiwKICAgICAgICBjaCA9IGRhdGFbb2Zmc2V0XTsKICAgICAgd2hpbGUgKGNoICE9PSBMRiAmJiBjaCAhPT0gQ1IgJiYgY2ggIT09IExUKSB7CiAgICAgICAgaWYgKCsrb2Zmc2V0ID49IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdG9rZW4gKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICAgICAgY2ggPSBkYXRhW29mZnNldF07CiAgICAgIH0KICAgICAgcmV0dXJuIHRva2VuOwogICAgfQogICAgZnVuY3Rpb24gc2tpcFVudGlsKGRhdGEsIG9mZnNldCwgd2hhdCkgewogICAgICBjb25zdCBsZW5ndGggPSB3aGF0Lmxlbmd0aCwKICAgICAgICBkYXRhTGVuZ3RoID0gZGF0YS5sZW5ndGg7CiAgICAgIGxldCBza2lwcGVkID0gMDsKICAgICAgd2hpbGUgKG9mZnNldCA8IGRhdGFMZW5ndGgpIHsKICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgd2hpbGUgKGkgPCBsZW5ndGggJiYgZGF0YVtvZmZzZXQgKyBpXSA9PT0gd2hhdFtpXSkgewogICAgICAgICAgKytpOwogICAgICAgIH0KICAgICAgICBpZiAoaSA+PSBsZW5ndGgpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBvZmZzZXQrKzsKICAgICAgICBza2lwcGVkKys7CiAgICAgIH0KICAgICAgcmV0dXJuIHNraXBwZWQ7CiAgICB9CiAgICBjb25zdCBnRW5kb2JqUmVnRXhwID0gL1xiKGVuZG9ianxcZCtccytcZCtccytvYmp8eHJlZnx0cmFpbGVyKVxiL2c7CiAgICBjb25zdCBnU3RhcnR4cmVmUmVnRXhwID0gL1xiKHN0YXJ0eHJlZnxcZCtccytcZCtccytvYmopXGIvZzsKICAgIGNvbnN0IG9ialJlZ0V4cCA9IC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W9uID49IGxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNoID0gYnVmZmVyW3Bvc2l0aW9uXTsKICAgICAgICB9IHdoaWxlIChjaCAhPT0gTEYgJiYgY2ggIT09IENSKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0b2tlbiA9IHJlYWRUb2tlbihidWZmZXIsIHBvc2l0aW9uKTsKICAgICAgbGV0IG07CiAgICAgIGlmICh0b2tlbi5zdGFydHNXaXRoKCJ4cmVmIikgJiYgKHRva2VuLmxlbmd0aCA9PT0gNCB8fCAvXHMvLnRlc3QodG9rZW5bNF0pKSkgewogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCB0cmFpbGVyQnl0ZXMpOwogICAgICAgIHRyYWlsZXJzLnB1c2gocG9zaXRpb24pOwogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCBzdGFydHhyZWZCeXRlcyk7CiAgICAgIH0gZWxzZSBpZiAobSA9IG9ialJlZ0V4cC5leGVjKHRva2VuKSkgewogICAgICAgIGNvbnN0IG51bSA9IG1bMV0gfCAwLAogICAgICAgICAgZ2VuID0gbVsyXSB8IDA7CiAgICAgICAgY29uc3Qgc3RhcnRQb3MgPSBwb3NpdGlvbiArIHRva2VuLmxlbmd0aDsKICAgICAgICBsZXQgY29udGVudExlbmd0aCwKICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSBmYWxzZTsKICAgICAgICBpZiAoIXRoaXMuZW50cmllc1tudW1dKSB7CiAgICAgICAgICB1cGRhdGVFbnRyaWVzID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZW50cmllc1tudW1dLmdlbiA9PT0gZ2VuKSB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBwYXJzZXIgPSBuZXcgX3BhcnNlci5QYXJzZXIoewogICAgICAgICAgICAgIGxleGVyOiBuZXcgX3BhcnNlci5MZXhlcihzdHJlYW0ubWFrZVN1YlN0cmVhbShzdGFydFBvcykpCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSB0cnVlOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHMgLS0gY2hlY2tpbmcgb2JqZWN0ICgke3Rva2VufSk6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdXBkYXRlRW50cmllcyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVwZGF0ZUVudHJpZXMpIHsKICAgICAgICAgIHRoaXMuZW50cmllc1tudW1dID0gewogICAgICAgICAgICBvZmZzZXQ6IHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0LAogICAgICAgICAgICBnZW4sCiAgICAgICAgICAgIHVuY29tcHJlc3NlZDogdHJ1ZQogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggPSBzdGFydFBvczsKICAgICAgICBjb25zdCBtYXRjaCA9IGdFbmRvYmpSZWdFeHAuZXhlYyhidWZmZXJTdHIpOwogICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgY29uc3QgZW5kUG9zID0gZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggKyAxOwogICAgICAgICAgY29udGVudExlbmd0aCA9IGVuZFBvcyAtIHBvc2l0aW9uOwogICAgICAgICAgaWYgKG1hdGNoWzFdICE9PSAiZW5kb2JqIikgewogICAgICAgICAgICAoMCwg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ycykgewogICAgICBzdHJlYW0ucG9zID0gdHJhaWxlcjsKICAgICAgY29uc3QgcGFyc2VyID0gbmV3IF9wYXJzZXIuUGFyc2VyKHsKICAgICAgICBsZXhlcjogbmV3IF9wYXJzZXIuTGV4ZXIoc3RyZWFtKSwKICAgICAgICB4cmVmOiB0aGlzLAogICAgICAgIGFsbG93U3RyZWFtczogdHJ1ZSwKICAgICAgICByZWNvdmVyeU1vZGU6IHRydWUKICAgICAgfSk7CiAgICAgIGNvbnN0IG9iaiA9IHBhcnNlci5nZXRPYmooKTsKICAgICAgaWYgKCEoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgInRyYWlsZXIiKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGRpY3QgPSBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgIGlmICghKGRpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRyYWlsZXJEaWN0cy5wdXNoKGRpY3QpOwogICAgICBpZiAoZGljdC5oYXMoIkVuY3J5cHQiKSkgewogICAgICAgIGlzRW5jcnlwdGVkID0gdHJ1ZTsKICAgICAgfQogICAgfQogICAgbGV0IHRyYWlsZXJEaWN0LCB0cmFpbGVyRXJyb3I7CiAgICBmb3IgKGNvbnN0IGRpY3Qgb2YgWy4uLnRyYWlsZXJEaWN0cywgImdlbkZhbGxiYWNrIiwgLi4udHJhaWxlckRpY3RzXSkgewogICAgICBpZiAoZGljdCA9PT0gImdlbkZhbGxiYWNrIikgewogICAgICAgIGlmICghdHJhaWxlckVycm9yKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZ2VuZXJhdGlvbkZhbGxiYWNrID0gdHJ1ZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdmFsaWRQYWdlc0RpY3QgPSBmYWxzZTsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCByb290RGljdCA9IGRpY3QuZ2V0KCJSb290Iik7CiAgICAgICAgaWYgKCEocm9vdERpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzRGljdCA9IHJvb3REaWN0LmdldCgiUGFnZXMiKTsKICAgICAgICBpZiAoIShwYWdlc0RpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzQ291bnQgPSBwYWdlc0RpY3QuZ2V0KCJDb3VudCIpOwogICAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHBhZ2VzQ291bnQpKSB7CiAgICAgICAgICB2YWxpZFBhZ2VzRGljdCA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRyYWlsZXJFcnJvciA9IGV4OwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWxpZFBhZ2VzRGljdCAmJiAoIWlzRW5jcnlwdGVkIHx8IGRpY3QuaGFzKCJFbmNyeXB0IikpICYmIGRpY3QuaGFzKCJJRCIpKSB7CiAgICAgICAgcmV0dXJuIGRpY3Q7CiAgICAgIH0KICAgICAgdHJhaWxlckRpY3QgPSBkaWN0OwogICAgfQogICAgaWYgKHRyYWlsZXJEaWN0KSB7CiAgICAgIHJldHVybiB0cmFpbGVyRGljdDsKICAgIH0KICAgIGlmICh0aGlzLnRvcERpY3QpIHsKICAgICAgcmV0dXJuIHRoaXMudG9wRGljdDsKICAgIH0KICAgIHRocm93IG5ldyBfdXRpbC5JbnZhbGlkUERGRXhjZXB0aW9uKCJJbnZhbGlkIFBERiBzdHJ1Y3R1cmUuIik7CiAgfQogIHJlYWRYUmVmKCkgewogICAgbGV0IHJlY292ZXJ5TW9kZSA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aXMucHJvY2Vzc1hSZWZUYWJsZShwYXJzZXIpOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGRpY3QuZ2V0KCJYUmVmU3RtIik7CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopICYmICF0aGlzLl94cmVmU3Rtcy5oYXMob2JqKSkgewogICAgICAgICAgICB0aGlzLl94cmVmU3Rtcy5hZGQob2JqKTsKICAgICAgICAgICAgdGhpcy5zdGFydFhSZWZRdWV1ZS5wdXNoKG9iaik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChOdW1iZXIuaXNJbnRlZ2VyKG9iaikpIHsKICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihwYXJzZXIuZ2V0T2JqKCkpIHx8ICEoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKHBhcnNlci5nZXRPYmooKSwgIm9iaiIpIHx8ICEoKG9iaiA9IHBhcnNlci5nZXRPYmooKSkgaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJJbnZhbGlkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgICBkaWN0ID0gdGhpcy5wcm9jZXNzWFJlZlN0cmVhbShvYmopOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghZGljdCkgewogICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkZhaWxlZCB0byByZWFkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHRoc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ShhY3Rpb24oZGF0YS5kYXRhKSk7CiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lOiBjYlNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgIGRhdGE6IHJlc3VsdAogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lOiBjYlRhcmdldE5hbWUsCiAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgIGNhbGxiYWNrSWQ6IGRhdGEuY2FsbGJhY2tJZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGFjdGlvbihkYXRhLmRhdGEpOwogICAgfTsKICAgIGNvbU9iai5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UpOwogIH0KICBvbihhY3Rpb25OYW1lLCBoYW5kbGVyKSB7CiAgICBjb25zdCBhaCA9IHRoaXMuYWN0aW9uSGFuZGxlcjsKICAgIGl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gICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgfQogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICBjaHVuawogICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgIH0sCiAgICAgIGNsb3NlKCkgewogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DTE9TRSwKICAgICAgICAgIHN0cmVhbUlkCiAgICAgICAgfSk7CiAgICAgICAgZGVsZXRlIHNlbGYuc3RyZWFtU2lua3Nbc3RyZWFtSWRdOwogICAgICB9LAogICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImVycm9yIG11c3QgaGF2ZSBhIHZhbGlkIHJlYXNvbiIpOwogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FUlJPUiwKICAgICAg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gICAgICAgaWYgKCFzdHJlYW1TaW5rKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgIHN1Y2Nlc3M6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgIH0KICAgICAgICBzdHJlYW1TaW5rLmRlc2lyZWRTaXplID0gZGF0YS5kZXNpcmVkU2l6ZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uUHVsbCAmJiBzdHJlYW1TaW5rLm9uUHVsbCgpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgc3Ry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ZUhhbmRsZXI7CiAgfQp9KSk7CnZhciBfd29ya2VyID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwpjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7Cn0pKCk7CgovKioqKioqLyAJcmV0dXJuIF9fd2VicGFja19leHBvcnRzX187Ci8qKioqKiovIH0pKCkKOwp9KTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cGRmLndvcmtlci5qcy5tYXA=",window.pdfjsLib.getDocument(this.pdf).promise.then((async g=>{this.pdfDoc=g,this.total=g.numPages,this.onLoad&&this.onLoad({success:!0,data:this.pdfDoc});for(let I=1;I<=this.total;I++)await this.getPdfPage(I)}))})).catch((g=>{this.onError&&this.onError({success:!1,data:g,message:g})}))})),C(this,"prevPage",(()=>{this.pageNumber>1?this.pageNumber-=1:this.pageNumber=1,this.getPdfPage(this.pageNumber)})),C(this,"nextPage",(()=>{this.pageNumber{try{if("undefined"!=typeof window){const C=await(g=>new Promise(((I,C)=>{const A=new FileReader;A.readAsDataURL(g),A.onload=()=>{I(A.result)},A.onerror=g=>{C(g)},A.onabort=g=>{C(g)}})))(g);if(C){new ei(C,I).pdfPreview()}}}catch(C){}}},Symbol.toStringTag,{value:"Module"}));var li={exports:{}}; /** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */!function(g,I){(function(){var C,A="Expected a function",i="__lodash_hash_undefined__",e="__lodash_placeholder__",t=16,l=32,s=64,o=128,c=256,d=1/0,a=9007199254740991,n=NaN,r=4294967295,m=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",t],["flip",512],["partial",l],["partialRight",s],["rearg",c]],h="[object Arguments]",Z="[object Array]",b="[object Boolean]",G="[object Date]",u="[object Error]",p="[object Function]",w="[object GeneratorFunction]",W="[object Map]",B="[object Number]",y="[object Object]",V="[object Promise]",X="[object RegExp]",Y="[object Set]",R="[object String]",N="[object Symbol]",H="[object WeakMap]",K="[object ArrayBuffer]",f="[object DataView]",F="[object Float32Array]",M="[object Float64Array]",S="[object Int8Array]",J="[object Int16Array]",k="[object Int32Array]",D="[object Uint8Array]",v="[object Uint8ClampedArray]",L="[object Uint16Array]",z="[object Uint32Array]",T=/\b__p \+= '';/g,x=/\b(__p \+=) '' \+/g,U=/(__e\(.*?\)|\b__t\)) \+\n'';/g,j=/&(?:amp|lt|gt|quot|#39);/g,Q=/[&<>"']/g,O=RegExp(j.source),E=RegExp(Q.source),P=/<%-([\s\S]+?)%>/g,_=/<%([\s\S]+?)%>/g,q=/<%=([\s\S]+?)%>/g,$=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gg=/^\w*$/,Ig=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Cg=/[\\^$.*+?()[\]{}|]/g,Ag=RegExp(Cg.source),ig=/^\s+/,eg=/\s/,tg=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,lg=/\{\n\/\* \[wrapped with (.+)\] \*/,sg=/,? & /,og=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,cg=/[()=,{}\[\]\/\s]/,dg=/\\(\\)?/g,ag=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ng=/\w*$/,rg=/^[-+]0x[0-9a-f]+$/i,mg=/^0b[01]+$/i,hg=/^\[object .+?Constructor\]$/,Zg=/^0o[0-7]+$/i,bg=/^(?:0|[1-9]\d*)$/,Gg=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ug=/($^)/,pg=/['\n\r\u2028\u2029\\]/g,wg="\\ud800-\\udfff",Wg="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Bg="\\u2700-\\u27bf",yg="a-z\\xdf-\\xf6\\xf8-\\xff",Vg="A-Z\\xc0-\\xd6\\xd8-\\xde",Xg="\\ufe0e\\ufe0f",Yg="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Rg="['’]",Ng="["+wg+"]",Hg="["+Yg+"]",Kg="["+Wg+"]",fg="\\d+",Fg="["+Bg+"]",Mg="["+yg+"]",Sg="[^"+wg+Yg+fg+Bg+yg+Vg+"]",Jg="\\ud83c[\\udffb-\\udfff]",kg="[^"+wg+"]",Dg="(?:\\ud83c[\\udde6-\\uddff]){2}",vg="[\\ud800-\\udbff][\\udc00-\\udfff]",Lg="["+Vg+"]",zg="\\u200d",Tg="(?:"+Mg+"|"+Sg+")",xg="(?:"+Lg+"|"+Sg+")",Ug="(?:['’](?:d|ll|m|re|s|t|ve))?",jg="(?:['’](?:D|LL|M|RE|S|T|VE))?",Qg="(?:"+Kg+"|"+Jg+")"+"?",Og="["+Xg+"]?",Eg=Og+Qg+("(?:"+zg+"(?:"+[kg,Dg,vg].join("|")+")"+Og+Qg+")*"),Pg="(?:"+[Fg,Dg,vg].join("|")+")"+Eg,_g="(?:"+[kg+Kg+"?",Kg,Dg,vg,Ng].join("|")+")",qg=RegExp(Rg,"g"),$g=RegExp(Kg,"g"),gI=RegExp(Jg+"(?="+Jg+")|"+_g+Eg,"g"),II=RegExp([Lg+"?"+Mg+"+"+Ug+"(?="+[Hg,Lg,"$"].join("|")+")",xg+"+"+jg+"(?="+[Hg,Lg+Tg,"$"].join("|")+")",Lg+"?"+Tg+"+"+Ug,Lg+"+"+jg,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",fg,Pg].join("|"),"g"),CI=RegExp("["+zg+wg+Wg+Xg+"]"),AI=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,iI=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],eI=-1,tI={};tI[F]=tI[M]=tI[S]=tI[J]=tI[k]=tI[D]=tI[v]=tI[L]=tI[z]=!0,tI[h]=tI[Z]=tI[K]=tI[b]=tI[f]=tI[G]=tI[u]=tI[p]=tI[W]=tI[B]=tI[y]=tI[X]=tI[Y]=tI[R]=tI[H]=!1;var lI={};lI[h]=lI[Z]=lI[K]=lI[f]=lI[b]=lI[G]=lI[F]=lI[M]=lI[S]=lI[J]=lI[k]=lI[W]=lI[B]=lI[y]=lI[X]=lI[Y]=lI[R]=lI[N]=lI[D]=lI[v]=lI[L]=lI[z]=!0,lI[u]=lI[p]=lI[H]=!1;var sI={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},oI=parseFloat,cI=parseInt,dI="object"==typeof lC&&lC&&lC.Object===Object&&lC,aI="object"==typeof self&&self&&self.Object===Object&&self,nI=dI||aI||Function("return this")(),rI=I&&!I.nodeType&&I,mI=rI&&g&&!g.nodeType&&g,hI=mI&&mI.exports===rI,ZI=hI&&dI.process,bI=function(){try{var g=mI&&mI.require&&mI.require("util").types;return g||ZI&&ZI.binding&&ZI.binding("util")}catch(I){}}(),GI=bI&&bI.isArrayBuffer,uI=bI&&bI.isDate,pI=bI&&bI.isMap,wI=bI&&bI.isRegExp,WI=bI&&bI.isSet,BI=bI&&bI.isTypedArray;function yI(g,I,C){switch(C.length){case 0:return g.call(I);case 1:return g.call(I,C[0]);case 2:return g.call(I,C[0],C[1]);case 3:return g.call(I,C[0],C[1],C[2])}return g.apply(I,C)}function VI(g,I,C,A){for(var i=-1,e=null==g?0:g.length;++i-1}function KI(g,I,C){for(var A=-1,i=null==g?0:g.length;++A-1;);return C}function IC(g,I){for(var C=g.length;C--&&LI(I,g[C],0)>-1;);return C}var CC=jI({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),AC=jI({"&":"&","<":"<",">":">",'"':""","'":"'"});function iC(g){return"\\"+sI[g]}function eC(g){return CI.test(g)}function tC(g){var I=-1,C=Array(g.size);return g.forEach((function(g,A){C[++I]=[A,g]})),C}function sC(g,I){return function(C){return g(I(C))}}function oC(g,I){for(var C=-1,A=g.length,i=0,t=[];++C",""":'"',"'":"'"});var mC=function g(I){var eg,wg=(I=null==I?nI:mC.defaults(nI.Object(),I,mC.pick(nI,iI))).Array,Wg=I.Date,Bg=I.Error,yg=I.Function,Vg=I.Math,Xg=I.Object,Yg=I.RegExp,Rg=I.String,Ng=I.TypeError,Hg=wg.prototype,Kg=yg.prototype,fg=Xg.prototype,Fg=I["__core-js_shared__"],Mg=Kg.toString,Sg=fg.hasOwnProperty,Jg=0,kg=(eg=/[^.]+$/.exec(Fg&&Fg.keys&&Fg.keys.IE_PROTO||""))?"Symbol(src)_1."+eg:"",Dg=fg.toString,vg=Mg.call(Xg),Lg=nI._,zg=Yg("^"+Mg.call(Sg).replace(Cg,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tg=hI?I.Buffer:C,xg=I.Symbol,Ug=I.Uint8Array,jg=Tg?Tg.allocUnsafe:C,Qg=sC(Xg.getPrototypeOf,Xg),Og=Xg.create,Eg=fg.propertyIsEnumerable,Pg=Hg.splice,_g=xg?xg.isConcatSpreadable:C,gI=xg?xg.iterator:C,CI=xg?xg.toStringTag:C,sI=function(){try{var g=ce(Xg,"defineProperty");return g({},"",{}),g}catch(I){}}(),dI=I.clearTimeout!==nI.clearTimeout&&I.clearTimeout,aI=Wg&&Wg.now!==nI.Date.now&&Wg.now,rI=I.setTimeout!==nI.setTimeout&&I.setTimeout,mI=Vg.ceil,ZI=Vg.floor,bI=Xg.getOwnPropertySymbols,kI=Tg?Tg.isBuffer:C,jI=I.isFinite,lC=Hg.join,hC=sC(Xg.keys,Xg),ZC=Vg.max,bC=Vg.min,GC=Wg.now,uC=I.parseInt,pC=Vg.random,wC=Hg.reverse,WC=ce(I,"DataView"),BC=ce(I,"Map"),yC=ce(I,"Promise"),VC=ce(I,"Set"),XC=ce(I,"WeakMap"),YC=ce(Xg,"create"),RC=XC&&new XC,NC={},HC=De(WC),KC=De(BC),fC=De(yC),FC=De(VC),MC=De(XC),SC=xg?xg.prototype:C,JC=SC?SC.valueOf:C,kC=SC?SC.toString:C;function DC(g){if(Cl(g)&&!Ut(g)&&!(g instanceof TC)){if(g instanceof zC)return g;if(Sg.call(g,"__wrapped__"))return ve(g)}return new zC(g)}var vC=function(){function g(){}return function(I){if(!Il(I))return{};if(Og)return Og(I);g.prototype=I;var A=new g;return g.prototype=C,A}}();function LC(){}function zC(g,I){this.__wrapped__=g,this.__actions__=[],this.__chain__=!!I,this.__index__=0,this.__values__=C}function TC(g){this.__wrapped__=g,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=r,this.__views__=[]}function xC(g){var I=-1,C=null==g?0:g.length;for(this.clear();++I=I?g:I)),g}function lA(g,I,A,i,e,t){var l,s=1&I,o=2&I,c=4&I;if(A&&(l=e?A(g,i,e,t):A(g)),l!==C)return l;if(!Il(g))return g;var d=Ut(g);if(d){if(l=function(g){var I=g.length,C=new g.constructor(I);I&&"string"==typeof g[0]&&Sg.call(g,"index")&&(C.index=g.index,C.input=g.input);return C}(g),!s)return Yi(g,l)}else{var a=ne(g),n=a==p||a==w;if(Et(g))return wi(g,s);if(a==y||a==h||n&&!e){if(l=o||n?{}:me(g),!s)return o?function(g,I){return Ri(g,ae(g),I)}(g,function(g,I){return g&&Ri(I,fl(I),g)}(l,g)):function(g,I){return Ri(g,de(g),I)}(g,AA(l,g))}else{if(!lI[a])return e?g:{};l=function(g,I,C){var A=g.constructor;switch(I){case K:return Wi(g);case b:case G:return new A(+g);case f:return function(g,I){var C=I?Wi(g.buffer):g.buffer;return new g.constructor(C,g.byteOffset,g.byteLength)}(g,C);case F:case M:case S:case J:case k:case D:case v:case L:case z:return Bi(g,C);case W:return new A;case B:case R:return new A(g);case X:return function(g){var I=new g.constructor(g.source,ng.exec(g));return I.lastIndex=g.lastIndex,I}(g);case Y:return new A;case N:return i=g,JC?Xg(JC.call(i)):{}}var i}(g,a,s)}}t||(t=new OC);var r=t.get(g);if(r)return r;t.set(g,l),ll(g)?g.forEach((function(C){l.add(lA(C,I,A,C,g,t))})):Al(g)&&g.forEach((function(C,i){l.set(i,lA(C,I,A,i,g,t))}));var m=d?C:(c?o?Ae:Ce:o?fl:Kl)(g);return XI(m||g,(function(C,i){m&&(C=g[i=C]),gA(l,i,lA(C,I,A,i,g,t))})),l}function sA(g,I,A){var i=A.length;if(null==g)return!i;for(g=Xg(g);i--;){var e=A[i],t=I[e],l=g[e];if(l===C&&!(e in g)||!t(l))return!1}return!0}function oA(g,I,i){if("function"!=typeof g)throw new Ng(A);return Re((function(){g.apply(C,i)}),I)}function cA(g,I,C,A){var i=-1,e=HI,t=!0,l=g.length,s=[],o=I.length;if(!l)return s;C&&(I=fI(I,_I(C))),A?(e=KI,t=!1):I.length>=200&&(e=$I,t=!1,I=new QC(I));g:for(;++i-1},UC.prototype.set=function(g,I){var C=this.__data__,A=IA(C,g);return A<0?(++this.size,C.push([g,I])):C[A][1]=I,this},jC.prototype.clear=function(){this.size=0,this.__data__={hash:new xC,map:new(BC||UC),string:new xC}},jC.prototype.delete=function(g){var I=se(this,g).delete(g);return this.size-=I?1:0,I},jC.prototype.get=function(g){return se(this,g).get(g)},jC.prototype.has=function(g){return se(this,g).has(g)},jC.prototype.set=function(g,I){var C=se(this,g),A=C.size;return C.set(g,I),this.size+=C.size==A?0:1,this},QC.prototype.add=QC.prototype.push=function(g){return this.__data__.set(g,i),this},QC.prototype.has=function(g){return this.__data__.has(g)},OC.prototype.clear=function(){this.__data__=new UC,this.size=0},OC.prototype.delete=function(g){var I=this.__data__,C=I.delete(g);return this.size=I.size,C},OC.prototype.get=function(g){return this.__data__.get(g)},OC.prototype.has=function(g){return this.__data__.has(g)},OC.prototype.set=function(g,I){var C=this.__data__;if(C instanceof UC){var A=C.__data__;if(!BC||A.length<199)return A.push([g,I]),this.size=++C.size,this;C=this.__data__=new jC(A)}return C.set(g,I),this.size=C.size,this};var dA=Ki(GA),aA=Ki(uA,!0);function nA(g,I){var C=!0;return dA(g,(function(g,A,i){return C=!!I(g,A,i)})),C}function rA(g,I,A){for(var i=-1,e=g.length;++i0&&C(l)?I>1?hA(l,I-1,C,A,i):FI(i,l):A||(i[i.length]=l)}return i}var ZA=fi(),bA=fi(!0);function GA(g,I){return g&&ZA(g,I,Kl)}function uA(g,I){return g&&bA(g,I,Kl)}function pA(g,I){return NI(I,(function(I){return qt(g[I])}))}function wA(g,I){for(var A=0,i=(I=bi(I,g)).length;null!=g&&AI}function VA(g,I){return null!=g&&Sg.call(g,I)}function XA(g,I){return null!=g&&I in Xg(g)}function YA(g,I,A){for(var i=A?KI:HI,e=g[0].length,t=g.length,l=t,s=wg(t),o=1/0,c=[];l--;){var d=g[l];l&&I&&(d=fI(d,_I(I))),o=bC(d.length,o),s[l]=!A&&(I||e>=120&&d.length>=120)?new QC(l&&d):C}d=g[0];var a=-1,n=s[0];g:for(;++a=l?s:s*("desc"==C[A]?-1:1)}return g.index-I.index}(g,I,C)}))}function xA(g,I,C){for(var A=-1,i=I.length,e={};++A-1;)l!==g&&Pg.call(l,s,1),Pg.call(g,s,1);return g}function jA(g,I){for(var C=g?I.length:0,A=C-1;C--;){var i=I[C];if(C==A||i!==e){var e=i;Ze(i)?Pg.call(g,i,1):ci(g,i)}}return g}function QA(g,I){return g+ZI(pC()*(I-g+1))}function OA(g,I){var C="";if(!g||I<1||I>a)return C;do{I%2&&(C+=g),(I=ZI(I/2))&&(g+=g)}while(I);return C}function EA(g,I){return Ne(ye(g,I,is),g+"")}function PA(g){return PC(Ll(g))}function _A(g,I){var C=Ll(g);return fe(C,tA(I,0,C.length))}function qA(g,I,A,i){if(!Il(g))return g;for(var e=-1,t=(I=bi(I,g)).length,l=t-1,s=g;null!=s&&++ei?0:i+I),(C=C>i?i:C)<0&&(C+=i),i=I>C?0:C-I>>>0,I>>>=0;for(var e=wg(i);++A>>1,t=g[e];null!==t&&!ol(t)&&(C?t<=I:t=200){var o=I?null:Oi(g);if(o)return cC(o);t=!1,i=$I,s=new QC}else s=I?[]:l;g:for(;++A=i?g:Ci(g,I,A)}var pi=dI||function(g){return nI.clearTimeout(g)};function wi(g,I){if(I)return g.slice();var C=g.length,A=jg?jg(C):new g.constructor(C);return g.copy(A),A}function Wi(g){var I=new g.constructor(g.byteLength);return new Ug(I).set(new Ug(g)),I}function Bi(g,I){var C=I?Wi(g.buffer):g.buffer;return new g.constructor(C,g.byteOffset,g.length)}function yi(g,I){if(g!==I){var A=g!==C,i=null===g,e=g==g,t=ol(g),l=I!==C,s=null===I,o=I==I,c=ol(I);if(!s&&!c&&!t&&g>I||t&&l&&o&&!s&&!c||i&&l&&o||!A&&o||!e)return 1;if(!i&&!t&&!c&&g1?A[e-1]:C,l=e>2?A[2]:C;for(t=g.length>3&&"function"==typeof t?(e--,t):C,l&&be(A[0],A[1],l)&&(t=e<3?C:t,e=1),I=Xg(I);++i-1?e[t?I[l]:l]:C}}function ki(g){return Ie((function(I){var i=I.length,e=i,t=zC.prototype.thru;for(g&&I.reverse();e--;){var l=I[e];if("function"!=typeof l)throw new Ng(A);if(t&&!s&&"wrapper"==ee(l))var s=new zC([],!0)}for(e=s?e:i;++e1&&G.reverse(),a&&cs))return!1;var c=t.get(g),d=t.get(I);if(c&&d)return c==I&&d==g;var a=-1,n=!0,r=2&A?new QC:C;for(t.set(g,I),t.set(I,g);++a-1&&g%1==0&&g1?"& ":"")+I[A],I=I.join(C>2?", ":" "),g.replace(tg,"{\n/* [wrapped with "+I+"] */\n")}(A,function(g,I){return XI(m,(function(C){var A="_."+C[0];I&C[1]&&!HI(g,A)&&g.push(A)})),g.sort()}(function(g){var I=g.match(lg);return I?I[1].split(sg):[]}(A),C)))}function Ke(g){var I=0,A=0;return function(){var i=GC(),e=16-(i-A);if(A=i,e>0){if(++I>=800)return arguments[0]}else I=0;return g.apply(C,arguments)}}function fe(g,I){var A=-1,i=g.length,e=i-1;for(I=I===C?i:I;++A1?g[I-1]:C;return A="function"==typeof A?(g.pop(),A):C,tt(g,A)}));function nt(g){var I=DC(g);return I.__chain__=!0,I}function rt(g,I){return I(g)}var mt=Ie((function(g){var I=g.length,A=I?g[0]:0,i=this.__wrapped__,e=function(I){return eA(I,g)};return!(I>1||this.__actions__.length)&&i instanceof TC&&Ze(A)?((i=i.slice(A,+A+(I?1:0))).__actions__.push({func:rt,args:[e],thisArg:C}),new zC(i,this.__chain__).thru((function(g){return I&&!g.length&&g.push(C),g}))):this.thru(e)}));var ht=Ni((function(g,I,C){Sg.call(g,C)?++g[C]:iA(g,C,1)}));var Zt=Ji(xe),bt=Ji(Ue);function Gt(g,I){return(Ut(g)?XI:dA)(g,le(I,3))}function ut(g,I){return(Ut(g)?YI:aA)(g,le(I,3))}var pt=Ni((function(g,I,C){Sg.call(g,C)?g[C].push(I):iA(g,C,[I])}));var wt=EA((function(g,I,C){var A=-1,i="function"==typeof I,e=Qt(g)?wg(g.length):[];return dA(g,(function(g){e[++A]=i?yI(I,g,C):RA(g,I,C)})),e})),Wt=Ni((function(g,I,C){iA(g,C,I)}));function Bt(g,I){return(Ut(g)?fI:kA)(g,le(I,3))}var yt=Ni((function(g,I,C){g[C?0:1].push(I)}),(function(){return[[],[]]}));var Vt=EA((function(g,I){if(null==g)return[];var C=I.length;return C>1&&be(g,I[0],I[1])?I=[]:C>2&&be(I[0],I[1],I[2])&&(I=[I[0]]),TA(g,hA(I,1),[])})),Xt=aI||function(){return nI.Date.now()};function Yt(g,I,A){return I=A?C:I,I=g&&null==I?g.length:I,Pi(g,o,C,C,C,C,I)}function Rt(g,I){var i;if("function"!=typeof I)throw new Ng(A);return g=ml(g),function(){return--g>0&&(i=I.apply(this,arguments)),g<=1&&(I=C),i}}var Nt=EA((function(g,I,C){var A=1;if(C.length){var i=oC(C,te(Nt));A|=l}return Pi(g,A,I,C,i)})),Ht=EA((function(g,I,C){var A=3;if(C.length){var i=oC(C,te(Ht));A|=l}return Pi(I,A,g,C,i)}));function Kt(g,I,i){var e,t,l,s,o,c,d=0,a=!1,n=!1,r=!0;if("function"!=typeof g)throw new Ng(A);function m(I){var A=e,i=t;return e=t=C,d=I,s=g.apply(i,A)}function h(g){var A=g-c;return c===C||A>=I||A<0||n&&g-d>=l}function Z(){var g=Xt();if(h(g))return b(g);o=Re(Z,function(g){var C=I-(g-c);return n?bC(C,l-(g-d)):C}(g))}function b(g){return o=C,r&&e?m(g):(e=t=C,s)}function G(){var g=Xt(),A=h(g);if(e=arguments,t=this,c=g,A){if(o===C)return function(g){return d=g,o=Re(Z,I),a?m(g):s}(c);if(n)return pi(o),o=Re(Z,I),m(c)}return o===C&&(o=Re(Z,I)),s}return I=Zl(I)||0,Il(i)&&(a=!!i.leading,l=(n="maxWait"in i)?ZC(Zl(i.maxWait)||0,I):l,r="trailing"in i?!!i.trailing:r),G.cancel=function(){o!==C&&pi(o),d=0,e=c=t=o=C},G.flush=function(){return o===C?s:b(Xt())},G}var ft=EA((function(g,I){return oA(g,1,I)})),Ft=EA((function(g,I,C){return oA(g,Zl(I)||0,C)}));function Mt(g,I){if("function"!=typeof g||null!=I&&"function"!=typeof I)throw new Ng(A);var C=function(){var A=arguments,i=I?I.apply(this,A):A[0],e=C.cache;if(e.has(i))return e.get(i);var t=g.apply(this,A);return C.cache=e.set(i,t)||e,t};return C.cache=new(Mt.Cache||jC),C}function St(g){if("function"!=typeof g)throw new Ng(A);return function(){var I=arguments;switch(I.length){case 0:return!g.call(this);case 1:return!g.call(this,I[0]);case 2:return!g.call(this,I[0],I[1]);case 3:return!g.call(this,I[0],I[1],I[2])}return!g.apply(this,I)}}Mt.Cache=jC;var Jt=Gi((function(g,I){var C=(I=1==I.length&&Ut(I[0])?fI(I[0],_I(le())):fI(hA(I,1),_I(le()))).length;return EA((function(A){for(var i=-1,e=bC(A.length,C);++i=I})),xt=NA(function(){return arguments}())?NA:function(g){return Cl(g)&&Sg.call(g,"callee")&&!Eg.call(g,"callee")},Ut=wg.isArray,jt=GI?_I(GI):function(g){return Cl(g)&&BA(g)==K};function Qt(g){return null!=g&&gl(g.length)&&!qt(g)}function Ot(g){return Cl(g)&&Qt(g)}var Et=kI||Zs,Pt=uI?_I(uI):function(g){return Cl(g)&&BA(g)==G};function _t(g){if(!Cl(g))return!1;var I=BA(g);return I==u||"[object DOMException]"==I||"string"==typeof g.message&&"string"==typeof g.name&&!el(g)}function qt(g){if(!Il(g))return!1;var I=BA(g);return I==p||I==w||"[object AsyncFunction]"==I||"[object Proxy]"==I}function $t(g){return"number"==typeof g&&g==ml(g)}function gl(g){return"number"==typeof g&&g>-1&&g%1==0&&g<=a}function Il(g){var I=typeof g;return null!=g&&("object"==I||"function"==I)}function Cl(g){return null!=g&&"object"==typeof g}var Al=pI?_I(pI):function(g){return Cl(g)&&ne(g)==W};function il(g){return"number"==typeof g||Cl(g)&&BA(g)==B}function el(g){if(!Cl(g)||BA(g)!=y)return!1;var I=Qg(g);if(null===I)return!0;var C=Sg.call(I,"constructor")&&I.constructor;return"function"==typeof C&&C instanceof C&&Mg.call(C)==vg}var tl=wI?_I(wI):function(g){return Cl(g)&&BA(g)==X};var ll=WI?_I(WI):function(g){return Cl(g)&&ne(g)==Y};function sl(g){return"string"==typeof g||!Ut(g)&&Cl(g)&&BA(g)==R}function ol(g){return"symbol"==typeof g||Cl(g)&&BA(g)==N}var cl=BI?_I(BI):function(g){return Cl(g)&&gl(g.length)&&!!tI[BA(g)]};var dl=Ui(JA),al=Ui((function(g,I){return g<=I}));function nl(g){if(!g)return[];if(Qt(g))return sl(g)?aC(g):Yi(g);if(gI&&g[gI])return function(g){for(var I,C=[];!(I=g.next()).done;)C.push(I.value);return C}(g[gI]());var I=ne(g);return(I==W?tC:I==Y?cC:Ll)(g)}function rl(g){return g?(g=Zl(g))===d||g===-1/0?17976931348623157e292*(g<0?-1:1):g==g?g:0:0===g?g:0}function ml(g){var I=rl(g),C=I%1;return I==I?C?I-C:I:0}function hl(g){return g?tA(ml(g),0,r):0}function Zl(g){if("number"==typeof g)return g;if(ol(g))return n;if(Il(g)){var I="function"==typeof g.valueOf?g.valueOf():g;g=Il(I)?I+"":I}if("string"!=typeof g)return 0===g?g:+g;g=PI(g);var C=mg.test(g);return C||Zg.test(g)?cI(g.slice(2),C?2:8):rg.test(g)?n:+g}function bl(g){return Ri(g,fl(g))}function Gl(g){return null==g?"":si(g)}var ul=Hi((function(g,I){if(we(I)||Qt(I))Ri(I,Kl(I),g);else for(var C in I)Sg.call(I,C)&&gA(g,C,I[C])})),pl=Hi((function(g,I){Ri(I,fl(I),g)})),wl=Hi((function(g,I,C,A){Ri(I,fl(I),g,A)})),Wl=Hi((function(g,I,C,A){Ri(I,Kl(I),g,A)})),Bl=Ie(eA);var yl=EA((function(g,I){g=Xg(g);var A=-1,i=I.length,e=i>2?I[2]:C;for(e&&be(I[0],I[1],e)&&(i=1);++A1),I})),Ri(g,Ae(g),C),A&&(C=lA(C,7,$i));for(var i=I.length;i--;)ci(C,I[i]);return C}));var Jl=Ie((function(g,I){return null==g?{}:function(g,I){return xA(g,I,(function(I,C){return Yl(g,C)}))}(g,I)}));function kl(g,I){if(null==g)return{};var C=fI(Ae(g),(function(g){return[g]}));return I=le(I),xA(g,C,(function(g,C){return I(g,C[0])}))}var Dl=Ei(Kl),vl=Ei(fl);function Ll(g){return null==g?[]:qI(g,Kl(g))}var zl=Mi((function(g,I,C){return I=I.toLowerCase(),g+(C?Tl(I):I)}));function Tl(g){return _l(Gl(g).toLowerCase())}function xl(g){return(g=Gl(g))&&g.replace(Gg,CC).replace($g,"")}var Ul=Mi((function(g,I,C){return g+(C?"-":"")+I.toLowerCase()})),jl=Mi((function(g,I,C){return g+(C?" ":"")+I.toLowerCase()})),Ql=Fi("toLowerCase");var Ol=Mi((function(g,I,C){return g+(C?"_":"")+I.toLowerCase()}));var El=Mi((function(g,I,C){return g+(C?" ":"")+_l(I)}));var Pl=Mi((function(g,I,C){return g+(C?" ":"")+I.toUpperCase()})),_l=Fi("toUpperCase");function ql(g,I,A){return g=Gl(g),(I=A?C:I)===C?function(g){return AI.test(g)}(g)?function(g){return g.match(II)||[]}(g):function(g){return g.match(og)||[]}(g):g.match(I)||[]}var $l=EA((function(g,I){try{return yI(g,C,I)}catch(A){return _t(A)?A:new Bg(A)}})),gs=Ie((function(g,I){return XI(I,(function(I){I=ke(I),iA(g,I,Nt(g[I],g))})),g}));function Is(g){return function(){return g}}var Cs=ki(),As=ki(!0);function is(g){return g}function es(g){return FA("function"==typeof g?g:lA(g,1))}var ts=EA((function(g,I){return function(C){return RA(C,g,I)}})),ls=EA((function(g,I){return function(C){return RA(g,C,I)}}));function ss(g,I,C){var A=Kl(I),i=pA(I,A);null!=C||Il(I)&&(i.length||!A.length)||(C=I,I=g,g=this,i=pA(I,Kl(I)));var e=!(Il(C)&&"chain"in C&&!C.chain),t=qt(g);return XI(i,(function(C){var A=I[C];g[C]=A,t&&(g.prototype[C]=function(){var I=this.__chain__;if(e||I){var C=g(this.__wrapped__);return(C.__actions__=Yi(this.__actions__)).push({func:A,args:arguments,thisArg:g}),C.__chain__=I,C}return A.apply(g,FI([this.value()],arguments))})})),g}function os(){}var cs=zi(fI),ds=zi(RI),as=zi(JI);function ns(g){return Ge(g)?UI(ke(g)):function(g){return function(I){return wA(I,g)}}(g)}var rs=xi(),ms=xi(!0);function hs(){return[]}function Zs(){return!1}var bs=Li((function(g,I){return g+I}),0),Gs=Qi("ceil"),us=Li((function(g,I){return g/I}),1),ps=Qi("floor");var ws,Ws=Li((function(g,I){return g*I}),1),Bs=Qi("round"),ys=Li((function(g,I){return g-I}),0);return DC.after=function(g,I){if("function"!=typeof I)throw new Ng(A);return g=ml(g),function(){if(--g<1)return I.apply(this,arguments)}},DC.ary=Yt,DC.assign=ul,DC.assignIn=pl,DC.assignInWith=wl,DC.assignWith=Wl,DC.at=Bl,DC.before=Rt,DC.bind=Nt,DC.bindAll=gs,DC.bindKey=Ht,DC.castArray=function(){if(!arguments.length)return[];var g=arguments[0];return Ut(g)?g:[g]},DC.chain=nt,DC.chunk=function(g,I,A){I=(A?be(g,I,A):I===C)?1:ZC(ml(I),0);var i=null==g?0:g.length;if(!i||I<1)return[];for(var e=0,t=0,l=wg(mI(i/I));ee?0:e+A),(i=i===C||i>e?e:ml(i))<0&&(i+=e),i=A>i?0:hl(i);A>>0)?(g=Gl(g))&&("string"==typeof I||null!=I&&!tl(I))&&!(I=si(I))&&eC(g)?ui(aC(g),0,A):g.split(I,A):[]},DC.spread=function(g,I){if("function"!=typeof g)throw new Ng(A);return I=null==I?0:ZC(ml(I),0),EA((function(C){var A=C[I],i=ui(C,0,I);return A&&FI(i,A),yI(g,this,i)}))},DC.tail=function(g){var I=null==g?0:g.length;return I?Ci(g,1,I):[]},DC.take=function(g,I,A){return g&&g.length?Ci(g,0,(I=A||I===C?1:ml(I))<0?0:I):[]},DC.takeRight=function(g,I,A){var i=null==g?0:g.length;return i?Ci(g,(I=i-(I=A||I===C?1:ml(I)))<0?0:I,i):[]},DC.takeRightWhile=function(g,I){return g&&g.length?ai(g,le(I,3),!1,!0):[]},DC.takeWhile=function(g,I){return g&&g.length?ai(g,le(I,3)):[]},DC.tap=function(g,I){return I(g),g},DC.throttle=function(g,I,C){var i=!0,e=!0;if("function"!=typeof g)throw new Ng(A);return Il(C)&&(i="leading"in C?!!C.leading:i,e="trailing"in C?!!C.trailing:e),Kt(g,I,{leading:i,maxWait:I,trailing:e})},DC.thru=rt,DC.toArray=nl,DC.toPairs=Dl,DC.toPairsIn=vl,DC.toPath=function(g){return Ut(g)?fI(g,ke):ol(g)?[g]:Yi(Je(Gl(g)))},DC.toPlainObject=bl,DC.transform=function(g,I,C){var A=Ut(g),i=A||Et(g)||cl(g);if(I=le(I,4),null==C){var e=g&&g.constructor;C=i?A?new e:[]:Il(g)&&qt(e)?vC(Qg(g)):{}}return(i?XI:GA)(g,(function(g,A,i){return I(C,g,A,i)})),C},DC.unary=function(g){return Yt(g,1)},DC.union=Ct,DC.unionBy=At,DC.unionWith=it,DC.uniq=function(g){return g&&g.length?oi(g):[]},DC.uniqBy=function(g,I){return g&&g.length?oi(g,le(I,2)):[]},DC.uniqWith=function(g,I){return I="function"==typeof I?I:C,g&&g.length?oi(g,C,I):[]},DC.unset=function(g,I){return null==g||ci(g,I)},DC.unzip=et,DC.unzipWith=tt,DC.update=function(g,I,C){return null==g?g:di(g,I,Zi(C))},DC.updateWith=function(g,I,A,i){return i="function"==typeof i?i:C,null==g?g:di(g,I,Zi(A),i)},DC.values=Ll,DC.valuesIn=function(g){return null==g?[]:qI(g,fl(g))},DC.without=lt,DC.words=ql,DC.wrap=function(g,I){return kt(Zi(I),g)},DC.xor=st,DC.xorBy=ot,DC.xorWith=ct,DC.zip=dt,DC.zipObject=function(g,I){return mi(g||[],I||[],gA)},DC.zipObjectDeep=function(g,I){return mi(g||[],I||[],qA)},DC.zipWith=at,DC.entries=Dl,DC.entriesIn=vl,DC.extend=pl,DC.extendWith=wl,ss(DC,DC),DC.add=bs,DC.attempt=$l,DC.camelCase=zl,DC.capitalize=Tl,DC.ceil=Gs,DC.clamp=function(g,I,A){return A===C&&(A=I,I=C),A!==C&&(A=(A=Zl(A))==A?A:0),I!==C&&(I=(I=Zl(I))==I?I:0),tA(Zl(g),I,A)},DC.clone=function(g){return lA(g,4)},DC.cloneDeep=function(g){return lA(g,5)},DC.cloneDeepWith=function(g,I){return lA(g,5,I="function"==typeof I?I:C)},DC.cloneWith=function(g,I){return lA(g,4,I="function"==typeof I?I:C)},DC.conformsTo=function(g,I){return null==I||sA(g,I,Kl(I))},DC.deburr=xl,DC.defaultTo=function(g,I){return null==g||g!=g?I:g},DC.divide=us,DC.endsWith=function(g,I,A){g=Gl(g),I=si(I);var i=g.length,e=A=A===C?i:tA(ml(A),0,i);return(A-=I.length)>=0&&g.slice(A,e)==I},DC.eq=Lt,DC.escape=function(g){return(g=Gl(g))&&E.test(g)?g.replace(Q,AC):g},DC.escapeRegExp=function(g){return(g=Gl(g))&&Ag.test(g)?g.replace(Cg,"\\$&"):g},DC.every=function(g,I,A){var i=Ut(g)?RI:nA;return A&&be(g,I,A)&&(I=C),i(g,le(I,3))},DC.find=Zt,DC.findIndex=xe,DC.findKey=function(g,I){return DI(g,le(I,3),GA)},DC.findLast=bt,DC.findLastIndex=Ue,DC.findLastKey=function(g,I){return DI(g,le(I,3),uA)},DC.floor=ps,DC.forEach=Gt,DC.forEachRight=ut,DC.forIn=function(g,I){return null==g?g:ZA(g,le(I,3),fl)},DC.forInRight=function(g,I){return null==g?g:bA(g,le(I,3),fl)},DC.forOwn=function(g,I){return g&&GA(g,le(I,3))},DC.forOwnRight=function(g,I){return g&&uA(g,le(I,3))},DC.get=Xl,DC.gt=zt,DC.gte=Tt,DC.has=function(g,I){return null!=g&&re(g,I,VA)},DC.hasIn=Yl,DC.head=Qe,DC.identity=is,DC.includes=function(g,I,C,A){g=Qt(g)?g:Ll(g),C=C&&!A?ml(C):0;var i=g.length;return C<0&&(C=ZC(i+C,0)),sl(g)?C<=i&&g.indexOf(I,C)>-1:!!i&&LI(g,I,C)>-1},DC.indexOf=function(g,I,C){var A=null==g?0:g.length;if(!A)return-1;var i=null==C?0:ml(C);return i<0&&(i=ZC(A+i,0)),LI(g,I,i)},DC.inRange=function(g,I,A){return I=rl(I),A===C?(A=I,I=0):A=rl(A),function(g,I,C){return g>=bC(I,C)&&g=-9007199254740991&&g<=a},DC.isSet=ll,DC.isString=sl,DC.isSymbol=ol,DC.isTypedArray=cl,DC.isUndefined=function(g){return g===C},DC.isWeakMap=function(g){return Cl(g)&&ne(g)==H},DC.isWeakSet=function(g){return Cl(g)&&"[object WeakSet]"==BA(g)},DC.join=function(g,I){return null==g?"":lC.call(g,I)},DC.kebabCase=Ul,DC.last=_e,DC.lastIndexOf=function(g,I,A){var i=null==g?0:g.length;if(!i)return-1;var e=i;return A!==C&&(e=(e=ml(A))<0?ZC(i+e,0):bC(e,i-1)),I==I?function(g,I,C){for(var A=C+1;A--;)if(g[A]===I)return A;return A}(g,I,e):vI(g,TI,e,!0)},DC.lowerCase=jl,DC.lowerFirst=Ql,DC.lt=dl,DC.lte=al,DC.max=function(g){return g&&g.length?rA(g,is,yA):C},DC.maxBy=function(g,I){return g&&g.length?rA(g,le(I,2),yA):C},DC.mean=function(g){return xI(g,is)},DC.meanBy=function(g,I){return xI(g,le(I,2))},DC.min=function(g){return g&&g.length?rA(g,is,JA):C},DC.minBy=function(g,I){return g&&g.length?rA(g,le(I,2),JA):C},DC.stubArray=hs,DC.stubFalse=Zs,DC.stubObject=function(){return{}},DC.stubString=function(){return""},DC.stubTrue=function(){return!0},DC.multiply=Ws,DC.nth=function(g,I){return g&&g.length?zA(g,ml(I)):C},DC.noConflict=function(){return nI._===this&&(nI._=Lg),this},DC.noop=os,DC.now=Xt,DC.pad=function(g,I,C){g=Gl(g);var A=(I=ml(I))?dC(g):0;if(!I||A>=I)return g;var i=(I-A)/2;return Ti(ZI(i),C)+g+Ti(mI(i),C)},DC.padEnd=function(g,I,C){g=Gl(g);var A=(I=ml(I))?dC(g):0;return I&&AI){var i=g;g=I,I=i}if(A||g%1||I%1){var e=pC();return bC(g+e*(I-g+oI("1e-"+((e+"").length-1))),I)}return QA(g,I)},DC.reduce=function(g,I,C){var A=Ut(g)?MI:QI,i=arguments.length<3;return A(g,le(I,4),C,i,dA)},DC.reduceRight=function(g,I,C){var A=Ut(g)?SI:QI,i=arguments.length<3;return A(g,le(I,4),C,i,aA)},DC.repeat=function(g,I,A){return I=(A?be(g,I,A):I===C)?1:ml(I),OA(Gl(g),I)},DC.replace=function(){var g=arguments,I=Gl(g[0]);return g.length<3?I:I.replace(g[1],g[2])},DC.result=function(g,I,A){var i=-1,e=(I=bi(I,g)).length;for(e||(e=1,g=C);++ia)return[];var C=r,A=bC(g,r);I=le(I),g-=r;for(var i=EI(A,I);++C=t)return g;var s=A-dC(i);if(s<1)return i;var o=l?ui(l,0,s).join(""):g.slice(0,s);if(e===C)return o+i;if(l&&(s+=o.length-s),tl(e)){if(g.slice(s).search(e)){var c,d=o;for(e.global||(e=Yg(e.source,Gl(ng.exec(e))+"g")),e.lastIndex=0;c=e.exec(d);)var a=c.index;o=o.slice(0,a===C?s:a)}}else if(g.indexOf(si(e),s)!=s){var n=o.lastIndexOf(e);n>-1&&(o=o.slice(0,n))}return o+i},DC.unescape=function(g){return(g=Gl(g))&&O.test(g)?g.replace(j,rC):g},DC.uniqueId=function(g){var I=++Jg;return Gl(g)+I},DC.upperCase=Pl,DC.upperFirst=_l,DC.each=Gt,DC.eachRight=ut,DC.first=Qe,ss(DC,(ws={},GA(DC,(function(g,I){Sg.call(DC.prototype,I)||(ws[I]=g)})),ws),{chain:!1}),DC.VERSION="4.17.21",XI(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(g){DC[g].placeholder=DC})),XI(["drop","take"],(function(g,I){TC.prototype[g]=function(A){A=A===C?1:ZC(ml(A),0);var i=this.__filtered__&&!I?new TC(this):this.clone();return i.__filtered__?i.__takeCount__=bC(A,i.__takeCount__):i.__views__.push({size:bC(A,r),type:g+(i.__dir__<0?"Right":"")}),i},TC.prototype[g+"Right"]=function(I){return this.reverse()[g](I).reverse()}})),XI(["filter","map","takeWhile"],(function(g,I){var C=I+1,A=1==C||3==C;TC.prototype[g]=function(g){var I=this.clone();return I.__iteratees__.push({iteratee:le(g,3),type:C}),I.__filtered__=I.__filtered__||A,I}})),XI(["head","last"],(function(g,I){var C="take"+(I?"Right":"");TC.prototype[g]=function(){return this[C](1).value()[0]}})),XI(["initial","tail"],(function(g,I){var C="drop"+(I?"":"Right");TC.prototype[g]=function(){return this.__filtered__?new TC(this):this[C](1)}})),TC.prototype.compact=function(){return this.filter(is)},TC.prototype.find=function(g){return this.filter(g).head()},TC.prototype.findLast=function(g){return this.reverse().find(g)},TC.prototype.invokeMap=EA((function(g,I){return"function"==typeof g?new TC(this):this.map((function(C){return RA(C,g,I)}))})),TC.prototype.reject=function(g){return this.filter(St(le(g)))},TC.prototype.slice=function(g,I){g=ml(g);var A=this;return A.__filtered__&&(g>0||I<0)?new TC(A):(g<0?A=A.takeRight(-g):g&&(A=A.drop(g)),I!==C&&(A=(I=ml(I))<0?A.dropRight(-I):A.take(I-g)),A)},TC.prototype.takeRightWhile=function(g){return this.reverse().takeWhile(g).reverse()},TC.prototype.toArray=function(){return this.take(r)},GA(TC.prototype,(function(g,I){var A=/^(?:filter|find|map|reject)|While$/.test(I),i=/^(?:head|last)$/.test(I),e=DC[i?"take"+("last"==I?"Right":""):I],t=i||/^find/.test(I);e&&(DC.prototype[I]=function(){var I=this.__wrapped__,l=i?[1]:arguments,s=I instanceof TC,o=l[0],c=s||Ut(I),d=function(g){var I=e.apply(DC,FI([g],l));return i&&a?I[0]:I};c&&A&&"function"==typeof o&&1!=o.length&&(s=c=!1);var a=this.__chain__,n=!!this.__actions__.length,r=t&&!a,m=s&&!n;if(!t&&c){I=m?I:new TC(this);var h=g.apply(I,l);return h.__actions__.push({func:rt,args:[d],thisArg:C}),new zC(h,a)}return r&&m?g.apply(this,l):(h=this.thru(d),r?i?h.value()[0]:h.value():h)})})),XI(["pop","push","shift","sort","splice","unshift"],(function(g){var I=Hg[g],C=/^(?:push|sort|unshift)$/.test(g)?"tap":"thru",A=/^(?:pop|shift)$/.test(g);DC.prototype[g]=function(){var g=arguments;if(A&&!this.__chain__){var i=this.value();return I.apply(Ut(i)?i:[],g)}return this[C]((function(C){return I.apply(Ut(C)?C:[],g)}))}})),GA(TC.prototype,(function(g,I){var C=DC[I];if(C){var A=C.name+"";Sg.call(NC,A)||(NC[A]=[]),NC[A].push({name:I,func:C})}})),NC[Di(C,2).name]=[{name:"wrapper",func:C}],TC.prototype.clone=function(){var g=new TC(this.__wrapped__);return g.__actions__=Yi(this.__actions__),g.__dir__=this.__dir__,g.__filtered__=this.__filtered__,g.__iteratees__=Yi(this.__iteratees__),g.__takeCount__=this.__takeCount__,g.__views__=Yi(this.__views__),g},TC.prototype.reverse=function(){if(this.__filtered__){var g=new TC(this);g.__dir__=-1,g.__filtered__=!0}else(g=this.clone()).__dir__*=-1;return g},TC.prototype.value=function(){var g=this.__wrapped__.value(),I=this.__dir__,C=Ut(g),A=I<0,i=C?g.length:0,e=function(g,I,C){var A=-1,i=C.length;for(;++A=this.__values__.length;return{done:g,value:g?C:this.__values__[this.__index__++]}},DC.prototype.plant=function(g){for(var I,A=this;A instanceof LC;){var i=ve(A);i.__index__=0,i.__values__=C,I?e.__wrapped__=i:I=i;var e=i;A=A.__wrapped__}return e.__wrapped__=g,I},DC.prototype.reverse=function(){var g=this.__wrapped__;if(g instanceof TC){var I=g;return this.__actions__.length&&(I=new TC(this)),(I=I.reverse()).__actions__.push({func:rt,args:[It],thisArg:C}),new zC(I,this.__chain__)}return this.thru(It)},DC.prototype.toJSON=DC.prototype.valueOf=DC.prototype.value=function(){return ni(this.__wrapped__,this.__actions__)},DC.prototype.first=DC.prototype.head,gI&&(DC.prototype[gI]=function(){return this}),DC}();mI?((mI.exports=mC)._=mC,rI._=mC):nI._=mC}).call(lC)}(li,li.exports);var si=li.exports;class oi{constructor(g,I=""){"string"==typeof g?(this.el=document.createElement(g),this.el.className=I):this.el=g,this.data={}}data(g,I){return void 0!==I?(this.data[g]=I,this):this.data[g]}on(g,I){const[C,...A]=g.split(".");let i=C;return"mousewheel"===i&&/Firefox/i.test(window.navigator.userAgent)&&(i="DOMMouseScroll"),this.el.addEventListener(i,(g=>{I(g);for(let I=0;I{this.css(I,`${g[I]}px`)})),this;const{offsetTop:I,offsetLeft:C,offsetHeight:A,offsetWidth:i}=this.el;return{top:I,left:C,height:A,width:i}}scroll(g){const{el:I}=this;return void 0!==g&&(void 0!==g.left&&(I.scrollLeft=g.left),void 0!==g.top&&(I.scrollTop=g.top)),{left:I.scrollLeft,top:I.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new oi(this.el.parentNode)}children(...g){return 0===arguments.length?this.el.childNodes:(g.forEach((g=>this.child(g))),this)}removeChild(g){this.el.removeChild(g)}child(g){let I=g;return"string"==typeof g?I=document.createTextNode(g):g instanceof oi&&(I=g.el),this.el.appendChild(I),this}contains(g){return this.el.contains(g)}className(g){return void 0!==g?(this.el.className=g,this):this.el.className}addClass(g){return this.el.classList.add(g),this}hasClass(g){return this.el.classList.contains(g)}removeClass(g){return this.el.classList.remove(g),this}toggle(g="active"){return this.toggleClass(g)}toggleClass(g){return this.el.classList.toggle(g)}active(g=!0,I="active"){return g?this.addClass(I):this.removeClass(I),this}checked(g=!0){return this.active(g,"checked"),this}disabled(g=!0){return g?this.addClass("disabled"):this.removeClass("disabled"),this}attr(g,I){if(void 0!==I)this.el.setAttribute(g,I);else{if("string"==typeof g)return this.el.getAttribute(g);Object.keys(g).forEach((I=>{this.el.setAttribute(I,g[I])}))}return this}removeAttr(g){return this.el.removeAttribute(g),this}html(g){return void 0!==g?(this.el.innerHTML=g,this):this.el.innerHTML}val(g){return void 0!==g?(this.el.value=g,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...g){return g.forEach((g=>this.el.style.removeProperty(g))),this}css(g,I){return void 0===I&&"string"!=typeof g?(Object.keys(g).forEach((I=>{this.el.style[I]=g[I]})),this):void 0!==I?(this.el.style[g]=I,this):this.el.style[g]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const ci=(g,I="")=>new oi(g,I),di=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function ai(g){let I="",C=g;for(;C>=di.length;)C/=di.length,C-=1,I+=di[parseInt(C,10)%di.length];const A=g%di.length;return I+=di[A],I}function ni(g){let I=0;for(let C=0;C="0"&&g.charAt(A)<="9"?C+=g.charAt(A):I+=g.charAt(A);return[ni(I),parseInt(C,10)-1]}function mi(g,I){return`${ai(g)}${I+1}`}function hi(g,I,C,A=()=>!0){if(0===I&&0===C)return g;const[i,e]=ri(g);return A(i,e)?mi(i+I,e+C):g}class Zi{constructor(g,I,C,A,i=0,e=0){this.sri=g,this.sci=I,this.eri=C,this.eci=A,this.w=i,this.h=e}set(g,I,C,A){this.sri=g,this.sci=I,this.eri=C,this.eci=A}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...g){let[I,C]=[0,0];1===g.length?[C,I]=ri(g[0]):2===g.length&&([I,C]=g);const{sri:A,sci:i,eri:e,eci:t}=this;return A<=I&&I<=e&&i<=C&&C<=t}each(g,I=()=>!0){const{sri:C,sci:A,eri:i,eci:e}=this;for(let t=C;t<=i;t+=1)if(I(t))for(let I=A;I<=e;I+=1)g(t,I)}contains(g){return this.sri<=g.sri&&this.sci<=g.sci&&this.eri>=g.eri&&this.eci>=g.eci}within(g){return this.sri>=g.sri&&this.sci>=g.sci&&this.eri<=g.eri&&this.eci<=g.eci}disjoint(g){return this.sri>g.eri||this.sci>g.eci||g.sri>this.eri||g.sci>this.eci}intersects(g){return this.sri<=g.eri&&this.sci<=g.eci&&g.sri<=this.eri&&g.sci<=this.eci}union(g){const{sri:I,sci:C,eri:A,eci:i}=this;return new Zi(g.sriA?g.eri:A,g.eci>i?g.eci:i)}difference(g){const I=[],C=(g,C,A,i)=>{I.push(new Zi(g,C,A,i))},{sri:A,sci:i,eri:e,eci:t}=this,l=g.sri-A,s=g.sci-i,o=e-g.eri,c=t-g.eci;return l>0?(C(A,i,g.sri-1,t),o>0?(C(g.eri+1,i,e,t),s>0&&C(g.sri,i,g.eri,g.sci-1),c>0&&C(g.sri,g.eci+1,g.eri,t)):(s>0&&C(g.sri,i,e,g.sci-1),c>0&&C(g.sri,g.eci+1,e,t))):o>0&&(C(g.eri+1,i,e,t),s>0&&C(A,i,g.eri,g.sci-1),c>0&&C(A,g.eci+1,g.eri,t)),s>0?(C(A,i,e,g.sci-1),c>0?(C(A,g.eri+1,e,t),l>0&&C(A,g.sci,g.sri-1,g.eci),o>0&&C(g.sri+1,g.sci,e,g.eci)):(l>0&&C(A,g.sci,g.sri-1,t),o>0&&C(g.sri+1,g.sci,e,t))):c>0&&(C(e,g.eci+1,e,t),l>0&&C(A,i,g.sri-1,g.eci),o>0&&C(g.eri+1,i,e,g.eci)),I}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:g,sci:I,eri:C,eci:A}=this;let i=mi(I,g);return this.multiple()&&(i=`${i}:${mi(A,C)}`),i}clone(){const{sri:g,sci:I,eri:C,eci:A,w:i,h:e}=this;return new Zi(g,I,C,A,i,e)}equals(g){return this.eri===g.eri&&this.eci===g.eci&&this.sri===g.sri&&this.sci===g.sci}static valueOf(g){const I=g.split(":"),[C,A]=ri(I[0]);let[i,e]=[A,C];return I.length>1&&([e,i]=ri(I[1])),new Zi(A,C,i,e)}}let bi=class{constructor(){this.range=new Zi(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(g,I){this.ri=g,this.ci=I}size(){return this.range.size()}};class Gi{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class ui{constructor(){this.undoItems=[],this.redoItems=[]}add(g){this.undoItems.push(JSON.stringify(g)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(g,I){const{undoItems:C,redoItems:A}=this;this.canUndo()&&(A.push(JSON.stringify(g)),I(JSON.parse(C.pop())))}redo(g,I){const{undoItems:C,redoItems:A}=this;this.canRedo()&&(C.push(JSON.stringify(g)),I(JSON.parse(A.pop())))}}class pi{constructor(){this.range=null,this.state="clear"}copy(g){return this.range=g,this.state="copy",this}cut(g){return this.range=g,this.state="cut",this}isCopy(){return"copy"===this.state}isCut(){return"cut"===this.state}isClear(){return"clear"===this.state}clear(){this.range=null,this.state="clear"}}class wi{constructor(g,I,C){this.ci=g,this.operator=I,this.value=C}set(g,I){this.operator=g,this.value=I}includes(g){const{operator:I,value:C}=this;return"all"===I||"in"===I&&C.includes(g)}vlength(){const{operator:g,value:I}=this;return"in"===g?I.length:0}getData(){const{ci:g,operator:I,value:C}=this;return{ci:g,operator:I,value:C}}}class Wi{constructor(g,I){this.ci=g,this.order=I}asc(){return"asc"===this.order}desc(){return"desc"===this.order}}class Bi{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:g,filters:I,sort:C}){null!=g&&(this.ref=g,this.filters=I.map((g=>new wi(g.ci,g.operator,g.value))),C&&(this.sort=new Wi(C.ci,C.order)))}getData(){if(this.active()){const{ref:g,filters:I,sort:C}=this;return{ref:g,filters:I.map((g=>g.getData())),sort:C}}return{}}addFilter(g,I,C){const A=this.getFilter(g);null==A?this.filters.push(new wi(g,I,C)):A.set(I,C)}setSort(g,I){this.sort=I?new Wi(g,I):null}includes(g,I){return!!this.active()&&this.hrange().includes(g,I)}getSort(g){const{sort:I}=this;return I&&I.ci===g?I:null}getFilter(g){const{filters:I}=this;for(let C=0;C!I.within(g)))}getFirstIncludes(g,I){for(let C=0;CI.intersects(g))))}intersects(g){for(let I=0;I{g.intersects(I)&&(I=g.union(I))})),I}add(g){this.deleteWithin(g),this._.push(g)}shift(g,I,C,A){this._.forEach((i=>{const{sri:e,sci:t,eri:l,eci:s}=i,o=i;"row"===g?e>=I?(o.sri+=C,o.eri+=C):e=I?(o.sci+=C,o.eci+=C):t{const i=A;i.within(g)&&(i.eri+=I,i.sri+=I,i.sci+=C,i.eci+=C)}))}setData(g){return this._=g.map((g=>Zi.valueOf(g))),this}getData(){return this._.map((g=>g.toString()))}}const Vi=(g={},...I)=>(I.forEach((I=>{Object.keys(I).forEach((C=>{const A=I[C];"string"==typeof A||"number"==typeof A||"boolean"==typeof A?g[C]=A:"function"!=typeof A&&!Array.isArray(A)&&A instanceof Object?(g[C]=g[C]||{},Vi(g[C],A)):g[C]=A}))})),g);function Xi(g){const I=`${g}`;let C=0,A=!1;for(let i=0;i5?l.toFixed(2):l;return l.toFixed(Math.max(A,i))}const Ri={cloneDeep:function(g){return JSON.parse(JSON.stringify(g))},merge:(...g)=>Vi({},...g),equals:function g(I,C){const A=Object.keys(I);if(A.length!==Object.keys(C).length)return!1;for(let i=0;ig)=>{let C=0,A=0;return Object.keys(g).forEach((i=>{C+=I(g[i],i),A+=1})),[C,A]},rangeEach:function(g,I,C){for(let A=g;Ai);s+=1)l=e(s),t+=l;return[s,t-l,l]},deleteProperty:function(g,I){const C=g[`${I}`];return delete g[`${I}`],C},numberCalc:Yi};class Ni{constructor({len:g,height:I}){this._={},this.len=g,this.height=I}getHeight(g){if(this.isHide(g))return 0;const I=this.get(g);return I&&I.height?I.height:this.height}setHeight(g,I){this.getOrNew(g).height=I}unhide(g){let I=g;for(;I>0&&(I-=1,this.isHide(I));)this.setHide(I,!1)}isHide(g){const I=this.get(g);return I&&I.hide}setHide(g,I){const C=this.getOrNew(g);!0===I?C.hide=!0:delete C.hide}setStyle(g,I){this.getOrNew(g).style=I}sumHeight(g,I,C){return Ri.rangeSum(g,I,(g=>C&&C.has(g)?0:this.getHeight(g)))}totalHeight(){return this.sumHeight(0,this.len)}get(g){return this._[g]}getOrNew(g){return this._[g]=this._[g]||{cells:{}},this._[g]}getCell(g,I){const C=this.get(g);return void 0!==C&&void 0!==C.cells&&void 0!==C.cells[I]?C.cells[I]:null}getCellMerge(g,I){const C=this.getCell(g,I);return C&&C.merge?C.merge:[0,0]}getCellOrNew(g,I){const C=this.getOrNew(g);return C.cells[I]=C.cells[I]||{},C.cells[I]}setCell(g,I,C,A="all"){const i=this.getOrNew(g);"all"===A?i.cells[I]=C:"text"===A?(i.cells[I]=i.cells[I]||{},i.cells[I].text=C.text):"format"===A&&(i.cells[I]=i.cells[I]||{},i.cells[I].style=C.style,C.merge&&(i.cells[I].merge=C.merge))}setCellText(g,I,C){const A=this.getCellOrNew(g,I);!1!==A.editable&&(A.text=C)}copyPaste(g,I,C,A=!1,i=()=>{}){const{sri:e,sci:t,eri:l,eci:s}=g,o=I.sri,c=I.sci,d=I.eri,a=I.eci,[n,r]=g.size(),[m,h]=I.size();let Z=!0,b=0;(d0){const{text:g}=p;let C=m-c+(I-o)+2;if(Z||(C-=b+1),"="===g[0])p.text=g.replace(/[a-zA-Z]{1,3}\d+/g,(g=>{let[I,A]=[0,0];return e===o?I=C-1:A=C-1,/^\d+$/.test(g)?g:hi(g,I,A)}));else if(n<=1&&r>1&&(o>l||d1&&(c>s||a{this.eachCells(A,(i=>{let e=parseInt(A,10),t=parseInt(i,10);g.includes(A,i)&&(e=I.sri+(e-g.sri),t=I.sci+(t-g.sci)),C[e]=C[e]||{cells:{}},C[e].cells[t]=this._[A].cells[i]}))})),this._=C}paste(g,I){if(g.length<=0)return;const{sri:C,sci:A}=I;g.forEach(((g,I)=>{const i=C+I;g.forEach(((g,I)=>{const C=A+I;this.setCellText(i,C,g)}))}))}insert(g,I=1){const C={};this.each(((A,i)=>{let e=parseInt(A,10);e>=g&&(e+=I,this.eachCells(A,((C,A)=>{A.text&&"="===A.text[0]&&(A.text=A.text.replace(/[a-zA-Z]{1,3}\d+/g,(C=>hi(C,0,I,((I,C)=>C>=g)))))}))),C[e]=i})),this._=C,this.len+=I}delete(g,I){const C=I-g+1,A={};this.each(((i,e)=>{const t=parseInt(i,10);tI&&(A[t-C]=e,this.eachCells(i,((g,A)=>{A.text&&"="===A.text[0]&&(A.text=A.text.replace(/[a-zA-Z]{1,3}\d+/g,(g=>hi(g,0,-C,((g,C)=>C>I)))))})))})),this._=A,this.len-=C}insertColumn(g,I=1){this.each(((C,A)=>{const i={};this.eachCells(C,((C,A)=>{let e=parseInt(C,10);e>=g&&(e+=I,A.text&&"="===A.text[0]&&(A.text=A.text.replace(/[a-zA-Z]{1,3}\d+/g,(C=>hi(C,I,0,(I=>I>=g)))))),i[e]=A})),A.cells=i}))}deleteColumn(g,I){const C=I-g+1;this.each(((A,i)=>{const e={};this.eachCells(A,((A,i)=>{const t=parseInt(A,10);tI&&(e[t-C]=i,i.text&&"="===i.text[0]&&(i.text=i.text.replace(/[a-zA-Z]{1,3}\d+/g,(g=>hi(g,-C,0,(g=>g>I))))))})),i.cells=e}))}deleteCells(g,I="all"){g.each(((g,C)=>{this.deleteCell(g,C,I)}))}deleteCell(g,I,C="all"){const A=this.get(g);if(null!==A){const i=this.getCell(g,I);null!==i&&!1!==i.editable&&("all"===C?delete A.cells[I]:"text"===C?(i.text&&delete i.text,i.value&&delete i.value):"format"===C?(void 0!==i.style&&delete i.style,i.merge&&delete i.merge):"merge"===C&&i.merge&&delete i.merge)}}maxCell(){const g=Object.keys(this._),I=g[g.length-1],C=this._[I];if(C){const{cells:g}=C,A=Object.keys(g),i=A[A.length-1];return[parseInt(I,10),parseInt(i,10)]}return[0,0]}each(g){Object.entries(this._).forEach((([I,C])=>{g(I,C)}))}eachCells(g,I){this._[g]&&this._[g].cells&&Object.entries(this._[g].cells).forEach((([g,C])=>{I(g,C)}))}setData(g){g.len&&(this.len=g.len,delete g.len),this._=g}getData(){const{len:g}=this;return Object.assign({len:g},this._)}}class Hi{constructor({len:g,width:I,indexWidth:C,minWidth:A}){this._={},this.len=g,this.width=I,this.indexWidth=C,this.minWidth=A}setData(g){g.len&&(this.len=g.len,delete g.len),this._=g}getData(){const{len:g}=this;return Object.assign({len:g},this._)}getWidth(g){if(this.isHide(g))return 0;const I=this._[g];return I&&I.width?I.width:this.width}getOrNew(g){return this._[g]=this._[g]||{},this._[g]}setWidth(g,I){this.getOrNew(g).width=I}unhide(g){let I=g;for(;I>0&&(I-=1,this.isHide(I));)this.setHide(I,!1)}isHide(g){const I=this._[g];return I&&I.hide}setHide(g,I){const C=this.getOrNew(g);!0===I?C.hide=!0:delete C.hide}setStyle(g,I){this.getOrNew(g).style=I}sumWidth(g,I){return Ri.rangeSum(g,I,(g=>this.getWidth(g)))}totalWidth(){return this.sumWidth(0,this.len)}}let Ki=["en"];const fi={en:{toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}}};function Fi(g,I){if(I)for(const C of Ki){if(!I[C])break;let A=I[C];const i=g.match(/(?:\\.|[^.])+/g);for(let g=0;gMi(g)}function Ji(g,I,C=!1){C?Ki=[g]:Ki.unshift(g),I&&(fi[g]=I)}const ki={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function Di(g,I,...C){let A="";return g||(A=Mi(`validation.${I}`,...C)),[g,A]}class vi{constructor(g,I,C,A){this.required=I,this.value=C,this.type=g,this.operator=A,this.message=""}parseValue(g){const{type:I}=this;return"date"===I?new Date(g):"number"===I?Number(g):g}equals(g){let I=this.type===g.type&&this.required===g.required&&this.operator===g.operator;return I&&(I=Array.isArray(this.value)?Ri.arrayEquals(this.value,g.value):this.value===g.value),I}values(){return this.value.split(",")}validate(g){const{required:I,operator:C,value:A,type:i}=this;if(I&&/^\s*$/.test(g))return Di(!1,"required");if(/^\s*$/.test(g))return[!0];if(ki[i]&&!ki[i].test(g))return Di(!1,"notMatch");if("list"===i)return Di(this.values().includes(g),"notIn");if(C){const I=this.parseValue(g);if("be"===C){const[g,C]=A;return Di(I>=this.parseValue(g)&&I<=this.parseValue(C),"between",g,C)}if("nbe"===C){const[g,C]=A;return Di(Ithis.parseValue(C),"notBetween",g,C)}if("eq"===C)return Di(I===this.parseValue(A),"equal",A);if("neq"===C)return Di(I!==this.parseValue(A),"notEqual",A);if("lt"===C)return Di(Ithis.parseValue(A),"greaterThan",A);if("gte"===C)return Di(I>=this.parseValue(A),"greaterThanEqual",A)}return[!0]}}class Li{constructor(g,I,C){this.refs=I,this.mode=g,this.validator=C}includes(g,I){const{refs:C}=this;for(let A=0;A{const A=Zi.valueOf(C);if(A.intersects(g)){A.difference(g).forEach((g=>I.push(g.toString())))}else I.push(C)})),this.refs=I}getData(){const{refs:g,mode:I,validator:C}=this,{type:A,required:i,operator:e,value:t}=C;return{refs:g,mode:I,type:A,required:i,operator:e,value:t}}static valueOf({refs:g,mode:I,type:C,required:A,operator:i,value:e}){return new Li(I,g,new vi(C,A,e,i))}}class zi{constructor(){this._=[],this.errors=new Map}getError(g,I){return this.errors.get(`${g}_${I}`)}validate(g,I,C){const A=this.get(g,I),i=`${g}_${I}`,{errors:e}=this;if(null!==A){const[g,I]=A.validator.validate(C);g?e.delete(i):e.set(i,I)}else e.delete(i);return!0}add(g,I,{type:C,required:A,value:i,operator:e}){const t=new vi(C,A,i,e),l=this.getByValidator(t);null!==l?l.addRef(I):this._.push(new Li(g,[I],t))}getByValidator(g){for(let I=0;I{I.remove(g)}))}each(g){this._.forEach((I=>g(I)))}getData(){return this._.filter((g=>g.refs.length>0)).map((g=>g.getData()))}setData(g){this._=g.map((g=>Li.valueOf(g)))}}const Ti={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},xi=(g,I)=>Object.prototype.hasOwnProperty.call(g,I);function Ui(g,I,C=()=>{}){const{merges:A}=this,i=I.clone(),[e,t]=g.size(),[l,s]=I.size();return e>l&&(i.eri=I.sri+e-1),t>s&&(i.eci=I.sci+t-1),!A.intersects(i)||(C(Mi("error.pasteForMergedCell")),!1)}function ji(g,I,C,A=!1){const{rows:i,merges:e}=this;"all"!==C&&"format"!==C||(i.deleteCells(I,C),e.deleteWithin(I)),i.copyPaste(g,I,C,A,((g,I,C)=>{if(C&&C.merge){const[A,i]=C.merge;if(A<=0&&i<=0)return;e.add(new Zi(g,I,g+A,I+i))}}))}function Qi(g,I){const{clipboard:C,rows:A,merges:i}=this;A.cutPaste(g,I),i.move(g,I.sri-g.sri,I.sci-g.sci),C.clear()}function Oi(g,I,C){const{styles:A,rows:i}=this,e=i.getCellOrNew(g,I);let t={};void 0!==e.style&&(t=Ri.cloneDeep(A[e.style])),t=Ri.merge(t,{border:C}),e.style=this.addStyle(t)}function Ei({mode:g,style:I,color:C}){const{styles:A,selector:i,rows:e}=this,{sri:t,sci:l,eri:s,eci:o}=i.range,c=!this.isSignleSelected();if(c||"inside"!==g&&"horizontal"!==g&&"vertical"!==g)if("outside"!==g||c){if("none"===g)i.range.each(((g,I)=>{const C=e.getCell(g,I);if(C&&void 0!==C.style){const g=Ri.cloneDeep(A[C.style]);delete g.border,C.style=this.addStyle(g)}}));else if("all"===g||"inside"===g||"outside"===g||"horizontal"===g||"vertical"===g){const A=[];for(let i=t;i<=s;i+=1)for(let d=l;d<=o;d+=1){const a=[];for(let g=0;gA.splice(g,1))),d>o)break;const n=e.getCell(i,d);let[r,m]=[0,0];n&&n.merge&&([r,m]=n.merge,A.push([i,d,r,m]));const h=r>0&&i+r===s,Z=m>0&&d+m===o;let b={};"all"===g?b={bottom:[I,C],top:[I,C],left:[I,C],right:[I,C]}:"inside"===g?(!Z&&d0&&Oi.call(this,i,d,b),d+=m}}else if("top"===g||"bottom"===g)for(let d=l;d<=o;d+=1)"top"===g&&(Oi.call(this,t,d,{top:[I,C]}),d+=e.getCellMerge(t,d)[1]),"bottom"===g&&(Oi.call(this,s,d,{bottom:[I,C]}),d+=e.getCellMerge(s,d)[1]);else if("left"===g||"right"===g)for(let d=t;d<=s;d+=1)"left"===g&&(Oi.call(this,d,l,{left:[I,C]}),d+=e.getCellMerge(d,l)[0]),"right"===g&&(Oi.call(this,d,o,{right:[I,C]}),d+=e.getCellMerge(d,o)[0])}else Oi.call(this,t,l,{top:[I,C],bottom:[I,C],left:[I,C],right:[I,C]})}function Pi(g,I){const{rows:C}=this,A=this.freezeTotalHeight();let i=C.height;A+C.heightg);t+=1)e.has(t)||(s=C.getHeight(t),l+=s);return l-=s,l<=0?{ri:-1,top:0,height:s}:{ri:t-1,top:l,height:s}}function _i(g,I){const{cols:C}=this,A=this.freezeTotalWidth();let i=C.indexWidth;A+C.indexWidthC.getWidth(g)));return t<=0?{ci:-1,left:0,width:C.indexWidth}:{ci:e-1,left:t,width:l}}class qi{constructor(g,I){this.settings=Ri.merge(Ti,I||{}),this.name=g||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new yi,this.rows=new Ni(this.settings.row),this.cols=new Hi(this.settings.col),this.validations=new zi,this.hyperlinks={},this.comments={},this.selector=new bi,this.scroll=new Gi,this.history=new ui,this.clipboard=new pi,this.autoFilter=new Bi,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(g,I,C){this.changeData((()=>{this.validations.add(g,I,C)}))}removeValidation(){const{range:g}=this.selector;this.changeData((()=>{this.validations.remove(g)}))}getSelectedValidator(){const{ri:g,ci:I}=this.selector,C=this.validations.get(g,I);return C?C.validator:null}getSelectedValidation(){const{ri:g,ci:I,range:C}=this.selector,A=this.validations.get(g,I),i={ref:C.toString()};return null!==A&&(i.mode=A.mode,i.validator=A.validator),i}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),(g=>{this.setData(g)}))}redo(){this.history.redo(this.getData(),(g=>{this.setData(g)}))}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(){if(void 0===navigator.clipboard)return;let g="";const I=this.rows.getData();for(let C=this.selector.range.sri;C<=this.selector.range.eri;C+=1){if(xi(I,C)){for(let A=this.selector.range.sci;A<=this.selector.range.eci;A+=1)if(A>this.selector.range.sci&&(g+="\t"),xi(I[C].cells,A)){const i=String(I[C].cells[A].text);-1===i.indexOf("\n")&&-1===i.indexOf("\t")&&-1===i.indexOf('"')?g+=i:g+=`"${i}"`}}else for(let I=this.selector.range.sci;I<=this.selector.range.eci;I+=1)g+="\t";g+="\n"}navigator.clipboard.writeText(g).then((()=>{}),(g=>{}))}cut(){this.clipboard.cut(this.selector.range)}paste(g="all",I=()=>{}){const{clipboard:C,selector:A}=this;return!C.isClear()&&(!!Ui.call(this,C.range,A.range,I)&&(this.changeData((()=>{C.isCopy()?ji.call(this,C.range,A.range,g):C.isCut()&&Qi.call(this,C.range,A.range)})),!0))}pasteFromText(g){const I=g.split("\r\n").map((g=>g.replace(/"/g,"").split("\t")));I.length>0&&(I.length-=1);const{rows:C,selector:A}=this;this.changeData((()=>{C.paste(I,A.range)}))}autofill(g,I,C=()=>{}){const A=this.selector.range;return!!Ui.call(this,A,g,C)&&(this.changeData((()=>{ji.call(this,A,g,I,!0)})),!0)}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(g,I){const{selector:C,rows:A,cols:i,merges:e}=this;let{sri:t,sci:l,eri:s,eci:o}=C.range;const c=C.ri,d=C.ci;let[a,n]=[g,I];return g<0&&(a=A.len-1),I<0&&(n=i.len-1),[t,s]=a>c?[c,a]:[a,c],[l,o]=n>d?[d,n]:[n,d],C.range=e.union(new Zi(t,l,s,o)),C.range=e.union(C.range),C.range}calSelectedRangeByStart(g,I){const{selector:C,rows:A,cols:i,merges:e}=this;let t=e.getFirstIncludes(g,I);return null===t&&(t=new Zi(g,I,g,I),-1===g&&(t.sri=0,t.eri=A.len-1),-1===I&&(t.sci=0,t.eci=i.len-1)),C.range=t,t}setSelectedCellAttr(g,I){this.changeData((()=>{const{selector:C,styles:A,rows:i}=this;if("merge"===g)I?this.merge():this.unmerge();else if("border"===g)Ei.call(this,I);else if("formula"===g){const{ri:g,ci:A,range:e}=C;if(C.multiple()){const[A,t]=C.size(),{sri:l,sci:s,eri:o,eci:c}=e;if(A>1)for(let g=s;g<=c;g+=1){i.getCellOrNew(o+1,g).text=`=${I}(${mi(g,l)}:${mi(g,o)})`}else if(t>1){i.getCellOrNew(g,c+1).text=`=${I}(${mi(s,g)}:${mi(c,g)})`}}else{i.getCellOrNew(g,A).text=`=${I}()`}}else C.range.each(((C,e)=>{const t=i.getCellOrNew(C,e);let l={};if(void 0!==t.style&&(l=Ri.cloneDeep(A[t.style])),"format"===g)l.format=I,t.style=this.addStyle(l);else if("font-bold"===g||"font-italic"===g||"font-name"===g||"font-size"===g){const C={};C[g.split("-")[1]]=I,l.font=Object.assign(l.font||{},C),t.style=this.addStyle(l)}else"strike"===g||"textwrap"===g||"underline"===g||"align"===g||"valign"===g||"color"===g||"bgcolor"===g?(l[g]=I,t.style=this.addStyle(l)):t[g]=I}))}))}setSelectedCellText(g,I="input"){const{autoFilter:C,selector:A,rows:i}=this,{ri:e,ci:t}=A;let l=e;this.unsortedRowMap.has(e)&&(l=this.unsortedRowMap.get(e));const s=i.getCell(l,t),o=s?s.text:"";if(this.setCellText(l,t,g,I),C.active()){const I=C.getFilter(t);if(I){const C=I.value.findIndex((g=>g===o));C>=0&&I.value.splice(C,1,g)}}}getSelectedCell(){const{ri:g,ci:I}=this.selector;let C=g;return this.unsortedRowMap.has(g)&&(C=this.unsortedRowMap.get(g)),this.rows.getCell(C,I)}xyInSelectedRect(g,I){const{left:C,top:A,width:i,height:e}=this.getSelectedRect(),t=g-this.cols.indexWidth,l=I-this.rows.height;return t>C&&tA&&l0&&h>o&&(n=o),m>0&&m>c&&(r=c),{l:o,t:c,left:n,top:r,height:d,width:a,scroll:I}}getCellRectByXY(g,I){const{scroll:C,merges:A,rows:i,cols:e}=this;let{ri:t,top:l,height:s}=Pi.call(this,I,C.y),{ci:o,left:c,width:d}=_i.call(this,g,C.x);if(-1===o&&(d=e.totalWidth()),-1===t&&(s=i.totalHeight()),t>=0||o>=0){const g=A.getFirstIncludes(t,o);g&&(t=g.sri,o=g.sci,({left:c,top:l,width:d,height:s}=this.cellRect(t,o)))}return{ri:t,ci:o,left:c,top:l,width:d,height:s}}isSignleSelected(){const{sri:g,sci:I,eri:C,eci:A}=this.selector.range,i=this.getCell(g,I);if(i&&i.merge){const[e,t]=i.merge;if(g+e===C&&I+t===A)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:g,sci:I,eri:C,eci:A}=this.selector.range,i=this.getCell(g,I);if(i&&i.merge){const[e,t]=i.merge;if(g+e===C&&I+t===A)return!0}return!1}merge(){const{selector:g,rows:I}=this;if(this.isSignleSelected())return;const[C,A]=g.size();if(C>1||A>1){const{sri:i,sci:e}=g.range;this.changeData((()=>{const t=I.getCellOrNew(i,e);t.merge=[C-1,A-1],this.merges.add(g.range),this.rows.deleteCells(g.range),this.rows.setCell(i,e,t)}))}}unmerge(){const{selector:g}=this;if(!this.isSignleSelected())return;const{sri:I,sci:C}=g.range;this.changeData((()=>{this.rows.deleteCell(I,C,"merge"),this.merges.deleteWithin(g.range)}))}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:g,selector:I}=this;this.changeData((()=>{g.active()?(g.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):g.ref=I.range.toString()}))}setAutoFilter(g,I,C,A){const{autoFilter:i}=this;i.addFilter(g,C,A),i.setSort(g,I),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:g,rows:I}=this;if(!g.active())return;const{sort:C}=g,{rset:A,fset:i}=g.filteredRows(((g,C)=>I.getCell(g,C))),e=Array.from(i),t=Array.from(i);C&&e.sort(((g,I)=>"asc"===C.order?g-I:"desc"===C.order?I-g:0)),this.exceptRowSet=A,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,e.forEach(((g,I)=>{this.sortedRowMap.set(t[I],g),this.unsortedRowMap.set(g,t[I])}))}deleteCell(g="all"){const{selector:I}=this;this.changeData((()=>{this.rows.deleteCells(I.range,g),"all"!==g&&"format"!==g||this.merges.deleteWithin(I.range)}))}insert(g,I=1){this.changeData((()=>{const{sri:C,sci:A}=this.selector.range,{rows:i,merges:e,cols:t}=this;let l=C;"row"===g?i.insert(C,I):"column"===g&&(i.insertColumn(A,I),l=A,t.len+=1),e.shift(g,l,I,((g,I,C,A)=>{const e=i.getCell(g,I);e.merge[0]+=C,e.merge[1]+=A}))}))}delete(g){this.changeData((()=>{const{rows:I,merges:C,selector:A,cols:i}=this,{range:e}=A,{sri:t,sci:l,eri:s,eci:o}=A.range,[c,d]=A.range.size();let a=t,n=c;"row"===g?I.delete(t,s):"column"===g&&(I.deleteColumn(l,o),a=e.sci,n=d,i.len-=1),C.shift(g,a,-n,((g,C,A,i)=>{const e=I.getCell(g,C);e.merge[0]+=A,e.merge[1]+=i,0===e.merge[0]&&0===e.merge[1]&&delete e.merge}))}))}scrollx(g,I){const{scroll:C,freeze:A,cols:i}=this,[,e]=A,[t,l,s]=Ri.rangeReduceIf(e,i.len,0,0,g,(g=>i.getWidth(g)));let o=l;g>0&&(o+=s),C.x!==o&&(C.ci=g>0?t:0,C.x=o,I())}scrolly(g,I){const{scroll:C,freeze:A,rows:i}=this,[e]=A,[t,l,s]=Ri.rangeReduceIf(e,i.len,0,0,g,(g=>i.getHeight(g)));let o=l;g>0&&(o+=s),C.y!==o&&(C.ri=g>0?t:0,C.y=o,I())}cellRect(g,I){const{rows:C,cols:A}=this,i=A.sumWidth(0,I),e=C.sumHeight(0,g),t=C.getCell(g,I);let l=A.getWidth(I),s=C.getHeight(g);if(null!==t&&t.merge){const[i,e]=t.merge;if(i>0)for(let I=1;I<=i;I+=1)s+=C.getHeight(g+I);if(e>0)for(let g=1;g<=e;g+=1)l+=A.getWidth(I+g)}return{left:i,top:e,width:l,height:s,cell:t}}getCell(g,I){return this.rows.getCell(g,I)}getCellTextOrDefault(g,I){const C=this.getCell(g,I);return C&&C.text?C.text:""}getCellStyle(g,I){const C=this.getCell(g,I);return C&&void 0!==C.style?this.styles[C.style]:null}getCellStyleOrDefault(g,I){const{styles:C,rows:A}=this,i=A.getCell(g,I),e=i&&void 0!==i.style?C[i.style]:{};return Ri.merge(this.defaultStyle(),e)}getSelectedCellStyle(){const{ri:g,ci:I}=this.selector;return this.getCellStyleOrDefault(g,I)}setCellText(g,I,C,A){const{rows:i,history:e,validations:t}=this;"finished"===A?(i.setCellText(g,I,""),e.add(this.getData()),i.setCellText(g,I,C)):(i.setCellText(g,I,C),this.change(this.getData())),t.validate(g,I,C)}freezeIsActive(){const[g,I]=this.freeze;return g>0||I>0}setFreeze(g,I){this.changeData((()=>{this.freeze=[g,I]}))}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(g,I){this.changeData((()=>{this.rows.setHeight(g,I)}))}setColWidth(g,I){this.changeData((()=>{this.cols.setWidth(g,I)}))}viewHeight(){const{view:g,showToolbar:I,showBottomBar:C}=this.settings;let A=g.height();return C&&(A-=41),I&&(A-=41),A}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[g,I]=this.freeze;return new Zi(0,0,g-1,I-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:g,cols:I}=this,[C,A]=g.maxCell(),i=g.sumHeight(0,C+1),e=I.sumWidth(0,A+1);return new Zi(0,0,C,A,e,i)}exceptRowTotalHeight(g,I){const{exceptRowSet:C,rows:A}=this,i=Array.from(C);let e=0;return i.forEach((C=>{if(CI){const g=A.getHeight(C);e+=g}})),e}viewRange(){const{scroll:g,rows:I,cols:C,freeze:A,exceptRowSet:i}=this;let{ri:e,ci:t}=g;e<=0&&([e]=A),t<=0&&([,t]=A);let[l,s]=[0,0],[o,c]=[I.len,C.len];for(let d=e;dthis.viewHeight()));d+=1);for(let d=t;dthis.viewWidth()));d+=1);return new Zi(e,t,o,c,l,s)}eachMergesInView(g,I){this.merges.filterIntersects(g).forEach((g=>I(g)))}hideRowsOrCols(){const{rows:g,cols:I,selector:C}=this,[A,i]=C.size(),{sri:e,sci:t,eri:l,eci:s}=C.range;if(A===g.len)for(let o=t;o<=s;o+=1)I.setHide(o,!0);else if(i===I.len)for(let o=e;o<=l;o+=1)g.setHide(o,!0)}unhideRowsOrCols(g,I){this[`${g}s`].unhide(I)}rowEach(g,I,C){let A=0;const{rows:i}=this,e=this.exceptRowSet,t=[...e];let l=0;for(let s=0;s0&&(C(s,A,g),A+=g,A>this.viewHeight()))break}}colEach(g,I,C){let A=0;const{cols:i}=this;for(let e=g;e<=I;e+=1){const g=i.getWidth(e);if(g>0&&(C(e,A,g),A+=g,A>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(g){const{styles:I}=this;for(let C=0;C{if("merges"===I||"rows"===I||"cols"===I||"validations"===I)this[I].setData(g[I]);else if("freeze"===I){const[C,A]=ri(g[I]);this.freeze=[A,C]}else"autofilter"===I?this.autoFilter.setData(g[I]):void 0!==g[I]&&(this[I]=g[I])})),this}getData(){const{name:g,freeze:I,styles:C,merges:A,rows:i,cols:e,validations:t,autoFilter:l}=this;return{name:g,freeze:mi(I[1],I[0]),styles:C,merges:A.getData(),rows:i.getData(),cols:e.getData(),validations:t.getData(),autofilter:l.getData()}}}function $i(g,I,C){g.addEventListener(I,C)}function ge(g,I,C){g.removeEventListener(I,C)}function Ie(g){g.xclickoutside&&(ge(window.document.body,"click",g.xclickoutside),delete g.xclickoutside)}function Ce(g,I){g.xclickoutside=C=>{2===C.detail||g.contains(C.target)||(I?I(g):(g.hide(),Ie(g)))},$i(window.document.body,"click",g.xclickoutside)}function Ae(g,I,C){$i(g,"mousemove",I);g.xEvtUp=A=>{ge(g,"mousemove",I),ge(g,"mouseup",g.xEvtUp),C(A)},$i(g,"mouseup",g.xEvtUp)}function ie(g,I,C,A){let i="";Math.abs(g)>Math.abs(I)?(i=g>0?"right":"left",A(i,g,C)):(i=I>0?"down":"up",A(i,I,C))}const ee="x-spreadsheet";class te{constructor(g=!1,I){this.moving=!1,this.vertical=g,this.el=ci("div",`${ee}-resizer ${g?"vertical":"horizontal"}`).children(this.unhideHoverEl=ci("div",`${ee}-resizer-hover`).on("dblclick.stop",(g=>this.mousedblclickHandler(g))).css("position","absolute").hide(),this.hoverEl=ci("div",`${ee}-resizer-hover`).on("mousedown.stop",(g=>this.mousedownHandler(g))),this.lineEl=ci("div",`${ee}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=I,this.unhideFn=()=>{}}showUnhide(g){this.unhideIndex=g,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(g,I){const{moving:C,vertical:A,hoverEl:i,lineEl:e,el:t,unhideHoverEl:l}=this;if(C)return;this.cRect=g;const{left:s,top:o,width:c,height:d}=g;t.offset({left:A?s+c-5:s,top:A?o:o+d-5}).show(),i.offset({width:A?5:c,height:A?d:5}),e.offset({width:A?0:I.width,height:A?I.height:0}),l.offset({left:A?5-c:s,top:A?o:5-d,width:A?5:c,height:A?d:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(g){let I=g;const{el:C,lineEl:A,cRect:i,vertical:e,minDistance:t}=this;let l=e?i.width:i.height;A.show(),Ae(window,(g=>{this.moving=!0,null!==I&&1===g.buttons&&(e?(l+=g.movementX,l>t&&C.css("left",`${i.left+l}px`)):(l+=g.movementY,l>t&&C.css("top",`${i.top+l}px`)),I=g)}),(()=>{I=null,A.hide(),this.moving=!1,this.hide(),this.finishedFn&&(l{})).on("scroll.stop",(g=>{const{scrollTop:I,scrollLeft:C}=g.target;this.moveFn&&this.moveFn(this.vertical?I:C,g)}))}move(g){return this.el.scroll(g),this}scroll(){return this.el.scroll()}set(g,I){const C=g-1;if(I>C){const g=this.vertical?"height":"width";this.el.css(g,C-15+"px").show(),this.contentEl.css(this.vertical?"width":"height","1px").css(g,`${I}px`)}else this.el.hide();return this}}let se=10;class oe{constructor(g=!1){this.useHideInput=g,this.inputChange=()=>{},this.cornerEl=ci("div",`${ee}-selector-corner`),this.areaEl=ci("div",`${ee}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=ci("div",`${ee}-selector-clipboard`).hide(),this.autofillEl=ci("div",`${ee}-selector-autofill`).hide(),this.el=ci("div",`${ee}-selector`).css("z-index",`${se}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),g&&(this.hideInput=ci("input","").on("compositionend",(g=>{this.inputChange(g.target.value)})),this.el.child(this.hideInputDiv=ci("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=ci("div","hide-input").child(this.hideInput))),se+=1}setOffset(g){return this.el.offset(g).show(),this}hide(){return this.el.hide(),this}setAreaOffset(g){const{left:I,top:C,width:A,height:i}=g,e={width:A-3+.8,height:i-3+.8,left:I-.8,top:C-.8};this.areaEl.offset(e).show(),this.useHideInput&&(this.hideInputDiv.offset(e),this.hideInput.val("").focus())}setClipboardOffset(g){const{left:I,top:C,width:A,height:i}=g;this.clipboardEl.offset({left:I,top:C,width:A-5,height:i-5})}showAutofill(g){const{left:I,top:C,width:A,height:i}=g;this.autofillEl.offset({width:A-3,height:i-3,left:I,top:C}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function ce(g){const{data:I}=this,{left:C,top:A,width:i,height:e,scroll:t,l:l,t:s}=g,o=I.freezeTotalWidth(),c=I.freezeTotalHeight();let d=C-o;o>l&&(d-=t.x);let a=A-c;return c>s&&(a-=t.y),{left:d,top:a,width:i,height:e}}function de(g){const{data:I}=this,{left:C,width:A,height:i,l:e,t:t,scroll:l}=g,s=I.freezeTotalWidth();let o=C-s;return s>e&&(o-=l.x),{left:o,top:t,width:A,height:i}}function ae(g){const{data:I}=this,{top:C,width:A,height:i,l:e,t:t,scroll:l}=g,s=I.freezeTotalHeight();let o=C-s;return s>t&&(o-=l.y),{left:e,top:o,width:A,height:i}}function ne(g){const{br:I}=this;I.setAreaOffset(ce.call(this,g))}function re(g){const{tl:I}=this;I.setAreaOffset(g)}function me(g){const{t:I}=this;I.setAreaOffset(de.call(this,g))}function he(g){const{l:I}=this;I.setAreaOffset(ae.call(this,g))}function Ze(g){const{l:I}=this;I.setClipboardOffset(ae.call(this,g))}function be(g){const{br:I}=this;I.setClipboardOffset(ce.call(this,g))}function Ge(g){const{tl:I}=this;I.setClipboardOffset(g)}function ue(g){const{t:I}=this;I.setClipboardOffset(de.call(this,g))}function pe(g){ne.call(this,g),re.call(this,g),me.call(this,g),he.call(this,g)}function we(g){be.call(this,g),Ge.call(this,g),ue.call(this,g),Ze.call(this,g)}class We{constructor(g){this.inputChange=()=>{},this.data=g,this.br=new oe(!0),this.t=new oe,this.l=new oe,this.tl=new oe,this.br.inputChange=g=>{this.inputChange(g)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=ci("div",`${ee}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,se+=1}resetData(g){this.data=g,this.range=g.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:g,tl:I,t:C,l:A,br:i}=this,e=g.freezeTotalHeight(),t=g.freezeTotalWidth();e>0||t>0?(I.setOffset({width:t,height:e}),C.setOffset({left:t,height:e}),A.setOffset({top:e,width:t}),i.setOffset({left:t,top:e})):(I.hide(),C.hide(),A.hide(),i.setOffset({left:0,top:0}))}resetAreaOffset(){const g=this.data.getSelectedRect(),I=this.data.getClipboardRect();pe.call(this,g),we.call(this,I),this.resetOffset()}resetBRTAreaOffset(){const g=this.data.getSelectedRect(),I=this.data.getClipboardRect();ne.call(this,g),me.call(this,g),be.call(this,I),ue.call(this,I),this.resetOffset()}resetBRLAreaOffset(){const g=this.data.getSelectedRect(),I=this.data.getClipboardRect();ne.call(this,g),he.call(this,g),be.call(this,I),Ze.call(this,I),this.resetOffset()}set(g,I,C=!0){const{data:A}=this,i=A.calSelectedRangeByStart(g,I),{sri:e,sci:t}=i;if(C){let[C,i]=[g,I];g<0&&(C=0),I<0&&(i=0),A.selector.setIndexes(C,i),this.indexes=[C,i]}this.moveIndexes=[e,t],this.range=i,this.resetAreaOffset(),this.el.show()}setEnd(g,I,C=!0){const{data:A,lastri:i,lastci:e}=this;if(C){if(g===i&&I===e)return;this.lastri=g,this.lastci=I}this.range=A.calSelectedRangeByEnd(g,I),pe.call(this,this.data.getSelectedRect())}reset(){const{eri:g,eci:I}=this.data.selector.range;this.setEnd(g,I)}showAutofill(g,I){if(-1===g&&-1===I)return;const{sri:C,sci:A,eri:i,eci:e}=this.range,[t,l]=[g,I],s=C-g,o=i-g,c=e-I;if(A-I>0)this.arange=new Zi(C,l,i,A-1);else if(s>0)this.arange=new Zi(t,A,C-1,e);else if(c<0)this.arange=new Zi(C,e+1,i,l);else{if(!(o<0))return void(this.arange=null);this.arange=new Zi(i+1,A,t,e)}if(null!==this.arange){const g=this.data.getRect(this.arange);g.width+=2,g.height+=2;const{br:I,l:C,t:A,tl:i}=this;I.showAutofill(ce.call(this,g)),C.showAutofill(ae.call(this,g)),A.showAutofill(de.call(this,g)),i.showAutofill(g)}}hideAutofill(){["br","l","t","tl"].forEach((g=>{this[g].hideAutofill()}))}showClipboard(){const g=this.data.getClipboardRect();we.call(this,g),["br","l","t","tl"].forEach((g=>{this[g].showClipboard()}))}hideClipboard(){["br","l","t","tl"].forEach((g=>{this[g].hideClipboard()}))}}function Be(g){g.preventDefault(),g.stopPropagation();const{filterItems:I}=this;I.length<=0||(this.itemIndex>=0&&I[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=I.length-1),I[this.itemIndex].toggle())}function ye(g){g.stopPropagation();const{filterItems:I}=this;I.length<=0||(this.itemIndex>=0&&I[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>I.length-1&&(this.itemIndex=0),I[this.itemIndex].toggle())}function Ve(g){g.preventDefault();const{filterItems:I}=this;I.length<=0||(g.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),I[this.itemIndex].el.click(),this.hide())}function Xe(g){const{keyCode:I}=g;switch(g.ctrlKey&&g.stopPropagation(),I){case 37:case 39:default:g.stopPropagation();break;case 38:Be.call(this,g);break;case 40:ye.call(this,g);break;case 13:case 9:Ve.call(this,g)}}class Ye{constructor(g,I,C="200px"){this.filterItems=[],this.items=g,this.el=ci("div",`${ee}-suggest`).css("width",C).hide(),this.itemClick=I,this.itemIndex=-1}setOffset(g){this.el.cssRemoveKeys("top","bottom").offset(g)}hide(){const{el:g}=this;this.filterItems=[],this.itemIndex=-1,g.hide(),Ie(this.el.parent())}setItems(g){this.items=g}search(g){let{items:I}=this;if(/^\s*$/.test(g)||(I=I.filter((I=>(I.key||I).startsWith(g.toUpperCase())))),I=I.map((g=>{let{title:I}=g;I?"function"==typeof I&&(I=I()):I=g;const C=ci("div",`${ee}-item`).child(I).on("click.stop",(()=>{this.itemClick(g),this.hide()}));return g.label&&C.child(ci("div","label").html(g.label)),C})),this.filterItems=I,I.length<=0)return;const{el:C}=this;C.html("").children(...I).show(),Ce(C.parent(),(()=>{this.hide()}))}bindInputEvents(g){g.on("keydown",(g=>Xe.call(this,g)))}}class Re extends oi{constructor(g){super("div",`${ee}-icon`),this.iconNameEl=ci("div",`${ee}-icon-img ${g}`),this.child(this.iconNameEl)}setName(g){this.iconNameEl.className(`${ee}-icon-img ${g}`)}}function Ne(g,I){g.setMonth(g.getMonth()+I)}function He(g,I){const C=new Date(g);return C.setDate(I-g.getDay()+1),C}class Ke{constructor(g){this.value=g,this.cvalue=new Date(g),this.headerLeftEl=ci("div","calendar-header-left"),this.bodyEl=ci("tbody",""),this.buildAll(),this.el=ci("div","x-spreadsheet-calendar").children(ci("div","calendar-header").children(this.headerLeftEl,ci("div","calendar-header-right").children(ci("a","calendar-prev").on("click.stop",(()=>this.prev())).child(new Re("chevron-left")),ci("a","calendar-next").on("click.stop",(()=>this.next())).child(new Re("chevron-right")))),ci("table","calendar-body").children(ci("thead","").child(ci("tr","").children(...Mi("calendar.weeks").map((g=>ci("th","cell").child(g))))),this.bodyEl)),this.selectChange=()=>{}}setValue(g){this.value=g,this.cvalue=new Date(g),this.buildAll()}prev(){const{value:g}=this;Ne(g,-1),this.buildAll()}next(){const{value:g}=this;Ne(g,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:g}=this;this.headerLeftEl.html(`${Mi("calendar.months")[g.getMonth()]} ${g.getFullYear()}`)}buildBody(){const{value:g,cvalue:I,bodyEl:C}=this,A=function(g,I,C){const A=new Date(g,I,1,23,59,59),i=[[],[],[],[],[],[]];for(let e=0;e<6;e+=1)for(let g=0;g<7;g+=1){const t=He(A,7*e+g),l=t.getMonth()!==I,s=t.getMonth()===C.getMonth()&&t.getDate()===C.getDate();i[e][g]={d:t,disabled:l,active:s}}return i}(g.getFullYear(),g.getMonth(),I).map((g=>{const I=g.map((g=>{let I="cell";return g.disabled&&(I+=" disabled"),g.active&&(I+=" active"),ci("td","").child(ci("div",I).on("click.stop",(()=>{this.selectChange(g.d)})).child(g.d.getDate().toString()))}));return ci("tr","").children(...I)}));C.html("").children(...A)}}class fe{constructor(){this.calendar=new Ke(new Date),this.el=ci("div",`${ee}-datepicker`).child(this.calendar.el).hide()}setValue(g){const{calendar:I}=this;return"string"==typeof g?/^\d{4}-\d{1,2}-\d{1,2}$/.test(g)&&I.setValue(new Date(g.replace(new RegExp("-","g"),"/"))):g instanceof Date&&I.setValue(g),this}change(g){this.calendar.selectChange=I=>{g(I),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function Fe(){const{inputText:g}=this;if(!/^\s*$/.test(g)){const{textlineEl:I,textEl:C,areaOffset:A}=this,i=g.split("\n"),e=Math.max(...i.map((g=>g.length))),t=I.offset().width/g.length,l=(e+1)*t+5,s=this.viewFn().width-A.left-t;let o=i.length;if(l>A.width){let g=l;l>s&&(g=s,o+=parseInt(l/s,10),o+=l%s>0?1:0),C.css("width",`${g}px`)}o*=this.rowHeight,o>A.height&&C.css("height",`${o}px`)}}function Me({target:g},I){const{value:C,selectionEnd:A}=g,i=`${C.slice(0,A)}${I}${C.slice(A)}`;g.value=i,g.setSelectionRange(A+1,A+1),this.inputText=i,this.textlineEl.html(i),Fe.call(this)}function Se(g){const{keyCode:I,altKey:C}=g;13!==I&&9!==I&&g.stopPropagation(),13===I&&C&&(Me.call(this,g,"\n"),g.stopPropagation()),13!==I||C||g.preventDefault()}function Je(g){const I=g.target.value,{suggest:C,textlineEl:A,validator:i}=this,{cell:e}=this;if(null!==e)if("editable"in e&&!0===e.editable||void 0===e.editable){if(this.inputText=I,i)"list"===i.type?C.search(I):C.hide();else{const g=I.lastIndexOf("=");-1!==g?C.search(I.substring(g+1)):C.hide()}A.html(I),Fe.call(this),this.change("input",I)}else g.target.value=e.text;else{if(this.inputText=I,i)"list"===i.type?C.search(I):C.hide();else{const g=I.lastIndexOf("=");-1!==g?C.search(I.substring(g+1)):C.hide()}A.html(I),Fe.call(this),this.change("input",I)}}function ke(g){const{el:I}=this.textEl;setTimeout((()=>{I.focus(),I.setSelectionRange(g,g)}),0)}function De(g,I){const{textEl:C,textlineEl:A}=this;C.el.blur(),C.val(g),A.html(g),ke.call(this,I)}function ve(g){const{inputText:I,validator:C}=this;let A=0;if(C&&"list"===C.type)this.inputText=g,A=this.inputText.length;else{const C=I.lastIndexOf("="),i=I.substring(0,C+1);let e=I.substring(C+1);e=-1!==e.indexOf(")")?e.substring(e.indexOf(")")):"",this.inputText=`${i+g.key}(`,A=this.inputText.length,this.inputText+=`)${e}`}De.call(this,this.inputText,A)}function Le(){this.suggest.setItems(this.formulas)}class ze{constructor(g,I,C){this.viewFn=I,this.rowHeight=C,this.formulas=g,this.suggest=new Ye(g,(g=>{ve.call(this,g)})),this.datepicker=new fe,this.datepicker.change((g=>{this.setText(function(g){let I=g.getMonth()+1,C=g.getDate();return I<10&&(I=`0${I}`),C<10&&(C=`0${C}`),`${g.getFullYear()}-${I}-${C}`}(g)),this.clear()})),this.areaEl=ci("div",`${ee}-editor-area`).children(this.textEl=ci("textarea","").on("input",(g=>Je.call(this,g))).on("paste.stop",(()=>{})).on("keydown",(g=>Se.call(this,g))),this.textlineEl=ci("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",(()=>{})).on("mousedown.stop",(()=>{})),this.el=ci("div",`${ee}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(g,I){this.freeze.w=g,this.freeze.h=I}clear(){""!==this.inputText&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),Le.call(this),this.datepicker.hide()}setOffset(g,I="top"){const{textEl:C,areaEl:A,suggest:i,freeze:e,el:t}=this;if(g){this.areaOffset=g;const{left:l,top:s,width:o,height:c,l:d,t:a}=g,n={left:0,top:0};e.w>d&&e.h>a||(e.wd?n.top=e.h:e.h>a&&(n.left=e.w)),t.offset(n),A.offset({left:l-n.left-.8,top:s-n.top-.8}),C.offset({width:o-9+.8,height:c-3+.8});const r={left:0};r[I]=c,i.setOffset(r),i.hide()}}setCell(g,I){const{el:C,datepicker:A,suggest:i}=this;C.show(),this.cell=g;const e=g&&g.text||"";if(this.setText(e),this.validator=I,I){const{type:g}=I;"date"===g&&(A.show(),/^\s*$/.test(e)||A.setValue(e)),"list"===g&&(i.setItems(I.values()),i.search(""))}}setText(g){this.inputText=g,De.call(this,g,g.length),Fe.call(this)}}class Te extends oi{constructor(g,I=""){super("div",`${ee}-button ${I}`),this.child(Mi(`button.${g}`))}}function xe(){return window.devicePixelRatio||1}function Ue(){return xe()-.5}function je(g){return parseInt(g*xe(),10)}function Qe(g){const I=je(g);return I>0?I-.5:.5}class Oe{constructor(g,I,C,A,i=0){this.x=g,this.y=I,this.width=C,this.height=A,this.padding=i,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:g,bottom:I,left:C,right:A}){g&&(this.borderTop=g),A&&(this.borderRight=A),I&&(this.borderBottom=I),C&&(this.borderLeft=C)}innerWidth(){return this.width-2*this.padding-2}innerHeight(){return this.height-2*this.padding-2}textx(g){const{width:I,padding:C}=this;let{x:A}=this;return"left"===g?A+=C:"center"===g?A+=I/2:"right"===g&&(A+=I-C),A}texty(g,I){const{height:C,padding:A}=this;let{y:i}=this;return"top"===g?i+=A:"middle"===g?i+=C/2-I/2:"bottom"===g&&(i+=C-A-I),i}topxys(){const{x:g,y:I,width:C}=this;return[[g,I],[g+C,I]]}rightxys(){const{x:g,y:I,width:C,height:A}=this;return[[g+C,I],[g+C,I+A]]}bottomxys(){const{x:g,y:I,width:C,height:A}=this;return[[g,I+A],[g+C,I+A]]}leftxys(){const{x:g,y:I,height:C}=this;return[[g,I],[g,I+C]]}}function Ee(g,I,C,A,i,e,t){const l={x:0,y:0};"underline"===g?l.y="bottom"===i?0:"top"===i?-(e+2):-e/2:"strike"===g&&("bottom"===i?l.y=e/2:"top"===i&&(l.y=-(e/2+2))),"center"===A?l.x=t/2:"right"===A&&(l.x=t),this.line([I-l.x,C-l.y],[I-l.x+t,C-l.y])}class Pe{constructor(g,I,C){this.el=g,this.ctx=g.getContext("2d"),this.resize(I,C),this.ctx.scale(xe(),xe())}resize(g,I){this.el.style.width=`${g}px`,this.el.style.height=`${I}px`,this.el.width=je(g),this.el.height=je(I)}clear(){const{width:g,height:I}=this.el;return this.ctx.clearRect(0,0,g,I),this}attr(g){return Object.assign(this.ctx,g),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(g,I){return this.ctx.translate(je(g),je(I)),this}scale(g,I){return this.ctx.scale(g,I),this}clearRect(g,I,C,A){return this.ctx.clearRect(g,I,C,A),this}fillRect(g,I,C,A){return this.ctx.fillRect(je(g)-.5,je(I)-.5,je(C),je(A)),this}fillText(g,I,C){return this.ctx.fillText(g,je(I),je(C)),this}text(g,I,C={},A=!0){const{ctx:i}=this,{align:e,valign:t,font:l,color:s,strike:o,underline:c}=C,d=I.textx(e);i.save(),i.beginPath(),this.attr({textAlign:e,textBaseline:t,font:`${l.italic?"italic":""} ${l.bold?"bold":""} ${je(l.size)}px ${l.name}`,fillStyle:s,strokeStyle:s});const a=`${g}`.split("\n"),n=I.innerWidth(),r=[];a.forEach((g=>{const I=i.measureText(g).width;if(A&&I>je(n)){let I={w:0,len:0,start:0};for(let C=0;C=je(n)&&(r.push(g.substr(I.start,I.len)),I={w:0,len:0,start:C}),I.len+=1,I.w+=i.measureText(g[C]).width+1;I.len>0&&r.push(g.substr(I.start,I.len))}else r.push(g)}));const m=(r.length-1)*(l.size+2);let h=I.texty(t,m);return r.forEach((g=>{const I=i.measureText(g).width;this.fillText(g,d,h),o&&Ee.call(this,"strike",d,h,e,t,l.size,I),c&&Ee.call(this,"underline",d,h,e,t,l.size,I),h+=l.size+2})),i.restore(),this}border(g,I){const{ctx:C}=this;return C.lineWidth=Ue,C.strokeStyle=I,"medium"===g?C.lineWidth=je(2)-.5:"thick"===g?C.lineWidth=je(3):"dashed"===g?C.setLineDash([je(3),je(2)]):"dotted"===g?C.setLineDash([je(1),je(1)]):"double"===g&&C.setLineDash([je(2),0]),this}line(...g){const{ctx:I}=this;if(g.length>1){I.beginPath();const[C,A]=g[0];I.moveTo(Qe(C),Qe(A));for(let i=1;i{const[C]=g;let A=g;if('"'===C)return g.substring(1);let i=1;if("-"===C&&(A=g.substring(1),i=-1),A[0]>="0"&&A[0]<="9")return i*Number(A);const[e,t]=ri(A);return i*I(e,t)},gt=(g,I,C,A=[])=>{if("="===g[0]){const i=(g=>{const I=[],C=[];let A=[],i=0,e="",t=1,l="";for(let o=0;o="a"&&c<="z")A.push(c.toUpperCase());else if(c>="0"&&c<="9"||c>="A"&&c<="Z"||"."===c)A.push(c);else if('"'===c){for(o+=1;'"'!==g.charAt(o);)A.push(g.charAt(o)),o+=1;C.push(`"${A.join("")}`),A=[]}else if("-"===c&&/[+\-*/,(]/.test(l))A.push(c);else{if("("!==c&&A.length>0&&C.push(A.join("")),")"===c){let g=I.pop();if(2===i)try{const[I,A]=ri(C.pop()),[i,e]=ri(C.pop());let t=0;for(let g=i;g<=I;g+=1)for(let I=e;I<=A;I+=1)C.push(mi(g,I)),t+=1;C.push([g,t])}catch(s){}else if(1===i||3===i)3===i&&C.push(e),C.push([g,t]),t=1;else for(;"("!==g&&(C.push(g),!(I.length<=0));)g=I.pop();i=0}else if("="===c||">"===c||"<"===c){const I=g.charAt(o+1);e=c,"="!==I&&"-"!==I||(e+=I,o+=1),i=3}else if(":"===c)i=2;else if(","===c)3===i&&C.push(e),i=1,t+=1;else if("("===c&&A.length>0)I.push(A.join(""));else{if(I.length>0&&("+"===c||"-"===c)){let g=I[I.length-1];if("("!==g&&C.push(I.pop()),"*"===g||"/"===g)for(;I.length>0&&(g=I[I.length-1],"("!==g);)C.push(I.pop())}else if(I.length>0){const g=I[I.length-1];"*"!==g&&"/"!==g||C.push(I.pop())}I.push(c)}A=[]}l=c}}for(A.length>0&&C.push(A.join(""));I.length>0;)C.push(I.pop());return C})(g.substring(1));return i.length<=0?g:((g,I,C,A)=>{const i=[];for(let e=0;e"===l||"<"===l){let g=i.pop();Number.isNaN(g)||(g=Number(g));let I=i.pop();Number.isNaN(I)||(I=Number(I));let C=!1;"="===l?C=I===g:">"===t?C=I>g:">="===t?C=I>=g:"<"===t?C=I="a"&&l<="z"||l>="A"&&l<="Z")&&A.push(t),i.push($e(t,C)),A.pop()}}return i[0]})(i,I,((g,i)=>gt(C(g,i),I,C,A)),A)}return g},It={render:gt},Ct=[{key:"SUM",title:Si("formula.sum"),render:g=>g.reduce(((g,I)=>Yi("+",g,I)),0)},{key:"AVERAGE",title:Si("formula.average"),render:g=>g.reduce(((g,I)=>Number(g)+Number(I)),0)/g.length},{key:"MAX",title:Si("formula.max"),render:g=>Math.max(...g.map((g=>Number(g))))},{key:"MIN",title:Si("formula.min"),render:g=>Math.min(...g.map((g=>Number(g))))},{key:"IF",title:Si("formula._if"),render:([g,I,C])=>g?I:C},{key:"AND",title:Si("formula.and"),render:g=>g.every((g=>g))},{key:"OR",title:Si("formula.or"),render:g=>g.some((g=>g))},{key:"CONCAT",title:Si("formula.concat"),render:g=>g.join("")}],At=Ct,it={};Ct.forEach((g=>{it[g.key]=g}));const et=g=>g,tt=g=>{if(/^(-?\d*.?\d*)$/.test(g)){const I=Number(g).toFixed(2).toString(),[C,...A]=I.split("\\.");return[C.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...A]}return g},lt=[{key:"normal",title:Si("format.normal"),type:"string",render:et},{key:"text",title:Si("format.text"),type:"string",render:et},{key:"number",title:Si("format.number"),type:"number",label:"1,000.12",render:tt},{key:"percent",title:Si("format.percent"),type:"number",label:"10.12%",render:g=>`${g}%`},{key:"rmb",title:Si("format.rmb"),type:"number",label:"¥10.00",render:g=>`¥${tt(g)}`},{key:"usd",title:Si("format.usd"),type:"number",label:"$10.00",render:g=>`$${tt(g)}`},{key:"eur",title:Si("format.eur"),type:"number",label:"€10.00",render:g=>`€${tt(g)}`},{key:"date",title:Si("format.date"),type:"date",label:"26/09/2008",render:et},{key:"time",title:Si("format.time"),type:"date",label:"15:59:00",render:et},{key:"datetime",title:Si("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:et},{key:"duration",title:Si("format.duration"),type:"date",label:"24:01:00",render:et}],st={};lt.forEach((g=>{st[g.key]=g}));const ot=5,ct={fillStyle:"#f4f5f8"},dt={fillStyle:"#fff",lineWidth:Ue,strokeStyle:"#e6e6e6"};function at(g,I,C,A=0){const{left:i,top:e,width:t,height:l}=g.cellRect(I,C);return new Oe(i,e+A,t,l,ot)}function nt(g,I,C,A,i=0){const{sortedRowMap:e,rows:t,cols:l}=I;if(t.isHide(C)||l.isHide(A))return;let s=C;e.has(C)&&(s=e.get(C));const o=I.getCell(s,A);if(null===o)return;let c=!1;"editable"in o&&!1===o.editable&&(c=!0);const d=I.getCellStyleOrDefault(s,A),a=at(I,C,A,i);a.bgcolor=d.bgcolor,void 0!==d.border&&(a.setBorders(d.border),g.strokeBorders(a)),g.rect(a,(()=>{let i="";i=I.settings.evalPaused?o.text||"":It.render(o.text||"",it,((g,C)=>I.getCellTextOrDefault(C,g))),d.format&&(i=st[d.format].render(i));const e=Object.assign({},d.font);e.size=function(g){for(let I=0;I{const i=at(I,g,A);C.dropdown(i)}))}}function mt(g,I,C,A,i){const{draw:e,data:t}=this;e.save(),e.translate(I,C).translate(A,i);const{exceptRowSet:l}=t,s=t.exceptRowTotalHeight(g.sri,g.eri);e.save(),e.translate(0,-s),g.each(((g,I)=>{nt(e,t,g,I)}),(g=>(g=>{const I=l.has(g);if(I){const I=t.rows.getHeight(g);e.translate(0,-I)}return!I})(g))),e.restore();const o=new Set;e.save(),e.translate(0,-s),t.eachMergesInView(g,(({sri:g,sci:I,eri:C})=>{if(l.has(g)){if(!o.has(g)){o.add(g);const I=t.rows.sumHeight(g,C+1);e.translate(0,-I)}}else nt(e,t,g,I)})),e.restore(),rt.call(this,g),e.restore()}function ht(g,I,C,A){const{draw:i}=this;i.save(),i.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(g,I,C,A),i.restore()}function Zt(g,I,C,A,i,e){const{draw:t,data:l}=this,s=I.h,o=I.w,c=e+A,d=i+C;t.save(),t.attr(ct),"all"!==g&&"left"!==g||t.fillRect(0,c,C,s),"all"!==g&&"top"!==g||t.fillRect(d,0,o,A);const{sri:a,sci:n,eri:r,eci:m}=l.selector.range;t.attr({textAlign:"center",textBaseline:"middle",font:`500 ${je(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:Ue(),strokeStyle:"#e6e6e6"}),"all"!==g&&"left"!==g||(l.rowEach(I.sri,I.eri,((g,I,A)=>{const i=c+I,e=g;t.line([0,i],[C,i]),a<=e&&e0&&l.rows.isHide(g-1)&&(t.save(),t.attr({strokeStyle:"#c6c6c6"}),t.line([5,i+5],[C-5,i+5]),t.restore())})),t.line([0,s+c],[C,s+c]),t.line([C,c],[C,s+c])),"all"!==g&&"top"!==g||(l.colEach(I.sci,I.eci,((g,I,C)=>{const i=d+I,e=g;t.line([i,0],[i,A]),n<=e&&e0&&l.cols.isHide(g-1)&&(t.save(),t.attr({strokeStyle:"#c6c6c6"}),t.line([i+5,5],[i+5,A-5]),t.restore())})),t.line([o+d,0],[o+d,A]),t.line([0,A],[o+d,A])),t.restore()}function bt(g,I){const{draw:C}=this;C.save(),C.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,g,I),C.restore()}function Gt({sri:g,sci:I,eri:C,eci:A,w:i,h:e},t,l,s,o){const{draw:c,data:d}=this,{settings:a}=d;c.save(),c.attr(dt).translate(t+s,l+o),a.showGrid?(d.rowEach(g,C,((I,A,e)=>{I!==g&&c.line([0,A],[i,A]),I===C&&c.line([0,A+e],[i,A+e])})),d.colEach(I,A,((g,C,i)=>{g!==I&&c.line([C,0],[C,e]),g===A&&c.line([C+i,0],[C+i,e])})),c.restore()):c.restore()}function ut(g,I,C,A){const{draw:i,data:e}=this,t=e.viewWidth()-g,l=e.viewHeight()-I;i.save().translate(g,I).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),i.line([0,A],[t,A]),i.line([C,0],[C,l]),i.restore()}class pt{constructor(g,I){this.el=g,this.draw=new Pe(g,I.viewWidth(),I.viewHeight()),this.data=I}resetData(g){this.data=g,this.render()}render(){const{data:g}=this,{rows:I,cols:C}=g,A=C.indexWidth,i=I.height;this.draw.resize(g.viewWidth(),g.viewHeight()),this.clear();const e=g.viewRange(),t=g.freezeTotalWidth(),l=g.freezeTotalHeight(),{x:s,y:o}=g.scroll;Gt.call(this,e,A,i,t,l),mt.call(this,e,A,i,-s,-o),Zt.call(this,"all",e,A,i,t,l),bt.call(this,A,i);const[c,d]=g.freeze;if(c>0||d>0){if(c>0){const g=e.clone();g.sri=0,g.eri=c-1,g.h=l,Gt.call(this,g,A,i,t,0),mt.call(this,g,A,i,-s,0),Zt.call(this,"top",g,A,i,t,0)}if(d>0){const g=e.clone();g.sci=0,g.eci=d-1,g.w=t,Gt.call(this,g,A,i,0,l),Zt.call(this,"left",g,A,i,0,l),mt.call(this,g,A,i,0,-o)}const I=g.freezeViewRange();Gt.call(this,I,A,i,0,0),Zt.call(this,"all",I,A,i,0,0),mt.call(this,I,A,i,0,0),ut.call(this,A,i,t,l)}}clear(){this.draw.clear()}}const wt=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],Wt=["landscape","portrait"];function Bt(g){return parseInt(96*g,10)}function yt(g){"cancel"===g?this.el.hide():this.toPrint()}function Vt(g){const{paper:I}=this,{value:C}=g.target,A=wt[C];I.w=Bt(A[1]),I.h=Bt(A[2]),this.preview()}function Xt(g){const{paper:I}=this,{value:C}=g.target,A=Wt[C];I.orientation=A,this.preview()}let Yt=class{constructor(g){this.paper={w:Bt(wt[0][1]),h:Bt(wt[0][2]),padding:50,orientation:Wt[0],get width(){return"landscape"===this.orientation?this.h:this.w},get height(){return"landscape"===this.orientation?this.w:this.h}},this.data=g,this.el=ci("div",`${ee}-print`).children(ci("div",`${ee}-print-bar`).children(ci("div","-title").child("Print settings"),ci("div","-right").children(ci("div",`${ee}-buttons`).children(new Te("cancel").on("click",yt.bind(this,"cancel")),new Te("next","primary").on("click",yt.bind(this,"next"))))),ci("div",`${ee}-print-content`).children(this.contentEl=ci("div","-content"),ci("div","-sider").child(ci("form","").children(ci("fieldset","").children(ci("label","").child(`${Mi("print.size")}`),ci("select","").children(...wt.map(((g,I)=>ci("option","").attr("value",I).child(`${g[0]} ( ${g[1]}''x${g[2]}'' )`)))).on("change",Vt.bind(this))),ci("fieldset","").children(ci("label","").child(`${Mi("print.orientation")}`),ci("select","").children(...Wt.map(((g,I)=>ci("option","").attr("value",I).child(`${Mi("print.orientations")[I]}`)))).on("change",Xt.bind(this))))))).hide()}resetData(g){this.data=g}preview(){const{data:g,paper:I}=this,{width:C,height:A,padding:i}=I,e=C-2*i,t=A-2*i,l=g.contentRange(),s=parseInt(l.h/t,10)+1,o=e/l.w;let c=i;const d=i;o>1&&(c+=(e-l.w)/2);let a=0,n=0;this.contentEl.html(""),this.canvases=[];const r={sri:0,sci:0,eri:0,eci:0};for(let m=0;m{nt(m,g,I,C,h)})),m.restore(),r.sri=r.eri,r.sci=r.eci,n+=i,this.contentEl.child(ci("div",`${ee}-canvas-card-wraper`).child(e.child(s)))}this.el.show()}toPrint(){this.el.hide();const{paper:g}=this,I=ci("iframe","").hide(),{el:C}=I;window.document.body.appendChild(C);const{contentWindow:A}=C,i=A.document,e=document.createElement("style");e.innerHTML=`\n @page { size: ${g.width}px ${g.height}px; };\n canvas {\n page-break-before: auto; \n page-break-after: always;\n image-rendering: pixelated;\n };\n `,i.head.appendChild(e),this.canvases.forEach((g=>{const I=g.cloneNode(!1);I.getContext("2d").drawImage(g,0,0),i.body.appendChild(I)})),A.print()}};const Rt=[{key:"copy",title:Si("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:Si("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:Si("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:Si("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:Si("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:Si("contextmenu.insertRow")},{key:"insert-column",title:Si("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:Si("contextmenu.deleteRow")},{key:"delete-column",title:Si("contextmenu.deleteColumn")},{key:"delete-cell-text",title:Si("contextmenu.deleteCellText")},{key:"hide",title:Si("contextmenu.hide")},{key:"divider"},{key:"validation",title:Si("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:Si("contextmenu.cellprintable")},{key:"cell-non-printable",title:Si("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:Si("contextmenu.celleditable")},{key:"cell-non-editable",title:Si("contextmenu.cellnoneditable")}];function Nt(g){return"divider"===g.key?ci("div",`${ee}-item divider`):ci("div",`${ee}-item`).on("click",(()=>{this.itemClick(g.key),this.hide()})).children(g.title(),ci("div","label").child(g.label||""))}function Ht(){return Rt.map((g=>Nt.call(this,g)))}let Kt=class{constructor(g,I=!1){this.menuItems=Ht.call(this),this.el=ci("div",`${ee}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=g,this.itemClick=()=>{},this.isHide=I,this.setMode("range")}setMode(g){const I=this.menuItems[12];"row-col"===g?I.show():I.hide()}hide(){const{el:g}=this;g.hide(),Ie(g)}setPosition(g,I){if(this.isHide)return;const{el:C}=this,{width:A}=C.show().offset(),i=this.viewFn(),e=i.height/2;let t=g;i.width-g<=A&&(t-=A),C.css("left",`${t}px`),I>e?C.css("bottom",i.height-I+"px").css("max-height",`${I}px`).css("top","auto"):C.css("top",`${I}px`).css("max-height",i.height-I+"px").css("bottom","auto"),Ce(C)}};class ft{constructor(g,I,C){this.tip=Mi(`toolbar.${g.replace(/-[a-z]/g,(g=>g[1].toUpperCase()))}`),I&&(this.tip+=` (${I})`),this.tag=g,this.shortcut=I,this.value=C,this.el=this.element(),this.change=()=>{}}element(){const{tip:g}=this;return ci("div",`${ee}-toolbar-btn`).on("mouseenter",(I=>{!function(g,I){if(I.classList.contains("active"))return;const{left:C,top:A,width:i,height:e}=I.getBoundingClientRect(),t=ci("div",`${ee}-tooltip`).html(g).show();document.body.appendChild(t.el);const l=t.box();t.css("left",C+i/2-l.width/2+"px").css("top",`${A+e+2}px`),$i(I,"mouseleave",(()=>{document.body.contains(t.el)&&document.body.removeChild(t.el)})),$i(I,"click",(()=>{document.body.contains(t.el)&&document.body.removeChild(t.el)}))}(g,I.target)})).attr("data-tooltip",g)}setState(){}}class Ft extends ft{dropdown(){}getValue(g){return g}element(){const{tag:g}=this;return this.dd=this.dropdown(),this.dd.change=I=>this.change(g,this.getValue(I)),super.element().child(this.dd)}setState(g){g&&(this.value=g,this.dd.setTitle(g))}}class Mt extends oi{constructor(g,I,C,A,...i){super("div",`${ee}-dropdown ${A}`),this.title=g,this.change=()=>{},this.headerClick=()=>{},"string"==typeof g?this.title=ci("div",`${ee}-dropdown-title`).child(g):C&&this.title.addClass("arrow-left"),this.contentEl=ci("div",`${ee}-dropdown-content`).css("width",I).hide(),this.setContentChildren(...i),this.headerEl=ci("div",`${ee}-dropdown-header`),this.headerEl.on("click",(()=>{"block"!==this.contentEl.css("display")?this.show():this.hide()})).children(this.title,C?ci("div",`${ee}-icon arrow-right`).child(ci("div",`${ee}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...g){this.contentEl.html(""),g.length>0&&this.contentEl.children(...g)}setTitle(g){this.title.html(g),this.hide()}show(){const{contentEl:g}=this;g.show(),this.parent().active(),Ce(this.parent(),(()=>{this.hide()}))}hide(){this.parent().active(!1),this.contentEl.hide(),Ie(this.parent())}}class St extends Mt{constructor(g,I){super(new Re(`align-${I}`),"auto",!0,"bottom-left",...g.map((g=>{return(I=`align-${g}`,ci("div",`${ee}-item`).child(new Re(I))).on("click",(()=>{this.setTitle(g),this.change(g)}));var I})))}setTitle(g){this.title.setName(`align-${g}`),this.hide()}}class Jt extends Ft{constructor(g){super("align","",g)}dropdown(){const{value:g}=this;return new St(["left","center","right"],g)}}class kt extends Ft{constructor(g){super("valign","",g)}dropdown(){const{value:g}=this;return new St(["top","middle","bottom"],g)}}class Dt extends ft{element(){const{tag:g}=this;return super.element().child(new Re(g)).on("click",(()=>this.click()))}click(){this.change(this.tag,this.toggle())}setState(g){this.el.active(g)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class vt extends Dt{constructor(){super("autofilter")}setState(){}}class Lt extends Dt{constructor(){super("font-bold","Ctrl+B")}}class zt extends Dt{constructor(){super("font-italic","Ctrl+I")}}class Tt extends Dt{constructor(){super("strike","Ctrl+U")}}class xt extends Dt{constructor(){super("underline","Ctrl+U")}}const Ut=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],jt=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],Qt=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function Ot(g){return ci("td","").child(ci("div",`${ee}-color-palette-cell`).on("click.stop",(()=>this.change(g))).css("background-color",g))}class Et{constructor(){this.el=ci("div",`${ee}-color-palette`),this.change=()=>{};const g=ci("table","").children(ci("tbody","").children(ci("tr",`${ee}-theme-color-placeholders`).children(...Ut.map((g=>Ot.call(this,g)))),...jt.map((g=>ci("tr",`${ee}-theme-colors`).children(...g.map((g=>Ot.call(this,g)))))),ci("tr",`${ee}-standard-colors`).children(...Qt.map((g=>Ot.call(this,g))))));this.el.child(g)}}class Pt extends Mt{constructor(g,I){const C=new Re(g).css("height","16px").css("border-bottom",`3px solid ${I}`),A=new Et;A.change=g=>{this.setTitle(g),this.change(g)},super(C,"auto",!1,"bottom-left",A.el)}setTitle(g){this.title.css("border-color",g),this.hide()}}const _t=[["thin",''],["medium",''],["thick",''],["dashed",''],["dotted",'']];class qt extends Mt{constructor(g){const I=new Re("line-type");let C=0;const A=_t.map(((I,i)=>ci("div",`${ee}-item state ${g===I[0]?"checked":""}`).on("click",(()=>{A[C].toggle("checked"),A[i].toggle("checked"),C=i,this.hide(),this.change(I)})).child(ci("div",`${ee}-line-type`).html(I[1]))));super(I,"auto",!1,"bottom-left",...A)}}function $t(...g){return ci("table","").child(ci("tbody","").children(...g))}function gl(g){return ci("td","").child(ci("div",`${ee}-border-palette-cell`).child(new Re(`border-${g}`)).on("click",(()=>{this.mode=g;const{mode:I,style:C,color:A}=this;this.change({mode:I,style:C,color:A})})))}class Il{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new Pt("line-color",this.color),this.ddColor.change=g=>{this.color=g},this.ddType=new qt(this.style),this.ddType.change=([g])=>{this.style=g},this.el=ci("div",`${ee}-border-palette`);const g=$t(ci("tr","").children(ci("td",`${ee}-border-palette-left`).child($t(ci("tr","").children(...["all","inside","horizontal","vertical","outside"].map((g=>gl.call(this,g)))),ci("tr","").children(...["left","top","right","bottom","none"].map((g=>gl.call(this,g)))))),ci("td",`${ee}-border-palette-right`).children(ci("div",`${ee}-toolbar-btn`).child(this.ddColor.el),ci("div",`${ee}-toolbar-btn`).child(this.ddType.el))));this.el.child(g)}}class Cl extends Mt{constructor(){const g=new Re("border-all"),I=new Il;I.change=g=>{this.change(g),this.hide()},super(g,"auto",!1,"bottom-left",I.el)}}class Al extends Ft{constructor(){super("border")}dropdown(){return new Cl}}class il extends ft{element(){return super.element().child(new Re(this.tag)).on("click",(()=>this.change(this.tag)))}setState(g){this.el.disabled(g)}}class el extends il{constructor(){super("clearformat")}}class tl extends Dt{constructor(){super("paintformat")}setState(){}}class ll extends Ft{constructor(g){super("color",void 0,g)}dropdown(){const{tag:g,value:I}=this;return new Pt(g,I)}}class sl extends Ft{constructor(g){super("bgcolor",void 0,g)}dropdown(){const{tag:g,value:I}=this;return new Pt(g,I)}}class ol extends Mt{constructor(){super("10","60px",!0,"bottom-left",...qe.map((g=>ci("div",`${ee}-item`).on("click",(()=>{this.setTitle(`${g.pt}`),this.change(g)})).child(`${g.pt}`))))}}let cl=class extends Ft{constructor(){super("font-size")}getValue(g){return g.pt}dropdown(){return new ol}};class dl extends Mt{constructor(){const g=_e.map((g=>ci("div",`${ee}-item`).on("click",(()=>{this.setTitle(g.title),this.change(g)})).child(g.title)));super(_e[0].title,"160px",!0,"bottom-left",...g)}}class al extends Ft{constructor(){super("font-name")}getValue(g){return g.key}dropdown(){return new dl}}class nl extends Mt{constructor(){let g=lt.slice(0);g.splice(2,0,{key:"divider"}),g.splice(8,0,{key:"divider"}),g=g.map((g=>{const I=ci("div",`${ee}-item`);return"divider"===g.key?I.addClass("divider"):(I.child(g.title()).on("click",(()=>{this.setTitle(g.title()),this.change(g)})),g.label&&I.child(ci("div","label").html(g.label))),I})),super("Normal","220px",!0,"bottom-left",...g)}setTitle(g){for(let I=0;Ici("div",`${ee}-item`).on("click",(()=>{this.hide(),this.change(g)})).child(g.key)));super(new Re("formula"),"180px",!0,"bottom-left",...g)}}class hl extends Ft{constructor(){super("formula")}getValue(g){return g.key}dropdown(){return new ml}}class Zl extends Dt{constructor(){super("freeze")}}class bl extends Dt{constructor(){super("merge")}setState(g,I){this.el.active(g).disabled(I)}}class Gl extends il{constructor(){super("redo","Ctrl+Y")}}class ul extends il{constructor(){super("undo","Ctrl+Z")}}class pl extends il{constructor(){super("print","Ctrl+P")}}class wl extends Dt{constructor(){super("textwrap")}}let Wl=class extends Mt{constructor(){const g=new Re("ellipsis"),I=ci("div",`${ee}-toolbar-more`);super(g,"auto",!1,"bottom-right",I),this.moreBtns=I,this.contentEl.css("max-width","420px")}};class Bl extends Ft{constructor(){super("more"),this.el.hide()}dropdown(){return new Wl}show(){this.el.show()}hide(){this.el.hide()}}function yl(){return ci("div",`${ee}-toolbar-divider`)}function Vl(){this.btns2=[],this.items.forEach((g=>{if(Array.isArray(g))g.forEach((({el:g})=>{const I=g.box(),{marginLeft:C,marginRight:A}=g.computedStyle();this.btns2.push([g,I.width+parseInt(C,10)+parseInt(A,10)])}));else{const I=g.box(),{marginLeft:C,marginRight:A}=g.computedStyle();this.btns2.push([g,I.width+parseInt(C,10)+parseInt(A,10)])}}))}function Xl(){const{el:g,btns:I,moreEl:C,btns2:A}=this,{moreBtns:i,contentEl:e}=C.dd;g.css("width",this.widthFn()-60+"px");const t=g.box();let l=160,s=12;const o=[],c=[];A.forEach((([g,I],C)=>{l+=I,C===A.length-1||l0?C.show():C.hide()}class Yl{constructor(g,I,C=!1){this.data=g,this.change=()=>{},this.widthFn=I,this.isHide=C;const A=g.defaultStyle();this.items=[[this.undoEl=new ul,this.redoEl=new Gl,new pl,this.paintformatEl=new tl,this.clearformatEl=new el],yl(),[this.formatEl=new rl],yl(),[this.fontEl=new al,this.fontSizeEl=new cl],yl(),[this.boldEl=new Lt,this.italicEl=new zt,this.underlineEl=new xt,this.strikeEl=new Tt,this.textColorEl=new ll(A.color)],yl(),[this.fillColorEl=new sl(A.bgcolor),this.borderEl=new Al,this.mergeEl=new bl],yl(),[this.alignEl=new Jt(A.align),this.valignEl=new kt(A.valign),this.textwrapEl=new wl],yl(),[this.freezeEl=new Zl,this.autofilterEl=new vt,this.formulaEl=new hl,this.moreEl=new Bl]],this.el=ci("div",`${ee}-toolbar`),this.btns=ci("div",`${ee}-toolbar-btns`),this.items.forEach((g=>{Array.isArray(g)?g.forEach((g=>{this.btns.child(g.el),g.change=(...g)=>{this.change(...g)}})):this.btns.child(g.el)})),this.el.child(this.btns),C?this.el.hide():(this.reset(),setTimeout((()=>{Vl.call(this),Xl.call(this)}),0),$i(window,"resize",(()=>{Xl.call(this)})))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(g){this[`${g}El`].click()}resetData(g){this.data=g,this.reset()}reset(){if(this.isHide)return;const{data:g}=this,I=g.getSelectedCellStyle();this.undoEl.setState(!g.canUndo()),this.redoEl.setState(!g.canRedo()),this.mergeEl.setState(g.canUnmerge(),!g.selector.multiple()),this.autofilterEl.setState(!g.canAutofilter());const{font:C,format:A}=I;this.formatEl.setState(A),this.fontEl.setState(C.name),this.fontSizeEl.setState(C.size),this.boldEl.setState(C.bold),this.italicEl.setState(C.italic),this.underlineEl.setState(I.underline),this.strikeEl.setState(I.strike),this.textColorEl.setState(I.color),this.fillColorEl.setState(I.bgcolor),this.alignEl.setState(I.align),this.valignEl.setState(I.valign),this.textwrapEl.setState(I.textwrap),this.freezeEl.setState(g.freezeIsActive())}}class Rl{constructor(g,I,C="600px"){this.title=g,this.el=ci("div",`${ee}-modal`).css("width",C).children(ci("div",`${ee}-modal-header`).children(new Re("close").on("click.stop",(()=>this.hide())),this.title),ci("div",`${ee}-modal-content`).children(...I)).hide()}show(){this.dimmer=ci("div",`${ee}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:g,height:I}=this.el.show().box(),{clientHeight:C,clientWidth:A}=document.documentElement;this.el.offset({left:(A-g)/2,top:(C-I)/3}),window.xkeydownEsc=g=>{27===g.keyCode&&this.hide()},$i(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),ge(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class Nl{constructor(g,I){this.vchange=()=>{},this.el=ci("div",`${ee}-form-input`),this.input=ci("input","").css("width",g).on("input",(g=>this.vchange(g))).attr("placeholder",I),this.el.child(this.input)}focus(){setTimeout((()=>{this.input.el.focus()}),10)}hint(g){this.input.attr("placeholder",g)}val(g){return this.input.val(g)}}class Hl{constructor(g,I,C,A=g=>g,i=()=>{}){this.key=g,this.getTitle=A,this.vchange=()=>{},this.el=ci("div",`${ee}-form-select`),this.suggest=new Ye(I.map((g=>({key:g,title:this.getTitle(g)}))),(g=>{this.itemClick(g.key),i(g.key),this.vchange(g.key)}),C,this.el),this.el.children(this.itemEl=ci("div","input-text").html(this.getTitle(g)),this.suggest.el).on("click",(()=>this.show()))}show(){this.suggest.search("")}itemClick(g){this.key=g,this.itemEl.html(this.getTitle(g))}val(g){return void 0!==g?(this.key=g,this.itemEl.html(this.getTitle(g)),this):this.key}}const Kl={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class fl{constructor(g,I,C,A){this.label="",this.rule=I,C&&(this.label=ci("label","label").css("width",`${A}px`).html(C)),this.tip=ci("div","tip").child("tip").hide(),this.input=g,this.input.vchange=()=>this.validate(),this.el=ci("div",`${ee}-form-field`).children(this.label,g.el,this.tip)}isShow(){return"none"!==this.el.css("display")}show(){this.el.show()}hide(){return this.el.hide(),this}val(g){return this.input.val(g)}hint(g){this.input.hint(g)}validate(){const{input:g,rule:I,tip:C,el:A}=this,i=g.val();if(I.required&&/^\s*$/.test(i))return C.html(Mi("validation.required")),A.addClass("error"),!1;if(I.type||I.pattern){if(!(I.pattern||Kl[I.type]).test(i))return C.html(Mi("validation.notMatch")),A.addClass("error"),!1}return A.removeClass("error"),!0}}class Fl extends Rl{constructor(){const g=new fl(new Hl("cell",["cell"],"100%",(g=>Mi(`dataValidation.modeType.${g}`))),{required:!0},`${Mi("dataValidation.range")}:`,100),I=new fl(new Nl("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),C=new fl(new Hl("list",["list","number","date","phone","email"],"100%",(g=>Mi(`dataValidation.type.${g}`)),(g=>this.criteriaSelected(g))),{required:!0},`${Mi("dataValidation.criteria")}:`,100),A=new fl(new Hl("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",(g=>Mi(`dataValidation.operator.${g}`)),(g=>this.criteriaOperatorSelected(g))),{required:!0}).hide(),i=new fl(new Nl("70px","10"),{required:!0}).hide(),e=new fl(new Nl("70px","100"),{required:!0,type:"number"}).hide(),t=new fl(new Nl("120px","a,b,c"),{required:!0}),l=new fl(new Nl("70px","10"),{required:!0,type:"number"}).hide();super(Mi("contextmenu.validation"),[ci("div",`${ee}-form-fields`).children(g.el,I.el),ci("div",`${ee}-form-fields`).children(C.el,A.el,i.el,e.el,l.el,t.el),ci("div",`${ee}-buttons`).children(new Te("cancel").on("click",(()=>this.btnClick("cancel"))),new Te("remove").on("click",(()=>this.btnClick("remove"))),new Te("save","primary").on("click",(()=>this.btnClick("save"))))]),this.mf=g,this.rf=I,this.cf=C,this.of=A,this.minvf=i,this.maxvf=e,this.vf=l,this.svf=t,this.change=()=>{}}showVf(g){const I="date"===g?"2018-11-12":"10",{vf:C}=this;C.input.hint(I),C.show()}criteriaSelected(g){const{of:I,minvf:C,maxvf:A,vf:i,svf:e}=this;"date"===g||"number"===g?(I.show(),C.rule.type=g,A.rule.type=g,"date"===g?(C.hint("2018-11-12"),A.hint("2019-11-12")):(C.hint("10"),A.hint("100")),C.show(),A.show(),i.hide(),e.hide()):("list"===g?e.show():e.hide(),i.hide(),I.hide(),C.hide(),A.hide())}criteriaOperatorSelected(g){if(!g)return;const{minvf:I,maxvf:C,vf:A}=this;if("be"===g||"nbe"===g)I.show(),C.show(),A.hide();else{const g=this.cf.val();A.rule.type=g,"date"===g?A.hint("2018-11-12"):A.hint("10"),A.show(),I.hide(),C.hide()}}btnClick(g){if("cancel"===g)this.hide();else if("remove"===g)this.change("remove"),this.hide();else if("save"===g){const g=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let t=0;tthis.itemClick(g)))}function Jl(g){const{filterbEl:I,filterValues:C}=this;I.html("");Object.keys(g).forEach(((A,i)=>{const e=g[A],t=C.includes(A)?"checked":"";I.child(ci("div",`${ee}-item state ${t}`).on("click.stop",(()=>this.filterClick(i,A))).children(""===A?Mi("filter.empty"):A,ci("div","label").html(`(${e})`)))}))}function kl(){const{filterhEl:g,filterValues:I,values:C}=this;g.html(`${I.length} / ${C.length}`),g.checked(I.length===C.length)}class Dl{constructor(){this.filterbEl=ci("div",`${ee}-body`),this.filterhEl=ci("div",`${ee}-header state`).on("click.stop",(()=>this.filterClick(0,"all"))),this.el=ci("div",`${ee}-sort-filter`).children(this.sortAscEl=Sl.call(this,"asc"),this.sortDescEl=Sl.call(this,"desc"),Ml("divider"),ci("div",`${ee}-filter`).children(this.filterhEl,this.filterbEl),ci("div",`${ee}-buttons`).children(new Te("cancel").on("click",(()=>this.btnClick("cancel"))),new Te("ok","primary").on("click",(()=>this.btnClick("ok"))))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(g){if("ok"===g){const{ci:g,sort:I,filterValues:C}=this;this.ok&&this.ok(g,I,"in",C)}this.hide()}itemClick(g){this.sort=g;const{sortAscEl:I,sortDescEl:C}=this;I.checked("asc"===g),C.checked("desc"===g)}filterClick(g,I){const{filterbEl:C,filterValues:A,values:i}=this,e=C.children();if("all"===I)e.length===A.length?(this.filterValues=[],e.forEach((g=>ci(g).checked(!1)))):(this.filterValues=Array.from(i),e.forEach((g=>ci(g).checked(!0))));else{ci(e[g]).toggle("checked")?A.push(I):A.splice(A.findIndex((g=>g===I)),1)}kl.call(this)}set(g,I,C,A){this.ci=g;const{sortAscEl:i,sortDescEl:e}=this;null!==A?(this.sort=A.order,i.checked(A.asc()),e.checked(A.desc())):(this.sortDesc=null,i.checked(!1),e.checked(!1)),this.values=Object.keys(I),this.filterValues=C?Array.from(C.value):Object.keys(I),Jl.call(this,I,C),kl.call(this)}setOffset(g){this.el.offset(g).show();let I=1;Ce(this.el,(()=>{I<=0&&this.hide(),I-=1}))}show(){this.el.show()}hide(){this.el.hide(),Ie(this.el)}}function vl(g,I){const C=ci("div",`${ee}-toast`),A=ci("div",`${ee}-dimmer active`);C.children(ci("div",`${ee}-toast-header`).children(new Re("close").on("click.stop",(()=>(document.body.removeChild(C.el),void document.body.removeChild(A.el)))),g),ci("div",`${ee}-toast-content`).html(I)),document.body.appendChild(C.el),document.body.appendChild(A.el);const{width:i,height:e}=C.box(),{clientHeight:t,clientWidth:l}=document.documentElement;C.offset({left:(l-i)/2,top:(t-e)/3})}function Ll(g,I){let C;return(...A)=>{const i=this,e=A;C||(C=setTimeout((()=>{C=null,g.apply(i,e)}),I))}}function zl(){const{data:g,verticalScrollbar:I,horizontalScrollbar:C}=this,{l:A,t:i,left:e,top:t,width:l,height:s}=g.getSelectedRect(),o=this.getTableOffset();if(Math.abs(e)+l>o.width)C.move({left:A+l-o.width});else{const I=g.freezeTotalWidth();eo.height)I.move({top:i+s-o.height-1});else{const C=g.freezeTotalHeight();t0&&(l-=1):"right"===I?(o!==l&&(l=o),l0&&(t-=1):"down"===I?(s!==t&&(t=s),ts.indexWidth&&C>l.height)return A.hide(),void i.hide();const o=e.box(),c=t.getCellRectByXY(g.offsetX,g.offsetY);c.ri>=0&&-1===c.ci?(c.width=s.indexWidth,A.show(c,{width:o.width}),l.isHide(c.ri-1)?A.showUnhide(c.ri):A.hideUnhide()):A.hide(),-1===c.ri&&c.ci>=0?(c.height=l.height,i.show(c,{height:o.height}),s.isHide(c.ci-1)?i.showUnhide(c.ci):i.hideUnhide()):i.hide()}function jl(g){const{verticalScrollbar:I,horizontalScrollbar:C,data:A}=this,{top:i}=I.scroll(),{left:e}=C.scroll(),{rows:t,cols:l}=A,{deltaY:s,deltaX:o}=g,c=(g,I)=>{let C=g,A=0;do{A=I(C),C+=1}while(A<=0);return A},d=g=>{if(g>0){const g=A.scroll.ri+1;if(gt.getHeight(g)));I.move({top:i+C-1})}}else{const g=A.scroll.ri-1;if(g>=0){const C=c(g,(g=>t.getHeight(g)));I.move({top:0===g?0:i-C})}}},a=Math.abs(s),n=Math.abs(o),r=Math.max(a,n);/Firefox/i.test(window.navigator.userAgent)&&Ll(d(g.detail),50),r===n&&Ll((g=>{if(g>0){const g=A.scroll.ci+1;if(gl.getWidth(g)));C.move({left:e+I-1})}}else{const g=A.scroll.ci-1;if(g>=0){const I=c(g,(g=>l.getWidth(g)));C.move({left:0===g?0:e-I})}}})(o),50),r===a&&Ll(d(s),50)}function Ql(g,I){const{verticalScrollbar:C,horizontalScrollbar:A}=this,{top:i}=C.scroll(),{left:e}=A.scroll();"left"===g||"right"===g?A.move({left:e-I}):"up"!==g&&"down"!==g||C.move({top:i-I})}function Ol(){const{data:g,verticalScrollbar:I}=this,{height:C}=this.getTableOffset(),A=g.exceptRowTotalHeight(0,-1);I.set(C,g.rows.totalHeight()-A)}function El(){const{data:g,horizontalScrollbar:I}=this,{width:C}=this.getTableOffset();g&&I.set(C,g.cols.totalWidth())}function Pl(){const{selector:g,data:I,editor:C}=this,[A,i]=I.freeze;if(A>0||i>0){const g=I.freezeTotalWidth(),A=I.freezeTotalHeight();C.setFreezeLengths(g,A)}g.resetAreaOffset()}function _l(){const{tableEl:g,overlayerEl:I,overlayerCEl:C,table:A,toolbar:i,selector:e,el:t}=this,l=this.getTableOffset(),s=this.getRect();g.attr(s),I.offset(s),C.offset(l),t.css("width",`${s.width}px`),Ol.call(this),El.call(this),Pl.call(this),A.render(),i.reset(),e.reset()}function ql(){const{data:g,selector:I}=this;g.clearClipboard(),I.hideClipboard()}function $l(){const{data:g,selector:I}=this;g.copy(),g.copyToSystemClipboard(),I.showClipboard()}function gs(){const{data:g,selector:I}=this;g.cut(),I.showClipboard()}function Is(g,I){const{data:C}=this;if("read"!==C.settings.mode)if(C.paste(g,(g=>vl("Tip",g))))_l.call(this);else if(I){const g=I.clipboardData.getData("text/plain");this.data.pasteFromText(g),_l.call(this)}}function Cs(){this.data.hideRowsOrCols(),_l.call(this)}function As(g,I){this.data.unhideRowsOrCols(g,I),_l.call(this)}function is(){const{data:g}=this;g.autofilter(),_l.call(this)}function es(){const{toolbar:g}=this;g.paintformatActive()&&(Is.call(this,"format"),ql.call(this),g.paintformatToggle())}function ts(g){const{selector:I,data:C,table:A,sortFilter:i}=this,{offsetX:e,offsetY:t}=g,l=g.target.className===`${ee}-selector-corner`,s=C.getCellRectByXY(e,t),{left:o,top:c,width:d,height:a}=s;let{ri:n,ci:r}=s;const{autoFilter:m}=C;if(m.includes(n,r)&&o+d-20C.rows.getCell(g,I)));return i.hide(),i.set(r,g,m.getFilter(r),m.getSort(r)),void i.setOffset({left:o,top:c+a+2})}g.shiftKey||(l?I.showAutofill(n,r):Tl.call(this,!1,n,r),Ae(window,(g=>{({ri:n,ci:r}=C.getCellRectByXY(g.offsetX,g.offsetY)),l?I.showAutofill(n,r):1!==g.buttons||g.shiftKey||Tl.call(this,!0,n,r,!0,!0)}),(()=>{l&&I.arange&&"read"!==C.settings.mode&&C.autofill(I.arange,"all",(g=>vl("Tip",g)))&&A.render(),I.hideAutofill(),es.call(this)}))),l||1!==g.buttons||g.shiftKey&&Tl.call(this,!0,n,r)}function ls(){const{editor:g,data:I}=this,C=I.getSelectedRect(),A=this.getTableOffset();let i="top";C.top>A.height/2&&(i="bottom"),g.setOffset(C,i)}function ss(){const{editor:g,data:I}=this;"read"!==I.settings.mode&&(ls.call(this),g.setCell(I.getSelectedCell(),I.getSelectedValidator()),ql.call(this))}function os(g){const{data:I,table:C,selector:A}=this;I.scrolly(g,(()=>{A.resetBRLAreaOffset(),ls.call(this),C.render()}))}function cs(g){const{data:I,table:C,selector:A}=this;I.scrollx(g,(()=>{A.resetBRTAreaOffset(),ls.call(this),C.render()}))}function ds(g,I){const{ri:C}=g,{table:A,selector:i,data:e}=this;e.rows.setHeight(C,I),A.render(),i.resetAreaOffset(),Ol.call(this),ls.call(this)}function as(g,I){const{ci:C}=g,{table:A,selector:i,data:e}=this;e.cols.setWidth(C,I),A.render(),i.resetAreaOffset(),El.call(this),ls.call(this)}function ns(g,I="finished"){const{data:C,table:A}=this;if("read"===C.settings.mode)return;C.setSelectedCellText(g,I);const{ri:i,ci:e}=C.selector;"finished"===I?A.render():this.trigger("cell-edited",g,i,e)}function rs(g){const{data:I}=this;"read"!==I.settings.mode&&("insert-row"===g?I.insert("row"):"delete-row"===g?I.delete("row"):"insert-column"===g?I.insert("column"):"delete-column"===g?I.delete("column"):"delete-cell"===g?I.deleteCell():"delete-cell-format"===g?I.deleteCell("format"):"delete-cell-text"===g?I.deleteCell("text"):"cell-printable"===g?I.setSelectedCellAttr("printable",!0):"cell-non-printable"===g?I.setSelectedCellAttr("printable",!1):"cell-editable"===g?I.setSelectedCellAttr("editable",!0):"cell-non-editable"===g&&I.setSelectedCellAttr("editable",!1),ql.call(this),_l.call(this))}function ms(g,I){const{data:C}=this;if("undo"===g)this.undo();else if("redo"===g)this.redo();else if("print"===g)this.print.preview();else if("paintformat"===g)!0===I?$l.call(this):ql.call(this);else if("clearformat"===g)rs.call(this,"delete-cell-format");else if("link"===g);else if("chart"===g);else if("autofilter"===g)is.call(this);else if("freeze"===g)if(I){const{ri:g,ci:I}=C.selector;this.freeze(g,I)}else this.freeze(0,0);else C.setSelectedCellAttr(g,I),"formula"!==g||C.selector.multiple()||ss.call(this),_l.call(this)}function hs(g,I,C,A){this.data.setAutoFilter(g,I,C,A),_l.call(this)}function Zs(){const{selector:g,overlayerEl:I,rowResizer:C,colResizer:A,verticalScrollbar:i,horizontalScrollbar:e,editor:t,contextMenu:l,toolbar:s,modalValidation:o,sortFilter:c}=this;I.on("mousemove",(g=>{Ul.call(this,g)})).on("mousedown",(g=>{t.clear(),l.hide(),2===g.buttons?(this.data.xyInSelectedRect(g.offsetX,g.offsetY)||ts.call(this,g),l.setPosition(g.offsetX,g.offsetY),g.stopPropagation()):2===g.detail?ss.call(this):ts.call(this,g)})).on("mousewheel.stop",(g=>{jl.call(this,g)})).on("mouseout",(g=>{const{offsetX:I,offsetY:i}=g;i<=0&&A.hide(),I<=0&&C.hide()})),g.inputChange=g=>{ns.call(this,g,"input"),ss.call(this)},function(g,{move:I,end:C}){let A=0,i=0;$i(g,"touchstart",(g=>{const{pageX:I,pageY:C}=g.touches[0];A=I,i=C})),$i(g,"touchmove",(g=>{if(!I)return;const{pageX:C,pageY:e}=g.changedTouches[0],t=C-A,l=e-i;(Math.abs(t)>10||Math.abs(l)>10)&&(ie(t,l,g,I),A=C,i=e),g.preventDefault()})),$i(g,"touchend",(g=>{if(!C)return;const{pageX:I,pageY:e}=g.changedTouches[0];ie(I-A,e-i,g,C)}))}(I.el,{move:(g,I)=>{Ql.call(this,g,I)}}),s.change=(g,I)=>ms.call(this,g,I),c.ok=(g,I,C,A)=>hs.call(this,g,I,C,A),C.finishedFn=(g,I)=>{ds.call(this,g,I)},A.finishedFn=(g,I)=>{as.call(this,g,I)},C.unhideFn=g=>{As.call(this,"row",g)},A.unhideFn=g=>{As.call(this,"col",g)},i.moveFn=(g,I)=>{os.call(this,g,I)},e.moveFn=(g,I)=>{cs.call(this,g,I)},t.change=(g,I)=>{ns.call(this,I,g)},o.change=(g,...I)=>{"save"===g?this.data.addValidation(...I):this.data.removeValidation()},l.itemClick=g=>{"validation"===g?o.setValue(this.data.getSelectedValidation()):"copy"===g?$l.call(this):"cut"===g?gs.call(this):"paste"===g?Is.call(this,"all"):"paste-value"===g?Is.call(this,"text"):"paste-format"===g?Is.call(this,"format"):"hide"===g?Cs.call(this):rs.call(this,g)},$i(window,"resize",(()=>{this.reload()})),$i(window,"click",(g=>{this.focusing=I.contains(g.target)})),$i(window,"paste",(g=>{this.focusing&&(Is.call(this,"all",g),g.preventDefault())})),$i(window,"keydown",(g=>{if(!this.focusing)return;const I=g.keyCode||g.which,{key:C,ctrlKey:A,shiftKey:i,metaKey:e}=g;if(A||e)switch(I){case 90:this.undo(),g.preventDefault();break;case 89:this.redo(),g.preventDefault();break;case 67:$l.call(this),g.preventDefault();break;case 88:gs.call(this),g.preventDefault();break;case 85:s.trigger("underline"),g.preventDefault();break;case 86:break;case 37:xl.call(this,i,"row-first"),g.preventDefault();break;case 38:xl.call(this,i,"col-first"),g.preventDefault();break;case 39:xl.call(this,i,"row-last"),g.preventDefault();break;case 40:xl.call(this,i,"col-last"),g.preventDefault();break;case 32:Tl.call(this,!1,-1,this.data.selector.ci,!1),g.preventDefault();break;case 66:s.trigger("bold");break;case 73:s.trigger("italic")}else{switch(I){case 32:i&&Tl.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:l.hide(),ql.call(this);break;case 37:xl.call(this,i,"left"),g.preventDefault();break;case 38:xl.call(this,i,"up"),g.preventDefault();break;case 39:xl.call(this,i,"right"),g.preventDefault();break;case 40:xl.call(this,i,"down"),g.preventDefault();break;case 9:t.clear(),xl.call(this,!1,i?"left":"right"),g.preventDefault();break;case 13:t.clear(),xl.call(this,!1,i?"up":"down"),g.preventDefault();break;case 8:rs.call(this,"delete-cell-text"),g.preventDefault()}"Delete"===C?(rs.call(this,"delete-cell-text"),g.preventDefault()):I>=65&&I<=90||I>=48&&I<=57||I>=96&&I<=105||"="===g.key?(ns.call(this,g.key,"input"),ss.call(this)):113===I&&ss.call(this)}}))}class bs{constructor(g,I){this.eventMap=function(){const g=new Map;function I(I,C){return g.has(I)&&(()=>{const A=g.get(I);return Array.isArray(A)&&A.push(C)||!1})()||g.set(I,[].concat(C))}function C(I,C){return g.has(I)&&(()=>{const A=g.get(I),i=A.indexOf(C);return i>=0&&A.splice(i,1)&&0===g.get(I).length&&g.delete(I)})()}return{get current(){return g},on:I,once:function(g,A){const i=(...I)=>{A.call(null,...I),C(g,i)};return I(g,i)},fire:function(I,C){return g.has(I)&&(()=>{const A=g.get(I);for(const g of A)g.call(null,...C)})()},removeListener:C,removeAllListeners:function(){g.clear()}}}();const{view:C,showToolbar:A,showContextmenu:i}=I.settings;this.el=ci("div",`${ee}-sheet`),this.toolbar=new Yl(I,C.width,!A),this.print=new Yt(I),g.children(this.toolbar.el,this.el,this.print.el),this.data=I,this.tableEl=ci("canvas",`${ee}-table`),this.rowResizer=new te(!1,I.rows.height),this.colResizer=new te(!0,I.cols.minWidth),this.verticalScrollbar=new le(!0),this.horizontalScrollbar=new le(!1),this.editor=new ze(At,(()=>this.getTableOffset()),I.rows.height),this.modalValidation=new Fl,this.contextMenu=new Kt((()=>this.getRect()),!i),this.selector=new We(I),this.overlayerCEl=ci("div",`${ee}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=ci("div",`${ee}-overlayer`).child(this.overlayerCEl),this.sortFilter=new Dl,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new pt(this.tableEl.el,I),Zs.call(this),_l.call(this),Tl.call(this,!1,0,0)}on(g,I){return this.eventMap.on(g,I),this}trigger(g,...I){const{eventMap:C}=this;C.fire(g,I)}resetData(g){this.editor.clear(),this.data=g,Ol.call(this),El.call(this),this.toolbar.resetData(g),this.print.resetData(g),this.selector.resetData(g),this.table.resetData(g)}loadData(g){return this.data.setData(g),_l.call(this),this}freeze(g,I){const{data:C}=this;return C.setFreeze(g,I),_l.call(this),this}undo(){this.data.undo(),_l.call(this)}redo(){this.data.redo(),_l.call(this)}reload(){return _l.call(this),this}getRect(){const{data:g}=this;return{width:g.viewWidth(),height:g.viewHeight()}}getTableOffset(){const{rows:g,cols:I}=this.data,{width:C,height:A}=this.getRect();return{width:C-I.indexWidth,height:A-g.height,left:I.indexWidth,top:g.height}}}class Gs extends Mt{constructor(g){super(new Re("ellipsis"),"auto",!1,"top-left"),this.contentClick=g}reset(g){const I=g.map(((g,I)=>ci("div",`${ee}-item`).css("width","150px").css("font-weight","normal").on("click",(()=>{this.contentClick(I),this.hide()})).child(g)));this.setContentChildren(...I)}setTitle(){}}const us=[{key:"delete",title:Si("contextmenu.deleteSheet")}];function ps(g){return ci("div",`${ee}-item`).child(g.title()).on("click",(()=>{this.itemClick(g.key),this.hide()}))}function ws(){return us.map((g=>ps.call(this,g)))}class Ws{constructor(){this.el=ci("div",`${ee}-contextmenu`).css("width","160px").children(...ws.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:g}=this;g.hide(),Ie(g)}setOffset(g){const{el:I}=this;I.offset(g),I.show(),Ce(I)}}class Bs{constructor(g=()=>{},I=()=>{},C=()=>{},A=()=>{}){this.swapFunc=I,this.updateFunc=A,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new Gs((g=>{this.clickSwap2(this.items[g])})),this.contextMenu=new Ws,this.contextMenu.itemClick=C,this.el=ci("div",`${ee}-bottombar`).children(this.contextMenu.el,this.menuEl=ci("ul",`${ee}-menu`).child(ci("li","").children(new Re("add").on("click",(()=>{g()})),ci("span","").child(this.moreEl))))}addItem(g,I){this.dataNames.push(g);const C=ci("li",I?"active":"").child(g);C.on("click",(()=>{this.clickSwap2(C)})).on("contextmenu",(g=>{const{offsetLeft:I,offsetHeight:A}=g.target;this.contextMenu.setOffset({left:I,bottom:A+1}),this.deleteEl=C})).on("dblclick",(()=>{const g=C.html(),I=new Nl("auto","");I.val(g),I.input.on("blur",(({target:I})=>{const{value:C}=I,A=this.dataNames.findIndex((I=>I===g));this.renameItem(A,C)})),C.html("").child(I.el),I.focus()})),I&&this.clickSwap(C),this.items.push(C),this.menuEl.child(C),this.moreEl.reset(this.dataNames)}renameItem(g,I){this.dataNames.splice(g,1,I),this.moreEl.reset(this.dataNames),this.items[g].html("").child(I),this.updateFunc(g,I)}clear(){this.items.forEach((g=>{this.menuEl.removeChild(g.el)})),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:g,deleteEl:I}=this;if(this.items.length>1){const C=this.items.findIndex((g=>g===I));if(this.items.splice(C,1),this.dataNames.splice(C,1),this.menuEl.removeChild(I.el),this.moreEl.reset(this.dataNames),g===I){const[g]=this.items;return this.activeEl=g,this.activeEl.toggle(),[C,0]}return[C,-1]}return[-1]}clickSwap2(g){const I=this.items.findIndex((I=>I===g));this.clickSwap(g),this.activeEl.toggle(),this.swapFunc(I)}clickSwap(g){null!==this.activeEl&&this.activeEl.toggle(),this.activeEl=g}}class ys{constructor(g,I={}){let C=g;this.options={showBottomBar:!0,...I},this.sheetIndex=1,this.datas=[],"string"==typeof g&&(C=document.querySelector(g)),this.bottombar=this.options.showBottomBar?new Bs((()=>{const g=this.addSheet();this.sheet.resetData(g)}),(g=>{const I=this.datas[g];this.sheet.resetData(I)}),(()=>{this.deleteSheet()}),((g,I)=>{this.datas[g].name=I})):null,this.data=this.addSheet();const A=ci("div",`${ee}`).on("contextmenu",(g=>g.preventDefault()));C.appendChild(A.el),this.sheet=new bs(A,this.data),null!==this.bottombar&&A.child(this.bottombar.el)}addSheet(g,I=!0){const C=g||`sheet${this.sheetIndex}`,A=new qi(C,this.options);return A.change=(...g)=>{this.sheet.trigger("change",...g)},this.datas.push(A),null!==this.bottombar&&this.bottombar.addItem(C,I),this.sheetIndex+=1,A}deleteSheet(){if(null===this.bottombar)return;const[g,I]=this.bottombar.deleteItem();g>=0&&(this.datas.splice(g,1),I>=0&&this.sheet.resetData(this.datas[I]))}loadData(g){const I=Array.isArray(g)?g:[g];if(null!==this.bottombar&&this.bottombar.clear(),this.datas=[],I.length>0)for(let C=0;Cg.getData()))}cellText(g,I,C,A=0){return this.datas[A].setCellText(g,I,C,"finished"),this}cell(g,I,C=0){return this.datas[C].getCell(g,I)}cellStyle(g,I,C=0){return this.datas[C].getCellStyle(g,I)}reRender(){return this.sheet.table.render(),this}on(g,I){return this.sheet.on(g,I),this}validate(){const{validations:g}=this.data;return g.errors.size<=0}change(g){return this.sheet.on("change",g),this}static locale(g,I){Ji(g,I)}}const Vs=(g,I={})=>new ys(g,I);"undefined"!=typeof window&&(window.x_spreadsheet=Vs,window.x_spreadsheet.locale=(g,I)=>Ji(g,I));var Xs={exports:{}};!function(g,I){g.exports=function(){function g(I,C,A){function i(t,l){if(!C[t]){if(!I[t]){if(!l&&oC)return oC(t);if(e)return e(t,!0);var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}var o=C[t]={exports:{}};I[t][0].call(o.exports,(function(g){return i(I[t][1][g]||g)}),o,o.exports,g,I,C,A)}return C[t].exports}for(var e=oC,t=0;t{const e=this.workbook.addWorksheet(I.sheetName),t=I.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],s=I.map||function(g){if(""===g)return null;const I=Number(g);if(!Number.isNaN(I)&&I!==1/0)return I;const C=t.reduce(((I,C)=>{if(I)return I;const A=l(g,C,!0);return A.isValid()?A:null}),null);if(C)return new Date(C.valueOf());const A=c[g];return void 0!==A?A:g},o=i.parse(I.parserOptions).on("data",(g=>{e.addRow(g.map(s))})).on("end",(()=>{o.emit("worksheet",e)}));o.on("worksheet",C).on("error",A),g.pipe(o)}))}createInputStream(){throw new Error("`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}write(g,I){return new Promise(((C,A)=>{I=I||{};const e=this.workbook.getWorksheet(I.sheetName||I.sheetId),t=i.format(I.formatterOptions);g.on("finish",(()=>{C()})),t.on("error",A),t.pipe(g);const{dateFormat:s,dateUTC:o}=I,c=I.map||(g=>{if(g){if(g.text||g.hyperlink)return g.hyperlink||g.text||"";if(g.formula||g.result)return g.result||"";if(g instanceof Date)return s?o?l.utc(g).format(s):l(g).format(s):o?l.utc(g).format():l(g).format();if(g.error)return g.error;if("object"==typeof g)return JSON.stringify(g)}return g}),d=void 0===I.includeEmptyRows||I.includeEmptyRows;let a=1;e&&e.eachRow(((g,I)=>{if(d)for(;a++2&&void 0!==arguments[2]?arguments[2]:0;if(this.worksheet=g,I)if("string"==typeof I){const g=A.decodeAddress(I);this.nativeCol=g.col+C,this.nativeColOff=0,this.nativeRow=g.row+C,this.nativeRowOff=0}else void 0!==I.nativeCol?(this.nativeCol=I.nativeCol||0,this.nativeColOff=I.nativeColOff||0,this.nativeRow=I.nativeRow||0,this.nativeRowOff=I.nativeRowOff||0):void 0!==I.col?(this.col=I.col+C,this.row=I.row+C):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);else this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0}static asInstance(g){return g instanceof i||null==g?g:new i(g)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(g){this.nativeCol=Math.floor(g),this.nativeColOff=Math.floor((g-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(g){this.nativeRow=Math.floor(g),this.nativeRowOff=Math.floor((g-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(1e4*this.worksheet.getColumn(this.nativeCol+1).width):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(1e4*this.worksheet.getRow(this.nativeRow+1).height):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(g){this.nativeCol=g.nativeCol,this.nativeColOff=g.nativeColOff,this.nativeRow=g.nativeRow,this.nativeRowOff=g.nativeRowOff}}I.exports=i},{"../utils/col-cache":19}],3:[function(g,I,C){const A=g("../utils/col-cache"),i=g("../utils/under-dash"),e=g("./enums"),{slideFormula:t}=g("../utils/shared-formula"),l=g("./note");class s{constructor(g,I,C){if(!g||!I)throw new Error("A Cell needs a Row");this._row=g,this._column=I,A.validateAddress(C),this._address=C,this._value=p.create(s.Types.Null,this),this.style=this._mergeStyle(g.style,I.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(g){this.style.numFmt=g}get font(){return this.style.font}set font(g){this.style.font=g}get alignment(){return this.style.alignment}set alignment(g){this.style.alignment=g}get border(){return this.style.border}set border(g){this.style.border=g}get fill(){return this.style.fill}set fill(g){this.style.fill=g}get protection(){return this.style.protection}set protection(g){this.style.protection=g}_mergeStyle(g,I,C){const A=g&&g.numFmt||I&&I.numFmt;A&&(C.numFmt=A);const i=g&&g.font||I&&I.font;i&&(C.font=i);const e=g&&g.alignment||I&&I.alignment;e&&(C.alignment=e);const t=g&&g.border||I&&I.border;t&&(C.border=t);const l=g&&g.fill||I&&I.fill;l&&(C.fill=l);const s=g&&g.protection||I&&I.protection;return s&&(C.protection=s),C}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===s.Types.Merge}merge(g,I){this._value.release(),this._value=p.create(s.Types.Merge,this,g),I||(this.style=g.style)}unmerge(){this.type===s.Types.Merge&&(this._value.release(),this._value=p.create(s.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}isMergedTo(g){return this._value.type===s.Types.Merge&&this._value.isMergedTo(g)}get master(){return this.type===s.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===s.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(g){this.type!==s.Types.Merge?(this._value.release(),this._value=p.create(p.getType(g),this,g)):this._value.master.value=g}get note(){return this._comment&&this._comment.note}set note(g){this._comment=new l(g)}get text(){return this._value.toString()}get html(){return i.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(g){this.type===s.Types.String&&(this._value=p.create(s.Types.Hyperlink,this,{text:this._value.value,hyperlink:g}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){const{worksheet:g}=this._row;return{sheetName:g.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(g){this.names=[g]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(g){const{definedNames:I}=this.workbook;I.removeAllNames(this.fullAddress),g.forEach((g=>{I.addEx(this.fullAddress,g)}))}addName(g){this.workbook.definedNames.addEx(this.fullAddress,g)}removeName(g){this.workbook.definedNames.removeEx(this.fullAddress,g)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(g){this._dataValidations.add(this.address,g)}get model(){const{model:g}=this._value;return g.style=this.style,this._comment&&(g.comment=this._comment.model),g}set model(g){this._value.release(),this._value=p.create(g.type,this),this._value.model=g,g.comment&&"note"===g.comment.type&&(this._comment=l.fromModel(g.comment)),g.style?this.style=g.style:this.style={}}}s.Types=e.ValueType;class o{constructor(g){this.model={address:g.address,type:s.Types.Null}}get value(){return null}set value(g){}get type(){return s.Types.Null}get effectiveType(){return s.Types.Null}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return""}release(){}toString(){return""}}class c{constructor(g,I){this.model={address:g.address,type:s.Types.Number,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Number}get effectiveType(){return s.Types.Number}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}class d{constructor(g,I){this.model={address:g.address,type:s.Types.String,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.String}get effectiveType(){return s.Types.String}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return`"${this.model.value.replace(/"/g,'""')}"`}release(){}toString(){return this.model.value}}class a{constructor(g,I){this.model={address:g.address,type:s.Types.String,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}toString(){return this.model.value.richText.map((g=>g.text)).join("")}get type(){return s.Types.RichText}get effectiveType(){return s.Types.RichText}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}class n{constructor(g,I){this.model={address:g.address,type:s.Types.Date,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Date}get effectiveType(){return s.Types.Date}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}}class r{constructor(g,I){this.model={address:g.address,type:s.Types.Hyperlink,text:I?I.text:void 0,hyperlink:I?I.hyperlink:void 0},I&&I.tooltip&&(this.model.tooltip=I.tooltip)}get value(){const g={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(g.tooltip=this.model.tooltip),g}set value(g){this.model={text:g.text,hyperlink:g.hyperlink},g.tooltip&&(this.model.tooltip=g.tooltip)}get text(){return this.model.text}set text(g){this.model.text=g}get hyperlink(){return this.model.hyperlink}set hyperlink(g){this.model.hyperlink=g}get type(){return s.Types.Hyperlink}get effectiveType(){return s.Types.Hyperlink}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.hyperlink}release(){}toString(){return this.model.text}}class m{constructor(g,I){this.model={address:g.address,type:s.Types.Merge,master:I?I.address:void 0},this._master=I,I&&I.addMergeRef()}get value(){return this._master.value}set value(g){g instanceof s?(this._master&&this._master.releaseMergeRef(),g.addMergeRef(),this._master=g):this._master.value=g}isMergedTo(g){return g===this._master}get master(){return this._master}get type(){return s.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return""}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}}class h{constructor(g,I){this.cell=g,this.model={address:g.address,type:s.Types.Formula,shareType:I?I.shareType:void 0,ref:I?I.ref:void 0,formula:I?I.formula:void 0,sharedFormula:I?I.sharedFormula:void 0,result:I?I.result:void 0}}_copyModel(g){const I={},C=C=>{const A=g[C];A&&(I[C]=A)};return C("formula"),C("result"),C("ref"),C("shareType"),C("sharedFormula"),I}get value(){return this._copyModel(this.model)}set value(g){this.model=this._copyModel(g)}validate(g){switch(p.getType(g)){case s.Types.Null:case s.Types.String:case s.Types.Number:case s.Types.Date:break;case s.Types.Hyperlink:case s.Types.Formula:default:throw new Error("Cannot process that type of result value")}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,"").match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()}set formula(g){this.model.formula=g}get formulaType(){return this.model.formula?e.FormulaType.Master:this.model.sharedFormula?e.FormulaType.Shared:e.FormulaType.None}get result(){return this.model.result}set result(g){this.model.result=g}get type(){return s.Types.Formula}get effectiveType(){const g=this.model.result;return null==g?e.ValueType.Null:g instanceof String||"string"==typeof g?e.ValueType.String:"number"==typeof g?e.ValueType.Number:g instanceof Date?e.ValueType.Date:g.text&&g.hyperlink?e.ValueType.Hyperlink:g.formula?e.ValueType.Formula:e.ValueType.Null}get address(){return this.model.address}set address(g){this.model.address=g}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){const{worksheet:g}=this.cell,I=g.findCell(this.model.sharedFormula);this._translatedFormula=I&&t(I.formula,I.address,this.model.address)}return this._translatedFormula}toCsvString(){return`${this.model.result||""}`}release(){}toString(){return this.model.result?this.model.result.toString():""}}class Z{constructor(g,I){this.model={address:g.address,type:s.Types.SharedString,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.SharedString}get effectiveType(){return s.Types.SharedString}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}class b{constructor(g,I){this.model={address:g.address,type:s.Types.Boolean,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Boolean}get effectiveType(){return s.Types.Boolean}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}}class G{constructor(g,I){this.model={address:g.address,type:s.Types.Error,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Error}get effectiveType(){return s.Types.Error}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}}class u{constructor(g,I){this.model={address:g.address,type:s.Types.String,value:JSON.stringify(I),rawValue:I}}get value(){return this.model.rawValue}set value(g){this.model.rawValue=g,this.model.value=JSON.stringify(g)}get type(){return s.Types.String}get effectiveType(){return s.Types.String}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}}const p={getType:g=>null==g?s.Types.Null:g instanceof String||"string"==typeof g?s.Types.String:"number"==typeof g?s.Types.Number:"boolean"==typeof g?s.Types.Boolean:g instanceof Date?s.Types.Date:g.text&&g.hyperlink?s.Types.Hyperlink:g.formula||g.sharedFormula?s.Types.Formula:g.richText?s.Types.RichText:g.sharedString?s.Types.SharedString:g.error?s.Types.Error:s.Types.JSON,types:[{t:s.Types.Null,f:o},{t:s.Types.Number,f:c},{t:s.Types.String,f:d},{t:s.Types.Date,f:n},{t:s.Types.Hyperlink,f:r},{t:s.Types.Formula,f:h},{t:s.Types.Merge,f:m},{t:s.Types.JSON,f:u},{t:s.Types.SharedString,f:Z},{t:s.Types.RichText,f:a},{t:s.Types.Boolean,f:b},{t:s.Types.Error,f:G}].reduce(((g,I)=>(g[I.t]=I.f,g)),[]),create(g,I,C){const A=this.types[g];if(!A)throw new Error(`Could not create Value of type ${g}`);return new A(I,C)}};I.exports=s},{"../utils/col-cache":19,"../utils/shared-formula":23,"../utils/under-dash":26,"./enums":7,"./note":9}],4:[function(g,I,C){const A=g("../utils/under-dash"),i=g("./enums"),e=g("../utils/col-cache"),t=9;class l{constructor(g,I,C){this._worksheet=g,this._number=I,!1!==C&&(this.defn=C)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return e.n2l(this._number)}get isCustomWidth(){return void 0!==this.width&&this.width!==t}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}}set defn(g){g?(this.key=g.key,this.width=void 0!==g.width?g.width:t,this.outlineLevel=g.outlineLevel,g.style?this.style=g.style:this.style={},this.header=g.header,this._hidden=!!g.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}get headers(){return this._header&&this._header instanceof Array?this._header:[this._header]}get header(){return this._header}set header(g){void 0!==g?(this._header=g,this.headers.forEach(((g,I)=>{this._worksheet.getCell(I+1,this.number).value=g}))):this._header=void 0}get key(){return this._key}set key(g){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=g,g&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(g){this._hidden=g}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(g){this._outlineLevel=g}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(g){return this.width===g.width&&this.hidden===g.hidden&&this.outlineLevel===g.outlineLevel&&A.isEqual(this.style,g.style)}get isDefault(){if(this.isCustomWidth)return!1;if(this.hidden)return!1;if(this.outlineLevel)return!1;const g=this.style;return!g||!(g.font||g.numFmt||g.alignment||g.border||g.fill||g.protection)}get headerCount(){return this.headers.length}eachCell(g,I){const C=this.number;I||(I=g,g=null),this._worksheet.eachRow(g,((g,A)=>{I(g.getCell(C),A)}))}get values(){const g=[];return this.eachCell(((I,C)=>{I&&I.type!==i.ValueType.Null&&(g[C]=I.value)})),g}set values(g){if(!g)return;const I=this.number;let C=0;g.hasOwnProperty("0")&&(C=1),g.forEach(((g,A)=>{this._worksheet.getCell(A+C,I).value=g}))}_applyStyle(g,I){return this.style[g]=I,this.eachCell((C=>{C[g]=I})),I}get numFmt(){return this.style.numFmt}set numFmt(g){this._applyStyle("numFmt",g)}get font(){return this.style.font}set font(g){this._applyStyle("font",g)}get alignment(){return this.style.alignment}set alignment(g){this._applyStyle("alignment",g)}get protection(){return this.style.protection}set protection(g){this._applyStyle("protection",g)}get border(){return this.style.border}set border(g){this._applyStyle("border",g)}get fill(){return this.style.fill}set fill(g){this._applyStyle("fill",g)}static toModel(g){const I=[];let C=null;return g&&g.forEach(((g,A)=>{g.isDefault?C&&(C=null):C&&g.equivalentTo(C)?C.max=A+1:(C={min:A+1,max:A+1,width:void 0!==g.width?g.width:t,style:g.style,isCustomWidth:g.isCustomWidth,hidden:g.hidden,outlineLevel:g.outlineLevel,collapsed:g.collapsed},I.push(C))})),I.length?I:void 0}static fromModel(g,I){const C=[];let A=1,i=0;for(I=(I=I||[]).sort((function(g,I){return g.min-I.min}));i{I.removeCellEx(g)}))}forEach(g){A.each(this.matrixMap,((I,C)=>{I.forEach((I=>{g(C,I)}))}))}getNames(g){return this.getNamesEx(i.decodeEx(g))}getNamesEx(g){return A.map(this.matrixMap,((I,C)=>I.findCellEx(g)&&C)).filter(Boolean)}_explore(g,I){I.mark=!1;const{sheetName:C}=I,A=new t(I.row,I.col,I.row,I.col,C);let i,e;function l(i,e){const t=g.findCellAt(C,i,I.col);return!(!t||!t.mark||(A[e]=i,t.mark=!1,0))}for(e=I.row-1;l(e,"top");e--);for(e=I.row+1;l(e,"bottom");e++);function s(I,i){const t=[];for(e=A.top;e<=A.bottom;e++){const A=g.findCellAt(C,e,I);if(!A||!A.mark)return!1;t.push(A)}A[i]=I;for(let g=0;g{g.mark=!0})),{name:g,ranges:I.map((g=>g.mark&&this._explore(I,g))).filter(Boolean).map((g=>g.$shortRange))}):{name:g,ranges:[]}}normaliseMatrix(g,I){g.forEachInSheet(I,((g,I,C)=>{g&&(g.row===I&&g.col===C||(g.row=I,g.col=C,g.address=i.n2l(C)+I))}))}spliceRows(g,I,C,i){A.each(this.matrixMap,(A=>{A.spliceRows(g,I,C,i),this.normaliseMatrix(A,g)}))}spliceColumns(g,I,C,i){A.each(this.matrixMap,(A=>{A.spliceColumns(g,I,C,i),this.normaliseMatrix(A,g)}))}get model(){return A.map(this.matrixMap,((g,I)=>this.getRanges(I,g))).filter((g=>g.ranges.length))}set model(g){const I=this.matrixMap={};g.forEach((g=>{const C=I[g.name]=new e;g.ranges.forEach((g=>{l.test(g.split("!").pop()||"")&&C.addCell(g)}))}))}}I.exports=s},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":26,"./range":10}],7:[function(g,I,C){I.exports={ValueType:{Null:0,Merge:1,Number:2,String:3,Date:4,Hyperlink:5,Formula:6,SharedString:7,RichText:8,Boolean:9,Error:10},FormulaType:{None:0,Master:1,Shared:2},RelationshipType:{None:0,OfficeDocument:1,Worksheet:2,CalcChain:3,SharedStrings:4,Styles:5,Theme:6,Hyperlink:7},DocumentType:{Xlsx:1},ReadingOrder:{LeftToRight:1,RightToLeft:2},ErrorValue:{NotApplicable:"#N/A",Ref:"#REF!",Name:"#NAME?",DivZero:"#DIV/0!",Null:"#NULL!",Value:"#VALUE!",Num:"#NUM!"}}},{}],8:[function(g,I,C){const A=g("../utils/col-cache"),i=g("./anchor");class e{constructor(g,I){this.worksheet=g,this.model=I}get model(){switch(this.type){case"background":return{type:this.type,imageId:this.imageId};case"image":return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw new Error("Invalid Image Type")}}set model(g){let{type:I,imageId:C,range:e,hyperlinks:t}=g;if(this.type=I,this.imageId=C,"image"===I)if("string"==typeof e){const g=A.decode(e);this.range={tl:new i(this.worksheet,{col:g.left,row:g.top},-1),br:new i(this.worksheet,{col:g.right,row:g.bottom},0),editAs:"oneCell"}}else this.range={tl:new i(this.worksheet,e.tl,0),br:e.br&&new i(this.worksheet,e.br,0),ext:e.ext,editAs:e.editAs,hyperlinks:t||e.hyperlinks}}}I.exports=e},{"../utils/col-cache":19,"./anchor":2}],9:[function(g,I,C){const A=g("../utils/under-dash");class i{constructor(g){this.note=g}get model(){let g=null;return g="string"==typeof this.note?{type:"note",note:{texts:[{text:this.note}]}}:{type:"note",note:this.note},A.deepMerge({},i.DEFAULT_CONFIGS,g)}set model(g){const{note:I}=g,{texts:C}=I;1===C.length&&1===Object.keys(C[0]).length?this.note=C[0].text:this.note=I}static fromModel(g){const I=new i;return I.model=g,I}}i.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},I.exports=i},{"../utils/under-dash":26}],10:[function(g,I,C){const A=g("../utils/col-cache");class i{constructor(){this.decode(arguments)}setTLBR(g,I,C,i,e){if(arguments.length<4){const i=A.decodeAddress(g),t=A.decodeAddress(I);this.model={top:Math.min(i.row,t.row),left:Math.min(i.col,t.col),bottom:Math.max(i.row,t.row),right:Math.max(i.col,t.col),sheetName:C},this.setTLBR(i.row,i.col,t.row,t.col,e)}else this.model={top:Math.min(g,C),left:Math.min(I,i),bottom:Math.max(g,C),right:Math.max(I,i),sheetName:e}}decode(g){switch(g.length){case 5:this.setTLBR(g[0],g[1],g[2],g[3],g[4]);break;case 4:this.setTLBR(g[0],g[1],g[2],g[3]);break;case 3:this.setTLBR(g[0],g[1],g[2]);break;case 2:this.setTLBR(g[0],g[1]);break;case 1:{const I=g[0];if(I instanceof i)this.model={top:I.model.top,left:I.model.left,bottom:I.model.bottom,right:I.model.right,sheetName:I.sheetName};else if(I instanceof Array)this.decode(I);else if(I.top&&I.left&&I.bottom&&I.right)this.model={top:I.top,left:I.left,bottom:I.bottom,right:I.right,sheetName:I.sheetName};else{const g=A.decodeEx(I);g.top?this.model={top:g.top,left:g.left,bottom:g.bottom,right:g.right,sheetName:g.sheetName}:this.model={top:g.row,left:g.col,bottom:g.row,right:g.col,sheetName:g.sheetName}}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Error(`Invalid number of arguments to _getDimensions() - ${g.length}`)}}get top(){return this.model.top||1}set top(g){this.model.top=g}get left(){return this.model.left||1}set left(g){this.model.left=g}get bottom(){return this.model.bottom||1}set bottom(g){this.model.bottom=g}get right(){return this.model.right||1}set right(g){this.model.right=g}get sheetName(){return this.model.sheetName}set sheetName(g){this.model.sheetName=g}get _serialisedSheetName(){const{sheetName:g}=this.model;return g?/^[a-zA-Z0-9]*$/.test(g)?`${g}!`:`'${g}'!`:""}expand(g,I,C,A){(!this.model.top||gthis.bottom)&&(this.bottom=C),(!this.model.right||A>this.right)&&(this.right=A)}expandRow(g){if(g){const{dimensions:I,number:C}=g;I&&this.expand(C,I.min,C,I.max)}}expandToAddress(g){const I=A.decodeEx(g);this.expand(I.row,I.col,I.row,I.col)}get tl(){return A.n2l(this.left)+this.top}get $t$l(){return`$${A.n2l(this.left)}$${this.top}`}get br(){return A.n2l(this.right)+this.bottom}get $b$r(){return`$${A.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(g){return!(g.sheetName&&this.sheetName&&g.sheetName!==this.sheetName||g.bottomthis.bottom||g.rightthis.right)}contains(g){const I=A.decodeEx(g);return this.containsEx(I)}containsEx(g){return(!g.sheetName||!this.sheetName||g.sheetName===this.sheetName)&&g.row>=this.top&&g.row<=this.bottom&&g.col>=this.left&&g.col<=this.right}forEachAddress(g){for(let I=this.left;I<=this.right;I++)for(let C=this.top;C<=this.bottom;C++)g(A.encodeAddress(C,I),C,I)}}I.exports=i},{"../utils/col-cache":19}],11:[function(g,I,C){const A=g("../utils/under-dash"),i=g("./enums"),e=g("../utils/col-cache"),t=g("./cell");class l{constructor(g,I){this._worksheet=g,this._number=I,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(g){return this._cells[g-1]}getCellEx(g){let I=this._cells[g.col-1];if(!I){const C=this._worksheet.getColumn(g.col);I=new t(this,C,g.address),this._cells[g.col-1]=I}return I}getCell(g){if("string"==typeof g){const I=this._worksheet.getColumnKey(g);g=I?I.number:e.l2n(g)}return this._cells[g-1]||this.getCellEx({address:e.encodeAddress(this._number,g),row:this._number,col:g})}splice(g,I){const C=g+I;for(var A=arguments.length,i=new Array(A>2?A-2:0),e=2;e0)for(s=l;s>=C;s--)o=this._cells[s-1],o?(c=this.getCell(s+t),c.value=o.value,c.style=o.style,c._comment=o._comment):this._cells[s+t-1]=void 0;for(s=0;s{g&&g.type!==i.ValueType.Null&&I(g,C+1)}))}addPageBreak(g,I){const C=this._worksheet,A=Math.max(0,g-1)||0,i=Math.max(0,I-1)||16838,e={id:this._number,max:i,man:1};A&&(e.min=A),C.rowBreaks.push(e)}get values(){const g=[];return this._cells.forEach((I=>{I&&I.type!==i.ValueType.Null&&(g[I.col]=I.value)})),g}set values(g){if(this._cells=[],g)if(g instanceof Array){let I=0;g.hasOwnProperty("0")&&(I=1),g.forEach(((g,C)=>{void 0!==g&&(this.getCellEx({address:e.encodeAddress(this._number,C+I),row:this._number,col:C+I}).value=g)}))}else this._worksheet.eachColumnKey(((I,C)=>{void 0!==g[C]&&(this.getCellEx({address:e.encodeAddress(this._number,I.number),row:this._number,col:I.number}).value=g[C])}))}get hasValues(){return A.some(this._cells,(g=>g&&g.type!==i.ValueType.Null))}get cellCount(){return this._cells.length}get actualCellCount(){let g=0;return this.eachCell((()=>{g++})),g}get dimensions(){let g=0,I=0;return this._cells.forEach((C=>{C&&C.type!==i.ValueType.Null&&((!g||g>C.col)&&(g=C.col),I0?{min:g,max:I}:null}_applyStyle(g,I){return this.style[g]=I,this._cells.forEach((C=>{C&&(C[g]=I)})),I}get numFmt(){return this.style.numFmt}set numFmt(g){this._applyStyle("numFmt",g)}get font(){return this.style.font}set font(g){this._applyStyle("font",g)}get alignment(){return this.style.alignment}set alignment(g){this._applyStyle("alignment",g)}get protection(){return this.style.protection}set protection(g){this._applyStyle("protection",g)}get border(){return this.style.border}set border(g){this._applyStyle("border",g)}get fill(){return this.style.fill}set fill(g){this._applyStyle("fill",g)}get hidden(){return!!this._hidden}set hidden(g){this._hidden=g}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(g){this._outlineLevel=g}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){const g=[];let I=0,C=0;return this._cells.forEach((A=>{if(A){const i=A.model;i&&((!I||I>A.col)&&(I=A.col),C{switch(g.type){case t.Types.Merge:break;default:{let C;if(g.address)C=e.decodeAddress(g.address);else if(I){const{row:g}=I,A=I.col+1;C={row:g,col:A,address:e.encodeAddress(g,A),$col$row:`$${e.n2l(A)}$${g}`}}I=C,this.getCellEx(C).model=g;break}}})),g.height?this.height=g.height:delete this.height,this.hidden=g.hidden,this.outlineLevel=g.outlineLevel||0,this.style=g.style&&JSON.parse(JSON.stringify(g.style))||{}}}I.exports=l},{"../utils/col-cache":19,"../utils/under-dash":26,"./cell":3,"./enums":7}],12:[function(g,I,C){const A=g("../utils/col-cache");class i{constructor(g,I,C){this.table=g,this.column=I,this.index=C}_set(g,I){this.table.cacheState(),this.column[g]=I}get name(){return this.column.name}set name(g){this._set("name",g)}get filterButton(){return this.column.filterButton}set filterButton(g){this.column.filterButton=g}get style(){return this.column.style}set style(g){this.column.style=g}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(g){this._set("totalsRowLabel",g)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(g){this._set("totalsRowFunction",g)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(g){this._set("totalsRowResult",g)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(g){this._set("totalsRowFormula",g)}}class e{constructor(g,I){this.worksheet=g,I&&(this.table=I,this.validate(),this.store())}getFormula(g){switch(g.totalsRowFunction){case"none":return null;case"average":return`SUBTOTAL(101,${this.table.name}[${g.name}])`;case"countNums":return`SUBTOTAL(102,${this.table.name}[${g.name}])`;case"count":return`SUBTOTAL(103,${this.table.name}[${g.name}])`;case"max":return`SUBTOTAL(104,${this.table.name}[${g.name}])`;case"min":return`SUBTOTAL(105,${this.table.name}[${g.name}])`;case"stdDev":return`SUBTOTAL(106,${this.table.name}[${g.name}])`;case"var":return`SUBTOTAL(107,${this.table.name}[${g.name}])`;case"sum":return`SUBTOTAL(109,${this.table.name}[${g.name}])`;case"custom":return g.totalsRowFormula;default:throw new Error(`Invalid Totals Row Function: ${g.totalsRowFunction}`)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){const{table:g}=this,I=(g,I,C)=>{void 0===g[I]&&(g[I]=C)};I(g,"headerRow",!0),I(g,"totalsRow",!1),I(g,"style",{}),I(g.style,"theme","TableStyleMedium2"),I(g.style,"showFirstColumn",!1),I(g.style,"showLastColumn",!1),I(g.style,"showRowStripes",!1),I(g.style,"showColumnStripes",!1);const C=(g,I)=>{if(!g)throw new Error(I)};C(g.ref,"Table must have ref"),C(g.columns,"Table must have column definitions"),C(g.rows,"Table must have row definitions"),g.tl=A.decodeAddress(g.ref);const{row:i,col:e}=g.tl;C(i>0,"Table must be on valid row"),C(e>0,"Table must be on valid col");const{width:t,filterHeight:l,tableHeight:s}=this;g.autoFilterRef=A.encode(i,e,i+l-1,e+t-1),g.tableRef=A.encode(i,e,i+s-1,e+t-1),g.columns.forEach(((g,A)=>{C(g.name,`Column ${A} must have a name`),0===A?I(g,"totalsRowLabel","Total"):(I(g,"totalsRowFunction","none"),g.totalsRowFormula=this.getFormula(g))}))}store(){const g=(g,I)=>{I&&Object.keys(I).forEach((C=>{g[C]=I[C]}))},{worksheet:I,table:C}=this,{row:A,col:i}=C.tl;let e=0;if(C.headerRow){const t=I.getRow(A+e++);C.columns.forEach(((I,C)=>{const{style:A,name:e}=I,l=t.getCell(i+C);l.value=e,g(l,A)}))}if(C.rows.forEach((t=>{const l=I.getRow(A+e++);t.forEach(((I,A)=>{const e=l.getCell(i+A);e.value=I,g(e,C.columns[A].style)}))})),C.totalsRow){const t=I.getRow(A+e++);C.columns.forEach(((I,C)=>{const A=t.getCell(i+C);if(0===C)A.value=I.totalsRowLabel;else{const g=this.getFormula(I);A.value=g?{formula:I.totalsRowFormula,result:I.totalsRowResult}:null}g(A,I.style)}))}}load(g){const{table:I}=this,{row:C,col:A}=I.tl;let i=0;if(I.headerRow){const e=g.getRow(C+i++);I.columns.forEach(((g,I)=>{e.getCell(A+I).value=g.name}))}if(I.rows.forEach((I=>{const e=g.getRow(C+i++);I.forEach(((g,I)=>{e.getCell(A+I).value=g}))})),I.totalsRow){const e=g.getRow(C+i++);I.columns.forEach(((g,I)=>{const C=e.getCell(A+I);0===I?C.value=g.totalsRowLabel:this.getFormula(g)&&(C.value={formula:g.totalsRowFormula,result:g.totalsRowResult})}))}}get model(){return this.table}set model(g){this.table=g}cacheState(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}commit(){if(!this._cache)return;this.validate();const g=A.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let I=0;I1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.rows.splice(g,I)}getColumn(g){const I=this.table.columns[g];return new i(this,I,g)}addColumn(g,I,C){this.cacheState(),void 0===C?(this.table.columns.push(g),this.table.rows.forEach(((g,C)=>{g.push(I[C])}))):(this.table.columns.splice(C,0,g),this.table.rows.forEach(((g,A)=>{g.splice(C,0,I[A])})))}removeColumns(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.columns.splice(g,I),this.table.rows.forEach((C=>{C.splice(g,I)}))}_assign(g,I,C){this.cacheState(),g[I]=C}get ref(){return this.table.ref}set ref(g){this._assign(this.table,"ref",g)}get name(){return this.table.name}set name(g){this.table.name=g}get displayName(){return this.table.displyName||this.table.name}set displayNamename(g){this.table.displayName=g}get headerRow(){return this.table.headerRow}set headerRow(g){this._assign(this.table,"headerRow",g)}get totalsRow(){return this.table.totalsRow}set totalsRow(g){this._assign(this.table,"totalsRow",g)}get theme(){return this.table.style.name}set theme(g){this.table.style.name=g}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(g){this.table.style.showFirstColumn=g}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(g){this.table.style.showLastColumn=g}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(g){this.table.style.showRowStripes=g}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(g){this.table.style.showColumnStripes=g}}I.exports=e},{"../utils/col-cache":19}],13:[function(g,I,C){const A=g("./worksheet"),i=g("./defined-names"),e=g("../xlsx/xlsx"),t=g("../csv/csv");class l{constructor(){this.category="",this.company="",this.created=new Date,this.description="",this.keywords="",this.manager="",this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject="",this.title="",this.views=[],this.media=[],this._definedNames=new i}get xlsx(){return this._xlsx||(this._xlsx=new e(this)),this._xlsx}get csv(){return this._csv||(this._csv=new t(this)),this._csv}get nextId(){for(let g=1;g(I&&I.orderNo)>g?I.orderNo:g),0),e=Object.assign({},I,{id:C,name:g,orderNo:i+1,workbook:this}),t=new A(e);return this._worksheets[C]=t,t}removeWorksheetEx(g){delete this._worksheets[g.id]}removeWorksheet(g){const I=this.getWorksheet(g);I&&I.destroy()}getWorksheet(g){return void 0===g?this._worksheets.find(Boolean):"number"==typeof g?this._worksheets[g]:"string"==typeof g?this._worksheets.find((I=>I&&I.name===g)):void 0}get worksheets(){return this._worksheets.slice(1).sort(((g,I)=>g.orderNo-I.orderNo)).filter(Boolean)}eachSheet(g){this.worksheets.forEach((I=>{g(I,I.id)}))}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(g){const I=this.media.length;return this.media.push(Object.assign({},g,{type:"image"})),I}getImage(g){return this.media[g]}get model(){return{creator:this.creator||"Unknown",lastModifiedBy:this.lastModifiedBy||"Unknown",lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map((g=>g.model)),sheets:this.worksheets.map((g=>g.model)).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,calcProperties:this.calcProperties}}set model(g){this.creator=g.creator,this.lastModifiedBy=g.lastModifiedBy,this.lastPrinted=g.lastPrinted,this.created=g.created,this.modified=g.modified,this.company=g.company,this.manager=g.manager,this.title=g.title,this.subject=g.subject,this.keywords=g.keywords,this.category=g.category,this.description=g.description,this.language=g.language,this.revision=g.revision,this.contentStatus=g.contentStatus,this.properties=g.properties,this.calcProperties=g.calcProperties,this._worksheets=[],g.worksheets.forEach((I=>{const{id:C,name:i,state:e}=I,t=g.sheets&&g.sheets.findIndex((g=>g.id===C));(this._worksheets[C]=new A({id:C,name:i,orderNo:t,state:e,workbook:this})).model=I})),this._definedNames.model=g.definedNames,this.views=g.views,this._themes=g.themes,this.media=g.media||[]}}I.exports=l},{"../csv/csv":1,"../xlsx/xlsx":144,"./defined-names":6,"./worksheet":14}],14:[function(g,I,C){const A=g("../utils/under-dash"),i=g("../utils/col-cache"),e=g("./range"),t=g("./row"),l=g("./column"),s=g("./enums"),o=g("./image"),c=g("./table"),d=g("./data-validations"),a=g("../utils/encryptor"),{copyStyle:n}=g("../utils/copy-style");class r{constructor(g){g=g||{},this._workbook=g.workbook,this.id=g.id,this.orderNo=g.orderNo,this.name=g.name,this.state=g.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},g.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!(!g.pageSetup||!g.pageSetup.fitToWidth&&!g.pageSetup.fitToHeight||g.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},g.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},g.headerFooter),this.dataValidations=new d,this.views=g.views||[],this.autoFilter=g.autoFilter||null,this._media=[],this.sheetProtection=null,this.tables={},this.conditionalFormattings=[]}get name(){return this._name}set name(g){if(void 0===g&&(g=`sheet${this.id}`),this._name!==g){if("string"!=typeof g)throw new Error("The name has to be a string.");if(""===g)throw new Error("The name can't be empty.");if("History"===g)throw new Error('The name "History" is protected. Please use a different name.');if(/[*?:/\\[\]]/.test(g))throw new Error(`Worksheet name ${g} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(g))throw new Error(`The first or last character of worksheet name cannot be a single quotation mark: ${g}`);if(g&&g.length>31&&(console.warn(`Worksheet name ${g} exceeds 31 chars. This will be truncated`),g=g.substring(0,31)),this._workbook._worksheets.find((I=>I&&I.name.toLowerCase()===g.toLowerCase())))throw new Error(`Worksheet name already exists: ${g}`);this._name=g}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){const g=new e;return this._rows.forEach((I=>{if(I){const C=I.dimensions;C&&g.expand(I.number,C.min,I.number,C.max)}})),g}get columns(){return this._columns}set columns(g){this._headerRowCount=g.reduce(((g,I)=>{const C=(I.header?1:I.headers&&I.headers.length)||0;return Math.max(g,C)}),0);let I=1;const C=this._columns=[];g.forEach((g=>{const A=new l(this,I++,!1);C.push(A),A.defn=g}))}getColumnKey(g){return this._keys[g]}setColumnKey(g,I){this._keys[g]=I}deleteColumnKey(g){delete this._keys[g]}eachColumnKey(g){A.each(this._keys,g)}getColumn(g){if("string"==typeof g){const I=this._keys[g];if(I)return I;g=i.l2n(g)}if(this._columns||(this._columns=[]),g>this._columns.length){let I=this._columns.length+1;for(;I<=g;)this._columns.push(new l(this,I++))}return this._columns[g-1]}spliceColumns(g,I){const C=this._rows.length;for(var A=arguments.length,i=new Array(A>2?A-2:0),e=2;e0)for(let o=0;o{C.push(g[o]||null)}));const A=this.getRow(o+1);A.splice.apply(A,C)}else this._rows.forEach((C=>{C&&C.splice(g,I)}));const t=i.length-I,l=g+I,s=this._columns.length;if(t<0)for(let o=g+i.length;o<=s;o++)this.getColumn(o).defn=this.getColumn(o-t).defn;else if(t>0)for(let o=s;o>=l;o--)this.getColumn(o+t).defn=this.getColumn(o).defn;for(let o=g;o{g=Math.max(g,I.cellCount)})),g}get actualColumnCount(){const g=[];let I=0;return this.eachRow((C=>{C.eachCell((C=>{let{col:A}=C;g[A]||(g[A]=!0,I++)}))})),I}_commitRow(){}get _lastRowNumber(){const g=this._rows;let I=g.length;for(;I>0&&void 0===g[I-1];)I--;return I}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(g){return this._rows[g-1]}findRows(g,I){return this._rows.slice(g-1,g-1+I)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let g=0;return this.eachRow((()=>{g++})),g}getRow(g){let I=this._rows[g-1];return I||(I=this._rows[g-1]=new t(this,g)),I}getRows(g,I){if(I<1)return;const C=[];for(let A=g;A1&&void 0!==arguments[1]?arguments[1]:"n";const C=this._nextRow,A=this.getRow(C);return A.values=g,this._setStyleOption(C,"i"===I[0]?I:"n"),A}addRows(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n";const C=[];return g.forEach((g=>{C.push(this.addRow(g,I))})),C}insertRow(g,I){let C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"n";return this.spliceRows(g,0,I),this._setStyleOption(g,C),this.getRow(g)}insertRows(g,I){let C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"n";if(this.spliceRows(g,0,...I),"n"!==C)for(let A=0;A1&&void 0!==arguments[1]?arguments[1]:"n";"o"===I[0]&&void 0!==this.findRow(g+1)?this._copyStyle(g+1,g,"+"===I[1]):"i"===I[0]&&void 0!==this.findRow(g-1)&&this._copyStyle(g-1,g,"+"===I[1])}_copyStyle(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this.getRow(g),i=this.getRow(I);i.style=n(A.style),A.eachCell({includeEmpty:C},((g,I)=>{i.getCell(I).style=n(g.style)})),i.height=A.height}duplicateRow(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this._rows[g-1],i=new Array(I).fill(A.values);this.spliceRows(g+1,C?0:I,...i);for(let e=0;e{I.getCell(C).style=g.style}))}}spliceRows(g,I){const C=g+I;for(var A=arguments.length,i=new Array(A>2?A-2:0),e=2;e{g.getCell(C).style=I.style})),this._rows[o-1]=void 0}else this._rows[o+l-1]=void 0;else if(l>0)for(o=s;o>=C;o--)if(c=this._rows[o-1],c){const g=this.getRow(o+l);g.values=c.values,g.style=c.style,g.height=c.height,c.eachCell({includeEmpty:!0},((I,C)=>{if(g.getCell(C).style=I.style,"MergeValue"===I._value.constructor.name){const g=this.getRow(I._row._number+t).getCell(C),A=I._value._master,i=this.getRow(A._row._number+t).getCell(A._column._number);g.merge(i)}}))}else this._rows[o+l-1]=void 0;for(o=0;o{g&&g.hasValues&&I(g,g.number)}))}getSheetValues(){const g=[];return this._rows.forEach((I=>{I&&(g[I.number]=I.values)})),g}findCell(g,I){const C=i.getAddress(g,I),A=this._rows[C.row-1];return A?A.findCell(C.col):void 0}getCell(g,I){const C=i.getAddress(g,I);return this.getRow(C.row).getCellEx(C)}mergeCells(){for(var g=arguments.length,I=new Array(g),C=0;C{if(I.intersects(g))throw new Error("Cannot merge already merged cells")}));const C=this.getCell(g.top,g.left);for(let A=g.top;A<=g.bottom;A++)for(let i=g.left;i<=g.right;i++)(A>g.top||i>g.left)&&this.getCell(A,i).merge(C,I);this._merges[C.address]=g}_unMergeMaster(g){const I=this._merges[g.address];if(I){for(let g=I.top;g<=I.bottom;g++)for(let C=I.left;C<=I.right;C++)this.getCell(g,C).unmerge();delete this._merges[g.address]}}get hasMerges(){return A.some(this._merges,Boolean)}unMergeCells(){for(var g=arguments.length,I=new Array(g),C=0;C3&&void 0!==arguments[3]?arguments[3]:"shared";const e=i.decode(g),{top:t,left:l,bottom:s,right:o}=e,c=o-l+1,d=i.encodeAddress(t,l),a="shared"===A;let n;n="function"==typeof C?C:Array.isArray(C)?Array.isArray(C[0])?(g,I)=>C[g-t][I-l]:(g,I)=>C[(g-t)*c+(I-l)]:()=>{};let r=!0;for(let i=t;i<=s;i++)for(let C=l;C<=o;C++)r?(this.getCell(i,C).value={shareType:A,formula:I,ref:g,result:n(i,C)},r=!1):this.getCell(i,C).value=a?{sharedFormula:d,result:n(i,C)}:n(i,C)}addImage(g,I){const C={type:"image",imageId:g,range:I};this._media.push(new o(this,C))}getImages(){return this._media.filter((g=>"image"===g.type))}addBackgroundImage(g){const I={type:"background",imageId:g};this._media.push(new o(this,I))}getBackgroundImageId(){const g=this._media.find((g=>"background"===g.type));return g&&g.imageId}protect(g,I){return new Promise((C=>{this.sheetProtection={sheet:!0},I&&"spinCount"in I&&(I.spinCount=Number.isFinite(I.spinCount)?Math.round(Math.max(0,I.spinCount)):1e5),g&&(this.sheetProtection.algorithmName="SHA-512",this.sheetProtection.saltValue=a.randomBytes(16).toString("base64"),this.sheetProtection.spinCount=I&&"spinCount"in I?I.spinCount:1e5,this.sheetProtection.hashValue=a.convertPasswordToHash(g,"SHA512",this.sheetProtection.saltValue,this.sheetProtection.spinCount)),I&&(this.sheetProtection=Object.assign(this.sheetProtection,I),!g&&"spinCount"in I&&delete this.sheetProtection.spinCount),C()}))}unprotect(){this.sheetProtection=null}addTable(g){const I=new c(this,g);return this.tables[g.name]=I,I}getTable(g){return this.tables[g]}removeTable(g){delete this.tables[g]}getTables(){return Object.values(this.tables)}addConditionalFormatting(g){this.conditionalFormattings.push(g)}removeConditionalFormatting(g){"number"==typeof g?this.conditionalFormattings.splice(g,1):this.conditionalFormattings=g instanceof Function?this.conditionalFormattings.filter(g):[]}get tabColor(){return console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor}set tabColor(g){console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor=g}get model(){const g={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map((g=>g.model)),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map((g=>g.model)),conditionalFormattings:this.conditionalFormattings};g.cols=l.toModel(this.columns);const I=g.rows=[],C=g.dimensions=new e;return this._rows.forEach((g=>{const A=g&&g.model;A&&(C.expand(A.number,A.min,A.number,A.max),I.push(A))})),g.merges=[],A.each(this._merges,(I=>{g.merges.push(I.range)})),g}_parseRows(g){this._rows=[],g.rows.forEach((g=>{const I=new t(this,g.number);this._rows[I.number-1]=I,I.model=g}))}_parseMergeCells(g){A.each(g.mergeCells,(g=>{this.mergeCellsWithoutStyle(g)}))}set model(g){this.name=g.name,this._columns=l.fromModel(this,g.cols),this._parseRows(g),this._parseMergeCells(g),this.dataValidations=new d(g.dataValidations),this.properties=g.properties,this.pageSetup=g.pageSetup,this.headerFooter=g.headerFooter,this.views=g.views,this.autoFilter=g.autoFilter,this._media=g.media.map((g=>new o(this,g))),this.sheetProtection=g.sheetProtection,this.tables=g.tables.reduce(((g,I)=>{const C=new c;return C.model=I,g[I.name]=C,g}),{}),this.conditionalFormattings=g.conditionalFormattings}}I.exports=r},{"../utils/col-cache":19,"../utils/copy-style":20,"../utils/encryptor":21,"../utils/under-dash":26,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(g,I,C){g("core-js/modules/es.promise"),g("core-js/modules/es.promise.finally"),g("core-js/modules/es.object.assign"),g("core-js/modules/es.object.keys"),g("core-js/modules/es.object.values"),g("core-js/modules/es.symbol"),g("core-js/modules/es.symbol.async-iterator"),g("core-js/modules/es.array.iterator"),g("core-js/modules/es.array.includes"),g("core-js/modules/es.array.find-index"),g("core-js/modules/es.array.find"),g("core-js/modules/es.string.from-code-point"),g("core-js/modules/es.string.includes"),g("core-js/modules/es.number.is-nan"),g("regenerator-runtime/runtime");const A={Workbook:g("./doc/workbook")},i=g("./doc/enums");Object.keys(i).forEach((g=>{A[g]=i[g]})),I.exports=A},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":359,"core-js/modules/es.array.find-index":358,"core-js/modules/es.array.includes":360,"core-js/modules/es.array.iterator":361,"core-js/modules/es.number.is-nan":363,"core-js/modules/es.object.assign":364,"core-js/modules/es.object.keys":366,"core-js/modules/es.object.values":367,"core-js/modules/es.promise":372,"core-js/modules/es.promise.finally":371,"core-js/modules/es.string.from-code-point":376,"core-js/modules/es.string.includes":377,"core-js/modules/es.symbol":381,"core-js/modules/es.symbol.async-iterator":378,"regenerator-runtime/runtime":492}],16:[function(g,I,C){const A="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function i(g){return"string"==typeof g?g:A?A.decode(g):g.toString()}C.bufferToString=i},{}],17:[function(g,I,C){const A="undefined"==typeof TextEncoder?null:new TextEncoder("utf-8"),{Buffer:i}=g("buffer");function e(g){return"string"!=typeof g?g:A?i.from(A.encode(g).buffer):i.from(g)}C.stringToBuffer=e},{buffer:220}],18:[function(g,I,C){const A=g("./under-dash"),i=g("./col-cache");class e{constructor(g){this.template=g,this.sheets={}}addCell(g){this.addCellEx(i.decodeEx(g))}getCell(g){return this.findCellEx(i.decodeEx(g),!0)}findCell(g){return this.findCellEx(i.decodeEx(g),!1)}findCellAt(g,I,C){const A=this.sheets[g],i=A&&A[I];return i&&i[C]}addCellEx(g){if(g.top)for(let I=g.top;I<=g.bottom;I++)for(let C=g.left;C<=g.right;C++)this.getCellAt(g.sheetName,I,C);else this.findCellEx(g,!0)}getCellEx(g){return this.findCellEx(g,!0)}findCellEx(g,I){const C=this.findSheet(g,I),A=this.findSheetRow(C,g,I);return this.findRowCell(A,g,I)}getCellAt(g,I,C){const A=this.sheets[g]||(this.sheets[g]=[]),e=A[I]||(A[I]=[]);return e[C]||(e[C]={sheetName:g,address:i.n2l(C)+I,row:I,col:C})}removeCellEx(g){const I=this.findSheet(g);if(!I)return;const C=this.findSheetRow(I,g);C&&delete C[g.col]}forEachInSheet(g,I){const C=this.sheets[g];C&&C.forEach(((g,C)=>{g&&g.forEach(((g,A)=>{g&&I(g,C,A)}))}))}forEach(g){A.each(this.sheets,((I,C)=>{this.forEachInSheet(C,g)}))}map(g){const I=[];return this.forEach((C=>{I.push(g(C))})),I}findSheet(g,I){const C=g.sheetName;return this.sheets[C]?this.sheets[C]:I?this.sheets[C]=[]:void 0}findSheetRow(g,I,C){const{row:A}=I;return g&&g[A]?g[A]:C?g[A]=[]:void 0}findRowCell(g,I,C){const{col:A}=I;return g&&g[A]?g[A]:C?g[A]=this.template?Object.assign(I,JSON.parse(JSON.stringify(this.template))):I:void 0}spliceRows(g,I,C,A){const i=this.sheets[g];if(i){const g=[];for(let I=0;I{A.splice(I,C,...g)}))}}}I.exports=e},{"./col-cache":19,"./under-dash":26}],19:[function(g,I,C){const A=/^[A-Z]+\d+$/,i={_dictionary:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],_l2nFill:0,_l2n:{},_n2l:[],_level:g=>g<=26?1:g<=676?2:3,_fill(g){let I,C,A,i,e,t=1;if(g>=4)throw new Error("Out of bounds. Excel supports columns from 1 to 16384");if(this._l2nFill<1&&g>=1){for(;t<=26;)I=this._dictionary[t-1],this._n2l[t]=I,this._l2n[I]=t,t++;this._l2nFill=1}if(this._l2nFill<2&&g>=2){for(t=27;t<=702;)C=t-27,A=C%26,i=Math.floor(C/26),I=this._dictionary[i]+this._dictionary[A],this._n2l[t]=I,this._l2n[I]=t,t++;this._l2nFill=2}if(this._l2nFill<3&&g>=3){for(t=703;t<=16384;)C=t-703,A=C%26,i=Math.floor(C/26)%26,e=Math.floor(C/676),I=this._dictionary[e]+this._dictionary[i]+this._dictionary[A],this._n2l[t]=I,this._l2n[I]=t,t++;this._l2nFill=3}},l2n(g){if(this._l2n[g]||this._fill(g.length),!this._l2n[g])throw new Error(`Out of bounds. Invalid column letter: ${g}`);return this._l2n[g]},n2l(g){if(g<1||g>16384)throw new Error(`${g} is out of bounds. Excel supports columns from 1 to 16384`);return this._n2l[g]||this._fill(this._level(g)),this._n2l[g]},_hash:{},validateAddress(g){if(!A.test(g))throw new Error(`Invalid Address: ${g}`);return!0},decodeAddress(g){const I=g.length<5&&this._hash[g];if(I)return I;let C=!1,A="",i=0,e=!1,t="",l=0;for(let o,c=0;c=65&&o<=90)C=!0,A+=g[c],i=26*i+o-64;else if(o>=48&&o<=57)e=!0,t+=g[c],l=10*l+o-48;else if(e&&C&&36!==o)break;if(C){if(i>16384)throw new Error(`Out of bounds. Invalid column letter: ${A}`)}else i=void 0;e||(l=void 0);const s={address:g=A+t,col:i,row:l,$col$row:`$${A}$${t}`};return i<=100&&l<=100&&(this._hash[g]=s,this._hash[s.$col$row]=s),s},getAddress(g,I){if(I){const C=this.n2l(I)+g;return this.decodeAddress(C)}return this.decodeAddress(g)},decode(g){const I=g.split(":");if(2===I.length){const g=this.decodeAddress(I[0]),C=this.decodeAddress(I[1]),A={top:Math.min(g.row,C.row),left:Math.min(g.col,C.col),bottom:Math.max(g.row,C.row),right:Math.max(g.col,C.col)};return A.tl=this.n2l(A.left)+A.top,A.br=this.n2l(A.right)+A.bottom,A.dimensions=`${A.tl}:${A.br}`,A}return this.decodeAddress(g)},decodeEx(g){const I=g.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/),C=I[1]||I[2],A=I[3],i=A.split(":");if(i.length>1){let g=this.decodeAddress(i[0]),I=this.decodeAddress(i[1]);const A=Math.min(g.row,I.row),e=Math.min(g.col,I.col),t=Math.max(g.row,I.row),l=Math.max(g.col,I.col);return g=this.n2l(e)+A,I=this.n2l(l)+t,{top:A,left:e,bottom:t,right:l,sheetName:C,tl:{address:g,col:e,row:A,$col$row:`$${this.n2l(e)}$${A}`,sheetName:C},br:{address:I,col:l,row:t,$col$row:`$${this.n2l(l)}$${t}`,sheetName:C},dimensions:`${g}:${I}`}}if(A.startsWith("#"))return C?{sheetName:C,error:A}:{error:A};const e=this.decodeAddress(A);return C?{sheetName:C,...e}:e},encodeAddress:(g,I)=>i.n2l(I)+g,encode(){switch(arguments.length){case 2:return i.encodeAddress(arguments[0],arguments[1]);case 4:return`${i.encodeAddress(arguments[0],arguments[1])}:${i.encodeAddress(arguments[2],arguments[3])}`;default:throw new Error("Can only encode with 2 or 4 arguments")}},inRange(g,I){const[C,A,,i,e]=g,[t,l]=I;return t>=C&&t<=i&&l>=A&&l<=e}};I.exports=i},{}],20:[function(g,I,C){const A=(g,I)=>({...g,...I.reduce(((I,C)=>(g[C]&&(I[C]={...g[C]}),I)),{})}),i=function(g,I,C){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];g[C]&&(I[C]=A(g[C],i))},e=g=>0===Object.keys(g).length,t=g=>{if(!g)return g;if(e(g))return{};const I={...g};return i(g,I,"font",["color"]),i(g,I,"alignment"),i(g,I,"protection"),g.border&&(i(g,I,"border"),i(g.border,I.border,"top",["color"]),i(g.border,I.border,"left",["color"]),i(g.border,I.border,"bottom",["color"]),i(g.border,I.border,"right",["color"]),i(g.border,I.border,"diagonal",["color"])),g.fill&&(i(g,I,"fill",["fgColor","bgColor","center"]),g.fill.stops&&(I.fill.stops=g.fill.stops.map((g=>A(g,["color"]))))),I};C.copyStyle=t},{}],21:[function(g,I,C){(function(C){(function(){const A=g("crypto"),i={hash(g){const I=A.createHash(g);for(var i=arguments.length,e=new Array(i>1?i-1:0),t=1;tA.randomBytes(g)};I.exports=i}).call(this)}).call(this,g("buffer").Buffer)},{buffer:220,crypto:390}],22:[function(g,I,C){const{SaxesParser:A}=g("saxes"),{PassThrough:i}=g("readable-stream"),{bufferToString:e}=g("./browser-buffer-decode");I.exports=async function*(g){g.pipe&&!g[Symbol.asyncIterator]&&(g=g.pipe(new i));const I=new A;let C;I.on("error",(g=>{C=g}));let t=[];I.on("opentag",(g=>t.push({eventType:"opentag",value:g}))),I.on("text",(g=>t.push({eventType:"text",value:g}))),I.on("closetag",(g=>t.push({eventType:"closetag",value:g})));for await(const A of g){if(I.write(e(A)),C)throw C;yield t,t=[]}}},{"./browser-buffer-decode":16,"readable-stream":491,saxes:496}],23:[function(g,I,C){const A=g("./col-cache"),i=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,e=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;function t(g,I,C){const t=A.decode(I),l=A.decode(C);return g.replace(i,((g,I,C,i,s)=>{if(s)return g;const o=e.exec(i);if(o){const C=o[1],i=o[2].toUpperCase(),e=o[3],s=o[4];if(i.length>3||3===i.length&&i>"XFD")return g;let c=A.l2n(i),d=parseInt(s,10);return C||(c+=l.col-t.col),e||(d+=l.row-t.row),(I||"")+(C||"")+A.n2l(c)+(e||"")+d}return g}))}I.exports={slideFormula:t}},{"./col-cache":19}],24:[function(g,I,C){(function(C,A){(function(){const i=g("readable-stream"),e=g("./utils"),t=g("./string-buf");class l{constructor(g,I){this._data=g,this._encoding=I}get length(){return this.toBuffer().length}copy(g,I,C,A){return this.toBuffer().copy(g,I,C,A)}toBuffer(){return this._buffer||(this._buffer=A.from(this._data,this._encoding)),this._buffer}}class s{constructor(g){this._data=g}get length(){return this._data.length}copy(g,I,C,A){return this._data._buf.copy(g,I,C,A)}toBuffer(){return this._data.toBuffer()}}class o{constructor(g){this._data=g}get length(){return this._data.length}copy(g,I,C,A){this._data.copy(g,I,C,A)}toBuffer(){return this._data}}class c{constructor(g){this.size=g,this.buffer=A.alloc(g),this.iRead=0,this.iWrite=0}toBuffer(){if(0===this.iRead&&this.iWrite===this.size)return this.buffer;const g=A.alloc(this.iWrite-this.iRead);return this.buffer.copy(g,0,this.iRead,this.iWrite),g}get length(){return this.iWrite-this.iRead}get eod(){return this.iRead===this.iWrite}get full(){return this.iWrite===this.size}read(g){let I;return 0===g?null:void 0===g||g>=this.length?(I=this.toBuffer(),this.iRead=this.iWrite,I):(I=A.alloc(g),this.buffer.copy(I,0,this.iRead,g),this.iRead+=g,I)}write(g,I,C){const A=Math.min(C,this.size-this.iWrite);return g.copy(this.buffer,this.iWrite,I,I+A),this.iWrite+=A,A}}const d=function(g){g=g||{},this.bufSize=g.bufSize||1048576,this.buffers=[],this.batch=g.batch||!1,this.corked=!1,this.inPos=0,this.outPos=0,this.pipes=[],this.paused=!1,this.encoding=null};e.inherits(d,i.Duplex,{toBuffer(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:return A.concat(this.buffers.map((g=>g.toBuffer())))}},_getWritableBuffer(){if(this.buffers.length){const g=this.buffers[this.buffers.length-1];if(!g.full)return g}const g=new c(this.bufSize);return this.buffers.push(g),g},async _pipe(g){const I=function(I){return new Promise((C=>{I.write(g.toBuffer(),(()=>{C()}))}))};await Promise.all(this.pipes.map(I))},_writeToBuffers(g){let I=0;const C=g.length;for(;I1;)this._pipe(this.buffers.shift());else this.corked?(this._writeToBuffers(c),C.nextTick(i)):(await this._pipe(c),i());else this.paused||this.emit("data",c.toBuffer()),this._writeToBuffers(c),this.emit("readable");return!0},cork(){this.corked=!0},_flush(){if(this.pipes.length)for(;this.buffers.length;)this._pipe(this.buffers.shift())},uncork(){this.corked=!1,this._flush()},end(g,I,C){const A=g=>{g?C(g):(this._flush(),this.pipes.forEach((g=>{g.end()})),this.emit("finish"))};g?this.write(g,I,A):A()},read(g){let I;if(g){for(I=[];g&&this.buffers.length&&!this.buffers[0].eod;){const C=this.buffers[0],A=C.read(g);g-=A.length,I.push(A),C.eod&&C.full&&this.buffers.shift()}return A.concat(I)}return I=this.buffers.map((g=>g.toBuffer())).filter(Boolean),this.buffers=[],A.concat(I)},setEncoding(g){this.encoding=g},pause(){this.paused=!0},resume(){this.paused=!1},isPaused(){return!!this.paused},pipe(g){this.pipes.push(g),!this.paused&&this.buffers.length&&this.end()},unpipe(g){this.pipes=this.pipes.filter((I=>I!==g))},unshift(){throw new Error("Not Implemented")},wrap(){throw new Error("Not Implemented")}}),I.exports=d}).call(this)}).call(this,g("_process"),g("buffer").Buffer)},{"./string-buf":25,"./utils":27,_process:467,buffer:220,"readable-stream":491}],25:[function(g,I,C){(function(g){(function(){class C{constructor(I){this._buf=g.alloc(I&&I.size||16384),this._encoding=I&&I.encoding||"utf8",this._inPos=0,this._buffer=void 0}get length(){return this._inPos}get capacity(){return this._buf.length}get buffer(){return this._buf}toBuffer(){return this._buffer||(this._buffer=g.alloc(this.length),this._buf.copy(this._buffer,0,0,this.length)),this._buffer}reset(g){g=g||0,this._buffer=void 0,this._inPos=g}_grow(I){let C=2*this._buf.length;for(;C=this._buf.length-4;)this._grow(this._inPos+g.length),I=this._inPos+this._buf.write(g,this._inPos,this._encoding);this._inPos=I}addStringBuf(g){g.length&&(this._buffer=void 0,this.length+g.length>this.capacity&&this._grow(this.length+g.length),g._buf.copy(this._buf,this._inPos,0,g.length),this._inPos+=g.length)}}I.exports=C}).call(this)}).call(this,g("buffer").Buffer)},{buffer:220}],26:[function(g,I,C){const{toString:A}=Object.prototype,i=/["&<>]/,e={each:function(g,I){g&&(Array.isArray(g)?g.forEach(I):Object.keys(g).forEach((C=>{I(g[C],C)})))},some:function(g,I){return!!g&&(Array.isArray(g)?g.some(I):Object.keys(g).some((C=>I(g[C],C))))},every:function(g,I){return!g||(Array.isArray(g)?g.every(I):Object.keys(g).every((C=>I(g[C],C))))},map:function(g,I){return g?Array.isArray(g)?g.map(I):Object.keys(g).map((C=>I(g[C],C))):[]},keyBy:(g,I)=>g.reduce(((g,C)=>(g[C[I]]=C,g)),{}),isEqual:function(g,I){const C=typeof g,A=typeof I,i=Array.isArray(g),t=Array.isArray(I);let l;if(C!==A)return!1;if("object"==typeof g){if(i||t)return!(!i||!t)&&g.length===I.length&&g.every(((g,C)=>{const A=I[C];return e.isEqual(g,A)}));if(null===g||null===I)return g===I;if(l=Object.keys(g),Object.keys(I).length!==l.length)return!1;for(const g of l)if(!I.hasOwnProperty(g))return!1;return e.every(g,((g,C)=>{const A=I[C];return e.isEqual(g,A)}))}return g===I},escapeHtml(g){const I=i.exec(g);if(!I)return g;let C="",A="",e=0,t=I.index;for(;t":A=">";break;default:continue}e!==t&&(C+=g.substring(e,t)),e=t+1,C+=A}return e!==t?C+g.substring(e,t):C},strcmp:(g,I)=>gI?1:0,isUndefined:g=>"[object Undefined]"===A.call(g),isObject:g=>"[object Object]"===A.call(g),deepMerge(){const g=arguments[0]||{},{length:I}=arguments;let C,A,i;function t(I,t){C=g[t],i=Array.isArray(I),e.isObject(I)||i?(i?(i=!1,A=C&&Array.isArray(C)?C:[]):A=C&&e.isObject(C)?C:{},g[t]=e.deepMerge(A,I)):e.isUndefined(I)||(g[t]=I)}for(let l=0;l{Object.defineProperty(g,I,Object.getOwnPropertyDescriptor(C,I))}));const i={constructor:{value:g,enumerable:!1,writable:!1,configurable:!0}};A&&Object.keys(A).forEach((g=>{i[g]=Object.getOwnPropertyDescriptor(A,g)})),g.prototype=Object.create(I.prototype,i)},t=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/,l={nop(){},promiseImmediate:g=>new Promise((I=>{C.setImmediate?A((()=>{I(g)})):setTimeout((()=>{I(g)}),1)})),inherits:e,dateToExcel:(g,I)=>25569+g.getTime()/864e5-(I?1462:0),excelToDate(g,I){const C=Math.round(24*(g-25569+(I?1462:0))*3600*1e3);return new Date(C)},parsePath(g){const I=g.lastIndexOf("/");return{path:g.substring(0,I),name:g.substring(I+1)}},getRelsPath(g){const I=l.parsePath(g);return`${I.path}/_rels/${I.name}.rels`},xmlEncode(g){const I=t.exec(g);if(!I)return g;let C="",A="",i=0,e=I.index;for(;e=11&&13!==I)){A="";break}continue}i!==e&&(C+=g.substring(i,e)),i=e+1,A&&(C+=A)}return i!==e?C+g.substring(i,e):C},xmlDecode:g=>g.replace(/&([a-z]*);/g,(g=>{switch(g){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case""":return'"';default:return g}})),validInt(g){const I=parseInt(g,10);return Number.isNaN(I)?0:I},isDateFmt:g=>!!g&&null!==(g=(g=g.replace(/\[[^\]]*]/g,"")).replace(/"[^"]*"/g,"")).match(/[ymdhMsb]+/),fs:{exists:g=>new Promise((I=>{i.access(g,i.constants.F_OK,(g=>{I(!g)}))}))},toIsoDateString:g=>g.toIsoString().subsstr(0,10),parseBoolean:g=>!0===g||"true"===g||1===g||"1"===g};I.exports=l}).call(this)}).call(this,void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},g("timers").setImmediate)},{fs:216,timers:523}],28:[function(g,I,C){const A=g("./under-dash"),i=g("./utils"),e="<",t=">",l="";function o(g,I,C){g.push(` ${I}="${i.xmlEncode(C.toString())}"`)}function c(g,I){if(I){const C=[];A.each(I,((g,I)=>{void 0!==g&&o(C,I,g)})),g.push(C.join(""))}}class d{constructor(){this._xml=[],this._stack=[],this._rollbacks=[]}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._xml.length}openXml(g){const I=this._xml;I.push("\n")}openNode(g,I){const C=this.tos,A=this._xml;C&&this.open&&A.push(t),this._stack.push(g),A.push(e),A.push(g),c(A,I),this.leaf=!0,this.open=!0}addAttribute(g,I){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");void 0!==I&&o(this._xml,g,I)}addAttributes(g){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");c(this._xml,g)}writeText(g){const I=this._xml;this.open&&(I.push(t),this.open=!1),this.leaf=!1,I.push(i.xmlEncode(g.toString()))}writeXml(g){this.open&&(this._xml.push(t),this.open=!1),this.leaf=!1,this._xml.push(g)}closeNode(){const g=this._stack.pop(),I=this._xml;this.leaf?I.push(s):(I.push(l),I.push(g),I.push(t)),this.open=!1,this.leaf=!1}leafNode(g,I,C){this.openNode(g,I),void 0!==C&&this.writeText(C),this.closeNode()}closeAll(){for(;this._stack.length;)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){const g=this._rollbacks.pop();this._xml.length>g.xml&&this._xml.splice(g.xml,this._xml.length-g.xml),this._stack.length>g.stack&&this._stack.splice(g.stack,this._stack.length-g.stack),this.leaf=g.leaf,this.open=g.open}get xml(){return this.closeAll(),this._xml.join("")}}d.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"},I.exports=d},{"./under-dash":26,"./utils":27}],29:[function(g,I,C){(function(C){(function(){const A=g("events"),i=g("jszip"),e=g("./stream-buf"),{stringToBuffer:t}=g("./browser-buffer-encode");class l extends A.EventEmitter{constructor(g){super(),this.options=Object.assign({type:"nodebuffer",compression:"DEFLATE"},g),this.zip=new i,this.stream=new e}append(g,I){I.hasOwnProperty("base64")&&I.base64?this.zip.file(I.name,g,{base64:!0}):(C.browser&&"string"==typeof g&&(g=t(g)),this.zip.file(I.name,g))}async finalize(){const g=await this.zip.generateAsync(this.options);this.stream.end(g),this.emit("finish")}read(g){return this.stream.read(g)}setEncoding(g){return this.stream.setEncoding(g)}pause(){return this.stream.pause()}resume(){return this.stream.resume()}isPaused(){return this.stream.isPaused()}pipe(g,I){return this.stream.pipe(g,I)}unpipe(g){return this.stream.unpipe(g)}unshift(g){return this.stream.unshift(g)}wrap(g){return this.stream.wrap(g)}}I.exports={ZipWriter:l}}).call(this)}).call(this,g("_process"))},{"./browser-buffer-encode":17,"./stream-buf":24,_process:467,events:422,jszip:441}],30:[function(g,I,C){I.exports={0:{f:"General"},1:{f:"0"},2:{f:"0.00"},3:{f:"#,##0"},4:{f:"#,##0.00"},9:{f:"0%"},10:{f:"0.00%"},11:{f:"0.00E+00"},12:{f:"# ?/?"},13:{f:"# ??/??"},14:{f:"mm-dd-yy"},15:{f:"d-mmm-yy"},16:{f:"d-mmm"},17:{f:"mmm-yy"},18:{f:"h:mm AM/PM"},19:{f:"h:mm:ss AM/PM"},20:{f:"h:mm"},21:{f:"h:mm:ss"},22:{f:'m/d/yy "h":mm'},27:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},28:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},29:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},30:{"zh-tw":"m/d/yy ","zh-cn":"m-d-yy","ja-jp":"m/d/yy","ko-kr":"mm-dd-yy"},31:{"zh-tw":'yyyy"年"m"月"d"日"',"zh-cn":'yyyy"年"m"月"d"日"',"ja-jp":'yyyy"年"m"月"d"日"',"ko-kr":'yyyy"년" mm"월" dd"일"'},32:{"zh-tw":'hh"時"mm"分"',"zh-cn":'h"时"mm"分"',"ja-jp":'h"時"mm"分"',"ko-kr":'h"시" mm"분"'},33:{"zh-tw":'hh"時"mm"分"ss"秒"',"zh-cn":'h"时"mm"分"ss"秒"',"ja-jp":'h"時"mm"分"ss"秒"',"ko-kr":'h"시" mm"분" ss"초"'},34:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'上午/下午 h"时"mm"分"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},35:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'上午/下午 h"时"mm"分"ss"秒"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},36:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},37:{f:"#,##0 ;(#,##0)"},38:{f:"#,##0 ;[Red](#,##0)"},39:{f:"#,##0.00 ;(#,##0.00)"},40:{f:"#,##0.00 ;[Red](#,##0.00)"},45:{f:"mm:ss"},46:{f:"[h]:mm:ss"},47:{f:"mmss.0"},48:{f:"##0.0E+0"},49:{f:"@"},50:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},51:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},52:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'yyyy"年"m"月"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},53:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'m"月"d"日"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},54:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},55:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'上午/下午 h"时"mm"分"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},56:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'上午/下午 h"时"mm"分"ss"秒"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},57:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},58:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},59:{"th-th":"t0"},60:{"th-th":"t0.00"},61:{"th-th":"t#,##0"},62:{"th-th":"t#,##0.00"},67:{"th-th":"t0%"},68:{"th-th":"t0.00%"},69:{"th-th":"t# ?/?"},70:{"th-th":"t# ??/??"},81:{"th-th":"d/m/bb"}}},{}],31:[function(g,I,C){I.exports={OfficeDocument:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",Worksheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",CalcChain:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",SharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",Styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",Theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",Hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",Image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",CoreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",ExtenderProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",Comments:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",VmlDrawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",Table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"}},{}],32:[function(g,I,C){const A=g("../../utils/parse-sax"),i=g("../../utils/xml-stream");class e{prepare(){}render(){}parseOpen(g){}parseText(g){}parseClose(g){}reconcile(g,I){}reset(){this.model=null,this.map&&Object.values(this.map).forEach((g=>{g instanceof e?g.reset():g.xform&&g.xform.reset()}))}mergeModel(g){this.model=Object.assign(this.model||{},g)}async parse(g){for await(const I of g)for(const{eventType:g,value:C}of I)if("opentag"===g)this.parseOpen(C);else if("text"===g)this.parseText(C);else if("closetag"===g&&!this.parseClose(C.name))return this.model;return this.model}async parseStream(g){return this.parse(A(g))}get xml(){return this.toXml(this.model)}toXml(g){const I=new i;return this.render(I,g),I.xml}static toAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0===g){if(C)return I}else if(C||g!==I)return g.toString()}static toStringAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.toAttribute(g,I,C)}static toStringValue(g,I){return void 0===g?I:g}static toBoolAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0===g){if(C)return I}else if(C||g!==I)return g?"1":"0"}static toBoolValue(g,I){return void 0===g?I:"1"===g}static toIntAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.toAttribute(g,I,C)}static toIntValue(g,I){return void 0===g?I:parseInt(g,10)}static toFloatAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.toAttribute(g,I,C)}static toFloatValue(g,I){return void 0===g?I:parseFloat(g)}}I.exports=e},{"../../utils/parse-sax":22,"../../utils/xml-stream":28}],33:[function(g,I,C){const A=g("../base-xform"),i=g("../../../utils/col-cache");class e extends A{render(g,I){g.openNode("definedName",{name:I.name,localSheetId:I.localSheetId}),g.writeText(I.ranges.join(",")),g.closeNode()}parseOpen(g){return"definedName"===g.name&&(this._parsedName=g.attributes.name,this._parsedLocalSheetId=g.attributes.localSheetId,this._parsedText=[],!0)}parseText(g){this._parsedText.push(g)}parseClose(){return this.model={name:this._parsedName,ranges:l(this._parsedText.join(""))},void 0!==this._parsedLocalSheetId&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}}function t(g){try{return i.decodeEx(g),!0}catch(I){return!1}}function l(g){const I=[];let C=!1,A="";return g.split(",").forEach((g=>{if(!g)return;const i=(g.match(/'/g)||[]).length;if(!i)return void(C?A+=`${g},`:t(g)&&I.push(g));const e=i%2==0;!C&&e&&t(g)?I.push(g):C&&!e?(C=!1,t(A+g)&&I.push(A+g),A=""):(C=!0,A+=`${g},`)})),I}I.exports=e},{"../../../utils/col-cache":19,"../base-xform":32}],34:[function(g,I,C){const A=g("../../../utils/utils"),i=g("../base-xform");class e extends i{render(g,I){g.leafNode("sheet",{sheetId:I.id,name:I.name,state:I.state,"r:id":I.rId})}parseOpen(g){return"sheet"===g.name&&(this.model={name:A.xmlDecode(g.attributes.name),id:parseInt(g.attributes.sheetId,10),state:g.attributes.state,rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../../../utils/utils":27,"../base-xform":32}],35:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.leafNode("calcPr",{calcId:171027,fullCalcOnLoad:I.fullCalcOnLoad?1:void 0})}parseOpen(g){return"calcPr"===g.name&&(this.model={},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],36:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.leafNode("workbookPr",{date1904:I.date1904?1:void 0,defaultThemeVersion:164011,filterPrivacy:1})}parseOpen(g){return"workbookPr"===g.name&&(this.model={date1904:"1"===g.attributes.date1904},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],37:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){const C={xWindow:I.x||0,yWindow:I.y||0,windowWidth:I.width||12e3,windowHeight:I.height||24e3,firstSheet:I.firstSheet,activeTab:I.activeTab};I.visibility&&"visible"!==I.visibility&&(C.visibility=I.visibility),g.leafNode("workbookView",C)}parseOpen(g){if("workbookView"===g.name){const I=this.model={},C=function(g,C,A){const i=void 0!==C?I[g]=C:A;void 0!==i&&(I[g]=i)},A=function(g,C,A){const i=void 0!==C?I[g]=parseInt(C,10):A;void 0!==i&&(I[g]=i)};return A("x",g.attributes.xWindow,0),A("y",g.attributes.yWindow,0),A("width",g.attributes.windowWidth,25e3),A("height",g.attributes.windowHeight,1e4),C("visibility",g.attributes.visibility,"visible"),A("activeTab",g.attributes.activeTab,void 0),A("firstSheet",g.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],38:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../utils/col-cache"),e=g("../../../utils/xml-stream"),t=g("../base-xform"),l=g("../static-xform"),s=g("../list-xform"),o=g("./defined-name-xform"),c=g("./sheet-xform"),d=g("./workbook-view-xform"),a=g("./workbook-properties-xform"),n=g("./workbook-calc-properties-xform");class r extends t{constructor(){super(),this.map={fileVersion:r.STATIC_XFORMS.fileVersion,workbookPr:new a,bookViews:new s({tag:"bookViews",count:!1,childXform:new d}),sheets:new s({tag:"sheets",count:!1,childXform:new c}),definedNames:new s({tag:"definedNames",count:!1,childXform:new o}),calcPr:new n}}prepare(g){g.sheets=g.worksheets;const I=[];let C=0;g.sheets.forEach((g=>{if(g.pageSetup&&g.pageSetup.printArea&&g.pageSetup.printArea.split("&&").forEach((A=>{const i=A.split(":"),e={name:"_xlnm.Print_Area",ranges:[`'${g.name}'!$${i[0]}:$${i[1]}`],localSheetId:C};I.push(e)})),g.pageSetup&&(g.pageSetup.printTitlesRow||g.pageSetup.printTitlesColumn)){const A=[];if(g.pageSetup.printTitlesColumn){const I=g.pageSetup.printTitlesColumn.split(":");A.push(`'${g.name}'!$${I[0]}:$${I[1]}`)}if(g.pageSetup.printTitlesRow){const I=g.pageSetup.printTitlesRow.split(":");A.push(`'${g.name}'!$${I[0]}:$${I[1]}`)}const i={name:"_xlnm.Print_Titles",ranges:A,localSheetId:C};I.push(i)}C++})),I.length&&(g.definedNames=g.definedNames.concat(I)),(g.media||[]).forEach(((g,I)=>{g.name=g.type+(I+1)}))}render(g,I){g.openXml(e.StdDocAttributes),g.openNode("workbook",r.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(g),this.map.workbookPr.render(g,I.properties),this.map.bookViews.render(g,I.views),this.map.sheets.render(g,I.sheets),this.map.definedNames.render(g,I.definedNames),this.map.calcPr.render(g,I.calcProperties),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):("workbook"===g.name||(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):"workbook"!==g||(this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),!1)}reconcile(g){const I=(g.workbookRels||[]).reduce(((g,I)=>(g[I.Id]=I,g)),{}),C=[];let e,t=0;(g.sheets||[]).forEach((A=>{const i=I[A.rId];i&&(e=g.worksheetHash[`xl/${i.Target.replace(/^(\s|\/xl\/)+/,"")}`],e&&(e.name=A.name,e.id=A.id,e.state=A.state,C[t++]=e))}));const l=[];A.each(g.definedNames,(g=>{if("_xlnm.Print_Area"===g.name){if(e=C[g.localSheetId],e){e.pageSetup||(e.pageSetup={});const I=i.decodeEx(g.ranges[0]);e.pageSetup.printArea=e.pageSetup.printArea?`${e.pageSetup.printArea}&&${I.dimensions}`:I.dimensions}}else if("_xlnm.Print_Titles"===g.name){if(e=C[g.localSheetId],e){e.pageSetup||(e.pageSetup={});const I=g.ranges.join(","),C=/\$/g,A=/\$\d+:\$\d+/,i=I.match(A);if(i&&i.length){const g=i[0];e.pageSetup.printTitlesRow=g.replace(C,"")}const t=/\$[A-Z]+:\$[A-Z]+/,l=I.match(t);if(l&&l.length){const g=l[0];e.pageSetup.printTitlesColumn=g.replace(C,"")}}}else l.push(g)})),g.definedNames=l,g.media.forEach(((g,I)=>{g.index=I}))}}r.WORKBOOK_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x15","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},r.STATIC_XFORMS={fileVersion:new l({tag:"fileVersion",$:{appName:"xl",lastEdited:5,lowestEdited:5,rupBuild:9303}})},I.exports=r},{"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"../static-xform":120,"./defined-name-xform":33,"./sheet-xform":34,"./workbook-calc-properties-xform":35,"./workbook-properties-xform":36,"./workbook-view-xform":37}],39:[function(g,I,C){const A=g("../strings/rich-text-xform"),i=g("../../../utils/utils"),e=g("../base-xform"),t=I.exports=function(g){this.model=g};i.inherits(t,e,{get tag(){return"r"},get richTextXform(){return this._richTextXform||(this._richTextXform=new A),this._richTextXform},render(g,I){I=I||this.model,g.openNode("comment",{ref:I.ref,authorId:0}),g.openNode("text"),I&&I.note&&I.note.texts&&I.note.texts.forEach((I=>{this.richTextXform.render(g,I)})),g.closeNode(),g.closeNode()},parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"comment":return this.model={type:"note",note:{texts:[]},...g.attributes},!0;case"r":return this.parser=this.richTextXform,this.parser.parseOpen(g),!0;default:return!1}},parseText(g){this.parser&&this.parser.parseText(g)},parseClose(g){switch(g){case"comment":return!1;case"r":return this.model.note.texts.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(g),!0}}})},{"../../../utils/utils":27,"../base-xform":32,"../strings/rich-text-xform":122}],40:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../../../utils/utils"),e=g("../base-xform"),t=g("./comment-xform"),l=I.exports=function(){this.map={comment:new t}};i.inherits(l,e,{COMMENTS_ATTRIBUTES:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main"}},{render(g,I){I=I||this.model,g.openXml(A.StdDocAttributes),g.openNode("comments",l.COMMENTS_ATTRIBUTES),g.openNode("authors"),g.leafNode("author",null,"Author"),g.closeNode(),g.openNode("commentList"),I.comments.forEach((I=>{this.map.comment.render(g,I)})),g.closeNode(),g.closeNode()},parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"commentList":return this.model={comments:[]},!0;case"comment":return this.parser=this.map.comment,this.parser.parseOpen(g),!0;default:return!1}},parseText(g){this.parser&&this.parser.parseText(g)},parseClose(g){switch(g){case"commentList":return!1;case"comment":return this.model.comments.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(g),!0}}})},{"../../../utils/utils":27,"../../../utils/xml-stream":28,"../base-xform":32,"./comment-xform":39}],41:[function(g,I,C){const A=g("../../base-xform");class i extends A{constructor(g){super(),this._model=g}get tag(){return this._model&&this._model.tag}render(g,I,C){(I===C[2]||"x:SizeWithCells"===this.tag&&I===C[1])&&g.leafNode(this.tag)}parseOpen(g){return g.name===this.tag&&(this.model={},this.model[this.tag]=!0,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../../base-xform":32}],42:[function(g,I,C){const A=g("../../base-xform");class i extends A{constructor(g){super(),this._model=g}get tag(){return this._model&&this._model.tag}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(g){return g.name===this.tag&&(this.text="",!0)}parseText(g){this.text=g}parseClose(){return!1}}I.exports=i},{"../../base-xform":32}],43:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"x:Anchor"}getAnchorRect(g){const I=Math.floor(g.left),C=Math.floor(68*(g.left-I)),A=Math.floor(g.top),i=Math.floor(18*(g.top-A)),e=Math.floor(g.right),t=Math.floor(68*(g.right-e)),l=Math.floor(g.bottom);return[I,C,A,i,e,t,l,Math.floor(18*(g.bottom-l))]}getDefaultRect(g){const I=g.col,C=6,A=Math.max(g.row-2,0);return[I,C,A,14,I+2,2,A+4,16]}render(g,I){const C=I.anchor?this.getAnchorRect(I.anchor):this.getDefaultRect(I.refAddress);g.leafNode("x:Anchor",null,C.join(", "))}parseOpen(g){return g.name===this.tag&&(this.text="",!0)}parseText(g){this.text=g}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],44:[function(g,I,C){const A=g("../base-xform"),i=g("./vml-anchor-xform"),e=g("./style/vml-protection-xform"),t=g("./style/vml-position-xform"),l=["twoCells","oneCells","absolute"];class s extends A{constructor(){super(),this.map={"x:Anchor":new i,"x:Locked":new e({tag:"x:Locked"}),"x:LockText":new e({tag:"x:LockText"}),"x:SizeWithCells":new t({tag:"x:SizeWithCells"}),"x:MoveWithCells":new t({tag:"x:MoveWithCells"})}}get tag(){return"x:ClientData"}render(g,I){const{protection:C,editAs:A}=I.note;g.openNode(this.tag,{ObjectType:"Note"}),this.map["x:MoveWithCells"].render(g,A,l),this.map["x:SizeWithCells"].render(g,A,l),this.map["x:Anchor"].render(g,I),this.map["x:Locked"].render(g,C.locked),g.leafNode("x:AutoFill",null,"False"),this.map["x:LockText"].render(g,C.lockText),g.leafNode("x:Row",null,I.refAddress.row-1),g.leafNode("x:Column",null,I.refAddress.col-1),g.closeNode()}parseOpen(g){return g.name===this.tag?(this.reset(),this.model={anchor:[],protection:{},editAs:""}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.normalizeModel(),!1)}normalizeModel(){const g=Object.assign({},this.map["x:MoveWithCells"].model,this.map["x:SizeWithCells"].model),I=Object.keys(g).length;this.model.editAs=l[I],this.model.anchor=this.map["x:Anchor"].text,this.model.protection.locked=this.map["x:Locked"].text,this.model.protection.lockText=this.map["x:LockText"].text}}I.exports=s},{"../base-xform":32,"./style/vml-position-xform":41,"./style/vml-protection-xform":42,"./vml-anchor-xform":43}],45:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("./vml-shape-xform");class t extends i{constructor(){super(),this.map={"v:shape":new e}}get tag(){return"xml"}render(g,I){g.openXml(A.StdDocAttributes),g.openNode(this.tag,t.DRAWING_ATTRIBUTES),g.openNode("o:shapelayout",{"v:ext":"edit"}),g.leafNode("o:idmap",{"v:ext":"edit",data:1}),g.closeNode(),g.openNode("v:shapetype",{id:"_x0000_t202",coordsize:"21600,21600","o:spt":202,path:"m,l,21600r21600,l21600,xe"}),g.leafNode("v:stroke",{joinstyle:"miter"}),g.leafNode("v:path",{gradientshapeok:"t","o:connecttype":"rect"}),g.closeNode(),I.comments.forEach(((I,C)=>{this.map["v:shape"].render(g,I,C)})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={comments:[]}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0):g!==this.tag}reconcile(g,I){g.anchors.forEach((g=>{g.br?this.map["xdr:twoCellAnchor"].reconcile(g,I):this.map["xdr:oneCellAnchor"].reconcile(g,I)}))}}t.DRAWING_ATTRIBUTES={"xmlns:v":"urn:schemas-microsoft-com:vml","xmlns:o":"urn:schemas-microsoft-com:office:office","xmlns:x":"urn:schemas-microsoft-com:office:excel"},I.exports=t},{"../../../utils/xml-stream":28,"../base-xform":32,"./vml-shape-xform":46}],46:[function(g,I,C){const A=g("../base-xform"),i=g("./vml-textbox-xform"),e=g("./vml-client-data-xform");class t extends A{constructor(){super(),this.map={"v:textbox":new i,"x:ClientData":new e}}get tag(){return"v:shape"}render(g,I,C){g.openNode("v:shape",t.V_SHAPE_ATTRIBUTES(I,C)),g.leafNode("v:fill",{color2:"infoBackground [80]"}),g.leafNode("v:shadow",{color:"none [81]",obscured:"t"}),g.leafNode("v:path",{"o:connecttype":"none"}),this.map["v:textbox"].render(g,I),this.map["x:ClientData"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={margins:{insetmode:g.attributes["o:insetmode"]},anchor:"",editAs:"",protection:{}}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.margins.inset=this.map["v:textbox"].model&&this.map["v:textbox"].model.inset,this.model.protection=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.protection,this.model.anchor=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.anchor,this.model.editAs=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.editAs,!1)}}t.V_SHAPE_ATTRIBUTES=(g,I)=>({id:`_x0000_s${1025+I}`,type:"#_x0000_t202",style:"position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden",fillcolor:"infoBackground [80]",strokecolor:"none [81]","o:insetmode":g.note.margins&&g.note.margins.insetmode}),I.exports=t},{"../base-xform":32,"./vml-client-data-xform":44,"./vml-textbox-xform":47}],47:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"v:textbox"}conversionUnit(g,I,C){return`${parseFloat(g)*I.toFixed(2)}${C}`}reverseConversionUnit(g){return(g||"").split(",").map((g=>Number(parseFloat(this.conversionUnit(parseFloat(g),.1,"")).toFixed(2))))}render(g,I){const C={style:"mso-direction-alt:auto"};if(I&&I.note){let{inset:g}=I.note&&I.note.margins;Array.isArray(g)&&(g=g.map((g=>this.conversionUnit(g,10,"mm"))).join(",")),g&&(C.inset=g)}g.openNode("v:textbox",C),g.leafNode("div",{style:"text-align:left"}),g.closeNode()}parseOpen(g){return g.name!==this.tag||(this.model={inset:this.reverseConversionUnit(g.attributes.inset)},!0)}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],48:[function(g,I,C){const A=g("./base-xform");class i extends A{createNewModel(g){return{}}parseOpen(g){return this.parser=this.parser||this.map[g.name],this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag&&(this.model=this.createNewModel(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}onParserClose(g,I){this.model[g]=I.model}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.onParserClose(g,this.parser),this.parser=void 0),!0):g!==this.tag}}I.exports=i},{"./base-xform":32}],49:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.openNode("HeadingPairs"),g.openNode("vt:vector",{size:2,baseType:"variant"}),g.openNode("vt:variant"),g.leafNode("vt:lpstr",void 0,"Worksheets"),g.closeNode(),g.openNode("vt:variant"),g.leafNode("vt:i4",void 0,I.length),g.closeNode(),g.closeNode(),g.closeNode()}parseOpen(g){return"HeadingPairs"===g.name}parseText(){}parseClose(g){return"HeadingPairs"!==g}}I.exports=i},{"../base-xform":32}],50:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.openNode("TitlesOfParts"),g.openNode("vt:vector",{size:I.length,baseType:"lpstr"}),I.forEach((I=>{g.leafNode("vt:lpstr",void 0,I.name)})),g.closeNode(),g.closeNode()}parseOpen(g){return"TitlesOfParts"===g.name}parseText(){}parseClose(g){return"TitlesOfParts"!==g}}I.exports=i},{"../base-xform":32}],51:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("../simple/string-xform"),t=g("./app-heading-pairs-xform"),l=g("./app-titles-of-parts-xform");class s extends i{constructor(){super(),this.map={Company:new e({tag:"Company"}),Manager:new e({tag:"Manager"}),HeadingPairs:new t,TitleOfParts:new l}}render(g,I){g.openXml(A.StdDocAttributes),g.openNode("Properties",s.PROPERTY_ATTRIBUTES),g.leafNode("Application",void 0,"Microsoft Excel"),g.leafNode("DocSecurity",void 0,"0"),g.leafNode("ScaleCrop",void 0,"false"),this.map.HeadingPairs.render(g,I.worksheets),this.map.TitleOfParts.render(g,I.worksheets),this.map.Company.render(g,I.company||""),this.map.Manager.render(g,I.manager),g.leafNode("LinksUpToDate",void 0,"false"),g.leafNode("SharedDoc",void 0,"false"),g.leafNode("HyperlinksChanged",void 0,"false"),g.leafNode("AppVersion",void 0,"16.0300"),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"Properties"===g.name||(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):"Properties"!==g||(this.model={worksheets:this.map.TitleOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1)}}s.DateFormat=function(g){return g.toISOString().replace(/[.]\d{3,6}/,"")},s.DateAttrs={"xsi:type":"dcterms:W3CDTF"},s.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties","xmlns:vt":"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"},I.exports=s},{"../../../utils/xml-stream":28,"../base-xform":32,"../simple/string-xform":119,"./app-heading-pairs-xform":49,"./app-titles-of-parts-xform":50}],52:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform");class e extends i{render(g,I){g.openXml(A.StdDocAttributes),g.openNode("Types",e.PROPERTY_ATTRIBUTES);const C={};(I.media||[]).forEach((I=>{if("image"===I.type){const A=I.extension;C[A]||(C[A]=!0,g.leafNode("Default",{Extension:A,ContentType:`image/${A}`}))}})),g.leafNode("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),g.leafNode("Default",{Extension:"xml",ContentType:"application/xml"}),g.leafNode("Override",{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}),I.worksheets.forEach((I=>{const C=`/xl/worksheets/sheet${I.id}.xml`;g.leafNode("Override",{PartName:C,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"})})),g.leafNode("Override",{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}),g.leafNode("Override",{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"}),I.sharedStrings&&I.sharedStrings.count&&g.leafNode("Override",{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}),I.tables&&I.tables.forEach((I=>{g.leafNode("Override",{PartName:`/xl/tables/${I.target}`,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"})})),I.drawings&&I.drawings.forEach((I=>{g.leafNode("Override",{PartName:`/xl/drawings/${I.name}.xml`,ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})})),I.commentRefs&&(g.leafNode("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}),I.commentRefs.forEach((I=>{let{commentName:C}=I;g.leafNode("Override",{PartName:`/xl/${C}.xml`,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"})}))),g.leafNode("Override",{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}),g.leafNode("Override",{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}),g.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}}e.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},I.exports=e},{"../../../utils/xml-stream":28,"../base-xform":32}],53:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("../simple/date-xform"),t=g("../simple/string-xform"),l=g("../simple/integer-xform");class s extends i{constructor(){super(),this.map={"dc:creator":new t({tag:"dc:creator"}),"dc:title":new t({tag:"dc:title"}),"dc:subject":new t({tag:"dc:subject"}),"dc:description":new t({tag:"dc:description"}),"dc:identifier":new t({tag:"dc:identifier"}),"dc:language":new t({tag:"dc:language"}),"cp:keywords":new t({tag:"cp:keywords"}),"cp:category":new t({tag:"cp:category"}),"cp:lastModifiedBy":new t({tag:"cp:lastModifiedBy"}),"cp:lastPrinted":new e({tag:"cp:lastPrinted",format:s.DateFormat}),"cp:revision":new l({tag:"cp:revision"}),"cp:version":new t({tag:"cp:version"}),"cp:contentStatus":new t({tag:"cp:contentStatus"}),"cp:contentType":new t({tag:"cp:contentType"}),"dcterms:created":new e({tag:"dcterms:created",attrs:s.DateAttrs,format:s.DateFormat}),"dcterms:modified":new e({tag:"dcterms:modified",attrs:s.DateAttrs,format:s.DateFormat})}}render(g,I){g.openXml(A.StdDocAttributes),g.openNode("cp:coreProperties",s.CORE_PROPERTY_ATTRIBUTES),this.map["dc:creator"].render(g,I.creator),this.map["dc:title"].render(g,I.title),this.map["dc:subject"].render(g,I.subject),this.map["dc:description"].render(g,I.description),this.map["dc:identifier"].render(g,I.identifier),this.map["dc:language"].render(g,I.language),this.map["cp:keywords"].render(g,I.keywords),this.map["cp:category"].render(g,I.category),this.map["cp:lastModifiedBy"].render(g,I.lastModifiedBy),this.map["cp:lastPrinted"].render(g,I.lastPrinted),this.map["cp:revision"].render(g,I.revision),this.map["cp:version"].render(g,I.version),this.map["cp:contentStatus"].render(g,I.contentStatus),this.map["cp:contentType"].render(g,I.contentType),this.map["dcterms:created"].render(g,I.created),this.map["dcterms:modified"].render(g,I.modified),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"cp:coreProperties":case"coreProperties":return!0;default:if(this.parser=this.map[g.name],this.parser)return this.parser.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;switch(g){case"cp:coreProperties":case"coreProperties":return this.model={creator:this.map["dc:creator"].model,title:this.map["dc:title"].model,subject:this.map["dc:subject"].model,description:this.map["dc:description"].model,identifier:this.map["dc:identifier"].model,language:this.map["dc:language"].model,keywords:this.map["cp:keywords"].model,category:this.map["cp:category"].model,lastModifiedBy:this.map["cp:lastModifiedBy"].model,lastPrinted:this.map["cp:lastPrinted"].model,revision:this.map["cp:revision"].model,contentStatus:this.map["cp:contentStatus"].model,contentType:this.map["cp:contentType"].model,created:this.map["dcterms:created"].model,modified:this.map["dcterms:modified"].model},!1;default:throw new Error(`Unexpected xml node in parseClose: ${g}`)}}}s.DateFormat=function(g){return g.toISOString().replace(/[.]\d{3}/,"")},s.DateAttrs={"xsi:type":"dcterms:W3CDTF"},s.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:dcterms":"http://purl.org/dc/terms/","xmlns:dcmitype":"http://purl.org/dc/dcmitype/","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance"},I.exports=s},{"../../../utils/xml-stream":28,"../base-xform":32,"../simple/date-xform":117,"../simple/integer-xform":118,"../simple/string-xform":119}],54:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.leafNode("Relationship",I)}parseOpen(g){return"Relationship"===g.name&&(this.model=g.attributes,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],55:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("./relationship-xform");class t extends i{constructor(){super(),this.map={Relationship:new e}}render(g,I){I=I||this._values,g.openXml(A.StdDocAttributes),g.openNode("Relationships",t.RELATIONSHIPS_ATTRIBUTES),I.forEach((I=>{this.map.Relationship.render(g,I)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;if("Relationships"===g.name)return this.model=[],!0;if(this.parser=this.map[g.name],this.parser)return this.parser.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.model.push(this.parser.model),this.parser=void 0),!0;if("Relationships"===g)return!1;throw new Error(`Unexpected xml node in parseClose: ${g}`)}}t.RELATIONSHIPS_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},I.exports=t},{"../../../utils/xml-stream":28,"../base-xform":32,"./relationship-xform":54}],56:[function(g,I,C){const A=g("../base-xform");class i extends A{parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={range:{editAs:g.attributes.editAs||"oneCell"}}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}reconcilePicture(g,I){if(g&&g.rId){const C=I.rels[g.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(C){const g=C[1],A=I.mediaIndex[g];return I.media[A]}}}}I.exports=i},{"../base-xform":32}],57:[function(g,I,C){const A=g("../base-xform"),i=g("./blip-xform");class e extends A{constructor(){super(),this.map={"a:blip":new i}}get tag(){return"xdr:blipFill"}render(g,I){g.openNode(this.tag),this.map["a:blip"].render(g,I),g.openNode("a:stretch"),g.leafNode("a:fillRect"),g.closeNode(),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model=this.map["a:blip"].model,!1)}}I.exports=e},{"../base-xform":32,"./blip-xform":58}],58:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"a:blip"}render(g,I){g.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":I.rId,cstate:"print"})}parseOpen(g){return g.name!==this.tag||(this.model={rId:g.attributes["r:embed"]},!0)}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],59:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"xdr:cNvPicPr"}render(g){g.openNode(this.tag),g.leafNode("a:picLocks",{noChangeAspect:"1"}),g.closeNode()}parseOpen(g){return g.name,this.tag,!0}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],60:[function(g,I,C){const A=g("../base-xform"),i=g("./hlink-click-xform"),e=g("./ext-lst-xform");class t extends A{constructor(){super(),this.map={"a:hlinkClick":new i,"a:extLst":new e}}get tag(){return"xdr:cNvPr"}render(g,I){g.openNode(this.tag,{id:I.index,name:`Picture ${I.index}`}),this.map["a:hlinkClick"].render(g,I),this.map["a:extLst"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model=this.map["a:hlinkClick"].model,!1)}}I.exports=t},{"../base-xform":32,"./ext-lst-xform":63,"./hlink-click-xform":65}],61:[function(g,I,C){const A=g("../base-xform"),i=g("../simple/integer-xform");class e extends A{constructor(g){super(),this.tag=g.tag,this.map={"xdr:col":new i({tag:"xdr:col",zero:!0}),"xdr:colOff":new i({tag:"xdr:colOff",zero:!0}),"xdr:row":new i({tag:"xdr:row",zero:!0}),"xdr:rowOff":new i({tag:"xdr:rowOff",zero:!0})}}render(g,I){g.openNode(this.tag),this.map["xdr:col"].render(g,I.nativeCol),this.map["xdr:colOff"].render(g,I.nativeColOff),this.map["xdr:row"].render(g,I.nativeRow),this.map["xdr:rowOff"].render(g,I.nativeRowOff),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model={nativeCol:this.map["xdr:col"].model,nativeColOff:this.map["xdr:colOff"].model,nativeRow:this.map["xdr:row"].model,nativeRowOff:this.map["xdr:rowOff"].model},!1)}}I.exports=e},{"../base-xform":32,"../simple/integer-xform":118}],62:[function(g,I,C){const A=g("../../../utils/col-cache"),i=g("../../../utils/xml-stream"),e=g("../base-xform"),t=g("./two-cell-anchor-xform"),l=g("./one-cell-anchor-xform");function s(g){return("string"==typeof g.range?A.decode(g.range):g.range).br?"xdr:twoCellAnchor":"xdr:oneCellAnchor"}class o extends e{constructor(){super(),this.map={"xdr:twoCellAnchor":new t,"xdr:oneCellAnchor":new l}}prepare(g){g.anchors.forEach(((g,I)=>{g.anchorType=s(g),this.map[g.anchorType].prepare(g,{index:I})}))}get tag(){return"xdr:wsDr"}render(g,I){g.openXml(i.StdDocAttributes),g.openNode(this.tag,o.DRAWING_ATTRIBUTES),I.anchors.forEach((I=>{this.map[I.anchorType].render(g,I)})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={anchors:[]}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0):g!==this.tag}reconcile(g,I){g.anchors.forEach((g=>{g.br?this.map["xdr:twoCellAnchor"].reconcile(g,I):this.map["xdr:oneCellAnchor"].reconcile(g,I)}))}}o.DRAWING_ATTRIBUTES={"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},I.exports=o},{"../../../utils/col-cache":19,"../../../utils/xml-stream":28,"../base-xform":32,"./one-cell-anchor-xform":67,"./two-cell-anchor-xform":70}],63:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"a:extLst"}render(g){g.openNode(this.tag),g.openNode("a:ext",{uri:"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"}),g.leafNode("a16:creationId",{"xmlns:a16":"http://schemas.microsoft.com/office/drawing/2014/main",id:"{00000000-0008-0000-0000-000002000000}"}),g.closeNode(),g.closeNode()}parseOpen(g){return g.name,this.tag,!0}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],64:[function(g,I,C){const A=g("../base-xform"),i=9525;class e extends A{constructor(g){super(),this.tag=g.tag,this.map={}}render(g,I){g.openNode(this.tag);const C=Math.floor(I.width*i),A=Math.floor(I.height*i);g.addAttribute("cx",C),g.addAttribute("cy",A),g.closeNode()}parseOpen(g){return g.name===this.tag&&(this.model={width:parseInt(g.attributes.cx||"0",10)/i,height:parseInt(g.attributes.cy||"0",10)/i},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../base-xform":32}],65:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"a:hlinkClick"}render(g,I){I.hyperlinks&&I.hyperlinks.rId&&g.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":I.hyperlinks.rId,tooltip:I.hyperlinks.tooltip})}parseOpen(g){return g.name!==this.tag||(this.model={hyperlinks:{rId:g.attributes["r:id"],tooltip:g.attributes.tooltip}},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],66:[function(g,I,C){const A=g("../base-xform"),i=g("./c-nv-pr-xform"),e=g("./c-nv-pic-pr-xform");class t extends A{constructor(){super(),this.map={"xdr:cNvPr":new i,"xdr:cNvPicPr":new e}}get tag(){return"xdr:nvPicPr"}render(g,I){g.openNode(this.tag),this.map["xdr:cNvPr"].render(g,I),this.map["xdr:cNvPicPr"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model=this.map["xdr:cNvPr"].model,!1)}}I.exports=t},{"../base-xform":32,"./c-nv-pic-pr-xform":59,"./c-nv-pr-xform":60}],67:[function(g,I,C){const A=g("./base-cell-anchor-xform"),i=g("../static-xform"),e=g("./cell-position-xform"),t=g("./ext-xform"),l=g("./pic-xform");class s extends A{constructor(){super(),this.map={"xdr:from":new e({tag:"xdr:from"}),"xdr:ext":new t({tag:"xdr:ext"}),"xdr:pic":new l,"xdr:clientData":new i({tag:"xdr:clientData"})}}get tag(){return"xdr:oneCellAnchor"}prepare(g,I){this.map["xdr:pic"].prepare(g.picture,I)}render(g,I){g.openNode(this.tag,{editAs:I.range.editAs||"oneCell"}),this.map["xdr:from"].render(g,I.range.tl),this.map["xdr:ext"].render(g,I.range.ext),this.map["xdr:pic"].render(g,I.picture),this.map["xdr:clientData"].render(g,{}),g.closeNode()}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.range.tl=this.map["xdr:from"].model,this.model.range.ext=this.map["xdr:ext"].model,this.model.picture=this.map["xdr:pic"].model,!1)}reconcile(g,I){g.medium=this.reconcilePicture(g.picture,I)}}I.exports=s},{"../static-xform":120,"./base-cell-anchor-xform":56,"./cell-position-xform":61,"./ext-xform":64,"./pic-xform":68}],68:[function(g,I,C){const A=g("../base-xform"),i=g("../static-xform"),e=g("./blip-fill-xform"),t=g("./nv-pic-pr-xform"),l=g("./sp-pr");class s extends A{constructor(){super(),this.map={"xdr:nvPicPr":new t,"xdr:blipFill":new e,"xdr:spPr":new i(l)}}get tag(){return"xdr:pic"}prepare(g,I){g.index=I.index+1}render(g,I){g.openNode(this.tag),this.map["xdr:nvPicPr"].render(g,I),this.map["xdr:blipFill"].render(g,I),this.map["xdr:spPr"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.mergeModel(this.parser.model),this.parser=void 0),!0):g!==this.tag}}I.exports=s},{"../base-xform":32,"../static-xform":120,"./blip-fill-xform":57,"./nv-pic-pr-xform":66,"./sp-pr":69}],69:[function(g,I,C){I.exports={tag:"xdr:spPr",c:[{tag:"a:xfrm",c:[{tag:"a:off",$:{x:"0",y:"0"}},{tag:"a:ext",$:{cx:"0",cy:"0"}}]},{tag:"a:prstGeom",$:{prst:"rect"},c:[{tag:"a:avLst"}]}]}},{}],70:[function(g,I,C){const A=g("./base-cell-anchor-xform"),i=g("../static-xform"),e=g("./cell-position-xform"),t=g("./pic-xform");class l extends A{constructor(){super(),this.map={"xdr:from":new e({tag:"xdr:from"}),"xdr:to":new e({tag:"xdr:to"}),"xdr:pic":new t,"xdr:clientData":new i({tag:"xdr:clientData"})}}get tag(){return"xdr:twoCellAnchor"}prepare(g,I){this.map["xdr:pic"].prepare(g.picture,I)}render(g,I){g.openNode(this.tag,{editAs:I.range.editAs||"oneCell"}),this.map["xdr:from"].render(g,I.range.tl),this.map["xdr:to"].render(g,I.range.br),this.map["xdr:pic"].render(g,I.picture),this.map["xdr:clientData"].render(g,{}),g.closeNode()}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.range.tl=this.map["xdr:from"].model,this.model.range.br=this.map["xdr:to"].model,this.model.picture=this.map["xdr:pic"].model,!1)}reconcile(g,I){g.medium=this.reconcilePicture(g.picture,I)}}I.exports=l},{"../static-xform":120,"./base-cell-anchor-xform":56,"./cell-position-xform":61,"./pic-xform":68}],71:[function(g,I,C){const A=g("./base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.always=!!g.always,this.count=g.count,this.empty=g.empty,this.$count=g.$count||"count",this.$=g.$,this.childXform=g.childXform,this.maxItems=g.maxItems}prepare(g,I){const{childXform:C}=this;g&&g.forEach(((g,A)=>{I.index=A,C.prepare(g,I)}))}render(g,I){if(this.always||I&&I.length){g.openNode(this.tag,this.$),this.count&&g.addAttribute(this.$count,I&&I.length||0);const{childXform:C}=this;(I||[]).forEach(((I,A)=>{C.render(g,I,A)})),g.closeNode()}else this.empty&&g.leafNode(this.tag)}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag?(this.model=[],!0):!!this.childXform.parseOpen(g)&&(this.parser=this.childXform,!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new Error(`Max ${this.childXform.tag} count (${this.maxItems}) exceeded`);return!0}return!1}reconcile(g,I){if(g){const{childXform:C}=this;g.forEach((g=>{C.reconcile(g,I)}))}}}I.exports=i},{"./base-xform":32}],72:[function(g,I,C){const A=g("../../../utils/col-cache"),i=g("../base-xform");class e extends i{get tag(){return"autoFilter"}render(g,I){if(I)if("string"==typeof I)g.leafNode("autoFilter",{ref:I});else{const C=function(g){return"string"==typeof g?g:A.getAddress(g.row,g.column).address},i=C(I.from),e=C(I.to);i&&e&&g.leafNode("autoFilter",{ref:`${i}:${e}`})}}parseOpen(g){"autoFilter"===g.name&&(this.model=g.attributes.ref)}}I.exports=e},{"../../../utils/col-cache":19,"../base-xform":32}],73:[function(g,I,C){const A=g("../../../utils/utils"),i=g("../base-xform"),e=g("../../../doc/range"),t=g("../../../doc/enums"),l=g("../strings/rich-text-xform");function s(g){if(null==g)return t.ValueType.Null;if(g instanceof String||"string"==typeof g)return t.ValueType.String;if("number"==typeof g)return t.ValueType.Number;if("boolean"==typeof g)return t.ValueType.Boolean;if(g instanceof Date)return t.ValueType.Date;if(g.text&&g.hyperlink)return t.ValueType.Hyperlink;if(g.formula)return t.ValueType.Formula;if(g.error)return t.ValueType.Error;throw new Error("I could not understand type of value")}function o(g){return g.type===t.ValueType.Formula?s(g.result):g.type}class c extends i{constructor(){super(),this.richTextXForm=new l}get tag(){return"c"}prepare(g,I){const C=I.styles.addStyleModel(g.style||{},o(g));switch(C&&(g.styleId=C),g.comment&&I.comments.push({...g.comment,ref:g.address}),g.type){case t.ValueType.String:case t.ValueType.RichText:I.sharedStrings&&(g.ssId=I.sharedStrings.add(g.value));break;case t.ValueType.Date:I.date1904&&(g.date1904=!0);break;case t.ValueType.Hyperlink:I.sharedStrings&&void 0!==g.text&&null!==g.text&&(g.ssId=I.sharedStrings.add(g.text)),I.hyperlinks.push({address:g.address,target:g.hyperlink,tooltip:g.tooltip});break;case t.ValueType.Merge:I.merges.add(g);break;case t.ValueType.Formula:if(I.date1904&&(g.date1904=!0),"shared"===g.shareType&&(g.si=I.siFormulae++),g.formula)I.formulae[g.address]=g;else if(g.sharedFormula){const C=I.formulae[g.sharedFormula];if(!C)throw new Error(`Shared Formula master must exist above and or left of clone for cell ${g.address}`);void 0===C.si?(C.shareType="shared",C.si=I.siFormulae++,C.range=new e(C.address,g.address)):C.range&&C.range.expandToAddress(g.address),g.si=C.si}}}renderFormula(g,I){let C=null;switch(I.shareType){case"shared":C={t:"shared",ref:I.ref||I.range.range,si:I.si};break;case"array":C={t:"array",ref:I.ref};break;default:void 0!==I.si&&(C={t:"shared",si:I.si})}switch(s(I.result)){case t.ValueType.Null:g.leafNode("f",C,I.formula);break;case t.ValueType.String:g.addAttribute("t","str"),g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result);break;case t.ValueType.Number:g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result);break;case t.ValueType.Boolean:g.addAttribute("t","b"),g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result?1:0);break;case t.ValueType.Error:g.addAttribute("t","e"),g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result.error);break;case t.ValueType.Date:g.leafNode("f",C,I.formula),g.leafNode("v",null,A.dateToExcel(I.result,I.date1904));break;default:throw new Error("I could not understand type of value")}}render(g,I){if(I.type!==t.ValueType.Null||I.styleId){switch(g.openNode("c"),g.addAttribute("r",I.address),I.styleId&&g.addAttribute("s",I.styleId),I.type){case t.ValueType.Null:break;case t.ValueType.Number:g.leafNode("v",null,I.value);break;case t.ValueType.Boolean:g.addAttribute("t","b"),g.leafNode("v",null,I.value?"1":"0");break;case t.ValueType.Error:g.addAttribute("t","e"),g.leafNode("v",null,I.value.error);break;case t.ValueType.String:case t.ValueType.RichText:void 0!==I.ssId?(g.addAttribute("t","s"),g.leafNode("v",null,I.ssId)):I.value&&I.value.richText?(g.addAttribute("t","inlineStr"),g.openNode("is"),I.value.richText.forEach((I=>{this.richTextXForm.render(g,I)})),g.closeNode("is")):(g.addAttribute("t","str"),g.leafNode("v",null,I.value));break;case t.ValueType.Date:g.leafNode("v",null,A.dateToExcel(I.value,I.date1904));break;case t.ValueType.Hyperlink:void 0!==I.ssId?(g.addAttribute("t","s"),g.leafNode("v",null,I.ssId)):(g.addAttribute("t","str"),g.leafNode("v",null,I.text));break;case t.ValueType.Formula:this.renderFormula(g,I);case t.ValueType.Merge:}g.closeNode()}}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"c":return this.model={address:g.attributes.r},this.t=g.attributes.t,g.attributes.s&&(this.model.styleId=parseInt(g.attributes.s,10)),!0;case"f":return this.currentNode="f",this.model.si=g.attributes.si,this.model.shareType=g.attributes.t,this.model.ref=g.attributes.ref,!0;case"v":return this.currentNode="v",!0;case"t":return this.currentNode="t",!0;case"r":return this.parser=this.richTextXForm,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){if(this.parser)this.parser.parseText(g);else switch(this.currentNode){case"f":this.model.formula=this.model.formula?this.model.formula+g:g;break;case"v":case"t":this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+g:g:this.model.value=this.model.value?this.model.value+g:g}}parseClose(g){switch(g){case"c":{const{model:g}=this;if(g.formula||g.shareType)g.type=t.ValueType.Formula,g.value&&("str"===this.t?g.result=A.xmlDecode(g.value):"b"===this.t?g.result=0!==parseInt(g.value,10):"e"===this.t?g.result={error:g.value}:g.result=parseFloat(g.value),g.value=void 0);else if(void 0!==g.value)switch(this.t){case"s":g.type=t.ValueType.String,g.value=parseInt(g.value,10);break;case"str":g.type=t.ValueType.String,g.value=A.xmlDecode(g.value);break;case"inlineStr":g.type=t.ValueType.String;break;case"b":g.type=t.ValueType.Boolean,g.value=0!==parseInt(g.value,10);break;case"e":g.type=t.ValueType.Error,g.value={error:g.value};break;default:g.type=t.ValueType.Number,g.value=parseFloat(g.value)}else g.styleId?g.type=t.ValueType.Null:g.type=t.ValueType.Merge;return!1}case"f":case"v":case"is":return this.currentNode=void 0,!0;case"t":return this.parser?(this.parser.parseClose(g),!0):(this.currentNode=void 0,!0);case"r":return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText||[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return!!this.parser&&(this.parser.parseClose(g),!0)}}reconcile(g,I){const C=g.styleId&&I.styles&&I.styles.getStyleModel(g.styleId);switch(C&&(g.style=C),void 0!==g.styleId&&(g.styleId=void 0),g.type){case t.ValueType.String:"number"==typeof g.value&&I.sharedStrings&&(g.value=I.sharedStrings.getString(g.value)),g.value.richText&&(g.type=t.ValueType.RichText);break;case t.ValueType.Number:C&&A.isDateFmt(C.numFmt)&&(g.type=t.ValueType.Date,g.value=A.excelToDate(g.value,I.date1904));break;case t.ValueType.Formula:void 0!==g.result&&C&&A.isDateFmt(C.numFmt)&&(g.result=A.excelToDate(g.result,I.date1904)),"shared"===g.shareType&&(g.ref?I.formulae[g.si]=g.address:(g.sharedFormula=I.formulae[g.si],delete g.shareType),delete g.si)}const i=I.hyperlinkMap[g.address];i&&(g.type===t.ValueType.Formula?(g.text=g.result,g.result=void 0):(g.text=g.value,g.value=void 0),g.type=t.ValueType.Hyperlink,g.hyperlink=i);const e=I.commentsMap&&I.commentsMap[g.address];e&&(g.comment=e)}}I.exports=c},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/utils":27,"../base-xform":32,"../strings/rich-text-xform":122}],74:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"x14:cfIcon"}render(g,I){g.leafNode(this.tag,{iconSet:I.iconSet,iconId:I.iconId})}parseOpen(g){let{attributes:I}=g;this.model={iconSet:I.iconSet,iconId:A.toIntValue(I.iconId)}}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],75:[function(g,I,C){const{v4:A}=g("uuid"),i=g("../../base-xform"),e=g("../../composite-xform"),t=g("./databar-ext-xform"),l=g("./icon-set-ext-xform"),s={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};class o extends e{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new t,"x14:iconSet":this.iconSetXform=new l}}get tag(){return"x14:cfRule"}static isExt(g){return"dataBar"===g.type?t.isExt(g):!("iconSet"!==g.type||!g.custom&&!s[g.iconSet])}prepare(g){o.isExt(g)&&(g.x14Id=`{${A()}}`.toUpperCase())}render(g,I){if(o.isExt(I))switch(I.type){case"dataBar":this.renderDataBar(g,I);break;case"iconSet":this.renderIconSet(g,I)}}renderDataBar(g,I){g.openNode(this.tag,{type:"dataBar",id:I.x14Id}),this.databarXform.render(g,I),g.closeNode()}renderIconSet(g,I){g.openNode(this.tag,{type:"iconSet",priority:I.priority,id:I.x14Id||`{${A()}}`}),this.iconSetXform.render(g,I),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{type:I.type,x14Id:I.id,priority:i.toIntValue(I.priority)}}onParserClose(g,I){Object.assign(this.model,I.model)}}I.exports=o},{"../../base-xform":32,"../../composite-xform":48,"./databar-ext-xform":79,"./icon-set-ext-xform":81,uuid:528}],76:[function(g,I,C){const A=g("../../composite-xform"),i=g("./f-ext-xform");class e extends A{constructor(){super(),this.map={"xm:f":this.fExtXform=new i}}get tag(){return"x14:cfvo"}render(g,I){g.openNode(this.tag,{type:I.type}),void 0!==I.value&&this.fExtXform.render(g,I.value),g.closeNode()}createNewModel(g){return{type:g.attributes.type}}onParserClose(g,I){"xm:f"===g&&(this.model.value=I.model?parseFloat(I.model):0)}}I.exports=e},{"../../composite-xform":48,"./f-ext-xform":80}],77:[function(g,I,C){const A=g("../../composite-xform"),i=g("./sqref-ext-xform"),e=g("./cf-rule-ext-xform");class t extends A{constructor(){super(),this.map={"xm:sqref":this.sqRef=new i,"x14:cfRule":this.cfRule=new e}}get tag(){return"x14:conditionalFormatting"}prepare(g,I){g.rules.forEach((g=>{this.cfRule.prepare(g,I)}))}render(g,I){I.rules.some(e.isExt)&&(g.openNode(this.tag,{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"}),I.rules.filter(e.isExt).forEach((I=>this.cfRule.render(g,I))),this.sqRef.render(g,I.ref),g.closeNode())}createNewModel(){return{rules:[]}}onParserClose(g,I){switch(g){case"xm:sqref":this.model.ref=I.model;break;case"x14:cfRule":this.model.rules.push(I.model)}}}I.exports=t},{"../../composite-xform":48,"./cf-rule-ext-xform":75,"./sqref-ext-xform":82}],78:[function(g,I,C){const A=g("../../composite-xform"),i=g("./cf-rule-ext-xform"),e=g("./conditional-formatting-ext-xform");class t extends A{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new e}}get tag(){return"x14:conditionalFormattings"}hasContent(g){return void 0===g.hasExtContent&&(g.hasExtContent=g.some((g=>g.rules.some(i.isExt)))),g.hasExtContent}prepare(g,I){g.forEach((g=>{this.cfXform.prepare(g,I)}))}render(g,I){this.hasContent(I)&&(g.openNode(this.tag),I.forEach((I=>this.cfXform.render(g,I))),g.closeNode())}createNewModel(){return[]}onParserClose(g,I){this.model.push(I.model)}}I.exports=t},{"../../composite-xform":48,"./cf-rule-ext-xform":75,"./conditional-formatting-ext-xform":77}],79:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("../../style/color-xform"),t=g("./cfvo-ext-xform");class l extends i{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new t,"x14:borderColor":this.borderColorXform=new e("x14:borderColor"),"x14:negativeBorderColor":this.negativeBorderColorXform=new e("x14:negativeBorderColor"),"x14:negativeFillColor":this.negativeFillColorXform=new e("x14:negativeFillColor"),"x14:axisColor":this.axisColorXform=new e("x14:axisColor")}}static isExt(g){return!g.gradient}get tag(){return"x14:dataBar"}render(g,I){g.openNode(this.tag,{minLength:A.toIntAttribute(I.minLength,0,!0),maxLength:A.toIntAttribute(I.maxLength,100,!0),border:A.toBoolAttribute(I.border,!1),gradient:A.toBoolAttribute(I.gradient,!0),negativeBarColorSameAsPositive:A.toBoolAttribute(I.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:A.toBoolAttribute(I.negativeBarBorderColorSameAsPositive,!0),axisPosition:A.toAttribute(I.axisPosition,"auto"),direction:A.toAttribute(I.direction,"leftToRight")}),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),this.borderColorXform.render(g,I.borderColor),this.negativeBorderColorXform.render(g,I.negativeBorderColor),this.negativeFillColorXform.render(g,I.negativeFillColor),this.axisColorXform.render(g,I.axisColor),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{cfvo:[],minLength:A.toIntValue(I.minLength,0),maxLength:A.toIntValue(I.maxLength,100),border:A.toBoolValue(I.border,!1),gradient:A.toBoolValue(I.gradient,!0),negativeBarColorSameAsPositive:A.toBoolValue(I.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:A.toBoolValue(I.negativeBarBorderColorSameAsPositive,!0),axisPosition:A.toStringValue(I.axisPosition,"auto"),direction:A.toStringValue(I.direction,"leftToRight")}}onParserClose(g,I){const[,C]=g.split(":");"cfvo"===C?this.model.cfvo.push(I.model):this.model[C]=I.model}}I.exports=l},{"../../base-xform":32,"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-ext-xform":76}],80:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"xm:f"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],81:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("./cfvo-ext-xform"),t=g("./cf-icon-ext-xform");class l extends i{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new e,"x14:cfIcon":this.cfIconXform=new t}}get tag(){return"x14:iconSet"}render(g,I){g.openNode(this.tag,{iconSet:A.toStringAttribute(I.iconSet),reverse:A.toBoolAttribute(I.reverse,!1),showValue:A.toBoolAttribute(I.showValue,!0),custom:A.toBoolAttribute(I.icons,!1)}),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),I.icons&&I.icons.forEach(((I,C)=>{I.iconId=C,this.cfIconXform.render(g,I)})),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{cfvo:[],iconSet:A.toStringValue(I.iconSet,"3TrafficLights"),reverse:A.toBoolValue(I.reverse,!1),showValue:A.toBoolValue(I.showValue,!0)}}onParserClose(g,I){const[,C]=g.split(":");switch(C){case"cfvo":this.model.cfvo.push(I.model);break;case"cfIcon":this.model.icons||(this.model.icons=[]),this.model.icons.push(I.model);break;default:this.model[C]=I.model}}}I.exports=l},{"../../base-xform":32,"../../composite-xform":48,"./cf-icon-ext-xform":74,"./cfvo-ext-xform":76}],82:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"xm:sqref"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],83:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("../../../../doc/range"),t=g("./databar-xform"),l=g("./ext-lst-ref-xform"),s=g("./formula-xform"),o=g("./color-scale-xform"),c=g("./icon-set-xform"),d={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},a=g=>{if(g.formulae&&g.formulae[0])return g.formulae[0];const I=new e(g.ref),{tl:C}=I;switch(g.operator){case"containsText":return`NOT(ISERROR(SEARCH("${g.text}",${C})))`;case"containsBlanks":return`LEN(TRIM(${C}))=0`;case"notContainsBlanks":return`LEN(TRIM(${C}))>0`;case"containsErrors":return`ISERROR(${C})`;case"notContainsErrors":return`NOT(ISERROR(${C}))`;default:return}},n=g=>{if(g.formulae&&g.formulae[0])return g.formulae[0];const I=new e(g.ref),{tl:C}=I;switch(g.timePeriod){case"thisWeek":return`AND(TODAY()-ROUNDDOWN(${C},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${C},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case"lastWeek":return`AND(TODAY()-ROUNDDOWN(${C},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${C},0)<(WEEKDAY(TODAY())+7))`;case"nextWeek":return`AND(ROUNDDOWN(${C},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${C},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case"yesterday":return`FLOOR(${C},1)=TODAY()-1`;case"today":return`FLOOR(${C},1)=TODAY()`;case"tomorrow":return`FLOOR(${C},1)=TODAY()+1`;case"last7Days":return`AND(TODAY()-FLOOR(${C},1)<=6,FLOOR(${C},1)<=TODAY())`;case"lastMonth":return`AND(MONTH(${C})=MONTH(EDATE(TODAY(),0-1)),YEAR(${C})=YEAR(EDATE(TODAY(),0-1)))`;case"thisMonth":return`AND(MONTH(${C})=MONTH(TODAY()),YEAR(${C})=YEAR(TODAY()))`;case"nextMonth":return`AND(MONTH(${C})=MONTH(EDATE(TODAY(),0+1)),YEAR(${C})=YEAR(EDATE(TODAY(),0+1)))`;default:return}},r=g=>{const{type:I,operator:C}=g;switch(I){case"containsText":case"containsBlanks":case"notContainsBlanks":case"containsErrors":case"notContainsErrors":return{type:"containsText",operator:I};default:return{type:I,operator:C}}};class m extends i{constructor(){super(),this.map={dataBar:this.databarXform=new t,extLst:this.extLstRefXform=new l,formula:this.formulaXform=new s,colorScale:this.colorScaleXform=new o,iconSet:this.iconSetXform=new c}}get tag(){return"cfRule"}static isPrimitive(g){return"iconSet"!==g.type||!g.custom&&!d[g.iconSet]}render(g,I){switch(I.type){case"expression":this.renderExpression(g,I);break;case"cellIs":this.renderCellIs(g,I);break;case"top10":this.renderTop10(g,I);break;case"aboveAverage":this.renderAboveAverage(g,I);break;case"dataBar":this.renderDataBar(g,I);break;case"colorScale":this.renderColorScale(g,I);break;case"iconSet":this.renderIconSet(g,I);break;case"containsText":this.renderText(g,I);break;case"timePeriod":this.renderTimePeriod(g,I)}}renderExpression(g,I){g.openNode(this.tag,{type:"expression",dxfId:I.dxfId,priority:I.priority}),this.formulaXform.render(g,I.formulae[0]),g.closeNode()}renderCellIs(g,I){g.openNode(this.tag,{type:"cellIs",dxfId:I.dxfId,priority:I.priority,operator:I.operator}),I.formulae.forEach((I=>{this.formulaXform.render(g,I)})),g.closeNode()}renderTop10(g,I){g.leafNode(this.tag,{type:"top10",dxfId:I.dxfId,priority:I.priority,percent:A.toBoolAttribute(I.percent,!1),bottom:A.toBoolAttribute(I.bottom,!1),rank:A.toIntValue(I.rank,10,!0)})}renderAboveAverage(g,I){g.leafNode(this.tag,{type:"aboveAverage",dxfId:I.dxfId,priority:I.priority,aboveAverage:A.toBoolAttribute(I.aboveAverage,!0)})}renderDataBar(g,I){g.openNode(this.tag,{type:"dataBar",priority:I.priority}),this.databarXform.render(g,I),this.extLstRefXform.render(g,I),g.closeNode()}renderColorScale(g,I){g.openNode(this.tag,{type:"colorScale",priority:I.priority}),this.colorScaleXform.render(g,I),g.closeNode()}renderIconSet(g,I){m.isPrimitive(I)&&(g.openNode(this.tag,{type:"iconSet",priority:I.priority}),this.iconSetXform.render(g,I),g.closeNode())}renderText(g,I){g.openNode(this.tag,{type:I.operator,dxfId:I.dxfId,priority:I.priority,operator:A.toStringAttribute(I.operator,"containsText")});const C=a(I);C&&this.formulaXform.render(g,C),g.closeNode()}renderTimePeriod(g,I){g.openNode(this.tag,{type:"timePeriod",dxfId:I.dxfId,priority:I.priority,timePeriod:I.timePeriod});const C=n(I);C&&this.formulaXform.render(g,C),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{...r(I),dxfId:A.toIntValue(I.dxfId),priority:A.toIntValue(I.priority),timePeriod:I.timePeriod,percent:A.toBoolValue(I.percent),bottom:A.toBoolValue(I.bottom),rank:A.toIntValue(I.rank),aboveAverage:A.toBoolValue(I.aboveAverage)}}onParserClose(g,I){switch(g){case"dataBar":case"extLst":case"colorScale":case"iconSet":Object.assign(this.model,I.model);break;case"formula":this.model.formulae=this.model.formulae||[],this.model.formulae.push(I.model)}}}I.exports=m},{"../../../../doc/range":10,"../../base-xform":32,"../../composite-xform":48,"./color-scale-xform":85,"./databar-xform":88,"./ext-lst-ref-xform":89,"./formula-xform":90,"./icon-set-xform":91}],84:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"cfvo"}render(g,I){g.leafNode(this.tag,{type:I.type,val:I.value})}parseOpen(g){this.model={type:g.attributes.type,value:A.toFloatValue(g.attributes.val)}}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],85:[function(g,I,C){const A=g("../../composite-xform"),i=g("../../style/color-xform"),e=g("./cfvo-xform");class t extends A{constructor(){super(),this.map={cfvo:this.cfvoXform=new e,color:this.colorXform=new i}}get tag(){return"colorScale"}render(g,I){g.openNode(this.tag),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),I.color.forEach((I=>{this.colorXform.render(g,I)})),g.closeNode()}createNewModel(g){return{cfvo:[],color:[]}}onParserClose(g,I){this.model[g].push(I.model)}}I.exports=t},{"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-xform":84}],86:[function(g,I,C){const A=g("../../composite-xform"),i=g("./cf-rule-xform");class e extends A{constructor(){super(),this.map={cfRule:new i}}get tag(){return"conditionalFormatting"}render(g,I){I.rules.some(i.isPrimitive)&&(g.openNode(this.tag,{sqref:I.ref}),I.rules.forEach((C=>{i.isPrimitive(C)&&(C.ref=I.ref,this.map.cfRule.render(g,C))})),g.closeNode())}createNewModel(g){let{attributes:I}=g;return{ref:I.sqref,rules:[]}}onParserClose(g,I){this.model.rules.push(I.model)}}I.exports=e},{"../../composite-xform":48,"./cf-rule-xform":83}],87:[function(g,I,C){const A=g("../../base-xform"),i=g("./conditional-formatting-xform");class e extends A{constructor(){super(),this.cfXform=new i}get tag(){return"conditionalFormatting"}reset(){this.model=[]}prepare(g,I){let C=g.reduce(((g,I)=>Math.max(g,...I.rules.map((g=>g.priority||0)))),1);g.forEach((g=>{g.rules.forEach((g=>{g.priority||(g.priority=C++),g.style&&(g.dxfId=I.styles.addDxfStyle(g.style))}))}))}render(g,I){I.forEach((I=>{this.cfXform.render(g,I)}))}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"conditionalFormatting"===g.name&&(this.parser=this.cfXform,this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!(!this.parser||!this.parser.parseClose(g)&&(this.model.push(this.parser.model),this.parser=void 0,1))}reconcile(g,I){g.forEach((g=>{g.rules.forEach((g=>{void 0!==g.dxfId&&(g.style=I.styles.getDxfStyle(g.dxfId),delete g.dxfId)}))}))}}I.exports=e},{"../../base-xform":32,"./conditional-formatting-xform":86}],88:[function(g,I,C){const A=g("../../composite-xform"),i=g("../../style/color-xform"),e=g("./cfvo-xform");class t extends A{constructor(){super(),this.map={cfvo:this.cfvoXform=new e,color:this.colorXform=new i}}get tag(){return"dataBar"}render(g,I){g.openNode(this.tag),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),this.colorXform.render(g,I.color),g.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(g,I){switch(g){case"cfvo":this.model.cfvo.push(I.model);break;case"color":this.model.color=I.model}}}I.exports=t},{"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-xform":84}],89:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform");class e extends A{get tag(){return"x14:id"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}class t extends i{constructor(){super(),this.map={"x14:id":this.idXform=new e}}get tag(){return"ext"}render(g,I){g.openNode(this.tag,{uri:"{B025F937-C7B1-47D3-B67F-A62EFF666E3E}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.idXform.render(g,I.x14Id),g.closeNode()}createNewModel(){return{}}onParserClose(g,I){this.model.x14Id=I.model}}class l extends i{constructor(){super(),this.map={ext:new t}}get tag(){return"extLst"}render(g,I){g.openNode(this.tag),this.map.ext.render(g,I),g.closeNode()}createNewModel(){return{}}onParserClose(g,I){Object.assign(this.model,I.model)}}I.exports=l},{"../../base-xform":32,"../../composite-xform":48}],90:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"formula"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],91:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("./cfvo-xform");class t extends i{constructor(){super(),this.map={cfvo:this.cfvoXform=new e}}get tag(){return"iconSet"}render(g,I){g.openNode(this.tag,{iconSet:A.toStringAttribute(I.iconSet,"3TrafficLights"),reverse:A.toBoolAttribute(I.reverse,!1),showValue:A.toBoolAttribute(I.showValue,!0)}),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{iconSet:A.toStringValue(I.iconSet,"3TrafficLights"),reverse:A.toBoolValue(I.reverse),showValue:A.toBoolValue(I.showValue),cfvo:[]}}onParserClose(g,I){this.model[g].push(I.model)}}I.exports=t},{"../../base-xform":32,"../../composite-xform":48,"./cfvo-xform":84}],92:[function(g,I,C){const A=g("../../../utils/utils"),i=g("../base-xform");class e extends i{get tag(){return"col"}prepare(g,I){const C=I.styles.addStyleModel(g.style||{});C&&(g.styleId=C)}render(g,I){g.openNode("col"),g.addAttribute("min",I.min),g.addAttribute("max",I.max),I.width&&g.addAttribute("width",I.width),I.styleId&&g.addAttribute("style",I.styleId),I.hidden&&g.addAttribute("hidden","1"),I.bestFit&&g.addAttribute("bestFit","1"),I.outlineLevel&&g.addAttribute("outlineLevel",I.outlineLevel),I.collapsed&&g.addAttribute("collapsed","1"),g.addAttribute("customWidth","1"),g.closeNode()}parseOpen(g){if("col"===g.name){const I=this.model={min:parseInt(g.attributes.min||"0",10),max:parseInt(g.attributes.max||"0",10),width:void 0===g.attributes.width?void 0:parseFloat(g.attributes.width||"0")};return g.attributes.style&&(I.styleId=parseInt(g.attributes.style,10)),A.parseBoolean(g.attributes.hidden)&&(I.hidden=!0),A.parseBoolean(g.attributes.bestFit)&&(I.bestFit=!0),g.attributes.outlineLevel&&(I.outlineLevel=parseInt(g.attributes.outlineLevel,10)),A.parseBoolean(g.attributes.collapsed)&&(I.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(g,I){g.styleId&&(g.style=I.styles.getStyleModel(g.styleId))}}I.exports=e},{"../../../utils/utils":27,"../base-xform":32}],93:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../utils/utils"),e=g("../../../utils/col-cache"),t=g("../base-xform"),l=g("../../../doc/range");function s(g,I,C,A){const i=I[C];void 0!==i?g[C]=i:void 0!==A&&(g[C]=A)}function o(g,I,C,A){const e=I[C];void 0!==e&&(g[C]=i.parseBoolean(e))}function c(g){const I=A.map(g,((g,I)=>({address:I,dataValidation:g,marked:!1}))).sort(((g,I)=>A.strcmp(g.address,I.address))),C=A.keyBy(I,"address"),i=(I,C,i)=>{for(let t=0;t{if(!I.marked){const t=e.decodeEx(I.address);if(t.dimensions)return C[t.dimensions].marked=!0,{...I.dataValidation,sqref:I.address};let l=1,s=e.encodeAddress(t.row+l,t.col);for(;g[s]&&A.isEqual(I.dataValidation,g[s]);)l++,s=e.encodeAddress(t.row+l,t.col);let o=1;for(;i(t,l,t.col+o);)o++;for(let g=0;g1||o>1){const g=t.row+(l-1),C=t.col+(o-1);return{...I.dataValidation,sqref:`${I.address}:${e.encodeAddress(g,C)}`}}return{...I.dataValidation,sqref:I.address}}return null})).filter(Boolean)}class d extends t{get tag(){return"dataValidations"}render(g,I){const C=c(I);C.length&&(g.openNode("dataValidations",{count:C.length}),C.forEach((I=>{g.openNode("dataValidation"),"any"!==I.type&&(g.addAttribute("type",I.type),I.operator&&"list"!==I.type&&"between"!==I.operator&&g.addAttribute("operator",I.operator),I.allowBlank&&g.addAttribute("allowBlank","1")),I.showInputMessage&&g.addAttribute("showInputMessage","1"),I.promptTitle&&g.addAttribute("promptTitle",I.promptTitle),I.prompt&&g.addAttribute("prompt",I.prompt),I.showErrorMessage&&g.addAttribute("showErrorMessage","1"),I.errorStyle&&g.addAttribute("errorStyle",I.errorStyle),I.errorTitle&&g.addAttribute("errorTitle",I.errorTitle),I.error&&g.addAttribute("error",I.error),g.addAttribute("sqref",I.sqref),(I.formulae||[]).forEach(((C,A)=>{g.openNode(`formula${A+1}`),"date"===I.type?g.writeText(i.dateToExcel(new Date(C))):g.writeText(C),g.closeNode()})),g.closeNode()})),g.closeNode())}parseOpen(g){switch(g.name){case"dataValidations":return this.model={},!0;case"dataValidation":{this._address=g.attributes.sqref;const I={type:g.attributes.type||"any",formulae:[]};switch(g.attributes.type&&o(I,g.attributes,"allowBlank"),o(I,g.attributes,"showInputMessage"),o(I,g.attributes,"showErrorMessage"),I.type){case"any":case"list":case"custom":break;default:s(I,g.attributes,"operator","between")}return s(I,g.attributes,"promptTitle"),s(I,g.attributes,"prompt"),s(I,g.attributes,"errorStyle"),s(I,g.attributes,"errorTitle"),s(I,g.attributes,"error"),this._dataValidation=I,!0}case"formula1":case"formula2":return this._formula=[],!0;default:return!1}}parseText(g){this._formula&&this._formula.push(g)}parseClose(g){switch(g){case"dataValidations":return!1;case"dataValidation":return this._dataValidation.formulae&&this._dataValidation.formulae.length||(delete this._dataValidation.formulae,delete this._dataValidation.operator),(this._address.split(/\s+/g)||[]).forEach((g=>{g.includes(":")?new l(g).forEachAddress((g=>{this.model[g]=this._dataValidation})):this.model[g]=this._dataValidation})),!0;case"formula1":case"formula2":{let g=this._formula.join("");switch(this._dataValidation.type){case"whole":case"textLength":g=parseInt(g,10);break;case"decimal":g=parseFloat(g);break;case"date":g=i.excelToDate(parseFloat(g))}return this._dataValidation.formulae.push(g),this._formula=void 0,!0}default:return!0}}}I.exports=d},{"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/utils":27,"../base-xform":32}],94:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"dimension"}render(g,I){I&&g.leafNode("dimension",{ref:I})}parseOpen(g){return"dimension"===g.name&&(this.model=g.attributes.ref,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],95:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"drawing"}render(g,I){I&&g.leafNode(this.tag,{"r:id":I.rId})}parseOpen(g){return g.name===this.tag&&(this.model={rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],96:[function(g,I,C){const A=g("../composite-xform"),i=g("./cf-ext/conditional-formattings-ext-xform");class e extends A{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new i}}get tag(){return"ext"}hasContent(g){return this.conditionalFormattings.hasContent(g.conditionalFormattings)}prepare(g,I){this.conditionalFormattings.prepare(g.conditionalFormattings,I)}render(g,I){g.openNode("ext",{uri:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.conditionalFormattings.render(g,I.conditionalFormattings),g.closeNode()}createNewModel(){return{}}onParserClose(g,I){this.model[g]=I.model}}class t extends A{constructor(){super(),this.map={ext:this.ext=new e}}get tag(){return"extLst"}prepare(g,I){this.ext.prepare(g,I)}hasContent(g){return this.ext.hasContent(g)}render(g,I){this.hasContent(I)&&(g.openNode("extLst"),this.ext.render(g,I),g.closeNode())}createNewModel(){return{}}onParserClose(g,I){Object.assign(this.model,I.model)}}I.exports=t},{"../composite-xform":48,"./cf-ext/conditional-formattings-ext-xform":78}],97:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"headerFooter"}render(g,I){if(I){g.addRollback();let C=!1;g.openNode("headerFooter"),I.differentFirst&&(g.addAttribute("differentFirst","1"),C=!0),I.differentOddEven&&(g.addAttribute("differentOddEven","1"),C=!0),I.oddHeader&&"string"==typeof I.oddHeader&&(g.leafNode("oddHeader",null,I.oddHeader),C=!0),I.oddFooter&&"string"==typeof I.oddFooter&&(g.leafNode("oddFooter",null,I.oddFooter),C=!0),I.evenHeader&&"string"==typeof I.evenHeader&&(g.leafNode("evenHeader",null,I.evenHeader),C=!0),I.evenFooter&&"string"==typeof I.evenFooter&&(g.leafNode("evenFooter",null,I.evenFooter),C=!0),I.firstHeader&&"string"==typeof I.firstHeader&&(g.leafNode("firstHeader",null,I.firstHeader),C=!0),I.firstFooter&&"string"==typeof I.firstFooter&&(g.leafNode("firstFooter",null,I.firstFooter),C=!0),C?(g.closeNode(),g.commit()):g.rollback()}}parseOpen(g){switch(g.name){case"headerFooter":return this.model={},g.attributes.differentFirst&&(this.model.differentFirst=1===parseInt(g.attributes.differentFirst,0)),g.attributes.differentOddEven&&(this.model.differentOddEven=1===parseInt(g.attributes.differentOddEven,0)),!0;case"oddHeader":return this.currentNode="oddHeader",!0;case"oddFooter":return this.currentNode="oddFooter",!0;case"evenHeader":return this.currentNode="evenHeader",!0;case"evenFooter":return this.currentNode="evenFooter",!0;case"firstHeader":return this.currentNode="firstHeader",!0;case"firstFooter":return this.currentNode="firstFooter",!0;default:return!1}}parseText(g){switch(this.currentNode){case"oddHeader":this.model.oddHeader=g;break;case"oddFooter":this.model.oddFooter=g;break;case"evenHeader":this.model.evenHeader=g;break;case"evenFooter":this.model.evenFooter=g;break;case"firstHeader":this.model.firstHeader=g;break;case"firstFooter":this.model.firstFooter=g}}parseClose(){switch(this.currentNode){case"oddHeader":case"oddFooter":case"evenHeader":case"evenFooter":case"firstHeader":case"firstFooter":return this.currentNode=void 0,!0;default:return!1}}}I.exports=i},{"../base-xform":32}],98:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"hyperlink"}render(g,I){this.isInternalLink(I)?g.leafNode("hyperlink",{ref:I.address,"r:id":I.rId,tooltip:I.tooltip,location:I.target}):g.leafNode("hyperlink",{ref:I.address,"r:id":I.rId,tooltip:I.tooltip})}parseOpen(g){return"hyperlink"===g.name&&(this.model={address:g.attributes.ref,rId:g.attributes["r:id"],tooltip:g.attributes.tooltip},g.attributes.location&&(this.model.target=g.attributes.location),!0)}parseText(){}parseClose(){return!1}isInternalLink(g){return g.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(g.target)}}I.exports=i},{"../base-xform":32}],99:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"mergeCell"}render(g,I){g.leafNode("mergeCell",{ref:I})}parseOpen(g){return"mergeCell"===g.name&&(this.model=g.attributes.ref,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],100:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../doc/range"),e=g("../../../utils/col-cache"),t=g("../../../doc/enums");class l{constructor(){this.merges={}}add(g){if(this.merges[g.master])this.merges[g.master].expandToAddress(g.address);else{const I=`${g.master}:${g.address}`;this.merges[g.master]=new i(I)}}get mergeCells(){return A.map(this.merges,(g=>g.range))}reconcile(g,I){A.each(g,(g=>{const C=e.decode(g);for(let A=C.top;A<=C.bottom;A++){const g=I[A-1];for(let I=C.left;I<=C.right;I++){const i=g.cells[I-1];i?i.type===t.ValueType.Merge&&(i.master=C.tl):g.cells[I]={type:t.ValueType.Null,address:e.encodeAddress(A,I)}}}}))}getMasterAddress(g){const I=this.hash[g];return I&&I.tl}}I.exports=l},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":26}],101:[function(g,I,C){const A=g("../base-xform"),i=g=>void 0!==g;class e extends A{get tag(){return"outlinePr"}render(g,I){return!(!I||!i(I.summaryBelow)&&!i(I.summaryRight)||(g.leafNode(this.tag,{summaryBelow:i(I.summaryBelow)?Number(I.summaryBelow):void 0,summaryRight:i(I.summaryRight)?Number(I.summaryRight):void 0}),0))}parseOpen(g){return g.name===this.tag&&(this.model={summaryBelow:i(g.attributes.summaryBelow)?Boolean(Number(g.attributes.summaryBelow)):void 0,summaryRight:i(g.attributes.summaryRight)?Boolean(Number(g.attributes.summaryRight)):void 0},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../base-xform":32}],102:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"brk"}render(g,I){g.leafNode("brk",I)}parseOpen(g){return"brk"===g.name&&(this.model=g.attributes.ref,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],103:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");class e extends i{get tag(){return"pageMargins"}render(g,I){if(I){const C={left:I.left,right:I.right,top:I.top,bottom:I.bottom,header:I.header,footer:I.footer};A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={left:parseFloat(g.attributes.left||.7),right:parseFloat(g.attributes.right||.7),top:parseFloat(g.attributes.top||.75),bottom:parseFloat(g.attributes.bottom||.75),header:parseFloat(g.attributes.header||.3),footer:parseFloat(g.attributes.footer||.3)},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../../../utils/under-dash":26,"../base-xform":32}],104:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"pageSetUpPr"}render(g,I){return!(!I||!I.fitToPage||(g.leafNode(this.tag,{fitToPage:I.fitToPage?"1":void 0}),0))}parseOpen(g){return g.name===this.tag&&(this.model={fitToPage:"1"===g.attributes.fitToPage},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],105:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");function e(g){return g?"1":void 0}function t(g){if("overThenDown"===g)return g}function l(g){switch(g){case"atEnd":case"asDisplyed":return g;default:return}}function s(g){switch(g){case"dash":case"blank":case"NA":return g;default:return}}function o(g){return void 0!==g?parseInt(g,10):void 0}class c extends i{get tag(){return"pageSetup"}render(g,I){if(I){const C={paperSize:I.paperSize,orientation:I.orientation,horizontalDpi:I.horizontalDpi,verticalDpi:I.verticalDpi,pageOrder:t(I.pageOrder),blackAndWhite:e(I.blackAndWhite),draft:e(I.draft),cellComments:l(I.cellComments),errors:s(I.errors),scale:I.scale,fitToWidth:I.fitToWidth,fitToHeight:I.fitToHeight,firstPageNumber:I.firstPageNumber,useFirstPageNumber:e(I.firstPageNumber),usePrinterDefaults:e(I.usePrinterDefaults),copies:I.copies};A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={paperSize:o(g.attributes.paperSize),orientation:g.attributes.orientation||"portrait",horizontalDpi:parseInt(g.attributes.horizontalDpi||"4294967295",10),verticalDpi:parseInt(g.attributes.verticalDpi||"4294967295",10),pageOrder:g.attributes.pageOrder||"downThenOver",blackAndWhite:"1"===g.attributes.blackAndWhite,draft:"1"===g.attributes.draft,cellComments:g.attributes.cellComments||"None",errors:g.attributes.errors||"displayed",scale:parseInt(g.attributes.scale||"100",10),fitToWidth:parseInt(g.attributes.fitToWidth||"1",10),fitToHeight:parseInt(g.attributes.fitToHeight||"1",10),firstPageNumber:parseInt(g.attributes.firstPageNumber||"1",10),useFirstPageNumber:"1"===g.attributes.useFirstPageNumber,usePrinterDefaults:"1"===g.attributes.usePrinterDefaults,copies:parseInt(g.attributes.copies||"1",10)},!0)}parseText(){}parseClose(){return!1}}I.exports=c},{"../../../utils/under-dash":26,"../base-xform":32}],106:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"picture"}render(g,I){I&&g.leafNode(this.tag,{"r:id":I.rId})}parseOpen(g){return g.name===this.tag&&(this.model={rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],107:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");function e(g){return g?"1":void 0}class t extends i{get tag(){return"printOptions"}render(g,I){if(I){const C={headings:e(I.showRowColHeaders),gridLines:e(I.showGridLines),horizontalCentered:e(I.horizontalCentered),verticalCentered:e(I.verticalCentered)};A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={showRowColHeaders:"1"===g.attributes.headings,showGridLines:"1"===g.attributes.gridLines,horizontalCentered:"1"===g.attributes.horizontalCentered,verticalCentered:"1"===g.attributes.verticalCentered},!0)}parseText(){}parseClose(){return!1}}I.exports=t},{"../../../utils/under-dash":26,"../base-xform":32}],108:[function(g,I,C){const A=g("./page-breaks-xform"),i=g("../list-xform");class e extends i{constructor(){super({tag:"rowBreaks",count:!0,childXform:new A})}render(g,I){if(I&&I.length){g.openNode(this.tag,this.$),this.count&&(g.addAttribute(this.$count,I.length),g.addAttribute("manualBreakCount",I.length));const{childXform:C}=this;I.forEach((I=>{C.render(g,I)})),g.closeNode()}else this.empty&&g.leafNode(this.tag)}}I.exports=e},{"../list-xform":71,"./page-breaks-xform":102}],109:[function(g,I,C){const A=g("../base-xform"),i=g("../../../utils/utils"),e=g("./cell-xform");class t extends A{constructor(g){super(),this.maxItems=g&&g.maxItems,this.map={c:new e}}get tag(){return"row"}prepare(g,I){const C=I.styles.addStyleModel(g.style);C&&(g.styleId=C);const A=this.map.c;g.cells.forEach((g=>{A.prepare(g,I)}))}render(g,I,C){g.openNode("row"),g.addAttribute("r",I.number),I.height&&(g.addAttribute("ht",I.height),g.addAttribute("customHeight","1")),I.hidden&&g.addAttribute("hidden","1"),I.min>0&&I.max>0&&I.min<=I.max&&g.addAttribute("spans",`${I.min}:${I.max}`),I.styleId&&(g.addAttribute("s",I.styleId),g.addAttribute("customFormat","1")),g.addAttribute("x14ac:dyDescent","0.25"),I.outlineLevel&&g.addAttribute("outlineLevel",I.outlineLevel),I.collapsed&&g.addAttribute("collapsed","1");const A=this.map.c;I.cells.forEach((I=>{A.render(g,I,C)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;if("row"===g.name){this.numRowsSeen+=1;const I=g.attributes.spans?g.attributes.spans.split(":").map((g=>parseInt(g,10))):[void 0,void 0],C=this.model={number:parseInt(g.attributes.r,10),min:I[0],max:I[1],cells:[]};return g.attributes.s&&(C.styleId=parseInt(g.attributes.s,10)),i.parseBoolean(g.attributes.hidden)&&(C.hidden=!0),i.parseBoolean(g.attributes.bestFit)&&(C.bestFit=!0),g.attributes.ht&&(C.height=parseFloat(g.attributes.ht)),g.attributes.outlineLevel&&(C.outlineLevel=parseInt(g.attributes.outlineLevel,10)),i.parseBoolean(g.attributes.collapsed)&&(C.collapsed=!0),!0}return this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)){if(this.model.cells.push(this.parser.model),this.maxItems&&this.model.cells.length>this.maxItems)throw new Error(`Max column count (${this.maxItems}) exceeded`);this.parser=void 0}return!0}return!1}reconcile(g,I){g.style=g.styleId?I.styles.getStyleModel(g.styleId):{},void 0!==g.styleId&&(g.styleId=void 0);const C=this.map.c;g.cells.forEach((g=>{C.reconcile(g,I)}))}}I.exports=t},{"../../../utils/utils":27,"../base-xform":32,"./cell-xform":73}],110:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");class e extends i{get tag(){return"sheetFormatPr"}render(g,I){if(I){const C={defaultRowHeight:I.defaultRowHeight,outlineLevelRow:I.outlineLevelRow,outlineLevelCol:I.outlineLevelCol,"x14ac:dyDescent":I.dyDescent};I.defaultColWidth&&(C.defaultColWidth=I.defaultColWidth),I.defaultRowHeight&&15===I.defaultRowHeight||(C.customHeight="1"),A.some(C,(g=>void 0!==g))&&g.leafNode("sheetFormatPr",C)}}parseOpen(g){return"sheetFormatPr"===g.name&&(this.model={defaultRowHeight:parseFloat(g.attributes.defaultRowHeight||"0"),dyDescent:parseFloat(g.attributes["x14ac:dyDescent"]||"0"),outlineLevelRow:parseInt(g.attributes.outlineLevelRow||"0",10),outlineLevelCol:parseInt(g.attributes.outlineLevelCol||"0",10)},g.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(g.attributes.defaultColWidth)),!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../../../utils/under-dash":26,"../base-xform":32}],111:[function(g,I,C){const A=g("../base-xform"),i=g("../style/color-xform"),e=g("./page-setup-properties-xform"),t=g("./outline-properties-xform");class l extends A{constructor(){super(),this.map={tabColor:new i("tabColor"),pageSetUpPr:new e,outlinePr:new t}}get tag(){return"sheetPr"}render(g,I){if(I){g.addRollback(),g.openNode("sheetPr");let C=!1;C=this.map.tabColor.render(g,I.tabColor)||C,C=this.map.pageSetUpPr.render(g,I.pageSetup)||C,C=this.map.outlinePr.render(g,I.outlineProperties)||C,C?(g.closeNode(),g.commit()):g.rollback()}}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag?(this.reset(),!0):!!this.map[g.name]&&(this.parser=this.map[g.name],this.parser.parseOpen(g),!0)}parseText(g){return!!this.parser&&(this.parser.parseText(g),!0)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}}I.exports=l},{"../base-xform":32,"../style/color-xform":128,"./outline-properties-xform":101,"./page-setup-properties-xform":104}],112:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");function e(g,I){return g?I:void 0}function t(g,I){return g===I||void 0}class l extends i{get tag(){return"sheetProtection"}render(g,I){if(I){const C={sheet:e(I.sheet,"1"),selectLockedCells:!1===I.selectLockedCells?"1":void 0,selectUnlockedCells:!1===I.selectUnlockedCells?"1":void 0,formatCells:e(I.formatCells,"0"),formatColumns:e(I.formatColumns,"0"),formatRows:e(I.formatRows,"0"),insertColumns:e(I.insertColumns,"0"),insertRows:e(I.insertRows,"0"),insertHyperlinks:e(I.insertHyperlinks,"0"),deleteColumns:e(I.deleteColumns,"0"),deleteRows:e(I.deleteRows,"0"),sort:e(I.sort,"0"),autoFilter:e(I.autoFilter,"0"),pivotTables:e(I.pivotTables,"0")};I.sheet&&(C.algorithmName=I.algorithmName,C.hashValue=I.hashValue,C.saltValue=I.saltValue,C.spinCount=I.spinCount,C.objects=e(!1===I.objects,"1"),C.scenarios=e(!1===I.scenarios,"1")),A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={sheet:t(g.attributes.sheet,"1"),objects:"1"!==g.attributes.objects&&void 0,scenarios:"1"!==g.attributes.scenarios&&void 0,selectLockedCells:"1"!==g.attributes.selectLockedCells&&void 0,selectUnlockedCells:"1"!==g.attributes.selectUnlockedCells&&void 0,formatCells:t(g.attributes.formatCells,"0"),formatColumns:t(g.attributes.formatColumns,"0"),formatRows:t(g.attributes.formatRows,"0"),insertColumns:t(g.attributes.insertColumns,"0"),insertRows:t(g.attributes.insertRows,"0"),insertHyperlinks:t(g.attributes.insertHyperlinks,"0"),deleteColumns:t(g.attributes.deleteColumns,"0"),deleteRows:t(g.attributes.deleteRows,"0"),sort:t(g.attributes.sort,"0"),autoFilter:t(g.attributes.autoFilter,"0"),pivotTables:t(g.attributes.pivotTables,"0")},g.attributes.algorithmName&&(this.model.algorithmName=g.attributes.algorithmName,this.model.hashValue=g.attributes.hashValue,this.model.saltValue=g.attributes.saltValue,this.model.spinCount=parseInt(g.attributes.spinCount,10)),!0)}parseText(){}parseClose(){return!1}}I.exports=l},{"../../../utils/under-dash":26,"../base-xform":32}],113:[function(g,I,C){const A=g("../../../utils/col-cache"),i=g("../base-xform"),e={frozen:"frozen",frozenSplit:"frozen",split:"split"};class t extends i{get tag(){return"sheetView"}prepare(g){switch(g.state){case"frozen":case"split":break;default:g.state="normal"}}render(g,I){g.openNode("sheetView",{workbookViewId:I.workbookViewId||0});const C=function(I,C,A){A&&g.addAttribute(I,C)};let i,e,t,l;switch(C("rightToLeft","1",!0===I.rightToLeft),C("tabSelected","1",I.tabSelected),C("showRuler","0",!1===I.showRuler),C("showRowColHeaders","0",!1===I.showRowColHeaders),C("showGridLines","0",!1===I.showGridLines),C("zoomScale",I.zoomScale,I.zoomScale),C("zoomScaleNormal",I.zoomScaleNormal,I.zoomScaleNormal),C("view",I.style,I.style),I.state){case"frozen":e=I.xSplit||0,t=I.ySplit||0,i=I.topLeftCell||A.getAddress(t+1,e+1).address,l=(I.xSplit&&I.ySplit?"bottomRight":I.xSplit&&"topRight")||"bottomLeft",g.leafNode("pane",{xSplit:I.xSplit||void 0,ySplit:I.ySplit||void 0,topLeftCell:i,activePane:l,state:"frozen"}),g.leafNode("selection",{pane:l,activeCell:I.activeCell,sqref:I.activeCell});break;case"split":"topLeft"===I.activePane&&(I.activePane=void 0),g.leafNode("pane",{xSplit:I.xSplit||void 0,ySplit:I.ySplit||void 0,topLeftCell:I.topLeftCell,activePane:I.activePane}),g.leafNode("selection",{pane:I.activePane,activeCell:I.activeCell,sqref:I.activeCell});break;case"normal":I.activeCell&&g.leafNode("selection",{activeCell:I.activeCell,sqref:I.activeCell})}g.closeNode()}parseOpen(g){switch(g.name){case"sheetView":return this.sheetView={workbookViewId:parseInt(g.attributes.workbookViewId,10),rightToLeft:"1"===g.attributes.rightToLeft,tabSelected:"1"===g.attributes.tabSelected,showRuler:!("0"===g.attributes.showRuler),showRowColHeaders:!("0"===g.attributes.showRowColHeaders),showGridLines:!("0"===g.attributes.showGridLines),zoomScale:parseInt(g.attributes.zoomScale||"100",10),zoomScaleNormal:parseInt(g.attributes.zoomScaleNormal||"100",10),style:g.attributes.view},this.pane=void 0,this.selections={},!0;case"pane":return this.pane={xSplit:parseInt(g.attributes.xSplit||"0",10),ySplit:parseInt(g.attributes.ySplit||"0",10),topLeftCell:g.attributes.topLeftCell,activePane:g.attributes.activePane||"topLeft",state:g.attributes.state},!0;case"selection":{const I=g.attributes.pane||"topLeft";return this.selections[I]={pane:I,activeCell:g.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(g){let I,C;return"sheetView"!==g||(this.sheetView&&this.pane?(I=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:e[this.pane.state]||"split",xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},"split"===this.model.state&&(I.activePane=this.pane.activePane),C=this.selections[this.pane.activePane],C&&C.activeCell&&(I.activeCell=C.activeCell),this.sheetView.style&&(I.style=this.sheetView.style)):(I=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:"normal",showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},C=this.selections.topLeft,C&&C.activeCell&&(I.activeCell=C.activeCell),this.sheetView.style&&(I.style=this.sheetView.style)),!1)}reconcile(){}}I.exports=t},{"../../../utils/col-cache":19,"../base-xform":32}],114:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"tablePart"}render(g,I){I&&g.leafNode(this.tag,{"r:id":I.rId})}parseOpen(g){return g.name===this.tag&&(this.model={rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],115:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../utils/col-cache"),e=g("../../../utils/xml-stream"),t=g("../../rel-type"),l=g("./merges"),s=g("../base-xform"),o=g("../list-xform"),c=g("./row-xform"),d=g("./col-xform"),a=g("./dimension-xform"),n=g("./hyperlink-xform"),r=g("./merge-cell-xform"),m=g("./data-validations-xform"),h=g("./sheet-properties-xform"),Z=g("./sheet-format-properties-xform"),b=g("./sheet-view-xform"),G=g("./sheet-protection-xform"),u=g("./page-margins-xform"),p=g("./page-setup-xform"),w=g("./print-options-xform"),W=g("./auto-filter-xform"),B=g("./picture-xform"),y=g("./drawing-xform"),V=g("./table-part-xform"),X=g("./row-breaks-xform"),Y=g("./header-footer-xform"),R=g("./cf/conditional-formattings-xform"),N=g("./ext-lst-xform"),H=(g,I)=>{Object.keys(I).forEach((C=>{const A=g[C],i=I[C];void 0===A&&void 0!==i&&(g[C]=i)}))},K=(g,I)=>{if(!I||!I.length)return g;if(!g||!g.length)return I;const C={},A={};return g.forEach((g=>{C[g.ref]=g,g.rules.forEach((g=>{const{x14Id:I}=g;I&&(A[I]=g)}))})),I.forEach((I=>{I.rules.forEach((i=>{const e=A[i.x14Id];e?H(e,i):C[I.ref]?C[I.ref].rules.push(i):g.push({ref:I.ref,rules:[i]})}))})),g};class f extends s{constructor(g){super();const{maxRows:I,maxCols:C,ignoreNodes:A}=g||{};this.ignoreNodes=A||[],this.map={sheetPr:new h,dimension:new a,sheetViews:new o({tag:"sheetViews",count:!1,childXform:new b}),sheetFormatPr:new Z,cols:new o({tag:"cols",count:!1,childXform:new d}),sheetData:new o({tag:"sheetData",count:!1,empty:!0,childXform:new c({maxItems:C}),maxItems:I}),autoFilter:new W,mergeCells:new o({tag:"mergeCells",count:!0,childXform:new r}),rowBreaks:new X,hyperlinks:new o({tag:"hyperlinks",count:!1,childXform:new n}),pageMargins:new u,dataValidations:new m,pageSetup:new p,headerFooter:new Y,printOptions:new w,picture:new B,drawing:new y,sheetProtection:new G,tableParts:new o({tag:"tableParts",count:!0,childXform:new V}),conditionalFormatting:new R,extLst:new N}}prepare(g,I){I.merges=new l,g.hyperlinks=I.hyperlinks=[],g.comments=I.comments=[],I.formulae={},I.siFormulae=0,this.map.cols.prepare(g.cols,I),this.map.sheetData.prepare(g.rows,I),this.map.conditionalFormatting.prepare(g.conditionalFormattings,I),g.mergeCells=I.merges.mergeCells;const C=g.rels=[];function A(g){return`rId${g.length+1}`}if(g.hyperlinks.forEach((g=>{const I=A(C);g.rId=I,C.push({Id:I,Type:t.Hyperlink,Target:g.target,TargetMode:"External"})})),g.comments.length>0){const e={Id:A(C),Type:t.Comments,Target:`../comments${g.id}.xml`};C.push(e);const l={Id:A(C),Type:t.VmlDrawing,Target:`../drawings/vmlDrawing${g.id}.vml`};C.push(l),g.comments.forEach((g=>{g.refAddress=i.decodeAddress(g.ref)})),I.commentRefs.push({commentName:`comments${g.id}`,vmlDrawing:`vmlDrawing${g.id}`})}const e=[];let s;g.media.forEach((i=>{if("background"===i.type){const e=A(C);s=I.media[i.imageId],C.push({Id:e,Type:t.Image,Target:`../media/${s.name}.${s.extension}`}),g.background={rId:e},g.image=I.media[i.imageId]}else if("image"===i.type){let{drawing:l}=g;s=I.media[i.imageId],l||(l=g.drawing={rId:A(C),name:"drawing"+ ++I.drawingsCount,anchors:[],rels:[]},I.drawings.push(l),C.push({Id:l.rId,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",Target:`../drawings/${l.name}.xml`}));let o=this.preImageId===i.imageId?e[i.imageId]:e[l.rels.length];o||(o=A(l.rels),e[l.rels.length]=o,l.rels.push({Id:o,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",Target:`../media/${s.name}.${s.extension}`}));const c={picture:{rId:o},range:i.range};if(i.hyperlinks&&i.hyperlinks.hyperlink){const g=A(l.rels);e[l.rels.length]=g,c.picture.hyperlinks={tooltip:i.hyperlinks.tooltip,rId:g},l.rels.push({Id:g,Type:t.Hyperlink,Target:i.hyperlinks.hyperlink,TargetMode:"External"})}this.preImageId=i.imageId,l.anchors.push(c)}})),g.tables.forEach((g=>{const i=A(C);g.rId=i,C.push({Id:i,Type:t.Table,Target:`../tables/${g.target}`}),g.columns.forEach((g=>{const{style:C}=g;C&&(g.dxfId=I.styles.addDxfStyle(C))}))})),this.map.extLst.prepare(g,I)}render(g,I){g.openXml(e.StdDocAttributes),g.openNode("worksheet",f.WORKSHEET_ATTRIBUTES);const C=I.properties?{defaultRowHeight:I.properties.defaultRowHeight,dyDescent:I.properties.dyDescent,outlineLevelCol:I.properties.outlineLevelCol,outlineLevelRow:I.properties.outlineLevelRow}:void 0;I.properties&&I.properties.defaultColWidth&&(C.defaultColWidth=I.properties.defaultColWidth);const A={outlineProperties:I.properties&&I.properties.outlineProperties,tabColor:I.properties&&I.properties.tabColor,pageSetup:I.pageSetup&&I.pageSetup.fitToPage?{fitToPage:I.pageSetup.fitToPage}:void 0},i=I.pageSetup&&I.pageSetup.margins,l={showRowColHeaders:I.pageSetup&&I.pageSetup.showRowColHeaders,showGridLines:I.pageSetup&&I.pageSetup.showGridLines,horizontalCentered:I.pageSetup&&I.pageSetup.horizontalCentered,verticalCentered:I.pageSetup&&I.pageSetup.verticalCentered},s=I.sheetProtection;this.map.sheetPr.render(g,A),this.map.dimension.render(g,I.dimensions),this.map.sheetViews.render(g,I.views),this.map.sheetFormatPr.render(g,C),this.map.cols.render(g,I.cols),this.map.sheetData.render(g,I.rows),this.map.sheetProtection.render(g,s),this.map.autoFilter.render(g,I.autoFilter),this.map.mergeCells.render(g,I.mergeCells),this.map.conditionalFormatting.render(g,I.conditionalFormattings),this.map.dataValidations.render(g,I.dataValidations),this.map.hyperlinks.render(g,I.hyperlinks),this.map.printOptions.render(g,l),this.map.pageMargins.render(g,i),this.map.pageSetup.render(g,I.pageSetup),this.map.headerFooter.render(g,I.headerFooter),this.map.rowBreaks.render(g,I.rowBreaks),this.map.drawing.render(g,I.drawing),this.map.picture.render(g,I.background),this.map.tableParts.render(g,I.tables),this.map.extLst.render(g,I),I.rels&&I.rels.forEach((I=>{I.Type===t.VmlDrawing&&g.leafNode("legacyDrawing",{"r:id":I.Id})})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"worksheet"===g.name?(A.each(this.map,(g=>{g.reset()})),!0):(this.map[g.name]&&!this.ignoreNodes.includes(g.name)&&(this.parser=this.map[g.name],this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;if("worksheet"===g){const g=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(g.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(g.outlineProperties=this.map.sheetPr.model.outlineProperties);const I={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},C=Object.assign(I,this.map.pageSetup.model,this.map.printOptions.model),A=K(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model["x14:conditionalFormattings"]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:g,views:this.map.sheetViews.model,pageSetup:C,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:A},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}return!0}reconcile(g,I){const C=(g.relationships||[]).reduce(((C,A)=>{if(C[A.Id]=A,A.Type===t.Comments&&(g.comments=I.comments[A.Target].comments),A.Type===t.VmlDrawing&&g.comments&&g.comments.length){const C=I.vmlDrawings[A.Target].comments;g.comments.forEach(((g,I)=>{g.note=Object.assign({},g.note,C[I])}))}return C}),{});if(I.commentsMap=(g.comments||[]).reduce(((g,I)=>(I.ref&&(g[I.ref]=I),g)),{}),I.hyperlinkMap=(g.hyperlinks||[]).reduce(((g,I)=>(I.rId&&(g[I.address]=C[I.rId].Target),g)),{}),I.formulae={},g.rows=g.rows&&g.rows.filter(Boolean)||[],g.rows.forEach((g=>{g.cells=g.cells&&g.cells.filter(Boolean)||[]})),this.map.cols.reconcile(g.cols,I),this.map.sheetData.reconcile(g.rows,I),this.map.conditionalFormatting.reconcile(g.conditionalFormattings,I),g.media=[],g.drawing){const A=C[g.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(A){const C=A[1];I.drawings[C].anchors.forEach((I=>{if(I.medium){const C={type:"image",imageId:I.medium.index,range:I.range,hyperlinks:I.picture.hyperlinks};g.media.push(C)}}))}}const A=g.background&&C[g.background.rId];if(A){const C=A.Target.split("/media/")[1],i=I.mediaIndex&&I.mediaIndex[C];void 0!==i&&g.media.push({type:"background",imageId:i})}g.tables=(g.tables||[]).map((g=>{const A=C[g.rId];return I.tables[A.Target]})),delete g.relationships,delete g.hyperlinks,delete g.comments}}f.WORKSHEET_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"},I.exports=f},{"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/xml-stream":28,"../../rel-type":31,"../base-xform":32,"../list-xform":71,"./auto-filter-xform":72,"./cf/conditional-formattings-xform":87,"./col-xform":92,"./data-validations-xform":93,"./dimension-xform":94,"./drawing-xform":95,"./ext-lst-xform":96,"./header-footer-xform":97,"./hyperlink-xform":98,"./merge-cell-xform":99,"./merges":100,"./page-margins-xform":103,"./page-setup-xform":105,"./picture-xform":106,"./print-options-xform":107,"./row-breaks-xform":108,"./row-xform":109,"./sheet-format-properties-xform":110,"./sheet-properties-xform":111,"./sheet-protection-xform":112,"./sheet-view-xform":113,"./table-part-xform":114}],116:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr}render(g,I){I&&(g.openNode(this.tag),g.closeNode())}parseOpen(g){g.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],117:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr,this.attrs=g.attrs,this._format=g.format||function(g){try{return Number.isNaN(g.getTime())?"":g.toISOString()}catch(I){return""}},this._parse=g.parse||function(g){return new Date(g)}}render(g,I){I&&(g.openNode(this.tag),this.attrs&&g.addAttributes(this.attrs),this.attr?g.addAttribute(this.attr,this._format(I)):g.writeText(this._format(I)),g.closeNode())}parseOpen(g){g.name===this.tag&&(this.attr?this.model=this._parse(g.attributes[this.attr]):this.text=[])}parseText(g){this.attr||this.text.push(g)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(""))),!1}}I.exports=i},{"../base-xform":32}],118:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr,this.attrs=g.attrs,this.zero=g.zero}render(g,I){(I||this.zero)&&(g.openNode(this.tag),this.attrs&&g.addAttributes(this.attrs),this.attr?g.addAttribute(this.attr,I):g.writeText(I),g.closeNode())}parseOpen(g){return g.name===this.tag&&(this.attr?this.model=parseInt(g.attributes[this.attr],10):this.text=[],!0)}parseText(g){this.attr||this.text.push(g)}parseClose(){return this.attr||(this.model=parseInt(this.text.join("")||0,10)),!1}}I.exports=i},{"../base-xform":32}],119:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr,this.attrs=g.attrs}render(g,I){void 0!==I&&(g.openNode(this.tag),this.attrs&&g.addAttributes(this.attrs),this.attr?g.addAttribute(this.attr,I):g.writeText(I),g.closeNode())}parseOpen(g){g.name===this.tag&&(this.attr?this.model=g.attributes[this.attr]:this.text=[])}parseText(g){this.attr||this.text.push(g)}parseClose(){return this.attr||(this.model=this.text.join("")),!1}}I.exports=i},{"../base-xform":32}],120:[function(g,I,C){const A=g("./base-xform"),i=g("../../utils/xml-stream");function e(g,I){g.openNode(I.tag,I.$),I.c&&I.c.forEach((I=>{e(g,I)})),I.t&&g.writeText(I.t),g.closeNode()}class t extends A{constructor(g){super(),this._model=g}render(g){if(!this._xml){const g=new i;e(g,this._model),this._xml=g.xml}g.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(g){return g!==this._model.tag}}I.exports=t},{"../../utils/xml-stream":28,"./base-xform":32}],121:[function(g,I,C){const A=g("./text-xform"),i=g("./rich-text-xform"),e=g("../base-xform");class t extends e{constructor(){super(),this.map={r:new i,t:new A}}get tag(){return"rPh"}render(g,I){if(g.openNode(this.tag,{sb:I.sb||0,eb:I.eb||0}),I&&I.hasOwnProperty("richText")&&I.richText){const{r:C}=this.map;I.richText.forEach((I=>{C.render(g,I)}))}else I&&this.map.t.render(g,I.text);g.closeNode()}parseOpen(g){const{name:I}=g;return this.parser?(this.parser.parseOpen(g),!0):I===this.tag?(this.model={sb:parseInt(g.attributes.sb,10),eb:parseInt(g.attributes.eb,10)},!0):(this.parser=this.map[I],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)){switch(g){case"r":{let g=this.model.richText;g||(g=this.model.richText=[]),g.push(this.parser.model);break}case"t":this.model.text=this.parser.model}this.parser=void 0}return!0}return g!==this.tag}}I.exports=t},{"../base-xform":32,"./rich-text-xform":122,"./text-xform":125}],122:[function(g,I,C){const A=g("./text-xform"),i=g("../style/font-xform"),e=g("../base-xform");class t extends e{constructor(g){super(),this.model=g}get tag(){return"r"}get textXform(){return this._textXform||(this._textXform=new A)}get fontXform(){return this._fontXform||(this._fontXform=new i(t.FONT_OPTIONS))}render(g,I){I=I||this.model,g.openNode("r"),I.font&&this.fontXform.render(g,I.font),this.textXform.render(g,I.text),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"r":return this.model={},!0;case"t":return this.parser=this.textXform,this.parser.parseOpen(g),!0;case"rPr":return this.parser=this.fontXform,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){switch(g){case"r":return!1;case"t":return this.model.text=this.parser.model,this.parser=void 0,!0;case"rPr":return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(g),!0}}}t.FONT_OPTIONS={tagName:"rPr",fontNameTag:"rFont"},I.exports=t},{"../base-xform":32,"../style/font-xform":131,"./text-xform":125}],123:[function(g,I,C){const A=g("./text-xform"),i=g("./rich-text-xform"),e=g("./phonetic-text-xform"),t=g("../base-xform");class l extends t{constructor(g){super(),this.model=g,this.map={r:new i,t:new A,rPh:new e}}get tag(){return"si"}render(g,I){g.openNode(this.tag),I&&I.hasOwnProperty("richText")&&I.richText?I.richText.length?I.richText.forEach((I=>{this.map.r.render(g,I)})):this.map.t.render(g,""):null!=I&&this.map.t.render(g,I),g.closeNode()}parseOpen(g){const{name:I}=g;return this.parser?(this.parser.parseOpen(g),!0):I===this.tag?(this.model={},!0):(this.parser=this.map[I],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)){switch(g){case"r":{let g=this.model.richText;g||(g=this.model.richText=[]),g.push(this.parser.model);break}case"t":this.model=this.parser.model}this.parser=void 0}return!0}return g!==this.tag}}I.exports=l},{"../base-xform":32,"./phonetic-text-xform":121,"./rich-text-xform":122,"./text-xform":125}],124:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("./shared-string-xform");class t extends i{constructor(g){super(),this.model=g||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||(this._sharedStringXform=new e)}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(g){return this.model.values[g]}add(g){return g.richText?this.addRichText(g):this.addText(g)}addText(g){let I=this.hash[g];return void 0===I&&(I=this.hash[g]=this.model.values.length,this.model.values.push(g)),this.model.count++,I}addRichText(g){const I=this.sharedStringXform.toXml(g);let C=this.rich[I];return void 0===C&&(C=this.rich[I]=this.model.values.length,this.model.values.push(g)),this.model.count++,C}render(g,I){I=I||this._values,g.openXml(A.StdDocAttributes),g.openNode("sst",{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:I.count,uniqueCount:I.values.length});const C=this.sharedStringXform;I.values.forEach((I=>{C.render(g,I)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"sst":return!0;case"si":return this.parser=this.sharedStringXform,this.parser.parseOpen(g),!0;default:throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;if("sst"===g)return!1;throw new Error(`Unexpected xml node in parseClose: ${g}`)}}I.exports=t},{"../../../utils/xml-stream":28,"../base-xform":32,"./shared-string-xform":123}],125:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"t"}render(g,I){g.openNode("t"),/^\s|\n|\s$/.test(I)&&g.addAttribute("xml:space","preserve"),g.writeText(I),g.closeNode()}get model(){return this._text.join("").replace(/_x([0-9A-F]{4})_/g,((g,I)=>String.fromCharCode(parseInt(I,16))))}parseOpen(g){return"t"===g.name&&(this._text=[],!0)}parseText(g){this._text.push(g)}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],126:[function(g,I,C){const A=g("../../../doc/enums"),i=g("../../../utils/utils"),e=g("../base-xform"),t={horizontalValues:["left","center","right","fill","centerContinuous","distributed","justify"].reduce(((g,I)=>(g[I]=!0,g)),{}),horizontal(g){return this.horizontalValues[g]?g:void 0},verticalValues:["top","middle","bottom","distributed","justify"].reduce(((g,I)=>(g[I]=!0,g)),{}),vertical(g){return"middle"===g?"center":this.verticalValues[g]?g:void 0},wrapText:g=>!!g||void 0,shrinkToFit:g=>!!g||void 0,textRotation:g=>"vertical"===g||(g=i.validInt(g))>=-90&&g<=90?g:void 0,indent:g=>(g=i.validInt(g),Math.max(0,g)),readingOrder(g){switch(g){case"ltr":return A.ReadingOrder.LeftToRight;case"rtl":return A.ReadingOrder.RightToLeft;default:return}}},l={toXml(g){if(g=t.textRotation(g)){if("vertical"===g)return 255;const I=Math.round(g);if(I>=0&&I<=90)return I;if(I<0&&I>=-90)return 90-I}},toModel(g){const I=i.validInt(g);if(void 0!==I){if(255===I)return"vertical";if(I>=0&&I<=90)return I;if(I>90&&I<=180)return 90-I}}};class s extends e{get tag(){return"alignment"}render(g,I){g.addRollback(),g.openNode("alignment");let C=!1;function A(I,A){A&&(g.addAttribute(I,A),C=!0)}A("horizontal",t.horizontal(I.horizontal)),A("vertical",t.vertical(I.vertical)),A("wrapText",!!t.wrapText(I.wrapText)&&"1"),A("shrinkToFit",!!t.shrinkToFit(I.shrinkToFit)&&"1"),A("indent",t.indent(I.indent)),A("textRotation",l.toXml(I.textRotation)),A("readingOrder",t.readingOrder(I.readingOrder)),g.closeNode(),C?g.commit():g.rollback()}parseOpen(g){const I={};let C=!1;function A(g,A,i){g&&(I[A]=i,C=!0)}A(g.attributes.horizontal,"horizontal",g.attributes.horizontal),A(g.attributes.vertical,"vertical","center"===g.attributes.vertical?"middle":g.attributes.vertical),A(g.attributes.wrapText,"wrapText",i.parseBoolean(g.attributes.wrapText)),A(g.attributes.shrinkToFit,"shrinkToFit",i.parseBoolean(g.attributes.shrinkToFit)),A(g.attributes.indent,"indent",parseInt(g.attributes.indent,10)),A(g.attributes.textRotation,"textRotation",l.toModel(g.attributes.textRotation)),A(g.attributes.readingOrder,"readingOrder","2"===g.attributes.readingOrder?"rtl":"ltr"),this.model=C?I:null}parseText(){}parseClose(){return!1}}I.exports=s},{"../../../doc/enums":7,"../../../utils/utils":27,"../base-xform":32}],127:[function(g,I,C){const A=g("../base-xform"),i=g("../../../utils/utils"),e=g("./color-xform");class t extends A{constructor(g){super(),this.name=g,this.map={color:new e}}get tag(){return this.name}render(g,I,C){const A=I&&I.color||C||this.defaultColor;g.openNode(this.name),I&&I.style&&(g.addAttribute("style",I.style),A&&this.map.color.render(g,A)),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case this.name:{const{style:I}=g.attributes;return this.model=I?{style:I}:void 0,!0}case"color":return this.parser=this.map.color,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):(g===this.name&&this.map.color.model&&(this.model||(this.model={}),this.model.color=this.map.color.model),!1)}validStyle(g){return t.validStyleValues[g]}}t.validStyleValues=["thin","dashed","dotted","dashDot","hair","dashDotDot","slantDashDot","mediumDashed","mediumDashDotDot","mediumDashDot","medium","double","thick"].reduce(((g,I)=>(g[I]=!0,g)),{});class l extends A{constructor(){super(),this.map={top:new t("top"),left:new t("left"),bottom:new t("bottom"),right:new t("right"),diagonal:new t("diagonal")}}render(g,I){const{color:C}=I;function A(A,i){A&&!A.color&&I.color&&(A={...A,color:I.color}),i.render(g,A,C)}g.openNode("border"),I.diagonal&&I.diagonal.style&&(I.diagonal.up&&g.addAttribute("diagonalUp","1"),I.diagonal.down&&g.addAttribute("diagonalDown","1")),A(I.left,this.map.left),A(I.right,this.map.right),A(I.top,this.map.top),A(I.bottom,this.map.bottom),A(I.diagonal,this.map.diagonal),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"border"===g.name?(this.reset(),this.diagonalUp=i.parseBoolean(g.attributes.diagonalUp),this.diagonalDown=i.parseBoolean(g.attributes.diagonalDown),!0):(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;if("border"===g){const g=this.model={},I=function(I,C,A){C&&(A&&Object.assign(C,A),g[I]=C)};I("left",this.map.left.model),I("right",this.map.right.model),I("top",this.map.top.model),I("bottom",this.map.bottom.model),I("diagonal",this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}}I.exports=l},{"../../../utils/utils":27,"../base-xform":32,"./color-xform":128}],128:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.name=g||"color"}get tag(){return this.name}render(g,I){return!!I&&(g.openNode(this.name),I.argb?g.addAttribute("rgb",I.argb):void 0!==I.theme?(g.addAttribute("theme",I.theme),void 0!==I.tint&&g.addAttribute("tint",I.tint)):void 0!==I.indexed?g.addAttribute("indexed",I.indexed):g.addAttribute("auto","1"),g.closeNode(),!0)}parseOpen(g){return g.name===this.name&&(g.attributes.rgb?this.model={argb:g.attributes.rgb}:g.attributes.theme?(this.model={theme:parseInt(g.attributes.theme,10)},g.attributes.tint&&(this.model.tint=parseFloat(g.attributes.tint))):g.attributes.indexed?this.model={indexed:parseInt(g.attributes.indexed,10)}:this.model=void 0,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],129:[function(g,I,C){const A=g("../base-xform"),i=g("./alignment-xform"),e=g("./border-xform"),t=g("./fill-xform"),l=g("./font-xform"),s=g("./numfmt-xform"),o=g("./protection-xform");class c extends A{constructor(){super(),this.map={alignment:new i,border:new e,fill:new t,font:new l,numFmt:new s,protection:new o}}get tag(){return"dxf"}render(g,I){if(g.openNode(this.tag),I.font&&this.map.font.render(g,I.font),I.numFmt&&I.numFmtId){const C={id:I.numFmtId,formatCode:I.numFmt};this.map.numFmt.render(g,C)}I.fill&&this.map.fill.render(g,I.fill),I.alignment&&this.map.alignment.render(g,I.alignment),I.border&&this.map.border.render(g,I.border),I.protection&&this.map.protection.render(g,I.protection),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag?(this.reset(),!0):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1)}}I.exports=c},{"../base-xform":32,"./alignment-xform":126,"./border-xform":127,"./fill-xform":130,"./font-xform":131,"./numfmt-xform":132,"./protection-xform":133}],130:[function(g,I,C){const A=g("../base-xform"),i=g("./color-xform");class e extends A{constructor(){super(),this.map={color:new i}}get tag(){return"stop"}render(g,I){g.openNode("stop"),g.addAttribute("position",I.position),this.map.color.render(g,I.color),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"stop":return this.model={position:parseFloat(g.attributes.position)},!0;case"color":return this.parser=this.map.color,this.parser.parseOpen(g),!0;default:return!1}}parseText(){}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.model.color=this.parser.model,this.parser=void 0),!0)}}class t extends A{constructor(){super(),this.map={fgColor:new i("fgColor"),bgColor:new i("bgColor")}}get name(){return"pattern"}get tag(){return"patternFill"}render(g,I){g.openNode("patternFill"),g.addAttribute("patternType",I.pattern),I.fgColor&&this.map.fgColor.render(g,I.fgColor),I.bgColor&&this.map.bgColor.render(g,I.bgColor),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"patternFill"===g.name?(this.model={type:"pattern",pattern:g.attributes.patternType},!0):(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.parser.model&&(this.model[g]=this.parser.model),this.parser=void 0),!0)}}class l extends A{constructor(){super(),this.map={stop:new e}}get name(){return"gradient"}get tag(){return"gradientFill"}render(g,I){switch(g.openNode("gradientFill"),I.gradient){case"angle":g.addAttribute("degree",I.degree);break;case"path":g.addAttribute("type","path"),I.center.left&&(g.addAttribute("left",I.center.left),void 0===I.center.right&&g.addAttribute("right",I.center.left)),I.center.right&&g.addAttribute("right",I.center.right),I.center.top&&(g.addAttribute("top",I.center.top),void 0===I.center.bottom&&g.addAttribute("bottom",I.center.top)),I.center.bottom&&g.addAttribute("bottom",I.center.bottom)}const C=this.map.stop;I.stops.forEach((I=>{C.render(g,I)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"gradientFill":{const I=this.model={stops:[]};return g.attributes.degree?(I.gradient="angle",I.degree=parseInt(g.attributes.degree,10)):"path"===g.attributes.type&&(I.gradient="path",I.center={left:g.attributes.left?parseFloat(g.attributes.left):0,top:g.attributes.top?parseFloat(g.attributes.top):0},g.attributes.right!==g.attributes.left&&(I.center.right=g.attributes.right?parseFloat(g.attributes.right):0),g.attributes.bottom!==g.attributes.top&&(I.center.bottom=g.attributes.bottom?parseFloat(g.attributes.bottom):0)),!0}case"stop":return this.parser=this.map.stop,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0)}}class s extends A{constructor(){super(),this.map={patternFill:new t,gradientFill:new l}}get tag(){return"fill"}render(g,I){switch(g.addRollback(),g.openNode("fill"),I.type){case"pattern":this.map.patternFill.render(g,I);break;case"gradient":this.map.gradientFill.render(g,I);break;default:return void g.rollback()}g.closeNode(),g.commit()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"fill"===g.name?(this.model={},!0):(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0)}validStyle(g){return s.validPatternValues[g]}}s.validPatternValues=["none","solid","darkVertical","darkGray","mediumGray","lightGray","gray125","gray0625","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","lightGrid"].reduce(((g,I)=>(g[I]=!0,g)),{}),s.StopXform=e,s.PatternFillXform=t,s.GradientFillXform=l,I.exports=s},{"../base-xform":32,"./color-xform":128}],131:[function(g,I,C){const A=g("./color-xform"),i=g("../simple/boolean-xform"),e=g("../simple/integer-xform"),t=g("../simple/string-xform"),l=g("./underline-xform"),s=g("../../../utils/under-dash"),o=g("../base-xform");class c extends o{constructor(g){super(),this.options=g||c.OPTIONS,this.map={b:{prop:"bold",xform:new i({tag:"b",attr:"val"})},i:{prop:"italic",xform:new i({tag:"i",attr:"val"})},u:{prop:"underline",xform:new l},charset:{prop:"charset",xform:new e({tag:"charset",attr:"val"})},color:{prop:"color",xform:new A},condense:{prop:"condense",xform:new i({tag:"condense",attr:"val"})},extend:{prop:"extend",xform:new i({tag:"extend",attr:"val"})},family:{prop:"family",xform:new e({tag:"family",attr:"val"})},outline:{prop:"outline",xform:new i({tag:"outline",attr:"val"})},vertAlign:{prop:"vertAlign",xform:new t({tag:"vertAlign",attr:"val"})},scheme:{prop:"scheme",xform:new t({tag:"scheme",attr:"val"})},shadow:{prop:"shadow",xform:new i({tag:"shadow",attr:"val"})},strike:{prop:"strike",xform:new i({tag:"strike",attr:"val"})},sz:{prop:"size",xform:new e({tag:"sz",attr:"val"})}},this.map[this.options.fontNameTag]={prop:"name",xform:new t({tag:this.options.fontNameTag,attr:"val"})}}get tag(){return this.options.tagName}render(g,I){const{map:C}=this;g.openNode(this.options.tagName),s.each(this.map,((A,i)=>{C[i].xform.render(g,I[A.prop])})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):this.map[g.name]?(this.parser=this.map[g.name].xform,this.parser.parseOpen(g)):g.name===this.options.tagName&&(this.model={},!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser&&!this.parser.parseClose(g)){const I=this.map[g];return this.parser.model&&(this.model[I.prop]=this.parser.model),this.parser=void 0,!0}return g!==this.options.tagName}}c.OPTIONS={tagName:"font",fontNameTag:"name"},I.exports=c},{"../../../utils/under-dash":26,"../base-xform":32,"../simple/boolean-xform":116,"../simple/integer-xform":118,"../simple/string-xform":119,"./color-xform":128,"./underline-xform":136}],132:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../defaultnumformats"),e=g("../base-xform");function t(){const g={};return A.each(i,((I,C)=>{I.f&&(g[I.f]=parseInt(C,10))})),g}const l=t();class s extends e{constructor(g,I){super(),this.id=g,this.formatCode=I}get tag(){return"numFmt"}render(g,I){g.leafNode("numFmt",{numFmtId:I.id,formatCode:I.formatCode})}parseOpen(g){return"numFmt"===g.name&&(this.model={id:parseInt(g.attributes.numFmtId,10),formatCode:g.attributes.formatCode.replace(/[\\](.)/g,"$1")},!0)}parseText(){}parseClose(){return!1}}s.getDefaultFmtId=function(g){return l[g]},s.getDefaultFmtCode=function(g){return i[g]&&i[g].f},I.exports=s},{"../../../utils/under-dash":26,"../../defaultnumformats":30,"../base-xform":32}],133:[function(g,I,C){const A=g("../base-xform"),i={boolean:(g,I)=>void 0===g?I:g};class e extends A{get tag(){return"protection"}render(g,I){g.addRollback(),g.openNode("protection");let C=!1;function A(I,A){void 0!==A&&(g.addAttribute(I,A),C=!0)}A("locked",i.boolean(I.locked,!0)?void 0:"0"),A("hidden",i.boolean(I.hidden,!1)?"1":void 0),g.closeNode(),C?g.commit():g.rollback()}parseOpen(g){const I={locked:!("0"===g.attributes.locked),hidden:"1"===g.attributes.hidden},C=!I.locked||I.hidden;this.model=C?I:null}parseText(){}parseClose(){return!1}}I.exports=e},{"../base-xform":32}],134:[function(g,I,C){const A=g("../base-xform"),i=g("./alignment-xform"),e=g("./protection-xform");class t extends A{constructor(g){super(),this.xfId=!(!g||!g.xfId),this.map={alignment:new i,protection:new e}}get tag(){return"xf"}render(g,I){g.openNode("xf",{numFmtId:I.numFmtId||0,fontId:I.fontId||0,fillId:I.fillId||0,borderId:I.borderId||0}),this.xfId&&g.addAttribute("xfId",I.xfId||0),I.numFmtId&&g.addAttribute("applyNumberFormat","1"),I.fontId&&g.addAttribute("applyFont","1"),I.fillId&&g.addAttribute("applyFill","1"),I.borderId&&g.addAttribute("applyBorder","1"),I.alignment&&g.addAttribute("applyAlignment","1"),I.protection&&g.addAttribute("applyProtection","1"),I.alignment&&this.map.alignment.render(g,I.alignment),I.protection&&this.map.protection.render(g,I.protection),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"xf":return this.model={numFmtId:parseInt(g.attributes.numFmtId,10),fontId:parseInt(g.attributes.fontId,10),fillId:parseInt(g.attributes.fillId,10),borderId:parseInt(g.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(g.attributes.xfId,10)),!0;case"alignment":return this.parser=this.map.alignment,this.parser.parseOpen(g),!0;case"protection":return this.parser=this.map.protection,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):"xf"!==g}}I.exports=t},{"../base-xform":32,"./alignment-xform":126,"./protection-xform":133}],135:[function(g,I,C){const A=g("../../../doc/enums"),i=g("../../../utils/xml-stream"),e=g("../base-xform"),t=g("../static-xform"),l=g("../list-xform"),s=g("./font-xform"),o=g("./fill-xform"),c=g("./border-xform"),d=g("./numfmt-xform"),a=g("./style-xform"),n=g("./dxf-xform"),r=164;class m extends e{constructor(g){super(),this.map={numFmts:new l({tag:"numFmts",count:!0,childXform:new d}),fonts:new l({tag:"fonts",count:!0,childXform:new s,$:{"x14ac:knownFonts":1}}),fills:new l({tag:"fills",count:!0,childXform:new o}),borders:new l({tag:"borders",count:!0,childXform:new c}),cellStyleXfs:new l({tag:"cellStyleXfs",count:!0,childXform:new a}),cellXfs:new l({tag:"cellXfs",count:!0,childXform:new a({xfId:!0})}),dxfs:new l({tag:"dxfs",always:!0,count:!0,childXform:new n}),numFmt:new d,font:new s,fill:new o,border:new c,style:new a({xfId:!0}),cellStyles:m.STATIC_XFORMS.cellStyles,tableStyles:m.STATIC_XFORMS.tableStyles,extLst:m.STATIC_XFORMS.extLst},g&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:"pattern",pattern:"none"}),this._addFill({type:"pattern",pattern:"gray125"}),this.weakMap=new WeakMap}render(g,I){I=I||this.model,g.openXml(i.StdDocAttributes),g.openNode("styleSheet",m.STYLESHEET_ATTRIBUTES),this.index?(I.numFmts&&I.numFmts.length&&(g.openNode("numFmts",{count:I.numFmts.length}),I.numFmts.forEach((I=>{g.writeXml(I)})),g.closeNode()),I.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),g.openNode("fonts",{count:I.fonts.length,"x14ac:knownFonts":1}),I.fonts.forEach((I=>{g.writeXml(I)})),g.closeNode(),g.openNode("fills",{count:I.fills.length}),I.fills.forEach((I=>{g.writeXml(I)})),g.closeNode(),g.openNode("borders",{count:I.borders.length}),I.borders.forEach((I=>{g.writeXml(I)})),g.closeNode(),this.map.cellStyleXfs.render(g,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),g.openNode("cellXfs",{count:I.styles.length}),I.styles.forEach((I=>{g.writeXml(I)})),g.closeNode()):(this.map.numFmts.render(g,I.numFmts),this.map.fonts.render(g,I.fonts),this.map.fills.render(g,I.fills),this.map.borders.render(g,I.borders),this.map.cellStyleXfs.render(g,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(g,I.styles)),m.STATIC_XFORMS.cellStyles.render(g),this.map.dxfs.render(g,I.dxfs),m.STATIC_XFORMS.tableStyles.render(g),m.STATIC_XFORMS.extLst.render(g),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"styleSheet"===g.name?(this.initIndex(),!0):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;if("styleSheet"===g){this.model={};const g=(g,I)=>{I.model&&I.model.length&&(this.model[g]=I.model)};if(g("numFmts",this.map.numFmts),g("fonts",this.map.fonts),g("fills",this.map.fills),g("borders",this.map.borders),g("styles",this.map.cellXfs),g("dxfs",this.map.dxfs),this.index={model:[],numFmt:[]},this.model.numFmts){const g=this.index.numFmt;this.model.numFmts.forEach((I=>{g[I.id]=I.formatCode}))}return!1}return!0}addStyleModel(g,I){if(!g)return 0;if(this.model.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),this.weakMap&&this.weakMap.has(g))return this.weakMap.get(g);const C={};if(I=I||A.ValueType.Number,g.numFmt)C.numFmtId=this._addNumFmtStr(g.numFmt);else switch(I){case A.ValueType.Number:C.numFmtId=this._addNumFmtStr("General");break;case A.ValueType.Date:C.numFmtId=this._addNumFmtStr("mm-dd-yy")}g.font&&(C.fontId=this._addFont(g.font)),g.border&&(C.borderId=this._addBorder(g.border)),g.fill&&(C.fillId=this._addFill(g.fill)),g.alignment&&(C.alignment=g.alignment),g.protection&&(C.protection=g.protection);const i=this._addStyle(C);return this.weakMap&&this.weakMap.set(g,i),i}getStyleModel(g){const I=this.model.styles[g];if(!I)return null;let C=this.index.model[g];if(C)return C;if(C=this.index.model[g]={},I.numFmtId){const g=this.index.numFmt[I.numFmtId]||d.getDefaultFmtCode(I.numFmtId);g&&(C.numFmt=g)}function A(g,I,A){if(A||0===A){const i=I[A];i&&(C[g]=i)}}return A("font",this.model.fonts,I.fontId),A("border",this.model.borders,I.borderId),A("fill",this.model.fills,I.fillId),I.alignment&&(C.alignment=I.alignment),I.protection&&(C.protection=I.protection),C}addDxfStyle(g){return g.numFmt&&(g.numFmtId=this._addNumFmtStr(g.numFmt)),this.model.dxfs.push(g),this.model.dxfs.length-1}getDxfStyle(g){return this.model.dxfs[g]}_addStyle(g){const I=this.map.style.toXml(g);let C=this.index.style[I];return void 0===C&&(C=this.index.style[I]=this.model.styles.length,this.model.styles.push(I)),C}_addNumFmtStr(g){let I=d.getDefaultFmtId(g);if(void 0!==I)return I;if(I=this.index.numFmt[g],void 0!==I)return I;I=this.index.numFmt[g]=r+this.model.numFmts.length;const C=this.map.numFmt.toXml({id:I,formatCode:g});return this.model.numFmts.push(C),I}_addFont(g){const I=this.map.font.toXml(g);let C=this.index.font[I];return void 0===C&&(C=this.index.font[I]=this.model.fonts.length,this.model.fonts.push(I)),C}_addBorder(g){const I=this.map.border.toXml(g);let C=this.index.border[I];return void 0===C&&(C=this.index.border[I]=this.model.borders.length,this.model.borders.push(I)),C}_addFill(g){const I=this.map.fill.toXml(g);let C=this.index.fill[I];return void 0===C&&(C=this.index.fill[I]=this.model.fills.length,this.model.fills.push(I)),C}}m.STYLESHEET_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac x16r2","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:x16r2":"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"},m.STATIC_XFORMS={cellStyles:new t({tag:"cellStyles",$:{count:1},c:[{tag:"cellStyle",$:{name:"Normal",xfId:0,builtinId:0}}]}),dxfs:new t({tag:"dxfs",$:{count:0}}),tableStyles:new t({tag:"tableStyles",$:{count:0,defaultTableStyle:"TableStyleMedium2",defaultPivotStyle:"PivotStyleLight16"}}),extLst:new t({tag:"extLst",c:[{tag:"ext",$:{uri:"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"},c:[{tag:"x14:slicerStyles",$:{defaultSlicerStyle:"SlicerStyleLight1"}}]},{tag:"ext",$:{uri:"{9260A510-F301-46a8-8635-F512D64BE5F5}","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},c:[{tag:"x15:timelineStyles",$:{defaultTimelineStyle:"TimeSlicerStyleLight1"}}]}]})};class h extends m{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}],borders:[{}],fills:[{type:"pattern",pattern:"none"},{type:"pattern",pattern:"gray125"}]}}parseStream(g){return g.autodrain(),Promise.resolve()}addStyleModel(g,I){return I===A.ValueType.Date?this.dateStyleId:0}get dateStyleId(){if(!this._dateStyleId){const g={numFmtId:d.getDefaultFmtId("mm-dd-yy")};this._dateStyleId=this.model.styles.length,this.model.styles.push(g)}return this._dateStyleId}getStyleModel(){return{}}}m.Mock=h,I.exports=m},{"../../../doc/enums":7,"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"../static-xform":120,"./border-xform":127,"./dxf-xform":129,"./fill-xform":130,"./font-xform":131,"./numfmt-xform":132,"./style-xform":134}],136:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.model=g}get tag(){return"u"}render(g,I){if(!0===(I=I||this.model))g.leafNode("u");else{const C=i.Attributes[I];C&&g.leafNode("u",C)}}parseOpen(g){"u"===g.name&&(this.model=g.attributes.val||!0)}parseText(){}parseClose(){return!1}}i.Attributes={single:{},double:{val:"double"},singleAccounting:{val:"singleAccounting"},doubleAccounting:{val:"doubleAccounting"}},I.exports=i},{"../base-xform":32}],137:[function(g,I,C){const A=g("../base-xform"),i=g("./filter-column-xform");class e extends A{constructor(){super(),this.map={filterColumn:new i}}get tag(){return"autoFilter"}prepare(g){g.columns.forEach(((g,I)=>{this.map.filterColumn.prepare(g,{index:I})}))}render(g,I){return g.openNode(this.tag,{ref:I.autoFilterRef}),I.columns.forEach((I=>{this.map.filterColumn.render(g,I)})),g.closeNode(),!0}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;if(g.name===this.tag)return this.model={autoFilterRef:g.attributes.ref,columns:[]},!0;if(this.parser=this.map[g.name],this.parser)return this.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;if(g===this.tag)return!1;throw new Error(`Unexpected xml node in parseClose: ${g}`)}}I.exports=e},{"../base-xform":32,"./filter-column-xform":139}],138:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"customFilter"}render(g,I){g.leafNode(this.tag,{val:I.val,operator:I.operator})}parseOpen(g){return g.name===this.tag&&(this.model={val:g.attributes.val,operator:g.attributes.operator},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],139:[function(g,I,C){const A=g("../base-xform"),i=g("../list-xform"),e=g("./custom-filter-xform"),t=g("./filter-xform");class l extends A{constructor(){super(),this.map={customFilters:new i({tag:"customFilters",count:!1,empty:!0,childXform:new e}),filters:new i({tag:"filters",count:!1,empty:!0,childXform:new t})}}get tag(){return"filterColumn"}prepare(g,I){g.colId=I.index.toString()}render(g,I){return I.customFilters?(g.openNode(this.tag,{colId:I.colId,hiddenButton:I.filterButton?"0":"1"}),this.map.customFilters.render(g,I.customFilters),g.closeNode(),!0):(g.leafNode(this.tag,{colId:I.colId,hiddenButton:I.filterButton?"0":"1"}),!0)}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;const{attributes:I}=g;if(g.name===this.tag)return this.model={filterButton:"0"===I.hiddenButton},!0;if(this.parser=this.map[g.name],this.parser)return this.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.customFilters=this.map.customFilters.model,!1)}}I.exports=l},{"../base-xform":32,"../list-xform":71,"./custom-filter-xform":138,"./filter-xform":140}],140:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"filter"}render(g,I){g.leafNode(this.tag,{val:I.val})}parseOpen(g){return g.name===this.tag&&(this.model={val:g.attributes.val},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],141:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"tableColumn"}prepare(g,I){g.id=I.index+1}render(g,I){return g.leafNode(this.tag,{id:I.id.toString(),name:I.name,totalsRowLabel:I.totalsRowLabel,totalsRowFunction:I.totalsRowFunction,dxfId:I.dxfId}),!0}parseOpen(g){if(g.name===this.tag){const{attributes:I}=g;return this.model={name:I.name,totalsRowLabel:I.totalsRowLabel,totalsRowFunction:I.totalsRowFunction,dxfId:I.dxfId},!0}return!1}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],142:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"tableStyleInfo"}render(g,I){return g.leafNode(this.tag,{name:I.theme?I.theme:void 0,showFirstColumn:I.showFirstColumn?"1":"0",showLastColumn:I.showLastColumn?"1":"0",showRowStripes:I.showRowStripes?"1":"0",showColumnStripes:I.showColumnStripes?"1":"0"}),!0}parseOpen(g){if(g.name===this.tag){const{attributes:I}=g;return this.model={theme:I.name?I.name:null,showFirstColumn:"1"===I.showFirstColumn,showLastColumn:"1"===I.showLastColumn,showRowStripes:"1"===I.showRowStripes,showColumnStripes:"1"===I.showColumnStripes},!0}return!1}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],143:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("../list-xform"),t=g("./auto-filter-xform"),l=g("./table-column-xform"),s=g("./table-style-info-xform");class o extends i{constructor(){super(),this.map={autoFilter:new t,tableColumns:new e({tag:"tableColumns",count:!0,empty:!0,childXform:new l}),tableStyleInfo:new s}}prepare(g,I){this.map.autoFilter.prepare(g),this.map.tableColumns.prepare(g.columns,I)}get tag(){return"table"}render(g,I){g.openXml(A.StdDocAttributes),g.openNode(this.tag,{...o.TABLE_ATTRIBUTES,id:I.id,name:I.name,displayName:I.displayName||I.name,ref:I.tableRef,totalsRowCount:I.totalsRow?"1":void 0,totalsRowShown:I.totalsRow?void 0:"1",headerRowCount:I.headerRow?"1":"0"}),this.map.autoFilter.render(g,I),this.map.tableColumns.render(g,I.columns),this.map.tableStyleInfo.render(g,I.style),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;const{name:I,attributes:C}=g;return I===this.tag?(this.reset(),this.model={name:C.name,displayName:C.displayName||C.name,tableRef:C.ref,totalsRow:"1"===C.totalsRowCount,headerRow:"1"===C.headerRowCount}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach(((g,I)=>{this.model.columns[I].filterButton=g.filterButton}))),this.model.style=this.map.tableStyleInfo.model,!1)}reconcile(g,I){g.columns.forEach((g=>{void 0!==g.dxfId&&(g.style=I.styles.getDxfStyle(g.dxfId))}))}}o.TABLE_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"xr xr3","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr3":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"},I.exports=o},{"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"./auto-filter-xform":137,"./table-column-xform":141,"./table-style-info-xform":142}],144:[function(g,I,C){(function(C,A){(function(){const i=g("fs"),e=g("jszip"),{PassThrough:t}=g("readable-stream"),l=g("../utils/zip-stream"),s=g("../utils/stream-buf"),o=g("../utils/utils"),c=g("../utils/xml-stream"),{bufferToString:d}=g("../utils/browser-buffer-decode"),a=g("./xform/style/styles-xform"),n=g("./xform/core/core-xform"),r=g("./xform/strings/shared-strings-xform"),m=g("./xform/core/relationships-xform"),h=g("./xform/core/content-types-xform"),Z=g("./xform/core/app-xform"),b=g("./xform/book/workbook-xform"),G=g("./xform/sheet/worksheet-xform"),u=g("./xform/drawing/drawing-xform"),p=g("./xform/table/table-xform"),w=g("./xform/comment/comments-xform"),W=g("./xform/comment/vml-notes-xform"),B=g("./xml/theme1");function y(g,I){return new Promise(((C,A)=>{i.readFile(g,I,((g,I)=>{g?A(g):C(I)}))}))}class V{constructor(g){this.workbook=g}async readFile(g,I){if(!(await o.fs.exists(g)))throw new Error(`File not found: ${g}`);const C=i.createReadStream(g);try{const g=await this.read(C,I);return C.close(),g}catch(A){throw C.close(),A}}parseRels(g){return(new m).parseStream(g)}parseWorkbook(g){return(new b).parseStream(g)}parseSharedStrings(g){return(new r).parseStream(g)}reconcile(g,I){const C=new b,A=new G(I),i=new u,e=new p;C.reconcile(g);const t={media:g.media,mediaIndex:g.mediaIndex};Object.keys(g.drawings).forEach((I=>{const C=g.drawings[I],A=g.drawingRels[I];A&&(t.rels=A.reduce(((g,I)=>(g[I.Id]=I,g)),{}),(C.anchors||[]).forEach((g=>{const I=g.picture&&g.picture.hyperlinks;I&&t.rels[I.rId]&&(I.hyperlink=t.rels[I.rId].Target,delete I.rId)})),i.reconcile(C,t))}));const l={styles:g.styles};Object.values(g.tables).forEach((g=>{e.reconcile(g,l)}));const s={styles:g.styles,sharedStrings:g.sharedStrings,media:g.media,mediaIndex:g.mediaIndex,date1904:g.properties&&g.properties.date1904,drawings:g.drawings,comments:g.comments,tables:g.tables,vmlDrawings:g.vmlDrawings};g.worksheets.forEach((I=>{I.relationships=g.worksheetRels[I.sheetNo],A.reconcile(I,s)})),delete g.worksheetHash,delete g.worksheetRels,delete g.globalRels,delete g.sharedStrings,delete g.workbookRels,delete g.sheetDefs,delete g.styles,delete g.mediaIndex,delete g.drawings,delete g.drawingRels,delete g.vmlDrawings}async _processWorksheetEntry(g,I,C,A,i){const e=new G(A),t=await e.parseStream(g);t.sheetNo=C,I.worksheetHash[i]=t,I.worksheets.push(t)}async _processCommentEntry(g,I,C){const A=new w,i=await A.parseStream(g);I.comments[`../${C}.xml`]=i}async _processTableEntry(g,I,C){const A=new p,i=await A.parseStream(g);I.tables[`../tables/${C}.xml`]=i}async _processWorksheetRelsEntry(g,I,C){const A=new m,i=await A.parseStream(g);I.worksheetRels[C]=i}async _processMediaEntry(g,I,C){const A=C.lastIndexOf(".");if(A>=1){const i=C.substr(A+1),e=C.substr(0,A);await new Promise(((A,t)=>{const l=new s;l.on("finish",(()=>{I.mediaIndex[C]=I.media.length,I.mediaIndex[e]=I.media.length;const g={type:"image",name:e,extension:i,buffer:l.toBuffer()};I.media.push(g),A()})),g.on("error",(g=>{t(g)})),g.pipe(l)}))}}async _processDrawingEntry(g,I,C){const A=new u,i=await A.parseStream(g);I.drawings[C]=i}async _processDrawingRelsEntry(g,I,C){const A=new m,i=await A.parseStream(g);I.drawingRels[C]=i}async _processVmlDrawingEntry(g,I,C){const A=new W,i=await A.parseStream(g);I.vmlDrawings[`../drawings/${C}.vml`]=i}async _processThemeEntry(g,I,C){await new Promise(((A,i)=>{const e=new s;g.on("error",i),e.on("error",i),e.on("finish",(()=>{I.themes[C]=e.read().toString(),A()})),g.pipe(e)}))}createInputStream(){throw new Error("`XLSX#createInputStream` is deprecated. You should use `XLSX#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}async read(g,I){!g[Symbol.asyncIterator]&&g.pipe&&(g=g.pipe(new t));const C=[];for await(const A of g)C.push(A);return this.load(A.concat(C),I)}async load(g,I){let i;i=I&&I.base64?A.from(g.toString(),"base64"):g;const l={worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},comments:{},tables:{},vmlDrawings:{}},s=await e.loadAsync(i);for(const A of Object.values(s.files))if(!A.dir){let g,i=A.name;if("/"===i[0]&&(i=i.substr(1)),i.match(/xl\/media\//)||i.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/))g=new t,g.write(await A.async("nodebuffer"));else{let I;g=new t({writableObjectMode:!0,readableObjectMode:!0}),I=C.browser?d(await A.async("nodebuffer")):await A.async("string");const i=16384;for(let C=0;C{if("image"===I.type){const C=`xl/media/${I.name}.${I.extension}`;if(I.filename){const A=await y(I.filename);return g.append(A,{name:C})}if(I.buffer)return g.append(I.buffer,{name:C});if(I.base64){const A=I.base64,i=A.substring(A.indexOf(",")+1);return g.append(i,{name:C,base64:!0})}}throw new Error("Unsupported media")})))}addDrawings(g,I){const C=new u,A=new m;I.worksheets.forEach((I=>{const{drawing:i}=I;if(i){C.prepare(i,{});let I=C.toXml(i);g.append(I,{name:`xl/drawings/${i.name}.xml`}),I=A.toXml(i.rels),g.append(I,{name:`xl/drawings/_rels/${i.name}.xml.rels`})}}))}addTables(g,I){const C=new p;I.worksheets.forEach((I=>{const{tables:A}=I;A.forEach((I=>{C.prepare(I,{});const A=C.toXml(I);g.append(A,{name:`xl/tables/${I.target}`})}))}))}async addContentTypes(g,I){const C=(new h).toXml(I);g.append(C,{name:"[Content_Types].xml"})}async addApp(g,I){const C=(new Z).toXml(I);g.append(C,{name:"docProps/app.xml"})}async addCore(g,I){const C=new n;g.append(C.toXml(I),{name:"docProps/core.xml"})}async addThemes(g,I){const C=I.themes||{theme1:B};Object.keys(C).forEach((I=>{const A=C[I],i=`xl/theme/${I}.xml`;g.append(A,{name:i})}))}async addOfficeRels(g){const I=(new m).toXml([{Id:"rId1",Type:V.RelType.OfficeDocument,Target:"xl/workbook.xml"},{Id:"rId2",Type:V.RelType.CoreProperties,Target:"docProps/core.xml"},{Id:"rId3",Type:V.RelType.ExtenderProperties,Target:"docProps/app.xml"}]);g.append(I,{name:"_rels/.rels"})}async addWorkbookRels(g,I){let C=1;const A=[{Id:"rId"+C++,Type:V.RelType.Styles,Target:"styles.xml"},{Id:"rId"+C++,Type:V.RelType.Theme,Target:"theme/theme1.xml"}];I.sharedStrings.count&&A.push({Id:"rId"+C++,Type:V.RelType.SharedStrings,Target:"sharedStrings.xml"}),I.worksheets.forEach((g=>{g.rId="rId"+C++,A.push({Id:g.rId,Type:V.RelType.Worksheet,Target:`worksheets/sheet${g.id}.xml`})}));const i=(new m).toXml(A);g.append(i,{name:"xl/_rels/workbook.xml.rels"})}async addSharedStrings(g,I){I.sharedStrings&&I.sharedStrings.count&&g.append(I.sharedStrings.xml,{name:"xl/sharedStrings.xml"})}async addStyles(g,I){const{xml:C}=I.styles;C&&g.append(C,{name:"xl/styles.xml"})}async addWorkbook(g,I){const C=new b;g.append(C.toXml(I),{name:"xl/workbook.xml"})}async addWorksheets(g,I){const C=new G,A=new m,i=new w,e=new W;I.worksheets.forEach((I=>{let t=new c;C.render(t,I),g.append(t.xml,{name:`xl/worksheets/sheet${I.id}.xml`}),I.rels&&I.rels.length&&(t=new c,A.render(t,I.rels),g.append(t.xml,{name:`xl/worksheets/_rels/sheet${I.id}.xml.rels`})),I.comments.length>0&&(t=new c,i.render(t,I),g.append(t.xml,{name:`xl/comments${I.id}.xml`}),t=new c,e.render(t,I),g.append(t.xml,{name:`xl/drawings/vmlDrawing${I.id}.vml`}))}))}_finalize(g){return new Promise(((I,C)=>{g.on("finish",(()=>{I(this)})),g.on("error",C),g.finalize()}))}prepareModel(g,I){g.creator=g.creator||"ExcelJS",g.lastModifiedBy=g.lastModifiedBy||"ExcelJS",g.created=g.created||new Date,g.modified=g.modified||new Date,g.useSharedStrings=void 0===I.useSharedStrings||I.useSharedStrings,g.useStyles=void 0===I.useStyles||I.useStyles,g.sharedStrings=new r,g.styles=g.useStyles?new a(!0):new a.Mock;const C=new b,A=new G;C.prepare(g);const i={sharedStrings:g.sharedStrings,styles:g.styles,date1904:g.properties.date1904,drawingsCount:0,media:g.media};i.drawings=g.drawings=[],i.commentRefs=g.commentRefs=[];let e=0;g.tables=[],g.worksheets.forEach((I=>{I.tables.forEach((I=>{e++,I.target=`table${e}.xml`,I.id=e,g.tables.push(I)})),A.prepare(I,i)}))}async write(g,I){I=I||{};const{model:C}=this.workbook,A=new l.ZipWriter(I.zip);return A.pipe(g),this.prepareModel(C,I),await this.addContentTypes(A,C),await this.addOfficeRels(A,C),await this.addWorkbookRels(A,C),await this.addWorksheets(A,C),await this.addSharedStrings(A,C),await this.addDrawings(A,C),await this.addTables(A,C),await Promise.all([this.addThemes(A,C),this.addStyles(A,C)]),await this.addMedia(A,C),await Promise.all([this.addApp(A,C),this.addCore(A,C)]),await this.addWorkbook(A,C),this._finalize(A)}writeFile(g,I){const C=i.createWriteStream(g);return new Promise(((g,A)=>{C.on("finish",(()=>{g()})),C.on("error",(g=>{A(g)})),this.write(C,I).then((()=>{C.end()})).catch((g=>{A(g)}))}))}async writeBuffer(g){const I=new s;return await this.write(I,g),I.read()}}V.RelType=g("./rel-type"),I.exports=V}).call(this)}).call(this,g("_process"),g("buffer").Buffer)},{"../utils/browser-buffer-decode":16,"../utils/stream-buf":24,"../utils/utils":27,"../utils/xml-stream":28,"../utils/zip-stream":29,"./rel-type":31,"./xform/book/workbook-xform":38,"./xform/comment/comments-xform":40,"./xform/comment/vml-notes-xform":45,"./xform/core/app-xform":51,"./xform/core/content-types-xform":52,"./xform/core/core-xform":53,"./xform/core/relationships-xform":55,"./xform/drawing/drawing-xform":62,"./xform/sheet/worksheet-xform":115,"./xform/strings/shared-strings-xform":124,"./xform/style/styles-xform":135,"./xform/table/table-xform":143,"./xml/theme1":145,_process:467,buffer:220,fs:216,jszip:441,"readable-stream":491}],145:[function(g,I,C){I.exports='\n '},{}],146:[function(g,I,C){(function(I){(function(){Object.defineProperty(C,"__esModule",{value:!0}),C.CsvFormatterStream=void 0;const A=g("stream"),i=g("./formatter");class e extends A.Transform{constructor(g){super({writableObjectMode:g.objectMode}),this.hasWrittenBOM=!1,this.formatterOptions=g,this.rowFormatter=new i.RowFormatter(g),this.hasWrittenBOM=!g.writeBOM}transform(g){return this.rowFormatter.rowTransform=g,this}_transform(g,C,A){let i=!1;try{this.hasWrittenBOM||(this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0),this.rowFormatter.format(g,((g,C)=>g?(i=!0,A(g)):(C&&C.forEach((g=>{this.push(I.from(g,"utf8"))})),i=!0,A())))}catch(e){if(i)throw e;A(e)}}_flush(g){this.rowFormatter.finish(((C,A)=>C?g(C):(A&&A.forEach((g=>{this.push(I.from(g,"utf8"))})),g())))}}C.CsvFormatterStream=e}).call(this)}).call(this,g("buffer").Buffer)},{"./formatter":150,buffer:220,stream:505}],147:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.FormatterOptions=void 0;class A{constructor(){let g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var I;this.objectMode=!0,this.delimiter=",",this.rowDelimiter="\n",this.quote='"',this.escape=this.quote,this.quoteColumns=!1,this.quoteHeaders=this.quoteColumns,this.headers=null,this.includeEndRowDelimiter=!1,this.writeBOM=!1,this.BOM="\ufeff",this.alwaysWriteHeaders=!1,Object.assign(this,g||{}),void 0===(null==g?void 0:g.quoteHeaders)&&(this.quoteHeaders=this.quoteColumns),!0===(null==g?void 0:g.quote)?this.quote='"':!1===(null==g?void 0:g.quote)&&(this.quote=""),"string"!=typeof(null==g?void 0:g.escape)&&(this.escape=this.quote),this.shouldWriteHeaders=!!this.headers&&(null===(I=g.writeHeaders)||void 0===I||I),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote=`${this.escape}${this.quote}`}}C.FormatterOptions=A},{}],148:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.FieldFormatter=void 0;const i=A(g("lodash.isboolean")),e=A(g("lodash.isnil")),t=A(g("lodash.escaperegexp"));class l{constructor(g){this._headers=null,this.formatterOptions=g,null!==g.headers&&(this.headers=g.headers),this.REPLACE_REGEXP=new RegExp(g.quote,"g");const I=`[${g.delimiter}${t.default(g.rowDelimiter)}|\r|\n]`;this.ESCAPE_REGEXP=new RegExp(I)}set headers(g){this._headers=g}shouldQuote(g,I){const C=I?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;return i.default(C)?C:Array.isArray(C)?C[g]:null!==this._headers&&C[this._headers[g]]}format(g,I,C){const A=`${e.default(g)?"":g}`.replace(/\0/g,""),{formatterOptions:i}=this;return""!==i.quote&&-1!==A.indexOf(i.quote)?this.quoteField(A.replace(this.REPLACE_REGEXP,i.escapedQuote)):-1!==A.search(this.ESCAPE_REGEXP)||this.shouldQuote(I,C)?this.quoteField(A):A}quoteField(g){const{quote:I}=this.formatterOptions;return`${I}${g}${I}`}}C.FieldFormatter=l},{"lodash.escaperegexp":442,"lodash.isboolean":444,"lodash.isnil":447}],149:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.RowFormatter=void 0;const i=A(g("lodash.isfunction")),e=A(g("lodash.isequal")),t=g("./FieldFormatter"),l=g("../types");class s{constructor(g){this.rowCount=0,this.formatterOptions=g,this.fieldFormatter=new t.FieldFormatter(g),this.headers=g.headers,this.shouldWriteHeaders=g.shouldWriteHeaders,this.hasWrittenHeaders=!1,null!==this.headers&&(this.fieldFormatter.headers=this.headers),g.transform&&(this.rowTransform=g.transform)}static isRowHashArray(g){return!!Array.isArray(g)&&Array.isArray(g[0])&&2===g[0].length}static isRowArray(g){return Array.isArray(g)&&!this.isRowHashArray(g)}static gatherHeaders(g){return s.isRowHashArray(g)?g.map((g=>g[0])):Array.isArray(g)?g:Object.keys(g)}static createTransform(g){return l.isSyncTransform(g)?(I,C)=>{let A=null;try{A=g(I)}catch(i){return C(i)}return C(null,A)}:(I,C)=>{g(I,C)}}set rowTransform(g){if(!i.default(g))throw new TypeError("The transform should be a function");this._rowTransform=s.createTransform(g)}format(g,I){this.callTransformer(g,((C,A)=>{if(C)return I(C);if(!g)return I(null);const i=[];if(A){const{shouldFormatColumns:g,headers:I}=this.checkHeaders(A);if(this.shouldWriteHeaders&&I&&!this.hasWrittenHeaders&&(i.push(this.formatColumns(I,!0)),this.hasWrittenHeaders=!0),g){const g=this.gatherColumns(A);i.push(this.formatColumns(g,!1))}}return I(null,i)}))}finish(g){const I=[];if(this.formatterOptions.alwaysWriteHeaders&&0===this.rowCount){if(!this.headers)return g(new Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));I.push(this.formatColumns(this.headers,!0))}return this.formatterOptions.includeEndRowDelimiter&&I.push(this.formatterOptions.rowDelimiter),g(null,I)}checkHeaders(g){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};const I=s.gatherHeaders(g);return this.headers=I,this.fieldFormatter.headers=I,this.shouldWriteHeaders?{shouldFormatColumns:!e.default(I,g),headers:I}:{shouldFormatColumns:!0,headers:null}}gatherColumns(g){if(null===this.headers)throw new Error("Headers is currently null");return Array.isArray(g)?s.isRowHashArray(g)?this.headers.map(((I,C)=>{const A=g[C];return A?A[1]:""})):s.isRowArray(g)&&!this.shouldWriteHeaders?g:this.headers.map(((I,C)=>g[C])):this.headers.map((I=>g[I]))}callTransformer(g,I){return this._rowTransform?this._rowTransform(g,I):I(null,g)}formatColumns(g,I){const C=g.map(((g,C)=>this.fieldFormatter.format(g,C,I))).join(this.formatterOptions.delimiter),{rowCount:A}=this;return this.rowCount+=1,A?[this.formatterOptions.rowDelimiter,C].join(""):C}}C.RowFormatter=s},{"../types":152,"./FieldFormatter":148,"lodash.isequal":445,"lodash.isfunction":446}],150:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.FieldFormatter=C.RowFormatter=void 0;var A=g("./RowFormatter");Object.defineProperty(C,"RowFormatter",{enumerable:!0,get:function(){return A.RowFormatter}});var i=g("./FieldFormatter");Object.defineProperty(C,"FieldFormatter",{enumerable:!0,get:function(){return i.FieldFormatter}})},{"./FieldFormatter":148,"./RowFormatter":149}],151:[function(g,I,C){(function(I){(function(){var A=Object.create?function(g,I,C,A){void 0===A&&(A=C),Object.defineProperty(g,A,{enumerable:!0,get:function(){return I[C]}})}:function(g,I,C,A){void 0===A&&(A=C),g[A]=I[C]},i=Object.create?function(g,I){Object.defineProperty(g,"default",{enumerable:!0,value:I})}:function(g,I){g.default=I},e=function(g){if(g&&g.__esModule)return g;var I={};if(null!=g)for(var C in g)"default"!==C&&Object.prototype.hasOwnProperty.call(g,C)&&A(I,g,C);return i(I,g),I},t=function(g,I){for(var C in g)"default"===C||Object.prototype.hasOwnProperty.call(I,C)||A(I,g,C)};Object.defineProperty(C,"__esModule",{value:!0}),C.writeToPath=C.writeToString=C.writeToBuffer=C.writeToStream=C.write=C.format=C.FormatterOptions=C.CsvFormatterStream=void 0;const l=g("util"),s=g("stream"),o=e(g("fs")),c=g("./FormatterOptions"),d=g("./CsvFormatterStream");t(g("./types"),C);var a=g("./CsvFormatterStream");Object.defineProperty(C,"CsvFormatterStream",{enumerable:!0,get:function(){return a.CsvFormatterStream}});var n=g("./FormatterOptions");Object.defineProperty(C,"FormatterOptions",{enumerable:!0,get:function(){return n.FormatterOptions}}),C.format=g=>new d.CsvFormatterStream(new c.FormatterOptions(g)),C.write=(g,I)=>{const A=C.format(I),i=l.promisify(((g,I)=>{A.write(g,void 0,I)}));return g.reduce(((g,I)=>g.then((()=>i(I)))),Promise.resolve()).then((()=>A.end())).catch((g=>{A.emit("error",g)})),A},C.writeToStream=(g,I,A)=>C.write(I,A).pipe(g),C.writeToBuffer=function(g){let A=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],e=new s.Writable({write(g,I,C){i.push(g),C()}});return new Promise(((t,l)=>{e.on("error",l).on("finish",(()=>t(I.concat(i)))),C.write(g,A).pipe(e)}))},C.writeToString=(g,I)=>C.writeToBuffer(g,I).then((g=>g.toString())),C.writeToPath=(g,I,A)=>{const i=o.createWriteStream(g,{encoding:"utf8"});return C.write(I,A).pipe(i)}}).call(this)}).call(this,g("buffer").Buffer)},{"./CsvFormatterStream":146,"./FormatterOptions":147,"./types":152,buffer:220,fs:216,stream:505,util:527}],152:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.isSyncTransform=void 0,C.isSyncTransform=g=>1===g.length},{}],153:[function(g,I,C){(function(I){(function(){Object.defineProperty(C,"__esModule",{value:!0}),C.CsvParserStream=void 0;const A=g("string_decoder"),i=g("stream"),e=g("./transforms"),t=g("./parser");class l extends i.Transform{constructor(g){super({objectMode:g.objectMode}),this.lines="",this.rowCount=0,this.parsedRowCount=0,this.parsedLineCount=0,this.endEmitted=!1,this.headersEmitted=!1,this.parserOptions=g,this.parser=new t.Parser(g),this.headerTransformer=new e.HeaderTransformer(g),this.decoder=new A.StringDecoder(g.encoding),this.rowTransformerValidator=new e.RowTransformerValidator}get hasHitRowLimit(){return this.parserOptions.limitRows&&this.rowCount>=this.parserOptions.maxRows}get shouldEmitRows(){return this.parsedRowCount>this.parserOptions.skipRows}get shouldSkipLine(){return this.parsedLineCount<=this.parserOptions.skipLines}transform(g){return this.rowTransformerValidator.rowTransform=g,this}validate(g){return this.rowTransformerValidator.rowValidator=g,this}emit(g){if("end"===g)return this.endEmitted||(this.endEmitted=!0,super.emit("end",this.rowCount)),!1;for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A{const t=g=>g?C(g):e%100!=0?i(e+1):void I((()=>i(e+1)));if(this.checkAndEmitHeaders(),e>=A||this.hasHitRowLimit)return C();if(this.parsedLineCount+=1,this.shouldSkipLine)return t();const l=g[e];this.rowCount+=1,this.parsedRowCount+=1;const s=this.rowCount;return this.transformRow(l,((g,I)=>{if(g)return this.rowCount-=1,t(g);if(!I)return t(new Error("expected transform result"));if(I.isValid){if(I.row)return this.pushRow(I.row,t)}else this.emit("data-invalid",I.row,s,I.reason);return t()}))};i(0)}transformRow(g,I){try{this.headerTransformer.transform(g,((C,A)=>C?I(C):A?A.isValid?A.row?this.shouldEmitRows?this.rowTransformerValidator.transformAndValidate(A.row,I):this.skipRow(I):(this.rowCount-=1,this.parsedRowCount-=1,I(null,{row:null,isValid:!0})):this.shouldEmitRows?I(null,{isValid:!1,row:g}):this.skipRow(I):I(new Error("Expected result from header transform"))))}catch(C){I(C)}}checkAndEmitHeaders(){!this.headersEmitted&&this.headerTransformer.headers&&(this.headersEmitted=!0,this.emit("headers",this.headerTransformer.headers))}skipRow(g){return this.rowCount-=1,g(null,{row:null,isValid:!0})}pushRow(g,I){try{this.parserOptions.objectMode?this.push(g):this.push(JSON.stringify(g)),I()}catch(C){I(C)}}static wrapDoneCallback(g){let I=!1;return function(C){if(C){if(I)throw C;return I=!0,void g(C)}for(var A=arguments.length,i=new Array(A>1?A-1:0),e=1;e1)throw new Error("delimiter option must be one character long");this.escapedDelimiter=i.default(this.delimiter),this.escapeChar=null!==(I=this.escape)&&void 0!==I?I:this.quote,this.supportsComments=!e.default(this.comment),this.NEXT_TOKEN_REGEXP=new RegExp(`([^\\s]|\\r\\n|\\n|\\r|${this.escapedDelimiter})`),this.maxRows>0&&(this.limitRows=!0)}}C.ParserOptions=t},{"lodash.escaperegexp":442,"lodash.isnil":447}],155:[function(g,I,C){var A=Object.create?function(g,I,C,A){void 0===A&&(A=C),Object.defineProperty(g,A,{enumerable:!0,get:function(){return I[C]}})}:function(g,I,C,A){void 0===A&&(A=C),g[A]=I[C]},i=Object.create?function(g,I){Object.defineProperty(g,"default",{enumerable:!0,value:I})}:function(g,I){g.default=I},e=function(g){if(g&&g.__esModule)return g;var I={};if(null!=g)for(var C in g)"default"!==C&&Object.prototype.hasOwnProperty.call(g,C)&&A(I,g,C);return i(I,g),I},t=function(g,I){for(var C in g)"default"===C||Object.prototype.hasOwnProperty.call(I,C)||A(I,g,C)};Object.defineProperty(C,"__esModule",{value:!0}),C.parseString=C.parseFile=C.parseStream=C.parse=C.ParserOptions=C.CsvParserStream=void 0;const l=e(g("fs")),s=g("stream"),o=g("./ParserOptions"),c=g("./CsvParserStream");t(g("./types"),C);var d=g("./CsvParserStream");Object.defineProperty(C,"CsvParserStream",{enumerable:!0,get:function(){return d.CsvParserStream}});var a=g("./ParserOptions");Object.defineProperty(C,"ParserOptions",{enumerable:!0,get:function(){return a.ParserOptions}}),C.parse=g=>new c.CsvParserStream(new o.ParserOptions(g)),C.parseStream=(g,I)=>g.pipe(new c.CsvParserStream(new o.ParserOptions(I))),C.parseFile=function(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l.createReadStream(g).pipe(new c.CsvParserStream(new o.ParserOptions(I)))},C.parseString=(g,I)=>{const C=new s.Readable;return C.push(g),C.push(null),C.pipe(new c.CsvParserStream(new o.ParserOptions(I)))}},{"./CsvParserStream":153,"./ParserOptions":154,"./types":169,fs:216,stream:505}],156:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.Parser=void 0;const A=g("./Scanner"),i=g("./RowParser"),e=g("./Token");class t{constructor(g){this.parserOptions=g,this.rowParser=new i.RowParser(this.parserOptions)}static removeBOM(g){return g&&65279===g.charCodeAt(0)?g.slice(1):g}parse(g,I){const C=new A.Scanner({line:t.removeBOM(g),parserOptions:this.parserOptions,hasMoreData:I});return this.parserOptions.supportsComments?this.parseWithComments(C):this.parseWithoutComments(C)}parseWithoutComments(g){const I=[];let C=!0;for(;C;)C=this.parseRow(g,I);return{line:g.line,rows:I}}parseWithComments(g){const{parserOptions:I}=this,C=[];for(let A=g.nextCharacterToken;null!==A;A=g.nextCharacterToken)if(e.Token.isTokenComment(A,I)){if(null===g.advancePastLine())return{line:g.lineFromCursor,rows:C};if(!g.hasMoreCharacters)return{line:g.lineFromCursor,rows:C};g.truncateToCursor()}else if(!this.parseRow(g,C))break;return{line:g.line,rows:C}}parseRow(g,I){if(!g.nextNonSpaceToken)return!1;const C=this.rowParser.parse(g);return null!==C&&(this.parserOptions.ignoreEmpty&&i.RowParser.isEmptyRow(C)||I.push(C),!0)}}C.Parser=t},{"./RowParser":157,"./Scanner":158,"./Token":159}],157:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.RowParser=void 0;const A=g("./column"),i=g("./Token"),e="";class t{constructor(g){this.parserOptions=g,this.columnParser=new A.ColumnParser(g)}static isEmptyRow(g){return g.join(e).replace(/\s+/g,e)===e}parse(g){const{parserOptions:I}=this,{hasMoreData:C}=g,A=g,e=[];let t=this.getStartToken(A,e);for(;t;){if(i.Token.isTokenRowDelimiter(t))return A.advancePastToken(t),!A.hasMoreCharacters&&i.Token.isTokenCarriageReturn(t,I)&&C?null:(A.truncateToCursor(),e);if(!this.shouldSkipColumnParse(A,t,e)){const g=this.columnParser.parse(A);if(null===g)return null;e.push(g)}t=A.nextNonSpaceToken}return C?null:(A.truncateToCursor(),e)}getStartToken(g,I){const C=g.nextNonSpaceToken;return null!==C&&i.Token.isTokenDelimiter(C,this.parserOptions)?(I.push(""),g.nextNonSpaceToken):C}shouldSkipColumnParse(g,I,C){const{parserOptions:A}=this;if(i.Token.isTokenDelimiter(I,A)){g.advancePastToken(I);const e=g.nextCharacterToken;if(!g.hasMoreCharacters||null!==e&&i.Token.isTokenRowDelimiter(e))return C.push(""),!0;if(null!==e&&i.Token.isTokenDelimiter(e,A))return C.push(""),!0}return!1}}C.RowParser=t},{"./Token":159,"./column":164}],158:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.Scanner=void 0;const A=g("./Token"),i=/((?:\r\n)|\n|\r)/;class e{constructor(g){this.cursor=0,this.line=g.line,this.lineLength=this.line.length,this.parserOptions=g.parserOptions,this.hasMoreData=g.hasMoreData,this.cursor=g.cursor||0}get hasMoreCharacters(){return this.lineLength>this.cursor}get nextNonSpaceToken(){const{lineFromCursor:g}=this,I=this.parserOptions.NEXT_TOKEN_REGEXP;if(-1===g.search(I))return null;const C=I.exec(g);if(null==C)return null;const i=C[1],e=this.cursor+(C.index||0);return new A.Token({token:i,startCursor:e,endCursor:e+i.length-1})}get nextCharacterToken(){const{cursor:g,lineLength:I}=this;return I<=g?null:new A.Token({token:this.line[g],startCursor:g,endCursor:g})}get lineFromCursor(){return this.line.substr(this.cursor)}advancePastLine(){const g=i.exec(this.lineFromCursor);return g?(this.cursor+=(g.index||0)+g[0].length,this):this.hasMoreData?null:(this.cursor=this.lineLength,this)}advanceTo(g){return this.cursor=g,this}advanceToToken(g){return this.cursor=g.startCursor,this}advancePastToken(g){return this.cursor=g.endCursor+1,this}truncateToCursor(){return this.line=this.lineFromCursor,this.lineLength=this.line.length,this.cursor=0,this}}C.Scanner=e},{"./Token":159}],159:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.Token=void 0;class A{constructor(g){this.token=g.token,this.startCursor=g.startCursor,this.endCursor=g.endCursor}static isTokenRowDelimiter(g){const I=g.token;return"\r"===I||"\n"===I||"\r\n"===I}static isTokenCarriageReturn(g,I){return g.token===I.carriageReturn}static isTokenComment(g,I){return I.supportsComments&&!!g&&g.token===I.comment}static isTokenEscapeCharacter(g,I){return g.token===I.escapeChar}static isTokenQuote(g,I){return g.token===I.quote}static isTokenDelimiter(g,I){return g.token===I.delimiter}}C.Token=A},{}],160:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.ColumnFormatter=void 0;class A{constructor(g){g.trim?this.format=g=>g.trim():g.ltrim?this.format=g=>g.trimLeft():g.rtrim?this.format=g=>g.trimRight():this.format=g=>g}}C.ColumnFormatter=A},{}],161:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.ColumnParser=void 0;const A=g("./NonQuotedColumnParser"),i=g("./QuotedColumnParser"),e=g("../Token");class t{constructor(g){this.parserOptions=g,this.quotedColumnParser=new i.QuotedColumnParser(g),this.nonQuotedColumnParser=new A.NonQuotedColumnParser(g)}parse(g){const{nextNonSpaceToken:I}=g;return null!==I&&e.Token.isTokenQuote(I,this.parserOptions)?(g.advanceToToken(I),this.quotedColumnParser.parse(g)):this.nonQuotedColumnParser.parse(g)}}C.ColumnParser=t},{"../Token":159,"./NonQuotedColumnParser":162,"./QuotedColumnParser":163}],162:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.NonQuotedColumnParser=void 0;const A=g("./ColumnFormatter"),i=g("../Token");class e{constructor(g){this.parserOptions=g,this.columnFormatter=new A.ColumnFormatter(g)}parse(g){if(!g.hasMoreCharacters)return null;const{parserOptions:I}=this,C=[];let A=g.nextCharacterToken;for(;A&&!i.Token.isTokenDelimiter(A,I)&&!i.Token.isTokenRowDelimiter(A);A=g.nextCharacterToken)C.push(A.token),g.advancePastToken(A);return this.columnFormatter.format(C.join(""))}}C.NonQuotedColumnParser=e},{"../Token":159,"./ColumnFormatter":160}],163:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.QuotedColumnParser=void 0;const A=g("./ColumnFormatter"),i=g("../Token");class e{constructor(g){this.parserOptions=g,this.columnFormatter=new A.ColumnFormatter(g)}parse(g){if(!g.hasMoreCharacters)return null;const I=g.cursor,{foundClosingQuote:C,col:A}=this.gatherDataBetweenQuotes(g);if(!C){if(g.advanceTo(I),!g.hasMoreData)throw new Error(`Parse Error: missing closing: '${this.parserOptions.quote||""}' in line: at '${g.lineFromCursor.replace(/[\r\n]/g,"\\n'")}'`);return null}return this.checkForMalformedColumn(g),A}gatherDataBetweenQuotes(g){const{parserOptions:I}=this;let C=!1,A=!1;const e=[];let t=g.nextCharacterToken;for(;!A&&null!==t;t=g.nextCharacterToken){const l=i.Token.isTokenQuote(t,I);if(!C&&l)C=!0;else if(C)if(i.Token.isTokenEscapeCharacter(t,I)){g.advancePastToken(t);const C=g.nextCharacterToken;null!==C&&(i.Token.isTokenQuote(C,I)||i.Token.isTokenEscapeCharacter(C,I))?(e.push(C.token),t=C):l?A=!0:e.push(t.token)}else l?A=!0:e.push(t.token);g.advancePastToken(t)}return{col:this.columnFormatter.format(e.join("")),foundClosingQuote:A}}checkForMalformedColumn(g){const{parserOptions:I}=this,{nextNonSpaceToken:C}=g;if(C){const A=i.Token.isTokenDelimiter(C,I),e=i.Token.isTokenRowDelimiter(C);if(!A&&!e){const A=g.lineFromCursor.substr(0,10).replace(/[\r\n]/g,"\\n'");throw new Error(`Parse Error: expected: '${I.escapedDelimiter}' OR new line got: '${C.token}'. at '${A}`)}g.advanceToToken(C)}else g.hasMoreData||g.advancePastLine()}}C.QuotedColumnParser=e},{"../Token":159,"./ColumnFormatter":160}],164:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.ColumnFormatter=C.QuotedColumnParser=C.NonQuotedColumnParser=C.ColumnParser=void 0;var A=g("./ColumnParser");Object.defineProperty(C,"ColumnParser",{enumerable:!0,get:function(){return A.ColumnParser}});var i=g("./NonQuotedColumnParser");Object.defineProperty(C,"NonQuotedColumnParser",{enumerable:!0,get:function(){return i.NonQuotedColumnParser}});var e=g("./QuotedColumnParser");Object.defineProperty(C,"QuotedColumnParser",{enumerable:!0,get:function(){return e.QuotedColumnParser}});var t=g("./ColumnFormatter");Object.defineProperty(C,"ColumnFormatter",{enumerable:!0,get:function(){return t.ColumnFormatter}})},{"./ColumnFormatter":160,"./ColumnParser":161,"./NonQuotedColumnParser":162,"./QuotedColumnParser":163}],165:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.QuotedColumnParser=C.NonQuotedColumnParser=C.ColumnParser=C.Token=C.Scanner=C.RowParser=C.Parser=void 0;var A=g("./Parser");Object.defineProperty(C,"Parser",{enumerable:!0,get:function(){return A.Parser}});var i=g("./RowParser");Object.defineProperty(C,"RowParser",{enumerable:!0,get:function(){return i.RowParser}});var e=g("./Scanner");Object.defineProperty(C,"Scanner",{enumerable:!0,get:function(){return e.Scanner}});var t=g("./Token");Object.defineProperty(C,"Token",{enumerable:!0,get:function(){return t.Token}});var l=g("./column");Object.defineProperty(C,"ColumnParser",{enumerable:!0,get:function(){return l.ColumnParser}}),Object.defineProperty(C,"NonQuotedColumnParser",{enumerable:!0,get:function(){return l.NonQuotedColumnParser}}),Object.defineProperty(C,"QuotedColumnParser",{enumerable:!0,get:function(){return l.QuotedColumnParser}})},{"./Parser":156,"./RowParser":157,"./Scanner":158,"./Token":159,"./column":164}],166:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.HeaderTransformer=void 0;const i=A(g("lodash.isundefined")),e=A(g("lodash.isfunction")),t=A(g("lodash.uniq")),l=A(g("lodash.groupby"));class s{constructor(g){this.headers=null,this.receivedHeaders=!1,this.shouldUseFirstRow=!1,this.processedFirstRow=!1,this.headersLength=0,this.parserOptions=g,!0===g.headers?this.shouldUseFirstRow=!0:Array.isArray(g.headers)?this.setHeaders(g.headers):e.default(g.headers)&&(this.headersTransform=g.headers)}transform(g,I){return this.shouldMapRow(g)?I(null,this.processRow(g)):I(null,{row:null,isValid:!0})}shouldMapRow(g){const{parserOptions:I}=this;if(!this.headersTransform&&I.renameHeaders&&!this.processedFirstRow){if(!this.receivedHeaders)throw new Error("Error renaming headers: new headers must be provided in an array");return this.processedFirstRow=!0,!1}if(!this.receivedHeaders&&Array.isArray(g)){if(this.headersTransform)this.setHeaders(this.headersTransform(g));else{if(!this.shouldUseFirstRow)return!0;this.setHeaders(g)}return!1}return!0}processRow(g){if(!this.headers)return{row:g,isValid:!0};const{parserOptions:I}=this;if(!I.discardUnmappedColumns&&g.length>this.headersLength){if(!I.strictColumnHandling)throw new Error(`Unexpected Error: column header mismatch expected: ${this.headersLength} columns got: ${g.length}`);return{row:g,isValid:!1,reason:`Column header mismatch expected: ${this.headersLength} columns got: ${g.length}`}}return I.strictColumnHandling&&g.length!!g));if(t.default(C).length!==C.length){const g=l.default(C),I=Object.keys(g).filter((I=>g[I].length>1));throw new Error(`Duplicate headers found ${JSON.stringify(I)}`)}this.headers=g,this.receivedHeaders=!0,this.headersLength=(null===(I=this.headers)||void 0===I?void 0:I.length)||0}}C.HeaderTransformer=s},{"lodash.groupby":443,"lodash.isfunction":446,"lodash.isundefined":448,"lodash.uniq":449}],167:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.RowTransformerValidator=void 0;const i=A(g("lodash.isfunction")),e=g("../types");class t{constructor(){this._rowTransform=null,this._rowValidator=null}static createTransform(g){return e.isSyncTransform(g)?(I,C)=>{let A=null;try{A=g(I)}catch(i){return C(i)}return C(null,A)}:g}static createValidator(g){return e.isSyncValidate(g)?(I,C)=>{C(null,{row:I,isValid:g(I)})}:(I,C)=>{g(I,((g,A,i)=>g?C(g):C(null,A?{row:I,isValid:A,reason:i}:{row:I,isValid:!1,reason:i})))}}set rowTransform(g){if(!i.default(g))throw new TypeError("The transform should be a function");this._rowTransform=t.createTransform(g)}set rowValidator(g){if(!i.default(g))throw new TypeError("The validate should be a function");this._rowValidator=t.createValidator(g)}transformAndValidate(g,I){return this.callTransformer(g,((g,C)=>g?I(g):C?this.callValidator(C,((g,A)=>g?I(g):A&&!A.isValid?I(null,{row:C,isValid:!1,reason:A.reason}):I(null,{row:C,isValid:!0}))):I(null,{row:null,isValid:!0})))}callTransformer(g,I){return this._rowTransform?this._rowTransform(g,I):I(null,g)}callValidator(g,I){return this._rowValidator?this._rowValidator(g,I):I(null,{row:g,isValid:!0})}}C.RowTransformerValidator=t},{"../types":169,"lodash.isfunction":446}],168:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.HeaderTransformer=C.RowTransformerValidator=void 0;var A=g("./RowTransformerValidator");Object.defineProperty(C,"RowTransformerValidator",{enumerable:!0,get:function(){return A.RowTransformerValidator}});var i=g("./HeaderTransformer");Object.defineProperty(C,"HeaderTransformer",{enumerable:!0,get:function(){return i.HeaderTransformer}})},{"./HeaderTransformer":166,"./RowTransformerValidator":167}],169:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.isSyncValidate=C.isSyncTransform=void 0,C.isSyncTransform=g=>1===g.length,C.isSyncValidate=g=>1===g.length},{}],170:[function(g,I,C){const A=C;A.bignum=g("bn.js"),A.define=g("./asn1/api").define,A.base=g("./asn1/base"),A.constants=g("./asn1/constants"),A.decoders=g("./asn1/decoders"),A.encoders=g("./asn1/encoders")},{"./asn1/api":171,"./asn1/base":173,"./asn1/constants":177,"./asn1/decoders":179,"./asn1/encoders":182,"bn.js":184}],171:[function(g,I,C){const A=g("./encoders"),i=g("./decoders"),e=g("inherits");function t(g,I){this.name=g,this.body=I,this.decoders={},this.encoders={}}C.define=function(g,I){return new t(g,I)},t.prototype._createNamed=function(g){const I=this.name;function C(g){this._initNamed(g,I)}return e(C,g),C.prototype._initNamed=function(I,C){g.call(this,I,C)},new C(this)},t.prototype._getDecoder=function(g){return g=g||"der",this.decoders.hasOwnProperty(g)||(this.decoders[g]=this._createNamed(i[g])),this.decoders[g]},t.prototype.decode=function(g,I,C){return this._getDecoder(I).decode(g,C)},t.prototype._getEncoder=function(g){return g=g||"der",this.encoders.hasOwnProperty(g)||(this.encoders[g]=this._createNamed(A[g])),this.encoders[g]},t.prototype.encode=function(g,I,C){return this._getEncoder(I).encode(g,C)}},{"./decoders":179,"./encoders":182,inherits:440}],172:[function(g,I,C){const A=g("inherits"),i=g("../base/reporter").Reporter,e=g("safer-buffer").Buffer;function t(g,I){i.call(this,I),e.isBuffer(g)?(this.base=g,this.offset=0,this.length=g.length):this.error("Input not Buffer")}function l(g,I){if(Array.isArray(g))this.length=0,this.value=g.map((function(g){return l.isEncoderBuffer(g)||(g=new l(g,I)),this.length+=g.length,g}),this);else if("number"==typeof g){if(!(0<=g&&g<=255))return I.error("non-byte EncoderBuffer value");this.value=g,this.length=1}else if("string"==typeof g)this.value=g,this.length=e.byteLength(g);else{if(!e.isBuffer(g))return I.error("Unsupported type: "+typeof g);this.value=g,this.length=g.length}}A(t,i),C.DecoderBuffer=t,t.isDecoderBuffer=function(g){return g instanceof t||"object"==typeof g&&e.isBuffer(g.base)&&"DecoderBuffer"===g.constructor.name&&"number"==typeof g.offset&&"number"==typeof g.length&&"function"==typeof g.save&&"function"==typeof g.restore&&"function"==typeof g.isEmpty&&"function"==typeof g.readUInt8&&"function"==typeof g.skip&&"function"==typeof g.raw},t.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},t.prototype.restore=function(g){const I=new t(this.base);return I.offset=g.offset,I.length=this.offset,this.offset=g.offset,i.prototype.restore.call(this,g.reporter),I},t.prototype.isEmpty=function(){return this.offset===this.length},t.prototype.readUInt8=function(g){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(g||"DecoderBuffer overrun")},t.prototype.skip=function(g,I){if(!(this.offset+g<=this.length))return this.error(I||"DecoderBuffer overrun");const C=new t(this.base);return C._reporterState=this._reporterState,C.offset=this.offset,C.length=this.offset+g,this.offset+=g,C},t.prototype.raw=function(g){return this.base.slice(g?g.offset:this.offset,this.length)},C.EncoderBuffer=l,l.isEncoderBuffer=function(g){return g instanceof l||"object"==typeof g&&"EncoderBuffer"===g.constructor.name&&"number"==typeof g.length&&"function"==typeof g.join},l.prototype.join=function(g,I){return g||(g=e.alloc(this.length)),I||(I=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(C){C.join(g,I),I+=C.length})):("number"==typeof this.value?g[I]=this.value:"string"==typeof this.value?g.write(this.value,I):e.isBuffer(this.value)&&this.value.copy(g,I),I+=this.length)),g}},{"../base/reporter":175,inherits:440,"safer-buffer":495}],173:[function(g,I,C){const A=C;A.Reporter=g("./reporter").Reporter,A.DecoderBuffer=g("./buffer").DecoderBuffer,A.EncoderBuffer=g("./buffer").EncoderBuffer,A.Node=g("./node")},{"./buffer":172,"./node":174,"./reporter":175}],174:[function(g,I,C){const A=g("../base/reporter").Reporter,i=g("../base/buffer").EncoderBuffer,e=g("../base/buffer").DecoderBuffer,t=g("minimalistic-assert"),l=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],s=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(l),o=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function c(g,I,C){const A={};this._baseState=A,A.name=C,A.enc=g,A.parent=I||null,A.children=null,A.tag=null,A.args=null,A.reverseArgs=null,A.choice=null,A.optional=!1,A.any=!1,A.obj=!1,A.use=null,A.useDecoder=null,A.key=null,A.default=null,A.explicit=null,A.implicit=null,A.contains=null,A.parent||(A.children=[],this._wrap())}I.exports=c;const d=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){const g=this._baseState,I={};d.forEach((function(C){I[C]=g[C]}));const C=new this.constructor(I.parent);return C._baseState=I,C},c.prototype._wrap=function(){const g=this._baseState;s.forEach((function(I){this[I]=function(){const C=new this.constructor(this);return g.children.push(C),C[I].apply(C,arguments)}}),this)},c.prototype._init=function(g){const I=this._baseState;t(null===I.parent),g.call(this),I.children=I.children.filter((function(g){return g._baseState.parent===this}),this),t.equal(I.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(g){const I=this._baseState,C=g.filter((function(g){return g instanceof this.constructor}),this);g=g.filter((function(g){return!(g instanceof this.constructor)}),this),0!==C.length&&(t(null===I.children),I.children=C,C.forEach((function(g){g._baseState.parent=this}),this)),0!==g.length&&(t(null===I.args),I.args=g,I.reverseArgs=g.map((function(g){if("object"!=typeof g||g.constructor!==Object)return g;const I={};return Object.keys(g).forEach((function(C){C==(0|C)&&(C|=0);const A=g[C];I[A]=C})),I})))},o.forEach((function(g){c.prototype[g]=function(){const I=this._baseState;throw new Error(g+" not implemented for encoding: "+I.enc)}})),l.forEach((function(g){c.prototype[g]=function(){const I=this._baseState,C=Array.prototype.slice.call(arguments);return t(null===I.tag),I.tag=g,this._useArgs(C),this}})),c.prototype.use=function(g){t(g);const I=this._baseState;return t(null===I.use),I.use=g,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(g){const I=this._baseState;return t(null===I.default),I.default=g,I.optional=!0,this},c.prototype.explicit=function(g){const I=this._baseState;return t(null===I.explicit&&null===I.implicit),I.explicit=g,this},c.prototype.implicit=function(g){const I=this._baseState;return t(null===I.explicit&&null===I.implicit),I.implicit=g,this},c.prototype.obj=function(){const g=this._baseState,I=Array.prototype.slice.call(arguments);return g.obj=!0,0!==I.length&&this._useArgs(I),this},c.prototype.key=function(g){const I=this._baseState;return t(null===I.key),I.key=g,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(g){const I=this._baseState;return t(null===I.choice),I.choice=g,this._useArgs(Object.keys(g).map((function(I){return g[I]}))),this},c.prototype.contains=function(g){const I=this._baseState;return t(null===I.use),I.contains=g,this},c.prototype._decode=function(g,I){const C=this._baseState;if(null===C.parent)return g.wrapResult(C.children[0]._decode(g,I));let A,i=C.default,t=!0,l=null;if(null!==C.key&&(l=g.enterKey(C.key)),C.optional){let A=null;if(null!==C.explicit?A=C.explicit:null!==C.implicit?A=C.implicit:null!==C.tag&&(A=C.tag),null!==A||C.any){if(t=this._peekTag(g,A,C.any),g.isError(t))return t}else{const A=g.save();try{null===C.choice?this._decodeGeneric(C.tag,g,I):this._decodeChoice(g,I),t=!0}catch(s){t=!1}g.restore(A)}}if(C.obj&&t&&(A=g.enterObject()),t){if(null!==C.explicit){const I=this._decodeTag(g,C.explicit);if(g.isError(I))return I;g=I}const A=g.offset;if(null===C.use&&null===C.choice){let I;C.any&&(I=g.save());const A=this._decodeTag(g,null!==C.implicit?C.implicit:C.tag,C.any);if(g.isError(A))return A;C.any?i=g.raw(I):g=A}if(I&&I.track&&null!==C.tag&&I.track(g.path(),A,g.length,"tagged"),I&&I.track&&null!==C.tag&&I.track(g.path(),g.offset,g.length,"content"),C.any||(i=null===C.choice?this._decodeGeneric(C.tag,g,I):this._decodeChoice(g,I)),g.isError(i))return i;if(C.any||null!==C.choice||null===C.children||C.children.forEach((function(C){C._decode(g,I)})),C.contains&&("octstr"===C.tag||"bitstr"===C.tag)){const A=new e(i);i=this._getUse(C.contains,g._reporterState.obj)._decode(A,I)}}return C.obj&&t&&(i=g.leaveObject(A)),null===C.key||null===i&&!0!==t?null!==l&&g.exitKey(l):g.leaveKey(l,C.key,i),i},c.prototype._decodeGeneric=function(g,I,C){const A=this._baseState;return"seq"===g||"set"===g?null:"seqof"===g||"setof"===g?this._decodeList(I,g,A.args[0],C):/str$/.test(g)?this._decodeStr(I,g,C):"objid"===g&&A.args?this._decodeObjid(I,A.args[0],A.args[1],C):"objid"===g?this._decodeObjid(I,null,null,C):"gentime"===g||"utctime"===g?this._decodeTime(I,g,C):"null_"===g?this._decodeNull(I,C):"bool"===g?this._decodeBool(I,C):"objDesc"===g?this._decodeStr(I,g,C):"int"===g||"enum"===g?this._decodeInt(I,A.args&&A.args[0],C):null!==A.use?this._getUse(A.use,I._reporterState.obj)._decode(I,C):I.error("unknown tag: "+g)},c.prototype._getUse=function(g,I){const C=this._baseState;return C.useDecoder=this._use(g,I),t(null===C.useDecoder._baseState.parent),C.useDecoder=C.useDecoder._baseState.children[0],C.implicit!==C.useDecoder._baseState.implicit&&(C.useDecoder=C.useDecoder.clone(),C.useDecoder._baseState.implicit=C.implicit),C.useDecoder},c.prototype._decodeChoice=function(g,I){const C=this._baseState;let A=null,i=!1;return Object.keys(C.choice).some((function(e){const t=g.save(),l=C.choice[e];try{const C=l._decode(g,I);if(g.isError(C))return!1;A={type:e,value:C},i=!0}catch(s){return g.restore(t),!1}return!0}),this),i?A:g.error("Choice not matched")},c.prototype._createEncoderBuffer=function(g){return new i(g,this.reporter)},c.prototype._encode=function(g,I,C){const A=this._baseState;if(null!==A.default&&A.default===g)return;const i=this._encodeValue(g,I,C);return void 0===i||this._skipDefault(i,I,C)?void 0:i},c.prototype._encodeValue=function(g,I,C){const i=this._baseState;if(null===i.parent)return i.children[0]._encode(g,I||new A);let e=null;if(this.reporter=I,i.optional&&void 0===g){if(null===i.default)return;g=i.default}let t=null,l=!1;if(i.any)e=this._createEncoderBuffer(g);else if(i.choice)e=this._encodeChoice(g,I);else if(i.contains)t=this._getUse(i.contains,C)._encode(g,I),l=!0;else if(i.children)t=i.children.map((function(C){if("null_"===C._baseState.tag)return C._encode(null,I,g);if(null===C._baseState.key)return I.error("Child should have a key");const A=I.enterKey(C._baseState.key);if("object"!=typeof g)return I.error("Child expected, but input is not object");const i=C._encode(g[C._baseState.key],I,g);return I.leaveKey(A),i}),this).filter((function(g){return g})),t=this._createEncoderBuffer(t);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return I.error("Too many args for : "+i.tag);if(!Array.isArray(g))return I.error("seqof/setof, but data is not Array");const C=this.clone();C._baseState.implicit=null,t=this._createEncoderBuffer(g.map((function(C){const A=this._baseState;return this._getUse(A.args[0],g)._encode(C,I)}),C))}else null!==i.use?e=this._getUse(i.use,C)._encode(g,I):(t=this._encodePrimitive(i.tag,g),l=!0);if(!i.any&&null===i.choice){const g=null!==i.implicit?i.implicit:i.tag,C=null===i.implicit?"universal":"context";null===g?null===i.use&&I.error("Tag could be omitted only for .use()"):null===i.use&&(e=this._encodeComposite(g,l,C,t))}return null!==i.explicit&&(e=this._encodeComposite(i.explicit,!1,"context",e)),e},c.prototype._encodeChoice=function(g,I){const C=this._baseState,A=C.choice[g.type];return A||t(!1,g.type+" not found in "+JSON.stringify(Object.keys(C.choice))),A._encode(g.value,I)},c.prototype._encodePrimitive=function(g,I){const C=this._baseState;if(/str$/.test(g))return this._encodeStr(I,g);if("objid"===g&&C.args)return this._encodeObjid(I,C.reverseArgs[0],C.args[1]);if("objid"===g)return this._encodeObjid(I,null,null);if("gentime"===g||"utctime"===g)return this._encodeTime(I,g);if("null_"===g)return this._encodeNull();if("int"===g||"enum"===g)return this._encodeInt(I,C.args&&C.reverseArgs[0]);if("bool"===g)return this._encodeBool(I);if("objDesc"===g)return this._encodeStr(I,g);throw new Error("Unsupported tag: "+g)},c.prototype._isNumstr=function(g){return/^[0-9 ]*$/.test(g)},c.prototype._isPrintstr=function(g){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(g)}},{"../base/buffer":172,"../base/reporter":175,"minimalistic-assert":453}],175:[function(g,I,C){const A=g("inherits");function i(g){this._reporterState={obj:null,path:[],options:g||{},errors:[]}}function e(g,I){this.path=g,this.rethrow(I)}C.Reporter=i,i.prototype.isError=function(g){return g instanceof e},i.prototype.save=function(){const g=this._reporterState;return{obj:g.obj,pathLen:g.path.length}},i.prototype.restore=function(g){const I=this._reporterState;I.obj=g.obj,I.path=I.path.slice(0,g.pathLen)},i.prototype.enterKey=function(g){return this._reporterState.path.push(g)},i.prototype.exitKey=function(g){const I=this._reporterState;I.path=I.path.slice(0,g-1)},i.prototype.leaveKey=function(g,I,C){const A=this._reporterState;this.exitKey(g),null!==A.obj&&(A.obj[I]=C)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const g=this._reporterState,I=g.obj;return g.obj={},I},i.prototype.leaveObject=function(g){const I=this._reporterState,C=I.obj;return I.obj=g,C},i.prototype.error=function(g){let I;const C=this._reporterState,A=g instanceof e;if(I=A?g:new e(C.path.map((function(g){return"["+JSON.stringify(g)+"]"})).join(""),g.message||g,g.stack),!C.options.partial)throw I;return A||C.errors.push(I),I},i.prototype.wrapResult=function(g){const I=this._reporterState;return I.options.partial?{result:this.isError(g)?null:g,errors:I.errors}:g},A(e,Error),e.prototype.rethrow=function(g){if(this.message=g+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,e),!this.stack)try{throw new Error(this.message)}catch(I){this.stack=I.stack}return this}},{inherits:440}],176:[function(g,I,C){function A(g){const I={};return Object.keys(g).forEach((function(C){(0|C)==C&&(C|=0);const A=g[C];I[A]=C})),I}C.tagClass={0:"universal",1:"application",2:"context",3:"private"},C.tagClassByName=A(C.tagClass),C.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},C.tagByName=A(C.tag)},{}],177:[function(g,I,C){const A=C;A._reverse=function(g){const I={};return Object.keys(g).forEach((function(C){(0|C)==C&&(C|=0);const A=g[C];I[A]=C})),I},A.der=g("./der")},{"./der":176}],178:[function(g,I,C){const A=g("inherits"),i=g("bn.js"),e=g("../base/buffer").DecoderBuffer,t=g("../base/node"),l=g("../constants/der");function s(g){this.enc="der",this.name=g.name,this.entity=g,this.tree=new o,this.tree._init(g.body)}function o(g){t.call(this,"der",g)}function c(g,I){let C=g.readUInt8(I);if(g.isError(C))return C;const A=l.tagClass[C>>6],i=!(32&C);if(31&~C)C&=31;else{let A=C;for(C=0;!(128&~A);){if(A=g.readUInt8(I),g.isError(A))return A;C<<=7,C|=127&A}}return{cls:A,primitive:i,tag:C,tagStr:l.tag[C]}}function d(g,I,C){let A=g.readUInt8(C);if(g.isError(A))return A;if(!I&&128===A)return null;if(!(128&A))return A;const i=127&A;if(i>4)return g.error("length octect is too long");A=0;for(let e=0;e=31?A.error("Multi-octet tag encoding unsupported"):(I||(i|=32),i|=t.tagClassByName[C||"universal"]<<6,i)}I.exports=l,l.prototype.encode=function(g,I){return this.tree._encode(g,I).join()},A(s,e),s.prototype._encodeComposite=function(g,I,C,A){const e=c(g,I,C,this.reporter);if(A.length<128){const g=i.alloc(2);return g[0]=e,g[1]=A.length,this._createEncoderBuffer([g,A])}let t=1;for(let i=A.length;i>=256;i>>=8)t++;const l=i.alloc(2+t);l[0]=e,l[1]=128|t;for(let i=1+t,s=A.length;s>0;i--,s>>=8)l[i]=255&s;return this._createEncoderBuffer([l,A])},s.prototype._encodeStr=function(g,I){if("bitstr"===I)return this._createEncoderBuffer([0|g.unused,g.data]);if("bmpstr"===I){const I=i.alloc(2*g.length);for(let C=0;C=40)return this.reporter.error("Second objid identifier OOB");g.splice(0,2,40*g[0]+g[1])}let A=0;for(let i=0;i=128;I>>=7)A++}const e=i.alloc(A);let t=e.length-1;for(let i=g.length-1;i>=0;i--){let I=g[i];for(e[t--]=127&I;(I>>=7)>0;)e[t--]=128|127&I}return this._createEncoderBuffer(e)},s.prototype._encodeTime=function(g,I){let C;const A=new Date(g);return"gentime"===I?C=[o(A.getUTCFullYear()),o(A.getUTCMonth()+1),o(A.getUTCDate()),o(A.getUTCHours()),o(A.getUTCMinutes()),o(A.getUTCSeconds()),"Z"].join(""):"utctime"===I?C=[o(A.getUTCFullYear()%100),o(A.getUTCMonth()+1),o(A.getUTCDate()),o(A.getUTCHours()),o(A.getUTCMinutes()),o(A.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+I+" time is not supported yet"),this._encodeStr(C,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(g,I){if("string"==typeof g){if(!I)return this.reporter.error("String int or enum given, but no values map");if(!I.hasOwnProperty(g))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(g));g=I[g]}if("number"!=typeof g&&!i.isBuffer(g)){const I=g.toArray();!g.sign&&128&I[0]&&I.unshift(0),g=i.from(I)}if(i.isBuffer(g)){let I=g.length;0===g.length&&I++;const C=i.alloc(I);return g.copy(C),0===g.length&&(C[0]=0),this._createEncoderBuffer(C)}if(g<128)return this._createEncoderBuffer(g);if(g<256)return this._createEncoderBuffer([0,g]);let C=1;for(let i=g;i>=256;i>>=8)C++;const A=new Array(C);for(let i=A.length-1;i>=0;i--)A[i]=255&g,g>>=8;return 128&A[0]&&A.unshift(0),this._createEncoderBuffer(i.from(A))},s.prototype._encodeBool=function(g){return this._createEncoderBuffer(g?255:0)},s.prototype._use=function(g,I){return"function"==typeof g&&(g=g(I)),g._getEncoder("der").tree},s.prototype._skipDefault=function(g,I,C){const A=this._baseState;let i;if(null===A.default)return!1;const e=g.join();if(void 0===A.defaultBuffer&&(A.defaultBuffer=this._encodeValue(A.default,I,C).join()),e.length!==A.defaultBuffer.length)return!1;for(i=0;i=65&&C<=70?C-55:C>=97&&C<=102?C-87:C-48&15}function s(g,I,C){var A=l(g,C);return C-1>=I&&(A|=l(g,C-1)<<4),A}function o(g,I,C,A){for(var i=0,e=Math.min(g.length,C),t=I;t=49?l-49+10:l>=17?l-17+10:l}return i}e.isBN=function(g){return g instanceof e||null!==g&&"object"==typeof g&&g.constructor.wordSize===e.wordSize&&Array.isArray(g.words)},e.max=function(g,I){return g.cmp(I)>0?g:I},e.min=function(g,I){return g.cmp(I)<0?g:I},e.prototype._init=function(g,I,C){if("number"==typeof g)return this._initNumber(g,I,C);if("object"==typeof g)return this._initArray(g,I,C);"hex"===I&&(I=16),A(I===(0|I)&&I>=2&&I<=36);var i=0;"-"===(g=g.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)t=g[i]|g[i-1]<<8|g[i-2]<<16,this.words[e]|=t<>>26-l&67108863,(l+=24)>=26&&(l-=26,e++);else if("le"===C)for(i=0,e=0;i>>26-l&67108863,(l+=24)>=26&&(l-=26,e++);return this.strip()},e.prototype._parseHex=function(g,I,C){this.length=Math.ceil((g.length-I)/6),this.words=new Array(this.length);for(var A=0;A=I;A-=2)i=s(g,I,A)<=18?(e-=18,t+=1,this.words[t]|=i>>>26):e+=8;else for(A=(g.length-I)%2==0?I+1:I;A=18?(e-=18,t+=1,this.words[t]|=i>>>26):e+=8;this.strip()},e.prototype._parseBase=function(g,I,C){this.words=[0],this.length=1;for(var A=0,i=1;i<=67108863;i*=I)A++;A--,i=i/I|0;for(var e=g.length-C,t=e%A,l=Math.min(e,e-t)+C,s=0,c=C;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},e.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],a=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function n(g){for(var I=new Array(g.bitLength()),C=0;C>>i}return I}function r(g,I,C){C.negative=I.negative^g.negative;var A=g.length+I.length|0;C.length=A,A=A-1|0;var i=0|g.words[0],e=0|I.words[0],t=i*e,l=67108863&t,s=t/67108864|0;C.words[0]=l;for(var o=1;o>>26,d=67108863&s,a=Math.min(o,I.length-1),n=Math.max(0,o-g.length+1);n<=a;n++){var r=o-n|0;c+=(t=(i=0|g.words[r])*(e=0|I.words[n])+d)/67108864|0,d=67108863&t}C.words[o]=0|d,s=0|c}return 0!==s?C.words[o]=0|s:C.length--,C.strip()}e.prototype.toString=function(g,I){var C;if(I=0|I||1,16===(g=g||10)||"hex"===g){C="";for(var i=0,e=0,t=0;t>>24-i&16777215)||t!==this.length-1?c[6-s.length]+s+C:s+C,(i+=2)>=26&&(i-=26,t--)}for(0!==e&&(C=e.toString(16)+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}if(g===(0|g)&&g>=2&&g<=36){var o=d[g],n=a[g];C="";var r=this.clone();for(r.negative=0;!r.isZero();){var m=r.modn(n).toString(g);C=(r=r.idivn(n)).isZero()?m+C:c[o-m.length]+m+C}for(this.isZero()&&(C="0"+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}A(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var g=this.words[0];return 2===this.length?g+=67108864*this.words[1]:3===this.length&&1===this.words[2]?g+=4503599627370496+67108864*this.words[1]:this.length>2&&A(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-g:g},e.prototype.toJSON=function(){return this.toString(16)},e.prototype.toBuffer=function(g,I){return A(void 0!==t),this.toArrayLike(t,g,I)},e.prototype.toArray=function(g,I){return this.toArrayLike(Array,g,I)},e.prototype.toArrayLike=function(g,I,C){var i=this.byteLength(),e=C||Math.max(1,i);A(i<=e,"byte array longer than desired length"),A(e>0,"Requested array length <= 0"),this.strip();var t,l,s="le"===I,o=new g(e),c=this.clone();if(s){for(l=0;!c.isZero();l++)t=c.andln(255),c.iushrn(8),o[l]=t;for(;l=4096&&(C+=13,I>>>=13),I>=64&&(C+=7,I>>>=7),I>=8&&(C+=4,I>>>=4),I>=2&&(C+=2,I>>>=2),C+I},e.prototype._zeroBits=function(g){if(0===g)return 26;var I=g,C=0;return 8191&I||(C+=13,I>>>=13),127&I||(C+=7,I>>>=7),15&I||(C+=4,I>>>=4),3&I||(C+=2,I>>>=2),1&I||C++,C},e.prototype.bitLength=function(){var g=this.words[this.length-1],I=this._countBits(g);return 26*(this.length-1)+I},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,I=0;Ig.length?this.clone().ior(g):g.clone().ior(this)},e.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},e.prototype.iuand=function(g){var I;I=this.length>g.length?g:this;for(var C=0;Cg.length?this.clone().iand(g):g.clone().iand(this)},e.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},e.prototype.iuxor=function(g){var I,C;this.length>g.length?(I=this,C=g):(I=g,C=this);for(var A=0;Ag.length?this.clone().ixor(g):g.clone().ixor(this)},e.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},e.prototype.inotn=function(g){A("number"==typeof g&&g>=0);var I=0|Math.ceil(g/26),C=g%26;this._expand(I),C>0&&I--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-C),this.strip()},e.prototype.notn=function(g){return this.clone().inotn(g)},e.prototype.setn=function(g,I){A("number"==typeof g&&g>=0);var C=g/26|0,i=g%26;return this._expand(C+1),this.words[C]=I?this.words[C]|1<g.length?(C=this,A=g):(C=g,A=this);for(var i=0,e=0;e>>26;for(;0!==i&&e>>26;if(this.length=C.length,0!==i)this.words[this.length]=i,this.length++;else if(C!==this)for(;eg.length?this.clone().iadd(g):g.clone().iadd(this)},e.prototype.isub=function(g){if(0!==g.negative){g.negative=0;var I=this.iadd(g);return g.negative=1,I._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var C,A,i=this.cmp(g);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(C=this,A=g):(C=g,A=this);for(var e=0,t=0;t>26,this.words[t]=67108863&I;for(;0!==e&&t>26,this.words[t]=67108863&I;if(0===e&&t>>13,n=0|t[1],r=8191&n,m=n>>>13,h=0|t[2],Z=8191&h,b=h>>>13,G=0|t[3],u=8191&G,p=G>>>13,w=0|t[4],W=8191&w,B=w>>>13,y=0|t[5],V=8191&y,X=y>>>13,Y=0|t[6],R=8191&Y,N=Y>>>13,H=0|t[7],K=8191&H,f=H>>>13,F=0|t[8],M=8191&F,S=F>>>13,J=0|t[9],k=8191&J,D=J>>>13,v=0|l[0],L=8191&v,z=v>>>13,T=0|l[1],x=8191&T,U=T>>>13,j=0|l[2],Q=8191&j,O=j>>>13,E=0|l[3],P=8191&E,_=E>>>13,q=0|l[4],$=8191&q,gg=q>>>13,Ig=0|l[5],Cg=8191&Ig,Ag=Ig>>>13,ig=0|l[6],eg=8191&ig,tg=ig>>>13,lg=0|l[7],sg=8191&lg,og=lg>>>13,cg=0|l[8],dg=8191&cg,ag=cg>>>13,ng=0|l[9],rg=8191&ng,mg=ng>>>13;C.negative=g.negative^I.negative,C.length=19;var hg=(o+(A=Math.imul(d,L))|0)+((8191&(i=(i=Math.imul(d,z))+Math.imul(a,L)|0))<<13)|0;o=((e=Math.imul(a,z))+(i>>>13)|0)+(hg>>>26)|0,hg&=67108863,A=Math.imul(r,L),i=(i=Math.imul(r,z))+Math.imul(m,L)|0,e=Math.imul(m,z);var Zg=(o+(A=A+Math.imul(d,x)|0)|0)+((8191&(i=(i=i+Math.imul(d,U)|0)+Math.imul(a,x)|0))<<13)|0;o=((e=e+Math.imul(a,U)|0)+(i>>>13)|0)+(Zg>>>26)|0,Zg&=67108863,A=Math.imul(Z,L),i=(i=Math.imul(Z,z))+Math.imul(b,L)|0,e=Math.imul(b,z),A=A+Math.imul(r,x)|0,i=(i=i+Math.imul(r,U)|0)+Math.imul(m,x)|0,e=e+Math.imul(m,U)|0;var bg=(o+(A=A+Math.imul(d,Q)|0)|0)+((8191&(i=(i=i+Math.imul(d,O)|0)+Math.imul(a,Q)|0))<<13)|0;o=((e=e+Math.imul(a,O)|0)+(i>>>13)|0)+(bg>>>26)|0,bg&=67108863,A=Math.imul(u,L),i=(i=Math.imul(u,z))+Math.imul(p,L)|0,e=Math.imul(p,z),A=A+Math.imul(Z,x)|0,i=(i=i+Math.imul(Z,U)|0)+Math.imul(b,x)|0,e=e+Math.imul(b,U)|0,A=A+Math.imul(r,Q)|0,i=(i=i+Math.imul(r,O)|0)+Math.imul(m,Q)|0,e=e+Math.imul(m,O)|0;var Gg=(o+(A=A+Math.imul(d,P)|0)|0)+((8191&(i=(i=i+Math.imul(d,_)|0)+Math.imul(a,P)|0))<<13)|0;o=((e=e+Math.imul(a,_)|0)+(i>>>13)|0)+(Gg>>>26)|0,Gg&=67108863,A=Math.imul(W,L),i=(i=Math.imul(W,z))+Math.imul(B,L)|0,e=Math.imul(B,z),A=A+Math.imul(u,x)|0,i=(i=i+Math.imul(u,U)|0)+Math.imul(p,x)|0,e=e+Math.imul(p,U)|0,A=A+Math.imul(Z,Q)|0,i=(i=i+Math.imul(Z,O)|0)+Math.imul(b,Q)|0,e=e+Math.imul(b,O)|0,A=A+Math.imul(r,P)|0,i=(i=i+Math.imul(r,_)|0)+Math.imul(m,P)|0,e=e+Math.imul(m,_)|0;var ug=(o+(A=A+Math.imul(d,$)|0)|0)+((8191&(i=(i=i+Math.imul(d,gg)|0)+Math.imul(a,$)|0))<<13)|0;o=((e=e+Math.imul(a,gg)|0)+(i>>>13)|0)+(ug>>>26)|0,ug&=67108863,A=Math.imul(V,L),i=(i=Math.imul(V,z))+Math.imul(X,L)|0,e=Math.imul(X,z),A=A+Math.imul(W,x)|0,i=(i=i+Math.imul(W,U)|0)+Math.imul(B,x)|0,e=e+Math.imul(B,U)|0,A=A+Math.imul(u,Q)|0,i=(i=i+Math.imul(u,O)|0)+Math.imul(p,Q)|0,e=e+Math.imul(p,O)|0,A=A+Math.imul(Z,P)|0,i=(i=i+Math.imul(Z,_)|0)+Math.imul(b,P)|0,e=e+Math.imul(b,_)|0,A=A+Math.imul(r,$)|0,i=(i=i+Math.imul(r,gg)|0)+Math.imul(m,$)|0,e=e+Math.imul(m,gg)|0;var pg=(o+(A=A+Math.imul(d,Cg)|0)|0)+((8191&(i=(i=i+Math.imul(d,Ag)|0)+Math.imul(a,Cg)|0))<<13)|0;o=((e=e+Math.imul(a,Ag)|0)+(i>>>13)|0)+(pg>>>26)|0,pg&=67108863,A=Math.imul(R,L),i=(i=Math.imul(R,z))+Math.imul(N,L)|0,e=Math.imul(N,z),A=A+Math.imul(V,x)|0,i=(i=i+Math.imul(V,U)|0)+Math.imul(X,x)|0,e=e+Math.imul(X,U)|0,A=A+Math.imul(W,Q)|0,i=(i=i+Math.imul(W,O)|0)+Math.imul(B,Q)|0,e=e+Math.imul(B,O)|0,A=A+Math.imul(u,P)|0,i=(i=i+Math.imul(u,_)|0)+Math.imul(p,P)|0,e=e+Math.imul(p,_)|0,A=A+Math.imul(Z,$)|0,i=(i=i+Math.imul(Z,gg)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,gg)|0,A=A+Math.imul(r,Cg)|0,i=(i=i+Math.imul(r,Ag)|0)+Math.imul(m,Cg)|0,e=e+Math.imul(m,Ag)|0;var wg=(o+(A=A+Math.imul(d,eg)|0)|0)+((8191&(i=(i=i+Math.imul(d,tg)|0)+Math.imul(a,eg)|0))<<13)|0;o=((e=e+Math.imul(a,tg)|0)+(i>>>13)|0)+(wg>>>26)|0,wg&=67108863,A=Math.imul(K,L),i=(i=Math.imul(K,z))+Math.imul(f,L)|0,e=Math.imul(f,z),A=A+Math.imul(R,x)|0,i=(i=i+Math.imul(R,U)|0)+Math.imul(N,x)|0,e=e+Math.imul(N,U)|0,A=A+Math.imul(V,Q)|0,i=(i=i+Math.imul(V,O)|0)+Math.imul(X,Q)|0,e=e+Math.imul(X,O)|0,A=A+Math.imul(W,P)|0,i=(i=i+Math.imul(W,_)|0)+Math.imul(B,P)|0,e=e+Math.imul(B,_)|0,A=A+Math.imul(u,$)|0,i=(i=i+Math.imul(u,gg)|0)+Math.imul(p,$)|0,e=e+Math.imul(p,gg)|0,A=A+Math.imul(Z,Cg)|0,i=(i=i+Math.imul(Z,Ag)|0)+Math.imul(b,Cg)|0,e=e+Math.imul(b,Ag)|0,A=A+Math.imul(r,eg)|0,i=(i=i+Math.imul(r,tg)|0)+Math.imul(m,eg)|0,e=e+Math.imul(m,tg)|0;var Wg=(o+(A=A+Math.imul(d,sg)|0)|0)+((8191&(i=(i=i+Math.imul(d,og)|0)+Math.imul(a,sg)|0))<<13)|0;o=((e=e+Math.imul(a,og)|0)+(i>>>13)|0)+(Wg>>>26)|0,Wg&=67108863,A=Math.imul(M,L),i=(i=Math.imul(M,z))+Math.imul(S,L)|0,e=Math.imul(S,z),A=A+Math.imul(K,x)|0,i=(i=i+Math.imul(K,U)|0)+Math.imul(f,x)|0,e=e+Math.imul(f,U)|0,A=A+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,O)|0)+Math.imul(N,Q)|0,e=e+Math.imul(N,O)|0,A=A+Math.imul(V,P)|0,i=(i=i+Math.imul(V,_)|0)+Math.imul(X,P)|0,e=e+Math.imul(X,_)|0,A=A+Math.imul(W,$)|0,i=(i=i+Math.imul(W,gg)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,gg)|0,A=A+Math.imul(u,Cg)|0,i=(i=i+Math.imul(u,Ag)|0)+Math.imul(p,Cg)|0,e=e+Math.imul(p,Ag)|0,A=A+Math.imul(Z,eg)|0,i=(i=i+Math.imul(Z,tg)|0)+Math.imul(b,eg)|0,e=e+Math.imul(b,tg)|0,A=A+Math.imul(r,sg)|0,i=(i=i+Math.imul(r,og)|0)+Math.imul(m,sg)|0,e=e+Math.imul(m,og)|0;var Bg=(o+(A=A+Math.imul(d,dg)|0)|0)+((8191&(i=(i=i+Math.imul(d,ag)|0)+Math.imul(a,dg)|0))<<13)|0;o=((e=e+Math.imul(a,ag)|0)+(i>>>13)|0)+(Bg>>>26)|0,Bg&=67108863,A=Math.imul(k,L),i=(i=Math.imul(k,z))+Math.imul(D,L)|0,e=Math.imul(D,z),A=A+Math.imul(M,x)|0,i=(i=i+Math.imul(M,U)|0)+Math.imul(S,x)|0,e=e+Math.imul(S,U)|0,A=A+Math.imul(K,Q)|0,i=(i=i+Math.imul(K,O)|0)+Math.imul(f,Q)|0,e=e+Math.imul(f,O)|0,A=A+Math.imul(R,P)|0,i=(i=i+Math.imul(R,_)|0)+Math.imul(N,P)|0,e=e+Math.imul(N,_)|0,A=A+Math.imul(V,$)|0,i=(i=i+Math.imul(V,gg)|0)+Math.imul(X,$)|0,e=e+Math.imul(X,gg)|0,A=A+Math.imul(W,Cg)|0,i=(i=i+Math.imul(W,Ag)|0)+Math.imul(B,Cg)|0,e=e+Math.imul(B,Ag)|0,A=A+Math.imul(u,eg)|0,i=(i=i+Math.imul(u,tg)|0)+Math.imul(p,eg)|0,e=e+Math.imul(p,tg)|0,A=A+Math.imul(Z,sg)|0,i=(i=i+Math.imul(Z,og)|0)+Math.imul(b,sg)|0,e=e+Math.imul(b,og)|0,A=A+Math.imul(r,dg)|0,i=(i=i+Math.imul(r,ag)|0)+Math.imul(m,dg)|0,e=e+Math.imul(m,ag)|0;var yg=(o+(A=A+Math.imul(d,rg)|0)|0)+((8191&(i=(i=i+Math.imul(d,mg)|0)+Math.imul(a,rg)|0))<<13)|0;o=((e=e+Math.imul(a,mg)|0)+(i>>>13)|0)+(yg>>>26)|0,yg&=67108863,A=Math.imul(k,x),i=(i=Math.imul(k,U))+Math.imul(D,x)|0,e=Math.imul(D,U),A=A+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,O)|0)+Math.imul(S,Q)|0,e=e+Math.imul(S,O)|0,A=A+Math.imul(K,P)|0,i=(i=i+Math.imul(K,_)|0)+Math.imul(f,P)|0,e=e+Math.imul(f,_)|0,A=A+Math.imul(R,$)|0,i=(i=i+Math.imul(R,gg)|0)+Math.imul(N,$)|0,e=e+Math.imul(N,gg)|0,A=A+Math.imul(V,Cg)|0,i=(i=i+Math.imul(V,Ag)|0)+Math.imul(X,Cg)|0,e=e+Math.imul(X,Ag)|0,A=A+Math.imul(W,eg)|0,i=(i=i+Math.imul(W,tg)|0)+Math.imul(B,eg)|0,e=e+Math.imul(B,tg)|0,A=A+Math.imul(u,sg)|0,i=(i=i+Math.imul(u,og)|0)+Math.imul(p,sg)|0,e=e+Math.imul(p,og)|0,A=A+Math.imul(Z,dg)|0,i=(i=i+Math.imul(Z,ag)|0)+Math.imul(b,dg)|0,e=e+Math.imul(b,ag)|0;var Vg=(o+(A=A+Math.imul(r,rg)|0)|0)+((8191&(i=(i=i+Math.imul(r,mg)|0)+Math.imul(m,rg)|0))<<13)|0;o=((e=e+Math.imul(m,mg)|0)+(i>>>13)|0)+(Vg>>>26)|0,Vg&=67108863,A=Math.imul(k,Q),i=(i=Math.imul(k,O))+Math.imul(D,Q)|0,e=Math.imul(D,O),A=A+Math.imul(M,P)|0,i=(i=i+Math.imul(M,_)|0)+Math.imul(S,P)|0,e=e+Math.imul(S,_)|0,A=A+Math.imul(K,$)|0,i=(i=i+Math.imul(K,gg)|0)+Math.imul(f,$)|0,e=e+Math.imul(f,gg)|0,A=A+Math.imul(R,Cg)|0,i=(i=i+Math.imul(R,Ag)|0)+Math.imul(N,Cg)|0,e=e+Math.imul(N,Ag)|0,A=A+Math.imul(V,eg)|0,i=(i=i+Math.imul(V,tg)|0)+Math.imul(X,eg)|0,e=e+Math.imul(X,tg)|0,A=A+Math.imul(W,sg)|0,i=(i=i+Math.imul(W,og)|0)+Math.imul(B,sg)|0,e=e+Math.imul(B,og)|0,A=A+Math.imul(u,dg)|0,i=(i=i+Math.imul(u,ag)|0)+Math.imul(p,dg)|0,e=e+Math.imul(p,ag)|0;var Xg=(o+(A=A+Math.imul(Z,rg)|0)|0)+((8191&(i=(i=i+Math.imul(Z,mg)|0)+Math.imul(b,rg)|0))<<13)|0;o=((e=e+Math.imul(b,mg)|0)+(i>>>13)|0)+(Xg>>>26)|0,Xg&=67108863,A=Math.imul(k,P),i=(i=Math.imul(k,_))+Math.imul(D,P)|0,e=Math.imul(D,_),A=A+Math.imul(M,$)|0,i=(i=i+Math.imul(M,gg)|0)+Math.imul(S,$)|0,e=e+Math.imul(S,gg)|0,A=A+Math.imul(K,Cg)|0,i=(i=i+Math.imul(K,Ag)|0)+Math.imul(f,Cg)|0,e=e+Math.imul(f,Ag)|0,A=A+Math.imul(R,eg)|0,i=(i=i+Math.imul(R,tg)|0)+Math.imul(N,eg)|0,e=e+Math.imul(N,tg)|0,A=A+Math.imul(V,sg)|0,i=(i=i+Math.imul(V,og)|0)+Math.imul(X,sg)|0,e=e+Math.imul(X,og)|0,A=A+Math.imul(W,dg)|0,i=(i=i+Math.imul(W,ag)|0)+Math.imul(B,dg)|0,e=e+Math.imul(B,ag)|0;var Yg=(o+(A=A+Math.imul(u,rg)|0)|0)+((8191&(i=(i=i+Math.imul(u,mg)|0)+Math.imul(p,rg)|0))<<13)|0;o=((e=e+Math.imul(p,mg)|0)+(i>>>13)|0)+(Yg>>>26)|0,Yg&=67108863,A=Math.imul(k,$),i=(i=Math.imul(k,gg))+Math.imul(D,$)|0,e=Math.imul(D,gg),A=A+Math.imul(M,Cg)|0,i=(i=i+Math.imul(M,Ag)|0)+Math.imul(S,Cg)|0,e=e+Math.imul(S,Ag)|0,A=A+Math.imul(K,eg)|0,i=(i=i+Math.imul(K,tg)|0)+Math.imul(f,eg)|0,e=e+Math.imul(f,tg)|0,A=A+Math.imul(R,sg)|0,i=(i=i+Math.imul(R,og)|0)+Math.imul(N,sg)|0,e=e+Math.imul(N,og)|0,A=A+Math.imul(V,dg)|0,i=(i=i+Math.imul(V,ag)|0)+Math.imul(X,dg)|0,e=e+Math.imul(X,ag)|0;var Rg=(o+(A=A+Math.imul(W,rg)|0)|0)+((8191&(i=(i=i+Math.imul(W,mg)|0)+Math.imul(B,rg)|0))<<13)|0;o=((e=e+Math.imul(B,mg)|0)+(i>>>13)|0)+(Rg>>>26)|0,Rg&=67108863,A=Math.imul(k,Cg),i=(i=Math.imul(k,Ag))+Math.imul(D,Cg)|0,e=Math.imul(D,Ag),A=A+Math.imul(M,eg)|0,i=(i=i+Math.imul(M,tg)|0)+Math.imul(S,eg)|0,e=e+Math.imul(S,tg)|0,A=A+Math.imul(K,sg)|0,i=(i=i+Math.imul(K,og)|0)+Math.imul(f,sg)|0,e=e+Math.imul(f,og)|0,A=A+Math.imul(R,dg)|0,i=(i=i+Math.imul(R,ag)|0)+Math.imul(N,dg)|0,e=e+Math.imul(N,ag)|0;var Ng=(o+(A=A+Math.imul(V,rg)|0)|0)+((8191&(i=(i=i+Math.imul(V,mg)|0)+Math.imul(X,rg)|0))<<13)|0;o=((e=e+Math.imul(X,mg)|0)+(i>>>13)|0)+(Ng>>>26)|0,Ng&=67108863,A=Math.imul(k,eg),i=(i=Math.imul(k,tg))+Math.imul(D,eg)|0,e=Math.imul(D,tg),A=A+Math.imul(M,sg)|0,i=(i=i+Math.imul(M,og)|0)+Math.imul(S,sg)|0,e=e+Math.imul(S,og)|0,A=A+Math.imul(K,dg)|0,i=(i=i+Math.imul(K,ag)|0)+Math.imul(f,dg)|0,e=e+Math.imul(f,ag)|0;var Hg=(o+(A=A+Math.imul(R,rg)|0)|0)+((8191&(i=(i=i+Math.imul(R,mg)|0)+Math.imul(N,rg)|0))<<13)|0;o=((e=e+Math.imul(N,mg)|0)+(i>>>13)|0)+(Hg>>>26)|0,Hg&=67108863,A=Math.imul(k,sg),i=(i=Math.imul(k,og))+Math.imul(D,sg)|0,e=Math.imul(D,og),A=A+Math.imul(M,dg)|0,i=(i=i+Math.imul(M,ag)|0)+Math.imul(S,dg)|0,e=e+Math.imul(S,ag)|0;var Kg=(o+(A=A+Math.imul(K,rg)|0)|0)+((8191&(i=(i=i+Math.imul(K,mg)|0)+Math.imul(f,rg)|0))<<13)|0;o=((e=e+Math.imul(f,mg)|0)+(i>>>13)|0)+(Kg>>>26)|0,Kg&=67108863,A=Math.imul(k,dg),i=(i=Math.imul(k,ag))+Math.imul(D,dg)|0,e=Math.imul(D,ag);var fg=(o+(A=A+Math.imul(M,rg)|0)|0)+((8191&(i=(i=i+Math.imul(M,mg)|0)+Math.imul(S,rg)|0))<<13)|0;o=((e=e+Math.imul(S,mg)|0)+(i>>>13)|0)+(fg>>>26)|0,fg&=67108863;var Fg=(o+(A=Math.imul(k,rg))|0)+((8191&(i=(i=Math.imul(k,mg))+Math.imul(D,rg)|0))<<13)|0;return o=((e=Math.imul(D,mg))+(i>>>13)|0)+(Fg>>>26)|0,Fg&=67108863,s[0]=hg,s[1]=Zg,s[2]=bg,s[3]=Gg,s[4]=ug,s[5]=pg,s[6]=wg,s[7]=Wg,s[8]=Bg,s[9]=yg,s[10]=Vg,s[11]=Xg,s[12]=Yg,s[13]=Rg,s[14]=Ng,s[15]=Hg,s[16]=Kg,s[17]=fg,s[18]=Fg,0!==o&&(s[19]=o,C.length++),C};function h(g,I,C){C.negative=I.negative^g.negative,C.length=g.length+I.length;for(var A=0,i=0,e=0;e>>26)|0)>>>26,t&=67108863}C.words[e]=l,A=t,t=i}return 0!==A?C.words[e]=A:C.length--,C.strip()}function Z(g,I,C){return(new b).mulp(g,I,C)}function b(g,I){this.x=g,this.y=I}Math.imul||(m=r),e.prototype.mulTo=function(g,I){var C=this.length+g.length;return 10===this.length&&10===g.length?m(this,g,I):C<63?r(this,g,I):C<1024?h(this,g,I):Z(this,g,I)},b.prototype.makeRBT=function(g){for(var I=new Array(g),C=e.prototype._countBits(g)-1,A=0;A>=1;return A},b.prototype.permute=function(g,I,C,A,i,e){for(var t=0;t>>=1)i++;return 1<>>=13,C[2*t+1]=8191&e,e>>>=13;for(t=2*I;t>=26,I+=i/67108864|0,I+=e>>>26,this.words[C]=67108863&e}return 0!==I&&(this.words[C]=I,this.length++),this},e.prototype.muln=function(g){return this.clone().imuln(g)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(g){var I=n(g);if(0===I.length)return new e(1);for(var C=this,A=0;A=0);var I,C=g%26,i=(g-C)/26,e=67108863>>>26-C<<26-C;if(0!==C){var t=0;for(I=0;I>>26-C}t&&(this.words[I]=t,this.length++)}if(0!==i){for(I=this.length-1;I>=0;I--)this.words[I+i]=this.words[I];for(I=0;I=0),i=I?(I-I%26)/26:0;var e=g%26,t=Math.min((g-e)/26,this.length),l=67108863^67108863>>>e<t)for(this.length-=t,o=0;o=0&&(0!==c||o>=i);o--){var d=0|this.words[o];this.words[o]=c<<26-e|d>>>e,c=d&l}return s&&0!==c&&(s.words[s.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},e.prototype.ishrn=function(g,I,C){return A(0===this.negative),this.iushrn(g,I,C)},e.prototype.shln=function(g){return this.clone().ishln(g)},e.prototype.ushln=function(g){return this.clone().iushln(g)},e.prototype.shrn=function(g){return this.clone().ishrn(g)},e.prototype.ushrn=function(g){return this.clone().iushrn(g)},e.prototype.testn=function(g){A("number"==typeof g&&g>=0);var I=g%26,C=(g-I)/26,i=1<=0);var I=g%26,C=(g-I)/26;if(A(0===this.negative,"imaskn works only with positive numbers"),this.length<=C)return this;if(0!==I&&C++,this.length=Math.min(C,this.length),0!==I){var i=67108863^67108863>>>I<=67108864;I++)this.words[I]-=67108864,I===this.length-1?this.words[I+1]=1:this.words[I+1]++;return this.length=Math.max(this.length,I+1),this},e.prototype.isubn=function(g){if(A("number"==typeof g),A(g<67108864),g<0)return this.iaddn(-g);if(0!==this.negative)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var I=0;I>26)-(s/67108864|0),this.words[i+C]=67108863&e}for(;i>26,this.words[i+C]=67108863&e;if(0===l)return this.strip();for(A(-1===l),l=0,i=0;i>26,this.words[i]=67108863&e;return this.negative=1,this.strip()},e.prototype._wordDiv=function(g,I){var C=this.length-g.length,A=this.clone(),i=g,t=0|i.words[i.length-1];0!=(C=26-this._countBits(t))&&(i=i.ushln(C),A.iushln(C),t=0|i.words[i.length-1]);var l,s=A.length-i.length;if("mod"!==I){(l=new e(null)).length=s+1,l.words=new Array(l.length);for(var o=0;o=0;d--){var a=67108864*(0|A.words[i.length+d])+(0|A.words[i.length+d-1]);for(a=Math.min(a/t|0,67108863),A._ishlnsubmul(i,a,d);0!==A.negative;)a--,A.negative=0,A._ishlnsubmul(i,1,d),A.isZero()||(A.negative^=1);l&&(l.words[d]=a)}return l&&l.strip(),A.strip(),"div"!==I&&0!==C&&A.iushrn(C),{div:l||null,mod:A}},e.prototype.divmod=function(g,I,C){return A(!g.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===g.negative?(l=this.neg().divmod(g,I),"mod"!==I&&(i=l.div.neg()),"div"!==I&&(t=l.mod.neg(),C&&0!==t.negative&&t.iadd(g)),{div:i,mod:t}):0===this.negative&&0!==g.negative?(l=this.divmod(g.neg(),I),"mod"!==I&&(i=l.div.neg()),{div:i,mod:l.mod}):this.negative&g.negative?(l=this.neg().divmod(g.neg(),I),"div"!==I&&(t=l.mod.neg(),C&&0!==t.negative&&t.isub(g)),{div:l.div,mod:t}):g.length>this.length||this.cmp(g)<0?{div:new e(0),mod:this}:1===g.length?"div"===I?{div:this.divn(g.words[0]),mod:null}:"mod"===I?{div:null,mod:new e(this.modn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new e(this.modn(g.words[0]))}:this._wordDiv(g,I);var i,t,l},e.prototype.div=function(g){return this.divmod(g,"div",!1).div},e.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},e.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},e.prototype.divRound=function(g){var I=this.divmod(g);if(I.mod.isZero())return I.div;var C=0!==I.div.negative?I.mod.isub(g):I.mod,A=g.ushrn(1),i=g.andln(1),e=C.cmp(A);return e<0||1===i&&0===e?I.div:0!==I.div.negative?I.div.isubn(1):I.div.iaddn(1)},e.prototype.modn=function(g){A(g<=67108863);for(var I=(1<<26)%g,C=0,i=this.length-1;i>=0;i--)C=(I*C+(0|this.words[i]))%g;return C},e.prototype.idivn=function(g){A(g<=67108863);for(var I=0,C=this.length-1;C>=0;C--){var i=(0|this.words[C])+67108864*I;this.words[C]=i/g|0,I=i%g}return this.strip()},e.prototype.divn=function(g){return this.clone().idivn(g)},e.prototype.egcd=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i=new e(1),t=new e(0),l=new e(0),s=new e(1),o=0;I.isEven()&&C.isEven();)I.iushrn(1),C.iushrn(1),++o;for(var c=C.clone(),d=I.clone();!I.isZero();){for(var a=0,n=1;!(I.words[0]&n)&&a<26;++a,n<<=1);if(a>0)for(I.iushrn(a);a-- >0;)(i.isOdd()||t.isOdd())&&(i.iadd(c),t.isub(d)),i.iushrn(1),t.iushrn(1);for(var r=0,m=1;!(C.words[0]&m)&&r<26;++r,m<<=1);if(r>0)for(C.iushrn(r);r-- >0;)(l.isOdd()||s.isOdd())&&(l.iadd(c),s.isub(d)),l.iushrn(1),s.iushrn(1);I.cmp(C)>=0?(I.isub(C),i.isub(l),t.isub(s)):(C.isub(I),l.isub(i),s.isub(t))}return{a:l,b:s,gcd:C.iushln(o)}},e.prototype._invmp=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i,t=new e(1),l=new e(0),s=C.clone();I.cmpn(1)>0&&C.cmpn(1)>0;){for(var o=0,c=1;!(I.words[0]&c)&&o<26;++o,c<<=1);if(o>0)for(I.iushrn(o);o-- >0;)t.isOdd()&&t.iadd(s),t.iushrn(1);for(var d=0,a=1;!(C.words[0]&a)&&d<26;++d,a<<=1);if(d>0)for(C.iushrn(d);d-- >0;)l.isOdd()&&l.iadd(s),l.iushrn(1);I.cmp(C)>=0?(I.isub(C),t.isub(l)):(C.isub(I),l.isub(t))}return(i=0===I.cmpn(1)?t:l).cmpn(0)<0&&i.iadd(g),i},e.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var I=this.clone(),C=g.clone();I.negative=0,C.negative=0;for(var A=0;I.isEven()&&C.isEven();A++)I.iushrn(1),C.iushrn(1);for(;;){for(;I.isEven();)I.iushrn(1);for(;C.isEven();)C.iushrn(1);var i=I.cmp(C);if(i<0){var e=I;I=C,C=e}else if(0===i||0===C.cmpn(1))break;I.isub(C)}return C.iushln(A)},e.prototype.invm=function(g){return this.egcd(g).a.umod(g)},e.prototype.isEven=function(){return!(1&this.words[0])},e.prototype.isOdd=function(){return!(1&~this.words[0])},e.prototype.andln=function(g){return this.words[0]&g},e.prototype.bincn=function(g){A("number"==typeof g);var I=g%26,C=(g-I)/26,i=1<>>26,l&=67108863,this.words[t]=l}return 0!==e&&(this.words[t]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(g){var I,C=g<0;if(0!==this.negative&&!C)return-1;if(0===this.negative&&C)return 1;if(this.strip(),this.length>1)I=1;else{C&&(g=-g),A(g<=67108863,"Number is too big");var i=0|this.words[0];I=i===g?0:ig.length)return 1;if(this.length=0;C--){var A=0|this.words[C],i=0|g.words[C];if(A!==i){Ai&&(I=1);break}}return I},e.prototype.gtn=function(g){return 1===this.cmpn(g)},e.prototype.gt=function(g){return 1===this.cmp(g)},e.prototype.gten=function(g){return this.cmpn(g)>=0},e.prototype.gte=function(g){return this.cmp(g)>=0},e.prototype.ltn=function(g){return-1===this.cmpn(g)},e.prototype.lt=function(g){return-1===this.cmp(g)},e.prototype.lten=function(g){return this.cmpn(g)<=0},e.prototype.lte=function(g){return this.cmp(g)<=0},e.prototype.eqn=function(g){return 0===this.cmpn(g)},e.prototype.eq=function(g){return 0===this.cmp(g)},e.red=function(g){return new y(g)},e.prototype.toRed=function(g){return A(!this.red,"Already a number in reduction context"),A(0===this.negative,"red works only with positives"),g.convertTo(this)._forceRed(g)},e.prototype.fromRed=function(){return A(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(g){return this.red=g,this},e.prototype.forceRed=function(g){return A(!this.red,"Already a number in reduction context"),this._forceRed(g)},e.prototype.redAdd=function(g){return A(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},e.prototype.redIAdd=function(g){return A(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},e.prototype.redSub=function(g){return A(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},e.prototype.redISub=function(g){return A(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},e.prototype.redShl=function(g){return A(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},e.prototype.redMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},e.prototype.redIMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},e.prototype.redSqr=function(){return A(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return A(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return A(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return A(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return A(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(g){return A(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var G={k256:null,p224:null,p192:null,p25519:null};function u(g,I){this.name=g,this.p=new e(I,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function p(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){u.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function W(){u.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function B(){u.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function y(g){if("string"==typeof g){var I=e._prime(g);this.m=I.p,this.prime=I}else A(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}function V(g){y.call(this,g),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}u.prototype._tmp=function(){var g=new e(null);return g.words=new Array(Math.ceil(this.n/13)),g},u.prototype.ireduce=function(g){var I,C=g;do{this.split(C,this.tmp),I=(C=(C=this.imulK(C)).iadd(this.tmp)).bitLength()}while(I>this.n);var A=I0?C.isub(this.p):void 0!==C.strip?C.strip():C._strip(),C},u.prototype.split=function(g,I){g.iushrn(this.n,0,I)},u.prototype.imulK=function(g){return g.imul(this.k)},i(p,u),p.prototype.split=function(g,I){for(var C=4194303,A=Math.min(g.length,9),i=0;i>>22,e=t}e>>>=22,g.words[i-10]=e,0===e&&g.length>10?g.length-=10:g.length-=9},p.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var I=0,C=0;C>>=26,g.words[C]=i,I=A}return 0!==I&&(g.words[g.length++]=I),g},e._prime=function(g){if(G[g])return G[g];var I;if("k256"===g)I=new p;else if("p224"===g)I=new w;else if("p192"===g)I=new W;else{if("p25519"!==g)throw new Error("Unknown prime "+g);I=new B}return G[g]=I,I},y.prototype._verify1=function(g){A(0===g.negative,"red works only with positives"),A(g.red,"red works only with red numbers")},y.prototype._verify2=function(g,I){A(!(g.negative|I.negative),"red works only with positives"),A(g.red&&g.red===I.red,"red works only with red numbers")},y.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},y.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},y.prototype.add=function(g,I){this._verify2(g,I);var C=g.add(I);return C.cmp(this.m)>=0&&C.isub(this.m),C._forceRed(this)},y.prototype.iadd=function(g,I){this._verify2(g,I);var C=g.iadd(I);return C.cmp(this.m)>=0&&C.isub(this.m),C},y.prototype.sub=function(g,I){this._verify2(g,I);var C=g.sub(I);return C.cmpn(0)<0&&C.iadd(this.m),C._forceRed(this)},y.prototype.isub=function(g,I){this._verify2(g,I);var C=g.isub(I);return C.cmpn(0)<0&&C.iadd(this.m),C},y.prototype.shl=function(g,I){return this._verify1(g),this.imod(g.ushln(I))},y.prototype.imul=function(g,I){return this._verify2(g,I),this.imod(g.imul(I))},y.prototype.mul=function(g,I){return this._verify2(g,I),this.imod(g.mul(I))},y.prototype.isqr=function(g){return this.imul(g,g.clone())},y.prototype.sqr=function(g){return this.mul(g,g)},y.prototype.sqrt=function(g){if(g.isZero())return g.clone();var I=this.m.andln(3);if(A(I%2==1),3===I){var C=this.m.add(new e(1)).iushrn(2);return this.pow(g,C)}for(var i=this.m.subn(1),t=0;!i.isZero()&&0===i.andln(1);)t++,i.iushrn(1);A(!i.isZero());var l=new e(1).toRed(this),s=l.redNeg(),o=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new e(2*c*c).toRed(this);0!==this.pow(c,o).cmp(s);)c.redIAdd(s);for(var d=this.pow(c,i),a=this.pow(g,i.addn(1).iushrn(1)),n=this.pow(g,i),r=t;0!==n.cmp(l);){for(var m=n,h=0;0!==m.cmp(l);h++)m=m.redSqr();A(h=0;i--){for(var c=I.words[i],d=o-1;d>=0;d--){var a=c>>d&1;t!==A[0]&&(t=this.sqr(t)),0!==a||0!==l?(l<<=1,l|=a,(++s===C||0===i&&0===d)&&(t=this.mul(t,A[l]),s=0,l=0)):s=0}o=26}return t},y.prototype.convertTo=function(g){var I=g.umod(this.m);return I===g?I.clone():I},y.prototype.convertFrom=function(g){var I=g.clone();return I.red=null,I},e.mont=function(g){return new V(g)},i(V,y),V.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},V.prototype.convertFrom=function(g){var I=this.imod(g.mul(this.rinv));return I.red=null,I},V.prototype.imul=function(g,I){if(g.isZero()||I.isZero())return g.words[0]=0,g.length=1,g;var C=g.imul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),e=i;return i.cmp(this.m)>=0?e=i.isub(this.m):i.cmpn(0)<0&&(e=i.iadd(this.m)),e._forceRed(this)},V.prototype.mul=function(g,I){if(g.isZero()||I.isZero())return new e(0)._forceRed(this);var C=g.mul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),t=i;return i.cmp(this.m)>=0?t=i.isub(this.m):i.cmpn(0)<0&&(t=i.iadd(this.m)),t._forceRed(this)},V.prototype.invm=function(g){return this.imod(g._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===I||I,void 0)},{buffer:188}],185:[function(g,I,C){C.byteLength=c,C.toByteArray=a,C.fromByteArray=m;for(var A=[],i=[],e="undefined"!=typeof Uint8Array?Uint8Array:Array,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,s=t.length;l0)throw new Error("Invalid string. Length must be a multiple of 4");var C=g.indexOf("=");return-1===C&&(C=I),[C,C===I?0:4-C%4]}function c(g){var I=o(g),C=I[0],A=I[1];return 3*(C+A)/4-A}function d(g,I,C){return 3*(I+C)/4-C}function a(g){var I,C,A=o(g),t=A[0],l=A[1],s=new e(d(g,t,l)),c=0,a=l>0?t-4:t;for(C=0;C>16&255,s[c++]=I>>8&255,s[c++]=255&I;return 2===l&&(I=i[g.charCodeAt(C)]<<2|i[g.charCodeAt(C+1)]>>4,s[c++]=255&I),1===l&&(I=i[g.charCodeAt(C)]<<10|i[g.charCodeAt(C+1)]<<4|i[g.charCodeAt(C+2)]>>2,s[c++]=I>>8&255,s[c++]=255&I),s}function n(g){return A[g>>18&63]+A[g>>12&63]+A[g>>6&63]+A[63&g]}function r(g,I,C){for(var A,i=[],e=I;es?s:l+t));return 1===i?(I=g[C-1],e.push(A[I>>2]+A[I<<4&63]+"==")):2===i&&(I=(g[C-2]<<8)+g[C-1],e.push(A[I>>10]+A[I>>4&63]+A[I<<2&63]+"=")),e.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],186:[function(g,I,C){!function(I,C){function A(g,I){if(!g)throw new Error(I||"Assertion failed")}function i(g,I){g.super_=I;var C=function(){};C.prototype=I.prototype,g.prototype=new C,g.prototype.constructor=g}function e(g,I,C){if(e.isBN(g))return g;this.negative=0,this.words=null,this.length=0,this.red=null,null!==g&&("le"!==I&&"be"!==I||(C=I,I=10),this._init(g||0,I||10,C||"be"))}var t;"object"==typeof I?I.exports=e:C.BN=e,e.BN=e,e.wordSize=26;try{t="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:g("buffer").Buffer}catch(R){}function l(g,I){var C=g.charCodeAt(I);return C>=48&&C<=57?C-48:C>=65&&C<=70?C-55:C>=97&&C<=102?C-87:void A(!1,"Invalid character in "+g)}function s(g,I,C){var A=l(g,C);return C-1>=I&&(A|=l(g,C-1)<<4),A}function o(g,I,C,i){for(var e=0,t=0,l=Math.min(g.length,C),s=I;s=49?o-49+10:o>=17?o-17+10:o,A(o>=0&&t0?g:I},e.min=function(g,I){return g.cmp(I)<0?g:I},e.prototype._init=function(g,I,C){if("number"==typeof g)return this._initNumber(g,I,C);if("object"==typeof g)return this._initArray(g,I,C);"hex"===I&&(I=16),A(I===(0|I)&&I>=2&&I<=36);var i=0;"-"===(g=g.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)t=g[i]|g[i-1]<<8|g[i-2]<<16,this.words[e]|=t<>>26-l&67108863,(l+=24)>=26&&(l-=26,e++);else if("le"===C)for(i=0,e=0;i>>26-l&67108863,(l+=24)>=26&&(l-=26,e++);return this._strip()},e.prototype._parseHex=function(g,I,C){this.length=Math.ceil((g.length-I)/6),this.words=new Array(this.length);for(var A=0;A=I;A-=2)i=s(g,I,A)<=18?(e-=18,t+=1,this.words[t]|=i>>>26):e+=8;else for(A=(g.length-I)%2==0?I+1:I;A=18?(e-=18,t+=1,this.words[t]|=i>>>26):e+=8;this._strip()},e.prototype._parseBase=function(g,I,C){this.words=[0],this.length=1;for(var A=0,i=1;i<=67108863;i*=I)A++;A--,i=i/I|0;for(var e=g.length-C,t=e%A,l=Math.min(e,e-t)+C,s=0,c=C;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{e.prototype[Symbol.for("nodejs.util.inspect.custom")]=d}catch(R){e.prototype.inspect=d}else e.prototype.inspect=d;function d(){return(this.red?""}var a=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],n=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],r=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];e.prototype.toString=function(g,I){var C;if(I=0|I||1,16===(g=g||10)||"hex"===g){C="";for(var i=0,e=0,t=0;t>>24-i&16777215,(i+=2)>=26&&(i-=26,t--),C=0!==e||t!==this.length-1?a[6-s.length]+s+C:s+C}for(0!==e&&(C=e.toString(16)+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}if(g===(0|g)&&g>=2&&g<=36){var o=n[g],c=r[g];C="";var d=this.clone();for(d.negative=0;!d.isZero();){var m=d.modrn(c).toString(g);C=(d=d.idivn(c)).isZero()?m+C:a[o-m.length]+m+C}for(this.isZero()&&(C="0"+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}A(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var g=this.words[0];return 2===this.length?g+=67108864*this.words[1]:3===this.length&&1===this.words[2]?g+=4503599627370496+67108864*this.words[1]:this.length>2&&A(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-g:g},e.prototype.toJSON=function(){return this.toString(16,2)},t&&(e.prototype.toBuffer=function(g,I){return this.toArrayLike(t,g,I)}),e.prototype.toArray=function(g,I){return this.toArrayLike(Array,g,I)};var m=function(g,I){return g.allocUnsafe?g.allocUnsafe(I):new g(I)};function h(g){for(var I=new Array(g.bitLength()),C=0;C>>i&1}return I}function Z(g,I,C){C.negative=I.negative^g.negative;var A=g.length+I.length|0;C.length=A,A=A-1|0;var i=0|g.words[0],e=0|I.words[0],t=i*e,l=67108863&t,s=t/67108864|0;C.words[0]=l;for(var o=1;o>>26,d=67108863&s,a=Math.min(o,I.length-1),n=Math.max(0,o-g.length+1);n<=a;n++){var r=o-n|0;c+=(t=(i=0|g.words[r])*(e=0|I.words[n])+d)/67108864|0,d=67108863&t}C.words[o]=0|d,s=0|c}return 0!==s?C.words[o]=0|s:C.length--,C._strip()}e.prototype.toArrayLike=function(g,I,C){this._strip();var i=this.byteLength(),e=C||Math.max(1,i);A(i<=e,"byte array longer than desired length"),A(e>0,"Requested array length <= 0");var t=m(g,e);return this["_toArrayLike"+("le"===I?"LE":"BE")](t,i),t},e.prototype._toArrayLikeLE=function(g,I){for(var C=0,A=0,i=0,e=0;i>8&255),C>16&255),6===e?(C>24&255),A=0,e=0):(A=t>>>24,e+=2)}if(C=0&&(g[C--]=t>>8&255),C>=0&&(g[C--]=t>>16&255),6===e?(C>=0&&(g[C--]=t>>24&255),A=0,e=0):(A=t>>>24,e+=2)}if(C>=0)for(g[C--]=A;C>=0;)g[C--]=0},Math.clz32?e.prototype._countBits=function(g){return 32-Math.clz32(g)}:e.prototype._countBits=function(g){var I=g,C=0;return I>=4096&&(C+=13,I>>>=13),I>=64&&(C+=7,I>>>=7),I>=8&&(C+=4,I>>>=4),I>=2&&(C+=2,I>>>=2),C+I},e.prototype._zeroBits=function(g){if(0===g)return 26;var I=g,C=0;return 8191&I||(C+=13,I>>>=13),127&I||(C+=7,I>>>=7),15&I||(C+=4,I>>>=4),3&I||(C+=2,I>>>=2),1&I||C++,C},e.prototype.bitLength=function(){var g=this.words[this.length-1],I=this._countBits(g);return 26*(this.length-1)+I},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,I=0;Ig.length?this.clone().ior(g):g.clone().ior(this)},e.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},e.prototype.iuand=function(g){var I;I=this.length>g.length?g:this;for(var C=0;Cg.length?this.clone().iand(g):g.clone().iand(this)},e.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},e.prototype.iuxor=function(g){var I,C;this.length>g.length?(I=this,C=g):(I=g,C=this);for(var A=0;Ag.length?this.clone().ixor(g):g.clone().ixor(this)},e.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},e.prototype.inotn=function(g){A("number"==typeof g&&g>=0);var I=0|Math.ceil(g/26),C=g%26;this._expand(I),C>0&&I--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-C),this._strip()},e.prototype.notn=function(g){return this.clone().inotn(g)},e.prototype.setn=function(g,I){A("number"==typeof g&&g>=0);var C=g/26|0,i=g%26;return this._expand(C+1),this.words[C]=I?this.words[C]|1<g.length?(C=this,A=g):(C=g,A=this);for(var i=0,e=0;e>>26;for(;0!==i&&e>>26;if(this.length=C.length,0!==i)this.words[this.length]=i,this.length++;else if(C!==this)for(;eg.length?this.clone().iadd(g):g.clone().iadd(this)},e.prototype.isub=function(g){if(0!==g.negative){g.negative=0;var I=this.iadd(g);return g.negative=1,I._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var C,A,i=this.cmp(g);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(C=this,A=g):(C=g,A=this);for(var e=0,t=0;t>26,this.words[t]=67108863&I;for(;0!==e&&t>26,this.words[t]=67108863&I;if(0===e&&t>>13,n=0|t[1],r=8191&n,m=n>>>13,h=0|t[2],Z=8191&h,b=h>>>13,G=0|t[3],u=8191&G,p=G>>>13,w=0|t[4],W=8191&w,B=w>>>13,y=0|t[5],V=8191&y,X=y>>>13,Y=0|t[6],R=8191&Y,N=Y>>>13,H=0|t[7],K=8191&H,f=H>>>13,F=0|t[8],M=8191&F,S=F>>>13,J=0|t[9],k=8191&J,D=J>>>13,v=0|l[0],L=8191&v,z=v>>>13,T=0|l[1],x=8191&T,U=T>>>13,j=0|l[2],Q=8191&j,O=j>>>13,E=0|l[3],P=8191&E,_=E>>>13,q=0|l[4],$=8191&q,gg=q>>>13,Ig=0|l[5],Cg=8191&Ig,Ag=Ig>>>13,ig=0|l[6],eg=8191&ig,tg=ig>>>13,lg=0|l[7],sg=8191&lg,og=lg>>>13,cg=0|l[8],dg=8191&cg,ag=cg>>>13,ng=0|l[9],rg=8191&ng,mg=ng>>>13;C.negative=g.negative^I.negative,C.length=19;var hg=(o+(A=Math.imul(d,L))|0)+((8191&(i=(i=Math.imul(d,z))+Math.imul(a,L)|0))<<13)|0;o=((e=Math.imul(a,z))+(i>>>13)|0)+(hg>>>26)|0,hg&=67108863,A=Math.imul(r,L),i=(i=Math.imul(r,z))+Math.imul(m,L)|0,e=Math.imul(m,z);var Zg=(o+(A=A+Math.imul(d,x)|0)|0)+((8191&(i=(i=i+Math.imul(d,U)|0)+Math.imul(a,x)|0))<<13)|0;o=((e=e+Math.imul(a,U)|0)+(i>>>13)|0)+(Zg>>>26)|0,Zg&=67108863,A=Math.imul(Z,L),i=(i=Math.imul(Z,z))+Math.imul(b,L)|0,e=Math.imul(b,z),A=A+Math.imul(r,x)|0,i=(i=i+Math.imul(r,U)|0)+Math.imul(m,x)|0,e=e+Math.imul(m,U)|0;var bg=(o+(A=A+Math.imul(d,Q)|0)|0)+((8191&(i=(i=i+Math.imul(d,O)|0)+Math.imul(a,Q)|0))<<13)|0;o=((e=e+Math.imul(a,O)|0)+(i>>>13)|0)+(bg>>>26)|0,bg&=67108863,A=Math.imul(u,L),i=(i=Math.imul(u,z))+Math.imul(p,L)|0,e=Math.imul(p,z),A=A+Math.imul(Z,x)|0,i=(i=i+Math.imul(Z,U)|0)+Math.imul(b,x)|0,e=e+Math.imul(b,U)|0,A=A+Math.imul(r,Q)|0,i=(i=i+Math.imul(r,O)|0)+Math.imul(m,Q)|0,e=e+Math.imul(m,O)|0;var Gg=(o+(A=A+Math.imul(d,P)|0)|0)+((8191&(i=(i=i+Math.imul(d,_)|0)+Math.imul(a,P)|0))<<13)|0;o=((e=e+Math.imul(a,_)|0)+(i>>>13)|0)+(Gg>>>26)|0,Gg&=67108863,A=Math.imul(W,L),i=(i=Math.imul(W,z))+Math.imul(B,L)|0,e=Math.imul(B,z),A=A+Math.imul(u,x)|0,i=(i=i+Math.imul(u,U)|0)+Math.imul(p,x)|0,e=e+Math.imul(p,U)|0,A=A+Math.imul(Z,Q)|0,i=(i=i+Math.imul(Z,O)|0)+Math.imul(b,Q)|0,e=e+Math.imul(b,O)|0,A=A+Math.imul(r,P)|0,i=(i=i+Math.imul(r,_)|0)+Math.imul(m,P)|0,e=e+Math.imul(m,_)|0;var ug=(o+(A=A+Math.imul(d,$)|0)|0)+((8191&(i=(i=i+Math.imul(d,gg)|0)+Math.imul(a,$)|0))<<13)|0;o=((e=e+Math.imul(a,gg)|0)+(i>>>13)|0)+(ug>>>26)|0,ug&=67108863,A=Math.imul(V,L),i=(i=Math.imul(V,z))+Math.imul(X,L)|0,e=Math.imul(X,z),A=A+Math.imul(W,x)|0,i=(i=i+Math.imul(W,U)|0)+Math.imul(B,x)|0,e=e+Math.imul(B,U)|0,A=A+Math.imul(u,Q)|0,i=(i=i+Math.imul(u,O)|0)+Math.imul(p,Q)|0,e=e+Math.imul(p,O)|0,A=A+Math.imul(Z,P)|0,i=(i=i+Math.imul(Z,_)|0)+Math.imul(b,P)|0,e=e+Math.imul(b,_)|0,A=A+Math.imul(r,$)|0,i=(i=i+Math.imul(r,gg)|0)+Math.imul(m,$)|0,e=e+Math.imul(m,gg)|0;var pg=(o+(A=A+Math.imul(d,Cg)|0)|0)+((8191&(i=(i=i+Math.imul(d,Ag)|0)+Math.imul(a,Cg)|0))<<13)|0;o=((e=e+Math.imul(a,Ag)|0)+(i>>>13)|0)+(pg>>>26)|0,pg&=67108863,A=Math.imul(R,L),i=(i=Math.imul(R,z))+Math.imul(N,L)|0,e=Math.imul(N,z),A=A+Math.imul(V,x)|0,i=(i=i+Math.imul(V,U)|0)+Math.imul(X,x)|0,e=e+Math.imul(X,U)|0,A=A+Math.imul(W,Q)|0,i=(i=i+Math.imul(W,O)|0)+Math.imul(B,Q)|0,e=e+Math.imul(B,O)|0,A=A+Math.imul(u,P)|0,i=(i=i+Math.imul(u,_)|0)+Math.imul(p,P)|0,e=e+Math.imul(p,_)|0,A=A+Math.imul(Z,$)|0,i=(i=i+Math.imul(Z,gg)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,gg)|0,A=A+Math.imul(r,Cg)|0,i=(i=i+Math.imul(r,Ag)|0)+Math.imul(m,Cg)|0,e=e+Math.imul(m,Ag)|0;var wg=(o+(A=A+Math.imul(d,eg)|0)|0)+((8191&(i=(i=i+Math.imul(d,tg)|0)+Math.imul(a,eg)|0))<<13)|0;o=((e=e+Math.imul(a,tg)|0)+(i>>>13)|0)+(wg>>>26)|0,wg&=67108863,A=Math.imul(K,L),i=(i=Math.imul(K,z))+Math.imul(f,L)|0,e=Math.imul(f,z),A=A+Math.imul(R,x)|0,i=(i=i+Math.imul(R,U)|0)+Math.imul(N,x)|0,e=e+Math.imul(N,U)|0,A=A+Math.imul(V,Q)|0,i=(i=i+Math.imul(V,O)|0)+Math.imul(X,Q)|0,e=e+Math.imul(X,O)|0,A=A+Math.imul(W,P)|0,i=(i=i+Math.imul(W,_)|0)+Math.imul(B,P)|0,e=e+Math.imul(B,_)|0,A=A+Math.imul(u,$)|0,i=(i=i+Math.imul(u,gg)|0)+Math.imul(p,$)|0,e=e+Math.imul(p,gg)|0,A=A+Math.imul(Z,Cg)|0,i=(i=i+Math.imul(Z,Ag)|0)+Math.imul(b,Cg)|0,e=e+Math.imul(b,Ag)|0,A=A+Math.imul(r,eg)|0,i=(i=i+Math.imul(r,tg)|0)+Math.imul(m,eg)|0,e=e+Math.imul(m,tg)|0;var Wg=(o+(A=A+Math.imul(d,sg)|0)|0)+((8191&(i=(i=i+Math.imul(d,og)|0)+Math.imul(a,sg)|0))<<13)|0;o=((e=e+Math.imul(a,og)|0)+(i>>>13)|0)+(Wg>>>26)|0,Wg&=67108863,A=Math.imul(M,L),i=(i=Math.imul(M,z))+Math.imul(S,L)|0,e=Math.imul(S,z),A=A+Math.imul(K,x)|0,i=(i=i+Math.imul(K,U)|0)+Math.imul(f,x)|0,e=e+Math.imul(f,U)|0,A=A+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,O)|0)+Math.imul(N,Q)|0,e=e+Math.imul(N,O)|0,A=A+Math.imul(V,P)|0,i=(i=i+Math.imul(V,_)|0)+Math.imul(X,P)|0,e=e+Math.imul(X,_)|0,A=A+Math.imul(W,$)|0,i=(i=i+Math.imul(W,gg)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,gg)|0,A=A+Math.imul(u,Cg)|0,i=(i=i+Math.imul(u,Ag)|0)+Math.imul(p,Cg)|0,e=e+Math.imul(p,Ag)|0,A=A+Math.imul(Z,eg)|0,i=(i=i+Math.imul(Z,tg)|0)+Math.imul(b,eg)|0,e=e+Math.imul(b,tg)|0,A=A+Math.imul(r,sg)|0,i=(i=i+Math.imul(r,og)|0)+Math.imul(m,sg)|0,e=e+Math.imul(m,og)|0;var Bg=(o+(A=A+Math.imul(d,dg)|0)|0)+((8191&(i=(i=i+Math.imul(d,ag)|0)+Math.imul(a,dg)|0))<<13)|0;o=((e=e+Math.imul(a,ag)|0)+(i>>>13)|0)+(Bg>>>26)|0,Bg&=67108863,A=Math.imul(k,L),i=(i=Math.imul(k,z))+Math.imul(D,L)|0,e=Math.imul(D,z),A=A+Math.imul(M,x)|0,i=(i=i+Math.imul(M,U)|0)+Math.imul(S,x)|0,e=e+Math.imul(S,U)|0,A=A+Math.imul(K,Q)|0,i=(i=i+Math.imul(K,O)|0)+Math.imul(f,Q)|0,e=e+Math.imul(f,O)|0,A=A+Math.imul(R,P)|0,i=(i=i+Math.imul(R,_)|0)+Math.imul(N,P)|0,e=e+Math.imul(N,_)|0,A=A+Math.imul(V,$)|0,i=(i=i+Math.imul(V,gg)|0)+Math.imul(X,$)|0,e=e+Math.imul(X,gg)|0,A=A+Math.imul(W,Cg)|0,i=(i=i+Math.imul(W,Ag)|0)+Math.imul(B,Cg)|0,e=e+Math.imul(B,Ag)|0,A=A+Math.imul(u,eg)|0,i=(i=i+Math.imul(u,tg)|0)+Math.imul(p,eg)|0,e=e+Math.imul(p,tg)|0,A=A+Math.imul(Z,sg)|0,i=(i=i+Math.imul(Z,og)|0)+Math.imul(b,sg)|0,e=e+Math.imul(b,og)|0,A=A+Math.imul(r,dg)|0,i=(i=i+Math.imul(r,ag)|0)+Math.imul(m,dg)|0,e=e+Math.imul(m,ag)|0;var yg=(o+(A=A+Math.imul(d,rg)|0)|0)+((8191&(i=(i=i+Math.imul(d,mg)|0)+Math.imul(a,rg)|0))<<13)|0;o=((e=e+Math.imul(a,mg)|0)+(i>>>13)|0)+(yg>>>26)|0,yg&=67108863,A=Math.imul(k,x),i=(i=Math.imul(k,U))+Math.imul(D,x)|0,e=Math.imul(D,U),A=A+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,O)|0)+Math.imul(S,Q)|0,e=e+Math.imul(S,O)|0,A=A+Math.imul(K,P)|0,i=(i=i+Math.imul(K,_)|0)+Math.imul(f,P)|0,e=e+Math.imul(f,_)|0,A=A+Math.imul(R,$)|0,i=(i=i+Math.imul(R,gg)|0)+Math.imul(N,$)|0,e=e+Math.imul(N,gg)|0,A=A+Math.imul(V,Cg)|0,i=(i=i+Math.imul(V,Ag)|0)+Math.imul(X,Cg)|0,e=e+Math.imul(X,Ag)|0,A=A+Math.imul(W,eg)|0,i=(i=i+Math.imul(W,tg)|0)+Math.imul(B,eg)|0,e=e+Math.imul(B,tg)|0,A=A+Math.imul(u,sg)|0,i=(i=i+Math.imul(u,og)|0)+Math.imul(p,sg)|0,e=e+Math.imul(p,og)|0,A=A+Math.imul(Z,dg)|0,i=(i=i+Math.imul(Z,ag)|0)+Math.imul(b,dg)|0,e=e+Math.imul(b,ag)|0;var Vg=(o+(A=A+Math.imul(r,rg)|0)|0)+((8191&(i=(i=i+Math.imul(r,mg)|0)+Math.imul(m,rg)|0))<<13)|0;o=((e=e+Math.imul(m,mg)|0)+(i>>>13)|0)+(Vg>>>26)|0,Vg&=67108863,A=Math.imul(k,Q),i=(i=Math.imul(k,O))+Math.imul(D,Q)|0,e=Math.imul(D,O),A=A+Math.imul(M,P)|0,i=(i=i+Math.imul(M,_)|0)+Math.imul(S,P)|0,e=e+Math.imul(S,_)|0,A=A+Math.imul(K,$)|0,i=(i=i+Math.imul(K,gg)|0)+Math.imul(f,$)|0,e=e+Math.imul(f,gg)|0,A=A+Math.imul(R,Cg)|0,i=(i=i+Math.imul(R,Ag)|0)+Math.imul(N,Cg)|0,e=e+Math.imul(N,Ag)|0,A=A+Math.imul(V,eg)|0,i=(i=i+Math.imul(V,tg)|0)+Math.imul(X,eg)|0,e=e+Math.imul(X,tg)|0,A=A+Math.imul(W,sg)|0,i=(i=i+Math.imul(W,og)|0)+Math.imul(B,sg)|0,e=e+Math.imul(B,og)|0,A=A+Math.imul(u,dg)|0,i=(i=i+Math.imul(u,ag)|0)+Math.imul(p,dg)|0,e=e+Math.imul(p,ag)|0;var Xg=(o+(A=A+Math.imul(Z,rg)|0)|0)+((8191&(i=(i=i+Math.imul(Z,mg)|0)+Math.imul(b,rg)|0))<<13)|0;o=((e=e+Math.imul(b,mg)|0)+(i>>>13)|0)+(Xg>>>26)|0,Xg&=67108863,A=Math.imul(k,P),i=(i=Math.imul(k,_))+Math.imul(D,P)|0,e=Math.imul(D,_),A=A+Math.imul(M,$)|0,i=(i=i+Math.imul(M,gg)|0)+Math.imul(S,$)|0,e=e+Math.imul(S,gg)|0,A=A+Math.imul(K,Cg)|0,i=(i=i+Math.imul(K,Ag)|0)+Math.imul(f,Cg)|0,e=e+Math.imul(f,Ag)|0,A=A+Math.imul(R,eg)|0,i=(i=i+Math.imul(R,tg)|0)+Math.imul(N,eg)|0,e=e+Math.imul(N,tg)|0,A=A+Math.imul(V,sg)|0,i=(i=i+Math.imul(V,og)|0)+Math.imul(X,sg)|0,e=e+Math.imul(X,og)|0,A=A+Math.imul(W,dg)|0,i=(i=i+Math.imul(W,ag)|0)+Math.imul(B,dg)|0,e=e+Math.imul(B,ag)|0;var Yg=(o+(A=A+Math.imul(u,rg)|0)|0)+((8191&(i=(i=i+Math.imul(u,mg)|0)+Math.imul(p,rg)|0))<<13)|0;o=((e=e+Math.imul(p,mg)|0)+(i>>>13)|0)+(Yg>>>26)|0,Yg&=67108863,A=Math.imul(k,$),i=(i=Math.imul(k,gg))+Math.imul(D,$)|0,e=Math.imul(D,gg),A=A+Math.imul(M,Cg)|0,i=(i=i+Math.imul(M,Ag)|0)+Math.imul(S,Cg)|0,e=e+Math.imul(S,Ag)|0,A=A+Math.imul(K,eg)|0,i=(i=i+Math.imul(K,tg)|0)+Math.imul(f,eg)|0,e=e+Math.imul(f,tg)|0,A=A+Math.imul(R,sg)|0,i=(i=i+Math.imul(R,og)|0)+Math.imul(N,sg)|0,e=e+Math.imul(N,og)|0,A=A+Math.imul(V,dg)|0,i=(i=i+Math.imul(V,ag)|0)+Math.imul(X,dg)|0,e=e+Math.imul(X,ag)|0;var Rg=(o+(A=A+Math.imul(W,rg)|0)|0)+((8191&(i=(i=i+Math.imul(W,mg)|0)+Math.imul(B,rg)|0))<<13)|0;o=((e=e+Math.imul(B,mg)|0)+(i>>>13)|0)+(Rg>>>26)|0,Rg&=67108863,A=Math.imul(k,Cg),i=(i=Math.imul(k,Ag))+Math.imul(D,Cg)|0,e=Math.imul(D,Ag),A=A+Math.imul(M,eg)|0,i=(i=i+Math.imul(M,tg)|0)+Math.imul(S,eg)|0,e=e+Math.imul(S,tg)|0,A=A+Math.imul(K,sg)|0,i=(i=i+Math.imul(K,og)|0)+Math.imul(f,sg)|0,e=e+Math.imul(f,og)|0,A=A+Math.imul(R,dg)|0,i=(i=i+Math.imul(R,ag)|0)+Math.imul(N,dg)|0,e=e+Math.imul(N,ag)|0;var Ng=(o+(A=A+Math.imul(V,rg)|0)|0)+((8191&(i=(i=i+Math.imul(V,mg)|0)+Math.imul(X,rg)|0))<<13)|0;o=((e=e+Math.imul(X,mg)|0)+(i>>>13)|0)+(Ng>>>26)|0,Ng&=67108863,A=Math.imul(k,eg),i=(i=Math.imul(k,tg))+Math.imul(D,eg)|0,e=Math.imul(D,tg),A=A+Math.imul(M,sg)|0,i=(i=i+Math.imul(M,og)|0)+Math.imul(S,sg)|0,e=e+Math.imul(S,og)|0,A=A+Math.imul(K,dg)|0,i=(i=i+Math.imul(K,ag)|0)+Math.imul(f,dg)|0,e=e+Math.imul(f,ag)|0;var Hg=(o+(A=A+Math.imul(R,rg)|0)|0)+((8191&(i=(i=i+Math.imul(R,mg)|0)+Math.imul(N,rg)|0))<<13)|0;o=((e=e+Math.imul(N,mg)|0)+(i>>>13)|0)+(Hg>>>26)|0,Hg&=67108863,A=Math.imul(k,sg),i=(i=Math.imul(k,og))+Math.imul(D,sg)|0,e=Math.imul(D,og),A=A+Math.imul(M,dg)|0,i=(i=i+Math.imul(M,ag)|0)+Math.imul(S,dg)|0,e=e+Math.imul(S,ag)|0;var Kg=(o+(A=A+Math.imul(K,rg)|0)|0)+((8191&(i=(i=i+Math.imul(K,mg)|0)+Math.imul(f,rg)|0))<<13)|0;o=((e=e+Math.imul(f,mg)|0)+(i>>>13)|0)+(Kg>>>26)|0,Kg&=67108863,A=Math.imul(k,dg),i=(i=Math.imul(k,ag))+Math.imul(D,dg)|0,e=Math.imul(D,ag);var fg=(o+(A=A+Math.imul(M,rg)|0)|0)+((8191&(i=(i=i+Math.imul(M,mg)|0)+Math.imul(S,rg)|0))<<13)|0;o=((e=e+Math.imul(S,mg)|0)+(i>>>13)|0)+(fg>>>26)|0,fg&=67108863;var Fg=(o+(A=Math.imul(k,rg))|0)+((8191&(i=(i=Math.imul(k,mg))+Math.imul(D,rg)|0))<<13)|0;return o=((e=Math.imul(D,mg))+(i>>>13)|0)+(Fg>>>26)|0,Fg&=67108863,s[0]=hg,s[1]=Zg,s[2]=bg,s[3]=Gg,s[4]=ug,s[5]=pg,s[6]=wg,s[7]=Wg,s[8]=Bg,s[9]=yg,s[10]=Vg,s[11]=Xg,s[12]=Yg,s[13]=Rg,s[14]=Ng,s[15]=Hg,s[16]=Kg,s[17]=fg,s[18]=Fg,0!==o&&(s[19]=o,C.length++),C};function G(g,I,C){C.negative=I.negative^g.negative,C.length=g.length+I.length;for(var A=0,i=0,e=0;e>>26)|0)>>>26,t&=67108863}C.words[e]=l,A=t,t=i}return 0!==A?C.words[e]=A:C.length--,C._strip()}function u(g,I,C){return G(g,I,C)}Math.imul||(b=Z),e.prototype.mulTo=function(g,I){var C=this.length+g.length;return 10===this.length&&10===g.length?b(this,g,I):C<63?Z(this,g,I):C<1024?G(this,g,I):u(this,g,I)},e.prototype.mul=function(g){var I=new e(null);return I.words=new Array(this.length+g.length),this.mulTo(g,I)},e.prototype.mulf=function(g){var I=new e(null);return I.words=new Array(this.length+g.length),u(this,g,I)},e.prototype.imul=function(g){return this.clone().mulTo(g,this)},e.prototype.imuln=function(g){var I=g<0;I&&(g=-g),A("number"==typeof g),A(g<67108864);for(var C=0,i=0;i>=26,C+=e/67108864|0,C+=t>>>26,this.words[i]=67108863&t}return 0!==C&&(this.words[i]=C,this.length++),I?this.ineg():this},e.prototype.muln=function(g){return this.clone().imuln(g)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(g){var I=h(g);if(0===I.length)return new e(1);for(var C=this,A=0;A=0);var I,C=g%26,i=(g-C)/26,e=67108863>>>26-C<<26-C;if(0!==C){var t=0;for(I=0;I>>26-C}t&&(this.words[I]=t,this.length++)}if(0!==i){for(I=this.length-1;I>=0;I--)this.words[I+i]=this.words[I];for(I=0;I=0),i=I?(I-I%26)/26:0;var e=g%26,t=Math.min((g-e)/26,this.length),l=67108863^67108863>>>e<t)for(this.length-=t,o=0;o=0&&(0!==c||o>=i);o--){var d=0|this.words[o];this.words[o]=c<<26-e|d>>>e,c=d&l}return s&&0!==c&&(s.words[s.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},e.prototype.ishrn=function(g,I,C){return A(0===this.negative),this.iushrn(g,I,C)},e.prototype.shln=function(g){return this.clone().ishln(g)},e.prototype.ushln=function(g){return this.clone().iushln(g)},e.prototype.shrn=function(g){return this.clone().ishrn(g)},e.prototype.ushrn=function(g){return this.clone().iushrn(g)},e.prototype.testn=function(g){A("number"==typeof g&&g>=0);var I=g%26,C=(g-I)/26,i=1<=0);var I=g%26,C=(g-I)/26;if(A(0===this.negative,"imaskn works only with positive numbers"),this.length<=C)return this;if(0!==I&&C++,this.length=Math.min(C,this.length),0!==I){var i=67108863^67108863>>>I<=67108864;I++)this.words[I]-=67108864,I===this.length-1?this.words[I+1]=1:this.words[I+1]++;return this.length=Math.max(this.length,I+1),this},e.prototype.isubn=function(g){if(A("number"==typeof g),A(g<67108864),g<0)return this.iaddn(-g);if(0!==this.negative)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var I=0;I>26)-(s/67108864|0),this.words[i+C]=67108863&e}for(;i>26,this.words[i+C]=67108863&e;if(0===l)return this._strip();for(A(-1===l),l=0,i=0;i>26,this.words[i]=67108863&e;return this.negative=1,this._strip()},e.prototype._wordDiv=function(g,I){var C=this.length-g.length,A=this.clone(),i=g,t=0|i.words[i.length-1];0!=(C=26-this._countBits(t))&&(i=i.ushln(C),A.iushln(C),t=0|i.words[i.length-1]);var l,s=A.length-i.length;if("mod"!==I){(l=new e(null)).length=s+1,l.words=new Array(l.length);for(var o=0;o=0;d--){var a=67108864*(0|A.words[i.length+d])+(0|A.words[i.length+d-1]);for(a=Math.min(a/t|0,67108863),A._ishlnsubmul(i,a,d);0!==A.negative;)a--,A.negative=0,A._ishlnsubmul(i,1,d),A.isZero()||(A.negative^=1);l&&(l.words[d]=a)}return l&&l._strip(),A._strip(),"div"!==I&&0!==C&&A.iushrn(C),{div:l||null,mod:A}},e.prototype.divmod=function(g,I,C){return A(!g.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===g.negative?(l=this.neg().divmod(g,I),"mod"!==I&&(i=l.div.neg()),"div"!==I&&(t=l.mod.neg(),C&&0!==t.negative&&t.iadd(g)),{div:i,mod:t}):0===this.negative&&0!==g.negative?(l=this.divmod(g.neg(),I),"mod"!==I&&(i=l.div.neg()),{div:i,mod:l.mod}):this.negative&g.negative?(l=this.neg().divmod(g.neg(),I),"div"!==I&&(t=l.mod.neg(),C&&0!==t.negative&&t.isub(g)),{div:l.div,mod:t}):g.length>this.length||this.cmp(g)<0?{div:new e(0),mod:this}:1===g.length?"div"===I?{div:this.divn(g.words[0]),mod:null}:"mod"===I?{div:null,mod:new e(this.modrn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new e(this.modrn(g.words[0]))}:this._wordDiv(g,I);var i,t,l},e.prototype.div=function(g){return this.divmod(g,"div",!1).div},e.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},e.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},e.prototype.divRound=function(g){var I=this.divmod(g);if(I.mod.isZero())return I.div;var C=0!==I.div.negative?I.mod.isub(g):I.mod,A=g.ushrn(1),i=g.andln(1),e=C.cmp(A);return e<0||1===i&&0===e?I.div:0!==I.div.negative?I.div.isubn(1):I.div.iaddn(1)},e.prototype.modrn=function(g){var I=g<0;I&&(g=-g),A(g<=67108863);for(var C=(1<<26)%g,i=0,e=this.length-1;e>=0;e--)i=(C*i+(0|this.words[e]))%g;return I?-i:i},e.prototype.modn=function(g){return this.modrn(g)},e.prototype.idivn=function(g){var I=g<0;I&&(g=-g),A(g<=67108863);for(var C=0,i=this.length-1;i>=0;i--){var e=(0|this.words[i])+67108864*C;this.words[i]=e/g|0,C=e%g}return this._strip(),I?this.ineg():this},e.prototype.divn=function(g){return this.clone().idivn(g)},e.prototype.egcd=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i=new e(1),t=new e(0),l=new e(0),s=new e(1),o=0;I.isEven()&&C.isEven();)I.iushrn(1),C.iushrn(1),++o;for(var c=C.clone(),d=I.clone();!I.isZero();){for(var a=0,n=1;!(I.words[0]&n)&&a<26;++a,n<<=1);if(a>0)for(I.iushrn(a);a-- >0;)(i.isOdd()||t.isOdd())&&(i.iadd(c),t.isub(d)),i.iushrn(1),t.iushrn(1);for(var r=0,m=1;!(C.words[0]&m)&&r<26;++r,m<<=1);if(r>0)for(C.iushrn(r);r-- >0;)(l.isOdd()||s.isOdd())&&(l.iadd(c),s.isub(d)),l.iushrn(1),s.iushrn(1);I.cmp(C)>=0?(I.isub(C),i.isub(l),t.isub(s)):(C.isub(I),l.isub(i),s.isub(t))}return{a:l,b:s,gcd:C.iushln(o)}},e.prototype._invmp=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i,t=new e(1),l=new e(0),s=C.clone();I.cmpn(1)>0&&C.cmpn(1)>0;){for(var o=0,c=1;!(I.words[0]&c)&&o<26;++o,c<<=1);if(o>0)for(I.iushrn(o);o-- >0;)t.isOdd()&&t.iadd(s),t.iushrn(1);for(var d=0,a=1;!(C.words[0]&a)&&d<26;++d,a<<=1);if(d>0)for(C.iushrn(d);d-- >0;)l.isOdd()&&l.iadd(s),l.iushrn(1);I.cmp(C)>=0?(I.isub(C),t.isub(l)):(C.isub(I),l.isub(t))}return(i=0===I.cmpn(1)?t:l).cmpn(0)<0&&i.iadd(g),i},e.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var I=this.clone(),C=g.clone();I.negative=0,C.negative=0;for(var A=0;I.isEven()&&C.isEven();A++)I.iushrn(1),C.iushrn(1);for(;;){for(;I.isEven();)I.iushrn(1);for(;C.isEven();)C.iushrn(1);var i=I.cmp(C);if(i<0){var e=I;I=C,C=e}else if(0===i||0===C.cmpn(1))break;I.isub(C)}return C.iushln(A)},e.prototype.invm=function(g){return this.egcd(g).a.umod(g)},e.prototype.isEven=function(){return!(1&this.words[0])},e.prototype.isOdd=function(){return!(1&~this.words[0])},e.prototype.andln=function(g){return this.words[0]&g},e.prototype.bincn=function(g){A("number"==typeof g);var I=g%26,C=(g-I)/26,i=1<>>26,l&=67108863,this.words[t]=l}return 0!==e&&(this.words[t]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(g){var I,C=g<0;if(0!==this.negative&&!C)return-1;if(0===this.negative&&C)return 1;if(this._strip(),this.length>1)I=1;else{C&&(g=-g),A(g<=67108863,"Number is too big");var i=0|this.words[0];I=i===g?0:ig.length)return 1;if(this.length=0;C--){var A=0|this.words[C],i=0|g.words[C];if(A!==i){Ai&&(I=1);break}}return I},e.prototype.gtn=function(g){return 1===this.cmpn(g)},e.prototype.gt=function(g){return 1===this.cmp(g)},e.prototype.gten=function(g){return this.cmpn(g)>=0},e.prototype.gte=function(g){return this.cmp(g)>=0},e.prototype.ltn=function(g){return-1===this.cmpn(g)},e.prototype.lt=function(g){return-1===this.cmp(g)},e.prototype.lten=function(g){return this.cmpn(g)<=0},e.prototype.lte=function(g){return this.cmp(g)<=0},e.prototype.eqn=function(g){return 0===this.cmpn(g)},e.prototype.eq=function(g){return 0===this.cmp(g)},e.red=function(g){return new X(g)},e.prototype.toRed=function(g){return A(!this.red,"Already a number in reduction context"),A(0===this.negative,"red works only with positives"),g.convertTo(this)._forceRed(g)},e.prototype.fromRed=function(){return A(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(g){return this.red=g,this},e.prototype.forceRed=function(g){return A(!this.red,"Already a number in reduction context"),this._forceRed(g)},e.prototype.redAdd=function(g){return A(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},e.prototype.redIAdd=function(g){return A(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},e.prototype.redSub=function(g){return A(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},e.prototype.redISub=function(g){return A(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},e.prototype.redShl=function(g){return A(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},e.prototype.redMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},e.prototype.redIMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},e.prototype.redSqr=function(){return A(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return A(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return A(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return A(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return A(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(g){return A(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var p={k256:null,p224:null,p192:null,p25519:null};function w(g,I){this.name=g,this.p=new e(I,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function W(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function B(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function y(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function V(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function X(g){if("string"==typeof g){var I=e._prime(g);this.m=I.p,this.prime=I}else A(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}function Y(g){X.call(this,g),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var g=new e(null);return g.words=new Array(Math.ceil(this.n/13)),g},w.prototype.ireduce=function(g){var I,C=g;do{this.split(C,this.tmp),I=(C=(C=this.imulK(C)).iadd(this.tmp)).bitLength()}while(I>this.n);var A=I0?C.isub(this.p):void 0!==C.strip?C.strip():C._strip(),C},w.prototype.split=function(g,I){g.iushrn(this.n,0,I)},w.prototype.imulK=function(g){return g.imul(this.k)},i(W,w),W.prototype.split=function(g,I){for(var C=4194303,A=Math.min(g.length,9),i=0;i>>22,e=t}e>>>=22,g.words[i-10]=e,0===e&&g.length>10?g.length-=10:g.length-=9},W.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var I=0,C=0;C>>=26,g.words[C]=i,I=A}return 0!==I&&(g.words[g.length++]=I),g},e._prime=function(g){if(p[g])return p[g];var I;if("k256"===g)I=new W;else if("p224"===g)I=new B;else if("p192"===g)I=new y;else{if("p25519"!==g)throw new Error("Unknown prime "+g);I=new V}return p[g]=I,I},X.prototype._verify1=function(g){A(0===g.negative,"red works only with positives"),A(g.red,"red works only with red numbers")},X.prototype._verify2=function(g,I){A(!(g.negative|I.negative),"red works only with positives"),A(g.red&&g.red===I.red,"red works only with red numbers")},X.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):(c(g,g.umod(this.m)._forceRed(this)),g)},X.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},X.prototype.add=function(g,I){this._verify2(g,I);var C=g.add(I);return C.cmp(this.m)>=0&&C.isub(this.m),C._forceRed(this)},X.prototype.iadd=function(g,I){this._verify2(g,I);var C=g.iadd(I);return C.cmp(this.m)>=0&&C.isub(this.m),C},X.prototype.sub=function(g,I){this._verify2(g,I);var C=g.sub(I);return C.cmpn(0)<0&&C.iadd(this.m),C._forceRed(this)},X.prototype.isub=function(g,I){this._verify2(g,I);var C=g.isub(I);return C.cmpn(0)<0&&C.iadd(this.m),C},X.prototype.shl=function(g,I){return this._verify1(g),this.imod(g.ushln(I))},X.prototype.imul=function(g,I){return this._verify2(g,I),this.imod(g.imul(I))},X.prototype.mul=function(g,I){return this._verify2(g,I),this.imod(g.mul(I))},X.prototype.isqr=function(g){return this.imul(g,g.clone())},X.prototype.sqr=function(g){return this.mul(g,g)},X.prototype.sqrt=function(g){if(g.isZero())return g.clone();var I=this.m.andln(3);if(A(I%2==1),3===I){var C=this.m.add(new e(1)).iushrn(2);return this.pow(g,C)}for(var i=this.m.subn(1),t=0;!i.isZero()&&0===i.andln(1);)t++,i.iushrn(1);A(!i.isZero());var l=new e(1).toRed(this),s=l.redNeg(),o=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new e(2*c*c).toRed(this);0!==this.pow(c,o).cmp(s);)c.redIAdd(s);for(var d=this.pow(c,i),a=this.pow(g,i.addn(1).iushrn(1)),n=this.pow(g,i),r=t;0!==n.cmp(l);){for(var m=n,h=0;0!==m.cmp(l);h++)m=m.redSqr();A(h=0;i--){for(var c=I.words[i],d=o-1;d>=0;d--){var a=c>>d&1;t!==A[0]&&(t=this.sqr(t)),0!==a||0!==l?(l<<=1,l|=a,(++s===C||0===i&&0===d)&&(t=this.mul(t,A[l]),s=0,l=0)):s=0}o=26}return t},X.prototype.convertTo=function(g){var I=g.umod(this.m);return I===g?I.clone():I},X.prototype.convertFrom=function(g){var I=g.clone();return I.red=null,I},e.mont=function(g){return new Y(g)},i(Y,X),Y.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},Y.prototype.convertFrom=function(g){var I=this.imod(g.mul(this.rinv));return I.red=null,I},Y.prototype.imul=function(g,I){if(g.isZero()||I.isZero())return g.words[0]=0,g.length=1,g;var C=g.imul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),e=i;return i.cmp(this.m)>=0?e=i.isub(this.m):i.cmpn(0)<0&&(e=i.iadd(this.m)),e._forceRed(this)},Y.prototype.mul=function(g,I){if(g.isZero()||I.isZero())return new e(0)._forceRed(this);var C=g.mul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),t=i;return i.cmp(this.m)>=0?t=i.isub(this.m):i.cmpn(0)<0&&(t=i.iadd(this.m)),t._forceRed(this)},Y.prototype.invm=function(g){return this.imod(g._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===I||I,void 0)},{buffer:188}],187:[function(g,I,C){var A;function i(g){this.rand=g}if(I.exports=function(g){return A||(A=new i(null)),A.generate(g)},I.exports.Rand=i,i.prototype.generate=function(g){return this._rand(g)},i.prototype._rand=function(g){if(this.rand.getBytes)return this.rand.getBytes(g);for(var I=new Uint8Array(g),C=0;C>>24]^c[r>>>16&255]^d[m>>>8&255]^a[255&h]^I[Z++],t=o[r>>>24]^c[m>>>16&255]^d[h>>>8&255]^a[255&n]^I[Z++],l=o[m>>>24]^c[h>>>16&255]^d[n>>>8&255]^a[255&r]^I[Z++],s=o[h>>>24]^c[n>>>16&255]^d[r>>>8&255]^a[255&m]^I[Z++],n=e,r=t,m=l,h=s;return e=(A[n>>>24]<<24|A[r>>>16&255]<<16|A[m>>>8&255]<<8|A[255&h])^I[Z++],t=(A[r>>>24]<<24|A[m>>>16&255]<<16|A[h>>>8&255]<<8|A[255&n])^I[Z++],l=(A[m>>>24]<<24|A[h>>>16&255]<<16|A[n>>>8&255]<<8|A[255&r])^I[Z++],s=(A[h>>>24]<<24|A[n>>>16&255]<<16|A[r>>>8&255]<<8|A[255&m])^I[Z++],[e>>>=0,t>>>=0,l>>>=0,s>>>=0]}var l=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var g=new Array(256),I=0;I<256;I++)g[I]=I<128?I<<1:I<<1^283;for(var C=[],A=[],i=[[],[],[],[]],e=[[],[],[],[]],t=0,l=0,s=0;s<256;++s){var o=l^l<<1^l<<2^l<<3^l<<4;o=o>>>8^255&o^99,C[t]=o,A[o]=t;var c=g[t],d=g[c],a=g[d],n=257*g[o]^16843008*o;i[0][t]=n<<24|n>>>8,i[1][t]=n<<16|n>>>16,i[2][t]=n<<8|n>>>24,i[3][t]=n,n=16843009*a^65537*d^257*c^16843008*t,e[0][o]=n<<24|n>>>8,e[1][o]=n<<16|n>>>16,e[2][o]=n<<8|n>>>24,e[3][o]=n,0===t?t=l=1:(t=c^g[g[g[a^c]]],l^=g[g[l]])}return{SBOX:C,INV_SBOX:A,SUB_MIX:i,INV_SUB_MIX:e}}();function o(g){this._key=i(g),this._reset()}o.blockSize=16,o.keySize=32,o.prototype.blockSize=o.blockSize,o.prototype.keySize=o.keySize,o.prototype._reset=function(){for(var g=this._key,I=g.length,C=I+6,A=4*(C+1),i=[],e=0;e>>24,t=s.SBOX[t>>>24]<<24|s.SBOX[t>>>16&255]<<16|s.SBOX[t>>>8&255]<<8|s.SBOX[255&t],t^=l[e/I|0]<<24):I>6&&e%I==4&&(t=s.SBOX[t>>>24]<<24|s.SBOX[t>>>16&255]<<16|s.SBOX[t>>>8&255]<<8|s.SBOX[255&t]),i[e]=i[e-I]^t}for(var o=[],c=0;c>>24]]^s.INV_SUB_MIX[1][s.SBOX[a>>>16&255]]^s.INV_SUB_MIX[2][s.SBOX[a>>>8&255]]^s.INV_SUB_MIX[3][s.SBOX[255&a]]}this._nRounds=C,this._keySchedule=i,this._invKeySchedule=o},o.prototype.encryptBlockRaw=function(g){return t(g=i(g),this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},o.prototype.encryptBlock=function(g){var I=this.encryptBlockRaw(g),C=A.allocUnsafe(16);return C.writeUInt32BE(I[0],0),C.writeUInt32BE(I[1],4),C.writeUInt32BE(I[2],8),C.writeUInt32BE(I[3],12),C},o.prototype.decryptBlock=function(g){var I=(g=i(g))[1];g[1]=g[3],g[3]=I;var C=t(g,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),e=A.allocUnsafe(16);return e.writeUInt32BE(C[0],0),e.writeUInt32BE(C[3],4),e.writeUInt32BE(C[2],8),e.writeUInt32BE(C[1],12),e},o.prototype.scrub=function(){e(this._keySchedule),e(this._invKeySchedule),e(this._key)},I.exports.AES=o},{"safe-buffer":494}],190:[function(g,I,C){var A=g("./aes"),i=g("safe-buffer").Buffer,e=g("cipher-base"),t=g("inherits"),l=g("./ghash"),s=g("buffer-xor"),o=g("./incr32");function c(g,I){var C=0;g.length!==I.length&&C++;for(var A=Math.min(g.length,I.length),i=0;i16)throw new Error("unable to decrypt data");for(var C=-1;++C16)return I=this.cache.slice(0,16),this.cache=this.cache.slice(16),I}else if(this.cache.length>=16)return I=this.cache.slice(0,16),this.cache=this.cache.slice(16),I;return null},d.prototype.flush=function(){if(this.cache.length)return this.cache},C.createDecipher=r,C.createDecipheriv=n},{"./aes":189,"./authCipher":190,"./modes":202,"./streamCipher":205,"cipher-base":221,evp_bytestokey:423,inherits:440,"safe-buffer":494}],193:[function(g,I,C){var A=g("./modes"),i=g("./authCipher"),e=g("safe-buffer").Buffer,t=g("./streamCipher"),l=g("cipher-base"),s=g("./aes"),o=g("evp_bytestokey");function c(g,I,C){l.call(this),this._cache=new a,this._cipher=new s.AES(I),this._prev=e.from(C),this._mode=g,this._autopadding=!0}g("inherits")(c,l),c.prototype._update=function(g){var I,C;this._cache.add(g);for(var A=[];I=this._cache.get();)C=this._mode.encrypt(this,I),A.push(C);return e.concat(A)};var d=e.alloc(16,16);function a(){this.cache=e.allocUnsafe(0)}function n(g,I,C){var l=A[g.toLowerCase()];if(!l)throw new TypeError("invalid suite type");if("string"==typeof I&&(I=e.from(I)),I.length!==l.key/8)throw new TypeError("invalid key length "+I.length);if("string"==typeof C&&(C=e.from(C)),"GCM"!==l.mode&&C.length!==l.iv)throw new TypeError("invalid iv length "+C.length);return"stream"===l.type?new t(l.module,I,C):"auth"===l.type?new i(l.module,I,C):new c(l.module,I,C)}function r(g,I){var C=A[g.toLowerCase()];if(!C)throw new TypeError("invalid suite type");var i=o(I,!1,C.key,C.iv);return n(g,i.key,i.iv)}c.prototype._final=function(){var g=this._cache.flush();if(this._autopadding)return g=this._mode.encrypt(this,g),this._cipher.scrub(),g;if(!g.equals(d))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(g){return this._autopadding=!!g,this},a.prototype.add=function(g){this.cache=e.concat([this.cache,g])},a.prototype.get=function(){if(this.cache.length>15){var g=this.cache.slice(0,16);return this.cache=this.cache.slice(16),g}return null},a.prototype.flush=function(){for(var g=16-this.cache.length,I=e.allocUnsafe(g),C=-1;++C>>0,0),I.writeUInt32BE(g[1]>>>0,4),I.writeUInt32BE(g[2]>>>0,8),I.writeUInt32BE(g[3]>>>0,12),I}function l(g){this.h=g,this.state=A.alloc(16,0),this.cache=A.allocUnsafe(0)}l.prototype.ghash=function(g){for(var I=-1;++I0;g--)C[g]=C[g]>>>1|(1&C[g-1])<<31;C[0]=C[0]>>>1,I&&(C[0]=C[0]^225<<24)}this.state=t(A)},l.prototype.update=function(g){var I;for(this.cache=A.concat([this.cache,g]);this.cache.length>=16;)I=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(I)},l.prototype.final=function(g,I){return this.cache.length&&this.ghash(A.concat([this.cache,i],16)),this.ghash(t([0,g,0,I])),this.state},I.exports=l},{"safe-buffer":494}],195:[function(g,I,C){function A(g){for(var I,C=g.length;C--;){if(255!==(I=g.readUInt8(C))){I++,g.writeUInt8(I,C);break}g.writeUInt8(0,C)}}I.exports=A},{}],196:[function(g,I,C){var A=g("buffer-xor");C.encrypt=function(g,I){var C=A(I,g._prev);return g._prev=g._cipher.encryptBlock(C),g._prev},C.decrypt=function(g,I){var C=g._prev;g._prev=I;var i=g._cipher.decryptBlock(I);return A(i,C)}},{"buffer-xor":219}],197:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("buffer-xor");function e(g,I,C){var e=I.length,t=i(I,g._cache);return g._cache=g._cache.slice(e),g._prev=A.concat([g._prev,C?I:t]),t}C.encrypt=function(g,I,C){for(var i,t=A.allocUnsafe(0);I.length;){if(0===g._cache.length&&(g._cache=g._cipher.encryptBlock(g._prev),g._prev=A.allocUnsafe(0)),!(g._cache.length<=I.length)){t=A.concat([t,e(g,I,C)]);break}i=g._cache.length,t=A.concat([t,e(g,I.slice(0,i),C)]),I=I.slice(i)}return t}},{"buffer-xor":219,"safe-buffer":494}],198:[function(g,I,C){var A=g("safe-buffer").Buffer;function i(g,I,C){for(var A,i,t=-1,l=8,s=0;++t>t%8,g._prev=e(g._prev,C?A:i);return s}function e(g,I){var C=g.length,i=-1,e=A.allocUnsafe(g.length);for(g=A.concat([g,A.from([I])]);++i>7;return e}C.encrypt=function(g,I,C){for(var e=I.length,t=A.allocUnsafe(e),l=-1;++l=0||!I.umod(g.prime1)||!I.umod(g.prime2));return I}function l(g,I){var i=e(I),t=I.modulus.byteLength(),l=new A(g).mul(i.blinder).umod(I.modulus),s=l.toRed(A.mont(I.prime1)),o=l.toRed(A.mont(I.prime2)),c=I.coefficient,d=I.prime1,a=I.prime2,n=s.redPow(I.exponent1).fromRed(),r=o.redPow(I.exponent2).fromRed(),m=n.isub(r).imul(c).umod(d).imul(a);return r.iadd(m).imul(i.unblinder).umod(I.modulus).toArrayLike(C,"be",t)}l.getr=t,I.exports=l}).call(this)}).call(this,g("buffer").Buffer)},{"bn.js":186,buffer:220,randombytes:475}],210:[function(g,I,C){I.exports=g("./browser/algorithms.json")},{"./browser/algorithms.json":211}],211:[function(g,I,C){I.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],212:[function(g,I,C){I.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],213:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("create-hash"),e=g("readable-stream"),t=g("inherits"),l=g("./sign"),s=g("./verify"),o=g("./algorithms.json");function c(g){e.Writable.call(this);var I=o[g];if(!I)throw new Error("Unknown message digest");this._hashType=I.hash,this._hash=i(I.hash),this._tag=I.id,this._signType=I.sign}function d(g){e.Writable.call(this);var I=o[g];if(!I)throw new Error("Unknown message digest");this._hash=i(I.hash),this._tag=I.id,this._signType=I.sign}function a(g){return new c(g)}function n(g){return new d(g)}Object.keys(o).forEach((function(g){o[g].id=A.from(o[g].id,"hex"),o[g.toLowerCase()]=o[g]})),t(c,e.Writable),c.prototype._write=function(g,I,C){this._hash.update(g),C()},c.prototype.update=function(g,I){return"string"==typeof g&&(g=A.from(g,I)),this._hash.update(g),this},c.prototype.sign=function(g,I){this.end();var C=this._hash.digest(),A=l(C,g,this._hashType,this._signType,this._tag);return I?A.toString(I):A},t(d,e.Writable),d.prototype._write=function(g,I,C){this._hash.update(g),C()},d.prototype.update=function(g,I){return"string"==typeof g&&(g=A.from(g,I)),this._hash.update(g),this},d.prototype.verify=function(g,I,C){"string"==typeof I&&(I=A.from(I,C)),this.end();var i=this._hash.digest();return s(I,i,g,this._signType,this._tag)},I.exports={Sign:a,Verify:n,createSign:a,createVerify:n}},{"./algorithms.json":211,"./sign":214,"./verify":215,"create-hash":386,inherits:440,"readable-stream":491,"safe-buffer":494}],214:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("create-hmac"),e=g("browserify-rsa"),t=g("elliptic").ec,l=g("bn.js"),s=g("parse-asn1"),o=g("./curves.json");function c(g,I,C,i,t){var l=s(I);if(l.curve){if("ecdsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong private key type");return d(g,l)}if("dsa"===l.type){if("dsa"!==i)throw new Error("wrong private key type");return a(g,l,C)}if("rsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong private key type");g=A.concat([t,g]);for(var o=l.modulus.byteLength(),c=[0,1];g.length+c.length+10&&C.ishrn(A),C}function h(g,I){g=(g=m(g,I)).mod(I);var C=A.from(g.toArray());if(C.length=I)throw new Error("invalid sig")}I.exports=s},{"./curves.json":212,"bn.js":186,elliptic:405,"parse-asn1":459,"safe-buffer":494}],216:[function(g,I,C){},{}],217:[function(g,I,C){var A=g("buffer"),i=A.Buffer;function e(g,I){for(var C in g)I[C]=g[C]}function t(g,I,C){return i(g,I,C)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?I.exports=A:(e(A,C),C.Buffer=t),e(i,t),t.from=function(g,I,C){if("number"==typeof g)throw new TypeError("Argument must not be a number");return i(g,I,C)},t.alloc=function(g,I,C){if("number"!=typeof g)throw new TypeError("Argument must be a number");var A=i(g);return void 0!==I?"string"==typeof C?A.fill(I,C):A.fill(I):A.fill(0),A},t.allocUnsafe=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return i(g)},t.allocUnsafeSlow=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return A.SlowBuffer(g)}},{buffer:220}],218:[function(g,I,C){var A=g("safe-buffer").Buffer,i=A.isEncoding||function(g){switch((g=""+g)&&g.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(g){if(!g)return"utf8";for(var I;;)switch(g){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return g;default:if(I)return;g=(""+g).toLowerCase(),I=!0}}function t(g){var I=e(g);if("string"!=typeof I&&(A.isEncoding===i||!i(g)))throw new Error("Unknown encoding: "+g);return I||g}function l(g){var I;switch(this.encoding=t(g),this.encoding){case"utf16le":this.text=r,this.end=m,I=4;break;case"utf8":this.fillLast=d,I=4;break;case"base64":this.text=h,this.end=Z,I=3;break;default:return this.write=b,void(this.end=G)}this.lastNeed=0,this.lastTotal=0,this.lastChar=A.allocUnsafe(I)}function s(g){return g<=127?0:g>>5==6?2:g>>4==14?3:g>>3==30?4:g>>6==2?-1:-2}function o(g,I,C){var A=I.length-1;if(A=0?(i>0&&(g.lastNeed=i-1),i):--A=0?(i>0&&(g.lastNeed=i-2),i):--A=0?(i>0&&(2===i?i=0:g.lastNeed=i-3),i):0}function c(g,I,C){if(128!=(192&I[0]))return g.lastNeed=0,"�";if(g.lastNeed>1&&I.length>1){if(128!=(192&I[1]))return g.lastNeed=1,"�";if(g.lastNeed>2&&I.length>2&&128!=(192&I[2]))return g.lastNeed=2,"�"}}function d(g){var I=this.lastTotal-this.lastNeed,C=c(this,g);return void 0!==C?C:this.lastNeed<=g.length?(g.copy(this.lastChar,I,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(g.copy(this.lastChar,I,0,g.length),void(this.lastNeed-=g.length))}function a(g,I){var C=o(this,g,I);if(!this.lastNeed)return g.toString("utf8",I);this.lastTotal=C;var A=g.length-(C-this.lastNeed);return g.copy(this.lastChar,0,A),g.toString("utf8",I,A)}function n(g){var I=g&&g.length?this.write(g):"";return this.lastNeed?I+"�":I}function r(g,I){if((g.length-I)%2==0){var C=g.toString("utf16le",I);if(C){var A=C.charCodeAt(C.length-1);if(A>=55296&&A<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1],C.slice(0,-1)}return C}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=g[g.length-1],g.toString("utf16le",I,g.length-1)}function m(g){var I=g&&g.length?this.write(g):"";if(this.lastNeed){var C=this.lastTotal-this.lastNeed;return I+this.lastChar.toString("utf16le",0,C)}return I}function h(g,I){var C=(g.length-I)%3;return 0===C?g.toString("base64",I):(this.lastNeed=3-C,this.lastTotal=3,1===C?this.lastChar[0]=g[g.length-1]:(this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1]),g.toString("base64",I,g.length-C))}function Z(g){var I=g&&g.length?this.write(g):"";return this.lastNeed?I+this.lastChar.toString("base64",0,3-this.lastNeed):I}function b(g){return g.toString(this.encoding)}function G(g){return g&&g.length?this.write(g):""}C.StringDecoder=l,l.prototype.write=function(g){if(0===g.length)return"";var I,C;if(this.lastNeed){if(void 0===(I=this.fillLast(g)))return"";C=this.lastNeed,this.lastNeed=0}else C=0;return Ci)throw new RangeError('The value "'+g+'" is invalid for option "size"');var I=new Uint8Array(g);return I.__proto__=l.prototype,I}function l(g,I,C){if("number"==typeof g){if("string"==typeof I)throw new TypeError('The "string" argument must be of type string. Received type number');return d(g)}return s(g,I,C)}function s(g,I,C){if("string"==typeof g)return a(g,I);if(ArrayBuffer.isView(g))return n(g);if(null==g)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g);if(P(g,ArrayBuffer)||g&&P(g.buffer,ArrayBuffer))return r(g,I,C);if("number"==typeof g)throw new TypeError('The "value" argument must not be of type number. Received type number');var A=g.valueOf&&g.valueOf();if(null!=A&&A!==g)return l.from(A,I,C);var i=m(g);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof g[Symbol.toPrimitive])return l.from(g[Symbol.toPrimitive]("string"),I,C);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g)}function o(g){if("number"!=typeof g)throw new TypeError('"size" argument must be of type number');if(g<0)throw new RangeError('The value "'+g+'" is invalid for option "size"')}function c(g,I,C){return o(g),g<=0?t(g):void 0!==I?"string"==typeof C?t(g).fill(I,C):t(g).fill(I):t(g)}function d(g){return o(g),t(g<0?0:0|h(g))}function a(g,I){if("string"==typeof I&&""!==I||(I="utf8"),!l.isEncoding(I))throw new TypeError("Unknown encoding: "+I);var C=0|b(g,I),A=t(C),i=A.write(g,I);return i!==C&&(A=A.slice(0,i)),A}function n(g){for(var I=g.length<0?0:0|h(g.length),C=t(I),A=0;A=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|g}function Z(g){return+g!=g&&(g=0),l.alloc(+g)}function b(g,I){if(l.isBuffer(g))return g.length;if(ArrayBuffer.isView(g)||P(g,ArrayBuffer))return g.byteLength;if("string"!=typeof g)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof g);var C=g.length,A=arguments.length>2&&!0===arguments[2];if(!A&&0===C)return 0;for(var i=!1;;)switch(I){case"ascii":case"latin1":case"binary":return C;case"utf8":case"utf-8":return U(g).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*C;case"hex":return C>>>1;case"base64":return O(g).length;default:if(i)return A?-1:U(g).length;I=(""+I).toLowerCase(),i=!0}}function G(g,I,C){var A=!1;if((void 0===I||I<0)&&(I=0),I>this.length)return"";if((void 0===C||C>this.length)&&(C=this.length),C<=0)return"";if((C>>>=0)<=(I>>>=0))return"";for(g||(g="utf8");;)switch(g){case"hex":return M(this,I,C);case"utf8":case"utf-8":return N(this,I,C);case"ascii":return f(this,I,C);case"latin1":case"binary":return F(this,I,C);case"base64":return R(this,I,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,I,C);default:if(A)throw new TypeError("Unknown encoding: "+g);g=(g+"").toLowerCase(),A=!0}}function u(g,I,C){var A=g[I];g[I]=g[C],g[C]=A}function p(g,I,C,A,i){if(0===g.length)return-1;if("string"==typeof C?(A=C,C=0):C>2147483647?C=2147483647:C<-2147483648&&(C=-2147483648),_(C=+C)&&(C=i?0:g.length-1),C<0&&(C=g.length+C),C>=g.length){if(i)return-1;C=g.length-1}else if(C<0){if(!i)return-1;C=0}if("string"==typeof I&&(I=l.from(I,A)),l.isBuffer(I))return 0===I.length?-1:w(g,I,C,A,i);if("number"==typeof I)return I&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(g,I,C):Uint8Array.prototype.lastIndexOf.call(g,I,C):w(g,[I],C,A,i);throw new TypeError("val must be string, number or Buffer")}function w(g,I,C,A,i){var e,t=1,l=g.length,s=I.length;if(void 0!==A&&("ucs2"===(A=String(A).toLowerCase())||"ucs-2"===A||"utf16le"===A||"utf-16le"===A)){if(g.length<2||I.length<2)return-1;t=2,l/=2,s/=2,C/=2}function o(g,I){return 1===t?g[I]:g.readUInt16BE(I*t)}if(i){var c=-1;for(e=C;el&&(C=l-s),e=C;e>=0;e--){for(var d=!0,a=0;ai&&(A=i):A=i;var e=I.length;A>e/2&&(A=e/2);for(var t=0;t239?4:o>223?3:o>191?2:1;if(i+d<=C)switch(d){case 1:o<128&&(c=o);break;case 2:128==(192&(e=g[i+1]))&&(s=(31&o)<<6|63&e)>127&&(c=s);break;case 3:e=g[i+1],t=g[i+2],128==(192&e)&&128==(192&t)&&(s=(15&o)<<12|(63&e)<<6|63&t)>2047&&(s<55296||s>57343)&&(c=s);break;case 4:e=g[i+1],t=g[i+2],l=g[i+3],128==(192&e)&&128==(192&t)&&128==(192&l)&&(s=(15&o)<<18|(63&e)<<12|(63&t)<<6|63&l)>65535&&s<1114112&&(c=s)}null===c?(c=65533,d=1):c>65535&&(c-=65536,A.push(c>>>10&1023|55296),c=56320|1023&c),A.push(c),i+=d}return K(A)}C.kMaxLength=i,l.TYPED_ARRAY_SUPPORT=e(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),l.poolSize=8192,l.from=function(g,I,C){return s(g,I,C)},l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,l.alloc=function(g,I,C){return c(g,I,C)},l.allocUnsafe=function(g){return d(g)},l.allocUnsafeSlow=function(g){return d(g)},l.isBuffer=function(g){return null!=g&&!0===g._isBuffer&&g!==l.prototype},l.compare=function(g,I){if(P(g,Uint8Array)&&(g=l.from(g,g.offset,g.byteLength)),P(I,Uint8Array)&&(I=l.from(I,I.offset,I.byteLength)),!l.isBuffer(g)||!l.isBuffer(I))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===I)return 0;for(var C=g.length,A=I.length,i=0,e=Math.min(C,A);iI&&(g+=" ... "),""},l.prototype.compare=function(g,I,C,A,i){if(P(g,Uint8Array)&&(g=l.from(g,g.offset,g.byteLength)),!l.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(void 0===I&&(I=0),void 0===C&&(C=g?g.length:0),void 0===A&&(A=0),void 0===i&&(i=this.length),I<0||C>g.length||A<0||i>this.length)throw new RangeError("out of range index");if(A>=i&&I>=C)return 0;if(A>=i)return-1;if(I>=C)return 1;if(this===g)return 0;for(var e=(i>>>=0)-(A>>>=0),t=(C>>>=0)-(I>>>=0),s=Math.min(e,t),o=this.slice(A,i),c=g.slice(I,C),d=0;d>>=0,isFinite(C)?(C>>>=0,void 0===A&&(A="utf8")):(A=C,C=void 0)}var i=this.length-I;if((void 0===C||C>i)&&(C=i),g.length>0&&(C<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");for(var e=!1;;)switch(A){case"hex":return W(this,g,I,C);case"utf8":case"utf-8":return B(this,g,I,C);case"ascii":return y(this,g,I,C);case"latin1":case"binary":return V(this,g,I,C);case"base64":return X(this,g,I,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,g,I,C);default:if(e)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),e=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var H=4096;function K(g){var I=g.length;if(I<=H)return String.fromCharCode.apply(String,g);for(var C="",A=0;AA)&&(C=A);for(var i="",e=I;eC)throw new RangeError("Trying to access beyond buffer length")}function k(g,I,C,A,i,e){if(!l.isBuffer(g))throw new TypeError('"buffer" argument must be a Buffer instance');if(I>i||Ig.length)throw new RangeError("Index out of range")}function D(g,I,C,A,i,e){if(C+A>g.length)throw new RangeError("Index out of range");if(C<0)throw new RangeError("Index out of range")}function v(g,I,C,i,e){return I=+I,C>>>=0,e||D(g,I,C,4),A.write(g,I,C,i,23,4),C+4}function L(g,I,C,i,e){return I=+I,C>>>=0,e||D(g,I,C,8),A.write(g,I,C,i,52,8),C+8}l.prototype.slice=function(g,I){var C=this.length;(g=~~g)<0?(g+=C)<0&&(g=0):g>C&&(g=C),(I=void 0===I?C:~~I)<0?(I+=C)<0&&(I=0):I>C&&(I=C),I>>=0,I>>>=0,C||J(g,I,this.length);for(var A=this[g],i=1,e=0;++e>>=0,I>>>=0,C||J(g,I,this.length);for(var A=this[g+--I],i=1;I>0&&(i*=256);)A+=this[g+--I]*i;return A},l.prototype.readUInt8=function(g,I){return g>>>=0,I||J(g,1,this.length),this[g]},l.prototype.readUInt16LE=function(g,I){return g>>>=0,I||J(g,2,this.length),this[g]|this[g+1]<<8},l.prototype.readUInt16BE=function(g,I){return g>>>=0,I||J(g,2,this.length),this[g]<<8|this[g+1]},l.prototype.readUInt32LE=function(g,I){return g>>>=0,I||J(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+16777216*this[g+3]},l.prototype.readUInt32BE=function(g,I){return g>>>=0,I||J(g,4,this.length),16777216*this[g]+(this[g+1]<<16|this[g+2]<<8|this[g+3])},l.prototype.readIntLE=function(g,I,C){g>>>=0,I>>>=0,C||J(g,I,this.length);for(var A=this[g],i=1,e=0;++e=(i*=128)&&(A-=Math.pow(2,8*I)),A},l.prototype.readIntBE=function(g,I,C){g>>>=0,I>>>=0,C||J(g,I,this.length);for(var A=I,i=1,e=this[g+--A];A>0&&(i*=256);)e+=this[g+--A]*i;return e>=(i*=128)&&(e-=Math.pow(2,8*I)),e},l.prototype.readInt8=function(g,I){return g>>>=0,I||J(g,1,this.length),128&this[g]?-1*(255-this[g]+1):this[g]},l.prototype.readInt16LE=function(g,I){g>>>=0,I||J(g,2,this.length);var C=this[g]|this[g+1]<<8;return 32768&C?4294901760|C:C},l.prototype.readInt16BE=function(g,I){g>>>=0,I||J(g,2,this.length);var C=this[g+1]|this[g]<<8;return 32768&C?4294901760|C:C},l.prototype.readInt32LE=function(g,I){return g>>>=0,I||J(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},l.prototype.readInt32BE=function(g,I){return g>>>=0,I||J(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},l.prototype.readFloatLE=function(g,I){return g>>>=0,I||J(g,4,this.length),A.read(this,g,!0,23,4)},l.prototype.readFloatBE=function(g,I){return g>>>=0,I||J(g,4,this.length),A.read(this,g,!1,23,4)},l.prototype.readDoubleLE=function(g,I){return g>>>=0,I||J(g,8,this.length),A.read(this,g,!0,52,8)},l.prototype.readDoubleBE=function(g,I){return g>>>=0,I||J(g,8,this.length),A.read(this,g,!1,52,8)},l.prototype.writeUIntLE=function(g,I,C,A){g=+g,I>>>=0,C>>>=0,A||k(this,g,I,C,Math.pow(2,8*C)-1,0);var i=1,e=0;for(this[I]=255&g;++e>>=0,C>>>=0,A||k(this,g,I,C,Math.pow(2,8*C)-1,0);var i=C-1,e=1;for(this[I+i]=255&g;--i>=0&&(e*=256);)this[I+i]=g/e&255;return I+C},l.prototype.writeUInt8=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,1,255,0),this[I]=255&g,I+1},l.prototype.writeUInt16LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,65535,0),this[I]=255&g,this[I+1]=g>>>8,I+2},l.prototype.writeUInt16BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,65535,0),this[I]=g>>>8,this[I+1]=255&g,I+2},l.prototype.writeUInt32LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,4294967295,0),this[I+3]=g>>>24,this[I+2]=g>>>16,this[I+1]=g>>>8,this[I]=255&g,I+4},l.prototype.writeUInt32BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,4294967295,0),this[I]=g>>>24,this[I+1]=g>>>16,this[I+2]=g>>>8,this[I+3]=255&g,I+4},l.prototype.writeIntLE=function(g,I,C,A){if(g=+g,I>>>=0,!A){var i=Math.pow(2,8*C-1);k(this,g,I,C,i-1,-i)}var e=0,t=1,l=0;for(this[I]=255&g;++e>>=0,!A){var i=Math.pow(2,8*C-1);k(this,g,I,C,i-1,-i)}var e=C-1,t=1,l=0;for(this[I+e]=255&g;--e>=0&&(t*=256);)g<0&&0===l&&0!==this[I+e+1]&&(l=1),this[I+e]=(g/t|0)-l&255;return I+C},l.prototype.writeInt8=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,1,127,-128),g<0&&(g=255+g+1),this[I]=255&g,I+1},l.prototype.writeInt16LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,32767,-32768),this[I]=255&g,this[I+1]=g>>>8,I+2},l.prototype.writeInt16BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,32767,-32768),this[I]=g>>>8,this[I+1]=255&g,I+2},l.prototype.writeInt32LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,2147483647,-2147483648),this[I]=255&g,this[I+1]=g>>>8,this[I+2]=g>>>16,this[I+3]=g>>>24,I+4},l.prototype.writeInt32BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,2147483647,-2147483648),g<0&&(g=4294967295+g+1),this[I]=g>>>24,this[I+1]=g>>>16,this[I+2]=g>>>8,this[I+3]=255&g,I+4},l.prototype.writeFloatLE=function(g,I,C){return v(this,g,I,!0,C)},l.prototype.writeFloatBE=function(g,I,C){return v(this,g,I,!1,C)},l.prototype.writeDoubleLE=function(g,I,C){return L(this,g,I,!0,C)},l.prototype.writeDoubleBE=function(g,I,C){return L(this,g,I,!1,C)},l.prototype.copy=function(g,I,C,A){if(!l.isBuffer(g))throw new TypeError("argument should be a Buffer");if(C||(C=0),A||0===A||(A=this.length),I>=g.length&&(I=g.length),I||(I=0),A>0&&A=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),g.length-I=0;--e)g[e+I]=this[e+C];else Uint8Array.prototype.set.call(g,this.subarray(C,A),I);return i},l.prototype.fill=function(g,I,C,A){if("string"==typeof g){if("string"==typeof I?(A=I,I=0,C=this.length):"string"==typeof C&&(A=C,C=this.length),void 0!==A&&"string"!=typeof A)throw new TypeError("encoding must be a string");if("string"==typeof A&&!l.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(1===g.length){var i=g.charCodeAt(0);("utf8"===A&&i<128||"latin1"===A)&&(g=i)}}else"number"==typeof g&&(g&=255);if(I<0||this.length>>=0,C=void 0===C?this.length:C>>>0,g||(g=0),"number"==typeof g)for(e=I;e55295&&C<57344){if(!i){if(C>56319){(I-=3)>-1&&e.push(239,191,189);continue}if(t+1===A){(I-=3)>-1&&e.push(239,191,189);continue}i=C;continue}if(C<56320){(I-=3)>-1&&e.push(239,191,189),i=C;continue}C=65536+(i-55296<<10|C-56320)}else i&&(I-=3)>-1&&e.push(239,191,189);if(i=null,C<128){if((I-=1)<0)break;e.push(C)}else if(C<2048){if((I-=2)<0)break;e.push(C>>6|192,63&C|128)}else if(C<65536){if((I-=3)<0)break;e.push(C>>12|224,C>>6&63|128,63&C|128)}else{if(!(C<1114112))throw new Error("Invalid code point");if((I-=4)<0)break;e.push(C>>18|240,C>>12&63|128,C>>6&63|128,63&C|128)}}return e}function j(g){for(var I=[],C=0;C>8,i=C%256,e.push(i),e.push(A);return e}function O(g){return I.toByteArray(T(g))}function E(g,I,C,A){for(var i=0;i=I.length||i>=g.length);++i)I[i+C]=g[i];return i}function P(g,I){return g instanceof I||null!=g&&null!=g.constructor&&null!=g.constructor.name&&g.constructor.name===I.name}function _(g){return g!=g}}).call(this)}).call(this,g("buffer").Buffer)},{"base64-js":185,buffer:220,ieee754:439}],221:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("stream").Transform,e=g("string_decoder").StringDecoder;function t(g){i.call(this),this.hashMode="string"==typeof g,this.hashMode?this[g]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}g("inherits")(t,i),t.prototype.update=function(g,I,C){"string"==typeof g&&(g=A.from(g,I));var i=this._update(g);return this.hashMode?this:(C&&(i=this._toString(i,C)),i)},t.prototype.setAutoPadding=function(){},t.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},t.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},t.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},t.prototype._transform=function(g,I,C){var A;try{this.hashMode?this._update(g):this.push(this._update(g))}catch(i){A=i}finally{C(A)}},t.prototype._flush=function(g){var I;try{this.push(this.__final())}catch(C){I=C}g(I)},t.prototype._finalOrDigest=function(g){var I=this.__final()||A.alloc(0);return g&&(I=this._toString(I,g,!0)),I},t.prototype._toString=function(g,I,C){if(this._decoder||(this._decoder=new e(I),this._encoding=I),this._encoding!==I)throw new Error("can't switch encodings");var A=this._decoder.write(g);return C&&(A+=this._decoder.end()),A},I.exports=t},{inherits:440,"safe-buffer":494,stream:505,string_decoder:218}],222:[function(g,I,C){var A=g("../internals/is-callable"),i=g("../internals/try-to-string"),e=TypeError;I.exports=function(g){if(A(g))return g;throw new e(i(g)+" is not a function")}},{"../internals/is-callable":285,"../internals/try-to-string":349}],223:[function(g,I,C){var A=g("../internals/is-constructor"),i=g("../internals/try-to-string"),e=TypeError;I.exports=function(g){if(A(g))return g;throw new e(i(g)+" is not a constructor")}},{"../internals/is-constructor":286,"../internals/try-to-string":349}],224:[function(g,I,C){var A=g("../internals/is-callable"),i=String,e=TypeError;I.exports=function(g){if("object"==typeof g||A(g))return g;throw new e("Can't set "+i(g)+" as a prototype")}},{"../internals/is-callable":285}],225:[function(g,I,C){var A=g("../internals/well-known-symbol"),i=g("../internals/object-create"),e=g("../internals/object-define-property").f,t=A("unscopables"),l=Array.prototype;void 0===l[t]&&e(l,t,{configurable:!0,value:i(null)}),I.exports=function(g){l[t][g]=!0}},{"../internals/object-create":306,"../internals/object-define-property":308,"../internals/well-known-symbol":357}],226:[function(g,I,C){var A=g("../internals/object-is-prototype-of"),i=TypeError;I.exports=function(g,I){if(A(I,g))return g;throw new i("Incorrect invocation")}},{"../internals/object-is-prototype-of":314}],227:[function(g,I,C){var A=g("../internals/is-object"),i=String,e=TypeError;I.exports=function(g){if(A(g))return g;throw new e(i(g)+" is not an object")}},{"../internals/is-object":289}],228:[function(g,I,C){var A=g("../internals/to-indexed-object"),i=g("../internals/to-absolute-index"),e=g("../internals/length-of-array-like"),t=function(g){return function(I,C,t){var l,s=A(I),o=e(s),c=i(t,o);if(g&&C!=C){for(;o>c;)if((l=s[c++])!=l)return!0}else for(;o>c;c++)if((g||c in s)&&s[c]===C)return g||c||0;return!g&&-1}};I.exports={includes:t(!0),indexOf:t(!1)}},{"../internals/length-of-array-like":299,"../internals/to-absolute-index":340,"../internals/to-indexed-object":341}],229:[function(g,I,C){var A=g("../internals/function-bind-context"),i=g("../internals/function-uncurry-this"),e=g("../internals/indexed-object"),t=g("../internals/to-object"),l=g("../internals/length-of-array-like"),s=g("../internals/array-species-create"),o=i([].push),c=function(g){var I=1===g,C=2===g,i=3===g,c=4===g,d=6===g,a=7===g,n=5===g||d;return function(r,m,h,Z){for(var b,G,u=t(r),p=e(u),w=A(m,h),W=l(p),B=0,y=Z||s,V=I?y(r,W):C||a?y(r,0):void 0;W>B;B++)if((n||B in p)&&(G=w(b=p[B],B,u),g))if(I)V[B]=G;else if(G)switch(g){case 3:return!0;case 5:return b;case 6:return B;case 2:o(V,b)}else switch(g){case 4:return!1;case 7:o(V,b)}return d?-1:i||c?c:V}};I.exports={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6),filterReject:c(7)}},{"../internals/array-species-create":233,"../internals/function-bind-context":262,"../internals/function-uncurry-this":268,"../internals/indexed-object":280,"../internals/length-of-array-like":299,"../internals/to-object":344}],230:[function(g,I,C){var A=g("../internals/to-absolute-index"),i=g("../internals/length-of-array-like"),e=g("../internals/create-property"),t=Array,l=Math.max;I.exports=function(g,I,C){for(var s=i(g),o=A(I,s),c=A(void 0===C?s:C,s),d=t(l(c-o,0)),a=0;o0&&A[0]<4?1:+(A[0]+A[1])),!i&&t&&(!(A=t.match(/Edge\/(\d+)/))||A[1]>=74)&&(A=t.match(/Chrome\/(\d+)/))&&(i=+A[1]),I.exports=i},{"../internals/engine-user-agent":256,"../internals/global":274}],258:[function(g,I,C){I.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},{}],259:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/object-get-own-property-descriptor").f,e=g("../internals/create-non-enumerable-property"),t=g("../internals/define-built-in"),l=g("../internals/define-global-property"),s=g("../internals/copy-constructor-properties"),o=g("../internals/is-forced");I.exports=function(g,I){var C,c,d,a,n,r=g.target,m=g.global,h=g.stat;if(C=m?A:h?A[r]||l(r,{}):(A[r]||{}).prototype)for(c in I){if(a=I[c],d=g.dontCallGetSet?(n=i(C,c))&&n.value:C[c],!o(m?c:r+(h?".":"#")+c,g.forced)&&void 0!==d){if(typeof a==typeof d)continue;s(a,d)}(g.sham||d&&d.sham)&&e(a,"sham",!0),t(C,c,a,g)}}},{"../internals/copy-constructor-properties":237,"../internals/create-non-enumerable-property":241,"../internals/define-built-in":245,"../internals/define-global-property":246,"../internals/global":274,"../internals/is-forced":287,"../internals/object-get-own-property-descriptor":309}],260:[function(g,I,C){I.exports=function(g){try{return!!g()}catch(I){return!0}}},{}],261:[function(g,I,C){var A=g("../internals/function-bind-native"),i=Function.prototype,e=i.apply,t=i.call;I.exports="object"==typeof Reflect&&Reflect.apply||(A?t.bind(e):function(){return t.apply(e,arguments)})},{"../internals/function-bind-native":263}],262:[function(g,I,C){var A=g("../internals/function-uncurry-this-clause"),i=g("../internals/a-callable"),e=g("../internals/function-bind-native"),t=A(A.bind);I.exports=function(g,I){return i(g),void 0===I?g:e?t(g,I):function(){return g.apply(I,arguments)}}},{"../internals/a-callable":222,"../internals/function-bind-native":263,"../internals/function-uncurry-this-clause":267}],263:[function(g,I,C){var A=g("../internals/fails");I.exports=!A((function(){var g=function(){}.bind();return"function"!=typeof g||g.hasOwnProperty("prototype")}))},{"../internals/fails":260}],264:[function(g,I,C){var A=g("../internals/function-bind-native"),i=Function.prototype.call;I.exports=A?i.bind(i):function(){return i.apply(i,arguments)}},{"../internals/function-bind-native":263}],265:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/has-own-property"),e=Function.prototype,t=A&&Object.getOwnPropertyDescriptor,l=i(e,"name"),s=l&&"something"===function(){}.name,o=l&&(!A||A&&t(e,"name").configurable);I.exports={EXISTS:l,PROPER:s,CONFIGURABLE:o}},{"../internals/descriptors":247,"../internals/has-own-property":275}],266:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/a-callable");I.exports=function(g,I,C){try{return A(i(Object.getOwnPropertyDescriptor(g,I)[C]))}catch(e){}}},{"../internals/a-callable":222,"../internals/function-uncurry-this":268}],267:[function(g,I,C){var A=g("../internals/classof-raw"),i=g("../internals/function-uncurry-this");I.exports=function(g){if("Function"===A(g))return i(g)}},{"../internals/classof-raw":235,"../internals/function-uncurry-this":268}],268:[function(g,I,C){var A=g("../internals/function-bind-native"),i=Function.prototype,e=i.call,t=A&&i.bind.bind(e,e);I.exports=A?t:function(g){return function(){return e.apply(g,arguments)}}},{"../internals/function-bind-native":263}],269:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/is-callable"),e=function(g){return i(g)?g:void 0};I.exports=function(g,I){return arguments.length<2?e(A[g]):A[g]&&A[g][I]}},{"../internals/global":274,"../internals/is-callable":285}],270:[function(g,I,C){var A=g("../internals/classof"),i=g("../internals/get-method"),e=g("../internals/is-null-or-undefined"),t=g("../internals/iterators"),l=g("../internals/well-known-symbol")("iterator");I.exports=function(g){if(!e(g))return i(g,l)||i(g,"@@iterator")||t[A(g)]}},{"../internals/classof":236,"../internals/get-method":273,"../internals/is-null-or-undefined":288,"../internals/iterators":298,"../internals/well-known-symbol":357}],271:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/a-callable"),e=g("../internals/an-object"),t=g("../internals/try-to-string"),l=g("../internals/get-iterator-method"),s=TypeError;I.exports=function(g,I){var C=arguments.length<2?l(g):I;if(i(C))return e(A(C,g));throw new s(t(g)+" is not iterable")}},{"../internals/a-callable":222,"../internals/an-object":227,"../internals/function-call":264,"../internals/get-iterator-method":270,"../internals/try-to-string":349}],272:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/is-array"),e=g("../internals/is-callable"),t=g("../internals/classof-raw"),l=g("../internals/to-string"),s=A([].push);I.exports=function(g){if(e(g))return g;if(i(g)){for(var I=g.length,C=[],A=0;Ab;b++)if((u=N(g[b]))&&o(m,u))return u;return new r(!1)}h=c(g,Z)}for(p=y?g.next:h.next;!(w=i(p,h)).done;){try{u=N(w.value)}catch(H){a(h,"throw",H)}if("object"==typeof u&&u&&o(m,u))return u}return new r(!1)}},{"../internals/an-object":227,"../internals/function-bind-context":262,"../internals/function-call":264,"../internals/get-iterator":271,"../internals/get-iterator-method":270,"../internals/is-array-iterator-method":283,"../internals/iterator-close":294,"../internals/length-of-array-like":299,"../internals/object-is-prototype-of":314,"../internals/try-to-string":349}],294:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/an-object"),e=g("../internals/get-method");I.exports=function(g,I,C){var t,l;i(g);try{if(!(t=e(g,"return"))){if("throw"===I)throw C;return C}t=A(t,g)}catch(s){l=!0,t=s}if("throw"===I)throw C;if(l)throw t;return i(t),C}},{"../internals/an-object":227,"../internals/function-call":264,"../internals/get-method":273}],295:[function(g,I,C){var A=g("../internals/iterators-core").IteratorPrototype,i=g("../internals/object-create"),e=g("../internals/create-property-descriptor"),t=g("../internals/set-to-string-tag"),l=g("../internals/iterators"),s=function(){return this};I.exports=function(g,I,C,o){var c=I+" Iterator";return g.prototype=i(A,{next:e(+!o,C)}),t(g,c,!1,!0),l[c]=s,g}},{"../internals/create-property-descriptor":242,"../internals/iterators":298,"../internals/iterators-core":297,"../internals/object-create":306,"../internals/set-to-string-tag":331}],296:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/is-pure"),t=g("../internals/function-name"),l=g("../internals/is-callable"),s=g("../internals/iterator-create-constructor"),o=g("../internals/object-get-prototype-of"),c=g("../internals/object-set-prototype-of"),d=g("../internals/set-to-string-tag"),a=g("../internals/create-non-enumerable-property"),n=g("../internals/define-built-in"),r=g("../internals/well-known-symbol"),m=g("../internals/iterators"),h=g("../internals/iterators-core"),Z=t.PROPER,b=t.CONFIGURABLE,G=h.IteratorPrototype,u=h.BUGGY_SAFARI_ITERATORS,p=r("iterator"),w="keys",W="values",B="entries",y=function(){return this};I.exports=function(g,I,C,t,r,h,V){s(C,I,t);var X,Y,R,N=function(g){if(g===r&&M)return M;if(!u&&g&&g in f)return f[g];switch(g){case w:case W:case B:return function(){return new C(this,g)}}return function(){return new C(this)}},H=I+" Iterator",K=!1,f=g.prototype,F=f[p]||f["@@iterator"]||r&&f[r],M=!u&&F||N(r),S="Array"===I&&f.entries||F;if(S&&(X=o(S.call(new g)))!==Object.prototype&&X.next&&(e||o(X)===G||(c?c(X,G):l(X[p])||n(X,p,y)),d(X,H,!0,!0),e&&(m[H]=y)),Z&&r===W&&F&&F.name!==W&&(!e&&b?a(f,"name",W):(K=!0,M=function(){return i(F,this)})),r)if(Y={values:N(W),keys:h?M:N(w),entries:N(B)},V)for(R in Y)(u||K||!(R in f))&&n(f,R,Y[R]);else A({target:I,proto:!0,forced:u||K},Y);return e&&!V||f[p]===M||n(f,p,M,{name:r}),m[I]=M,Y}},{"../internals/create-non-enumerable-property":241,"../internals/define-built-in":245,"../internals/export":259,"../internals/function-call":264,"../internals/function-name":265,"../internals/is-callable":285,"../internals/is-pure":290,"../internals/iterator-create-constructor":295,"../internals/iterators":298,"../internals/iterators-core":297,"../internals/object-get-prototype-of":313,"../internals/object-set-prototype-of":318,"../internals/set-to-string-tag":331,"../internals/well-known-symbol":357}],297:[function(g,I,C){var A,i,e,t=g("../internals/fails"),l=g("../internals/is-callable"),s=g("../internals/is-object"),o=g("../internals/object-create"),c=g("../internals/object-get-prototype-of"),d=g("../internals/define-built-in"),a=g("../internals/well-known-symbol"),n=g("../internals/is-pure"),r=a("iterator"),m=!1;[].keys&&("next"in(e=[].keys())?(i=c(c(e)))!==Object.prototype&&(A=i):m=!0),!s(A)||t((function(){var g={};return A[r].call(g)!==g}))?A={}:n&&(A=o(A)),l(A[r])||d(A,r,(function(){return this})),I.exports={IteratorPrototype:A,BUGGY_SAFARI_ITERATORS:m}},{"../internals/define-built-in":245,"../internals/fails":260,"../internals/is-callable":285,"../internals/is-object":289,"../internals/is-pure":290,"../internals/object-create":306,"../internals/object-get-prototype-of":313,"../internals/well-known-symbol":357}],298:[function(g,I,C){arguments[4][276][0].apply(C,arguments)},{dup:276}],299:[function(g,I,C){var A=g("../internals/to-length");I.exports=function(g){return A(g.length)}},{"../internals/to-length":343}],300:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/fails"),e=g("../internals/is-callable"),t=g("../internals/has-own-property"),l=g("../internals/descriptors"),s=g("../internals/function-name").CONFIGURABLE,o=g("../internals/inspect-source"),c=g("../internals/internal-state"),d=c.enforce,a=c.get,n=String,r=Object.defineProperty,m=A("".slice),h=A("".replace),Z=A([].join),b=l&&!i((function(){return 8!==r((function(){}),"length",{value:8}).length})),G=String(String).split("String"),u=I.exports=function(g,I,C){"Symbol("===m(n(I),0,7)&&(I="["+h(n(I),/^Symbol\(([^)]*)\)/,"$1")+"]"),C&&C.getter&&(I="get "+I),C&&C.setter&&(I="set "+I),(!t(g,"name")||s&&g.name!==I)&&(l?r(g,"name",{value:I,configurable:!0}):g.name=I),b&&C&&t(C,"arity")&&g.length!==C.arity&&r(g,"length",{value:C.arity});try{C&&t(C,"constructor")&&C.constructor?l&&r(g,"prototype",{writable:!1}):g.prototype&&(g.prototype=void 0)}catch(i){}var A=d(g);return t(A,"source")||(A.source=Z(G,"string"==typeof I?I:"")),g};Function.prototype.toString=u((function(){return e(this)&&a(this).source||o(this)}),"toString")},{"../internals/descriptors":247,"../internals/fails":260,"../internals/function-name":265,"../internals/function-uncurry-this":268,"../internals/has-own-property":275,"../internals/inspect-source":281,"../internals/internal-state":282,"../internals/is-callable":285}],301:[function(g,I,C){var A=Math.ceil,i=Math.floor;I.exports=Math.trunc||function(g){var I=+g;return(I>0?i:A)(I)}},{}],302:[function(g,I,C){var A,i,e,t,l,s=g("../internals/global"),o=g("../internals/function-bind-context"),c=g("../internals/object-get-own-property-descriptor").f,d=g("../internals/task").set,a=g("../internals/queue"),n=g("../internals/engine-is-ios"),r=g("../internals/engine-is-ios-pebble"),m=g("../internals/engine-is-webos-webkit"),h=g("../internals/engine-is-node"),Z=s.MutationObserver||s.WebKitMutationObserver,b=s.document,G=s.process,u=s.Promise,p=c(s,"queueMicrotask"),w=p&&p.value;if(!w){var W=new a,B=function(){var g,I;for(h&&(g=G.domain)&&g.exit();I=W.get();)try{I()}catch(C){throw W.head&&A(),C}g&&g.enter()};n||h||m||!Z||!b?!r&&u&&u.resolve?((t=u.resolve(void 0)).constructor=u,l=o(t.then,t),A=function(){l(B)}):h?A=function(){G.nextTick(B)}:(d=o(d,s),A=function(){d(B)}):(i=!0,e=b.createTextNode(""),new Z(B).observe(e,{characterData:!0}),A=function(){e.data=i=!i}),w=function(g){W.head||A(),W.add(g)}}I.exports=w},{"../internals/engine-is-ios":253,"../internals/engine-is-ios-pebble":252,"../internals/engine-is-node":254,"../internals/engine-is-webos-webkit":255,"../internals/function-bind-context":262,"../internals/global":274,"../internals/object-get-own-property-descriptor":309,"../internals/queue":328,"../internals/task":339}],303:[function(g,I,C){var A=g("../internals/a-callable"),i=TypeError,e=function(g){var I,C;this.promise=new g((function(g,A){if(void 0!==I||void 0!==C)throw new i("Bad Promise constructor");I=g,C=A})),this.resolve=A(I),this.reject=A(C)};I.exports.f=function(g){return new e(g)}},{"../internals/a-callable":222}],304:[function(g,I,C){var A=g("../internals/is-regexp"),i=TypeError;I.exports=function(g){if(A(g))throw new i("The method doesn't accept regular expressions");return g}},{"../internals/is-regexp":291}],305:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/function-uncurry-this"),e=g("../internals/function-call"),t=g("../internals/fails"),l=g("../internals/object-keys"),s=g("../internals/object-get-own-property-symbols"),o=g("../internals/object-property-is-enumerable"),c=g("../internals/to-object"),d=g("../internals/indexed-object"),a=Object.assign,n=Object.defineProperty,r=i([].concat);I.exports=!a||t((function(){if(A&&1!==a({b:1},a(n({},"a",{enumerable:!0,get:function(){n(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var g={},I={},C=Symbol("assign detection"),i="abcdefghijklmnopqrst";return g[C]=7,i.split("").forEach((function(g){I[g]=g})),7!==a({},g)[C]||l(a({},I)).join("")!==i}))?function(g,I){for(var C=c(g),i=arguments.length,t=1,a=s.f,n=o.f;i>t;)for(var m,h=d(arguments[t++]),Z=a?r(l(h),a(h)):l(h),b=Z.length,G=0;b>G;)m=Z[G++],A&&!e(n,h,m)||(C[m]=h[m]);return C}:a},{"../internals/descriptors":247,"../internals/fails":260,"../internals/function-call":264,"../internals/function-uncurry-this":268,"../internals/indexed-object":280,"../internals/object-get-own-property-symbols":312,"../internals/object-keys":316,"../internals/object-property-is-enumerable":317,"../internals/to-object":344}],306:[function(g,I,C){var A,i=g("../internals/an-object"),e=g("../internals/object-define-properties"),t=g("../internals/enum-bug-keys"),l=g("../internals/hidden-keys"),s=g("../internals/html"),o=g("../internals/document-create-element"),c=g("../internals/shared-key"),d=">",a="<",n="prototype",r="script",m=c("IE_PROTO"),h=function(){},Z=function(g){return a+r+d+g+a+"/"+r+d},b=function(g){g.write(Z("")),g.close();var I=g.parentWindow.Object;return g=null,I},G=function(){var g,I=o("iframe"),C="java"+r+":";return I.style.display="none",s.appendChild(I),I.src=String(C),(g=I.contentWindow.document).open(),g.write(Z("document.F=Object")),g.close(),g.F},u=function(){try{A=new ActiveXObject("htmlfile")}catch(I){}u="undefined"!=typeof document?document.domain&&A?b(A):G():b(A);for(var g=t.length;g--;)delete u[n][t[g]];return u()};l[m]=!0,I.exports=Object.create||function(g,I){var C;return null!==g?(h[n]=i(g),C=new h,h[n]=null,C[m]=g):C=u(),void 0===I?C:e.f(C,I)}},{"../internals/an-object":227,"../internals/document-create-element":249,"../internals/enum-bug-keys":258,"../internals/hidden-keys":276,"../internals/html":278,"../internals/object-define-properties":307,"../internals/shared-key":332}],307:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/v8-prototype-define-bug"),e=g("../internals/object-define-property"),t=g("../internals/an-object"),l=g("../internals/to-indexed-object"),s=g("../internals/object-keys");C.f=A&&!i?Object.defineProperties:function(g,I){t(g);for(var C,A=l(I),i=s(I),o=i.length,c=0;o>c;)e.f(g,C=i[c++],A[C]);return g}},{"../internals/an-object":227,"../internals/descriptors":247,"../internals/object-define-property":308,"../internals/object-keys":316,"../internals/to-indexed-object":341,"../internals/v8-prototype-define-bug":352}],308:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/ie8-dom-define"),e=g("../internals/v8-prototype-define-bug"),t=g("../internals/an-object"),l=g("../internals/to-property-key"),s=TypeError,o=Object.defineProperty,c=Object.getOwnPropertyDescriptor,d="enumerable",a="configurable",n="writable";C.f=A?e?function(g,I,C){if(t(g),I=l(I),t(C),"function"==typeof g&&"prototype"===I&&"value"in C&&n in C&&!C[n]){var A=c(g,I);A&&A[n]&&(g[I]=C.value,C={configurable:a in C?C[a]:A[a],enumerable:d in C?C[d]:A[d],writable:!1})}return o(g,I,C)}:o:function(g,I,C){if(t(g),I=l(I),t(C),i)try{return o(g,I,C)}catch(A){}if("get"in C||"set"in C)throw new s("Accessors not supported");return"value"in C&&(g[I]=C.value),g}},{"../internals/an-object":227,"../internals/descriptors":247,"../internals/ie8-dom-define":279,"../internals/to-property-key":346,"../internals/v8-prototype-define-bug":352}],309:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/function-call"),e=g("../internals/object-property-is-enumerable"),t=g("../internals/create-property-descriptor"),l=g("../internals/to-indexed-object"),s=g("../internals/to-property-key"),o=g("../internals/has-own-property"),c=g("../internals/ie8-dom-define"),d=Object.getOwnPropertyDescriptor;C.f=A?d:function(g,I){if(g=l(g),I=s(I),c)try{return d(g,I)}catch(C){}if(o(g,I))return t(!i(e.f,g,I),g[I])}},{"../internals/create-property-descriptor":242,"../internals/descriptors":247,"../internals/function-call":264,"../internals/has-own-property":275,"../internals/ie8-dom-define":279,"../internals/object-property-is-enumerable":317,"../internals/to-indexed-object":341,"../internals/to-property-key":346}],310:[function(g,I,C){var A=g("../internals/classof-raw"),i=g("../internals/to-indexed-object"),e=g("../internals/object-get-own-property-names").f,t=g("../internals/array-slice-simple"),l="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(g){try{return e(g)}catch(I){return t(l)}};I.exports.f=function(g){return l&&"Window"===A(g)?s(g):e(i(g))}},{"../internals/array-slice-simple":230,"../internals/classof-raw":235,"../internals/object-get-own-property-names":311,"../internals/to-indexed-object":341}],311:[function(g,I,C){var A=g("../internals/object-keys-internal"),i=g("../internals/enum-bug-keys").concat("length","prototype");C.f=Object.getOwnPropertyNames||function(g){return A(g,i)}},{"../internals/enum-bug-keys":258,"../internals/object-keys-internal":315}],312:[function(g,I,C){C.f=Object.getOwnPropertySymbols},{}],313:[function(g,I,C){var A=g("../internals/has-own-property"),i=g("../internals/is-callable"),e=g("../internals/to-object"),t=g("../internals/shared-key"),l=g("../internals/correct-prototype-getter"),s=t("IE_PROTO"),o=Object,c=o.prototype;I.exports=l?o.getPrototypeOf:function(g){var I=e(g);if(A(I,s))return I[s];var C=I.constructor;return i(C)&&I instanceof C?C.prototype:I instanceof o?c:null}},{"../internals/correct-prototype-getter":239,"../internals/has-own-property":275,"../internals/is-callable":285,"../internals/shared-key":332,"../internals/to-object":344}],314:[function(g,I,C){var A=g("../internals/function-uncurry-this");I.exports=A({}.isPrototypeOf)},{"../internals/function-uncurry-this":268}],315:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/has-own-property"),e=g("../internals/to-indexed-object"),t=g("../internals/array-includes").indexOf,l=g("../internals/hidden-keys"),s=A([].push);I.exports=function(g,I){var C,A=e(g),o=0,c=[];for(C in A)!i(l,C)&&i(A,C)&&s(c,C);for(;I.length>o;)i(A,C=I[o++])&&(~t(c,C)||s(c,C));return c}},{"../internals/array-includes":228,"../internals/function-uncurry-this":268,"../internals/has-own-property":275,"../internals/hidden-keys":276,"../internals/to-indexed-object":341}],316:[function(g,I,C){var A=g("../internals/object-keys-internal"),i=g("../internals/enum-bug-keys");I.exports=Object.keys||function(g){return A(g,i)}},{"../internals/enum-bug-keys":258,"../internals/object-keys-internal":315}],317:[function(g,I,C){var A={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,e=i&&!A.call({1:2},1);C.f=e?function(g){var I=i(this,g);return!!I&&I.enumerable}:A},{}],318:[function(g,I,C){var A=g("../internals/function-uncurry-this-accessor"),i=g("../internals/an-object"),e=g("../internals/a-possible-prototype");I.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var g,I=!1,C={};try{(g=A(Object.prototype,"__proto__","set"))(C,[]),I=C instanceof Array}catch(t){}return function(C,A){return i(C),e(A),I?g(C,A):C.__proto__=A,C}}():void 0)},{"../internals/a-possible-prototype":224,"../internals/an-object":227,"../internals/function-uncurry-this-accessor":266}],319:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/fails"),e=g("../internals/function-uncurry-this"),t=g("../internals/object-get-prototype-of"),l=g("../internals/object-keys"),s=g("../internals/to-indexed-object"),o=e(g("../internals/object-property-is-enumerable").f),c=e([].push),d=A&&i((function(){var g=Object.create(null);return g[2]=2,!o(g,2)})),a=function(g){return function(I){for(var C,i=s(I),e=l(i),a=d&&null===t(i),n=e.length,r=0,m=[];n>r;)C=e[r++],A&&!(a?C in i:o(i,C))||c(m,g?[C,i[C]]:i[C]);return m}};I.exports={entries:a(!0),values:a(!1)}},{"../internals/descriptors":247,"../internals/fails":260,"../internals/function-uncurry-this":268,"../internals/object-get-prototype-of":313,"../internals/object-keys":316,"../internals/object-property-is-enumerable":317,"../internals/to-indexed-object":341}],320:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/is-callable"),e=g("../internals/is-object"),t=TypeError;I.exports=function(g,I){var C,l;if("string"===I&&i(C=g.toString)&&!e(l=A(C,g)))return l;if(i(C=g.valueOf)&&!e(l=A(C,g)))return l;if("string"!==I&&i(C=g.toString)&&!e(l=A(C,g)))return l;throw new t("Can't convert object to primitive value")}},{"../internals/function-call":264,"../internals/is-callable":285,"../internals/is-object":289}],321:[function(g,I,C){var A=g("../internals/get-built-in"),i=g("../internals/function-uncurry-this"),e=g("../internals/object-get-own-property-names"),t=g("../internals/object-get-own-property-symbols"),l=g("../internals/an-object"),s=i([].concat);I.exports=A("Reflect","ownKeys")||function(g){var I=e.f(l(g)),C=t.f;return C?s(I,C(g)):I}},{"../internals/an-object":227,"../internals/function-uncurry-this":268,"../internals/get-built-in":269,"../internals/object-get-own-property-names":311,"../internals/object-get-own-property-symbols":312}],322:[function(g,I,C){var A=g("../internals/global");I.exports=A},{"../internals/global":274}],323:[function(g,I,C){I.exports=function(g){try{return{error:!1,value:g()}}catch(I){return{error:!0,value:I}}}},{}],324:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/promise-native-constructor"),e=g("../internals/is-callable"),t=g("../internals/is-forced"),l=g("../internals/inspect-source"),s=g("../internals/well-known-symbol"),o=g("../internals/engine-is-browser"),c=g("../internals/engine-is-deno"),d=g("../internals/is-pure"),a=g("../internals/engine-v8-version"),n=i&&i.prototype,r=s("species"),m=!1,h=e(A.PromiseRejectionEvent),Z=t("Promise",(function(){var g=l(i),I=g!==String(i);if(!I&&66===a)return!0;if(d&&(!n.catch||!n.finally))return!0;if(!a||a<51||!/native code/.test(g)){var C=new i((function(g){g(1)})),A=function(g){g((function(){}),(function(){}))};if((C.constructor={})[r]=A,!(m=C.then((function(){}))instanceof A))return!0}return!I&&(o||c)&&!h}));I.exports={CONSTRUCTOR:Z,REJECTION_EVENT:h,SUBCLASSING:m}},{"../internals/engine-is-browser":250,"../internals/engine-is-deno":251,"../internals/engine-v8-version":257,"../internals/global":274,"../internals/inspect-source":281,"../internals/is-callable":285,"../internals/is-forced":287,"../internals/is-pure":290,"../internals/promise-native-constructor":325,"../internals/well-known-symbol":357}],325:[function(g,I,C){var A=g("../internals/global");I.exports=A.Promise},{"../internals/global":274}],326:[function(g,I,C){var A=g("../internals/an-object"),i=g("../internals/is-object"),e=g("../internals/new-promise-capability");I.exports=function(g,I){if(A(g),i(I)&&I.constructor===g)return I;var C=e.f(g);return(0,C.resolve)(I),C.promise}},{"../internals/an-object":227,"../internals/is-object":289,"../internals/new-promise-capability":303}],327:[function(g,I,C){var A=g("../internals/promise-native-constructor"),i=g("../internals/check-correctness-of-iteration"),e=g("../internals/promise-constructor-detection").CONSTRUCTOR;I.exports=e||!i((function(g){A.all(g).then(void 0,(function(){}))}))},{"../internals/check-correctness-of-iteration":234,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325}],328:[function(g,I,C){var A=function(){this.head=null,this.tail=null};A.prototype={add:function(g){var I={item:g,next:null},C=this.tail;C?C.next=I:this.head=I,this.tail=I},get:function(){var g=this.head;if(g)return null===(this.head=g.next)&&(this.tail=null),g.item}},I.exports=A},{}],329:[function(g,I,C){var A=g("../internals/is-null-or-undefined"),i=TypeError;I.exports=function(g){if(A(g))throw new i("Can't call method on "+g);return g}},{"../internals/is-null-or-undefined":288}],330:[function(g,I,C){var A=g("../internals/get-built-in"),i=g("../internals/define-built-in-accessor"),e=g("../internals/well-known-symbol"),t=g("../internals/descriptors"),l=e("species");I.exports=function(g){var I=A(g);t&&I&&!I[l]&&i(I,l,{configurable:!0,get:function(){return this}})}},{"../internals/define-built-in-accessor":244,"../internals/descriptors":247,"../internals/get-built-in":269,"../internals/well-known-symbol":357}],331:[function(g,I,C){var A=g("../internals/object-define-property").f,i=g("../internals/has-own-property"),e=g("../internals/well-known-symbol")("toStringTag");I.exports=function(g,I,C){g&&!C&&(g=g.prototype),g&&!i(g,e)&&A(g,e,{configurable:!0,value:I})}},{"../internals/has-own-property":275,"../internals/object-define-property":308,"../internals/well-known-symbol":357}],332:[function(g,I,C){var A=g("../internals/shared"),i=g("../internals/uid"),e=A("keys");I.exports=function(g){return e[g]||(e[g]=i(g))}},{"../internals/shared":334,"../internals/uid":350}],333:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/define-global-property"),e="__core-js_shared__",t=A[e]||i(e,{});I.exports=t},{"../internals/define-global-property":246,"../internals/global":274}],334:[function(g,I,C){var A=g("../internals/is-pure"),i=g("../internals/shared-store");(I.exports=function(g,I){return i[g]||(i[g]=void 0!==I?I:{})})("versions",[]).push({version:"3.33.0",mode:A?"pure":"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.33.0/LICENSE",source:"https://github.com/zloirock/core-js"})},{"../internals/is-pure":290,"../internals/shared-store":333}],335:[function(g,I,C){var A=g("../internals/an-object"),i=g("../internals/a-constructor"),e=g("../internals/is-null-or-undefined"),t=g("../internals/well-known-symbol")("species");I.exports=function(g,I){var C,l=A(g).constructor;return void 0===l||e(C=A(l)[t])?I:i(C)}},{"../internals/a-constructor":223,"../internals/an-object":227,"../internals/is-null-or-undefined":288,"../internals/well-known-symbol":357}],336:[function(g,I,C){var A=g("../internals/engine-v8-version"),i=g("../internals/fails"),e=g("../internals/global").String;I.exports=!!Object.getOwnPropertySymbols&&!i((function(){var g=Symbol("symbol detection");return!e(g)||!(Object(g)instanceof Symbol)||!Symbol.sham&&A&&A<41}))},{"../internals/engine-v8-version":257,"../internals/fails":260,"../internals/global":274}],337:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/get-built-in"),e=g("../internals/well-known-symbol"),t=g("../internals/define-built-in");I.exports=function(){var g=i("Symbol"),I=g&&g.prototype,C=I&&I.valueOf,l=e("toPrimitive");I&&!I[l]&&t(I,l,(function(g){return A(C,this)}),{arity:1})}},{"../internals/define-built-in":245,"../internals/function-call":264,"../internals/get-built-in":269,"../internals/well-known-symbol":357}],338:[function(g,I,C){var A=g("../internals/symbol-constructor-detection");I.exports=A&&!!Symbol.for&&!!Symbol.keyFor},{"../internals/symbol-constructor-detection":336}],339:[function(g,I,C){var A,i,e,t,l=g("../internals/global"),s=g("../internals/function-apply"),o=g("../internals/function-bind-context"),c=g("../internals/is-callable"),d=g("../internals/has-own-property"),a=g("../internals/fails"),n=g("../internals/html"),r=g("../internals/array-slice"),m=g("../internals/document-create-element"),h=g("../internals/validate-arguments-length"),Z=g("../internals/engine-is-ios"),b=g("../internals/engine-is-node"),G=l.setImmediate,u=l.clearImmediate,p=l.process,w=l.Dispatch,W=l.Function,B=l.MessageChannel,y=l.String,V=0,X={},Y="onreadystatechange";a((function(){A=l.location}));var R=function(g){if(d(X,g)){var I=X[g];delete X[g],I()}},N=function(g){return function(){R(g)}},H=function(g){R(g.data)},K=function(g){l.postMessage(y(g),A.protocol+"//"+A.host)};G&&u||(G=function(g){h(arguments.length,1);var I=c(g)?g:W(g),C=r(arguments,1);return X[++V]=function(){s(I,void 0,C)},i(V),V},u=function(g){delete X[g]},b?i=function(g){p.nextTick(N(g))}:w&&w.now?i=function(g){w.now(N(g))}:B&&!Z?(t=(e=new B).port2,e.port1.onmessage=H,i=o(t.postMessage,t)):l.addEventListener&&c(l.postMessage)&&!l.importScripts&&A&&"file:"!==A.protocol&&!a(K)?(i=K,l.addEventListener("message",H,!1)):i=Y in m("script")?function(g){n.appendChild(m("script"))[Y]=function(){n.removeChild(this),R(g)}}:function(g){setTimeout(N(g),0)}),I.exports={set:G,clear:u}},{"../internals/array-slice":231,"../internals/document-create-element":249,"../internals/engine-is-ios":253,"../internals/engine-is-node":254,"../internals/fails":260,"../internals/function-apply":261,"../internals/function-bind-context":262,"../internals/global":274,"../internals/has-own-property":275,"../internals/html":278,"../internals/is-callable":285,"../internals/validate-arguments-length":353}],340:[function(g,I,C){var A=g("../internals/to-integer-or-infinity"),i=Math.max,e=Math.min;I.exports=function(g,I){var C=A(g);return C<0?i(C+I,0):e(C,I)}},{"../internals/to-integer-or-infinity":342}],341:[function(g,I,C){var A=g("../internals/indexed-object"),i=g("../internals/require-object-coercible");I.exports=function(g){return A(i(g))}},{"../internals/indexed-object":280,"../internals/require-object-coercible":329}],342:[function(g,I,C){var A=g("../internals/math-trunc");I.exports=function(g){var I=+g;return I!=I||0===I?0:A(I)}},{"../internals/math-trunc":301}],343:[function(g,I,C){var A=g("../internals/to-integer-or-infinity"),i=Math.min;I.exports=function(g){return g>0?i(A(g),9007199254740991):0}},{"../internals/to-integer-or-infinity":342}],344:[function(g,I,C){var A=g("../internals/require-object-coercible"),i=Object;I.exports=function(g){return i(A(g))}},{"../internals/require-object-coercible":329}],345:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/is-object"),e=g("../internals/is-symbol"),t=g("../internals/get-method"),l=g("../internals/ordinary-to-primitive"),s=g("../internals/well-known-symbol"),o=TypeError,c=s("toPrimitive");I.exports=function(g,I){if(!i(g)||e(g))return g;var C,s=t(g,c);if(s){if(void 0===I&&(I="default"),C=A(s,g,I),!i(C)||e(C))return C;throw new o("Can't convert object to primitive value")}return void 0===I&&(I="number"),l(g,I)}},{"../internals/function-call":264,"../internals/get-method":273,"../internals/is-object":289,"../internals/is-symbol":292,"../internals/ordinary-to-primitive":320,"../internals/well-known-symbol":357}],346:[function(g,I,C){var A=g("../internals/to-primitive"),i=g("../internals/is-symbol");I.exports=function(g){var I=A(g,"string");return i(I)?I:I+""}},{"../internals/is-symbol":292,"../internals/to-primitive":345}],347:[function(g,I,C){var A={};A[g("../internals/well-known-symbol")("toStringTag")]="z",I.exports="[object z]"===String(A)},{"../internals/well-known-symbol":357}],348:[function(g,I,C){var A=g("../internals/classof"),i=String;I.exports=function(g){if("Symbol"===A(g))throw new TypeError("Cannot convert a Symbol value to a string");return i(g)}},{"../internals/classof":236}],349:[function(g,I,C){var A=String;I.exports=function(g){try{return A(g)}catch(I){return"Object"}}},{}],350:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=0,e=Math.random(),t=A(1..toString);I.exports=function(g){return"Symbol("+(void 0===g?"":g)+")_"+t(++i+e,36)}},{"../internals/function-uncurry-this":268}],351:[function(g,I,C){var A=g("../internals/symbol-constructor-detection");I.exports=A&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},{"../internals/symbol-constructor-detection":336}],352:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/fails");I.exports=A&&i((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},{"../internals/descriptors":247,"../internals/fails":260}],353:[function(g,I,C){var A=TypeError;I.exports=function(g,I){if(g1?arguments[1]:void 0)}}),e(t)},{"../internals/add-to-unscopables":225,"../internals/array-iteration":229,"../internals/export":259}],359:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/array-iteration").find,e=g("../internals/add-to-unscopables"),t="find",l=!0;t in[]&&Array(1)[t]((function(){l=!1})),A({target:"Array",proto:!0,forced:l},{find:function(g){return i(this,g,arguments.length>1?arguments[1]:void 0)}}),e(t)},{"../internals/add-to-unscopables":225,"../internals/array-iteration":229,"../internals/export":259}],360:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/array-includes").includes,e=g("../internals/fails"),t=g("../internals/add-to-unscopables");A({target:"Array",proto:!0,forced:e((function(){return!Array(1).includes()}))},{includes:function(g){return i(this,g,arguments.length>1?arguments[1]:void 0)}}),t("includes")},{"../internals/add-to-unscopables":225,"../internals/array-includes":228,"../internals/export":259,"../internals/fails":260}],361:[function(g,I,C){var A=g("../internals/to-indexed-object"),i=g("../internals/add-to-unscopables"),e=g("../internals/iterators"),t=g("../internals/internal-state"),l=g("../internals/object-define-property").f,s=g("../internals/iterator-define"),o=g("../internals/create-iter-result-object"),c=g("../internals/is-pure"),d=g("../internals/descriptors"),a="Array Iterator",n=t.set,r=t.getterFor(a);I.exports=s(Array,"Array",(function(g,I){n(this,{type:a,target:A(g),index:0,kind:I})}),(function(){var g=r(this),I=g.target,C=g.kind,A=g.index++;if(!I||A>=I.length)return g.target=void 0,o(void 0,!0);switch(C){case"keys":return o(A,!1);case"values":return o(I[A],!1)}return o([A,I[A]],!1)}),"values");var m=e.Arguments=e.Array;if(i("keys"),i("values"),i("entries"),!c&&d&&"values"!==m.name)try{l(m,"name",{value:"values"})}catch(h){}},{"../internals/add-to-unscopables":225,"../internals/create-iter-result-object":240,"../internals/descriptors":247,"../internals/internal-state":282,"../internals/is-pure":290,"../internals/iterator-define":296,"../internals/iterators":298,"../internals/object-define-property":308,"../internals/to-indexed-object":341}],362:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/get-built-in"),e=g("../internals/function-apply"),t=g("../internals/function-call"),l=g("../internals/function-uncurry-this"),s=g("../internals/fails"),o=g("../internals/is-callable"),c=g("../internals/is-symbol"),d=g("../internals/array-slice"),a=g("../internals/get-json-replacer-function"),n=g("../internals/symbol-constructor-detection"),r=String,m=i("JSON","stringify"),h=l(/./.exec),Z=l("".charAt),b=l("".charCodeAt),G=l("".replace),u=l(1..toString),p=/[\uD800-\uDFFF]/g,w=/^[\uD800-\uDBFF]$/,W=/^[\uDC00-\uDFFF]$/,B=!n||s((function(){var g=i("Symbol")("stringify detection");return"[null]"!==m([g])||"{}"!==m({a:g})||"{}"!==m(Object(g))})),y=s((function(){return'"\\udf06\\ud834"'!==m("\udf06\ud834")||'"\\udead"'!==m("\udead")})),V=function(g,I){var C=d(arguments),A=a(I);if(o(A)||void 0!==g&&!c(g))return C[1]=function(g,I){if(o(A)&&(I=t(A,this,r(g),I)),!c(I))return I},e(m,null,C)},X=function(g,I,C){var A=Z(C,I-1),i=Z(C,I+1);return h(w,g)&&!h(W,i)||h(W,g)&&!h(w,A)?"\\u"+u(b(g,0),16):g};m&&A({target:"JSON",stat:!0,arity:3,forced:B||y},{stringify:function(g,I,C){var A=d(arguments),i=e(B?V:m,null,A);return y&&"string"==typeof i?G(i,p,X):i}})},{"../internals/array-slice":231,"../internals/export":259,"../internals/fails":260,"../internals/function-apply":261,"../internals/function-call":264,"../internals/function-uncurry-this":268,"../internals/get-built-in":269,"../internals/get-json-replacer-function":272,"../internals/is-callable":285,"../internals/is-symbol":292,"../internals/symbol-constructor-detection":336}],363:[function(g,I,C){g("../internals/export")({target:"Number",stat:!0},{isNaN:function(g){return g!=g}})},{"../internals/export":259}],364:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/object-assign");A({target:"Object",stat:!0,arity:2,forced:Object.assign!==i},{assign:i})},{"../internals/export":259,"../internals/object-assign":305}],365:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/symbol-constructor-detection"),e=g("../internals/fails"),t=g("../internals/object-get-own-property-symbols"),l=g("../internals/to-object");A({target:"Object",stat:!0,forced:!i||e((function(){t.f(1)}))},{getOwnPropertySymbols:function(g){var I=t.f;return I?I(l(g)):[]}})},{"../internals/export":259,"../internals/fails":260,"../internals/object-get-own-property-symbols":312,"../internals/symbol-constructor-detection":336,"../internals/to-object":344}],366:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/to-object"),e=g("../internals/object-keys");A({target:"Object",stat:!0,forced:g("../internals/fails")((function(){e(1)}))},{keys:function(g){return e(i(g))}})},{"../internals/export":259,"../internals/fails":260,"../internals/object-keys":316,"../internals/to-object":344}],367:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/object-to-array").values;A({target:"Object",stat:!0},{values:function(g){return i(g)}})},{"../internals/export":259,"../internals/object-to-array":319}],368:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/a-callable"),t=g("../internals/new-promise-capability"),l=g("../internals/perform"),s=g("../internals/iterate");A({target:"Promise",stat:!0,forced:g("../internals/promise-statics-incorrect-iteration")},{all:function(g){var I=this,C=t.f(I),A=C.resolve,o=C.reject,c=l((function(){var C=e(I.resolve),t=[],l=0,c=1;s(g,(function(g){var e=l++,s=!1;c++,i(C,I,g).then((function(g){s||(s=!0,t[e]=g,--c||A(t))}),o)})),--c||A(t)}));return c.error&&o(c.value),C.promise}})},{"../internals/a-callable":222,"../internals/export":259,"../internals/function-call":264,"../internals/iterate":293,"../internals/new-promise-capability":303,"../internals/perform":323,"../internals/promise-statics-incorrect-iteration":327}],369:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/is-pure"),e=g("../internals/promise-constructor-detection").CONSTRUCTOR,t=g("../internals/promise-native-constructor"),l=g("../internals/get-built-in"),s=g("../internals/is-callable"),o=g("../internals/define-built-in"),c=t&&t.prototype;if(A({target:"Promise",proto:!0,forced:e,real:!0},{catch:function(g){return this.then(void 0,g)}}),!i&&s(t)){var d=l("Promise").prototype.catch;c.catch!==d&&o(c,"catch",d,{unsafe:!0})}},{"../internals/define-built-in":245,"../internals/export":259,"../internals/get-built-in":269,"../internals/is-callable":285,"../internals/is-pure":290,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325}],370:[function(g,I,C){var A,i,e,t,l=g("../internals/export"),s=g("../internals/is-pure"),o=g("../internals/engine-is-node"),c=g("../internals/global"),d=g("../internals/function-call"),a=g("../internals/define-built-in"),n=g("../internals/object-set-prototype-of"),r=g("../internals/set-to-string-tag"),m=g("../internals/set-species"),h=g("../internals/a-callable"),Z=g("../internals/is-callable"),b=g("../internals/is-object"),G=g("../internals/an-instance"),u=g("../internals/species-constructor"),p=g("../internals/task").set,w=g("../internals/microtask"),W=g("../internals/host-report-errors"),B=g("../internals/perform"),y=g("../internals/queue"),V=g("../internals/internal-state"),X=g("../internals/promise-native-constructor"),Y=g("../internals/promise-constructor-detection"),R=g("../internals/new-promise-capability"),N="Promise",H=Y.CONSTRUCTOR,K=Y.REJECTION_EVENT,f=Y.SUBCLASSING,F=V.getterFor(N),M=V.set,S=X&&X.prototype,J=X,k=S,D=c.TypeError,v=c.document,L=c.process,z=R.f,T=z,x=!!(v&&v.createEvent&&c.dispatchEvent),U="unhandledrejection",j="rejectionhandled",Q=0,O=1,E=2,P=1,_=2,q=function(g){var I;return!(!b(g)||!Z(I=g.then))&&I},$=function(g,I){var C,A,i,e=I.value,t=I.state===O,l=t?g.ok:g.fail,s=g.resolve,o=g.reject,c=g.domain;try{l?(t||(I.rejection===_&&ig(I),I.rejection=P),!0===l?C=e:(c&&c.enter(),C=l(e),c&&(c.exit(),i=!0)),C===g.promise?o(new D("Promise-chain cycle")):(A=q(C))?d(A,C,s,o):s(C)):o(e)}catch(a){c&&!i&&c.exit(),o(a)}},gg=function(g,I){g.notified||(g.notified=!0,w((function(){for(var C,A=g.reactions;C=A.get();)$(C,g);g.notified=!1,I&&!g.rejection&&Cg(g)})))},Ig=function(g,I,C){var A,i;x?((A=v.createEvent("Event")).promise=I,A.reason=C,A.initEvent(g,!1,!0),c.dispatchEvent(A)):A={promise:I,reason:C},!K&&(i=c["on"+g])?i(A):g===U&&W("Unhandled promise rejection",C)},Cg=function(g){d(p,c,(function(){var I,C=g.facade,A=g.value;if(Ag(g)&&(I=B((function(){o?L.emit("unhandledRejection",A,C):Ig(U,C,A)})),g.rejection=o||Ag(g)?_:P,I.error))throw I.value}))},Ag=function(g){return g.rejection!==P&&!g.parent},ig=function(g){d(p,c,(function(){var I=g.facade;o?L.emit("rejectionHandled",I):Ig(j,I,g.value)}))},eg=function(g,I,C){return function(A){g(I,A,C)}},tg=function(g,I,C){g.done||(g.done=!0,C&&(g=C),g.value=I,g.state=E,gg(g,!0))},lg=function(g,I,C){if(!g.done){g.done=!0,C&&(g=C);try{if(g.facade===I)throw new D("Promise can't be resolved itself");var A=q(I);A?w((function(){var C={done:!1};try{d(A,I,eg(lg,C,g),eg(tg,C,g))}catch(i){tg(C,i,g)}})):(g.value=I,g.state=O,gg(g,!1))}catch(i){tg({done:!1},i,g)}}};if(H&&(k=(J=function(g){G(this,k),h(g),d(A,this);var I=F(this);try{g(eg(lg,I),eg(tg,I))}catch(C){tg(I,C)}}).prototype,(A=function(g){M(this,{type:N,done:!1,notified:!1,parent:!1,reactions:new y,rejection:!1,state:Q,value:void 0})}).prototype=a(k,"then",(function(g,I){var C=F(this),A=z(u(this,J));return C.parent=!0,A.ok=!Z(g)||g,A.fail=Z(I)&&I,A.domain=o?L.domain:void 0,C.state===Q?C.reactions.add(A):w((function(){$(A,C)})),A.promise})),i=function(){var g=new A,I=F(g);this.promise=g,this.resolve=eg(lg,I),this.reject=eg(tg,I)},R.f=z=function(g){return g===J||g===e?new i(g):T(g)},!s&&Z(X)&&S!==Object.prototype)){t=S.then,f||a(S,"then",(function(g,I){var C=this;return new J((function(g,I){d(t,C,g,I)})).then(g,I)}),{unsafe:!0});try{delete S.constructor}catch(sg){}n&&n(S,k)}l({global:!0,constructor:!0,wrap:!0,forced:H},{Promise:J}),r(J,N,!1,!0),m(N)},{"../internals/a-callable":222,"../internals/an-instance":226,"../internals/define-built-in":245,"../internals/engine-is-node":254,"../internals/export":259,"../internals/function-call":264,"../internals/global":274,"../internals/host-report-errors":277,"../internals/internal-state":282,"../internals/is-callable":285,"../internals/is-object":289,"../internals/is-pure":290,"../internals/microtask":302,"../internals/new-promise-capability":303,"../internals/object-set-prototype-of":318,"../internals/perform":323,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325,"../internals/queue":328,"../internals/set-species":330,"../internals/set-to-string-tag":331,"../internals/species-constructor":335,"../internals/task":339}],371:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/is-pure"),e=g("../internals/promise-native-constructor"),t=g("../internals/fails"),l=g("../internals/get-built-in"),s=g("../internals/is-callable"),o=g("../internals/species-constructor"),c=g("../internals/promise-resolve"),d=g("../internals/define-built-in"),a=e&&e.prototype;if(A({target:"Promise",proto:!0,real:!0,forced:!!e&&t((function(){a.finally.call({then:function(){}},(function(){}))}))},{finally:function(g){var I=o(this,l("Promise")),C=s(g);return this.then(C?function(C){return c(I,g()).then((function(){return C}))}:g,C?function(C){return c(I,g()).then((function(){throw C}))}:g)}}),!i&&s(e)){var n=l("Promise").prototype.finally;a.finally!==n&&d(a,"finally",n,{unsafe:!0})}},{"../internals/define-built-in":245,"../internals/export":259,"../internals/fails":260,"../internals/get-built-in":269,"../internals/is-callable":285,"../internals/is-pure":290,"../internals/promise-native-constructor":325,"../internals/promise-resolve":326,"../internals/species-constructor":335}],372:[function(g,I,C){g("../modules/es.promise.constructor"),g("../modules/es.promise.all"),g("../modules/es.promise.catch"),g("../modules/es.promise.race"),g("../modules/es.promise.reject"),g("../modules/es.promise.resolve")},{"../modules/es.promise.all":368,"../modules/es.promise.catch":369,"../modules/es.promise.constructor":370,"../modules/es.promise.race":373,"../modules/es.promise.reject":374,"../modules/es.promise.resolve":375}],373:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/a-callable"),t=g("../internals/new-promise-capability"),l=g("../internals/perform"),s=g("../internals/iterate");A({target:"Promise",stat:!0,forced:g("../internals/promise-statics-incorrect-iteration")},{race:function(g){var I=this,C=t.f(I),A=C.reject,o=l((function(){var t=e(I.resolve);s(g,(function(g){i(t,I,g).then(C.resolve,A)}))}));return o.error&&A(o.value),C.promise}})},{"../internals/a-callable":222,"../internals/export":259,"../internals/function-call":264,"../internals/iterate":293,"../internals/new-promise-capability":303,"../internals/perform":323,"../internals/promise-statics-incorrect-iteration":327}],374:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/new-promise-capability");A({target:"Promise",stat:!0,forced:g("../internals/promise-constructor-detection").CONSTRUCTOR},{reject:function(g){var I=e.f(this);return i(I.reject,void 0,g),I.promise}})},{"../internals/export":259,"../internals/function-call":264,"../internals/new-promise-capability":303,"../internals/promise-constructor-detection":324}],375:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/get-built-in"),e=g("../internals/is-pure"),t=g("../internals/promise-native-constructor"),l=g("../internals/promise-constructor-detection").CONSTRUCTOR,s=g("../internals/promise-resolve"),o=i("Promise"),c=e&&!l;A({target:"Promise",stat:!0,forced:e||l},{resolve:function(g){return s(c&&this===o?t:this,g)}})},{"../internals/export":259,"../internals/get-built-in":269,"../internals/is-pure":290,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325,"../internals/promise-resolve":326}],376:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-uncurry-this"),e=g("../internals/to-absolute-index"),t=RangeError,l=String.fromCharCode,s=String.fromCodePoint,o=i([].join);A({target:"String",stat:!0,arity:1,forced:!!s&&1!==s.length},{fromCodePoint:function(g){for(var I,C=[],A=arguments.length,i=0;A>i;){if(I=+arguments[i++],e(I,1114111)!==I)throw new t(I+" is not a valid code point");C[i]=I<65536?l(I):l(55296+((I-=65536)>>10),I%1024+56320)}return o(C,"")}})},{"../internals/export":259,"../internals/function-uncurry-this":268,"../internals/to-absolute-index":340}],377:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-uncurry-this"),e=g("../internals/not-a-regexp"),t=g("../internals/require-object-coercible"),l=g("../internals/to-string"),s=g("../internals/correct-is-regexp-logic"),o=i("".indexOf);A({target:"String",proto:!0,forced:!s("includes")},{includes:function(g){return!!~o(l(t(this)),l(e(g)),arguments.length>1?arguments[1]:void 0)}})},{"../internals/correct-is-regexp-logic":238,"../internals/export":259,"../internals/function-uncurry-this":268,"../internals/not-a-regexp":304,"../internals/require-object-coercible":329,"../internals/to-string":348}],378:[function(g,I,C){g("../internals/well-known-symbol-define")("asyncIterator")},{"../internals/well-known-symbol-define":355}],379:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/global"),e=g("../internals/function-call"),t=g("../internals/function-uncurry-this"),l=g("../internals/is-pure"),s=g("../internals/descriptors"),o=g("../internals/symbol-constructor-detection"),c=g("../internals/fails"),d=g("../internals/has-own-property"),a=g("../internals/object-is-prototype-of"),n=g("../internals/an-object"),r=g("../internals/to-indexed-object"),m=g("../internals/to-property-key"),h=g("../internals/to-string"),Z=g("../internals/create-property-descriptor"),b=g("../internals/object-create"),G=g("../internals/object-keys"),u=g("../internals/object-get-own-property-names"),p=g("../internals/object-get-own-property-names-external"),w=g("../internals/object-get-own-property-symbols"),W=g("../internals/object-get-own-property-descriptor"),B=g("../internals/object-define-property"),y=g("../internals/object-define-properties"),V=g("../internals/object-property-is-enumerable"),X=g("../internals/define-built-in"),Y=g("../internals/define-built-in-accessor"),R=g("../internals/shared"),N=g("../internals/shared-key"),H=g("../internals/hidden-keys"),K=g("../internals/uid"),f=g("../internals/well-known-symbol"),F=g("../internals/well-known-symbol-wrapped"),M=g("../internals/well-known-symbol-define"),S=g("../internals/symbol-define-to-primitive"),J=g("../internals/set-to-string-tag"),k=g("../internals/internal-state"),D=g("../internals/array-iteration").forEach,v=N("hidden"),L="Symbol",z="prototype",T=k.set,x=k.getterFor(L),U=Object[z],j=i.Symbol,Q=j&&j[z],O=i.RangeError,E=i.TypeError,P=i.QObject,_=W.f,q=B.f,$=p.f,gg=V.f,Ig=t([].push),Cg=R("symbols"),Ag=R("op-symbols"),ig=R("wks"),eg=!P||!P[z]||!P[z].findChild,tg=function(g,I,C){var A=_(U,I);A&&delete U[I],q(g,I,C),A&&g!==U&&q(U,I,A)},lg=s&&c((function(){return 7!==b(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?tg:q,sg=function(g,I){var C=Cg[g]=b(Q);return T(C,{type:L,tag:g,description:I}),s||(C.description=I),C},og=function(g,I,C){g===U&&og(Ag,I,C),n(g);var A=m(I);return n(C),d(Cg,A)?(C.enumerable?(d(g,v)&&g[v][A]&&(g[v][A]=!1),C=b(C,{enumerable:Z(0,!1)})):(d(g,v)||q(g,v,Z(1,{})),g[v][A]=!0),lg(g,A,C)):q(g,A,C)},cg=function(g,I){n(g);var C=r(I),A=G(C).concat(mg(C));return D(A,(function(I){s&&!e(ag,C,I)||og(g,I,C[I])})),g},dg=function(g,I){return void 0===I?b(g):cg(b(g),I)},ag=function(g){var I=m(g),C=e(gg,this,I);return!(this===U&&d(Cg,I)&&!d(Ag,I))&&(!(C||!d(this,I)||!d(Cg,I)||d(this,v)&&this[v][I])||C)},ng=function(g,I){var C=r(g),A=m(I);if(C!==U||!d(Cg,A)||d(Ag,A)){var i=_(C,A);return!i||!d(Cg,A)||d(C,v)&&C[v][A]||(i.enumerable=!0),i}},rg=function(g){var I=$(r(g)),C=[];return D(I,(function(g){d(Cg,g)||d(H,g)||Ig(C,g)})),C},mg=function(g){var I=g===U,C=$(I?Ag:r(g)),A=[];return D(C,(function(g){!d(Cg,g)||I&&!d(U,g)||Ig(A,Cg[g])})),A};o||(j=function(){if(a(Q,this))throw new E("Symbol is not a constructor");var g=arguments.length&&void 0!==arguments[0]?h(arguments[0]):void 0,I=K(g),C=function(g){this===U&&e(C,Ag,g),d(this,v)&&d(this[v],I)&&(this[v][I]=!1);var A=Z(1,g);try{lg(this,I,A)}catch(i){if(!(i instanceof O))throw i;tg(this,I,A)}};return s&&eg&&lg(U,I,{configurable:!0,set:C}),sg(I,g)},X(Q=j[z],"toString",(function(){return x(this).tag})),X(j,"withoutSetter",(function(g){return sg(K(g),g)})),V.f=ag,B.f=og,y.f=cg,W.f=ng,u.f=p.f=rg,w.f=mg,F.f=function(g){return sg(f(g),g)},s&&(Y(Q,"description",{configurable:!0,get:function(){return x(this).description}}),l||X(U,"propertyIsEnumerable",ag,{unsafe:!0}))),A({global:!0,constructor:!0,wrap:!0,forced:!o,sham:!o},{Symbol:j}),D(G(ig),(function(g){M(g)})),A({target:L,stat:!0,forced:!o},{useSetter:function(){eg=!0},useSimple:function(){eg=!1}}),A({target:"Object",stat:!0,forced:!o,sham:!s},{create:dg,defineProperty:og,defineProperties:cg,getOwnPropertyDescriptor:ng}),A({target:"Object",stat:!0,forced:!o},{getOwnPropertyNames:rg}),S(),J(j,L),H[v]=!0},{"../internals/an-object":227,"../internals/array-iteration":229,"../internals/create-property-descriptor":242,"../internals/define-built-in":245,"../internals/define-built-in-accessor":244,"../internals/descriptors":247,"../internals/export":259,"../internals/fails":260,"../internals/function-call":264,"../internals/function-uncurry-this":268,"../internals/global":274,"../internals/has-own-property":275,"../internals/hidden-keys":276,"../internals/internal-state":282,"../internals/is-pure":290,"../internals/object-create":306,"../internals/object-define-properties":307,"../internals/object-define-property":308,"../internals/object-get-own-property-descriptor":309,"../internals/object-get-own-property-names":311,"../internals/object-get-own-property-names-external":310,"../internals/object-get-own-property-symbols":312,"../internals/object-is-prototype-of":314,"../internals/object-keys":316,"../internals/object-property-is-enumerable":317,"../internals/set-to-string-tag":331,"../internals/shared":334,"../internals/shared-key":332,"../internals/symbol-constructor-detection":336,"../internals/symbol-define-to-primitive":337,"../internals/to-indexed-object":341,"../internals/to-property-key":346,"../internals/to-string":348,"../internals/uid":350,"../internals/well-known-symbol":357,"../internals/well-known-symbol-define":355,"../internals/well-known-symbol-wrapped":356}],380:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/get-built-in"),e=g("../internals/has-own-property"),t=g("../internals/to-string"),l=g("../internals/shared"),s=g("../internals/symbol-registry-detection"),o=l("string-to-symbol-registry"),c=l("symbol-to-string-registry");A({target:"Symbol",stat:!0,forced:!s},{for:function(g){var I=t(g);if(e(o,I))return o[I];var C=i("Symbol")(I);return o[I]=C,c[C]=I,C}})},{"../internals/export":259,"../internals/get-built-in":269,"../internals/has-own-property":275,"../internals/shared":334,"../internals/symbol-registry-detection":338,"../internals/to-string":348}],381:[function(g,I,C){g("../modules/es.symbol.constructor"),g("../modules/es.symbol.for"),g("../modules/es.symbol.key-for"),g("../modules/es.json.stringify"),g("../modules/es.object.get-own-property-symbols")},{"../modules/es.json.stringify":362,"../modules/es.object.get-own-property-symbols":365,"../modules/es.symbol.constructor":379,"../modules/es.symbol.for":380,"../modules/es.symbol.key-for":382}],382:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/has-own-property"),e=g("../internals/is-symbol"),t=g("../internals/try-to-string"),l=g("../internals/shared"),s=g("../internals/symbol-registry-detection"),o=l("symbol-to-string-registry");A({target:"Symbol",stat:!0,forced:!s},{keyFor:function(g){if(!e(g))throw new TypeError(t(g)+" is not a symbol");if(i(o,g))return o[g]}})},{"../internals/export":259,"../internals/has-own-property":275,"../internals/is-symbol":292,"../internals/shared":334,"../internals/symbol-registry-detection":338,"../internals/try-to-string":349}],383:[function(g,I,C){function A(g){return Array.isArray?Array.isArray(g):"[object Array]"===Z(g)}function i(g){return"boolean"==typeof g}function e(g){return null===g}function t(g){return null==g}function l(g){return"number"==typeof g}function s(g){return"string"==typeof g}function o(g){return"symbol"==typeof g}function c(g){return void 0===g}function d(g){return"[object RegExp]"===Z(g)}function a(g){return"object"==typeof g&&null!==g}function n(g){return"[object Date]"===Z(g)}function r(g){return"[object Error]"===Z(g)||g instanceof Error}function m(g){return"function"==typeof g}function h(g){return null===g||"boolean"==typeof g||"number"==typeof g||"string"==typeof g||"symbol"==typeof g||void 0===g}function Z(g){return Object.prototype.toString.call(g)}C.isArray=A,C.isBoolean=i,C.isNull=e,C.isNullOrUndefined=t,C.isNumber=l,C.isString=s,C.isSymbol=o,C.isUndefined=c,C.isRegExp=d,C.isObject=a,C.isDate=n,C.isError=r,C.isFunction=m,C.isPrimitive=h,C.isBuffer=g("buffer").Buffer.isBuffer},{buffer:220}],384:[function(g,I,C){(function(C){(function(){var A=g("elliptic"),i=g("bn.js");I.exports=function(g){return new t(g)};var e={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function t(g){this.curveType=e[g],this.curveType||(this.curveType={name:g}),this.curve=new A.ec(this.curveType.name),this.keys=void 0}function l(g,I,A){Array.isArray(g)||(g=g.toArray());var i=new C(g);if(A&&i.lengthC?I=("rmd160"===g?new s:o(g)).update(I).digest():I.lengthl?I=g(I):I.length=I?g:""+Array(I+1-A.length).join(C)+g},b={s:Z,z:function(g){var I=-g.utcOffset(),C=Math.abs(I),A=Math.floor(C/60),i=C%60;return(I<=0?"+":"-")+Z(A,2,"0")+":"+Z(i,2,"0")},m:function g(I,C){if(I.date()1)return g(t[0])}else{var l=I.name;u[l]=I,i=l}return!A&&i&&(G=i),i||!A&&G},B=function(g,I){if(w(g))return g.clone();var C="object"==typeof I?I:{};return C.date=g,C.args=arguments,new V(C)},y=b;y.l=W,y.i=w,y.w=function(g,I){return B(g,{locale:I.$L,utc:I.$u,x:I.$x,$offset:I.$offset})};var V=function(){function h(g){this.$L=W(g.locale,null,!0),this.parse(g),this.$x=this.$x||g.x||{},this[p]=!0}var Z=h.prototype;return Z.parse=function(g){this.$d=function(g){var I=g.date,C=g.utc;if(null===I)return new Date(NaN);if(y.u(I))return new Date;if(I instanceof Date)return new Date(I);if("string"==typeof I&&!/Z$/i.test(I)){var A=I.match(r);if(A){var i=A[2]-1||0,e=(A[7]||"0").substring(0,3);return C?new Date(Date.UTC(A[1],i,A[3]||1,A[4]||0,A[5]||0,A[6]||0,e)):new Date(A[1],i,A[3]||1,A[4]||0,A[5]||0,A[6]||0,e)}}return new Date(I)}(g),this.init()},Z.init=function(){var g=this.$d;this.$y=g.getFullYear(),this.$M=g.getMonth(),this.$D=g.getDate(),this.$W=g.getDay(),this.$H=g.getHours(),this.$m=g.getMinutes(),this.$s=g.getSeconds(),this.$ms=g.getMilliseconds()},Z.$utils=function(){return y},Z.isValid=function(){return!(this.$d.toString()===n)},Z.isSame=function(g,I){var C=B(g);return this.startOf(I)<=C&&C<=this.endOf(I)},Z.isAfter=function(g,I){return B(g)68?1900:2e3)},l=function(g){return function(I){this[g]=+I}},s=[/[+-]\d\d:?(\d\d)?|Z/,function(g){(this.zone||(this.zone={})).offset=function(g){if(!g)return 0;if("Z"===g)return 0;var I=g.match(/([+-]|\d\d)/g),C=60*I[1]+(+I[2]||0);return 0===C?0:"+"===I[0]?-C:C}(g)}],o=function(g){var I=e[g];return I&&(I.indexOf?I:I.s.concat(I.f))},c=function(g,I){var C,A=e.meridiem;if(A){for(var i=1;i<=24;i+=1)if(g.indexOf(A(i,0,I))>-1){C=i>12;break}}else C=g===(I?"pm":"PM");return C},d={A:[i,function(g){this.afternoon=c(g,!1)}],a:[i,function(g){this.afternoon=c(g,!0)}],S:[/\d/,function(g){this.milliseconds=100*+g}],SS:[C,function(g){this.milliseconds=10*+g}],SSS:[/\d{3}/,function(g){this.milliseconds=+g}],s:[A,l("seconds")],ss:[A,l("seconds")],m:[A,l("minutes")],mm:[A,l("minutes")],H:[A,l("hours")],h:[A,l("hours")],HH:[A,l("hours")],hh:[A,l("hours")],D:[A,l("day")],DD:[C,l("day")],Do:[i,function(g){var I=e.ordinal,C=g.match(/\d+/);if(this.day=C[0],I)for(var A=1;A<=31;A+=1)I(A).replace(/\[|\]/g,"")===g&&(this.day=A)}],M:[A,l("month")],MM:[C,l("month")],MMM:[i,function(g){var I=o("months"),C=(o("monthsShort")||I.map((function(g){return g.slice(0,3)}))).indexOf(g)+1;if(C<1)throw new Error;this.month=C%12||C}],MMMM:[i,function(g){var I=o("months").indexOf(g)+1;if(I<1)throw new Error;this.month=I%12||I}],Y:[/[+-]?\d+/,l("year")],YY:[C,function(g){this.year=t(g)}],YYYY:[/\d{4}/,l("year")],Z:s,ZZ:s};function a(C){var A,i;A=C,i=e&&e.formats;for(var t=(C=A.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(I,C,A){var e=A&&A.toUpperCase();return C||i[A]||g[A]||i[e].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(g,I,C){return I||C.slice(1)}))}))).match(I),l=t.length,s=0;s-1)return new Date(("X"===I?1e3:1)*g);var A=a(I)(g),i=A.year,e=A.month,t=A.day,l=A.hours,s=A.minutes,o=A.seconds,c=A.milliseconds,d=A.zone,n=new Date,r=t||(i||e?1:n.getDate()),m=i||n.getFullYear(),h=0;i&&!e||(h=e>0?e-1:n.getMonth());var Z=l||0,b=s||0,G=o||0,u=c||0;return d?new Date(Date.UTC(m,h,r,Z,b,G,u+60*d.offset*1e3)):C?new Date(Date.UTC(m,h,r,Z,b,G,u)):new Date(m,h,r,Z,b,G,u)}catch(p){return new Date("")}}(I,l,A),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),c&&I!=this.format(l)&&(this.$d=new Date("")),e={}}else if(l instanceof Array)for(var n=l.length,r=1;r<=n;r+=1){t[1]=l[r-1];var m=C.apply(this,t);if(m.isValid()){this.$d=m.$d,this.$L=m.$L,this.init();break}r===n&&(this.$d=new Date(""))}else i.call(this,g)}}},"object"==typeof C&&void 0!==I?I.exports=i():(A="undefined"!=typeof globalThis?globalThis:A||self).dayjs_plugin_customParseFormat=i()},{}],393:[function(g,I,C){var A,i;A=void 0,i=function(){var g="minute",I=/[+-]\d\d(?::?\d\d)?/g,C=/([+-]|\d\d)/g;return function(A,i,e){var t=i.prototype;e.utc=function(g){return new i({date:g,utc:!0,args:arguments})},t.utc=function(I){var C=e(this.toDate(),{locale:this.$L,utc:!0});return I?C.add(this.utcOffset(),g):C},t.local=function(){return e(this.toDate(),{locale:this.$L,utc:!1})};var l=t.parse;t.parse=function(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),l.call(this,g)};var s=t.init;t.init=function(){if(this.$u){var g=this.$d;this.$y=g.getUTCFullYear(),this.$M=g.getUTCMonth(),this.$D=g.getUTCDate(),this.$W=g.getUTCDay(),this.$H=g.getUTCHours(),this.$m=g.getUTCMinutes(),this.$s=g.getUTCSeconds(),this.$ms=g.getUTCMilliseconds()}else s.call(this)};var o=t.utcOffset;t.utcOffset=function(A,i){var e=this.$utils().u;if(e(A))return this.$u?0:e(this.$offset)?o.call(this):this.$offset;if("string"==typeof A&&null===(A=function(g){void 0===g&&(g="");var A=g.match(I);if(!A)return null;var i=(""+A[0]).match(C)||["-",0,0],e=i[0],t=60*+i[1]+ +i[2];return 0===t?0:"+"===e?t:-t}(A)))return this;var t=Math.abs(A)<=16?60*A:A,l=this;if(i)return l.$offset=t,l.$u=0===A,l;if(0!==A){var s=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(l=this.local().add(t+s,g)).$offset=t,l.$x.$localOffset=s}else l=this.utc();return l};var c=t.format;t.format=function(g){var I=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,I)},t.valueOf=function(){var g=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*g},t.isUTC=function(){return!!this.$u},t.toISOString=function(){return this.toDate().toISOString()},t.toString=function(){return this.toDate().toUTCString()};var d=t.toDate;t.toDate=function(g){return"s"===g&&this.$offset?e(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var a=t.diff;t.diff=function(g,I,C){if(g&&this.$u===g.$u)return a.call(this,g,I,C);var A=this.local(),i=e(g).local();return a.call(A,i,I,C)}}},"object"==typeof C&&void 0!==I?I.exports=i():(A="undefined"!=typeof globalThis?globalThis:A||self).dayjs_plugin_utc=i()},{}],394:[function(g,I,C){C.utils=g("./des/utils"),C.Cipher=g("./des/cipher"),C.DES=g("./des/des"),C.CBC=g("./des/cbc"),C.EDE=g("./des/ede")},{"./des/cbc":395,"./des/cipher":396,"./des/des":397,"./des/ede":398,"./des/utils":399}],395:[function(g,I,C){var A=g("minimalistic-assert"),i=g("inherits"),e={};function t(g){A.equal(g.length,8,"Invalid IV length"),this.iv=new Array(8);for(var I=0;I0;A--)I+=this._buffer(g,I),C+=this._flushBuffer(i,C);return I+=this._buffer(g,I),i},i.prototype.final=function(g){var I,C;return g&&(I=this.update(g)),C="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),I?I.concat(C):C},i.prototype._pad=function(g,I){if(0===I)return!1;for(;I>>1];C=e.r28shl(C,l),i=e.r28shl(i,l),e.pc2(C,i,g.keys,t)}},s.prototype._update=function(g,I,C,A){var i=this._desState,t=e.readUInt32BE(g,I),l=e.readUInt32BE(g,I+4);e.ip(t,l,i.tmp,0),t=i.tmp[0],l=i.tmp[1],"encrypt"===this.type?this._encrypt(i,t,l,i.tmp,0):this._decrypt(i,t,l,i.tmp,0),t=i.tmp[0],l=i.tmp[1],e.writeUInt32BE(C,t,A),e.writeUInt32BE(C,l,A+4)},s.prototype._pad=function(g,I){if(!1===this.padding)return!1;for(var C=g.length-I,A=I;A>>0,t=a}e.rip(l,t,A,i)},s.prototype._decrypt=function(g,I,C,A,i){for(var t=C,l=I,s=g.keys.length-2;s>=0;s-=2){var o=g.keys[s],c=g.keys[s+1];e.expand(t,g.tmp,0),o^=g.tmp[0],c^=g.tmp[1];var d=e.substitute(o,c),a=t;t=(l^e.permute(d))>>>0,l=a}e.rip(t,l,A,i)}},{"./cipher":396,"./utils":399,inherits:440,"minimalistic-assert":453}],398:[function(g,I,C){var A=g("minimalistic-assert"),i=g("inherits"),e=g("./cipher"),t=g("./des");function l(g,I){A.equal(I.length,24,"Invalid key length");var C=I.slice(0,8),i=I.slice(8,16),e=I.slice(16,24);this.ciphers="encrypt"===g?[t.create({type:"encrypt",key:C}),t.create({type:"decrypt",key:i}),t.create({type:"encrypt",key:e})]:[t.create({type:"decrypt",key:e}),t.create({type:"encrypt",key:i}),t.create({type:"decrypt",key:C})]}function s(g){e.call(this,g);var I=new l(this.type,this.options.key);this._edeState=I}i(s,e),I.exports=s,s.create=function(g){return new s(g)},s.prototype._update=function(g,I,C,A){var i=this._edeState;i.ciphers[0]._update(g,I,C,A),i.ciphers[1]._update(C,A,C,A),i.ciphers[2]._update(C,A,C,A)},s.prototype._pad=t.prototype._pad,s.prototype._unpad=t.prototype._unpad},{"./cipher":396,"./des":397,inherits:440,"minimalistic-assert":453}],399:[function(g,I,C){C.readUInt32BE=function(g,I){return(g[0+I]<<24|g[1+I]<<16|g[2+I]<<8|g[3+I])>>>0},C.writeUInt32BE=function(g,I,C){g[0+C]=I>>>24,g[1+C]=I>>>16&255,g[2+C]=I>>>8&255,g[3+C]=255&I},C.ip=function(g,I,C,A){for(var i=0,e=0,t=6;t>=0;t-=2){for(var l=0;l<=24;l+=8)i<<=1,i|=I>>>l+t&1;for(l=0;l<=24;l+=8)i<<=1,i|=g>>>l+t&1}for(t=6;t>=0;t-=2){for(l=1;l<=25;l+=8)e<<=1,e|=I>>>l+t&1;for(l=1;l<=25;l+=8)e<<=1,e|=g>>>l+t&1}C[A+0]=i>>>0,C[A+1]=e>>>0},C.rip=function(g,I,C,A){for(var i=0,e=0,t=0;t<4;t++)for(var l=24;l>=0;l-=8)i<<=1,i|=I>>>l+t&1,i<<=1,i|=g>>>l+t&1;for(t=4;t<8;t++)for(l=24;l>=0;l-=8)e<<=1,e|=I>>>l+t&1,e<<=1,e|=g>>>l+t&1;C[A+0]=i>>>0,C[A+1]=e>>>0},C.pc1=function(g,I,C,A){for(var i=0,e=0,t=7;t>=5;t--){for(var l=0;l<=24;l+=8)i<<=1,i|=I>>l+t&1;for(l=0;l<=24;l+=8)i<<=1,i|=g>>l+t&1}for(l=0;l<=24;l+=8)i<<=1,i|=I>>l+t&1;for(t=1;t<=3;t++){for(l=0;l<=24;l+=8)e<<=1,e|=I>>l+t&1;for(l=0;l<=24;l+=8)e<<=1,e|=g>>l+t&1}for(l=0;l<=24;l+=8)e<<=1,e|=g>>l+t&1;C[A+0]=i>>>0,C[A+1]=e>>>0},C.r28shl=function(g,I){return g<>>28-I};var A=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];C.pc2=function(g,I,C,i){for(var e=0,t=0,l=A.length>>>1,s=0;s>>A[s]&1;for(s=l;s>>A[s]&1;C[i+0]=e>>>0,C[i+1]=t>>>0},C.expand=function(g,I,C){var A=0,i=0;A=(1&g)<<5|g>>>27;for(var e=23;e>=15;e-=4)A<<=6,A|=g>>>e&63;for(e=11;e>=3;e-=4)i|=g>>>e&63,i<<=6;i|=(31&g)<<1|g>>>31,I[C+0]=A>>>0,I[C+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];C.substitute=function(g,I){for(var C=0,A=0;A<4;A++)C<<=4,C|=i[64*A+(g>>>18-6*A&63)];for(A=0;A<4;A++)C<<=4,C|=i[256+64*A+(I>>>18-6*A&63)];return C>>>0};var e=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];C.permute=function(g){for(var I=0,C=0;C>>e[C]&1;return I>>>0},C.padSplit=function(g,I,C){for(var A=g.toString(2);A.lengthg;)C.ishrn(1);if(C.isEven()&&C.iadd(l),C.testn(1)||C.iadd(s),I.cmp(s)){if(!I.cmp(o))for(;C.mod(c).cmp(d);)C.iadd(n)}else for(;C.mod(e).cmp(a);)C.iadd(n);if(h(r=C.shrn(1))&&h(C)&&Z(r)&&Z(C)&&t.test(r)&&t.test(C))return C}}},{"bn.js":404,"miller-rabin":451,randombytes:475}],403:[function(g,I,C){I.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],404:[function(g,I,C){arguments[4][184][0].apply(C,arguments)},{buffer:188,dup:184}],405:[function(g,I,C){var A=C;A.version=g("../package.json").version,A.utils=g("./elliptic/utils"),A.rand=g("brorand"),A.curve=g("./elliptic/curve"),A.curves=g("./elliptic/curves"),A.ec=g("./elliptic/ec"),A.eddsa=g("./elliptic/eddsa")},{"../package.json":421,"./elliptic/curve":408,"./elliptic/curves":411,"./elliptic/ec":412,"./elliptic/eddsa":415,"./elliptic/utils":419,brorand:187}],406:[function(g,I,C){var A=g("bn.js"),i=g("../utils"),e=i.getNAF,t=i.getJSF,l=i.assert;function s(g,I){this.type=g,this.p=new A(I.p,16),this.red=I.prime?A.red(I.prime):A.mont(this.p),this.zero=new A(0).toRed(this.red),this.one=new A(1).toRed(this.red),this.two=new A(2).toRed(this.red),this.n=I.n&&new A(I.n,16),this.g=I.g&&this.pointFromJSON(I.g,I.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var C=this.n&&this.p.div(this.n);!C||C.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function o(g,I){this.curve=g,this.type=I,this.precomputed=null}I.exports=s,s.prototype.point=function(){throw new Error("Not implemented")},s.prototype.validate=function(){throw new Error("Not implemented")},s.prototype._fixedNafMul=function(g,I){l(g.precomputed);var C=g._getDoubles(),A=e(I,1,this._bitLength),i=(1<=t;c--)s=(s<<1)+A[c];o.push(s)}for(var d=this.jpoint(null,null,null),a=this.jpoint(null,null,null),n=i;n>0;n--){for(t=0;t=0;o--){for(var c=0;o>=0&&0===t[o];o--)c++;if(o>=0&&c++,s=s.dblp(c),o<0)break;var d=t[o];l(0!==d),s="affine"===g.type?d>0?s.mixedAdd(i[d-1>>1]):s.mixedAdd(i[-d-1>>1].neg()):d>0?s.add(i[d-1>>1]):s.add(i[-d-1>>1].neg())}return"affine"===g.type?s.toP():s},s.prototype._wnafMulAdd=function(g,I,C,A,i){var l,s,o,c=this._wnafT1,d=this._wnafT2,a=this._wnafT3,n=0;for(l=0;l=1;l-=2){var m=l-1,h=l;if(1===c[m]&&1===c[h]){var Z=[I[m],null,null,I[h]];0===I[m].y.cmp(I[h].y)?(Z[1]=I[m].add(I[h]),Z[2]=I[m].toJ().mixedAdd(I[h].neg())):0===I[m].y.cmp(I[h].y.redNeg())?(Z[1]=I[m].toJ().mixedAdd(I[h]),Z[2]=I[m].add(I[h].neg())):(Z[1]=I[m].toJ().mixedAdd(I[h]),Z[2]=I[m].toJ().mixedAdd(I[h].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],G=t(C[m],C[h]);for(n=Math.max(G[0].length,n),a[m]=new Array(n),a[h]=new Array(n),s=0;s=0;l--){for(var B=0;l>=0;){var y=!0;for(s=0;s=0&&B++,w=w.dblp(B),l<0)break;for(s=0;s0?o=d[s][V-1>>1]:V<0&&(o=d[s][-V-1>>1].neg()),w="affine"===o.type?w.mixedAdd(o):w.add(o))}}for(l=0;l=Math.ceil((g.bitLength()+1)/I.step)},o.prototype._getDoubles=function(g,I){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var C=[this],A=this,i=0;i":""},o.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},o.prototype._extDbl=function(){var g=this.x.redSqr(),I=this.y.redSqr(),C=this.z.redSqr();C=C.redIAdd(C);var A=this.curve._mulA(g),i=this.x.redAdd(this.y).redSqr().redISub(g).redISub(I),e=A.redAdd(I),t=e.redSub(C),l=A.redSub(I),s=i.redMul(t),o=e.redMul(l),c=i.redMul(l),d=t.redMul(e);return this.curve.point(s,o,d,c)},o.prototype._projDbl=function(){var g,I,C,A,i,e,t=this.x.redAdd(this.y).redSqr(),l=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=(A=this.curve._mulA(l)).redAdd(s);this.zOne?(g=t.redSub(l).redSub(s).redMul(o.redSub(this.curve.two)),I=o.redMul(A.redSub(s)),C=o.redSqr().redSub(o).redSub(o)):(i=this.z.redSqr(),e=o.redSub(i).redISub(i),g=t.redSub(l).redISub(s).redMul(e),I=o.redMul(A.redSub(s)),C=o.redMul(e))}else A=l.redAdd(s),i=this.curve._mulC(this.z).redSqr(),e=A.redSub(i).redSub(i),g=this.curve._mulC(t.redISub(A)).redMul(e),I=this.curve._mulC(A).redMul(l.redISub(s)),C=A.redMul(e);return this.curve.point(g,I,C)},o.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},o.prototype._extAdd=function(g){var I=this.y.redSub(this.x).redMul(g.y.redSub(g.x)),C=this.y.redAdd(this.x).redMul(g.y.redAdd(g.x)),A=this.t.redMul(this.curve.dd).redMul(g.t),i=this.z.redMul(g.z.redAdd(g.z)),e=C.redSub(I),t=i.redSub(A),l=i.redAdd(A),s=C.redAdd(I),o=e.redMul(t),c=l.redMul(s),d=e.redMul(s),a=t.redMul(l);return this.curve.point(o,c,a,d)},o.prototype._projAdd=function(g){var I,C,A=this.z.redMul(g.z),i=A.redSqr(),e=this.x.redMul(g.x),t=this.y.redMul(g.y),l=this.curve.d.redMul(e).redMul(t),s=i.redSub(l),o=i.redAdd(l),c=this.x.redAdd(this.y).redMul(g.x.redAdd(g.y)).redISub(e).redISub(t),d=A.redMul(s).redMul(c);return this.curve.twisted?(I=A.redMul(o).redMul(t.redSub(this.curve._mulA(e))),C=s.redMul(o)):(I=A.redMul(o).redMul(t.redSub(e)),C=this.curve._mulC(s).redMul(o)),this.curve.point(d,I,C)},o.prototype.add=function(g){return this.isInfinity()?g:g.isInfinity()?this:this.curve.extended?this._extAdd(g):this._projAdd(g)},o.prototype.mul=function(g){return this._hasDoubles(g)?this.curve._fixedNafMul(this,g):this.curve._wnafMul(this,g)},o.prototype.mulAdd=function(g,I,C){return this.curve._wnafMulAdd(1,[this,I],[g,C],2,!1)},o.prototype.jmulAdd=function(g,I,C){return this.curve._wnafMulAdd(1,[this,I],[g,C],2,!0)},o.prototype.normalize=function(){if(this.zOne)return this;var g=this.z.redInvm();return this.x=this.x.redMul(g),this.y=this.y.redMul(g),this.t&&(this.t=this.t.redMul(g)),this.z=this.curve.one,this.zOne=!0,this},o.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},o.prototype.getX=function(){return this.normalize(),this.x.fromRed()},o.prototype.getY=function(){return this.normalize(),this.y.fromRed()},o.prototype.eq=function(g){return this===g||0===this.getX().cmp(g.getX())&&0===this.getY().cmp(g.getY())},o.prototype.eqXToP=function(g){var I=g.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(I))return!0;for(var C=g.clone(),A=this.curve.redN.redMul(this.z);;){if(C.iadd(this.curve.n),C.cmp(this.curve.p)>=0)return!1;if(I.redIAdd(A),0===this.x.cmp(I))return!0}},o.prototype.toP=o.prototype.normalize,o.prototype.mixedAdd=o.prototype.add},{"../utils":419,"./base":406,"bn.js":420,inherits:440}],408:[function(g,I,C){var A=C;A.base=g("./base"),A.short=g("./short"),A.mont=g("./mont"),A.edwards=g("./edwards")},{"./base":406,"./edwards":407,"./mont":409,"./short":410}],409:[function(g,I,C){var A=g("bn.js"),i=g("inherits"),e=g("./base"),t=g("../utils");function l(g){e.call(this,"mont",g),this.a=new A(g.a,16).toRed(this.red),this.b=new A(g.b,16).toRed(this.red),this.i4=new A(4).toRed(this.red).redInvm(),this.two=new A(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function s(g,I,C){e.BasePoint.call(this,g,"projective"),null===I&&null===C?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new A(I,16),this.z=new A(C,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(l,e),I.exports=l,l.prototype.validate=function(g){var I=g.normalize().x,C=I.redSqr(),A=C.redMul(I).redAdd(C.redMul(this.a)).redAdd(I);return 0===A.redSqrt().redSqr().cmp(A)},i(s,e.BasePoint),l.prototype.decodePoint=function(g,I){return this.point(t.toArray(g,I),1)},l.prototype.point=function(g,I){return new s(this,g,I)},l.prototype.pointFromJSON=function(g){return s.fromJSON(this,g)},s.prototype.precompute=function(){},s.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},s.fromJSON=function(g,I){return new s(g,I[0],I[1]||g.one)},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},s.prototype.dbl=function(){var g=this.x.redAdd(this.z).redSqr(),I=this.x.redSub(this.z).redSqr(),C=g.redSub(I),A=g.redMul(I),i=C.redMul(I.redAdd(this.curve.a24.redMul(C)));return this.curve.point(A,i)},s.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.diffAdd=function(g,I){var C=this.x.redAdd(this.z),A=this.x.redSub(this.z),i=g.x.redAdd(g.z),e=g.x.redSub(g.z).redMul(C),t=i.redMul(A),l=I.z.redMul(e.redAdd(t).redSqr()),s=I.x.redMul(e.redISub(t).redSqr());return this.curve.point(l,s)},s.prototype.mul=function(g){for(var I=g.clone(),C=this,A=this.curve.point(null,null),i=this,e=[];0!==I.cmpn(0);I.iushrn(1))e.push(I.andln(1));for(var t=e.length-1;t>=0;t--)0===e[t]?(C=C.diffAdd(A,i),A=A.dbl()):(A=C.diffAdd(A,i),C=C.dbl());return A},s.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.eq=function(g){return 0===this.getX().cmp(g.getX())},s.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},s.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":419,"./base":406,"bn.js":420,inherits:440}],410:[function(g,I,C){var A=g("../utils"),i=g("bn.js"),e=g("inherits"),t=g("./base"),l=A.assert;function s(g){t.call(this,"short",g),this.a=new i(g.a,16).toRed(this.red),this.b=new i(g.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(g),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function o(g,I,C,A){t.BasePoint.call(this,g,"affine"),null===I&&null===C?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(I,16),this.y=new i(C,16),A&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(g,I,C,A){t.BasePoint.call(this,g,"jacobian"),null===I&&null===C&&null===A?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(I,16),this.y=new i(C,16),this.z=new i(A,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}e(s,t),I.exports=s,s.prototype._getEndomorphism=function(g){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var I,C;if(g.beta)I=new i(g.beta,16).toRed(this.red);else{var A=this._getEndoRoots(this.p);I=(I=A[0].cmp(A[1])<0?A[0]:A[1]).toRed(this.red)}if(g.lambda)C=new i(g.lambda,16);else{var e=this._getEndoRoots(this.n);0===this.g.mul(e[0]).x.cmp(this.g.x.redMul(I))?C=e[0]:(C=e[1],l(0===this.g.mul(C).x.cmp(this.g.x.redMul(I))))}return{beta:I,lambda:C,basis:g.basis?g.basis.map((function(g){return{a:new i(g.a,16),b:new i(g.b,16)}})):this._getEndoBasis(C)}}},s.prototype._getEndoRoots=function(g){var I=g===this.p?this.red:i.mont(g),C=new i(2).toRed(I).redInvm(),A=C.redNeg(),e=new i(3).toRed(I).redNeg().redSqrt().redMul(C);return[A.redAdd(e).fromRed(),A.redSub(e).fromRed()]},s.prototype._getEndoBasis=function(g){for(var I,C,A,e,t,l,s,o,c,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),a=g,n=this.n.clone(),r=new i(1),m=new i(0),h=new i(0),Z=new i(1),b=0;0!==a.cmpn(0);){var G=n.div(a);o=n.sub(G.mul(a)),c=h.sub(G.mul(r));var u=Z.sub(G.mul(m));if(!A&&o.cmp(d)<0)I=s.neg(),C=r,A=o.neg(),e=c;else if(A&&2==++b)break;s=o,n=a,a=o,h=r,r=c,Z=m,m=u}t=o.neg(),l=c;var p=A.sqr().add(e.sqr());return t.sqr().add(l.sqr()).cmp(p)>=0&&(t=I,l=C),A.negative&&(A=A.neg(),e=e.neg()),t.negative&&(t=t.neg(),l=l.neg()),[{a:A,b:e},{a:t,b:l}]},s.prototype._endoSplit=function(g){var I=this.endo.basis,C=I[0],A=I[1],i=A.b.mul(g).divRound(this.n),e=C.b.neg().mul(g).divRound(this.n),t=i.mul(C.a),l=e.mul(A.a),s=i.mul(C.b),o=e.mul(A.b);return{k1:g.sub(t).sub(l),k2:s.add(o).neg()}},s.prototype.pointFromX=function(g,I){(g=new i(g,16)).red||(g=g.toRed(this.red));var C=g.redSqr().redMul(g).redIAdd(g.redMul(this.a)).redIAdd(this.b),A=C.redSqrt();if(0!==A.redSqr().redSub(C).cmp(this.zero))throw new Error("invalid point");var e=A.fromRed().isOdd();return(I&&!e||!I&&e)&&(A=A.redNeg()),this.point(g,A)},s.prototype.validate=function(g){if(g.inf)return!0;var I=g.x,C=g.y,A=this.a.redMul(I),i=I.redSqr().redMul(I).redIAdd(A).redIAdd(this.b);return 0===C.redSqr().redISub(i).cmpn(0)},s.prototype._endoWnafMulAdd=function(g,I,C){for(var A=this._endoWnafT1,i=this._endoWnafT2,e=0;e":""},o.prototype.isInfinity=function(){return this.inf},o.prototype.add=function(g){if(this.inf)return g;if(g.inf)return this;if(this.eq(g))return this.dbl();if(this.neg().eq(g))return this.curve.point(null,null);if(0===this.x.cmp(g.x))return this.curve.point(null,null);var I=this.y.redSub(g.y);0!==I.cmpn(0)&&(I=I.redMul(this.x.redSub(g.x).redInvm()));var C=I.redSqr().redISub(this.x).redISub(g.x),A=I.redMul(this.x.redSub(C)).redISub(this.y);return this.curve.point(C,A)},o.prototype.dbl=function(){if(this.inf)return this;var g=this.y.redAdd(this.y);if(0===g.cmpn(0))return this.curve.point(null,null);var I=this.curve.a,C=this.x.redSqr(),A=g.redInvm(),i=C.redAdd(C).redIAdd(C).redIAdd(I).redMul(A),e=i.redSqr().redISub(this.x.redAdd(this.x)),t=i.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,t)},o.prototype.getX=function(){return this.x.fromRed()},o.prototype.getY=function(){return this.y.fromRed()},o.prototype.mul=function(g){return g=new i(g,16),this.isInfinity()?this:this._hasDoubles(g)?this.curve._fixedNafMul(this,g):this.curve.endo?this.curve._endoWnafMulAdd([this],[g]):this.curve._wnafMul(this,g)},o.prototype.mulAdd=function(g,I,C){var A=[this,I],i=[g,C];return this.curve.endo?this.curve._endoWnafMulAdd(A,i):this.curve._wnafMulAdd(1,A,i,2)},o.prototype.jmulAdd=function(g,I,C){var A=[this,I],i=[g,C];return this.curve.endo?this.curve._endoWnafMulAdd(A,i,!0):this.curve._wnafMulAdd(1,A,i,2,!0)},o.prototype.eq=function(g){return this===g||this.inf===g.inf&&(this.inf||0===this.x.cmp(g.x)&&0===this.y.cmp(g.y))},o.prototype.neg=function(g){if(this.inf)return this;var I=this.curve.point(this.x,this.y.redNeg());if(g&&this.precomputed){var C=this.precomputed,A=function(g){return g.neg()};I.precomputed={naf:C.naf&&{wnd:C.naf.wnd,points:C.naf.points.map(A)},doubles:C.doubles&&{step:C.doubles.step,points:C.doubles.points.map(A)}}}return I},o.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},e(c,t.BasePoint),s.prototype.jpoint=function(g,I,C){return new c(this,g,I,C)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var g=this.z.redInvm(),I=g.redSqr(),C=this.x.redMul(I),A=this.y.redMul(I).redMul(g);return this.curve.point(C,A)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(g){if(this.isInfinity())return g;if(g.isInfinity())return this;var I=g.z.redSqr(),C=this.z.redSqr(),A=this.x.redMul(I),i=g.x.redMul(C),e=this.y.redMul(I.redMul(g.z)),t=g.y.redMul(C.redMul(this.z)),l=A.redSub(i),s=e.redSub(t);if(0===l.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var o=l.redSqr(),c=o.redMul(l),d=A.redMul(o),a=s.redSqr().redIAdd(c).redISub(d).redISub(d),n=s.redMul(d.redISub(a)).redISub(e.redMul(c)),r=this.z.redMul(g.z).redMul(l);return this.curve.jpoint(a,n,r)},c.prototype.mixedAdd=function(g){if(this.isInfinity())return g.toJ();if(g.isInfinity())return this;var I=this.z.redSqr(),C=this.x,A=g.x.redMul(I),i=this.y,e=g.y.redMul(I).redMul(this.z),t=C.redSub(A),l=i.redSub(e);if(0===t.cmpn(0))return 0!==l.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=t.redSqr(),o=s.redMul(t),c=C.redMul(s),d=l.redSqr().redIAdd(o).redISub(c).redISub(c),a=l.redMul(c.redISub(d)).redISub(i.redMul(o)),n=this.z.redMul(t);return this.curve.jpoint(d,a,n)},c.prototype.dblp=function(g){if(0===g)return this;if(this.isInfinity())return this;if(!g)return this.dbl();var I;if(this.curve.zeroA||this.curve.threeA){var C=this;for(I=0;I=0)return!1;if(C.redIAdd(i),0===this.x.cmp(C))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":419,"./base":406,"bn.js":420,inherits:440}],411:[function(g,I,C){var A,i=C,e=g("hash.js"),t=g("./curve"),l=g("./utils").assert;function s(g){"short"===g.type?this.curve=new t.short(g):"edwards"===g.type?this.curve=new t.edwards(g):this.curve=new t.mont(g),this.g=this.curve.g,this.n=this.curve.n,this.hash=g.hash,l(this.g.validate(),"Invalid curve"),l(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(g,I){Object.defineProperty(i,g,{configurable:!0,enumerable:!0,get:function(){var C=new s(I);return Object.defineProperty(i,g,{configurable:!0,enumerable:!0,value:C}),C}})}i.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:e.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:e.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:e.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:e.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:e.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:e.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:e.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{A=g("./precomputed/secp256k1")}catch(c){A=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:e.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",A]})},{"./curve":408,"./precomputed/secp256k1":418,"./utils":419,"hash.js":426}],412:[function(g,I,C){var A=g("bn.js"),i=g("hmac-drbg"),e=g("../utils"),t=g("../curves"),l=g("brorand"),s=e.assert,o=g("./key"),c=g("./signature");function d(g){if(!(this instanceof d))return new d(g);"string"==typeof g&&(s(Object.prototype.hasOwnProperty.call(t,g),"Unknown curve "+g),g=t[g]),g instanceof t.PresetCurve&&(g={curve:g}),this.curve=g.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=g.curve.g,this.g.precompute(g.curve.n.bitLength()+1),this.hash=g.hash||g.curve.hash}I.exports=d,d.prototype.keyPair=function(g){return new o(this,g)},d.prototype.keyFromPrivate=function(g,I){return o.fromPrivate(this,g,I)},d.prototype.keyFromPublic=function(g,I){return o.fromPublic(this,g,I)},d.prototype.genKeyPair=function(g){g||(g={});for(var I=new i({hash:this.hash,pers:g.pers,persEnc:g.persEnc||"utf8",entropy:g.entropy||l(this.hash.hmacStrength),entropyEnc:g.entropy&&g.entropyEnc||"utf8",nonce:this.n.toArray()}),C=this.n.byteLength(),e=this.n.sub(new A(2));;){var t=new A(I.generate(C));if(!(t.cmp(e)>0))return t.iaddn(1),this.keyFromPrivate(t)}},d.prototype._truncateToN=function(g,I){var C=8*g.byteLength()-this.n.bitLength();return C>0&&(g=g.ushrn(C)),!I&&g.cmp(this.n)>=0?g.sub(this.n):g},d.prototype.sign=function(g,I,C,e){"object"==typeof C&&(e=C,C=null),e||(e={}),I=this.keyFromPrivate(I,C),g=this._truncateToN(new A(g,16));for(var t=this.n.byteLength(),l=I.getPrivate().toArray("be",t),s=g.toArray("be",t),o=new i({hash:this.hash,entropy:l,nonce:s,pers:e.pers,persEnc:e.persEnc||"utf8"}),d=this.n.sub(new A(1)),a=0;;a++){var n=e.k?e.k(a):new A(o.generate(this.n.byteLength()));if(!((n=this._truncateToN(n,!0)).cmpn(1)<=0||n.cmp(d)>=0)){var r=this.g.mul(n);if(!r.isInfinity()){var m=r.getX(),h=m.umod(this.n);if(0!==h.cmpn(0)){var Z=n.invm(this.n).mul(h.mul(I.getPrivate()).iadd(g));if(0!==(Z=Z.umod(this.n)).cmpn(0)){var b=(r.getY().isOdd()?1:0)|(0!==m.cmp(h)?2:0);return e.canonical&&Z.cmp(this.nh)>0&&(Z=this.n.sub(Z),b^=1),new c({r:h,s:Z,recoveryParam:b})}}}}}},d.prototype.verify=function(g,I,C,i){g=this._truncateToN(new A(g,16)),C=this.keyFromPublic(C,i);var e=(I=new c(I,"hex")).r,t=I.s;if(e.cmpn(1)<0||e.cmp(this.n)>=0)return!1;if(t.cmpn(1)<0||t.cmp(this.n)>=0)return!1;var l,s=t.invm(this.n),o=s.mul(g).umod(this.n),d=s.mul(e).umod(this.n);return this.curve._maxwellTrick?!(l=this.g.jmulAdd(o,C.getPublic(),d)).isInfinity()&&l.eqXToP(e):!(l=this.g.mulAdd(o,C.getPublic(),d)).isInfinity()&&0===l.getX().umod(this.n).cmp(e)},d.prototype.recoverPubKey=function(g,I,C,i){s((3&C)===C,"The recovery param is more than two bits"),I=new c(I,i);var e=this.n,t=new A(g),l=I.r,o=I.s,d=1&C,a=C>>1;if(l.cmp(this.curve.p.umod(this.curve.n))>=0&&a)throw new Error("Unable to find sencond key candinate");l=a?this.curve.pointFromX(l.add(this.curve.n),d):this.curve.pointFromX(l,d);var n=I.r.invm(e),r=e.sub(t).mul(n).umod(e),m=o.mul(n).umod(e);return this.g.mulAdd(r,l,m)},d.prototype.getKeyRecoveryParam=function(g,I,C,A){if(null!==(I=new c(I,A)).recoveryParam)return I.recoveryParam;for(var i=0;i<4;i++){var e;try{e=this.recoverPubKey(g,I,i)}catch(t){continue}if(e.eq(C))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":411,"../utils":419,"./key":413,"./signature":414,"bn.js":420,brorand:187,"hmac-drbg":438}],413:[function(g,I,C){var A=g("bn.js"),i=g("../utils").assert;function e(g,I){this.ec=g,this.priv=null,this.pub=null,I.priv&&this._importPrivate(I.priv,I.privEnc),I.pub&&this._importPublic(I.pub,I.pubEnc)}I.exports=e,e.fromPublic=function(g,I,C){return I instanceof e?I:new e(g,{pub:I,pubEnc:C})},e.fromPrivate=function(g,I,C){return I instanceof e?I:new e(g,{priv:I,privEnc:C})},e.prototype.validate=function(){var g=this.getPublic();return g.isInfinity()?{result:!1,reason:"Invalid public key"}:g.validate()?g.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},e.prototype.getPublic=function(g,I){return"string"==typeof g&&(I=g,g=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),I?this.pub.encode(I,g):this.pub},e.prototype.getPrivate=function(g){return"hex"===g?this.priv.toString(16,2):this.priv},e.prototype._importPrivate=function(g,I){this.priv=new A(g,I||16),this.priv=this.priv.umod(this.ec.curve.n)},e.prototype._importPublic=function(g,I){if(g.x||g.y)return"mont"===this.ec.curve.type?i(g.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(g.x&&g.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(g.x,g.y));this.pub=this.ec.curve.decodePoint(g,I)},e.prototype.derive=function(g){return g.validate()||i(g.validate(),"public point not validated"),g.mul(this.priv).getX()},e.prototype.sign=function(g,I,C){return this.ec.sign(g,this,I,C)},e.prototype.verify=function(g,I){return this.ec.verify(g,I,this)},e.prototype.inspect=function(){return""}},{"../utils":419,"bn.js":420}],414:[function(g,I,C){var A=g("bn.js"),i=g("../utils"),e=i.assert;function t(g,I){if(g instanceof t)return g;this._importDER(g,I)||(e(g.r&&g.s,"Signature without r or s"),this.r=new A(g.r,16),this.s=new A(g.s,16),void 0===g.recoveryParam?this.recoveryParam=null:this.recoveryParam=g.recoveryParam)}function l(){this.place=0}function s(g,I){var C=g[I.place++];if(!(128&C))return C;var A=15&C;if(0===A||A>4)return!1;for(var i=0,e=0,t=I.place;e>>=0;return!(i<=127)&&(I.place=t,i)}function o(g){for(var I=0,C=g.length-1;!g[I]&&!(128&g[I+1])&&I>>3);for(g.push(128|C);--C;)g.push(I>>>(C<<3)&255);g.push(I)}}I.exports=t,t.prototype._importDER=function(g,I){g=i.toArray(g,I);var C=new l;if(48!==g[C.place++])return!1;var e=s(g,C);if(!1===e)return!1;if(e+C.place!==g.length)return!1;if(2!==g[C.place++])return!1;var t=s(g,C);if(!1===t)return!1;var o=g.slice(C.place,t+C.place);if(C.place+=t,2!==g[C.place++])return!1;var c=s(g,C);if(!1===c)return!1;if(g.length!==c+C.place)return!1;var d=g.slice(C.place,c+C.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new A(o),this.s=new A(d),this.recoveryParam=null,!0},t.prototype.toDER=function(g){var I=this.r.toArray(),C=this.s.toArray();for(128&I[0]&&(I=[0].concat(I)),128&C[0]&&(C=[0].concat(C)),I=o(I),C=o(C);!(C[0]||128&C[1]);)C=C.slice(1);var A=[2];c(A,I.length),(A=A.concat(I)).push(2),c(A,C.length);var e=A.concat(C),t=[48];return c(t,e.length),t=t.concat(e),i.encode(t,g)}},{"../utils":419,"bn.js":420}],415:[function(g,I,C){var A=g("hash.js"),i=g("../curves"),e=g("../utils"),t=e.assert,l=e.parseBytes,s=g("./key"),o=g("./signature");function c(g){if(t("ed25519"===g,"only tested with ed25519 so far"),!(this instanceof c))return new c(g);g=i[g].curve,this.curve=g,this.g=g.g,this.g.precompute(g.n.bitLength()+1),this.pointClass=g.point().constructor,this.encodingLength=Math.ceil(g.n.bitLength()/8),this.hash=A.sha512}I.exports=c,c.prototype.sign=function(g,I){g=l(g);var C=this.keyFromSecret(I),A=this.hashInt(C.messagePrefix(),g),i=this.g.mul(A),e=this.encodePoint(i),t=this.hashInt(e,C.pubBytes(),g).mul(C.priv()),s=A.add(t).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:e})},c.prototype.verify=function(g,I,C){g=l(g),I=this.makeSignature(I);var A=this.keyFromPublic(C),i=this.hashInt(I.Rencoded(),A.pubBytes(),g),e=this.g.mul(I.S());return I.R().add(A.pub().mul(i)).eq(e)},c.prototype.hashInt=function(){for(var g=this.hash(),I=0;I(i>>1)-1?(i>>1)-s:s,e.isubn(l)):l=0,A[t]=l,e.iushrn(1)}return A}function s(g,I){var C=[[],[]];g=g.clone(),I=I.clone();for(var A,i=0,e=0;g.cmpn(-i)>0||I.cmpn(-e)>0;){var t,l,s=g.andln(3)+i&3,o=I.andln(3)+e&3;3===s&&(s=-1),3===o&&(o=-1),t=1&s?3!=(A=g.andln(7)+i&7)&&5!==A||2!==o?s:-s:0,C[0].push(t),l=1&o?3!=(A=I.andln(7)+e&7)&&5!==A||2!==s?o:-o:0,C[1].push(l),2*i===t+1&&(i=1-i),2*e===l+1&&(e=1-e),g.iushrn(1),I.iushrn(1)}return C}function o(g,I,C){var A="_"+I;g.prototype[I]=function(){return void 0!==this[A]?this[A]:this[A]=C.call(this)}}function c(g){return"string"==typeof g?A.toArray(g,"hex"):g}function d(g){return new i(g,"hex","le")}A.assert=e,A.toArray=t.toArray,A.zero2=t.zero2,A.toHex=t.toHex,A.encode=t.encode,A.getNAF=l,A.getJSF=s,A.cachedProperty=o,A.parseBytes=c,A.intFromLE=d},{"bn.js":420,"minimalistic-assert":453,"minimalistic-crypto-utils":454}],420:[function(g,I,C){arguments[4][184][0].apply(C,arguments)},{buffer:188,dup:184}],421:[function(g,I,C){I.exports={name:"elliptic",version:"6.5.4",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}},{}],422:[function(g,I,C){var A=Object.create||B,i=Object.keys||y,e=Function.prototype.bind||V;function t(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=A(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}I.exports=t,t.EventEmitter=t,t.prototype._events=void 0,t.prototype._maxListeners=void 0;var l,s=10;try{var o={};Object.defineProperty&&Object.defineProperty(o,"x",{value:0}),l=0===o.x}catch(X){l=!1}function c(g){return void 0===g._maxListeners?t.defaultMaxListeners:g._maxListeners}function d(g,I,C){if(I)g.call(C);else for(var A=g.length,i=w(g,A),e=0;e0&&l.length>e){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(I)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=g,s.type=I,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=t[I]=C,++g._eventsCount;return g}function Z(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var g=new Array(arguments.length),I=0;I1&&(I=arguments[1]),I instanceof Error)throw I;var s=new Error('Unhandled "error" event. ('+I+")");throw s.context=I,s}if(!(C=t[g]))return!1;var o="function"==typeof C;switch(A=arguments.length){case 1:d(C,o,this);break;case 2:a(C,o,this,arguments[1]);break;case 3:n(C,o,this,arguments[1],arguments[2]);break;case 4:r(C,o,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(A-1),e=1;e=0;t--)if(C[t]===I||C[t].listener===I){l=C[t].listener,e=t;break}if(e<0)return this;0===e?C.shift():p(C,e),1===C.length&&(i[g]=C[0]),i.removeListener&&this.emit("removeListener",g,l||I)}return this},t.prototype.removeAllListeners=function(g){var I,C,e;if(!(C=this._events))return this;if(!C.removeListener)return 0===arguments.length?(this._events=A(null),this._eventsCount=0):C[g]&&(0==--this._eventsCount?this._events=A(null):delete C[g]),this;if(0===arguments.length){var t,l=i(C);for(e=0;e=0;e--)this.removeListener(g,I[e]);return this},t.prototype.listeners=function(g){return G(this,g,!0)},t.prototype.rawListeners=function(g){return G(this,g,!1)},t.listenerCount=function(g,I){return"function"==typeof g.listenerCount?g.listenerCount(I):u.call(g,I)},t.prototype.listenerCount=u,t.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],423:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("md5.js");function e(g,I,C,e){if(A.isBuffer(g)||(g=A.from(g,"binary")),I&&(A.isBuffer(I)||(I=A.from(I,"binary")),8!==I.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var t=C/8,l=A.alloc(t),s=A.alloc(e||0),o=A.alloc(0);t>0||e>0;){var c=new i;c.update(o),c.update(g),I&&c.update(I),o=c.digest();var d=0;if(t>0){var a=l.length-t;d=Math.min(t,o.length),o.copy(l,a,0,d),t-=d}if(d0){var n=s.length-e,r=Math.min(e,o.length-d);o.copy(s,n,d,d+r),e-=r}}return o.fill(0),{key:l,iv:s}}I.exports=e},{"md5.js":450,"safe-buffer":494}],424:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.CsvParserStream=C.ParserOptions=C.parseFile=C.parseStream=C.parseString=C.parse=C.FormatterOptions=C.CsvFormatterStream=C.writeToPath=C.writeToString=C.writeToBuffer=C.writeToStream=C.write=C.format=void 0;var A=g("@fast-csv/format");Object.defineProperty(C,"format",{enumerable:!0,get:function(){return A.format}}),Object.defineProperty(C,"write",{enumerable:!0,get:function(){return A.write}}),Object.defineProperty(C,"writeToStream",{enumerable:!0,get:function(){return A.writeToStream}}),Object.defineProperty(C,"writeToBuffer",{enumerable:!0,get:function(){return A.writeToBuffer}}),Object.defineProperty(C,"writeToString",{enumerable:!0,get:function(){return A.writeToString}}),Object.defineProperty(C,"writeToPath",{enumerable:!0,get:function(){return A.writeToPath}}),Object.defineProperty(C,"CsvFormatterStream",{enumerable:!0,get:function(){return A.CsvFormatterStream}}),Object.defineProperty(C,"FormatterOptions",{enumerable:!0,get:function(){return A.FormatterOptions}});var i=g("@fast-csv/parse");Object.defineProperty(C,"parse",{enumerable:!0,get:function(){return i.parse}}),Object.defineProperty(C,"parseString",{enumerable:!0,get:function(){return i.parseString}}),Object.defineProperty(C,"parseStream",{enumerable:!0,get:function(){return i.parseStream}}),Object.defineProperty(C,"parseFile",{enumerable:!0,get:function(){return i.parseFile}}),Object.defineProperty(C,"ParserOptions",{enumerable:!0,get:function(){return i.ParserOptions}}),Object.defineProperty(C,"CsvParserStream",{enumerable:!0,get:function(){return i.CsvParserStream}})},{"@fast-csv/format":151,"@fast-csv/parse":155}],425:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("readable-stream").Transform;function e(g,I){if(!A.isBuffer(g)&&"string"!=typeof g)throw new TypeError(I+" must be a string or a buffer")}function t(g){i.call(this),this._block=A.allocUnsafe(g),this._blockSize=g,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}g("inherits")(t,i),t.prototype._transform=function(g,I,C){var A=null;try{this.update(g,I)}catch(i){A=i}C(A)},t.prototype._flush=function(g){var I=null;try{this.push(this.digest())}catch(C){I=C}g(I)},t.prototype.update=function(g,I){if(e(g,"Data"),this._finalized)throw new Error("Digest already called");A.isBuffer(g)||(g=A.from(g,I));for(var C=this._block,i=0;this._blockOffset+g.length-i>=this._blockSize;){for(var t=this._blockOffset;t0;++l)this._length[l]+=s,(s=this._length[l]/4294967296|0)>0&&(this._length[l]-=4294967296*s);return this},t.prototype._update=function(){throw new Error("_update is not implemented")},t.prototype.digest=function(g){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var I=this._digest();void 0!==g&&(I=I.toString(g)),this._block.fill(0),this._blockOffset=0;for(var C=0;C<4;++C)this._length[C]=0;return I},t.prototype._digest=function(){throw new Error("_digest is not implemented")},I.exports=t},{inherits:440,"readable-stream":491,"safe-buffer":494}],426:[function(g,I,C){var A=C;A.utils=g("./hash/utils"),A.common=g("./hash/common"),A.sha=g("./hash/sha"),A.ripemd=g("./hash/ripemd"),A.hmac=g("./hash/hmac"),A.sha1=A.sha.sha1,A.sha256=A.sha.sha256,A.sha224=A.sha.sha224,A.sha384=A.sha.sha384,A.sha512=A.sha.sha512,A.ripemd160=A.ripemd.ripemd160},{"./hash/common":427,"./hash/hmac":428,"./hash/ripemd":429,"./hash/sha":430,"./hash/utils":437}],427:[function(g,I,C){var A=g("./utils"),i=g("minimalistic-assert");function e(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}C.BlockHash=e,e.prototype.update=function(g,I){if(g=A.toArray(g,I),this.pending?this.pending=this.pending.concat(g):this.pending=g,this.pendingTotal+=g.length,this.pending.length>=this._delta8){var C=(g=this.pending).length%this._delta8;this.pending=g.slice(g.length-C,g.length),0===this.pending.length&&(this.pending=null),g=A.join32(g,0,g.length-C,this.endian);for(var i=0;i>>24&255,A[i++]=g>>>16&255,A[i++]=g>>>8&255,A[i++]=255&g}else for(A[i++]=255&g,A[i++]=g>>>8&255,A[i++]=g>>>16&255,A[i++]=g>>>24&255,A[i++]=0,A[i++]=0,A[i++]=0,A[i++]=0,e=8;ethis.blockSize&&(g=(new this.Hash).update(g).digest()),i(g.length<=this.blockSize);for(var I=g.length;I>>3}function d(g){return A(g,17)^A(g,19)^g>>>10}C.ft_1=i,C.ch32=e,C.maj32=t,C.p32=l,C.s0_256=s,C.s1_256=o,C.g0_256=c,C.g1_256=d},{"../utils":437}],437:[function(g,I,C){var A=g("minimalistic-assert"),i=g("inherits");function e(g,I){return 55296==(64512&g.charCodeAt(I))&&!(I<0||I+1>=g.length)&&56320==(64512&g.charCodeAt(I+1))}function t(g,I){if(Array.isArray(g))return g.slice();if(!g)return[];var C=[];if("string"==typeof g)if(I){if("hex"===I)for((g=g.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(g="0"+g),i=0;i>6|192,C[A++]=63&t|128):e(g,i)?(t=65536+((1023&t)<<10)+(1023&g.charCodeAt(++i)),C[A++]=t>>18|240,C[A++]=t>>12&63|128,C[A++]=t>>6&63|128,C[A++]=63&t|128):(C[A++]=t>>12|224,C[A++]=t>>6&63|128,C[A++]=63&t|128)}else for(i=0;i>>24|g>>>8&65280|g<<8&16711680|(255&g)<<24)>>>0}function o(g,I){for(var C="",A=0;A>>0}return t}function n(g,I){for(var C=new Array(4*g.length),A=0,i=0;A>>24,C[i+1]=e>>>16&255,C[i+2]=e>>>8&255,C[i+3]=255&e):(C[i+3]=e>>>24,C[i+2]=e>>>16&255,C[i+1]=e>>>8&255,C[i]=255&e)}return C}function r(g,I){return g>>>I|g<<32-I}function m(g,I){return g<>>32-I}function h(g,I){return g+I>>>0}function Z(g,I,C){return g+I+C>>>0}function b(g,I,C,A){return g+I+C+A>>>0}function G(g,I,C,A,i){return g+I+C+A+i>>>0}function u(g,I,C,A){var i=g[I],e=A+g[I+1]>>>0,t=(e>>0,g[I+1]=e}function p(g,I,C,A){return(I+A>>>0>>0}function w(g,I,C,A){return I+A>>>0}function W(g,I,C,A,i,e,t,l){var s=0,o=I;return s+=(o=o+A>>>0)>>0)>>0)>>0}function B(g,I,C,A,i,e,t,l){return I+A+e+l>>>0}function y(g,I,C,A,i,e,t,l,s,o){var c=0,d=I;return c+=(d=d+A>>>0)>>0)>>0)>>0)>>0}function V(g,I,C,A,i,e,t,l,s,o){return I+A+e+l+o>>>0}function X(g,I,C){return(I<<32-C|g>>>C)>>>0}function Y(g,I,C){return(g<<32-C|I>>>C)>>>0}function R(g,I,C){return g>>>C}function N(g,I,C){return(g<<32-C|I>>>C)>>>0}C.inherits=i,C.toArray=t,C.toHex=l,C.htonl=s,C.toHex32=o,C.zero2=c,C.zero8=d,C.join32=a,C.split32=n,C.rotr32=r,C.rotl32=m,C.sum32=h,C.sum32_3=Z,C.sum32_4=b,C.sum32_5=G,C.sum64=u,C.sum64_hi=p,C.sum64_lo=w,C.sum64_4_hi=W,C.sum64_4_lo=B,C.sum64_5_hi=y,C.sum64_5_lo=V,C.rotr64_hi=X,C.rotr64_lo=Y,C.shr64_hi=R,C.shr64_lo=N},{inherits:440,"minimalistic-assert":453}],438:[function(g,I,C){var A=g("hash.js"),i=g("minimalistic-crypto-utils"),e=g("minimalistic-assert");function t(g){if(!(this instanceof t))return new t(g);this.hash=g.hash,this.predResist=!!g.predResist,this.outLen=this.hash.outSize,this.minEntropy=g.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var I=i.toArray(g.entropy,g.entropyEnc||"hex"),C=i.toArray(g.nonce,g.nonceEnc||"hex"),A=i.toArray(g.pers,g.persEnc||"hex");e(I.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(I,C,A)}I.exports=t,t.prototype._init=function(g,I,C){var A=g.concat(I).concat(C);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(g.concat(C||[])),this._reseed=1},t.prototype.generate=function(g,I,C,A){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof I&&(A=C,C=I,I=null),C&&(C=i.toArray(C,A||"hex"),this._update(C));for(var e=[];e.length */ C.read=function(g,I,C,A,i){var e,t,l=8*i-A-1,s=(1<>1,c=-7,d=C?i-1:0,a=C?-1:1,n=g[I+d];for(d+=a,e=n&(1<<-c)-1,n>>=-c,c+=l;c>0;e=256*e+g[I+d],d+=a,c-=8);for(t=e&(1<<-c)-1,e>>=-c,c+=A;c>0;t=256*t+g[I+d],d+=a,c-=8);if(0===e)e=1-o;else{if(e===s)return t?NaN:1/0*(n?-1:1);t+=Math.pow(2,A),e-=o}return(n?-1:1)*t*Math.pow(2,e-A)},C.write=function(g,I,C,A,i,e){var t,l,s,o=8*e-i-1,c=(1<>1,a=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,n=A?0:e-1,r=A?1:-1,m=I<0||0===I&&1/I<0?1:0;for(I=Math.abs(I),isNaN(I)||I===1/0?(l=isNaN(I)?1:0,t=c):(t=Math.floor(Math.log(I)/Math.LN2),I*(s=Math.pow(2,-t))<1&&(t--,s*=2),(I+=t+d>=1?a/s:a*Math.pow(2,1-d))*s>=2&&(t++,s/=2),t+d>=c?(l=0,t=c):t+d>=1?(l=(I*s-1)*Math.pow(2,i),t+=d):(l=I*Math.pow(2,d-1)*Math.pow(2,i),t=0));i>=8;g[C+n]=255&l,n+=r,l/=256,i-=8);for(t=t<0;g[C+n]=255&t,n+=r,t/=256,o-=8);g[C+n-r]|=128*m}},{}],440:[function(g,I,C){"function"==typeof Object.create?I.exports=function(g,I){I&&(g.super_=I,g.prototype=Object.create(I.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}))}:I.exports=function(g,I){if(I){g.super_=I;var C=function(){};C.prototype=I.prototype,g.prototype=new C,g.prototype.constructor=g}}},{}],441:[function(g,I,C){(function(A,i,e,t,l,s,o,c){(function(){ /*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */ !function(g){"object"==typeof C&&void 0!==I?I.exports=g():("undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:this).JSZip=g()}((function(){return function I(C,A,i){function e(l,s){if(!A[l]){if(!C[l]){var o="function"==typeof g&&g;if(!s&&o)return o(l,!0);if(t)return t(l,!0);var c=new Error("Cannot find module '"+l+"'");throw c.code="MODULE_NOT_FOUND",c}var d=A[l]={exports:{}};C[l][0].call(d.exports,(function(g){return e(C[l][1][g]||g)}),d,d.exports,I,C,A,i)}return A[l].exports}for(var t="function"==typeof g&&g,l=0;l>2,l=(3&I)<<4|C>>4,s=1>6:64,o=2>4,C=(15&t)<<4|(l=e.indexOf(g.charAt(o++)))>>2,A=(3&l)<<6|(s=e.indexOf(g.charAt(o++))),a[c++]=I,64!==l&&(a[c++]=C),64!==s&&(a[c++]=A);return a}},{"./support":30,"./utils":32}],2:[function(g,I,C){var A=g("./external"),i=g("./stream/DataWorker"),e=g("./stream/Crc32Probe"),t=g("./stream/DataLengthProbe");function l(g,I,C,A,i){this.compressedSize=g,this.uncompressedSize=I,this.crc32=C,this.compression=A,this.compressedContent=i}l.prototype={getContentWorker:function(){var g=new i(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new t("data_length")),I=this;return g.on("end",(function(){if(this.streamInfo.data_length!==I.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),g},getCompressedWorker:function(){return new i(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,I,C){return g.pipe(new e).pipe(new t("uncompressedSize")).pipe(I.compressWorker(C)).pipe(new t("compressedSize")).withStreamInfo("compression",I)},I.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(g,I,C){var A=g("./stream/GenericWorker");C.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},C.DEFLATE=g("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(g,I,C){var A=g("./utils"),i=function(){for(var g,I=[],C=0;C<256;C++){g=C;for(var A=0;A<8;A++)g=1&g?3988292384^g>>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I){return void 0!==g&&g.length?"string"!==A.getTypeOf(g)?function(g,I,C,A){var e=i,t=A+C;g^=-1;for(var l=A;l>>8^e[255&(g^I[l])];return~g}(0|I,g,g.length,0):function(g,I,C,A){var e=i,t=A+C;g^=-1;for(var l=A;l>>8^e[255&(g^I.charCodeAt(l))];return~g}(0|I,g,g.length,0):0}},{"./utils":32}],5:[function(g,I,C){C.base64=!1,C.binary=!1,C.dir=!1,C.createFolders=!0,C.date=null,C.compression=null,C.compressionOptions=null,C.comment=null,C.unixPermissions=null,C.dosPermissions=null},{}],6:[function(g,I,C){var A=null;A="undefined"!=typeof Promise?Promise:g("lie"),I.exports={Promise:A}},{lie:37}],7:[function(g,I,C){var A="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=g("pako"),e=g("./utils"),t=g("./stream/GenericWorker"),l=A?"uint8array":"array";function s(g,I){t.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=I,this.meta={}}C.magic="\b\0",e.inherits(s,t),s.prototype.processChunk=function(g){this.meta=g.meta,null===this._pako&&this._createPako(),this._pako.push(e.transformTo(l,g.data),!1)},s.prototype.flush=function(){t.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},s.prototype.cleanUp=function(){t.prototype.cleanUp.call(this),this._pako=null},s.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(I){g.push({data:I,meta:g.meta})}},C.compressWorker=function(g){return new s("Deflate",g)},C.uncompressWorker=function(){return new s("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(g,I,C){function A(g,I){var C,A="";for(C=0;C>>=8;return A}function i(g,I,C,i,t,c){var d,a,n=g.file,r=g.compression,m=c!==l.utf8encode,h=e.transformTo("string",c(n.name)),Z=e.transformTo("string",l.utf8encode(n.name)),b=n.comment,G=e.transformTo("string",c(b)),u=e.transformTo("string",l.utf8encode(b)),p=Z.length!==n.name.length,w=u.length!==b.length,W="",B="",y="",V=n.dir,X=n.date,Y={crc32:0,compressedSize:0,uncompressedSize:0};I&&!C||(Y.crc32=g.crc32,Y.compressedSize=g.compressedSize,Y.uncompressedSize=g.uncompressedSize);var R=0;I&&(R|=8),m||!p&&!w||(R|=2048);var N,H,K,f=0,F=0;V&&(f|=16),"UNIX"===t?(F=798,f|=(N=n.unixPermissions,H=V,K=N,N||(K=H?16893:33204),(65535&K)<<16)):(F=20,f|=function(g){return 63&(g||0)}(n.dosPermissions)),d=X.getUTCHours(),d<<=6,d|=X.getUTCMinutes(),d<<=5,d|=X.getUTCSeconds()/2,a=X.getUTCFullYear()-1980,a<<=4,a|=X.getUTCMonth()+1,a<<=5,a|=X.getUTCDate(),p&&(B=A(1,1)+A(s(h),4)+Z,W+="up"+A(B.length,2)+B),w&&(y=A(1,1)+A(s(G),4)+u,W+="uc"+A(y.length,2)+y);var M="";return M+="\n\0",M+=A(R,2),M+=r.magic,M+=A(d,2),M+=A(a,2),M+=A(Y.crc32,4),M+=A(Y.compressedSize,4),M+=A(Y.uncompressedSize,4),M+=A(h.length,2),M+=A(W.length,2),{fileRecord:o.LOCAL_FILE_HEADER+M+h+W,dirRecord:o.CENTRAL_FILE_HEADER+A(F,2)+M+A(G.length,2)+"\0\0\0\0"+A(f,4)+A(i,4)+h+W+G}}var e=g("../utils"),t=g("../stream/GenericWorker"),l=g("../utf8"),s=g("../crc32"),o=g("../signature");function c(g,I,C,A){t.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=I,this.zipPlatform=C,this.encodeFileName=A,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}e.inherits(c,t),c.prototype.push=function(g){var I=g.meta.percent||0,C=this.entriesCount,A=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,t.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:C?(I+100*(C-A-1))/C:100}}))},c.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var I=this.streamFiles&&!g.file.dir;if(I){var C=i(g,I,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:C.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(g){this.accumulate=!1;var I,C=this.streamFiles&&!g.file.dir,e=i(g,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(e.dirRecord),C)this.push({data:(I=g,o.DATA_DESCRIPTOR+A(I.crc32,4)+A(I.compressedSize,4)+A(I.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:e.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var g=this.bytesWritten,I=0;I=this.index;I--)C=(C<<8)+this.byteAt(I);return this.index+=g,C},readString:function(g){return A.transformTo("string",this.readData(g))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var g=this.readInt(4);return new Date(Date.UTC(1980+(g>>25&127),(g>>21&15)-1,g>>16&31,g>>11&31,g>>5&63,(31&g)<<1))}},I.exports=i},{"../utils":32}],19:[function(g,I,C){var A=g("./Uint8ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(g,I,C){var A=g("./DataReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.byteAt=function(g){return this.data.charCodeAt(this.zero+g)},i.prototype.lastIndexOfSignature=function(g){return this.data.lastIndexOf(g)-this.zero},i.prototype.readAndCheckSignature=function(g){return g===this.readData(4)},i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./DataReader":18}],21:[function(g,I,C){var A=g("./ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){if(this.checkOffset(g),0===g)return new Uint8Array(0);var I=this.data.subarray(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(g,I,C){var A=g("../utils"),i=g("../support"),e=g("./ArrayReader"),t=g("./StringReader"),l=g("./NodeBufferReader"),s=g("./Uint8ArrayReader");I.exports=function(g){var I=A.getTypeOf(g);return A.checkSupport(I),"string"!==I||i.uint8array?"nodebuffer"===I?new l(g):i.uint8array?new s(A.transformTo("uint8array",g)):new e(A.transformTo("array",g)):new t(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(g,I,C){C.LOCAL_FILE_HEADER="PK",C.CENTRAL_FILE_HEADER="PK",C.CENTRAL_DIRECTORY_END="PK",C.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",C.ZIP64_CENTRAL_DIRECTORY_END="PK",C.DATA_DESCRIPTOR="PK\b"},{}],24:[function(g,I,C){var A=g("./GenericWorker"),i=g("../utils");function e(g){A.call(this,"ConvertWorker to "+g),this.destType=g}i.inherits(e,A),e.prototype.processChunk=function(g){this.push({data:i.transformTo(this.destType,g.data),meta:g.meta})},I.exports=e},{"../utils":32,"./GenericWorker":28}],25:[function(g,I,C){var A=g("./GenericWorker"),i=g("../crc32");function e(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g("../utils").inherits(e,A),e.prototype.processChunk=function(g){this.streamInfo.crc32=i(g.data,this.streamInfo.crc32||0),this.push(g)},I.exports=e},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataLengthProbe for "+g),this.propName=g,this.withStreamInfo(g,0)}A.inherits(e,i),e.prototype.processChunk=function(g){if(g){var I=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=I+g.data.length}i.prototype.processChunk.call(this,g)},I.exports=e},{"../utils":32,"./GenericWorker":28}],27:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataWorker");var I=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,g.then((function(g){I.dataIsReady=!0,I.data=g,I.max=g&&g.length||0,I.type=A.getTypeOf(g),I.isPaused||I._tickAndRepeat()}),(function(g){I.error(g)}))}A.inherits(e,i),e.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},e.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},e.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},e.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var g=null,I=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":g=this.data.substring(this.index,I);break;case"uint8array":g=this.data.subarray(this.index,I);break;case"array":case"nodebuffer":g=this.data.slice(this.index,I)}return this.index=I,this.push({data:g,meta:{percent:this.max?this.index/this.max*100:0}})},I.exports=e},{"../utils":32,"./GenericWorker":28}],28:[function(g,I,C){function A(g){this.name=g||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}A.prototype={push:function(g){this.emit("data",g)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(g){this.emit("error",g)}return!0},error:function(g){return!this.isFinished&&(this.isPaused?this.generatedError=g:(this.isFinished=!0,this.emit("error",g),this.previous&&this.previous.error(g),this.cleanUp()),!0)},on:function(g,I){return this._listeners[g].push(I),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(g,I){if(this._listeners[g])for(var C=0;C "+g:g}},I.exports=A},{}],29:[function(g,I,C){var A=g("../utils"),i=g("./ConvertWorker"),t=g("./GenericWorker"),l=g("../base64"),s=g("../support"),o=g("../external"),c=null;if(s.nodestream)try{c=g("../nodejs/NodejsStreamOutputAdapter")}catch(n){}function d(g,I){return new o.Promise((function(C,i){var t=[],s=g._internalType,o=g._outputType,c=g._mimeType;g.on("data",(function(g,C){t.push(g),I&&I(C)})).on("error",(function(g){t=[],i(g)})).on("end",(function(){try{var g=function(g,I,C){switch(g){case"blob":return A.newBlob(A.transformTo("arraybuffer",I),C);case"base64":return l.encode(I);default:return A.transformTo(g,I)}}(o,function(g,I){var C,A=0,i=null,t=0;for(C=0;C>>6:(C<65536?I[t++]=224|C>>>12:(I[t++]=240|C>>>18,I[t++]=128|C>>>12&63),I[t++]=128|C>>>6&63),I[t++]=128|63&C);return I}(g)},C.utf8decode=function(g){return i.nodebuffer?A.transformTo("nodebuffer",g).toString("utf-8"):function(g){var I,C,i,e,t=g.length,s=new Array(2*t);for(I=C=0;I>10&1023,s[C++]=56320|1023&i)}return s.length!==C&&(s.subarray?s=s.subarray(0,C):s.length=C),A.applyFromCharCode(s)}(g=A.transformTo(i.uint8array?"uint8array":"array",g))},A.inherits(o,t),o.prototype.processChunk=function(g){var I=A.transformTo(i.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var e=I;(I=new Uint8Array(e.length+this.leftOver.length)).set(this.leftOver,0),I.set(e,this.leftOver.length)}else I=this.leftOver.concat(I);this.leftOver=null}var t=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+l[g[C]]>I?C:I}(I),s=I;t!==I.length&&(i.uint8array?(s=I.subarray(0,t),this.leftOver=I.subarray(t,I.length)):(s=I.slice(0,t),this.leftOver=I.slice(t,I.length))),this.push({data:C.utf8decode(s),meta:g.meta})},o.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:C.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},C.Utf8DecodeWorker=o,A.inherits(c,t),c.prototype.processChunk=function(g){this.push({data:C.utf8encode(g.data),meta:g.meta})},C.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(g,I,C){var A=g("./support"),i=g("./base64"),e=g("./nodejsUtils"),t=g("./external");function l(g){return g}function s(g,I){for(var C=0;C>8;this.dir=!!(16&this.externalFileAttributes),0==g&&(this.dosPermissions=63&this.externalFileAttributes),3==g&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=A(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var I,C,A,i=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4>>6:(C<65536?I[t++]=224|C>>>12:(I[t++]=240|C>>>18,I[t++]=128|C>>>12&63),I[t++]=128|C>>>6&63),I[t++]=128|63&C);return I},C.buf2binstring=function(g){return s(g,g.length)},C.binstring2buf=function(g){for(var I=new A.Buf8(g.length),C=0,i=I.length;C>10&1023,o[A++]=56320|1023&i)}return s(o,A)},C.utf8border=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+t[g[C]]>I?C:I}},{"./common":41}],43:[function(g,I,C){I.exports=function(g,I,C,A){for(var i=65535&g,e=g>>>16&65535,t=0;0!==C;){for(C-=t=2e3>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I,C,i){var e=A,t=i+C;g^=-1;for(var l=i;l>>8^e[255&(g^I[l])];return~g}},{}],46:[function(g,I,C){var A,i=g("../utils/common"),e=g("./trees"),t=g("./adler32"),l=g("./crc32"),s=g("./messages"),o=0,c=4,d=0,a=-2,n=-1,r=4,m=2,h=8,Z=9,b=286,G=30,u=19,p=2*b+1,w=15,W=3,B=258,y=B+W+1,V=42,X=113,Y=1,R=2,N=3,H=4;function K(g,I){return g.msg=s[I],I}function f(g){return(g<<1)-(4g.avail_out&&(C=g.avail_out),0!==C&&(i.arraySet(g.output,I.pending_buf,I.pending_out,C,g.next_out),g.next_out+=C,I.pending_out+=C,g.total_out+=C,g.avail_out-=C,I.pending-=C,0===I.pending&&(I.pending_out=0))}function S(g,I){e._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,I),g.block_start=g.strstart,M(g.strm)}function J(g,I){g.pending_buf[g.pending++]=I}function k(g,I){g.pending_buf[g.pending++]=I>>>8&255,g.pending_buf[g.pending++]=255&I}function D(g,I){var C,A,i=g.max_chain_length,e=g.strstart,t=g.prev_length,l=g.nice_match,s=g.strstart>g.w_size-y?g.strstart-(g.w_size-y):0,o=g.window,c=g.w_mask,d=g.prev,a=g.strstart+B,n=o[e+t-1],r=o[e+t];g.prev_length>=g.good_match&&(i>>=2),l>g.lookahead&&(l=g.lookahead);do{if(o[(C=I)+t]===r&&o[C+t-1]===n&&o[C]===o[e]&&o[++C]===o[e+1]){e+=2,C++;do{}while(o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&o[++e]===o[++C]&&es&&0!=--i);return t<=g.lookahead?t:g.lookahead}function v(g){var I,C,A,e,s,o,c,d,a,n,r=g.w_size;do{if(e=g.window_size-g.lookahead-g.strstart,g.strstart>=r+(r-y)){for(i.arraySet(g.window,g.window,r,r,0),g.match_start-=r,g.strstart-=r,g.block_start-=r,I=C=g.hash_size;A=g.head[--I],g.head[I]=r<=A?A-r:0,--C;);for(I=C=r;A=g.prev[--I],g.prev[I]=r<=A?A-r:0,--C;);e+=r}if(0===g.strm.avail_in)break;if(o=g.strm,c=g.window,d=g.strstart+g.lookahead,n=void 0,(a=e)<(n=o.avail_in)&&(n=a),C=0===n?0:(o.avail_in-=n,i.arraySet(c,o.input,o.next_in,n,d),1===o.state.wrap?o.adler=t(o.adler,c,n,d):2===o.state.wrap&&(o.adler=l(o.adler,c,n,d)),o.next_in+=n,o.total_in+=n,n),g.lookahead+=C,g.lookahead+g.insert>=W)for(s=g.strstart-g.insert,g.ins_h=g.window[s],g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W)if(A=e._tr_tally(g,g.strstart-g.match_start,g.match_length-W),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=W){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W&&g.match_length<=g.prev_length){for(i=g.strstart+g.lookahead-W,A=e._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-W),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=i&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(C=g.pending_buf_size-5);;){if(g.lookahead<=1){if(v(g),0===g.lookahead&&I===o)return Y;if(0===g.lookahead)break}g.strstart+=g.lookahead,g.lookahead=0;var A=g.block_start+C;if((0===g.strstart||g.strstart>=A)&&(g.lookahead=g.strstart-A,g.strstart=A,S(g,!1),0===g.strm.avail_out))return Y;if(g.strstart-g.block_start>=g.w_size-y&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===c?(S(g,!0),0===g.strm.avail_out?N:H):(g.strstart>g.block_start&&(S(g,!1),g.strm.avail_out),Y)})),new T(4,4,8,4,L),new T(4,5,16,8,L),new T(4,6,32,32,L),new T(4,4,16,16,z),new T(8,16,32,32,z),new T(8,16,128,128,z),new T(8,32,128,256,z),new T(32,128,258,1024,z),new T(32,258,258,4096,z)],C.deflateInit=function(g,I){return Q(g,I,h,15,8,0)},C.deflateInit2=Q,C.deflateReset=j,C.deflateResetKeep=U,C.deflateSetHeader=function(g,I){return g&&g.state?2!==g.state.wrap?a:(g.state.gzhead=I,d):a},C.deflate=function(g,I){var C,i,t,s;if(!g||!g.state||5>8&255),J(i,i.gzhead.time>>16&255),J(i,i.gzhead.time>>24&255),J(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),J(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(J(i,255&i.gzhead.extra.length),J(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(g.adler=l(g.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(J(i,0),J(i,0),J(i,0),J(i,0),J(i,0),J(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),J(i,3),i.status=X);else{var n=h+(i.w_bits-8<<4)<<8;n|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(n|=32),n+=31-n%31,i.status=X,k(i,n),0!==i.strstart&&(k(i,g.adler>>>16),k(i,65535&g.adler)),g.adler=1}if(69===i.status)if(i.gzhead.extra){for(t=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),M(g),t=i.pending,i.pending!==i.pending_buf_size));)J(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),M(g),t=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindext&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),M(g),t=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindext&&(g.adler=l(g.adler,i.pending_buf,i.pending-t,t)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&M(g),i.pending+2<=i.pending_buf_size&&(J(i,255&g.adler),J(i,g.adler>>8&255),g.adler=0,i.status=X)):i.status=X),0!==i.pending){if(M(g),0===g.avail_out)return i.last_flush=-1,d}else if(0===g.avail_in&&f(I)<=f(C)&&I!==c)return K(g,-5);if(666===i.status&&0!==g.avail_in)return K(g,-5);if(0!==g.avail_in||0!==i.lookahead||I!==o&&666!==i.status){var r=2===i.strategy?function(g,I){for(var C;;){if(0===g.lookahead&&(v(g),0===g.lookahead)){if(I===o)return Y;break}if(g.match_length=0,C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===c?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):3===i.strategy?function(g,I){for(var C,A,i,t,l=g.window;;){if(g.lookahead<=B){if(v(g),g.lookahead<=B&&I===o)return Y;if(0===g.lookahead)break}if(g.match_length=0,g.lookahead>=W&&0g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=W?(C=e._tr_tally(g,1,g.match_length-W),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===c?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):A[i.level].func(i,I);if(r!==N&&r!==H||(i.status=666),r===Y||r===N)return 0===g.avail_out&&(i.last_flush=-1),d;if(r===R&&(1===I?e._tr_align(i):5!==I&&(e._tr_stored_block(i,0,0,!1),3===I&&(F(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),M(g),0===g.avail_out))return i.last_flush=-1,d}return I!==c?d:i.wrap<=0?1:(2===i.wrap?(J(i,255&g.adler),J(i,g.adler>>8&255),J(i,g.adler>>16&255),J(i,g.adler>>24&255),J(i,255&g.total_in),J(i,g.total_in>>8&255),J(i,g.total_in>>16&255),J(i,g.total_in>>24&255)):(k(i,g.adler>>>16),k(i,65535&g.adler)),M(g),0=C.w_size&&(0===l&&(F(C.head),C.strstart=0,C.block_start=0,C.insert=0),n=new i.Buf8(C.w_size),i.arraySet(n,I,r-C.w_size,C.w_size,0),I=n,r=C.w_size),s=g.avail_in,o=g.next_in,c=g.input,g.avail_in=r,g.next_in=0,g.input=I,v(C);C.lookahead>=W;){for(A=C.strstart,e=C.lookahead-(W-1);C.ins_h=(C.ins_h<>>=u=G>>>24,r-=u,0==(u=G>>>16&255))V[e++]=65535&G;else{if(!(16&u)){if(!(64&u)){G=m[(65535&G)+(n&(1<>>=u,r-=u),r<15&&(n+=y[A++]<>>=u=G>>>24,r-=u,!(16&(u=G>>>16&255))){if(!(64&u)){G=h[(65535&G)+(n&(1<>>=u,r-=u,(u=e-t)>3,n&=(1<<(r-=p<<3))-1,g.next_in=A,g.next_out=e,g.avail_in=A>>24&255)+(g>>>8&65280)+((65280&g)<<8)+((255&g)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Z(g){var I;return g&&g.state?(I=g.state,g.total_in=g.total_out=I.total=0,g.msg="",I.wrap&&(g.adler=1&I.wrap),I.mode=a,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new A.Buf32(n),I.distcode=I.distdyn=new A.Buf32(r),I.sane=1,I.back=-1,c):d}function b(g){var I;return g&&g.state?((I=g.state).wsize=0,I.whave=0,I.wnext=0,Z(g)):d}function G(g,I){var C,A;return g&&g.state?(A=g.state,I<0?(C=0,I=-I):(C=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15=t.wsize?(A.arraySet(t.window,I,C-t.wsize,t.wsize,0),t.wnext=0,t.whave=t.wsize):(i<(e=t.wsize-t.wnext)&&(e=i),A.arraySet(t.window,I,C-i,e,t.wnext),(i-=e)?(A.arraySet(t.window,I,C-i,i,0),t.wnext=i,t.whave=t.wsize):(t.wnext+=e,t.wnext===t.wsize&&(t.wnext=0),t.whave>>8&255,C.check=e(C.check,v,2,0),p=u=0,C.mode=2;break}if(C.flags=0,C.head&&(C.head.done=!1),!(1&C.wrap)||(((255&u)<<8)+(u>>8))%31){g.msg="incorrect header check",C.mode=30;break}if(8!=(15&u)){g.msg="unknown compression method",C.mode=30;break}if(p-=4,M=8+(15&(u>>>=4)),0===C.wbits)C.wbits=M;else if(M>C.wbits){g.msg="invalid window size",C.mode=30;break}C.dmax=1<>8&1),512&C.flags&&(v[0]=255&u,v[1]=u>>>8&255,C.check=e(C.check,v,2,0)),p=u=0,C.mode=3;case 3:for(;p<32;){if(0===b)break g;b--,u+=n[h++]<>>8&255,v[2]=u>>>16&255,v[3]=u>>>24&255,C.check=e(C.check,v,4,0)),p=u=0,C.mode=4;case 4:for(;p<16;){if(0===b)break g;b--,u+=n[h++]<>8),512&C.flags&&(v[0]=255&u,v[1]=u>>>8&255,C.check=e(C.check,v,2,0)),p=u=0,C.mode=5;case 5:if(1024&C.flags){for(;p<16;){if(0===b)break g;b--,u+=n[h++]<>>8&255,C.check=e(C.check,v,2,0)),p=u=0}else C.head&&(C.head.extra=null);C.mode=6;case 6:if(1024&C.flags&&(b<(V=C.length)&&(V=b),V&&(C.head&&(M=C.head.extra_len-C.length,C.head.extra||(C.head.extra=new Array(C.head.extra_len)),A.arraySet(C.head.extra,n,h,V,M)),512&C.flags&&(C.check=e(C.check,n,V,h)),b-=V,h+=V,C.length-=V),C.length))break g;C.length=0,C.mode=7;case 7:if(2048&C.flags){if(0===b)break g;for(V=0;M=n[h+V++],C.head&&M&&C.length<65536&&(C.head.name+=String.fromCharCode(M)),M&&V>9&1,C.head.done=!0),g.adler=C.check=0,C.mode=12;break;case 10:for(;p<32;){if(0===b)break g;b--,u+=n[h++]<>>=7&p,p-=7&p,C.mode=27;break}for(;p<3;){if(0===b)break g;b--,u+=n[h++]<>>=1)){case 0:C.mode=14;break;case 1:if(B(C),C.mode=20,6!==I)break;u>>>=2,p-=2;break g;case 2:C.mode=17;break;case 3:g.msg="invalid block type",C.mode=30}u>>>=2,p-=2;break;case 14:for(u>>>=7&p,p-=7&p;p<32;){if(0===b)break g;b--,u+=n[h++]<>>16^65535)){g.msg="invalid stored block lengths",C.mode=30;break}if(C.length=65535&u,p=u=0,C.mode=15,6===I)break g;case 15:C.mode=16;case 16:if(V=C.length){if(b>>=5,p-=5,C.ndist=1+(31&u),u>>>=5,p-=5,C.ncode=4+(15&u),u>>>=4,p-=4,286>>=3,p-=3}for(;C.have<19;)C.lens[L[C.have++]]=0;if(C.lencode=C.lendyn,C.lenbits=7,J={bits:C.lenbits},S=l(0,C.lens,0,19,C.lencode,0,C.work,J),C.lenbits=J.bits,S){g.msg="invalid code lengths set",C.mode=30;break}C.have=0,C.mode=19;case 19:for(;C.have>>16&255,H=65535&D,!((R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>>=R,p-=R,C.lens[C.have++]=H;else{if(16===H){for(k=R+2;p>>=R,p-=R,0===C.have){g.msg="invalid bit length repeat",C.mode=30;break}M=C.lens[C.have-1],V=3+(3&u),u>>>=2,p-=2}else if(17===H){for(k=R+3;p>>=R)),u>>>=3,p-=3}else{for(k=R+7;p>>=R)),u>>>=7,p-=7}if(C.have+V>C.nlen+C.ndist){g.msg="invalid bit length repeat",C.mode=30;break}for(;V--;)C.lens[C.have++]=M}}if(30===C.mode)break;if(0===C.lens[256]){g.msg="invalid code -- missing end-of-block",C.mode=30;break}if(C.lenbits=9,J={bits:C.lenbits},S=l(s,C.lens,0,C.nlen,C.lencode,0,C.work,J),C.lenbits=J.bits,S){g.msg="invalid literal/lengths set",C.mode=30;break}if(C.distbits=6,C.distcode=C.distdyn,J={bits:C.distbits},S=l(o,C.lens,C.nlen,C.ndist,C.distcode,0,C.work,J),C.distbits=J.bits,S){g.msg="invalid distances set",C.mode=30;break}if(C.mode=20,6===I)break g;case 20:C.mode=21;case 21:if(6<=b&&258<=G){g.next_out=Z,g.avail_out=G,g.next_in=h,g.avail_in=b,C.hold=u,C.bits=p,t(g,W),Z=g.next_out,r=g.output,G=g.avail_out,h=g.next_in,n=g.input,b=g.avail_in,u=C.hold,p=C.bits,12===C.mode&&(C.back=-1);break}for(C.back=0;N=(D=C.lencode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>>=K,p-=K,C.back+=K}if(u>>>=R,p-=R,C.back+=R,C.length=H,0===N){C.mode=26;break}if(32&N){C.back=-1,C.mode=12;break}if(64&N){g.msg="invalid literal/length code",C.mode=30;break}C.extra=15&N,C.mode=22;case 22:if(C.extra){for(k=C.extra;p>>=C.extra,p-=C.extra,C.back+=C.extra}C.was=C.length,C.mode=23;case 23:for(;N=(D=C.distcode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=p);){if(0===b)break g;b--,u+=n[h++]<>>=K,p-=K,C.back+=K}if(u>>>=R,p-=R,C.back+=R,64&N){g.msg="invalid distance code",C.mode=30;break}C.offset=H,C.extra=15&N,C.mode=24;case 24:if(C.extra){for(k=C.extra;p>>=C.extra,p-=C.extra,C.back+=C.extra}if(C.offset>C.dmax){g.msg="invalid distance too far back",C.mode=30;break}C.mode=25;case 25:if(0===G)break g;if(V=W-G,C.offset>V){if((V=C.offset-V)>C.whave&&C.sane){g.msg="invalid distance too far back",C.mode=30;break}X=V>C.wnext?(V-=C.wnext,C.wsize-V):C.wnext-V,V>C.length&&(V=C.length),Y=C.window}else Y=r,X=Z-C.offset,V=C.length;for(Gb?(u=J[k+d[B]],f[F+d[B]]):(u=96,0),n=1<>R)+(r-=n)]=G<<24|u<<16|p,0!==r;);for(n=1<>=1;if(0!==n?(K&=n-1,K+=n):K=0,B++,0==--M[W]){if(W===V)break;W=I[C+d[B]]}if(X>>7)]}function J(g,I){g.pending_buf[g.pending++]=255&I,g.pending_buf[g.pending++]=I>>>8&255}function k(g,I,C){g.bi_valid>m-C?(g.bi_buf|=I<>m-g.bi_valid,g.bi_valid+=C-m):(g.bi_buf|=I<>>=1,C<<=1,0<--I;);return C>>>1}function L(g,I,C){var A,i,e=new Array(r+1),t=0;for(A=1;A<=r;A++)e[A]=t=t+C[A-1]<<1;for(i=0;i<=I;i++){var l=g[2*i+1];0!==l&&(g[2*i]=v(e[l]++,l))}}function z(g){var I;for(I=0;I>1;1<=C;C--)U(g,e,C);for(i=s;C=g.heap[1],g.heap[1]=g.heap[g.heap_len--],U(g,e,1),A=g.heap[1],g.heap[--g.heap_max]=C,g.heap[--g.heap_max]=A,e[2*i]=e[2*C]+e[2*A],g.depth[i]=(g.depth[C]>=g.depth[A]?g.depth[C]:g.depth[A])+1,e[2*C+1]=e[2*A+1]=i,g.heap[1]=i++,U(g,e,1),2<=g.heap_len;);g.heap[--g.heap_max]=g.heap[1],function(g,I){var C,A,i,e,t,l,s=I.dyn_tree,o=I.max_code,c=I.stat_desc.static_tree,d=I.stat_desc.has_stree,a=I.stat_desc.extra_bits,m=I.stat_desc.extra_base,h=I.stat_desc.max_length,Z=0;for(e=0;e<=r;e++)g.bl_count[e]=0;for(s[2*g.heap[g.heap_max]+1]=0,C=g.heap_max+1;C>=7;A>>=1)if(1&C&&0!==g.dyn_ltree[2*I])return i;if(0!==g.dyn_ltree[18]||0!==g.dyn_ltree[20]||0!==g.dyn_ltree[26])return e;for(I=32;I>>3,(l=g.static_len+3+7>>>3)<=t&&(t=l)):t=l=C+5,C+4<=t&&-1!==I?_(g,I,C,A):4===g.strategy||l===t?(k(g,2+(A?1:0),3),j(g,y,V)):(k(g,4+(A?1:0),3),function(g,I,C,A){var i;for(k(g,I-257,5),k(g,C-1,5),k(g,A-4,4),i=0;i>>8&255,g.pending_buf[g.d_buf+2*g.last_lit+1]=255&I,g.pending_buf[g.l_buf+g.last_lit]=255&C,g.last_lit++,0===I?g.dyn_ltree[2*C]++:(g.matches++,I--,g.dyn_ltree[2*(Y[C]+o+1)]++,g.dyn_dtree[2*S(I)]++),g.last_lit===g.lit_bufsize-1},C._tr_align=function(g){var I;k(g,2,3),D(g,Z,y),16===(I=g).bi_valid?(J(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)}},{"../utils/common":41}],53:[function(g,I,C){I.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(g,I,C){(function(g){!function(g,I){if(!g.setImmediate){var C,i,e,t,l=1,s={},o=!1,c=g.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(g);d=d&&d.setTimeout?d:g,C="[object process]"==={}.toString.call(g.process)?function(g){A.nextTick((function(){n(g)}))}:function(){if(g.postMessage&&!g.importScripts){var I=!0,C=g.onmessage;return g.onmessage=function(){I=!1},g.postMessage("","*"),g.onmessage=C,I}}()?(t="setImmediate$"+Math.random()+"$",g.addEventListener?g.addEventListener("message",r,!1):g.attachEvent("onmessage",r),function(I){g.postMessage(t+I,"*")}):g.MessageChannel?((e=new MessageChannel).port1.onmessage=function(g){n(g.data)},function(g){e.port2.postMessage(g)}):c&&"onreadystatechange"in c.createElement("script")?(i=c.documentElement,function(g){var I=c.createElement("script");I.onreadystatechange=function(){n(g),I.onreadystatechange=null,i.removeChild(I),I=null},i.appendChild(I)}):function(g){setTimeout(n,0,g)},d.setImmediate=function(g){"function"!=typeof g&&(g=new Function(""+g));for(var I=new Array(arguments.length-1),A=0;A-1}function Eg(g,I){var C=this.__data__,A=aI(C,g);return A<0?C.push([g,I]):C[A][1]=I,this}function Pg(g){var I=-1,C=g?g.length:0;for(this.clear();++Io))return!1;var d=e.get(g);if(d&&e.get(I))return d==I;var a=-1,n=!0,r=i&t?new CI:void 0;for(e.set(g,I),e.set(I,g);++a-1&&g%1==0&&g-1&&g%1==0&&g<=o}function sC(g){var I=typeof g;return!!g&&("object"==I||"function"==I)}function oC(g){return!!g&&"object"==typeof g}function cC(g){return"symbol"==typeof g||oC(g)&&Zg.call(g)==B}var dC=q?Ag(q):BI;function aC(g){return null==g?"":NI(g)}function nC(g,I,C){var A=null==g?void 0:ZI(g,I);return void 0===A?C:A}function rC(g,I){return null!=g&&zI(g,I,GI)}function mC(g){return iC(g)?dI(g):VI(g)}function hC(g){return g}function ZC(g){return xI(g)?Ig(_I(g)):RI(g)}I.exports=$I}).call(this)}).call(this,void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],444:[function(g,I,C){var A="[object Boolean]",i=Object.prototype.toString;function e(g){return!0===g||!1===g||t(g)&&i.call(g)==A}function t(g){return!!g&&"object"==typeof g}I.exports=e},{}],445:[function(g,I,C){(function(g){(function(){var A=200,i="__lodash_hash_undefined__",e=1,t=2,l=9007199254740991,s="[object Arguments]",o="[object Array]",c="[object AsyncFunction]",d="[object Boolean]",a="[object Date]",n="[object Error]",r="[object Function]",m="[object GeneratorFunction]",h="[object Map]",Z="[object Number]",b="[object Null]",G="[object Object]",u="[object Promise]",p="[object Proxy]",w="[object RegExp]",W="[object Set]",B="[object String]",y="[object Symbol]",V="[object Undefined]",X="[object WeakMap]",Y="[object ArrayBuffer]",R="[object DataView]",N="[object Float64Array]",H="[object Int8Array]",K="[object Int16Array]",f="[object Int32Array]",F="[object Uint8Array]",M="[object Uint8ClampedArray]",S="[object Uint16Array]",J="[object Uint32Array]",k=/[\\^$.*+?()[\]{}|]/g,D=/^\[object .+?Constructor\]$/,v=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L[N]=L[H]=L[K]=L[f]=L[F]=L[M]=L[S]=L[J]=!0,L[s]=L[o]=L[Y]=L[d]=L[R]=L[a]=L[n]=L[r]=L[h]=L[Z]=L[G]=L[w]=L[W]=L[B]=L[X]=!1;var z="object"==typeof g&&g&&g.Object===Object&&g,T="object"==typeof self&&self&&self.Object===Object&&self,x=z||T||Function("return this")(),U="object"==typeof C&&C&&!C.nodeType&&C,j=U&&"object"==typeof I&&I&&!I.nodeType&&I,Q=j&&j.exports===U,O=Q&&z.process,E=function(){try{return O&&O.binding&&O.binding("util")}catch(g){}}(),P=E&&E.isTypedArray;function _(g,I){for(var C=-1,A=null==g?0:g.length,i=0,e=[];++C-1}function Pg(g,I){var C=this.__data__,A=nI(C,g);return A<0?(++this.size,C.push([g,I])):C[A][1]=I,this}function _g(g){var I=-1,C=null==g?0:g.length;for(this.clear();++Io))return!1;var d=l.get(g);if(d&&l.get(I))return d==I;var a=-1,n=!0,r=C&t?new AI:void 0;for(l.set(g,I),l.set(I,g);++a-1&&g%1==0&&g-1&&g%1==0&&g<=l}function UI(g){var I=typeof g;return null!=g&&("object"==I||"function"==I)}function jI(g){return null!=g&&"object"==typeof g}var QI=P?Ig(P):uI;function OI(g){return vI(g)?aI(g):pI(g)}function EI(){return[]}function PI(){return!1}I.exports=zI}).call(this)}).call(this,void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],446:[function(g,I,C){(function(g){(function(){var C="[object AsyncFunction]",A="[object Function]",i="[object GeneratorFunction]",e="[object Null]",t="[object Proxy]",l="[object Undefined]",s="object"==typeof g&&g&&g.Object===Object&&g,o="object"==typeof self&&self&&self.Object===Object&&self,c=s||o||Function("return this")(),d=Object.prototype,a=d.hasOwnProperty,n=d.toString,r=c.Symbol,m=r?r.toStringTag:void 0;function h(g){return null==g?void 0===g?l:e:m&&m in Object(g)?Z(g):b(g)}function Z(g){var I=a.call(g,m),C=g[m];try{g[m]=void 0;var A=!0}catch(e){}var i=n.call(g);return A&&(I?g[m]=C:delete g[m]),i}function b(g){return n.call(g)}function G(g){if(!u(g))return!1;var I=h(g);return I==A||I==i||I==C||I==t}function u(g){var I=typeof g;return null!=g&&("object"==I||"function"==I)}I.exports=G}).call(this)}).call(this,void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],447:[function(g,I,C){function A(g){return null==g}I.exports=A},{}],448:[function(g,I,C){function A(g){return void 0===g}I.exports=A},{}],449:[function(g,I,C){(function(g){(function(){var C=200,A="__lodash_hash_undefined__",i=1/0,e="[object Function]",t="[object GeneratorFunction]",l=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,o="object"==typeof g&&g&&g.Object===Object&&g,c="object"==typeof self&&self&&self.Object===Object&&self,d=o||c||Function("return this")();function a(g,I){return!(!g||!g.length)&&r(g,I,0)>-1}function n(g,I,C,A){for(var i=g.length,e=C+-1;++e-1}function U(g,I){var C=this.__data__,A=Ig(C,g);return A<0?C.push([g,I]):C[A][1]=I,this}function j(g){var I=-1,C=g?g.length:0;for(this.clear();++I=C){var c=ig(g);if(c)return G(c);l=!1,e=h,o=new q}else o=s;g:for(;++i>>32-I}function o(g,I,C,A,i,e,t){return s(g+(I&C|~I&A)+i+e|0,t)+I|0}function c(g,I,C,A,i,e,t){return s(g+(I&A|C&~A)+i+e|0,t)+I|0}function d(g,I,C,A,i,e,t){return s(g+(I^C^A)+i+e|0,t)+I|0}function a(g,I,C,A,i,e,t){return s(g+(C^(I|~A))+i+e|0,t)+I|0}A(l,i),l.prototype._update=function(){for(var g=t,I=0;I<16;++I)g[I]=this._block.readInt32LE(4*I);var C=this._a,A=this._b,i=this._c,e=this._d;C=o(C,A,i,e,g[0],3614090360,7),e=o(e,C,A,i,g[1],3905402710,12),i=o(i,e,C,A,g[2],606105819,17),A=o(A,i,e,C,g[3],3250441966,22),C=o(C,A,i,e,g[4],4118548399,7),e=o(e,C,A,i,g[5],1200080426,12),i=o(i,e,C,A,g[6],2821735955,17),A=o(A,i,e,C,g[7],4249261313,22),C=o(C,A,i,e,g[8],1770035416,7),e=o(e,C,A,i,g[9],2336552879,12),i=o(i,e,C,A,g[10],4294925233,17),A=o(A,i,e,C,g[11],2304563134,22),C=o(C,A,i,e,g[12],1804603682,7),e=o(e,C,A,i,g[13],4254626195,12),i=o(i,e,C,A,g[14],2792965006,17),C=c(C,A=o(A,i,e,C,g[15],1236535329,22),i,e,g[1],4129170786,5),e=c(e,C,A,i,g[6],3225465664,9),i=c(i,e,C,A,g[11],643717713,14),A=c(A,i,e,C,g[0],3921069994,20),C=c(C,A,i,e,g[5],3593408605,5),e=c(e,C,A,i,g[10],38016083,9),i=c(i,e,C,A,g[15],3634488961,14),A=c(A,i,e,C,g[4],3889429448,20),C=c(C,A,i,e,g[9],568446438,5),e=c(e,C,A,i,g[14],3275163606,9),i=c(i,e,C,A,g[3],4107603335,14),A=c(A,i,e,C,g[8],1163531501,20),C=c(C,A,i,e,g[13],2850285829,5),e=c(e,C,A,i,g[2],4243563512,9),i=c(i,e,C,A,g[7],1735328473,14),C=d(C,A=c(A,i,e,C,g[12],2368359562,20),i,e,g[5],4294588738,4),e=d(e,C,A,i,g[8],2272392833,11),i=d(i,e,C,A,g[11],1839030562,16),A=d(A,i,e,C,g[14],4259657740,23),C=d(C,A,i,e,g[1],2763975236,4),e=d(e,C,A,i,g[4],1272893353,11),i=d(i,e,C,A,g[7],4139469664,16),A=d(A,i,e,C,g[10],3200236656,23),C=d(C,A,i,e,g[13],681279174,4),e=d(e,C,A,i,g[0],3936430074,11),i=d(i,e,C,A,g[3],3572445317,16),A=d(A,i,e,C,g[6],76029189,23),C=d(C,A,i,e,g[9],3654602809,4),e=d(e,C,A,i,g[12],3873151461,11),i=d(i,e,C,A,g[15],530742520,16),C=a(C,A=d(A,i,e,C,g[2],3299628645,23),i,e,g[0],4096336452,6),e=a(e,C,A,i,g[7],1126891415,10),i=a(i,e,C,A,g[14],2878612391,15),A=a(A,i,e,C,g[5],4237533241,21),C=a(C,A,i,e,g[12],1700485571,6),e=a(e,C,A,i,g[3],2399980690,10),i=a(i,e,C,A,g[10],4293915773,15),A=a(A,i,e,C,g[1],2240044497,21),C=a(C,A,i,e,g[8],1873313359,6),e=a(e,C,A,i,g[15],4264355552,10),i=a(i,e,C,A,g[6],2734768916,15),A=a(A,i,e,C,g[13],1309151649,21),C=a(C,A,i,e,g[4],4149444226,6),e=a(e,C,A,i,g[11],3174756917,10),i=a(i,e,C,A,g[2],718787259,15),A=a(A,i,e,C,g[9],3951481745,21),this._a=this._a+C|0,this._b=this._b+A|0,this._c=this._c+i|0,this._d=this._d+e|0},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var g=e.allocUnsafe(16);return g.writeInt32LE(this._a,0),g.writeInt32LE(this._b,4),g.writeInt32LE(this._c,8),g.writeInt32LE(this._d,12),g},I.exports=l},{"hash-base":425,inherits:440,"safe-buffer":494}],451:[function(g,I,C){var A=g("bn.js"),i=g("brorand");function e(g){this.rand=g||new i.Rand}I.exports=e,e.create=function(g){return new e(g)},e.prototype._randbelow=function(g){var I=g.bitLength(),C=Math.ceil(I/8);do{var i=new A(this.rand.generate(C))}while(i.cmp(g)>=0);return i},e.prototype._randrange=function(g,I){var C=I.sub(g);return g.add(this._randbelow(C))},e.prototype.test=function(g,I,C){var i=g.bitLength(),e=A.mont(g),t=new A(1).toRed(e);I||(I=Math.max(1,i/48|0));for(var l=g.subn(1),s=0;!l.testn(s);s++);for(var o=g.shrn(s),c=l.toRed(e),d=!0;I>0;I--){var a=this._randrange(new A(2),l);C&&C(a);var n=a.toRed(e).redPow(o);if(0!==n.cmp(t)&&0!==n.cmp(c)){for(var r=1;r0;I--){var c=this._randrange(new A(2),t),d=g.gcd(c);if(0!==d.cmpn(1))return d;var a=c.toRed(i).redPow(s);if(0!==a.cmp(e)&&0!==a.cmp(o)){for(var n=1;n>8,t=255&i;e?C.push(e,t):C.push(t)}return C}function e(g){return 1===g.length?"0"+g:g}function t(g){for(var I="",C=0;C=6?"utf-8":"binary":"utf-8",I.exports=A}).call(this)}).call(this,g("_process"),void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:467}],463:[function(g,I,C){var A=Math.pow(2,30)-1;I.exports=function(g,I){if("number"!=typeof g)throw new TypeError("Iterations not a number");if(g<0)throw new TypeError("Bad iterations");if("number"!=typeof I)throw new TypeError("Key length not a number");if(I<0||I>A||I!=I)throw new TypeError("Bad key length")}},{}],464:[function(g,I,C){var A=g("create-hash/md5"),i=g("ripemd160"),e=g("sha.js"),t=g("safe-buffer").Buffer,l=g("./precondition"),s=g("./default-encoding"),o=g("./to-buffer"),c=t.alloc(128),d={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function a(g,I,C){var A=n(g),i="sha512"===g||"sha384"===g?128:64;I.length>i?I=A(I):I.length1)for(var C=1;C=I.length){e++;break}var t=I.slice(2,i-1);if(("0002"!==A.toString("hex")&&!C||"0001"!==A.toString("hex")&&C)&&e++,t.length<8&&e++,e)throw new Error("decryption error");return I.slice(i)}function n(g,I){g=c.from(g),I=c.from(I);var C=0,A=g.length;g.length!==I.length&&(C++,A=Math.min(g.length,I.length));for(var i=-1;++in||new t(I).cmp(s.modulus)>=0)throw new Error("decryption error");e=C?o(new t(I),s):l(I,s);var r=c.alloc(n-e.length);if(e=c.concat([r,e],n),4===i)return d(s,e);if(1===i)return a(s,e,C);if(3===i)return e;throw new Error("unknown padding")}},{"./mgf":469,"./withPublic":473,"./xor":474,"bn.js":470,"browserify-rsa":209,"create-hash":386,"parse-asn1":459,"safe-buffer":494}],472:[function(g,I,C){var A=g("parse-asn1"),i=g("randombytes"),e=g("create-hash"),t=g("./mgf"),l=g("./xor"),s=g("bn.js"),o=g("./withPublic"),c=g("browserify-rsa"),d=g("safe-buffer").Buffer;function a(g,I){var C=g.modulus.byteLength(),A=I.length,o=e("sha1").update(d.alloc(0)).digest(),c=o.length,a=2*c;if(A>C-a-2)throw new Error("message too long");var n=d.alloc(C-A-a-2),r=C-c-1,m=i(c),h=l(d.concat([o,n,d.alloc(1,1),I],r),t(m,r)),Z=l(m,t(h,c));return new s(d.concat([d.alloc(1),Z,h],C))}function n(g,I,C){var A,i=I.length,e=g.modulus.byteLength();if(i>e-11)throw new Error("message too long");return A=C?d.alloc(e-i-3,255):r(e-i-3),new s(d.concat([d.from([0,C?1:2]),A,d.alloc(1),I],e))}function r(g){for(var I,C=d.allocUnsafe(g),A=0,e=i(2*g),t=0;A=0)throw new Error("data too long for modulus")}return C?c(e,t):o(e,t)}},{"./mgf":469,"./withPublic":473,"./xor":474,"bn.js":470,"browserify-rsa":209,"create-hash":386,"parse-asn1":459,randombytes:475,"safe-buffer":494}],473:[function(g,I,C){var A=g("bn.js"),i=g("safe-buffer").Buffer;function e(g,I){return i.from(g.toRed(A.mont(I.modulus)).redPow(new A(I.publicExponent)).fromRed().toArray())}I.exports=e},{"bn.js":470,"safe-buffer":494}],474:[function(g,I,C){I.exports=function(g,I){for(var C=g.length,A=-1;++Ae)throw new RangeError("requested too many random bytes");var A=l.allocUnsafe(g);if(g>0)if(g>i)for(var t=0;tc||g<0)throw new TypeError("offset must be a uint32");if(g>s||g>I)throw new RangeError("offset out of range")}function a(g,I,C){if("number"!=typeof g||g!=g)throw new TypeError("size must be a number");if(g>c||g<0)throw new TypeError("size must be a uint32");if(g+I>C||g>s)throw new RangeError("buffer too small")}function n(g,I,C,i){if(!(l.isBuffer(g)||g instanceof A.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof I)i=I,I=0,C=g.length;else if("function"==typeof C)i=C,C=g.length-I;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return d(I,g.length),a(C,I,g.length),r(g,I,C,i)}function r(g,C,A,i){if(I.browser){var e=g.buffer,l=new Uint8Array(e,C,A);return o.getRandomValues(l),i?void I.nextTick((function(){i(null,g)})):g}if(!i)return t(A).copy(g,C),g;t(A,(function(I,A){if(I)return i(I);A.copy(g,C),i(null,g)}))}function m(g,I,C){if(void 0===I&&(I=0),!(l.isBuffer(g)||g instanceof A.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return d(I,g.length),void 0===C&&(C=g.length-I),a(C,I,g.length),r(g,I,C)}o&&o.getRandomValues||!I.browser?(C.randomFill=n,C.randomFillSync=m):(C.randomFill=i,C.randomFillSync=i)}).call(this)}).call(this,g("_process"),void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:467,randombytes:475,"safe-buffer":494}],477:[function(g,I,C){function A(g,I){g.prototype=Object.create(I.prototype),g.prototype.constructor=g,g.__proto__=I}var i={};function e(g,I,C){function e(g,C,A){return"string"==typeof I?I:I(g,C,A)}C||(C=Error);var t=function(g){function I(I,C,A){return g.call(this,e(I,C,A))||this}return A(I,g),I}(C);t.prototype.name=C.name,t.prototype.code=g,i[g]=t}function t(g,I){if(Array.isArray(g)){var C=g.length;return g=g.map((function(g){return String(g)})),C>2?"one of ".concat(I," ").concat(g.slice(0,C-1).join(", "),", or ")+g[C-1]:2===C?"one of ".concat(I," ").concat(g[0]," or ").concat(g[1]):"of ".concat(I," ").concat(g[0])}return"of ".concat(I," ").concat(String(g))}function l(g,I,C){return g.substr(0,I.length)===I}function s(g,I,C){return(void 0===C||C>g.length)&&(C=g.length),g.substring(C-I.length,C)===I}function o(g,I,C){return"number"!=typeof C&&(C=0),!(C+I.length>g.length)&&-1!==g.indexOf(I,C)}e("ERR_INVALID_OPT_VALUE",(function(g,I){return'The value "'+I+'" is invalid for option "'+g+'"'}),TypeError),e("ERR_INVALID_ARG_TYPE",(function(g,I,C){var A,i;if("string"==typeof I&&l(I,"not ")?(A="must not be",I=I.replace(/^not /,"")):A="must be",s(g," argument"))i="The ".concat(g," ").concat(A," ").concat(t(I,"type"));else{var e=o(g,".")?"property":"argument";i='The "'.concat(g,'" ').concat(e," ").concat(A," ").concat(t(I,"type"))}return i+=". Received type ".concat(typeof C)}),TypeError),e("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),e("ERR_METHOD_NOT_IMPLEMENTED",(function(g){return"The "+g+" method is not implemented"})),e("ERR_STREAM_PREMATURE_CLOSE","Premature close"),e("ERR_STREAM_DESTROYED",(function(g){return"Cannot call "+g+" after a stream was destroyed"})),e("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),e("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),e("ERR_STREAM_WRITE_AFTER_END","write after end"),e("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),e("ERR_UNKNOWN_ENCODING",(function(g){return"Unknown encoding: "+g}),TypeError),e("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),I.exports.codes=i},{}],478:[function(g,I,C){(function(C){(function(){var A=Object.keys||function(g){var I=[];for(var C in g)I.push(C);return I};I.exports=o;var i=g("./_stream_readable"),e=g("./_stream_writable");g("inherits")(o,i);for(var t=A(e.prototype),l=0;l0)if("string"==typeof I||t.objectMode||Object.getPrototypeOf(I)===l.prototype||(I=o(I)),A)t.endEmitted?B(g,new W):N(g,t,I,!0);else if(t.ended)B(g,new p);else{if(t.destroyed)return!1;t.reading=!1,t.decoder&&!C?(I=t.decoder.write(I),t.objectMode||0!==I.length?N(g,t,I,!1):k(g,t)):N(g,t,I,!1)}else A||(t.reading=!1,k(g,t));return!t.ended&&(t.length=K?g=K:(g--,g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g++),g}function F(g,I){return g<=0||0===I.length&&I.ended?0:I.objectMode?1:g!=g?I.flowing&&I.length?I.buffer.head.data.length:I.length:(g>I.highWaterMark&&(I.highWaterMark=f(g)),g<=I.length?g:I.ended?I.length:(I.needReadable=!0,0))}function M(g,I){if(d("onEofChunk"),!I.ended){if(I.decoder){var C=I.decoder.end();C&&C.length&&(I.buffer.push(C),I.length+=I.objectMode?1:C.length)}I.ended=!0,I.sync?S(g):(I.needReadable=!1,I.emittedReadable||(I.emittedReadable=!0,J(g)))}}function S(g){var I=g._readableState;d("emitReadable",I.needReadable,I.emittedReadable),I.needReadable=!1,I.emittedReadable||(d("emitReadable",I.flowing),I.emittedReadable=!0,C.nextTick(J,g))}function J(g){var I=g._readableState;d("emitReadable_",I.destroyed,I.length,I.ended),I.destroyed||!I.length&&!I.ended||(g.emit("readable"),I.emittedReadable=!1),I.needReadable=!I.flowing&&!I.ended&&I.length<=I.highWaterMark,U(g)}function k(g,I){I.readingMore||(I.readingMore=!0,C.nextTick(D,g,I))}function D(g,I){for(;!I.reading&&!I.ended&&(I.length0,I.resumeScheduled&&!I.paused?I.flowing=!0:g.listenerCount("data")>0&&g.resume()}function z(g){d("readable nexttick read 0"),g.read(0)}function T(g,I){I.resumeScheduled||(I.resumeScheduled=!0,C.nextTick(x,g,I))}function x(g,I){d("resume",I.reading),I.reading||g.read(0),I.resumeScheduled=!1,g.emit("resume"),U(g),I.flowing&&!I.reading&&g.read(0)}function U(g){var I=g._readableState;for(d("flow",I.flowing);I.flowing&&null!==g.read(););}function j(g,I){return 0===I.length?null:(I.objectMode?C=I.buffer.shift():!g||g>=I.length?(C=I.decoder?I.buffer.join(""):1===I.buffer.length?I.buffer.first():I.buffer.concat(I.length),I.buffer.clear()):C=I.buffer.consume(g,I.decoder),C);var C}function Q(g){var I=g._readableState;d("endReadable",I.endEmitted),I.endEmitted||(I.ended=!0,C.nextTick(O,I,g))}function O(g,I){if(d("endReadableNT",g.endEmitted,g.length),!g.endEmitted&&0===g.length&&(g.endEmitted=!0,I.readable=!1,I.emit("end"),g.autoDestroy)){var C=I._writableState;(!C||C.autoDestroy&&C.finished)&&I.destroy()}}function E(g,I){for(var C=0,A=g.length;C=I.highWaterMark:I.length>0)||I.ended))return d("read: emitReadable",I.length,I.ended),0===I.length&&I.ended?Q(this):S(this),null;if(0===(g=F(g,I))&&I.ended)return 0===I.length&&Q(this),null;var A,i=I.needReadable;return d("need readable",i),(0===I.length||I.length-g0?j(g,I):null)?(I.needReadable=I.length<=I.highWaterMark,g=0):(I.length-=g,I.awaitDrain=0),0===I.length&&(I.ended||(I.needReadable=!0),C!==g&&I.ended&&Q(this)),null!==A&&this.emit("data",A),A},Y.prototype._read=function(g){B(this,new w("_read()"))},Y.prototype.pipe=function(g,I){var A=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=g;break;case 1:i.pipes=[i.pipes,g];break;default:i.pipes.push(g)}i.pipesCount+=1,d("pipe count=%d opts=%j",i.pipesCount,I);var t=I&&!1===I.end||g===C.stdout||g===C.stderr?Z:s;function l(g,I){d("onunpipe"),g===A&&I&&!1===I.hasUnpiped&&(I.hasUnpiped=!0,a())}function s(){d("onend"),g.end()}i.endEmitted?C.nextTick(t):A.once("end",t),g.on("unpipe",l);var o=v(A);g.on("drain",o);var c=!1;function a(){d("cleanup"),g.removeListener("close",m),g.removeListener("finish",h),g.removeListener("drain",o),g.removeListener("error",r),g.removeListener("unpipe",l),A.removeListener("end",s),A.removeListener("end",Z),A.removeListener("data",n),c=!0,!i.awaitDrain||g._writableState&&!g._writableState.needDrain||o()}function n(I){d("ondata");var C=g.write(I);d("dest.write",C),!1===C&&((1===i.pipesCount&&i.pipes===g||i.pipesCount>1&&-1!==E(i.pipes,g))&&!c&&(d("false write response, pause",i.awaitDrain),i.awaitDrain++),A.pause())}function r(I){d("onerror",I),Z(),g.removeListener("error",r),0===e(g,"error")&&B(g,I)}function m(){g.removeListener("finish",h),Z()}function h(){d("onfinish"),g.removeListener("close",m),Z()}function Z(){d("unpipe"),A.unpipe(g)}return A.on("data",n),V(g,"error",r),g.once("close",m),g.once("finish",h),g.emit("pipe",A),i.flowing||(d("pipe resume"),A.resume()),g},Y.prototype.unpipe=function(g){var I=this._readableState,C={hasUnpiped:!1};if(0===I.pipesCount)return this;if(1===I.pipesCount)return g&&g!==I.pipes||(g||(g=I.pipes),I.pipes=null,I.pipesCount=0,I.flowing=!1,g&&g.emit("unpipe",this,C)),this;if(!g){var A=I.pipes,i=I.pipesCount;I.pipes=null,I.pipesCount=0,I.flowing=!1;for(var e=0;e0,!1!==i.flowing&&this.resume()):"readable"===g&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,d("on readable",i.length,i.reading),i.length?S(this):i.reading||C.nextTick(z,this))),A},Y.prototype.addListener=Y.prototype.on,Y.prototype.removeListener=function(g,I){var A=t.prototype.removeListener.call(this,g,I);return"readable"===g&&C.nextTick(L,this),A},Y.prototype.removeAllListeners=function(g){var I=t.prototype.removeAllListeners.apply(this,arguments);return"readable"!==g&&void 0!==g||C.nextTick(L,this),I},Y.prototype.resume=function(){var g=this._readableState;return g.flowing||(d("resume"),g.flowing=!g.readableListening,T(this,g)),g.paused=!1,this},Y.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Y.prototype.wrap=function(g){var I=this,C=this._readableState,A=!1;for(var i in g.on("end",(function(){if(d("wrapped end"),C.decoder&&!C.ended){var g=C.decoder.end();g&&g.length&&I.push(g)}I.push(null)})),g.on("data",(function(i){d("wrapped data"),C.decoder&&(i=C.decoder.write(i)),C.objectMode&&null==i||(C.objectMode||i&&i.length)&&(I.push(i)||(A=!0,g.pause()))})),g)void 0===this[i]&&"function"==typeof g[i]&&(this[i]=function(I){return function(){return g[I].apply(g,arguments)}}(i));for(var e=0;e-1))throw new W(g);return this._writableState.defaultEncoding=g,this},Object.defineProperty(X.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(X.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),X.prototype._write=function(g,I,C){C(new Z("_write()"))},X.prototype._writev=null,X.prototype.end=function(g,I,C){var A=this._writableState;return"function"==typeof g?(C=g,g=null,I=null):"function"==typeof I&&(C=I,I=null),null!=g&&this.write(g,I),A.corked&&(A.corked=1,this.uncork()),A.ending||T(this,A,C),this},Object.defineProperty(X.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(X.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(g){this._writableState&&(this._writableState.destroyed=g)}}),X.prototype.destroy=n.destroy,X.prototype._undestroy=n.undestroy,X.prototype._destroy=function(g,I){I(g)}}).call(this)}).call(this,g("_process"),void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":477,"./_stream_duplex":478,"./internal/streams/destroy":485,"./internal/streams/state":489,"./internal/streams/stream":490,_process:467,buffer:220,inherits:440,"util-deprecate":524}],483:[function(g,I,C){(function(C){(function(){var A;function i(g,I,C){return(I=e(I))in g?Object.defineProperty(g,I,{value:C,enumerable:!0,configurable:!0,writable:!0}):g[I]=C,g}function e(g){var I=t(g,"string");return"symbol"==typeof I?I:String(I)}function t(g,I){if("object"!=typeof g||null===g)return g;var C=g[Symbol.toPrimitive];if(void 0!==C){var A=C.call(g,I||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(g)}var l=g("./end-of-stream"),s=Symbol("lastResolve"),o=Symbol("lastReject"),c=Symbol("error"),d=Symbol("ended"),a=Symbol("lastPromise"),n=Symbol("handlePromise"),r=Symbol("stream");function m(g,I){return{value:g,done:I}}function h(g){var I=g[s];if(null!==I){var C=g[r].read();null!==C&&(g[a]=null,g[s]=null,g[o]=null,I(m(C,!1)))}}function Z(g){C.nextTick(h,g)}function b(g,I){return function(C,A){g.then((function(){I[d]?C(m(void 0,!0)):I[n](C,A)}),A)}}var G=Object.getPrototypeOf((function(){})),u=Object.setPrototypeOf((i(A={get stream(){return this[r]},next:function(){var g=this,I=this[c];if(null!==I)return Promise.reject(I);if(this[d])return Promise.resolve(m(void 0,!0));if(this[r].destroyed)return new Promise((function(I,A){C.nextTick((function(){g[c]?A(g[c]):I(m(void 0,!0))}))}));var A,i=this[a];if(i)A=new Promise(b(i,this));else{var e=this[r].read();if(null!==e)return Promise.resolve(m(e,!1));A=new Promise(this[n])}return this[a]=A,A}},Symbol.asyncIterator,(function(){return this})),i(A,"return",(function(){var g=this;return new Promise((function(I,C){g[r].destroy(null,(function(g){g?C(g):I(m(void 0,!0))}))}))})),A),G),p=function(g){var I,C=Object.create(u,(i(I={},r,{value:g,writable:!0}),i(I,s,{value:null,writable:!0}),i(I,o,{value:null,writable:!0}),i(I,c,{value:null,writable:!0}),i(I,d,{value:g._readableState.endEmitted,writable:!0}),i(I,n,{value:function(g,I){var A=C[r].read();A?(C[a]=null,C[s]=null,C[o]=null,g(m(A,!1))):(C[s]=g,C[o]=I)},writable:!0}),I));return C[a]=null,l(g,(function(g){if(g&&"ERR_STREAM_PREMATURE_CLOSE"!==g.code){var I=C[o];return null!==I&&(C[a]=null,C[s]=null,C[o]=null,I(g)),void(C[c]=g)}var A=C[s];null!==A&&(C[a]=null,C[s]=null,C[o]=null,A(m(void 0,!0))),C[d]=!0})),g.on("readable",Z.bind(null,C)),C};I.exports=p}).call(this)}).call(this,g("_process"))},{"./end-of-stream":486,_process:467}],484:[function(g,I,C){function A(g,I){var C=Object.keys(g);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(g);I&&(A=A.filter((function(I){return Object.getOwnPropertyDescriptor(g,I).enumerable}))),C.push.apply(C,A)}return C}function i(g){for(var I=1;I0?this.tail.next=I:this.head=I,this.tail=I,++this.length}},{key:"unshift",value:function(g){var I={data:g,next:this.head};0===this.length&&(this.tail=I),this.head=I,++this.length}},{key:"shift",value:function(){if(0!==this.length){var g=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,g}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(g){if(0===this.length)return"";for(var I=this.head,C=""+I.data;I=I.next;)C+=g+I.data;return C}},{key:"concat",value:function(g){if(0===this.length)return d.alloc(0);for(var I=d.allocUnsafe(g>>>0),C=this.head,A=0;C;)r(C.data,I,A),A+=C.data.length,C=C.next;return I}},{key:"consume",value:function(g,I){var C;return gi.length?i.length:g;if(e===i.length?A+=i:A+=i.slice(0,g),0==(g-=e)){e===i.length?(++C,I.next?this.head=I.next:this.head=this.tail=null):(this.head=I,I.data=i.slice(e));break}++C}return this.length-=C,A}},{key:"_getBuffer",value:function(g){var I=d.allocUnsafe(g),C=this.head,A=1;for(C.data.copy(I),g-=C.data.length;C=C.next;){var i=C.data,e=g>i.length?i.length:g;if(i.copy(I,I.length-g,0,e),0==(g-=e)){e===i.length?(++A,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=i.slice(e));break}++A}return this.length-=A,I}},{key:n,value:function(g,I){return a(this,i(i({},I),{},{depth:0,customInspect:!1}))}}]),g}()},{buffer:220,util:188}],485:[function(g,I,C){(function(g){(function(){function C(I,C){var e=this,l=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return l||s?(C?C(I):I&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,g.nextTick(t,this,I)):g.nextTick(t,this,I)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(I||null,(function(I){!C&&I?e._writableState?e._writableState.errorEmitted?g.nextTick(i,e):(e._writableState.errorEmitted=!0,g.nextTick(A,e,I)):g.nextTick(A,e,I):C?(g.nextTick(i,e),C(I)):g.nextTick(i,e)})),this)}function A(g,I){t(g,I),i(g)}function i(g){g._writableState&&!g._writableState.emitClose||g._readableState&&!g._readableState.emitClose||g.emit("close")}function e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function t(g,I){g.emit("error",I)}function l(g,I){var C=g._readableState,A=g._writableState;C&&C.autoDestroy||A&&A.autoDestroy?g.destroy(I):g.emit("error",I)}I.exports={destroy:C,undestroy:e,errorOrDestroy:l}}).call(this)}).call(this,g("_process"))},{_process:467}],486:[function(g,I,C){var A=g("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function i(g){var I=!1;return function(){if(!I){I=!0;for(var C=arguments.length,A=new Array(C),i=0;i0,(function(g){A||(A=g),g&&e.forEach(d),t||(e.forEach(d),i(A))}))}));return I.reduce(a)}I.exports=r},{"../../../errors":477,"./end-of-stream":486}],489:[function(g,I,C){var A=g("../../../errors").codes.ERR_INVALID_OPT_VALUE;function i(g,I,C){return null!=g.highWaterMark?g.highWaterMark:I?g[C]:null}function e(g,I,C,e){var t=i(I,e,C);if(null!=t){if(!isFinite(t)||Math.floor(t)!==t||t<0)throw new A(e?C:"highWaterMark",t);return Math.floor(t)}return g.objectMode?16:16384}I.exports={getHighWaterMark:e}},{"../../../errors":477}],490:[function(g,I,C){I.exports=g("events").EventEmitter},{events:422}],491:[function(g,I,C){(C=I.exports=g("./lib/_stream_readable.js")).Stream=C,C.Readable=C,C.Writable=g("./lib/_stream_writable.js"),C.Duplex=g("./lib/_stream_duplex.js"),C.Transform=g("./lib/_stream_transform.js"),C.PassThrough=g("./lib/_stream_passthrough.js"),C.finished=g("./lib/internal/streams/end-of-stream.js"),C.pipeline=g("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":478,"./lib/_stream_passthrough.js":479,"./lib/_stream_readable.js":480,"./lib/_stream_transform.js":481,"./lib/_stream_writable.js":482,"./lib/internal/streams/end-of-stream.js":486,"./lib/internal/streams/pipeline.js":488}],492:[function(g,I,C){var A=function(g){var I,C=Object.prototype,A=C.hasOwnProperty,i=Object.defineProperty||function(g,I,C){g[I]=C.value},e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",l=e.asyncIterator||"@@asyncIterator",s=e.toStringTag||"@@toStringTag";function o(g,I,C){return Object.defineProperty(g,I,{value:C,enumerable:!0,configurable:!0,writable:!0}),g[I]}try{o({},"")}catch(f){o=function(g,I,C){return g[I]=C}}function c(g,I,C,A){var e=I&&I.prototype instanceof Z?I:Z,t=Object.create(e.prototype),l=new N(A||[]);return i(t,"_invoke",{value:V(g,C,l)}),t}function d(g,I,C){try{return{type:"normal",arg:g.call(I,C)}}catch(f){return{type:"throw",arg:f}}}g.wrap=c;var a="suspendedStart",n="suspendedYield",r="executing",m="completed",h={};function Z(){}function b(){}function G(){}var u={};o(u,t,(function(){return this}));var p=Object.getPrototypeOf,w=p&&p(p(H([])));w&&w!==C&&A.call(w,t)&&(u=w);var W=G.prototype=Z.prototype=Object.create(u);function B(g){["next","throw","return"].forEach((function(I){o(g,I,(function(g){return this._invoke(I,g)}))}))}function y(g,I){function C(i,e,t,l){var s=d(g[i],g,e);if("throw"!==s.type){var o=s.arg,c=o.value;return c&&"object"==typeof c&&A.call(c,"__await")?I.resolve(c.__await).then((function(g){C("next",g,t,l)}),(function(g){C("throw",g,t,l)})):I.resolve(c).then((function(g){o.value=g,t(o)}),(function(g){return C("throw",g,t,l)}))}l(s.arg)}var e;function t(g,A){function i(){return new I((function(I,i){C(g,A,I,i)}))}return e=e?e.then(i,i):i()}i(this,"_invoke",{value:t})}function V(g,I,C){var A=a;return function(i,e){if(A===r)throw new Error("Generator is already running");if(A===m){if("throw"===i)throw e;return K()}for(C.method=i,C.arg=e;;){var t=C.delegate;if(t){var l=X(t,C);if(l){if(l===h)continue;return l}}if("next"===C.method)C.sent=C._sent=C.arg;else if("throw"===C.method){if(A===a)throw A=m,C.arg;C.dispatchException(C.arg)}else"return"===C.method&&C.abrupt("return",C.arg);A=r;var s=d(g,I,C);if("normal"===s.type){if(A=C.done?m:n,s.arg===h)continue;return{value:s.arg,done:C.done}}"throw"===s.type&&(A=m,C.method="throw",C.arg=s.arg)}}}function X(g,C){var A=C.method,i=g.iterator[A];if(i===I)return C.delegate=null,"throw"===A&&g.iterator.return&&(C.method="return",C.arg=I,X(g,C),"throw"===C.method)||"return"!==A&&(C.method="throw",C.arg=new TypeError("The iterator does not provide a '"+A+"' method")),h;var e=d(i,g.iterator,C.arg);if("throw"===e.type)return C.method="throw",C.arg=e.arg,C.delegate=null,h;var t=e.arg;return t?t.done?(C[g.resultName]=t.value,C.next=g.nextLoc,"return"!==C.method&&(C.method="next",C.arg=I),C.delegate=null,h):t:(C.method="throw",C.arg=new TypeError("iterator result is not an object"),C.delegate=null,h)}function Y(g){var I={tryLoc:g[0]};1 in g&&(I.catchLoc=g[1]),2 in g&&(I.finallyLoc=g[2],I.afterLoc=g[3]),this.tryEntries.push(I)}function R(g){var I=g.completion||{};I.type="normal",delete I.arg,g.completion=I}function N(g){this.tryEntries=[{tryLoc:"root"}],g.forEach(Y,this),this.reset(!0)}function H(g){if(g){var C=g[t];if(C)return C.call(g);if("function"==typeof g.next)return g;if(!isNaN(g.length)){var i=-1,e=function C(){for(;++i=0;--e){var t=this.tryEntries[e],l=t.completion;if("root"===t.tryLoc)return i("end");if(t.tryLoc<=this.prev){var s=A.call(t,"catchLoc"),o=A.call(t,"finallyLoc");if(s&&o){if(this.prev=0;--C){var i=this.tryEntries[C];if(i.tryLoc<=this.prev&&A.call(i,"finallyLoc")&&this.prev=0;--I){var C=this.tryEntries[I];if(C.finallyLoc===g)return this.complete(C.completion,C.afterLoc),R(C),h}},catch:function(g){for(var I=this.tryEntries.length-1;I>=0;--I){var C=this.tryEntries[I];if(C.tryLoc===g){var A=C.completion;if("throw"===A.type){var i=A.arg;R(C)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(g,C,A){return this.delegate={iterator:H(g),resultName:C,nextLoc:A},"next"===this.method&&(this.arg=I),h}},g}("object"==typeof I?I.exports:{});try{regeneratorRuntime=A}catch(i){"object"==typeof globalThis?globalThis.regeneratorRuntime=A:Function("r","regeneratorRuntime = r")(A)}},{}],493:[function(g,I,C){var A=g("buffer").Buffer,i=g("inherits"),e=g("hash-base"),t=new Array(16),l=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],s=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],o=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],d=[0,1518500249,1859775393,2400959708,2840853838],a=[1352829926,1548603684,1836072691,2053994217,0];function n(){e.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function r(g,I){return g<>>32-I}function m(g,I,C,A,i,e,t,l){return r(g+(I^C^A)+e+t|0,l)+i|0}function h(g,I,C,A,i,e,t,l){return r(g+(I&C|~I&A)+e+t|0,l)+i|0}function Z(g,I,C,A,i,e,t,l){return r(g+((I|~C)^A)+e+t|0,l)+i|0}function b(g,I,C,A,i,e,t,l){return r(g+(I&A|C&~A)+e+t|0,l)+i|0}function G(g,I,C,A,i,e,t,l){return r(g+(I^(C|~A))+e+t|0,l)+i|0}i(n,e),n.prototype._update=function(){for(var g=t,I=0;I<16;++I)g[I]=this._block.readInt32LE(4*I);for(var C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,n=0|this._e,u=0|this._a,p=0|this._b,w=0|this._c,W=0|this._d,B=0|this._e,y=0;y<80;y+=1){var V,X;y<16?(V=m(C,A,i,e,n,g[l[y]],d[0],o[y]),X=G(u,p,w,W,B,g[s[y]],a[0],c[y])):y<32?(V=h(C,A,i,e,n,g[l[y]],d[1],o[y]),X=b(u,p,w,W,B,g[s[y]],a[1],c[y])):y<48?(V=Z(C,A,i,e,n,g[l[y]],d[2],o[y]),X=Z(u,p,w,W,B,g[s[y]],a[2],c[y])):y<64?(V=b(C,A,i,e,n,g[l[y]],d[3],o[y]),X=h(u,p,w,W,B,g[s[y]],a[3],c[y])):(V=G(C,A,i,e,n,g[l[y]],d[4],o[y]),X=m(u,p,w,W,B,g[s[y]],a[4],c[y])),C=n,n=e,e=r(i,10),i=A,A=V,u=B,B=W,W=r(w,10),w=p,p=X}var Y=this._b+i+W|0;this._b=this._c+e+B|0,this._c=this._d+n+u|0,this._d=this._e+C+p|0,this._e=this._a+A+w|0,this._a=Y},n.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var g=A.alloc?A.alloc(20):new A(20);return g.writeInt32LE(this._a,0),g.writeInt32LE(this._b,4),g.writeInt32LE(this._c,8),g.writeInt32LE(this._d,12),g.writeInt32LE(this._e,16),g},I.exports=n},{buffer:220,"hash-base":425,inherits:440}],494:[function(g,I,C){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var A=g("buffer"),i=A.Buffer;function e(g,I){for(var C in g)I[C]=g[C]}function t(g,I,C){return i(g,I,C)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?I.exports=A:(e(A,C),C.Buffer=t),t.prototype=Object.create(i.prototype),e(i,t),t.from=function(g,I,C){if("number"==typeof g)throw new TypeError("Argument must not be a number");return i(g,I,C)},t.alloc=function(g,I,C){if("number"!=typeof g)throw new TypeError("Argument must be a number");var A=i(g);return void 0!==I?"string"==typeof C?A.fill(I,C):A.fill(I):A.fill(0),A},t.allocUnsafe=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return i(g)},t.allocUnsafeSlow=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return A.SlowBuffer(g)}},{buffer:220}],495:[function(g,I,C){(function(C){(function(){var A,i=g("buffer"),e=i.Buffer,t={};for(A in i)i.hasOwnProperty(A)&&"SlowBuffer"!==A&&"Buffer"!==A&&(t[A]=i[A]);var l=t.Buffer={};for(A in e)e.hasOwnProperty(A)&&"allocUnsafe"!==A&&"allocUnsafeSlow"!==A&&(l[A]=e[A]);if(t.Buffer.prototype=e.prototype,l.from&&l.from!==Uint8Array.from||(l.from=function(g,I,C){if("number"==typeof g)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof g);if(g&&void 0===g.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g);return e(g,I,C)}),l.alloc||(l.alloc=function(g,I,C){if("number"!=typeof g)throw new TypeError('The "size" argument must be of type number. Received type '+typeof g);if(g<0||g>=2*(1<<30))throw new RangeError('The value "'+g+'" is invalid for option "size"');var A=e(g);return I&&0!==I.length?"string"==typeof C?A.fill(I,C):A.fill(I):A.fill(0),A}),!t.kStringMaxLength)try{t.kStringMaxLength=C.binding("buffer").kStringMaxLength}catch(s){}t.constants||(t.constants={MAX_LENGTH:t.kMaxLength},t.kStringMaxLength&&(t.constants.MAX_STRING_LENGTH=t.kStringMaxLength)),I.exports=t}).call(this)}).call(this,g("_process"))},{_process:467,buffer:220}],496:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0});const A=g("xmlchars/xml/1.0/ed5"),i=g("xmlchars/xml/1.1/ed2"),e=g("xmlchars/xmlns/1.0/ed3");var t=A.isS,l=A.isChar,s=A.isNameStartChar,o=A.isNameChar,c=A.S_LIST,d=A.NAME_RE,a=i.isChar,n=e.isNCNameStartChar,r=e.isNCNameChar,m=e.NC_NAME_RE;const h="http://www.w3.org/XML/1998/namespace",Z="http://www.w3.org/2000/xmlns/",b={__proto__:null,xml:h,xmlns:Z},G={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},u=-1,p=-2,w=0,W=1,B=2,y=3,V=4,X=5,Y=6,R=7,N=8,H=9,K=10,f=11,F=12,M=13,S=14,J=15,k=16,D=17,v=18,L=19,z=20,T=21,x=22,U=23,j=24,Q=25,O=26,E=27,P=28,_=29,q=30,$=31,gg=32,Ig=33,Cg=34,Ag=35,ig=36,eg=37,tg=38,lg=39,sg=40,og=41,cg=42,dg=43,ag=44,ng=9,rg=10,mg=13,hg=32,Zg=33,bg=34,Gg=38,ug=39,pg=45,wg=47,Wg=59,Bg=60,yg=61,Vg=62,Xg=63,Yg=91,Rg=93,Ng=133,Hg=8232,Kg=g=>g===bg||g===ug,fg=[bg,ug],Fg=[...fg,Yg,Vg],Mg=[...fg,Bg,Rg],Sg=[yg,Xg,...c],Jg=[...c,Vg,Gg,Bg];function kg(g,I,C){switch(I){case"xml":C!==h&&g.fail(`xml prefix must be bound to ${h}.`);break;case"xmlns":C!==Z&&g.fail(`xmlns prefix must be bound to ${Z}.`)}switch(C){case Z:g.fail(""===I?`the default namespace may not be set to ${C}.`:`may not assign a prefix (even "xmlns") to the URI ${Z}.`);break;case h:switch(I){case"xml":break;case"":g.fail(`the default namespace may not be set to ${C}.`);break;default:g.fail("may not assign the xml namespace to another prefix.")}}}function Dg(g,I){for(const C of Object.keys(I))kg(g,C,I[C])}const vg=g=>m.test(g),Lg=g=>d.test(g),zg=0,Tg=1,xg=2;C.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];const Ug={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"};class jg{constructor(g){this.opt=null!=g?g:{},this.fragmentOpt=!!this.opt.fragment;const I=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=!1!==this.opt.position,this.fileName=this.opt.fileName,I){this.nameStartCheck=n,this.nameCheck=r,this.isName=vg,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},b);const g=this.opt.additionalNamespaces;null!=g&&(Dg(this,g),Object.assign(this.ns,g))}else this.nameStartCheck=s,this.nameCheck=o,this.isName=Lg,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var g;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=zg,this.attribList=[];const{fragmentOpt:I}=this;this.state=I?M:w,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=I,this.xmlDeclPossible=!I,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:C}=this.opt;if(void 0===C){if(!0===this.opt.forceXMLVersion)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");C="1.0"}this.setXMLVersion(C),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(G),null===(g=this.readyHandler)||void 0===g||g.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(g,I){this[Ug[g]]=I}off(g){this[Ug[g]]=void 0}makeError(g){var I;let C=null!==(I=this.fileName)&&void 0!==I?I:"";return this.trackPosition&&(C.length>0&&(C+=":"),C+=`${this.line}:${this.column}`),C.length>0&&(C+=": "),new Error(C+g)}fail(g){const I=this.makeError(g),C=this.errorHandler;if(void 0===C)throw I;return C(I),this}write(g){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let I=!1;null===g?(I=!0,g=""):"object"==typeof g&&(g=g.toString()),void 0!==this.carriedFromPrevious&&(g=`${this.carriedFromPrevious}${g}`,this.carriedFromPrevious=void 0);let C=g.length;const A=g.charCodeAt(C-1);!I&&(A===mg||A>=55296&&A<=56319)&&(this.carriedFromPrevious=g[C-1],C--,g=g.slice(0,C));const{stateTable:i}=this;for(this.chunk=g,this.i=0;this.i=g.length)return u;const C=g.charCodeAt(I);if(this.column++,C<55296){if(C>=hg||C===ng)return C;switch(C){case rg:return this.line++,this.column=0,this.positionAtNewLine=this.position,rg;case mg:return g.charCodeAt(I+1)===rg&&(this.i=I+2),this.line++,this.column=0,this.positionAtNewLine=this.position,p;default:return this.fail("disallowed character."),C}}if(C>56319)return C>=57344&&C<=65533||this.fail("disallowed character."),C;const A=65536+1024*(C-55296)+(g.charCodeAt(I+1)-56320);return this.i=I+2,A>1114111&&this.fail("disallowed character."),A}getCode11(){const{chunk:g,i:I}=this;if(this.prevI=I,this.i=I+1,I>=g.length)return u;const C=g.charCodeAt(I);if(this.column++,C<55296){if(C>31&&C<127||C>159&&C!==Hg||C===ng)return C;switch(C){case rg:return this.line++,this.column=0,this.positionAtNewLine=this.position,rg;case mg:{const C=g.charCodeAt(I+1);C!==rg&&C!==Ng||(this.i=I+2)}case Ng:case Hg:return this.line++,this.column=0,this.positionAtNewLine=this.position,p;default:return this.fail("disallowed character."),C}}if(C>56319)return C>=57344&&C<=65533||this.fail("disallowed character."),C;const A=65536+1024*(C-55296)+(g.charCodeAt(I+1)-56320);return this.i=I+2,A>1114111&&this.fail("disallowed character."),A}getCodeNorm(){const g=this.getCode();return g===p?rg:g}unget(){this.i=this.prevI,this.column--}captureTo(g){let{i:I}=this;const{chunk:C}=this;for(;;){const A=this.getCode(),i=A===p,e=i?rg:A;if(e===u||g.includes(e))return this.text+=C.slice(I,this.prevI),e;i&&(this.text+=`${C.slice(I,this.prevI)}\n`,I=this.i)}}captureToChar(g){let{i:I}=this;const{chunk:C}=this;for(;;){let A=this.getCode();switch(A){case p:this.text+=`${C.slice(I,this.prevI)}\n`,I=this.i,A=rg;break;case u:return this.text+=C.slice(I),!1}if(A===g)return this.text+=C.slice(I,this.prevI),!0}}captureNameChars(){const{chunk:g,i:I}=this;for(;;){const C=this.getCode();if(C===u)return this.name+=g.slice(I),u;if(!o(C))return this.name+=g.slice(I,this.prevI),C===p?rg:C}}skipSpaces(){for(;;){const g=this.getCodeNorm();if(g===u||!t(g))return g}}setXMLVersion(g){this.currentXMLVersion=g,"1.0"===g?(this.isChar=l,this.getCode=this.getCode10):(this.isChar=a,this.getCode=this.getCode11)}sBegin(){65279===this.chunk.charCodeAt(0)&&(this.i++,this.column++),this.state=W}sBeginWhitespace(){const g=this.i,I=this.skipSpaces();switch(this.prevI!==g&&(this.xmlDeclPossible=!1),I){case Bg:if(this.state=J,0!==this.text.length)throw new Error("no-empty text at start");break;case u:break;default:this.unget(),this.state=M,this.xmlDeclPossible=!1}}sDoctype(){var g;const I=this.captureTo(Fg);switch(I){case Vg:null===(g=this.doctypeHandler)||void 0===g||g.call(this,this.text),this.text="",this.state=M,this.doctype=!0;break;case u:break;default:this.text+=String.fromCodePoint(I),I===Yg?this.state=V:Kg(I)&&(this.state=y,this.q=I)}}sDoctypeQuote(){const g=this.q;this.captureToChar(g)&&(this.text+=String.fromCodePoint(g),this.q=null,this.state=B)}sDTD(){const g=this.captureTo(Mg);g!==u&&(this.text+=String.fromCodePoint(g),g===Rg?this.state=B:g===Bg?this.state=Y:Kg(g)&&(this.state=X,this.q=g))}sDTDQuoted(){const g=this.q;this.captureToChar(g)&&(this.text+=String.fromCodePoint(g),this.state=V,this.q=null)}sDTDOpenWaka(){const g=this.getCodeNorm();switch(this.text+=String.fromCodePoint(g),g){case Zg:this.state=R,this.openWakaBang="";break;case Xg:this.state=f;break;default:this.state=V}}sDTDOpenWakaBang(){const g=String.fromCodePoint(this.getCodeNorm()),I=this.openWakaBang+=g;this.text+=g,"-"!==I&&(this.state="--"===I?N:V,this.openWakaBang="")}sDTDComment(){this.captureToChar(pg)&&(this.text+="-",this.state=H)}sDTDCommentEnding(){const g=this.getCodeNorm();this.text+=String.fromCodePoint(g),this.state=g===pg?K:N}sDTDCommentEnded(){const g=this.getCodeNorm();this.text+=String.fromCodePoint(g),g===Vg?this.state=V:(this.fail("malformed comment."),this.state=N)}sDTDPI(){this.captureToChar(Xg)&&(this.text+="?",this.state=F)}sDTDPIEnding(){const g=this.getCodeNorm();this.text+=String.fromCodePoint(g),g===Vg&&(this.state=V)}sText(){0!==this.tags.length?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:g}=this;const{chunk:I}=this;g:for(;;)switch(this.getCode()){case p:this.entity+=`${I.slice(g,this.prevI)}\n`,g=this.i;break;case Wg:{const{entityReturnState:C}=this,A=this.entity+I.slice(g,this.prevI);let i;this.state=C,""===A?(this.fail("empty entity name."),i="&;"):(i=this.parseEntity(A),this.entity=""),C===M&&void 0===this.textHandler||(this.text+=i);break g}case u:this.entity+=I.slice(g);break g}}sOpenWaka(){const g=this.getCode();if(s(g))this.state=Cg,this.unget(),this.xmlDeclPossible=!1;else switch(g){case wg:this.state=dg,this.xmlDeclPossible=!1;break;case Zg:this.state=k,this.openWakaBang="",this.xmlDeclPossible=!1;break;case Xg:this.state=U;break;default:this.fail("disallowed character in tag name"),this.state=M,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":this.sawRoot||this.reportedTextBeforeRoot||(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=z,this.openWakaBang="";break;case"--":this.state=D,this.openWakaBang="";break;case"DOCTYPE":this.state=B,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(pg)&&(this.state=v)}sCommentEnding(){var g;const I=this.getCodeNorm();I===pg?(this.state=L,null===(g=this.commentHandler)||void 0===g||g.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(I)}`,this.state=D)}sCommentEnded(){const g=this.getCodeNorm();g!==Vg?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(g)}`,this.state=D):this.state=M}sCData(){this.captureToChar(Rg)&&(this.state=T)}sCDataEnding(){const g=this.getCodeNorm();g===Rg?this.state=x:(this.text+=`]${String.fromCodePoint(g)}`,this.state=z)}sCDataEnding2(){var g;const I=this.getCodeNorm();switch(I){case Vg:null===(g=this.cdataHandler)||void 0===g||g.call(this,this.text),this.text="",this.state=M;break;case Rg:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=z}}sPIFirstChar(){const g=this.getCodeNorm();this.nameStartCheck(g)?(this.piTarget+=String.fromCodePoint(g),this.state=j):g===Xg||t(g)?(this.fail("processing instruction without a target."),this.state=g===Xg?O:Q):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(g),this.state=j)}sPIRest(){const{chunk:g,i:I}=this;for(;;){const C=this.getCodeNorm();if(C===u)return void(this.piTarget+=g.slice(I));if(!this.nameCheck(C)){this.piTarget+=g.slice(I,this.prevI);const A=C===Xg;A||t(C)?"xml"===this.piTarget?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=A?Ig:E):this.state=A?O:Q:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(C));break}}}sPIBody(){if(0===this.text.length){const g=this.getCodeNorm();g===Xg?this.state=O:t(g)||(this.text=String.fromCodePoint(g))}else this.captureToChar(Xg)&&(this.state=O)}sPIEnding(){var g;const I=this.getCodeNorm();if(I===Vg){const{piTarget:I}=this;"xml"===I.toLowerCase()&&this.fail("the XML declaration must appear at the start of the document."),null===(g=this.piHandler)||void 0===g||g.call(this,{target:I,body:this.text}),this.piTarget=this.text="",this.state=M}else I===Xg?this.text+="?":(this.text+=`?${String.fromCodePoint(I)}`,this.state=Q);this.xmlDeclPossible=!1}sXMLDeclNameStart(){const g=this.skipSpaces();g!==Xg?g!==u&&(this.state=P,this.name=String.fromCodePoint(g)):this.state=Ig}sXMLDeclName(){const g=this.captureTo(Sg);if(g===Xg)return this.state=Ig,this.name+=this.text,this.text="",void this.fail("XML declaration is incomplete.");if(t(g)||g===yg){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=g===yg?q:_}}sXMLDeclEq(){const g=this.getCodeNorm();if(g===Xg)return this.state=Ig,void this.fail("XML declaration is incomplete.");t(g)||(g!==yg&&this.fail("value required."),this.state=q)}sXMLDeclValueStart(){const g=this.getCodeNorm();if(g===Xg)return this.state=Ig,void this.fail("XML declaration is incomplete.");t(g)||(Kg(g)?this.q=g:(this.fail("value must be quoted."),this.q=hg),this.state=$)}sXMLDeclValue(){const g=this.captureTo([this.q,Xg]);if(g===Xg)return this.state=Ig,this.text="",void this.fail("XML declaration is incomplete.");if(g===u)return;const I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];const g=I;this.xmlDecl.version=g,/^1\.[0-9]+$/.test(g)?this.opt.forceXMLVersion||this.setXMLVersion(g):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(I)||this.fail("encoding value must match \t/^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=I;break;case"standalone":"yes"!==I&&"no"!==I&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=I}this.name="",this.state=gg}sXMLDeclSeparator(){const g=this.getCodeNorm();g!==Xg?(t(g)||(this.fail("whitespace required."),this.unget()),this.state=E):this.state=Ig}sXMLDeclEnding(){var g;this.getCodeNorm()===Vg?("xml"!==this.piTarget?this.fail("processing instructions are not allowed before root."):"version"!==this.name&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),null===(g=this.xmldeclHandler)||void 0===g||g.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=M):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var g;const I=this.captureNameChars();if(I===u)return;const C=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=C.ns=Object.create(null)),null===(g=this.openTagStartHandler)||void 0===g||g.call(this,C),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),I){case Vg:this.openTag();break;case wg:this.state=Ag;break;default:t(I)||this.fail("disallowed character in tag name."),this.state=ig}}sOpenTagSlash(){this.getCode()===Vg?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=ig)}sAttrib(){const g=this.skipSpaces();g!==u&&(s(g)?(this.unget(),this.state=eg):g===Vg?this.openTag():g===wg?this.state=Ag:this.fail("disallowed character in attribute name."))}sAttribName(){const g=this.captureNameChars();g===yg?this.state=lg:t(g)?this.state=tg:g===Vg?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):g!==u&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){const g=this.skipSpaces();switch(g){case u:return;case yg:this.state=lg;break;default:this.fail("attribute without value."),this.text="",this.name="",g===Vg?this.openTag():s(g)?(this.unget(),this.state=eg):(this.fail("disallowed character in attribute name."),this.state=ig)}}sAttribValue(){const g=this.getCodeNorm();Kg(g)?(this.q=g,this.state=sg):t(g)||(this.fail("unquoted attribute value."),this.state=cg,this.unget())}sAttribValueQuoted(){const{q:g,chunk:I}=this;let{i:C}=this;for(;;)switch(this.getCode()){case g:return this.pushAttrib(this.name,this.text+I.slice(C,this.prevI)),this.name=this.text="",this.q=null,void(this.state=og);case Gg:return this.text+=I.slice(C,this.prevI),this.state=S,void(this.entityReturnState=sg);case rg:case p:case ng:this.text+=`${I.slice(C,this.prevI)} `,C=this.i;break;case Bg:return this.text+=I.slice(C,this.prevI),void this.fail("disallowed character.");case u:return void(this.text+=I.slice(C))}}sAttribValueClosed(){const g=this.getCodeNorm();t(g)?this.state=ig:g===Vg?this.openTag():g===wg?this.state=Ag:s(g)?(this.fail("no whitespace between attributes."),this.unget(),this.state=eg):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){const g=this.captureTo(Jg);switch(g){case Gg:this.state=S,this.entityReturnState=cg;break;case Bg:this.fail("disallowed character.");break;case u:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",g===Vg?this.openTag():this.state=ig}}sCloseTag(){const g=this.captureNameChars();g===Vg?this.closeTag():t(g)?this.state=ag:g!==u&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case Vg:this.closeTag();break;case u:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:g,forbiddenState:I}=this;const{chunk:C,textHandler:A}=this;g:for(;;)switch(this.getCode()){case Bg:if(this.state=J,void 0!==A){const{text:I}=this,i=C.slice(g,this.prevI);0!==I.length?(A(I+i),this.text=""):0!==i.length&&A(i)}I=zg;break g;case Gg:this.state=S,this.entityReturnState=M,void 0!==A&&(this.text+=C.slice(g,this.prevI)),I=zg;break g;case Rg:switch(I){case zg:I=Tg;break;case Tg:I=xg;break;case xg:break;default:throw new Error("impossible state")}break;case Vg:I===xg&&this.fail('the string "]]>" is disallowed in char data.'),I=zg;break;case p:void 0!==A&&(this.text+=`${C.slice(g,this.prevI)}\n`),g=this.i,I=zg;break;case u:void 0!==A&&(this.text+=C.slice(g));break g;default:I=zg}this.forbiddenState=I}handleTextOutsideRoot(){let{i:g}=this;const{chunk:I,textHandler:C}=this;let A=!1;g:for(;;){const i=this.getCode();switch(i){case Bg:if(this.state=J,void 0!==C){const{text:A}=this,i=I.slice(g,this.prevI);0!==A.length?(C(A+i),this.text=""):0!==i.length&&C(i)}break g;case Gg:this.state=S,this.entityReturnState=M,void 0!==C&&(this.text+=I.slice(g,this.prevI)),A=!0;break g;case p:void 0!==C&&(this.text+=`${I.slice(g,this.prevI)}\n`),g=this.i;break;case u:void 0!==C&&(this.text+=I.slice(g));break g;default:t(i)||(A=!0)}}A&&(this.sawRoot||this.reportedTextBeforeRoot||(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(g,I){var C;const{prefix:A,local:i}=this.qname(g),e={name:g,prefix:A,local:i,value:I};if(this.attribList.push(e),null===(C=this.attributeHandler)||void 0===C||C.call(this,e),"xmlns"===A){const g=I.trim();"1.0"===this.currentXMLVersion&&""===g&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[i]=g,kg(this,i,g)}else if("xmlns"===g){const g=I.trim();this.topNS[""]=g,kg(this,"",g)}}pushAttribPlain(g,I){var C;const A={name:g,value:I};this.attribList.push(A),null===(C=this.attributeHandler)||void 0===C||C.call(this,A)}end(){var g,I;this.sawRoot||this.fail("document must contain a root element.");const{tags:C}=this;for(;C.length>0;){const g=C.pop();this.fail(`unclosed tag: ${g.name}`)}this.state!==w&&this.state!==M&&this.fail("unexpected end.");const{text:A}=this;return 0!==A.length&&(null===(g=this.textHandler)||void 0===g||g.call(this,A),this.text=""),this._closed=!0,null===(I=this.endHandler)||void 0===I||I.call(this),this._init(),this}resolve(g){var I,C;let A=this.topNS[g];if(void 0!==A)return A;const{tags:i}=this;for(let e=i.length-1;e>=0;e--)if(A=i[e].ns[g],void 0!==A)return A;return A=this.ns[g],void 0!==A?A:null===(C=(I=this.opt).resolvePrefix)||void 0===C?void 0:C.call(I,g)}qname(g){const I=g.indexOf(":");if(-1===I)return{prefix:"",local:g};const C=g.slice(I+1),A=g.slice(0,I);return(""===A||""===C||C.includes(":"))&&this.fail(`malformed name: ${g}.`),{prefix:A,local:C}}processAttribsNS(){var g;const{attribList:I}=this,C=this.tag;{const{prefix:I,local:A}=this.qname(C.name);C.prefix=I,C.local=A;const i=C.uri=null!==(g=this.resolve(I))&&void 0!==g?g:"";""!==I&&("xmlns"===I&&this.fail('tags may not have "xmlns" as prefix.'),""===i&&(this.fail(`unbound namespace prefix: ${JSON.stringify(I)}.`),C.uri=I))}if(0===I.length)return;const{attributes:A}=C,i=new Set;for(const e of I){const{name:g,prefix:I,local:C}=e;let t,l;""===I?(t="xmlns"===g?Z:"",l=g):(t=this.resolve(I),void 0===t&&(this.fail(`unbound namespace prefix: ${JSON.stringify(I)}.`),t=I),l=`{${t}}${C}`),i.has(l)&&this.fail(`duplicate attribute: ${l}.`),i.add(l),e.uri=t,A[g]=e}this.attribList=[]}processAttribsPlain(){const{attribList:g}=this,I=this.tag.attributes;for(const{name:C,value:A}of g)void 0!==I[C]&&this.fail(`duplicate attribute: ${C}.`),I[C]=A;this.attribList=[]}openTag(){var g;this.processAttribs();const{tags:I}=this,C=this.tag;C.isSelfClosing=!1,null===(g=this.openTagHandler)||void 0===g||g.call(this,C),I.push(C),this.state=M,this.name=""}openSelfClosingTag(){var g,I,C;this.processAttribs();const{tags:A}=this,i=this.tag;i.isSelfClosing=!0,null===(g=this.openTagHandler)||void 0===g||g.call(this,i),null===(I=this.closeTagHandler)||void 0===I||I.call(this,i),null===(this.tag=null!==(C=A[A.length-1])&&void 0!==C?C:null)&&(this.closedRoot=!0),this.state=M,this.name=""}closeTag(){const{tags:g,name:I}=this;if(this.state=M,this.name="",""===I)return this.fail("weird empty close tag."),void(this.text+="");const C=this.closeTagHandler;let A=g.length;for(;A-- >0;){const A=this.tag=g.pop();if(this.topNS=A.ns,null==C||C(A),A.name===I)break;this.fail("unexpected close tag.")}0===A?this.closedRoot=!0:A<0&&(this.fail(`unmatched closing tag: ${I}.`),this.text+=``)}parseEntity(g){if("#"!==g[0]){const I=this.ENTITIES[g];return void 0!==I?I:(this.fail(this.isName(g)?"undefined entity.":"disallowed character in entity name."),`&${g};`)}let I=NaN;return"x"===g[1]&&/^#x[0-9a-f]+$/i.test(g)?I=parseInt(g.slice(2),16):/^#[0-9]+$/.test(g)&&(I=parseInt(g.slice(1),10)),this.isChar(I)?String.fromCodePoint(I):(this.fail("malformed character entity."),`&${g};`)}}C.SaxesParser=jg},{"xmlchars/xml/1.0/ed5":543,"xmlchars/xml/1.1/ed2":544,"xmlchars/xmlns/1.0/ed3":545}],497:[function(g,I,C){var A=g("safe-buffer").Buffer;function i(g,I){this._block=A.alloc(g),this._finalSize=I,this._blockSize=g,this._len=0}i.prototype.update=function(g,I){"string"==typeof g&&(I=I||"utf8",g=A.from(g,I));for(var C=this._block,i=this._blockSize,e=g.length,t=this._len,l=0;l=this._finalSize&&(this._update(this._block),this._block.fill(0));var C=8*this._len;if(C<=4294967295)this._block.writeUInt32BE(C,this._blockSize-4);else{var A=(4294967295&C)>>>0,i=(C-A)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(A,this._blockSize-4)}this._update(this._block);var e=this._hash();return g?e.toString(g):e},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},I.exports=i},{"safe-buffer":494}],498:[function(g,I,C){var A=I.exports=function(g){g=g.toLowerCase();var I=A[g];if(!I)throw new Error(g+" is not supported (we accept pull requests)");return new I};A.sha=g("./sha"),A.sha1=g("./sha1"),A.sha224=g("./sha224"),A.sha256=g("./sha256"),A.sha384=g("./sha384"),A.sha512=g("./sha512")},{"./sha":499,"./sha1":500,"./sha224":501,"./sha256":502,"./sha384":503,"./sha512":504}],499:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,t=[1518500249,1859775393,-1894007588,-899497514],l=new Array(80);function s(){this.init(),this._w=l,i.call(this,64,56)}function o(g){return g<<5|g>>>27}function c(g){return g<<30|g>>>2}function d(g,I,C,A){return 0===g?I&C|~I&A:2===g?I&C|I&A|C&A:I^C^A}A(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,l=0|this._e,s=0;s<16;++s)I[s]=g.readInt32BE(4*s);for(;s<80;++s)I[s]=I[s-3]^I[s-8]^I[s-14]^I[s-16];for(var a=0;a<80;++a){var n=~~(a/20),r=o(C)+d(n,A,i,e)+l+I[a]+t[n]|0;l=e,e=i,i=c(A),A=C,C=r}this._a=C+this._a|0,this._b=A+this._b|0,this._c=i+this._c|0,this._d=e+this._d|0,this._e=l+this._e|0},s.prototype._hash=function(){var g=e.allocUnsafe(20);return g.writeInt32BE(0|this._a,0),g.writeInt32BE(0|this._b,4),g.writeInt32BE(0|this._c,8),g.writeInt32BE(0|this._d,12),g.writeInt32BE(0|this._e,16),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],500:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,t=[1518500249,1859775393,-1894007588,-899497514],l=new Array(80);function s(){this.init(),this._w=l,i.call(this,64,56)}function o(g){return g<<1|g>>>31}function c(g){return g<<5|g>>>27}function d(g){return g<<30|g>>>2}function a(g,I,C,A){return 0===g?I&C|~I&A:2===g?I&C|I&A|C&A:I^C^A}A(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,l=0|this._e,s=0;s<16;++s)I[s]=g.readInt32BE(4*s);for(;s<80;++s)I[s]=o(I[s-3]^I[s-8]^I[s-14]^I[s-16]);for(var n=0;n<80;++n){var r=~~(n/20),m=c(C)+a(r,A,i,e)+l+I[n]+t[r]|0;l=e,e=i,i=d(A),A=C,C=m}this._a=C+this._a|0,this._b=A+this._b|0,this._c=i+this._c|0,this._d=e+this._d|0,this._e=l+this._e|0},s.prototype._hash=function(){var g=e.allocUnsafe(20);return g.writeInt32BE(0|this._a,0),g.writeInt32BE(0|this._b,4),g.writeInt32BE(0|this._c,8),g.writeInt32BE(0|this._d,12),g.writeInt32BE(0|this._e,16),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],501:[function(g,I,C){var A=g("inherits"),i=g("./sha256"),e=g("./hash"),t=g("safe-buffer").Buffer,l=new Array(64);function s(){this.init(),this._w=l,e.call(this,64,56)}A(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var g=t.allocUnsafe(28);return g.writeInt32BE(this._a,0),g.writeInt32BE(this._b,4),g.writeInt32BE(this._c,8),g.writeInt32BE(this._d,12),g.writeInt32BE(this._e,16),g.writeInt32BE(this._f,20),g.writeInt32BE(this._g,24),g},I.exports=s},{"./hash":497,"./sha256":502,inherits:440,"safe-buffer":494}],502:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,t=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=new Array(64);function s(){this.init(),this._w=l,i.call(this,64,56)}function o(g,I,C){return C^g&(I^C)}function c(g,I,C){return g&I|C&(g|I)}function d(g){return(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10)}function a(g){return(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7)}function n(g){return(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3}function r(g){return(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10}A(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,l=0|this._e,s=0|this._f,m=0|this._g,h=0|this._h,Z=0;Z<16;++Z)I[Z]=g.readInt32BE(4*Z);for(;Z<64;++Z)I[Z]=r(I[Z-2])+I[Z-7]+n(I[Z-15])+I[Z-16]|0;for(var b=0;b<64;++b){var G=h+a(l)+o(l,s,m)+t[b]+I[b]|0,u=d(C)+c(C,A,i)|0;h=m,m=s,s=l,l=e+G|0,e=i,i=A,A=C,C=G+u|0}this._a=C+this._a|0,this._b=A+this._b|0,this._c=i+this._c|0,this._d=e+this._d|0,this._e=l+this._e|0,this._f=s+this._f|0,this._g=m+this._g|0,this._h=h+this._h|0},s.prototype._hash=function(){var g=e.allocUnsafe(32);return g.writeInt32BE(this._a,0),g.writeInt32BE(this._b,4),g.writeInt32BE(this._c,8),g.writeInt32BE(this._d,12),g.writeInt32BE(this._e,16),g.writeInt32BE(this._f,20),g.writeInt32BE(this._g,24),g.writeInt32BE(this._h,28),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],503:[function(g,I,C){var A=g("inherits"),i=g("./sha512"),e=g("./hash"),t=g("safe-buffer").Buffer,l=new Array(160);function s(){this.init(),this._w=l,e.call(this,128,112)}A(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var g=t.allocUnsafe(48);function I(I,C,A){g.writeInt32BE(I,A),g.writeInt32BE(C,A+4)}return I(this._ah,this._al,0),I(this._bh,this._bl,8),I(this._ch,this._cl,16),I(this._dh,this._dl,24),I(this._eh,this._el,32),I(this._fh,this._fl,40),g},I.exports=s},{"./hash":497,"./sha512":504,inherits:440,"safe-buffer":494}],504:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,t=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],l=new Array(160);function s(){this.init(),this._w=l,i.call(this,128,112)}function o(g,I,C){return C^g&(I^C)}function c(g,I,C){return g&I|C&(g|I)}function d(g,I){return(g>>>28|I<<4)^(I>>>2|g<<30)^(I>>>7|g<<25)}function a(g,I){return(g>>>14|I<<18)^(g>>>18|I<<14)^(I>>>9|g<<23)}function n(g,I){return(g>>>1|I<<31)^(g>>>8|I<<24)^g>>>7}function r(g,I){return(g>>>1|I<<31)^(g>>>8|I<<24)^(g>>>7|I<<25)}function m(g,I){return(g>>>19|I<<13)^(I>>>29|g<<3)^g>>>6}function h(g,I){return(g>>>19|I<<13)^(I>>>29|g<<3)^(g>>>6|I<<26)}function Z(g,I){return g>>>0>>0?1:0}A(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._ah,A=0|this._bh,i=0|this._ch,e=0|this._dh,l=0|this._eh,s=0|this._fh,b=0|this._gh,G=0|this._hh,u=0|this._al,p=0|this._bl,w=0|this._cl,W=0|this._dl,B=0|this._el,y=0|this._fl,V=0|this._gl,X=0|this._hl,Y=0;Y<32;Y+=2)I[Y]=g.readInt32BE(4*Y),I[Y+1]=g.readInt32BE(4*Y+4);for(;Y<160;Y+=2){var R=I[Y-30],N=I[Y-30+1],H=n(R,N),K=r(N,R),f=m(R=I[Y-4],N=I[Y-4+1]),F=h(N,R),M=I[Y-14],S=I[Y-14+1],J=I[Y-32],k=I[Y-32+1],D=K+S|0,v=H+M+Z(D,K)|0;v=(v=v+f+Z(D=D+F|0,F)|0)+J+Z(D=D+k|0,k)|0,I[Y]=v,I[Y+1]=D}for(var L=0;L<160;L+=2){v=I[L],D=I[L+1];var z=c(C,A,i),T=c(u,p,w),x=d(C,u),U=d(u,C),j=a(l,B),Q=a(B,l),O=t[L],E=t[L+1],P=o(l,s,b),_=o(B,y,V),q=X+Q|0,$=G+j+Z(q,X)|0;$=($=($=$+P+Z(q=q+_|0,_)|0)+O+Z(q=q+E|0,E)|0)+v+Z(q=q+D|0,D)|0;var gg=U+T|0,Ig=x+z+Z(gg,U)|0;G=b,X=V,b=s,V=y,s=l,y=B,l=e+$+Z(B=W+q|0,W)|0,e=i,W=w,i=A,w=p,A=C,p=u,C=$+Ig+Z(u=q+gg|0,q)|0}this._al=this._al+u|0,this._bl=this._bl+p|0,this._cl=this._cl+w|0,this._dl=this._dl+W|0,this._el=this._el+B|0,this._fl=this._fl+y|0,this._gl=this._gl+V|0,this._hl=this._hl+X|0,this._ah=this._ah+C+Z(this._al,u)|0,this._bh=this._bh+A+Z(this._bl,p)|0,this._ch=this._ch+i+Z(this._cl,w)|0,this._dh=this._dh+e+Z(this._dl,W)|0,this._eh=this._eh+l+Z(this._el,B)|0,this._fh=this._fh+s+Z(this._fl,y)|0,this._gh=this._gh+b+Z(this._gl,V)|0,this._hh=this._hh+G+Z(this._hl,X)|0},s.prototype._hash=function(){var g=e.allocUnsafe(64);function I(I,C,A){g.writeInt32BE(I,A),g.writeInt32BE(C,A+4)}return I(this._ah,this._al,0),I(this._bh,this._bl,8),I(this._ch,this._cl,16),I(this._dh,this._dl,24),I(this._eh,this._el,32),I(this._fh,this._fl,40),I(this._gh,this._gl,48),I(this._hh,this._hl,56),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],505:[function(g,I,C){I.exports=i;var A=g("events").EventEmitter;function i(){A.call(this)}g("inherits")(i,A),i.Readable=g("readable-stream/readable.js"),i.Writable=g("readable-stream/writable.js"),i.Duplex=g("readable-stream/duplex.js"),i.Transform=g("readable-stream/transform.js"),i.PassThrough=g("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(g,I){var C=this;function i(I){g.writable&&!1===g.write(I)&&C.pause&&C.pause()}function e(){C.readable&&C.resume&&C.resume()}C.on("data",i),g.on("drain",e),g._isStdio||I&&!1===I.end||(C.on("end",l),C.on("close",s));var t=!1;function l(){t||(t=!0,g.end())}function s(){t||(t=!0,"function"==typeof g.destroy&&g.destroy())}function o(g){if(c(),0===A.listenerCount(this,"error"))throw g}function c(){C.removeListener("data",i),g.removeListener("drain",e),C.removeListener("end",l),C.removeListener("close",s),C.removeListener("error",o),g.removeListener("error",o),C.removeListener("end",c),C.removeListener("close",c),g.removeListener("close",c)}return C.on("error",o),g.on("error",o),C.on("end",c),C.on("close",c),g.on("close",c),g.emit("pipe",C),g}},{events:422,inherits:440,"readable-stream/duplex.js":507,"readable-stream/passthrough.js":516,"readable-stream/readable.js":517,"readable-stream/transform.js":518,"readable-stream/writable.js":519}],506:[function(g,I,C){var A={}.toString;I.exports=Array.isArray||function(g){return"[object Array]"==A.call(g)}},{}],507:[function(g,I,C){I.exports=g("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":508}],508:[function(g,I,C){var A=g("process-nextick-args"),i=Object.keys||function(g){var I=[];for(var C in g)I.push(C);return I};I.exports=d;var e=Object.create(g("core-util-is"));e.inherits=g("inherits");var t=g("./_stream_readable"),l=g("./_stream_writable");e.inherits(d,t);for(var s=i(l.prototype),o=0;o0?("string"==typeof I||t.objectMode||Object.getPrototypeOf(I)===o.prototype||(I=d(I)),A?t.endEmitted?g.emit("error",new Error("stream.unshift() after end event")):B(g,t,I,!0):t.ended?g.emit("error",new Error("stream.push() after EOF")):(t.reading=!1,t.decoder&&!C?(I=t.decoder.write(I),t.objectMode||0!==I.length?B(g,t,I,!1):f(g,t)):B(g,t,I,!1))):A||(t.reading=!1)),V(t)}function B(g,I,C,A){I.flowing&&0===I.length&&!I.sync?(g.emit("data",C),g.read(0)):(I.length+=I.objectMode?1:C.length,A?I.buffer.unshift(C):I.buffer.push(C),I.needReadable&&H(g)),f(g,I)}function y(g,I){var C;return a(I)||"string"==typeof I||void 0===I||g.objectMode||(C=new TypeError("Invalid non-string/buffer chunk")),C}function V(g){return!g.ended&&(g.needReadable||g.length=X?g=X:(g--,g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g++),g}function R(g,I){return g<=0||0===I.length&&I.ended?0:I.objectMode?1:g!=g?I.flowing&&I.length?I.buffer.head.data.length:I.length:(g>I.highWaterMark&&(I.highWaterMark=Y(g)),g<=I.length?g:I.ended?I.length:(I.needReadable=!0,0))}function N(g,I){if(!I.ended){if(I.decoder){var C=I.decoder.end();C&&C.length&&(I.buffer.push(C),I.length+=I.objectMode?1:C.length)}I.ended=!0,H(g)}}function H(g){var I=g._readableState;I.needReadable=!1,I.emittedReadable||(m("emitReadable",I.flowing),I.emittedReadable=!0,I.sync?i.nextTick(K,g):K(g))}function K(g){m("emit readable"),g.emit("readable"),D(g)}function f(g,I){I.readingMore||(I.readingMore=!0,i.nextTick(F,g,I))}function F(g,I){for(var C=I.length;!I.reading&&!I.flowing&&!I.ended&&I.length=I.length?(C=I.decoder?I.buffer.join(""):1===I.buffer.length?I.buffer.head.data:I.buffer.concat(I.length),I.buffer.clear()):C=L(g,I.buffer,I.decoder),C);var C}function L(g,I,C){var A;return ge.length?e.length:g;if(t===e.length?i+=e:i+=e.slice(0,g),0==(g-=t)){t===e.length?(++A,C.next?I.head=C.next:I.head=I.tail=null):(I.head=C,C.data=e.slice(t));break}++A}return I.length-=A,i}function T(g,I){var C=o.allocUnsafe(g),A=I.head,i=1;for(A.data.copy(C),g-=A.data.length;A=A.next;){var e=A.data,t=g>e.length?e.length:g;if(e.copy(C,C.length-g,0,t),0==(g-=t)){t===e.length?(++i,A.next?I.head=A.next:I.head=I.tail=null):(I.head=A,A.data=e.slice(t));break}++i}return I.length-=i,C}function x(g){var I=g._readableState;if(I.length>0)throw new Error('"endReadable()" called on non-empty stream');I.endEmitted||(I.ended=!0,i.nextTick(U,I,g))}function U(g,I){g.endEmitted||0!==g.length||(g.endEmitted=!0,I.readable=!1,I.emit("end"))}function j(g,I){for(var C=0,A=g.length;C=I.highWaterMark||I.ended))return m("read: emitReadable",I.length,I.ended),0===I.length&&I.ended?x(this):H(this),null;if(0===(g=R(g,I))&&I.ended)return 0===I.length&&x(this),null;var A,i=I.needReadable;return m("need readable",i),(0===I.length||I.length-g0?v(g,I):null)?(I.needReadable=!0,g=0):I.length-=g,0===I.length&&(I.ended||(I.needReadable=!0),C!==g&&I.ended&&x(this)),null!==A&&this.emit("data",A),A},w.prototype._read=function(g){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(g,I){var A=this,e=this._readableState;switch(e.pipesCount){case 0:e.pipes=g;break;case 1:e.pipes=[e.pipes,g];break;default:e.pipes.push(g)}e.pipesCount+=1,m("pipe count=%d opts=%j",e.pipesCount,I);var t=I&&!1===I.end||g===C.stdout||g===C.stderr?G:o;function s(g,I){m("onunpipe"),g===A&&I&&!1===I.hasUnpiped&&(I.hasUnpiped=!0,a())}function o(){m("onend"),g.end()}e.endEmitted?i.nextTick(t):A.once("end",t),g.on("unpipe",s);var c=M(A);g.on("drain",c);var d=!1;function a(){m("cleanup"),g.removeListener("close",Z),g.removeListener("finish",b),g.removeListener("drain",c),g.removeListener("error",h),g.removeListener("unpipe",s),A.removeListener("end",o),A.removeListener("end",G),A.removeListener("data",r),d=!0,!e.awaitDrain||g._writableState&&!g._writableState.needDrain||c()}var n=!1;function r(I){m("ondata"),n=!1,!1!==g.write(I)||n||((1===e.pipesCount&&e.pipes===g||e.pipesCount>1&&-1!==j(e.pipes,g))&&!d&&(m("false write response, pause",e.awaitDrain),e.awaitDrain++,n=!0),A.pause())}function h(I){m("onerror",I),G(),g.removeListener("error",h),0===l(g,"error")&&g.emit("error",I)}function Z(){g.removeListener("finish",b),G()}function b(){m("onfinish"),g.removeListener("close",Z),G()}function G(){m("unpipe"),A.unpipe(g)}return A.on("data",r),u(g,"error",h),g.once("close",Z),g.once("finish",b),g.emit("pipe",A),e.flowing||(m("pipe resume"),A.resume()),g},w.prototype.unpipe=function(g){var I=this._readableState,C={hasUnpiped:!1};if(0===I.pipesCount)return this;if(1===I.pipesCount)return g&&g!==I.pipes||(g||(g=I.pipes),I.pipes=null,I.pipesCount=0,I.flowing=!1,g&&g.emit("unpipe",this,C)),this;if(!g){var A=I.pipes,i=I.pipesCount;I.pipes=null,I.pipesCount=0,I.flowing=!1;for(var e=0;e-1?i:e.nextTick;u.WritableState=G;var o=Object.create(g("core-util-is"));o.inherits=g("inherits");var c={deprecate:g("util-deprecate")},d=g("./internal/streams/stream"),a=g("safe-buffer").Buffer,n=(void 0!==A?A:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};function r(g){return a.from(g)}function m(g){return a.isBuffer(g)||g instanceof n}var h,Z=g("./internal/streams/destroy");function b(){}function G(I,C){l=l||g("./_stream_duplex"),I=I||{};var A=C instanceof l;this.objectMode=!!I.objectMode,A&&(this.objectMode=this.objectMode||!!I.writableObjectMode);var i=I.highWaterMark,e=I.writableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:A&&(e||0===e)?e:s,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===I.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=I.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(g){Y(C,g)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}function u(I){if(l=l||g("./_stream_duplex"),!(h.call(u,this)||this instanceof l))return new u(I);this._writableState=new G(I,this),this.writable=!0,I&&("function"==typeof I.write&&(this._write=I.write),"function"==typeof I.writev&&(this._writev=I.writev),"function"==typeof I.destroy&&(this._destroy=I.destroy),"function"==typeof I.final&&(this._final=I.final)),d.call(this)}function p(g,I){var C=new Error("write after end");g.emit("error",C),e.nextTick(I,C)}function w(g,I,C,A){var i=!0,t=!1;return null===C?t=new TypeError("May not write null values to stream"):"string"==typeof C||void 0===C||I.objectMode||(t=new TypeError("Invalid non-string/buffer chunk")),t&&(g.emit("error",t),e.nextTick(A,t),i=!1),i}function W(g,I,C){return g.objectMode||!1===g.decodeStrings||"string"!=typeof I||(I=a.from(I,C)),I}function B(g,I,C,A,i,e){if(!C){var t=W(I,A,i);A!==t&&(C=!0,i="buffer",A=t)}var l=I.objectMode?1:A.length;I.length+=l;var s=I.length-1))throw new TypeError("Unknown encoding: "+g);return this._writableState.defaultEncoding=g,this},Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),u.prototype._write=function(g,I,C){C(new Error("_write() is not implemented"))},u.prototype._writev=null,u.prototype.end=function(g,I,C){var A=this._writableState;"function"==typeof g?(C=g,g=null,I=null):"function"==typeof I&&(C=I,I=null),null!=g&&this.write(g,I),A.corked&&(A.corked=1,this.uncork()),A.ending||S(this,A,C)},Object.defineProperty(u.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(g){this._writableState&&(this._writableState.destroyed=g)}}),u.prototype.destroy=Z.destroy,u.prototype._undestroy=Z.undestroy,u.prototype._destroy=function(g,I){this.end(),I(g)}}).call(this)}).call(this,g("_process"),void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},g("timers").setImmediate)},{"./_stream_duplex":508,"./internal/streams/destroy":514,"./internal/streams/stream":515,_process:467,"core-util-is":383,inherits:440,"process-nextick-args":466,"safe-buffer":520,timers:523,"util-deprecate":524}],513:[function(g,I,C){function A(g,I){if(!(g instanceof I))throw new TypeError("Cannot call a class as a function")}var i=g("safe-buffer").Buffer,e=g("util");function t(g,I,C){g.copy(I,C)}I.exports=function(){function g(){A(this,g),this.head=null,this.tail=null,this.length=0}return g.prototype.push=function(g){var I={data:g,next:null};this.length>0?this.tail.next=I:this.head=I,this.tail=I,++this.length},g.prototype.unshift=function(g){var I={data:g,next:this.head};0===this.length&&(this.tail=I),this.head=I,++this.length},g.prototype.shift=function(){if(0!==this.length){var g=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,g}},g.prototype.clear=function(){this.head=this.tail=null,this.length=0},g.prototype.join=function(g){if(0===this.length)return"";for(var I=this.head,C=""+I.data;I=I.next;)C+=g+I.data;return C},g.prototype.concat=function(g){if(0===this.length)return i.alloc(0);for(var I=i.allocUnsafe(g>>>0),C=this.head,A=0;C;)t(C.data,I,A),A+=C.data.length,C=C.next;return I},g}(),e&&e.inspect&&e.inspect.custom&&(I.exports.prototype[e.inspect.custom]=function(){var g=e.inspect({length:this.length});return this.constructor.name+" "+g})},{"safe-buffer":520,util:188}],514:[function(g,I,C){var A=g("process-nextick-args");function i(g,I){var C=this,i=this._readableState&&this._readableState.destroyed,e=this._writableState&&this._writableState.destroyed;return i||e?(I?I(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,A.nextTick(t,this,g)):A.nextTick(t,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,(function(g){!I&&g?C._writableState?C._writableState.errorEmitted||(C._writableState.errorEmitted=!0,A.nextTick(t,C,g)):A.nextTick(t,C,g):I&&I(g)})),this)}function e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function t(g,I){g.emit("error",I)}I.exports={destroy:i,undestroy:e}},{"process-nextick-args":466}],515:[function(g,I,C){arguments[4][490][0].apply(C,arguments)},{dup:490,events:422}],516:[function(g,I,C){I.exports=g("./readable").PassThrough},{"./readable":517}],517:[function(g,I,C){(C=I.exports=g("./lib/_stream_readable.js")).Stream=C,C.Readable=C,C.Writable=g("./lib/_stream_writable.js"),C.Duplex=g("./lib/_stream_duplex.js"),C.Transform=g("./lib/_stream_transform.js"),C.PassThrough=g("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":508,"./lib/_stream_passthrough.js":509,"./lib/_stream_readable.js":510,"./lib/_stream_transform.js":511,"./lib/_stream_writable.js":512}],518:[function(g,I,C){I.exports=g("./readable").Transform},{"./readable":517}],519:[function(g,I,C){I.exports=g("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":512}],520:[function(g,I,C){arguments[4][217][0].apply(C,arguments)},{buffer:220,dup:217}],521:[function(g,I,C){arguments[4][218][0].apply(C,arguments)},{dup:218,"safe-buffer":520}],522:[function(g,I,C){arguments[4][218][0].apply(C,arguments)},{dup:218,"safe-buffer":494}],523:[function(g,I,C){(function(I,A){(function(){var i=g("process/browser.js").nextTick,e=Function.prototype.apply,t=Array.prototype.slice,l={},s=0;function o(g,I){this._id=g,this._clearFn=I}C.setTimeout=function(){return new o(e.call(setTimeout,window,arguments),clearTimeout)},C.setInterval=function(){return new o(e.call(setInterval,window,arguments),clearInterval)},C.clearTimeout=C.clearInterval=function(g){g.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},C.enroll=function(g,I){clearTimeout(g._idleTimeoutId),g._idleTimeout=I},C.unenroll=function(g){clearTimeout(g._idleTimeoutId),g._idleTimeout=-1},C._unrefActive=C.active=function(g){clearTimeout(g._idleTimeoutId);var I=g._idleTimeout;I>=0&&(g._idleTimeoutId=setTimeout((function(){g._onTimeout&&g._onTimeout()}),I))},C.setImmediate="function"==typeof I?I:function(g){var I=s++,A=!(arguments.length<2)&&t.call(arguments,1);return l[I]=!0,i((function(){l[I]&&(A?g.apply(null,A):g.call(null),C.clearImmediate(I))})),I},C.clearImmediate="function"==typeof A?A:function(g){delete l[g]}}).call(this)}).call(this,g("timers").setImmediate,g("timers").clearImmediate)},{"process/browser.js":467,timers:523}],524:[function(g,I,C){(function(g){(function(){function C(g,I){if(A("noDeprecation"))return g;var C=!1;function i(){if(!C){if(A("throwDeprecation"))throw new Error(I);A("traceDeprecation")?console.trace(I):console.warn(I),C=!0}return g.apply(this,arguments)}return i}function A(I){try{if(!g.localStorage)return!1}catch(A){return!1}var C=g.localStorage[I];return null!=C&&"true"===String(C).toLowerCase()}I.exports=C}).call(this)}).call(this,void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],525:[function(g,I,C){"function"==typeof Object.create?I.exports=function(g,I){g.super_=I,g.prototype=Object.create(I.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}})}:I.exports=function(g,I){g.super_=I;var C=function(){};C.prototype=I.prototype,g.prototype=new C,g.prototype.constructor=g}},{}],526:[function(g,I,C){I.exports=function(g){return g&&"object"==typeof g&&"function"==typeof g.copy&&"function"==typeof g.fill&&"function"==typeof g.readUInt8}},{}],527:[function(g,I,C){(function(I,A){(function(){var i=/%[sdj%]/g;C.format=function(g){if(!w(g)){for(var I=[],C=0;C=e)return g;switch(g){case"%s":return String(A[C++]);case"%d":return Number(A[C++]);case"%j":try{return JSON.stringify(A[C++])}catch(I){return"[Circular]"}default:return g}})),s=A[C];C=3&&(A.depth=arguments[2]),arguments.length>=4&&(A.colors=arguments[3]),b(I)?A.showHidden=I:I&&C._extend(A,I),B(A.showHidden)&&(A.showHidden=!1),B(A.depth)&&(A.depth=2),B(A.colors)&&(A.colors=!1),B(A.customInspect)&&(A.customInspect=!0),A.colors&&(A.stylize=s),d(A,g,A.depth)}function s(g,I){var C=l.styles[I];return C?"["+l.colors[C][0]+"m"+g+"["+l.colors[C][1]+"m":g}function o(g,I){return g}function c(g){var I={};return g.forEach((function(g,C){I[g]=!0})),I}function d(g,I,A){if(g.customInspect&&I&&R(I.inspect)&&I.inspect!==C.inspect&&(!I.constructor||I.constructor.prototype!==I)){var i=I.inspect(A,g);return w(i)||(i=d(g,i,A)),i}var e=a(g,I);if(e)return e;var t=Object.keys(I),l=c(t);if(g.showHidden&&(t=Object.getOwnPropertyNames(I)),Y(I)&&(t.indexOf("message")>=0||t.indexOf("description")>=0))return n(I);if(0===t.length){if(R(I)){var s=I.name?": "+I.name:"";return g.stylize("[Function"+s+"]","special")}if(y(I))return g.stylize(RegExp.prototype.toString.call(I),"regexp");if(X(I))return g.stylize(Date.prototype.toString.call(I),"date");if(Y(I))return n(I)}var o,b="",G=!1,u=["{","}"];return Z(I)&&(G=!0,u=["[","]"]),R(I)&&(b=" [Function"+(I.name?": "+I.name:"")+"]"),y(I)&&(b=" "+RegExp.prototype.toString.call(I)),X(I)&&(b=" "+Date.prototype.toUTCString.call(I)),Y(I)&&(b=" "+n(I)),0!==t.length||G&&0!=I.length?A<0?y(I)?g.stylize(RegExp.prototype.toString.call(I),"regexp"):g.stylize("[Object]","special"):(g.seen.push(I),o=G?r(g,I,A,l,t):t.map((function(C){return m(g,I,A,l,C,G)})),g.seen.pop(),h(o,b,u)):u[0]+b+u[1]}function a(g,I){if(B(I))return g.stylize("undefined","undefined");if(w(I)){var C="'"+JSON.stringify(I).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g.stylize(C,"string")}return p(I)?g.stylize(""+I,"number"):b(I)?g.stylize(""+I,"boolean"):G(I)?g.stylize("null","null"):void 0}function n(g){return"["+Error.prototype.toString.call(g)+"]"}function r(g,I,C,A,i){for(var e=[],t=0,l=I.length;t-1&&(l=e?l.split("\n").map((function(g){return" "+g})).join("\n").substr(2):"\n"+l.split("\n").map((function(g){return" "+g})).join("\n")):l=g.stylize("[Circular]","special")),B(t)){if(e&&i.match(/^\d+$/))return l;(t=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(t=t.substr(1,t.length-2),t=g.stylize(t,"name")):(t=t.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),t=g.stylize(t,"string"))}return t+": "+l}function h(g,I,C){return g.reduce((function(g,I){return I.indexOf("\n"),g+I.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?C[0]+(""===I?"":I+"\n ")+" "+g.join(",\n ")+" "+C[1]:C[0]+I+" "+g.join(", ")+" "+C[1]}function Z(g){return Array.isArray(g)}function b(g){return"boolean"==typeof g}function G(g){return null===g}function u(g){return null==g}function p(g){return"number"==typeof g}function w(g){return"string"==typeof g}function W(g){return"symbol"==typeof g}function B(g){return void 0===g}function y(g){return V(g)&&"[object RegExp]"===H(g)}function V(g){return"object"==typeof g&&null!==g}function X(g){return V(g)&&"[object Date]"===H(g)}function Y(g){return V(g)&&("[object Error]"===H(g)||g instanceof Error)}function R(g){return"function"==typeof g}function N(g){return null===g||"boolean"==typeof g||"number"==typeof g||"string"==typeof g||"symbol"==typeof g||void 0===g}function H(g){return Object.prototype.toString.call(g)}function K(g){return g<10?"0"+g.toString(10):g.toString(10)}C.debuglog=function(g){if(B(e)&&(e=I.env.NODE_DEBUG||""),g=g.toUpperCase(),!t[g])if(new RegExp("\\b"+g+"\\b","i").test(e)){var A=I.pid;t[g]=function(){var I=C.format.apply(C,arguments);console.error("%s %d: %s",g,A,I)}}else t[g]=function(){};return t[g]},C.inspect=l,l.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},l.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},C.isArray=Z,C.isBoolean=b,C.isNull=G,C.isNullOrUndefined=u,C.isNumber=p,C.isString=w,C.isSymbol=W,C.isUndefined=B,C.isRegExp=y,C.isObject=V,C.isDate=X,C.isError=Y,C.isFunction=R,C.isPrimitive=N,C.isBuffer=g("./support/isBuffer");var f=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function F(){var g=new Date,I=[K(g.getHours()),K(g.getMinutes()),K(g.getSeconds())].join(":");return[g.getDate(),f[g.getMonth()],I].join(" ")}function M(g,I){return Object.prototype.hasOwnProperty.call(g,I)}C.log=function(){console.log("%s - %s",F(),C.format.apply(C,arguments))},C.inherits=g("inherits"),C._extend=function(g,I){if(!I||!V(I))return g;for(var C=Object.keys(I),A=C.length;A--;)g[C[A]]=I[C[A]];return g}}).call(this)}).call(this,g("_process"),void 0!==lC?lC:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":526,_process:467,inherits:525}],528:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),Object.defineProperty(C,"v1",{enumerable:!0,get:function(){return A.default}}),Object.defineProperty(C,"v3",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(C,"v4",{enumerable:!0,get:function(){return e.default}}),Object.defineProperty(C,"v5",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(C,"NIL",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(C,"version",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(C,"validate",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(C,"stringify",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(C,"parse",{enumerable:!0,get:function(){return d.default}});var A=a(g("./v1.js")),i=a(g("./v3.js")),e=a(g("./v4.js")),t=a(g("./v5.js")),l=a(g("./nil.js")),s=a(g("./version.js")),o=a(g("./validate.js")),c=a(g("./stringify.js")),d=a(g("./parse.js"));function a(g){return g&&g.__esModule?g:{default:g}}},{"./nil.js":530,"./parse.js":531,"./stringify.js":535,"./v1.js":536,"./v3.js":537,"./v4.js":539,"./v5.js":540,"./validate.js":541,"./version.js":542}],529:[function(g,I,C){function A(g){if("string"==typeof g){const I=unescape(encodeURIComponent(g));g=new Uint8Array(I.length);for(let C=0;C>5]>>>i%32&255,e=parseInt(A.charAt(C>>>4&15)+A.charAt(15&C),16);I.push(e)}return I}function e(g){return 14+(g+64>>>9<<4)+1}function t(g,I){g[I>>5]|=128<>5]|=(255&g[A/8])<>16)+(I>>16)+(C>>16)<<16|65535&C}function o(g,I){return g<>>32-I}function c(g,I,C,A,i,e){return s(o(s(s(I,g),s(A,e)),i),C)}function d(g,I,C,A,i,e,t){return c(I&C|~I&A,g,I,i,e,t)}function a(g,I,C,A,i,e,t){return c(I&A|C&~A,g,I,i,e,t)}function n(g,I,C,A,i,e,t){return c(I^C^A,g,I,i,e,t)}function r(g,I,C,A,i,e,t){return c(C^(I|~A),g,I,i,e,t)}Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var m=A;C.default=m},{}],530:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A="00000000-0000-0000-0000-000000000000";C.default=A},{}],531:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=i(g("./validate.js"));function i(g){return g&&g.__esModule?g:{default:g}}function e(g){if(!(0,A.default)(g))throw TypeError("Invalid UUID");let I;const C=new Uint8Array(16);return C[0]=(I=parseInt(g.slice(0,8),16))>>>24,C[1]=I>>>16&255,C[2]=I>>>8&255,C[3]=255&I,C[4]=(I=parseInt(g.slice(9,13),16))>>>8,C[5]=255&I,C[6]=(I=parseInt(g.slice(14,18),16))>>>8,C[7]=255&I,C[8]=(I=parseInt(g.slice(19,23),16))>>>8,C[9]=255&I,C[10]=(I=parseInt(g.slice(24,36),16))/1099511627776&255,C[11]=I/4294967296&255,C[12]=I>>>24&255,C[13]=I>>>16&255,C[14]=I>>>8&255,C[15]=255&I,C}var t=e;C.default=t},{"./validate.js":541}],532:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;C.default=A},{}],533:[function(g,I,C){let A;Object.defineProperty(C,"__esModule",{value:!0}),C.default=e;const i=new Uint8Array(16);function e(){if(!A&&(A="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),!A))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return A(i)}},{}],534:[function(g,I,C){function A(g,I,C,A){switch(g){case 0:return I&C^~I&A;case 1:case 3:return I^C^A;case 2:return I&C^I&A^C&A}}function i(g,I){return g<>>32-I}function e(g){const I=[1518500249,1859775393,2400959708,3395469782],C=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof g){const I=unescape(encodeURIComponent(g));g=[];for(let C=0;C>>0;d=c,c=o,o=i(t,30)>>>0,t=e,e=s}C[0]=C[0]+e>>>0,C[1]=C[1]+t>>>0,C[2]=C[2]+o>>>0,C[3]=C[3]+c>>>0,C[4]=C[4]+d>>>0}return[C[0]>>24&255,C[0]>>16&255,C[0]>>8&255,255&C[0],C[1]>>24&255,C[1]>>16&255,C[1]>>8&255,255&C[1],C[2]>>24&255,C[2]>>16&255,C[2]>>8&255,255&C[2],C[3]>>24&255,C[3]>>16&255,C[3]>>8&255,255&C[3],C[4]>>24&255,C[4]>>16&255,C[4]>>8&255,255&C[4]]}Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var t=e;C.default=t},{}],535:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=i(g("./validate.js"));function i(g){return g&&g.__esModule?g:{default:g}}const e=[];for(let s=0;s<256;++s)e.push((s+256).toString(16).substr(1));function t(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const C=(e[g[I+0]]+e[g[I+1]]+e[g[I+2]]+e[g[I+3]]+"-"+e[g[I+4]]+e[g[I+5]]+"-"+e[g[I+6]]+e[g[I+7]]+"-"+e[g[I+8]]+e[g[I+9]]+"-"+e[g[I+10]]+e[g[I+11]]+e[g[I+12]]+e[g[I+13]]+e[g[I+14]]+e[g[I+15]]).toLowerCase();if(!(0,A.default)(C))throw TypeError("Stringified UUID is invalid");return C}var l=t;C.default=l},{"./validate.js":541}],536:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=e(g("./rng.js")),i=e(g("./stringify.js"));function e(g){return g&&g.__esModule?g:{default:g}}let t,l,s=0,o=0;function c(g,I,C){let e=I&&C||0;const c=I||new Array(16);let d=(g=g||{}).node||t,a=void 0!==g.clockseq?g.clockseq:l;if(null==d||null==a){const I=g.random||(g.rng||A.default)();null==d&&(d=t=[1|I[0],I[1],I[2],I[3],I[4],I[5]]),null==a&&(a=l=16383&(I[6]<<8|I[7]))}let n=void 0!==g.msecs?g.msecs:Date.now(),r=void 0!==g.nsecs?g.nsecs:o+1;const m=n-s+(r-o)/1e4;if(m<0&&void 0===g.clockseq&&(a=a+1&16383),(m<0||n>s)&&void 0===g.nsecs&&(r=0),r>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=n,o=r,l=a,n+=122192928e5;const h=(1e4*(268435455&n)+r)%4294967296;c[e++]=h>>>24&255,c[e++]=h>>>16&255,c[e++]=h>>>8&255,c[e++]=255&h;const Z=n/4294967296*1e4&268435455;c[e++]=Z>>>8&255,c[e++]=255&Z,c[e++]=Z>>>24&15|16,c[e++]=Z>>>16&255,c[e++]=a>>>8|128,c[e++]=255&a;for(let A=0;A<6;++A)c[e+A]=d[A];return I||(0,i.default)(c)}var d=c;C.default=d},{"./rng.js":533,"./stringify.js":535}],537:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=e(g("./v35.js")),i=e(g("./md5.js"));function e(g){return g&&g.__esModule?g:{default:g}}var t=(0,A.default)("v3",48,i.default);C.default=t},{"./md5.js":529,"./v35.js":538}],538:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=o,C.URL=C.DNS=void 0;var A=e(g("./stringify.js")),i=e(g("./parse.js"));function e(g){return g&&g.__esModule?g:{default:g}}function t(g){g=unescape(encodeURIComponent(g));const I=[];for(let C=0;C=t&&g<=55295||g===i||g===e||g===A||g>=57344&&g<=65533||g>=65536&&g<=1114111}function s(g){return g===t||g===i||g===e||g===A}function o(g){return g>=65&&g<=90||g>=97&&g<=122||58===g||95===g||8204===g||8205===g||g>=192&&g<=214||g>=216&&g<=246||g>=248&&g<=767||g>=880&&g<=893||g>=895&&g<=8191||g>=8304&&g<=8591||g>=11264&&g<=12271||g>=12289&&g<=55295||g>=63744&&g<=64975||g>=65008&&g<=65533||g>=65536&&g<=983039}function c(g){return o(g)||g>=48&&g<=57||45===g||46===g||183===g||g>=768&&g<=879||g>=8255&&g<=8256}C.S_LIST=[t,i,e,A],C.isChar=l,C.isS=s,C.isNameStartChar=o,C.isNameChar=c},{}],544:[function(g,I,C){ /** * Character classes and associated utilities for the 2nd edition of XML 1.1. * * @author Louis-Dominique Dubeau * @license MIT * @copyright Louis-Dominique Dubeau */ Object.defineProperty(C,"__esModule",{value:!0}),C.CHAR="-퟿-�𐀀-􏿿",C.RESTRICTED_CHAR="-\b\v\f--„†-Ÿ",C.S=" \t\r\n",C.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",C.NAME_CHAR="-"+C.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",C.CHAR_RE=new RegExp("^["+C.CHAR+"]$","u"),C.RESTRICTED_CHAR_RE=new RegExp("^["+C.RESTRICTED_CHAR+"]$","u"),C.S_RE=new RegExp("^["+C.S+"]+$","u"),C.NAME_START_CHAR_RE=new RegExp("^["+C.NAME_START_CHAR+"]$","u"),C.NAME_CHAR_RE=new RegExp("^["+C.NAME_CHAR+"]$","u"),C.NAME_RE=new RegExp("^["+C.NAME_START_CHAR+"]["+C.NAME_CHAR+"]*$","u"),C.NMTOKEN_RE=new RegExp("^["+C.NAME_CHAR+"]+$","u");var A=9,i=10,e=13,t=32;function l(g){return g>=1&&g<=55295||g>=57344&&g<=65533||g>=65536&&g<=1114111}function s(g){return g>=1&&g<=8||11===g||12===g||g>=14&&g<=31||g>=127&&g<=132||g>=134&&g<=159}function o(g){return 9===g||10===g||13===g||g>31&&g<127||133===g||g>159&&g<=55295||g>=57344&&g<=65533||g>=65536&&g<=1114111}function c(g){return g===t||g===i||g===e||g===A}function d(g){return g>=65&&g<=90||g>=97&&g<=122||58===g||95===g||8204===g||8205===g||g>=192&&g<=214||g>=216&&g<=246||g>=248&&g<=767||g>=880&&g<=893||g>=895&&g<=8191||g>=8304&&g<=8591||g>=11264&&g<=12271||g>=12289&&g<=55295||g>=63744&&g<=64975||g>=65008&&g<=65533||g>=65536&&g<=983039}function a(g){return d(g)||g>=48&&g<=57||45===g||46===g||183===g||g>=768&&g<=879||g>=8255&&g<=8256}C.S_LIST=[t,i,e,A],C.isChar=l,C.isRestrictedChar=s,C.isCharAndNotRestricted=o,C.isS=c,C.isNameStartChar=d,C.isNameChar=a},{}],545:[function(g,I,C){function A(g){return g>=65&&g<=90||95===g||g>=97&&g<=122||g>=192&&g<=214||g>=216&&g<=246||g>=248&&g<=767||g>=880&&g<=893||g>=895&&g<=8191||g>=8204&&g<=8205||g>=8304&&g<=8591||g>=11264&&g<=12271||g>=12289&&g<=55295||g>=63744&&g<=64975||g>=65008&&g<=65533||g>=65536&&g<=983039}function i(g){return A(g)||45===g||46===g||g>=48&&g<=57||183===g||g>=768&&g<=879||g>=8255&&g<=8256} /** * Character class utilities for XML NS 1.0 edition 3. * * @author Louis-Dominique Dubeau * @license MIT * @copyright Louis-Dominique Dubeau */ Object.defineProperty(C,"__esModule",{value:!0}),C.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",C.NC_NAME_CHAR="-"+C.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",C.NC_NAME_START_CHAR_RE=new RegExp("^["+C.NC_NAME_START_CHAR+"]$","u"),C.NC_NAME_CHAR_RE=new RegExp("^["+C.NC_NAME_CHAR+"]$","u"),C.NC_NAME_RE=new RegExp("^["+C.NC_NAME_START_CHAR+"]["+C.NC_NAME_CHAR+"]*$","u"),C.isNCNameStartChar=A,C.isNCNameChar=i},{}]},{},[15])(15)}(Xs);var Ys=Xs.exports;function Rs(g){return(Rs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(g){return typeof g}:function(g){return g&&"function"==typeof Symbol&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g})(g)}var Ns=/^\s+/,Hs=/\s+$/;function Ks(g,I){if(I=I||{},(g=g||"")instanceof Ks)return g;if(!(this instanceof Ks))return new Ks(g,I);var C=function(g){var I={r:0,g:0,b:0},C=1,A=null,i=null,e=null,t=!1,l=!1;"string"==typeof g&&(g=function(g){g=g.replace(Ns,"").replace(Hs,"").toLowerCase();var I,C=!1;if(Es[g])g=Es[g],C=!0;else if("transparent"==g)return{r:0,g:0,b:0,a:0,format:"name"};if(I=so.rgb.exec(g))return{r:I[1],g:I[2],b:I[3]};if(I=so.rgba.exec(g))return{r:I[1],g:I[2],b:I[3],a:I[4]};if(I=so.hsl.exec(g))return{h:I[1],s:I[2],l:I[3]};if(I=so.hsla.exec(g))return{h:I[1],s:I[2],l:I[3],a:I[4]};if(I=so.hsv.exec(g))return{h:I[1],s:I[2],v:I[3]};if(I=so.hsva.exec(g))return{h:I[1],s:I[2],v:I[3],a:I[4]};if(I=so.hex8.exec(g))return{r:go(I[1]),g:go(I[2]),b:go(I[3]),a:io(I[4]),format:C?"name":"hex8"};if(I=so.hex6.exec(g))return{r:go(I[1]),g:go(I[2]),b:go(I[3]),format:C?"name":"hex"};if(I=so.hex4.exec(g))return{r:go(I[1]+""+I[1]),g:go(I[2]+""+I[2]),b:go(I[3]+""+I[3]),a:io(I[4]+""+I[4]),format:C?"name":"hex8"};if(I=so.hex3.exec(g))return{r:go(I[1]+""+I[1]),g:go(I[2]+""+I[2]),b:go(I[3]+""+I[3]),format:C?"name":"hex"};return!1}(g));"object"==Rs(g)&&(oo(g.r)&&oo(g.g)&&oo(g.b)?(s=g.r,o=g.g,c=g.b,I={r:255*qs(s,255),g:255*qs(o,255),b:255*qs(c,255)},t=!0,l="%"===String(g.r).substr(-1)?"prgb":"rgb"):oo(g.h)&&oo(g.s)&&oo(g.v)?(A=Co(g.s),i=Co(g.v),I=function(g,I,C){g=6*qs(g,360),I=qs(I,100),C=qs(C,100);var A=Math.floor(g),i=g-A,e=C*(1-I),t=C*(1-i*I),l=C*(1-(1-i)*I),s=A%6,o=[C,t,e,e,l,C][s],c=[l,C,C,t,e,e][s],d=[e,e,l,C,C,t][s];return{r:255*o,g:255*c,b:255*d}}(g.h,A,i),t=!0,l="hsv"):oo(g.h)&&oo(g.s)&&oo(g.l)&&(A=Co(g.s),e=Co(g.l),I=function(g,I,C){var A,i,e;function t(g,I,C){return C<0&&(C+=1),C>1&&(C-=1),C<1/6?g+6*(I-g)*C:C<.5?I:C<2/3?g+(I-g)*(2/3-C)*6:g}if(g=qs(g,360),I=qs(I,100),C=qs(C,100),0===I)A=i=e=C;else{var l=C<.5?C*(1+I):C+I-C*I,s=2*C-l;A=t(s,l,g+1/3),i=t(s,l,g),e=t(s,l,g-1/3)}return{r:255*A,g:255*i,b:255*e}}(g.h,A,e),t=!0,l="hsl"),g.hasOwnProperty("a")&&(C=g.a));var s,o,c;return C=_s(C),{ok:t,format:g.format||l,r:Math.min(255,Math.max(I.r,0)),g:Math.min(255,Math.max(I.g,0)),b:Math.min(255,Math.max(I.b,0)),a:C}}(g);this._originalInput=g,this._r=C.r,this._g=C.g,this._b=C.b,this._a=C.a,this._roundA=Math.round(100*this._a)/100,this._format=I.format||C.format,this._gradientType=I.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=C.ok}function fs(g,I,C){g=qs(g,255),I=qs(I,255),C=qs(C,255);var A,i,e=Math.max(g,I,C),t=Math.min(g,I,C),l=(e+t)/2;if(e==t)A=i=0;else{var s=e-t;switch(i=l>.5?s/(2-e-t):s/(e+t),e){case g:A=(I-C)/s+(I>1)+720)%360;--I;)A.h=(A.h+i)%360,e.push(Ks(A));return e}function Os(g,I){I=I||6;for(var C=Ks(g).toHsv(),A=C.h,i=C.s,e=C.v,t=[],l=1/I;I--;)t.push(Ks({h:A,s:i,v:e})),e=(e+l)%1;return t}Ks.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var g=this.toRgb();return(299*g.r+587*g.g+114*g.b)/1e3},getLuminance:function(){var g,I,C,A=this.toRgb();return g=A.r/255,I=A.g/255,C=A.b/255,.2126*(g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4))+.7152*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))+.0722*(C<=.03928?C/12.92:Math.pow((C+.055)/1.055,2.4))},setAlpha:function(g){return this._a=_s(g),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var g=Fs(this._r,this._g,this._b);return{h:360*g.h,s:g.s,v:g.v,a:this._a}},toHsvString:function(){var g=Fs(this._r,this._g,this._b),I=Math.round(360*g.h),C=Math.round(100*g.s),A=Math.round(100*g.v);return 1==this._a?"hsv("+I+", "+C+"%, "+A+"%)":"hsva("+I+", "+C+"%, "+A+"%, "+this._roundA+")"},toHsl:function(){var g=fs(this._r,this._g,this._b);return{h:360*g.h,s:g.s,l:g.l,a:this._a}},toHslString:function(){var g=fs(this._r,this._g,this._b),I=Math.round(360*g.h),C=Math.round(100*g.s),A=Math.round(100*g.l);return 1==this._a?"hsl("+I+", "+C+"%, "+A+"%)":"hsla("+I+", "+C+"%, "+A+"%, "+this._roundA+")"},toHex:function(g){return Ms(this._r,this._g,this._b,g)},toHexString:function(g){return"#"+this.toHex(g)},toHex8:function(g){return function(g,I,C,A,i){var e=[Io(Math.round(g).toString(16)),Io(Math.round(I).toString(16)),Io(Math.round(C).toString(16)),Io(Ao(A))];if(i&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)&&e[3].charAt(0)==e[3].charAt(1))return e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0)+e[3].charAt(0);return e.join("")}(this._r,this._g,this._b,this._a,g)},toHex8String:function(g){return"#"+this.toHex8(g)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*qs(this._r,255))+"%",g:Math.round(100*qs(this._g,255))+"%",b:Math.round(100*qs(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*qs(this._r,255))+"%, "+Math.round(100*qs(this._g,255))+"%, "+Math.round(100*qs(this._b,255))+"%)":"rgba("+Math.round(100*qs(this._r,255))+"%, "+Math.round(100*qs(this._g,255))+"%, "+Math.round(100*qs(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Ps[Ms(this._r,this._g,this._b,!0)]||!1)},toFilter:function(g){var I="#"+Ss(this._r,this._g,this._b,this._a),C=I,A=this._gradientType?"GradientType = 1, ":"";if(g){var i=Ks(g);C="#"+Ss(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+A+"startColorstr="+I+",endColorstr="+C+")"},toString:function(g){var I=!!g;g=g||this._format;var C=!1,A=this._a<1&&this._a>=0;return I||!A||"hex"!==g&&"hex6"!==g&&"hex3"!==g&&"hex4"!==g&&"hex8"!==g&&"name"!==g?("rgb"===g&&(C=this.toRgbString()),"prgb"===g&&(C=this.toPercentageRgbString()),"hex"!==g&&"hex6"!==g||(C=this.toHexString()),"hex3"===g&&(C=this.toHexString(!0)),"hex4"===g&&(C=this.toHex8String(!0)),"hex8"===g&&(C=this.toHex8String()),"name"===g&&(C=this.toName()),"hsl"===g&&(C=this.toHslString()),"hsv"===g&&(C=this.toHsvString()),C||this.toHexString()):"name"===g&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Ks(this.toString())},_applyModification:function(g,I){var C=g.apply(null,[this].concat([].slice.call(I)));return this._r=C._r,this._g=C._g,this._b=C._b,this.setAlpha(C._a),this},lighten:function(){return this._applyModification(vs,arguments)},brighten:function(){return this._applyModification(Ls,arguments)},darken:function(){return this._applyModification(zs,arguments)},desaturate:function(){return this._applyModification(Js,arguments)},saturate:function(){return this._applyModification(ks,arguments)},greyscale:function(){return this._applyModification(Ds,arguments)},spin:function(){return this._applyModification(Ts,arguments)},_applyCombination:function(g,I){return g.apply(null,[this].concat([].slice.call(I)))},analogous:function(){return this._applyCombination(Qs,arguments)},complement:function(){return this._applyCombination(xs,arguments)},monochromatic:function(){return this._applyCombination(Os,arguments)},splitcomplement:function(){return this._applyCombination(js,arguments)},triad:function(){return this._applyCombination(Us,[3])},tetrad:function(){return this._applyCombination(Us,[4])}},Ks.fromRatio=function(g,I){if("object"==Rs(g)){var C={};for(var A in g)g.hasOwnProperty(A)&&(C[A]="a"===A?g[A]:Co(g[A]));g=C}return Ks(g,I)},Ks.equals=function(g,I){return!(!g||!I)&&Ks(g).toRgbString()==Ks(I).toRgbString()},Ks.random=function(){return Ks.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Ks.mix=function(g,I,C){C=0===C?0:C||50;var A=Ks(g).toRgb(),i=Ks(I).toRgb(),e=C/100;return Ks({r:(i.r-A.r)*e+A.r,g:(i.g-A.g)*e+A.g,b:(i.b-A.b)*e+A.b,a:(i.a-A.a)*e+A.a})},Ks.readability=function(g,I){var C=Ks(g),A=Ks(I);return(Math.max(C.getLuminance(),A.getLuminance())+.05)/(Math.min(C.getLuminance(),A.getLuminance())+.05)},Ks.isReadable=function(g,I,C){var A,i,e=Ks.readability(g,I);switch(i=!1,(A=function(g){var I,C;I=((g=g||{level:"AA",size:"small"}).level||"AA").toUpperCase(),C=(g.size||"small").toLowerCase(),"AA"!==I&&"AAA"!==I&&(I="AA");"small"!==C&&"large"!==C&&(C="small");return{level:I,size:C}}(C)).level+A.size){case"AAsmall":case"AAAlarge":i=e>=4.5;break;case"AAlarge":i=e>=3;break;case"AAAsmall":i=e>=7}return i},Ks.mostReadable=function(g,I,C){var A,i,e,t,l=null,s=0;i=(C=C||{}).includeFallbackColors,e=C.level,t=C.size;for(var o=0;os&&(s=A,l=Ks(I[o]));return Ks.isReadable(g,l,{level:e,size:t})||!i?l:(C.includeFallbackColors=!1,Ks.mostReadable(g,["#fff","#000"],C))};var Es=Ks.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Ps=Ks.hexNames=function(g){var I={};for(var C in g)g.hasOwnProperty(C)&&(I[g[C]]=C);return I}(Es);function _s(g){return g=parseFloat(g),(isNaN(g)||g<0||g>1)&&(g=1),g}function qs(g,I){(function(g){return"string"==typeof g&&-1!=g.indexOf(".")&&1===parseFloat(g)})(g)&&(g="100%");var C=function(g){return"string"==typeof g&&-1!=g.indexOf("%")}(g);return g=Math.min(I,Math.max(0,parseFloat(g))),C&&(g=parseInt(g*I,10)/100),Math.abs(g-I)<1e-6?1:g%I/parseFloat(I)}function $s(g){return Math.min(1,Math.max(0,g))}function go(g){return parseInt(g,16)}function Io(g){return 1==g.length?"0"+g:""+g}function Co(g){return g<=1&&(g=100*g+"%"),g}function Ao(g){return Math.round(255*parseFloat(g)).toString(16)}function io(g){return go(g)/255}var eo,to,lo,so=(to="[\\s|\\(]+("+(eo="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+eo+")[,|\\s]+("+eo+")\\s*\\)?",lo="[\\s|\\(]+("+eo+")[,|\\s]+("+eo+")[,|\\s]+("+eo+")[,|\\s]+("+eo+")\\s*\\)?",{CSS_UNIT:new RegExp(eo),rgb:new RegExp("rgb"+to),rgba:new RegExp("rgba"+lo),hsl:new RegExp("hsl"+to),hsla:new RegExp("hsla"+lo),hsv:new RegExp("hsv"+to),hsva:new RegExp("hsva"+lo),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function oo(g){return!!so.CSS_UNIT.exec(g)}const co=["#FFFFFF","#000000","#BFBFBF","#323232","#4472C4","#ED7D31","#A5A5A5","#FFC000","#5B9BD5","#71AD47"],ao=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#800000","#008000","#000080","#808000","#800080","#008080","#C0C0C0","#808080","#9999FF","#993366","#FFFFCC","#CCFFFF","#660066","#FF8080","#0066CC","#CCCCFF","#000080","#FF00FF","#FFFF00","#00FFFF","#800080","#800000","#008080","#0000FF","#00CCFF","#CCFFFF","#CCFFCC","#FFFF99","#99CCFF","#FF99CC","#CC99FF","#FFCC99","#3366FF","#33CCCC","#99CC00","#FFCC00","#FF9900","#FF6600","#666699","#969696","#003366","#339966","#003300","#333300","#993300","#993366","#333399","#333333","#FFFFFF"],no=80;function ro(g){if("object"==typeof g)return"#000000";if(/^#?[a-f\d]{6}$/i.test(g))return g.startsWith("#")?g:"#"+g;g=g.trim().toLowerCase();const I={};try{const C=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(g)||"";return I.r=parseInt(C[2],16),I.g=parseInt(C[3],16),I.b=parseInt(C[4],16),I.a=parseInt(C[1],16)/255,Ks(`rgba(${I.r}, ${I.g}, ${I.b}, ${I.a})`).toHexString()}catch(C){console.warn(C)}}function mo(g,I){return g>9?"#C7C9CC":void 0===I?co[g]:I>0?function(g,I){const C=EI(g)||[];for(let A=0;A<3;A++)C[A]=Math.floor((255-Number(C[A]))*I+Number(C[A]));return qI(C[0],C[1],C[2])}(co[g],I):PI(co[g],Math.abs(I))}function ho(g,I){const C=[];return g.eachSheet((g=>{const A={name:g.name,styles:[],rows:{},cols:{},merges:[],media:[]},i=[];for(const I in g._merges){A.merges.push(g._merges[I].shortRange);const C={};C.startAddress=g._merges[I].tl,C.endAddress=g._merges[I].br,C.YRange=g._merges[I].model.bottom-g._merges[I].model.top,C.XRange=g._merges[I].model.right-g._merges[I].model.left,i.push(C)}!function(g,I,C){for(let A=0;A<(g.columns||[]).length;A++)I.cols[A.toString()]={},g.columns[A].width?I.cols[A.toString()].width=no+6*g.columns[A].width+(C.widthOffset||0):I.cols[A.toString()].width=no+(C.widthOffset||0);I.cols.len=Math.max(Object.keys(I.cols).length,C.minColLength||0)}(g,A,I),(g._rows||[]).forEach(((g,C)=>{A.rows[C]={cells:{}},g.height?A.rows[C].height=24+g.height+(I.heightOffset||0):A.rows[C].height=24+(I.heightOffset||0),(g._cells||[]).forEach(((g,I)=>{A.rows[C].cells[I]={};const e=si.find(i,(function(I){return I.startAddress===g._address}));e&&g.master.address!==e.startAddress||(e&&(A.rows[C].cells[I].merge=[e.YRange,e.XRange]),A.rows[C].cells[I].text=function(g){const{numFmt:I,value:C,type:A}=g;switch(A){case 2:try{if(g.style.numFmt){if(g.style.numFmt.endsWith("%")){const I=g.style.numFmt.match(/\.(\d+)%/);return I?(100*Number(C)).toFixed(I[1].length)+"%":100*Number(C)+"%"}if(/0(?:\.0+)?/.test(g.style.numFmt)){if(0===Number(C)&&g.style.numFmt.startsWith("_"))return"-";let I=g.style.numFmt.match(/0\.(0+)(_|;|$)/);I=I?I[1].length:0;let A=Number(C).toFixed(I)+"";if(g.style.numFmt.includes("#,##")){A=A.split(".");const g=A[0].split("").reverse(),I=[];for(let C=0;C{const A=g.style.border[C];let i="#000000";"string"==typeof A.color?i=A.color:A.color&&(A.color.argb?i=ro(A.color.argb)||"":Object.prototype.hasOwnProperty.call(A.color,"theme")?i=mo(A.color.theme,A.color.tint):A.color.indexed&&(i=ao[A.color.indexed])),I[C]=[A.style||"thin",i]})),g.style.border2={...g.style.border},g.style.border=I}return g.style}(g)),A.rows[C].cells[I].style=A.styles.length-1)}))})),A._media&&(A.media=A._media),A.rows.len=Math.max(Object.keys(A.rows).length,100),C.push(A)})),{workbookData:C,workbookSource:g,medias:g.media||[]}}let Zo=[];function bo(g,I,C,A){C&&C._media.length&&C._media.forEach((i=>{const{imageId:e,range:t,type:l}=i;if("image"===l){const i=function(g,I,C){var A,i,e,t,l,s,o,c,d,a,n,r,m,h;const{tl:Z={},br:b={}}=I,{nativeCol:G,nativeColOff:u,nativeRow:p,nativeRowOff:w}=Z;let W=Go,B=uo;for(let f=0;f{if(Zo[g])return C(Zo[g]);const{buffer:i,extension:e}=I.buffer,t=new Blob([i],{type:"image/"+e}),l=URL.createObjectURL(t),s=new Image;s.src=l,s.onload=function(){C(s),Zo[g]=s},s.onerror=function(g){A(g)}}))})(I,C).then((I=>{let C=0,i=0,e=I.width,t=I.height,l=A.x,s=A.y,o=A.width,c=A.height;const d=o/e,a=c/t;if(l{}))}(g,e,I[e],i)}}))}const Go=60,uo=25,po=80,wo=24,Wo=window.devicePixelRatio;function Bo(){Zo=[]}function yo(g){if(g){const I=g.querySelectorAll("input");for(const g of I)g&&!g.readOnly&&(g.readOnly=!0)}}const Vo={minColLength:20};class Xo{constructor(g,I={}){C(this,"container"),C(this,"options",{}),C(this,"wrapper"),C(this,"wrapperMain"),C(this,"xs"),C(this,"sheetIndex"),C(this,"mediasSource"),C(this,"workbookDataSource"),C(this,"ctx"),C(this,"fileData"),C(this,"observer"),C(this,"offset"),this.container=g,this.options={...Vo,...I},this.sheetIndex=1,this.mediasSource={},this.workbookDataSource={_worksheets:[]},this.createWrapper(),this.initSpreadsheet(),this.hack()}createWrapper(){this.wrapper=document.createElement("div"),this.wrapper.className="r-preview-excel-main",this.container.appendChild(this.wrapper)}async initSpreadsheet(){var g;if(!this.wrapper&&"undefined"!=typeof window)return;if(this.xs=new ys(this.wrapper,{mode:"read",showToolbar:!1,showContextmenu:this.options.showContextmenu||!1,view:{height:()=>this.wrapper&&this.wrapper.clientHeight||300,width:()=>this.wrapper&&this.wrapper.clientWidth||1200},row:{height:24,len:100},col:{len:26,width:80,indexWidth:60,minWidth:60}}).loadData({}),!this.xs)return;if(this.xs.bottombar){const g=this.xs.bottombar.swapFunc;this.xs.bottombar.swapFunc=I=>{var C;g.call(null==(C=this.xs)?void 0:C.bottombar,I),this.sheetIndex=I+1,setTimeout((()=>{var g,I;(null==(g=this.xs)?void 0:g.reRender)&&(null==(I=this.xs)||I.reRender()),this.mediasSource&&this.ctx&&this.offset&&bo(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}))}}if(null==(g=this.xs.sheet)?void 0:g.editor){const g=this.xs.sheet.editor.clear;this.xs.sheet.editor.clear=(...I)=>{var C,A;g.apply(null==(A=null==(C=this.xs)?void 0:C.sheet)?void 0:A.editor,I),setTimeout((()=>{this.ctx&&this.mediasSource&&this.offset&&bo(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}))};const I=this.xs.sheet.editor.setOffset;this.xs.sheet.editor.setOffset=(...g)=>{var C,A;I.apply(null==(A=null==(C=this.xs)?void 0:C.sheet)?void 0:A.editor,g),g.length>1&&(this.offset=g.shift()),this.ctx&&this.mediasSource&&this.offset&&bo(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}}const I=this.wrapper&&this.wrapper.querySelector("canvas");I&&(this.ctx=I.getContext("2d"))}renderExcel(g,I,C){return this.fileData=g,function(g){try{return(new Ys.Workbook).xlsx.load(g)}catch(I){return console.warn(I),Promise.reject(I)}}(g).then((g=>{var A;if(!g._worksheets||0===g._worksheets.length)throw I&&I({success:!1,data:null,message:"未获取到数据,可能文件格式不正确或文件已损坏"}),new Error("未获取到数据,可能文件格式不正确或文件已损坏");const{workbookData:i,medias:e,workbookSource:t}=ho(g,this.options);this.mediasSource=e,this.workbookDataSource=t,this.offset=void 0,this.sheetIndex=1,Bo(),null==(A=this.xs)||A.loadData(i),this.ctx&&this.mediasSource&&this.offset&&bo(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset),C&&C({success:!0,data:g})})).catch((g=>{var C;return this.mediasSource=[],this.workbookDataSource={_worksheets:[]},Bo(),null==(C=this.xs)||C.loadData({}),I&&I({success:!1,message:"未获取到数据,可能文件格式不正确或文件已损坏"}),Promise.reject(g)}))}hack(){if(!this.wrapper)return;const g=si.debounce(yo,200).bind(this,this.wrapper);this.observer=new MutationObserver(g);this.observer.observe(this.wrapper,{attributes:!0,childList:!0,subtree:!0}),g()}}const Yo=Object.freeze(Object.defineProperty({__proto__:null,renderExcel:(g,I)=>{const{dom:C,onError:A,onLoad:i}=I;if(!C)return Promise.reject();const e=new Xo(C);return new Promise(((I,C)=>{const A=new FileReader;A.readAsArrayBuffer(g),A.onload=()=>{A.result?I(null==A?void 0:A.result):C()}})).then((g=>{e.renderExcel(g,A,i)}))}},Symbol.toStringTag,{value:"Module"}));class Ro{constructor(g,I,C){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=g,this.start=I,this.end=C}static range(g,I){return I?g&&g.loc&&I.loc&&g.loc.lexer===I.loc.lexer?new Ro(g.loc.lexer,g.loc.start,I.loc.end):null:g&&g.loc}}class No{constructor(g,I){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=g,this.loc=I}range(g,I){return new No(I,Ro.range(this,g))}}class Ho{constructor(g,I){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var C,A,i="KaTeX parse error: "+g,e=I&&I.loc;if(e&&e.start<=e.end){var t=e.lexer.input;C=e.start,A=e.end,C===t.length?i+=" at end of input: ":i+=" at position "+(C+1)+": ";var l=t.slice(C,A).replace(/[^]/g,"$&̲");i+=(C>15?"…"+t.slice(C-15,C):t.slice(0,C))+l+(A+15":">","<":"<",'"':""","'":"'"},Fo=/[&><"']/g;var Mo=function g(I){return"ordgroup"===I.type||"color"===I.type?1===I.body.length?g(I.body[0]):I:"font"===I.type?g(I.body):I},So={contains:function(g,I){return-1!==g.indexOf(I)},deflt:function(g,I){return void 0===g?I:g},escape:function(g){return String(g).replace(Fo,(g=>fo[g]))},hyphenate:function(g){return g.replace(Ko,"-$1").toLowerCase()},getBaseElem:Mo,isCharacterBox:function(g){var I=Mo(g);return"mathord"===I.type||"textord"===I.type||"atom"===I.type},protocolFromUrl:function(g){var I=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(g);return I?":"!==I[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(I[1])?I[1].toLowerCase():null:"_relative"}},Jo={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:g=>"#"+g},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(g,I)=>(I.push(g),I)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:g=>Math.max(0,g),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:g=>Math.max(0,g),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:g=>Math.max(0,g),cli:"-e, --max-expand ",cliProcessor:g=>"Infinity"===g?1/0:parseInt(g)},globalGroup:{type:"boolean",cli:!1}};function ko(g){if(g.default)return g.default;var I=g.type,C=Array.isArray(I)?I[0]:I;if("string"!=typeof C)return C.enum[0];switch(C){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class Do{constructor(g){for(var I in this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,g=g||{},Jo)if(Jo.hasOwnProperty(I)){var C=Jo[I];this[I]=void 0!==g[I]?C.processor?C.processor(g[I]):g[I]:ko(C)}}reportNonstrict(g,I,C){var A=this.strict;if("function"==typeof A&&(A=A(g,I,C)),A&&"ignore"!==A){if(!0===A||"error"===A)throw new Ho("LaTeX-incompatible input and strict mode is set to 'error': "+I+" ["+g+"]",C);"warn"===A?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+I+" ["+g+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+A+"': "+I+" ["+g+"]")}}useStrictBehavior(g,I,C){var A=this.strict;if("function"==typeof A)try{A=A(g,I,C)}catch(i){A="error"}return!(!A||"ignore"===A)&&(!0===A||"error"===A||("warn"===A?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+I+" ["+g+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+A+"': "+I+" ["+g+"]"),!1)))}isTrusted(g){if(g.url&&!g.protocol){var I=So.protocolFromUrl(g.url);if(null==I)return!1;g.protocol=I}var C="function"==typeof this.trust?this.trust(g):this.trust;return Boolean(C)}}class vo{constructor(g,I,C){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=g,this.size=I,this.cramped=C}sup(){return Lo[zo[this.id]]}sub(){return Lo[To[this.id]]}fracNum(){return Lo[xo[this.id]]}fracDen(){return Lo[Uo[this.id]]}cramp(){return Lo[jo[this.id]]}text(){return Lo[Qo[this.id]]}isTight(){return this.size>=2}}var Lo=[new vo(0,0,!1),new vo(1,0,!0),new vo(2,1,!1),new vo(3,1,!0),new vo(4,2,!1),new vo(5,2,!0),new vo(6,3,!1),new vo(7,3,!0)],zo=[4,5,4,5,6,7,6,7],To=[5,5,5,5,7,7,7,7],xo=[2,3,4,5,6,7,6,7],Uo=[3,3,5,5,7,7,7,7],jo=[1,1,3,3,5,5,7,7],Qo=[0,1,2,3,2,3,2,3],Oo={DISPLAY:Lo[0],TEXT:Lo[2],SCRIPT:Lo[4],SCRIPTSCRIPT:Lo[6]},Eo=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];var Po=[];function _o(g){for(var I=0;I=Po[I]&&g<=Po[I+1])return!0;return!1}Eo.forEach((g=>g.blocks.forEach((g=>Po.push(...g)))));var qo=80,$o={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:"M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",leftmapsto:"M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:"M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:"M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"};class gc{constructor(g){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=g,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(g){return So.contains(this.classes,g)}toNode(){for(var g=document.createDocumentFragment(),I=0;Ig.toText())).join("")}}var Ic={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},Cc={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},Ac={"Å":"A","Ð":"D","Þ":"o","å":"a","ð":"d","þ":"o","А":"A","Б":"B","В":"B","Г":"F","Д":"A","Е":"E","Ж":"K","З":"3","И":"N","Й":"N","К":"K","Л":"N","М":"M","Н":"H","О":"O","П":"N","Р":"P","С":"C","Т":"T","У":"y","Ф":"O","Х":"X","Ц":"U","Ч":"h","Ш":"W","Щ":"W","Ъ":"B","Ы":"X","Ь":"B","Э":"3","Ю":"X","Я":"R","а":"a","б":"b","в":"a","г":"r","д":"y","е":"e","ж":"m","з":"e","и":"n","й":"n","к":"n","л":"n","м":"m","н":"n","о":"o","п":"n","р":"p","с":"c","т":"o","у":"y","ф":"b","х":"x","ц":"n","ч":"n","ш":"w","щ":"w","ъ":"a","ы":"m","ь":"a","э":"e","ю":"m","я":"r"};function ic(g,I,C){if(!Ic[I])throw new Error("Font metrics not found for font: "+I+".");var A=g.charCodeAt(0),i=Ic[I][A];if(!i&&g[0]in Ac&&(A=Ac[g[0]].charCodeAt(0),i=Ic[I][A]),i||"text"!==C||_o(A)&&(i=Ic[I][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var ec={};var tc=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],lc=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],sc=function(g,I){return I.size<2?g:tc[g-1][I.size-1]};class oc{constructor(g){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=g.style,this.color=g.color,this.size=g.size||oc.BASESIZE,this.textSize=g.textSize||this.size,this.phantom=!!g.phantom,this.font=g.font||"",this.fontFamily=g.fontFamily||"",this.fontWeight=g.fontWeight||"",this.fontShape=g.fontShape||"",this.sizeMultiplier=lc[this.size-1],this.maxSize=g.maxSize,this.minRuleThickness=g.minRuleThickness,this._fontMetrics=void 0}extend(g){var I={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};for(var C in g)g.hasOwnProperty(C)&&(I[C]=g[C]);return new oc(I)}havingStyle(g){return this.style===g?this:this.extend({style:g,size:sc(this.textSize,g)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(g){return this.size===g&&this.textSize===g?this:this.extend({style:this.style.text(),size:g,textSize:g,sizeMultiplier:lc[g-1]})}havingBaseStyle(g){g=g||this.style.text();var I=sc(oc.BASESIZE,g);return this.size===I&&this.textSize===oc.BASESIZE&&this.style===g?this:this.extend({style:g,size:I})}havingBaseSizing(){var g;switch(this.style.id){case 4:case 5:g=3;break;case 6:case 7:g=1;break;default:g=6}return this.extend({style:this.style.text(),size:g})}withColor(g){return this.extend({color:g})}withPhantom(){return this.extend({phantom:!0})}withFont(g){return this.extend({font:g})}withTextFontFamily(g){return this.extend({fontFamily:g,font:""})}withTextFontWeight(g){return this.extend({fontWeight:g,font:""})}withTextFontShape(g){return this.extend({fontShape:g,font:""})}sizingClasses(g){return g.size!==this.size?["sizing","reset-size"+g.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==oc.BASESIZE?["sizing","reset-size"+this.size,"size"+oc.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=function(g){var I;if(!ec[I=g>=5?0:g>=3?1:2]){var C=ec[I]={cssEmPerMu:Cc.quad[I]/18};for(var A in Cc)Cc.hasOwnProperty(A)&&(C[A]=Cc[A][I])}return ec[I]}(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}oc.BASESIZE=6;var cc={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:1.00375,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:1.00375},dc={ex:!0,em:!0,mu:!0},ac=function(g){return"string"!=typeof g&&(g=g.unit),g in cc||g in dc||"ex"===g},nc=function(g,I){var C;if(g.unit in cc)C=cc[g.unit]/I.fontMetrics().ptPerEm/I.sizeMultiplier;else if("mu"===g.unit)C=I.fontMetrics().cssEmPerMu;else{var A;if(A=I.style.isTight()?I.havingStyle(I.style.text()):I,"ex"===g.unit)C=A.fontMetrics().xHeight;else{if("em"!==g.unit)throw new Ho("Invalid unit: '"+g.unit+"'");C=A.fontMetrics().quad}A!==I&&(C*=A.sizeMultiplier/I.sizeMultiplier)}return Math.min(g.number*C,I.maxSize)},rc=function(g){return+g.toFixed(4)+"em"},mc=function(g){return g.filter((g=>g)).join(" ")},hc=function(g,I,C){if(this.classes=g||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=C||{},I){I.style.isTight()&&this.classes.push("mtight");var A=I.getColor();A&&(this.style.color=A)}},Zc=function(g){var I=document.createElement(g);for(var C in I.className=mc(this.classes),this.style)this.style.hasOwnProperty(C)&&(I.style[C]=this.style[C]);for(var A in this.attributes)this.attributes.hasOwnProperty(A)&&I.setAttribute(A,this.attributes[A]);for(var i=0;i"};class Gc{constructor(g,I,C,A){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,hc.call(this,g,C,A),this.children=I||[]}setAttribute(g,I){this.attributes[g]=I}hasClass(g){return So.contains(this.classes,g)}toNode(){return Zc.call(this,"span")}toMarkup(){return bc.call(this,"span")}}class uc{constructor(g,I,C,A){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,hc.call(this,I,A),this.children=C||[],this.setAttribute("href",g)}setAttribute(g,I){this.attributes[g]=I}hasClass(g){return So.contains(this.classes,g)}toNode(){return Zc.call(this,"a")}toMarkup(){return bc.call(this,"a")}}class pc{constructor(g,I,C){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=I,this.src=g,this.classes=["mord"],this.style=C}hasClass(g){return So.contains(this.classes,g)}toNode(){var g=document.createElement("img");for(var I in g.src=this.src,g.alt=this.alt,g.className="mord",this.style)this.style.hasOwnProperty(I)&&(g.style[I]=this.style[I]);return g}toMarkup(){var g=''+So.escape(this.alt)+'=i[0]&&g<=i[1])return C.name}return null}(this.text.charCodeAt(0));s&&this.classes.push(s+"_fallback"),/[îïíì]/.test(this.text)&&(this.text=wc[this.text])}hasClass(g){return So.contains(this.classes,g)}toNode(){var g=document.createTextNode(this.text),I=null;for(var C in this.italic>0&&((I=document.createElement("span")).style.marginRight=rc(this.italic)),this.classes.length>0&&((I=I||document.createElement("span")).className=mc(this.classes)),this.style)this.style.hasOwnProperty(C)&&((I=I||document.createElement("span")).style[C]=this.style[C]);return I?(I.appendChild(g),I):g}toMarkup(){var g=!1,I="0&&(C+="margin-right:"+this.italic+"em;"),this.style)this.style.hasOwnProperty(A)&&(C+=So.hyphenate(A)+":"+this.style[A]+";");C&&(g=!0,I+=' style="'+So.escape(C)+'"');var i=So.escape(this.text);return g?(I+=">",I+=i,I+=""):i}}class Bc{constructor(g,I){this.children=void 0,this.attributes=void 0,this.children=g||[],this.attributes=I||{}}toNode(){var g=document.createElementNS("http://www.w3.org/2000/svg","svg");for(var I in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,I)&&g.setAttribute(I,this.attributes[I]);for(var C=0;C':''}}class Vc{constructor(g){this.attributes=void 0,this.attributes=g||{}}toNode(){var g=document.createElementNS("http://www.w3.org/2000/svg","line");for(var I in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,I)&&g.setAttribute(I,this.attributes[I]);return g}toMarkup(){var g="","\\gt",!0),Hc(Kc,Fc,xc,"∈","\\in",!0),Hc(Kc,Fc,xc,"","\\@not"),Hc(Kc,Fc,xc,"⊂","\\subset",!0),Hc(Kc,Fc,xc,"⊃","\\supset",!0),Hc(Kc,Fc,xc,"⊆","\\subseteq",!0),Hc(Kc,Fc,xc,"⊇","\\supseteq",!0),Hc(Kc,Mc,xc,"⊈","\\nsubseteq",!0),Hc(Kc,Mc,xc,"⊉","\\nsupseteq",!0),Hc(Kc,Fc,xc,"⊨","\\models"),Hc(Kc,Fc,xc,"←","\\leftarrow",!0),Hc(Kc,Fc,xc,"≤","\\le"),Hc(Kc,Fc,xc,"≤","\\leq",!0),Hc(Kc,Fc,xc,"<","\\lt",!0),Hc(Kc,Fc,xc,"→","\\rightarrow",!0),Hc(Kc,Fc,xc,"→","\\to"),Hc(Kc,Mc,xc,"≱","\\ngeq",!0),Hc(Kc,Mc,xc,"≰","\\nleq",!0),Hc(Kc,Fc,Uc," ","\\ "),Hc(Kc,Fc,Uc," ","\\space"),Hc(Kc,Fc,Uc," ","\\nobreakspace"),Hc(fc,Fc,Uc," ","\\ "),Hc(fc,Fc,Uc," "," "),Hc(fc,Fc,Uc," ","\\space"),Hc(fc,Fc,Uc," ","\\nobreakspace"),Hc(Kc,Fc,Uc,null,"\\nobreak"),Hc(Kc,Fc,Uc,null,"\\allowbreak"),Hc(Kc,Fc,Tc,",",","),Hc(Kc,Fc,Tc,";",";"),Hc(Kc,Mc,Jc,"⊼","\\barwedge",!0),Hc(Kc,Mc,Jc,"⊻","\\veebar",!0),Hc(Kc,Fc,Jc,"⊙","\\odot",!0),Hc(Kc,Fc,Jc,"⊕","\\oplus",!0),Hc(Kc,Fc,Jc,"⊗","\\otimes",!0),Hc(Kc,Fc,jc,"∂","\\partial",!0),Hc(Kc,Fc,Jc,"⊘","\\oslash",!0),Hc(Kc,Mc,Jc,"⊚","\\circledcirc",!0),Hc(Kc,Mc,Jc,"⊡","\\boxdot",!0),Hc(Kc,Fc,Jc,"△","\\bigtriangleup"),Hc(Kc,Fc,Jc,"▽","\\bigtriangledown"),Hc(Kc,Fc,Jc,"†","\\dagger"),Hc(Kc,Fc,Jc,"⋄","\\diamond"),Hc(Kc,Fc,Jc,"⋆","\\star"),Hc(Kc,Fc,Jc,"◃","\\triangleleft"),Hc(Kc,Fc,Jc,"▹","\\triangleright"),Hc(Kc,Fc,zc,"{","\\{"),Hc(fc,Fc,jc,"{","\\{"),Hc(fc,Fc,jc,"{","\\textbraceleft"),Hc(Kc,Fc,kc,"}","\\}"),Hc(fc,Fc,jc,"}","\\}"),Hc(fc,Fc,jc,"}","\\textbraceright"),Hc(Kc,Fc,zc,"{","\\lbrace"),Hc(Kc,Fc,kc,"}","\\rbrace"),Hc(Kc,Fc,zc,"[","\\lbrack",!0),Hc(fc,Fc,jc,"[","\\lbrack",!0),Hc(Kc,Fc,kc,"]","\\rbrack",!0),Hc(fc,Fc,jc,"]","\\rbrack",!0),Hc(Kc,Fc,zc,"(","\\lparen",!0),Hc(Kc,Fc,kc,")","\\rparen",!0),Hc(fc,Fc,jc,"<","\\textless",!0),Hc(fc,Fc,jc,">","\\textgreater",!0),Hc(Kc,Fc,zc,"⌊","\\lfloor",!0),Hc(Kc,Fc,kc,"⌋","\\rfloor",!0),Hc(Kc,Fc,zc,"⌈","\\lceil",!0),Hc(Kc,Fc,kc,"⌉","\\rceil",!0),Hc(Kc,Fc,jc,"\\","\\backslash"),Hc(Kc,Fc,jc,"∣","|"),Hc(Kc,Fc,jc,"∣","\\vert"),Hc(fc,Fc,jc,"|","\\textbar",!0),Hc(Kc,Fc,jc,"∥","\\|"),Hc(Kc,Fc,jc,"∥","\\Vert"),Hc(fc,Fc,jc,"∥","\\textbardbl"),Hc(fc,Fc,jc,"~","\\textasciitilde"),Hc(fc,Fc,jc,"\\","\\textbackslash"),Hc(fc,Fc,jc,"^","\\textasciicircum"),Hc(Kc,Fc,xc,"↑","\\uparrow",!0),Hc(Kc,Fc,xc,"⇑","\\Uparrow",!0),Hc(Kc,Fc,xc,"↓","\\downarrow",!0),Hc(Kc,Fc,xc,"⇓","\\Downarrow",!0),Hc(Kc,Fc,xc,"↕","\\updownarrow",!0),Hc(Kc,Fc,xc,"⇕","\\Updownarrow",!0),Hc(Kc,Fc,Lc,"∐","\\coprod"),Hc(Kc,Fc,Lc,"⋁","\\bigvee"),Hc(Kc,Fc,Lc,"⋀","\\bigwedge"),Hc(Kc,Fc,Lc,"⨄","\\biguplus"),Hc(Kc,Fc,Lc,"⋂","\\bigcap"),Hc(Kc,Fc,Lc,"⋃","\\bigcup"),Hc(Kc,Fc,Lc,"∫","\\int"),Hc(Kc,Fc,Lc,"∫","\\intop"),Hc(Kc,Fc,Lc,"∬","\\iint"),Hc(Kc,Fc,Lc,"∭","\\iiint"),Hc(Kc,Fc,Lc,"∏","\\prod"),Hc(Kc,Fc,Lc,"∑","\\sum"),Hc(Kc,Fc,Lc,"⨂","\\bigotimes"),Hc(Kc,Fc,Lc,"⨁","\\bigoplus"),Hc(Kc,Fc,Lc,"⨀","\\bigodot"),Hc(Kc,Fc,Lc,"∮","\\oint"),Hc(Kc,Fc,Lc,"∯","\\oiint"),Hc(Kc,Fc,Lc,"∰","\\oiiint"),Hc(Kc,Fc,Lc,"⨆","\\bigsqcup"),Hc(Kc,Fc,Lc,"∫","\\smallint"),Hc(fc,Fc,Dc,"…","\\textellipsis"),Hc(Kc,Fc,Dc,"…","\\mathellipsis"),Hc(fc,Fc,Dc,"…","\\ldots",!0),Hc(Kc,Fc,Dc,"…","\\ld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fc,Fc,Sc,"◯","\\textcircled");var Qc={"--":!0,"---":!0,"``":!0,"''":!0};Hc(fc,Fc,jc,"–","--",!0),Hc(fc,Fc,jc,"–","\\textendash"),Hc(fc,Fc,jc,"—","---",!0),Hc(fc,Fc,jc,"—","\\textemdash"),Hc(fc,Fc,jc,"‘","`",!0),Hc(fc,Fc,jc,"‘","\\textquoteleft"),Hc(fc,Fc,jc,"’","'",!0),Hc(fc,Fc,jc,"’","\\textquoteright"),Hc(fc,Fc,jc,"“","``",!0),Hc(fc,Fc,jc,"“","\\textquotedblleft"),Hc(fc,Fc,jc,"”","''",!0),Hc(fc,Fc,jc,"”","\\textquotedblright"),Hc(Kc,Fc,jc,"°","\\degree",!0),Hc(fc,Fc,jc,"°","\\degree"),Hc(fc,Fc,jc,"°","\\textdegree",!0),Hc(Kc,Fc,jc,"£","\\pounds"),Hc(Kc,Fc,jc,"£","\\mathsterling",!0),Hc(fc,Fc,jc,"£","\\pounds"),Hc(fc,Fc,jc,"£","\\textsterling",!0),Hc(Kc,Mc,jc,"✠","\\maltese"),Hc(fc,Mc,jc,"✠","\\maltese");for(var Oc='0123456789/@."',Ec=0;Ec<14;Ec++){var Pc=Oc.charAt(Ec);Hc(Kc,Fc,jc,Pc,Pc)}for(var _c='0123456789!@*()-=+";:?/.,',qc=0;qc<25;qc++){var $c=_c.charAt(qc);Hc(fc,Fc,jc,$c,$c)}for(var gd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Id=0;Id<52;Id++){var Cd=gd.charAt(Id);Hc(Kc,Fc,vc,Cd,Cd),Hc(fc,Fc,jc,Cd,Cd)}Hc(Kc,Mc,jc,"C","ℂ"),Hc(fc,Mc,jc,"C","ℂ"),Hc(Kc,Mc,jc,"H","ℍ"),Hc(fc,Mc,jc,"H","ℍ"),Hc(Kc,Mc,jc,"N","ℕ"),Hc(fc,Mc,jc,"N","ℕ"),Hc(Kc,Mc,jc,"P","ℙ"),Hc(fc,Mc,jc,"P","ℙ"),Hc(Kc,Mc,jc,"Q","ℚ"),Hc(fc,Mc,jc,"Q","ℚ"),Hc(Kc,Mc,jc,"R","ℝ"),Hc(fc,Mc,jc,"R","ℝ"),Hc(Kc,Mc,jc,"Z","ℤ"),Hc(fc,Mc,jc,"Z","ℤ"),Hc(Kc,Fc,vc,"h","ℎ"),Hc(fc,Fc,vc,"h","ℎ");for(var Ad="",id=0;id<52;id++){var ed=gd.charAt(id);Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56320+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56372+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56424+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56580+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56684+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56736+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56788+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56840+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56944+id)),Hc(fc,Fc,jc,ed,Ad),id<26&&(Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56632+id)),Hc(fc,Fc,jc,ed,Ad),Hc(Kc,Fc,vc,ed,Ad=String.fromCharCode(55349,56476+id)),Hc(fc,Fc,jc,ed,Ad))}Hc(Kc,Fc,vc,"k",Ad=String.fromCharCode(55349,56668)),Hc(fc,Fc,jc,"k",Ad);for(var td=0;td<10;td++){var ld=td.toString();Hc(Kc,Fc,vc,ld,Ad=String.fromCharCode(55349,57294+td)),Hc(fc,Fc,jc,ld,Ad),Hc(Kc,Fc,vc,ld,Ad=String.fromCharCode(55349,57314+td)),Hc(fc,Fc,jc,ld,Ad),Hc(Kc,Fc,vc,ld,Ad=String.fromCharCode(55349,57324+td)),Hc(fc,Fc,jc,ld,Ad),Hc(Kc,Fc,vc,ld,Ad=String.fromCharCode(55349,57334+td)),Hc(fc,Fc,jc,ld,Ad)}for(var sd="ÐÞþ",od=0;od<3;od++){var cd=sd.charAt(od);Hc(Kc,Fc,vc,cd,cd),Hc(fc,Fc,jc,cd,cd)}var dd=[["mathbf","textbf","Main-Bold"],["mathbf","textbf","Main-Bold"],["mathnormal","textit","Math-Italic"],["mathnormal","textit","Math-Italic"],["boldsymbol","boldsymbol","Main-BoldItalic"],["boldsymbol","boldsymbol","Main-BoldItalic"],["mathscr","textscr","Script-Regular"],["","",""],["","",""],["","",""],["mathfrak","textfrak","Fraktur-Regular"],["mathfrak","textfrak","Fraktur-Regular"],["mathbb","textbb","AMS-Regular"],["mathbb","textbb","AMS-Regular"],["mathboldfrak","textboldfrak","Fraktur-Regular"],["mathboldfrak","textboldfrak","Fraktur-Regular"],["mathsf","textsf","SansSerif-Regular"],["mathsf","textsf","SansSerif-Regular"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathitsf","textitsf","SansSerif-Italic"],["mathitsf","textitsf","SansSerif-Italic"],["","",""],["","",""],["mathtt","texttt","Typewriter-Regular"],["mathtt","texttt","Typewriter-Regular"]],ad=[["mathbf","textbf","Main-Bold"],["","",""],["mathsf","textsf","SansSerif-Regular"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathtt","texttt","Typewriter-Regular"]],nd=function(g,I,C){return Nc[C][g]&&Nc[C][g].replace&&(g=Nc[C][g].replace),{value:g,metrics:ic(g,I,C)}},rd=function(g,I,C,A,i){var e,t=nd(g,I,C),l=t.metrics;if(g=t.value,l){var s=l.italic;("text"===C||A&&"mathit"===A.font)&&(s=0),e=new Wc(g,l.height,l.depth,s,l.skew,l.width,i)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+g+"' in style '"+I+"' and mode '"+C+"'"),e=new Wc(g,0,0,0,0,0,i);if(A){e.maxFontSize=A.sizeMultiplier,A.style.isTight()&&e.classes.push("mtight");var o=A.getColor();o&&(e.style.color=o)}return e},md=(g,I)=>{if(mc(g.classes)!==mc(I.classes)||g.skew!==I.skew||g.maxFontSize!==I.maxFontSize)return!1;if(1===g.classes.length){var C=g.classes[0];if("mbin"===C||"mord"===C)return!1}for(var A in g.style)if(g.style.hasOwnProperty(A)&&g.style[A]!==I.style[A])return!1;for(var i in I.style)if(I.style.hasOwnProperty(i)&&g.style[i]!==I.style[i])return!1;return!0},hd=function(g){for(var I=0,C=0,A=0,i=0;iI&&(I=e.height),e.depth>C&&(C=e.depth),e.maxFontSize>A&&(A=e.maxFontSize)}g.height=I,g.depth=C,g.maxFontSize=A},Zd=function(g,I,C,A){var i=new Gc(g,I,C,A);return hd(i),i},bd=(g,I,C,A)=>new Gc(g,I,C,A),Gd=function(g){var I=new gc(g);return hd(I),I},ud=function(g,I,C){var A="";switch(g){case"amsrm":A="AMS";break;case"textrm":A="Main";break;case"textsf":A="SansSerif";break;case"texttt":A="Typewriter";break;default:A=g}return A+"-"+("textbf"===I&&"textit"===C?"BoldItalic":"textbf"===I?"Bold":"textit"===I?"Italic":"Regular")},pd={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},wd={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},Wd={fontMap:pd,makeSymbol:rd,mathsym:function(g,I,C,A){return void 0===A&&(A=[]),"boldsymbol"===C.font&&nd(g,"Main-Bold",I).metrics?rd(g,"Main-Bold",I,C,A.concat(["mathbf"])):"\\"===g||"main"===Nc[I][g].font?rd(g,"Main-Regular",I,C,A):rd(g,"AMS-Regular",I,C,A.concat(["amsrm"]))},makeSpan:Zd,makeSvgSpan:bd,makeLineSpan:function(g,I,C){var A=Zd([g],[],I);return A.height=Math.max(C||I.fontMetrics().defaultRuleThickness,I.minRuleThickness),A.style.borderBottomWidth=rc(A.height),A.maxFontSize=1,A},makeAnchor:function(g,I,C,A){var i=new uc(g,I,C,A);return hd(i),i},makeFragment:Gd,wrapFragment:function(g,I){return g instanceof gc?Zd([],[g],I):g},makeVList:function(g,I){for(var{children:C,depth:A}=function(g){if("individualShift"===g.positionType){for(var I=g.children,C=[I[0]],A=-I[0].shift-I[0].elem.depth,i=A,e=1;e0)return rd(i,s,A,I,e.concat(o));if(l){var c,d;if("boldsymbol"===l){var a=function(g,I,C,A,i){return"textord"!==i&&nd(g,"Math-BoldItalic",I).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}}(i,A,0,0,C);c=a.fontName,d=[a.fontClass]}else t?(c=pd[l].fontName,d=[l]):(c=ud(l,I.fontWeight,I.fontShape),d=[l,I.fontWeight,I.fontShape]);if(nd(i,c,A).metrics)return rd(i,c,A,I,e.concat(d));if(Qc.hasOwnProperty(i)&&"Typewriter"===c.slice(0,10)){for(var n=[],r=0;r{var C=Zd(["mspace"],[],I),A=nc(g,I);return C.style.marginRight=rc(A),C},staticSvg:function(g,I){var[C,A,i]=wd[g],e=new yc(C),t=new Bc([e],{width:rc(A),height:rc(i),style:"width:"+rc(A),viewBox:"0 0 "+1e3*A+" "+1e3*i,preserveAspectRatio:"xMinYMin"}),l=bd(["overlay"],[t],I);return l.height=i,l.style.height=rc(i),l.style.width=rc(A),l},svgData:wd,tryCombineChars:g=>{for(var I=0;I{var C=I.classes[0],A=g.classes[0];"mbin"===C&&So.contains(kd,A)?I.classes[0]="mord":"mbin"===A&&So.contains(Jd,C)&&(g.classes[0]="mord")}),{node:c},d,a),zd(i,((g,I)=>{var C=Ud(I),A=Ud(g),i=C&&A?g.hasClass("mtight")?Yd[C][A]:Xd[C][A]:null;if(i)return Wd.makeGlue(i,s)}),{node:c},d,a),i},zd=function g(I,C,A,i,e){i&&I.push(i);for(var t=0;tC=>{I.splice(g+1,0,C),t++})(t)}}i&&I.pop()},Td=function(g){return g instanceof gc||g instanceof uc||g instanceof Gc&&g.hasClass("enclosing")?g:null},xd=function g(I,C){var A=Td(I);if(A){var i=A.children;if(i.length){if("right"===C)return g(i[i.length-1],"right");if("left"===C)return g(i[0],"left")}}return I},Ud=function(g,I){return g?(I&&(g=xd(g,I)),vd[g.classes[0]]||null):null},jd=function(g,I){var C=["nulldelimiter"].concat(g.baseSizingClasses());return Sd(I.concat(C))},Qd=function(g,I,C){if(!g)return Sd();if(Nd[g.type]){var A=Nd[g.type](g,I);if(C&&I.size!==C.size){A=Sd(I.sizingClasses(C),[A],I);var i=I.sizeMultiplier/C.sizeMultiplier;A.height*=i,A.depth*=i}return A}throw new Ho("Got group of unknown type: '"+g.type+"'")};function Od(g,I){var C=Sd(["base"],g,I),A=Sd(["strut"]);return A.style.height=rc(C.height+C.depth),C.depth&&(A.style.verticalAlign=rc(-C.depth)),C.children.unshift(A),C}function Ed(g,I){var C=null;1===g.length&&"tag"===g[0].type&&(C=g[0].tag,g=g[0].body);var A,i=Ld(g,I,"root");2===i.length&&i[1].hasClass("tag")&&(A=i.pop());for(var e,t=[],l=[],s=0;s0&&(t.push(Od(l,I)),l=[]),t.push(i[s]));l.length>0&&t.push(Od(l,I)),C?((e=Od(Ld(C,I,!0))).classes=["tag"],t.push(e)):A&&t.push(A);var c=Sd(["katex-html"],t);if(c.setAttribute("aria-hidden","true"),e){var d=e.children[0];d.style.height=rc(c.height+c.depth),c.depth&&(d.style.verticalAlign=rc(-c.depth))}return c}function Pd(g){return new gc(g)}class _d{constructor(g,I,C){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=g,this.attributes={},this.children=I||[],this.classes=C||[]}setAttribute(g,I){this.attributes[g]=I}getAttribute(g){return this.attributes[g]}toNode(){var g=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var I in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,I)&&g.setAttribute(I,this.attributes[I]);this.classes.length>0&&(g.className=mc(this.classes));for(var C=0;C0&&(g+=' class ="'+So.escape(mc(this.classes))+'"'),g+=">";for(var C=0;C"}toText(){return this.children.map((g=>g.toText())).join("")}}class qd{constructor(g){this.text=void 0,this.text=g}toNode(){return document.createTextNode(this.text)}toMarkup(){return So.escape(this.toText())}toText(){return this.text}}var $d={MathNode:_d,TextNode:qd,SpaceNode:class{constructor(g){this.width=void 0,this.character=void 0,this.width=g,this.character=g>=.05555&&g<=.05556?" ":g>=.1666&&g<=.1667?" ":g>=.2222&&g<=.2223?" ":g>=.2777&&g<=.2778?"  ":g>=-.05556&&g<=-.05555?" ⁣":g>=-.1667&&g<=-.1666?" ⁣":g>=-.2223&&g<=-.2222?" ⁣":g>=-.2778&&g<=-.2777?" ⁣":null}toNode(){if(this.character)return document.createTextNode(this.character);var g=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return g.setAttribute("width",rc(this.width)),g}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}},newDocumentFragment:Pd},ga=function(g,I,C){return!Nc[I][g]||!Nc[I][g].replace||55349===g.charCodeAt(0)||Qc.hasOwnProperty(g)&&C&&(C.fontFamily&&"tt"===C.fontFamily.slice(4,6)||C.font&&"tt"===C.font.slice(4,6))||(g=Nc[I][g].replace),new $d.TextNode(g)},Ia=function(g){return 1===g.length?g[0]:new $d.MathNode("mrow",g)},Ca=function(g,I){if("texttt"===I.fontFamily)return"monospace";if("textsf"===I.fontFamily)return"textit"===I.fontShape&&"textbf"===I.fontWeight?"sans-serif-bold-italic":"textit"===I.fontShape?"sans-serif-italic":"textbf"===I.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===I.fontShape&&"textbf"===I.fontWeight)return"bold-italic";if("textit"===I.fontShape)return"italic";if("textbf"===I.fontWeight)return"bold";var C=I.font;if(!C||"mathnormal"===C)return null;var A=g.mode;if("mathit"===C)return"italic";if("boldsymbol"===C)return"textord"===g.type?"bold":"bold-italic";if("mathbf"===C)return"bold";if("mathbb"===C)return"double-struck";if("mathfrak"===C)return"fraktur";if("mathscr"===C||"mathcal"===C)return"script";if("mathsf"===C)return"sans-serif";if("mathtt"===C)return"monospace";var i=g.text;return So.contains(["\\imath","\\jmath"],i)?null:(Nc[A][i]&&Nc[A][i].replace&&(i=Nc[A][i].replace),ic(i,Wd.fontMap[C].fontName,A)?Wd.fontMap[C].variant:null)},Aa=function(g,I,C){if(1===g.length){var A=ea(g[0],I);return C&&A instanceof _d&&"mo"===A.type&&(A.setAttribute("lspace","0em"),A.setAttribute("rspace","0em")),[A]}for(var i,e=[],t=0;t0&&(c.text=c.text.slice(0,1)+"̸"+c.text.slice(1),e.pop())}}}e.push(l),i=l}return e},ia=function(g,I,C){return Ia(Aa(g,I,C))},ea=function(g,I){if(!g)return new $d.MathNode("mrow");if(Hd[g.type])return Hd[g.type](g,I);throw new Ho("Got group of unknown type: '"+g.type+"'")};function ta(g,I,C,A,i){var e,t=Aa(g,C);e=1===t.length&&t[0]instanceof _d&&So.contains(["mrow","mtable"],t[0].type)?t[0]:new $d.MathNode("mrow",t);var l=new $d.MathNode("annotation",[new $d.TextNode(I)]);l.setAttribute("encoding","application/x-tex");var s=new $d.MathNode("semantics",[e,l]),o=new $d.MathNode("math",[s]);o.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),A&&o.setAttribute("display","block");var c=i?"katex":"katex-mathml";return Wd.makeSpan([c],[o])}var la=function(g){return new oc({style:g.displayMode?Oo.DISPLAY:Oo.TEXT,maxSize:g.maxSize,minRuleThickness:g.minRuleThickness})},sa=function(g,I){if(I.displayMode){var C=["katex-display"];I.leqno&&C.push("leqno"),I.fleqn&&C.push("fleqn"),g=Wd.makeSpan(C,[g])}return g},oa={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xrightleftarrows:"⇄",xrightequilibrium:"⇌",xleftequilibrium:"⇋","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"="},ca={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},da=function(g,I,C,A,i){var e,t=g.height+g.depth+C+A;if(/fbox|color|angl/.test(I)){if(e=Wd.makeSpan(["stretchy",I],[],i),"fbox"===I){var l=i.color&&i.getColor();l&&(e.style.borderColor=l)}}else{var s=[];/^[bx]cancel$/.test(I)&&s.push(new Vc({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(I)&&s.push(new Vc({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var o=new Bc(s,{width:"100%",height:rc(t)});e=Wd.makeSvgSpan([],[o],i)}return e.height=t,e.style.height=rc(t),e},aa=function(g){var I=new $d.MathNode("mo",[new $d.TextNode(oa[g.replace(/^\\/,"")])]);return I.setAttribute("stretchy","true"),I},na=function(g,I){var{span:C,minWidth:A,height:i}=function(){var C=4e5,A=g.label.slice(1);if(So.contains(["widehat","widecheck","widetilde","utilde"],A)){var i,e,t,l="ordgroup"===(n=g.base).type?n.body.length:1;if(l>5)"widehat"===A||"widecheck"===A?(i=420,C=2364,t=.42,e=A+"4"):(i=312,C=2340,t=.34,e="tilde4");else{var s=[1,1,2,2,3,3][l];"widehat"===A||"widecheck"===A?(C=[0,1062,2364,2364,2364][s],i=[0,239,300,360,420][s],t=[0,.24,.3,.3,.36,.42][s],e=A+s):(C=[0,600,1033,2339,2340][s],i=[0,260,286,306,312][s],t=[0,.26,.286,.3,.306,.34][s],e="tilde"+s)}var o=new yc(e),c=new Bc([o],{width:"100%",height:rc(t),viewBox:"0 0 "+C+" "+i,preserveAspectRatio:"none"});return{span:Wd.makeSvgSpan([],[c],I),minWidth:0,height:t}}var d,a,n,r=[],m=ca[A],[h,Z,b]=m,G=b/1e3,u=h.length;if(1===u)d=["hide-tail"],a=[m[3]];else if(2===u)d=["halfarrow-left","halfarrow-right"],a=["xMinYMin","xMaxYMin"];else{if(3!==u)throw new Error("Correct katexImagesData or update code here to support\n "+u+" children.");d=["brace-left","brace-center","brace-right"],a=["xMinYMin","xMidYMin","xMaxYMin"]}for(var p=0;p0&&(C.style.minWidth=rc(A)),C};function ra(g,I){if(!g||g.type!==I)throw new Error("Expected node of type "+I+", but got "+(g?"node of type "+g.type:String(g)));return g}function ma(g){var I=ha(g);if(!I)throw new Error("Expected node of symbol group type, but got "+(g?"node of type "+g.type:String(g)));return I}function ha(g){return g&&("atom"===g.type||Rc.hasOwnProperty(g.type))?g:null}var Za=(g,I)=>{var C,A,i;g&&"supsub"===g.type?(C=(A=ra(g.base,"accent")).base,g.base=C,i=function(g){if(g instanceof Gc)return g;throw new Error("Expected span but got "+String(g)+".")}(Qd(g,I)),g.base=A):C=(A=ra(g,"accent")).base;var e=Qd(C,I.havingCrampedStyle()),t=0;if(A.isShifty&&So.isCharacterBox(C)){var l=So.getBaseElem(C);t=Xc(Qd(l,I.havingCrampedStyle())).skew}var s,o="\\c"===A.label,c=o?e.height+e.depth:Math.min(e.height,I.fontMetrics().xHeight);if(A.isStretchy)s=na(A,I),s=Wd.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:e},{type:"elem",elem:s,wrapperClasses:["svg-align"],wrapperStyle:t>0?{width:"calc(100% - "+rc(2*t)+")",marginLeft:rc(2*t)}:void 0}]},I);else{var d,a;"\\vec"===A.label?(d=Wd.staticSvg("vec",I),a=Wd.svgData.vec[1]):((d=Xc(d=Wd.makeOrd({mode:A.mode,text:A.label},I,"textord"))).italic=0,a=d.width,o&&(c+=d.depth)),s=Wd.makeSpan(["accent-body"],[d]);var n="\\textcircled"===A.label;n&&(s.classes.push("accent-full"),c=e.height);var r=t;n||(r-=a/2),s.style.left=rc(r),"\\textcircled"===A.label&&(s.style.top=".2em"),s=Wd.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:e},{type:"kern",size:-c},{type:"elem",elem:s}]},I)}var m=Wd.makeSpan(["mord","accent"],[s],I);return i?(i.children[0]=m,i.height=Math.max(m.height,i.height),i.classes[0]="mord",i):m},ba=(g,I)=>{var C=g.isStretchy?aa(g.label):new $d.MathNode("mo",[ga(g.label,g.mode)]),A=new $d.MathNode("mover",[ea(g.base,I),C]);return A.setAttribute("accent","true"),A},Ga=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map((g=>"\\"+g)).join("|"));Kd({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(g,I)=>{var C=Fd(I[0]),A=!Ga.test(g.funcName),i=!A||"\\widehat"===g.funcName||"\\widetilde"===g.funcName||"\\widecheck"===g.funcName;return{type:"accent",mode:g.parser.mode,label:g.funcName,isStretchy:A,isShifty:i,base:C}},htmlBuilder:Za,mathmlBuilder:ba}),Kd({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(g,I)=>{var C=I[0],A=g.parser.mode;return"math"===A&&(g.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+g.funcName+" works only in text mode"),A="text"),{type:"accent",mode:A,label:g.funcName,isStretchy:!1,isShifty:!0,base:C}},htmlBuilder:Za,mathmlBuilder:ba}),Kd({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(g,I)=>{var{parser:C,funcName:A}=g,i=I[0];return{type:"accentUnder",mode:C.mode,label:A,base:i}},htmlBuilder:(g,I)=>{var C=Qd(g.base,I),A=na(g,I),i="\\utilde"===g.label?.12:0,e=Wd.makeVList({positionType:"top",positionData:C.height,children:[{type:"elem",elem:A,wrapperClasses:["svg-align"]},{type:"kern",size:i},{type:"elem",elem:C}]},I);return Wd.makeSpan(["mord","accentunder"],[e],I)},mathmlBuilder:(g,I)=>{var C=aa(g.label),A=new $d.MathNode("munder",[ea(g.base,I),C]);return A.setAttribute("accentunder","true"),A}});var ua=g=>{var I=new $d.MathNode("mpadded",g?[g]:[]);return I.setAttribute("width","+0.6em"),I.setAttribute("lspace","0.3em"),I};Kd({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler(g,I,C){var{parser:A,funcName:i}=g;return{type:"xArrow",mode:A.mode,label:i,body:I[0],below:C[0]}},htmlBuilder(g,I){var C,A=I.style,i=I.havingStyle(A.sup()),e=Wd.wrapFragment(Qd(g.body,i,I),I),t="\\x"===g.label.slice(0,2)?"x":"cd";e.classes.push(t+"-arrow-pad"),g.below&&(i=I.havingStyle(A.sub()),(C=Wd.wrapFragment(Qd(g.below,i,I),I)).classes.push(t+"-arrow-pad"));var l,s=na(g,I),o=-I.fontMetrics().axisHeight+.5*s.height,c=-I.fontMetrics().axisHeight-.5*s.height-.111;if((e.depth>.25||"\\xleftequilibrium"===g.label)&&(c-=e.depth),C){var d=-I.fontMetrics().axisHeight+C.height+.5*s.height+.111;l=Wd.makeVList({positionType:"individualShift",children:[{type:"elem",elem:e,shift:c},{type:"elem",elem:s,shift:o},{type:"elem",elem:C,shift:d}]},I)}else l=Wd.makeVList({positionType:"individualShift",children:[{type:"elem",elem:e,shift:c},{type:"elem",elem:s,shift:o}]},I);return l.children[0].children[0].children[1].classes.push("svg-align"),Wd.makeSpan(["mrel","x-arrow"],[l],I)},mathmlBuilder(g,I){var C,A=aa(g.label);if(A.setAttribute("minsize","x"===g.label.charAt(0)?"1.75em":"3.0em"),g.body){var i=ua(ea(g.body,I));if(g.below){var e=ua(ea(g.below,I));C=new $d.MathNode("munderover",[A,e,i])}else C=new $d.MathNode("mover",[A,i])}else if(g.below){var t=ua(ea(g.below,I));C=new $d.MathNode("munder",[A,t])}else C=ua(),C=new $d.MathNode("mover",[A,C]);return C}});var pa=Wd.makeSpan;function wa(g,I){var C=Ld(g.body,I,!0);return pa([g.mclass],C,I)}function Wa(g,I){var C,A=Aa(g.body,I);return"minner"===g.mclass?C=new $d.MathNode("mpadded",A):"mord"===g.mclass?g.isCharacterBox?(C=A[0]).type="mi":C=new $d.MathNode("mi",A):(g.isCharacterBox?(C=A[0]).type="mo":C=new $d.MathNode("mo",A),"mbin"===g.mclass?(C.attributes.lspace="0.22em",C.attributes.rspace="0.22em"):"mpunct"===g.mclass?(C.attributes.lspace="0em",C.attributes.rspace="0.17em"):"mopen"===g.mclass||"mclose"===g.mclass?(C.attributes.lspace="0em",C.attributes.rspace="0em"):"minner"===g.mclass&&(C.attributes.lspace="0.0556em",C.attributes.width="+0.1111em")),C}Kd({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(g,I){var{parser:C,funcName:A}=g,i=I[0];return{type:"mclass",mode:C.mode,mclass:"m"+A.slice(5),body:Md(i),isCharacterBox:So.isCharacterBox(i)}},htmlBuilder:wa,mathmlBuilder:Wa});var Ba=g=>{var I="ordgroup"===g.type&&g.body.length?g.body[0]:g;return"atom"!==I.type||"bin"!==I.family&&"rel"!==I.family?"mord":"m"+I.family};Kd({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(g,I){var{parser:C}=g;return{type:"mclass",mode:C.mode,mclass:Ba(I[0]),body:Md(I[1]),isCharacterBox:So.isCharacterBox(I[1])}}}),Kd({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(g,I){var C,{parser:A,funcName:i}=g,e=I[1],t=I[0];C="\\stackrel"!==i?Ba(e):"mrel";var l={type:"op",mode:e.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==i,body:Md(e)},s={type:"supsub",mode:t.mode,base:l,sup:"\\underset"===i?null:t,sub:"\\underset"===i?t:null};return{type:"mclass",mode:A.mode,mclass:C,body:[s],isCharacterBox:So.isCharacterBox(s)}},htmlBuilder:wa,mathmlBuilder:Wa}),Kd({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(g,I){var{parser:C}=g;return{type:"pmb",mode:C.mode,mclass:Ba(I[0]),body:Md(I[0])}},htmlBuilder(g,I){var C=Ld(g.body,I,!0),A=Wd.makeSpan([g.mclass],C,I);return A.style.textShadow="0.02em 0.01em 0.04px",A},mathmlBuilder(g,I){var C=Aa(g.body,I),A=new $d.MathNode("mstyle",C);return A.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),A}});var ya={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Va=g=>"textord"===g.type&&"@"===g.text;function Xa(g,I,C){var A=ya[g];switch(A){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return C.callFunction(A,[I[0]],[I[1]]);case"\\uparrow":case"\\downarrow":var i={type:"atom",text:A,mode:"math",family:"rel"},e={type:"ordgroup",mode:"math",body:[C.callFunction("\\\\cdleft",[I[0]],[]),C.callFunction("\\Big",[i],[]),C.callFunction("\\\\cdright",[I[1]],[])]};return C.callFunction("\\\\cdparent",[e],[]);case"\\\\cdlongequal":return C.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":return C.callFunction("\\Big",[{type:"textord",text:"\\Vert",mode:"math"}],[]);default:return{type:"textord",text:" ",mode:"math"}}}Kd({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(g,I){var{parser:C,funcName:A}=g;return{type:"cdlabel",mode:C.mode,side:A.slice(4),label:I[0]}},htmlBuilder(g,I){var C=I.havingStyle(I.style.sup()),A=Wd.wrapFragment(Qd(g.label,C,I),I);return A.classes.push("cd-label-"+g.side),A.style.bottom=rc(.8-A.depth),A.height=0,A.depth=0,A},mathmlBuilder(g,I){var C=new $d.MathNode("mrow",[ea(g.label,I)]);return(C=new $d.MathNode("mpadded",[C])).setAttribute("width","0"),"left"===g.side&&C.setAttribute("lspace","-1width"),C.setAttribute("voffset","0.7em"),(C=new $d.MathNode("mstyle",[C])).setAttribute("displaystyle","false"),C.setAttribute("scriptlevel","1"),C}}),Kd({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(g,I){var{parser:C}=g;return{type:"cdlabelparent",mode:C.mode,fragment:I[0]}},htmlBuilder(g,I){var C=Wd.wrapFragment(Qd(g.fragment,I),I);return C.classes.push("cd-vert-arrow"),C},mathmlBuilder:(g,I)=>new $d.MathNode("mrow",[ea(g.fragment,I)])}),Kd({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(g,I){for(var{parser:C}=g,A=ra(I[0],"ordgroup").body,i="",e=0;e=1114111)throw new Ho("\\@char with invalid code point "+i);return l<=65535?t=String.fromCharCode(l):(l-=65536,t=String.fromCharCode(55296+(l>>10),56320+(1023&l))),{type:"textord",mode:C.mode,text:t}}});var Ya=(g,I)=>{var C=Ld(g.body,I.withColor(g.color),!1);return Wd.makeFragment(C)},Ra=(g,I)=>{var C=Aa(g.body,I.withColor(g.color)),A=new $d.MathNode("mstyle",C);return A.setAttribute("mathcolor",g.color),A};Kd({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(g,I){var{parser:C}=g,A=ra(I[0],"color-token").color,i=I[1];return{type:"color",mode:C.mode,color:A,body:Md(i)}},htmlBuilder:Ya,mathmlBuilder:Ra}),Kd({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(g,I){var{parser:C,breakOnTokenText:A}=g,i=ra(I[0],"color-token").color;C.gullet.macros.set("\\current@color",i);var e=C.parseExpression(!0,A);return{type:"color",mode:C.mode,color:i,body:e}},htmlBuilder:Ya,mathmlBuilder:Ra}),Kd({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(g,I,C){var{parser:A}=g,i="["===A.gullet.future().text?A.parseSizeGroup(!0):null,e=!A.settings.displayMode||!A.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:A.mode,newLine:e,size:i&&ra(i,"size").value}},htmlBuilder(g,I){var C=Wd.makeSpan(["mspace"],[],I);return g.newLine&&(C.classes.push("newline"),g.size&&(C.style.marginTop=rc(nc(g.size,I)))),C},mathmlBuilder(g,I){var C=new $d.MathNode("mspace");return g.newLine&&(C.setAttribute("linebreak","newline"),g.size&&C.setAttribute("height",rc(nc(g.size,I)))),C}});var Na={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Ha=g=>{var I=g.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(I))throw new Ho("Expected a control sequence",g);return I},Ka=(g,I,C,A)=>{var i=g.gullet.macros.get(C.text);null==i&&(C.noexpand=!0,i={tokens:[C],numArgs:0,unexpandable:!g.gullet.isExpandable(C.text)}),g.gullet.macros.set(I,i,A)};Kd({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(g){var{parser:I,funcName:C}=g;I.consumeSpaces();var A=I.fetch();if(Na[A.text])return"\\global"!==C&&"\\\\globallong"!==C||(A.text=Na[A.text]),ra(I.parseFunction(),"internal");throw new Ho("Invalid token after macro prefix",A)}}),Kd({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(g){var{parser:I,funcName:C}=g,A=I.gullet.popToken(),i=A.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new Ho("Expected a control sequence",A);for(var e,t=0,l=[[]];"{"!==I.gullet.future().text;)if("#"===(A=I.gullet.popToken()).text){if("{"===I.gullet.future().text){e=I.gullet.future(),l[t].push("{");break}if(A=I.gullet.popToken(),!/^[1-9]$/.test(A.text))throw new Ho('Invalid argument number "'+A.text+'"');if(parseInt(A.text)!==t+1)throw new Ho('Argument number "'+A.text+'" out of order');t++,l.push([])}else{if("EOF"===A.text)throw new Ho("Expected a macro definition");l[t].push(A.text)}var{tokens:s}=I.gullet.consumeArg();return e&&s.unshift(e),"\\edef"!==C&&"\\xdef"!==C||(s=I.gullet.expandTokens(s)).reverse(),I.gullet.macros.set(i,{tokens:s,numArgs:t,delimiters:l},C===Na[C]),{type:"internal",mode:I.mode}}}),Kd({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(g){var{parser:I,funcName:C}=g,A=Ha(I.gullet.popToken());I.gullet.consumeSpaces();var i=(g=>{var I=g.gullet.popToken();return"="===I.text&&" "===(I=g.gullet.popToken()).text&&(I=g.gullet.popToken()),I})(I);return Ka(I,A,i,"\\\\globallet"===C),{type:"internal",mode:I.mode}}}),Kd({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(g){var{parser:I,funcName:C}=g,A=Ha(I.gullet.popToken()),i=I.gullet.popToken(),e=I.gullet.popToken();return Ka(I,A,e,"\\\\globalfuture"===C),I.gullet.pushToken(e),I.gullet.pushToken(i),{type:"internal",mode:I.mode}}});var fa=function(g,I,C){var A=ic(Nc.math[g]&&Nc.math[g].replace||g,I,C);if(!A)throw new Error("Unsupported symbol "+g+" and font size "+I+".");return A},Fa=function(g,I,C,A){var i=C.havingBaseStyle(I),e=Wd.makeSpan(A.concat(i.sizingClasses(C)),[g],C),t=i.sizeMultiplier/C.sizeMultiplier;return e.height*=t,e.depth*=t,e.maxFontSize=i.sizeMultiplier,e},Ma=function(g,I,C){var A=I.havingBaseStyle(C),i=(1-I.sizeMultiplier/A.sizeMultiplier)*I.fontMetrics().axisHeight;g.classes.push("delimcenter"),g.style.top=rc(i),g.height-=i,g.depth+=i},Sa=function(g,I,C,A,i,e){var t=function(g,I,C,A){return Wd.makeSymbol(g,"Size"+I+"-Regular",C,A)}(g,I,i,A),l=Fa(Wd.makeSpan(["delimsizing","size"+I],[t],A),Oo.TEXT,A,e);return C&&Ma(l,A,Oo.TEXT),l},Ja=function(g,I,C){var A;return A="Size1-Regular"===I?"delim-size1":"delim-size4",{type:"elem",elem:Wd.makeSpan(["delimsizinginner",A],[Wd.makeSpan([],[Wd.makeSymbol(g,I,C)])])}},ka=function(g,I,C){var A=Ic["Size4-Regular"][g.charCodeAt(0)]?Ic["Size4-Regular"][g.charCodeAt(0)][4]:Ic["Size1-Regular"][g.charCodeAt(0)][4],i=new yc("inner",function(g,I){switch(g){case"⎜":return"M291 0 H417 V"+I+" H291z M291 0 H417 V"+I+" H291z";case"∣":return"M145 0 H188 V"+I+" H145z M145 0 H188 V"+I+" H145z";case"∥":return"M145 0 H188 V"+I+" H145z M145 0 H188 V"+I+" H145zM367 0 H410 V"+I+" H367z M367 0 H410 V"+I+" H367z";case"⎟":return"M457 0 H583 V"+I+" H457z M457 0 H583 V"+I+" H457z";case"⎢":return"M319 0 H403 V"+I+" H319z M319 0 H403 V"+I+" H319z";case"⎥":return"M263 0 H347 V"+I+" H263z M263 0 H347 V"+I+" H263z";case"⎪":return"M384 0 H504 V"+I+" H384z M384 0 H504 V"+I+" H384z";case"⏐":return"M312 0 H355 V"+I+" H312z M312 0 H355 V"+I+" H312z";case"‖":return"M257 0 H300 V"+I+" H257z M257 0 H300 V"+I+" H257zM478 0 H521 V"+I+" H478z M478 0 H521 V"+I+" H478z";default:return""}}(g,Math.round(1e3*I))),e=new Bc([i],{width:rc(A),height:rc(I),style:"width:"+rc(A),viewBox:"0 0 "+1e3*A+" "+Math.round(1e3*I),preserveAspectRatio:"xMinYMin"}),t=Wd.makeSvgSpan([],[e],C);return t.height=I,t.style.height=rc(I),t.style.width=rc(A),{type:"elem",elem:t}},Da={type:"kern",size:-.008},va=["|","\\lvert","\\rvert","\\vert"],La=["\\|","\\lVert","\\rVert","\\Vert"],za=function(g,I,C,A,i,e){var t,l,s,o,c="",d=0;t=s=o=g,l=null;var a="Size1-Regular";"\\uparrow"===g?s=o="⏐":"\\Uparrow"===g?s=o="‖":"\\downarrow"===g?t=s="⏐":"\\Downarrow"===g?t=s="‖":"\\updownarrow"===g?(t="\\uparrow",s="⏐",o="\\downarrow"):"\\Updownarrow"===g?(t="\\Uparrow",s="‖",o="\\Downarrow"):So.contains(va,g)?(s="∣",c="vert",d=333):So.contains(La,g)?(s="∥",c="doublevert",d=556):"["===g||"\\lbrack"===g?(t="⎡",s="⎢",o="⎣",a="Size4-Regular",c="lbrack",d=667):"]"===g||"\\rbrack"===g?(t="⎤",s="⎥",o="⎦",a="Size4-Regular",c="rbrack",d=667):"\\lfloor"===g||"⌊"===g?(s=t="⎢",o="⎣",a="Size4-Regular",c="lfloor",d=667):"\\lceil"===g||"⌈"===g?(t="⎡",s=o="⎢",a="Size4-Regular",c="lceil",d=667):"\\rfloor"===g||"⌋"===g?(s=t="⎥",o="⎦",a="Size4-Regular",c="rfloor",d=667):"\\rceil"===g||"⌉"===g?(t="⎤",s=o="⎥",a="Size4-Regular",c="rceil",d=667):"("===g||"\\lparen"===g?(t="⎛",s="⎜",o="⎝",a="Size4-Regular",c="lparen",d=875):")"===g||"\\rparen"===g?(t="⎞",s="⎟",o="⎠",a="Size4-Regular",c="rparen",d=875):"\\{"===g||"\\lbrace"===g?(t="⎧",l="⎨",o="⎩",s="⎪",a="Size4-Regular"):"\\}"===g||"\\rbrace"===g?(t="⎫",l="⎬",o="⎭",s="⎪",a="Size4-Regular"):"\\lgroup"===g||"⟮"===g?(t="⎧",o="⎩",s="⎪",a="Size4-Regular"):"\\rgroup"===g||"⟯"===g?(t="⎫",o="⎭",s="⎪",a="Size4-Regular"):"\\lmoustache"===g||"⎰"===g?(t="⎧",o="⎭",s="⎪",a="Size4-Regular"):"\\rmoustache"!==g&&"⎱"!==g||(t="⎫",o="⎩",s="⎪",a="Size4-Regular");var n=fa(t,a,i),r=n.height+n.depth,m=fa(s,a,i),h=m.height+m.depth,Z=fa(o,a,i),b=Z.height+Z.depth,G=0,u=1;if(null!==l){var p=fa(l,a,i);G=p.height+p.depth,u=2}var w=r+b+G,W=w+Math.max(0,Math.ceil((I-w)/(u*h)))*u*h,B=A.fontMetrics().axisHeight;C&&(B*=A.sizeMultiplier);var y=W/2-B,V=[];if(c.length>0){var X=W-r-b,Y=Math.round(1e3*W),R=function(g,I){switch(g){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+I+" v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v"+I+" v1759 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+I+" v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v"+I+" v1759 h84z";case"vert":return"M145 15 v585 v"+I+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-I+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+I+" v585 h43z";case"doublevert":return"M145 15 v585 v"+I+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-I+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+I+" v585 h43z\nM367 15 v585 v"+I+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-I+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v"+I+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+I+" v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v"+I+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+I+" v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v"+I+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+I+" v602 h84z\nM403 1759 V0 H319 V1759 v"+I+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+I+" v602 h84z\nM347 1759 V0 h-84 V1759 v"+I+" v602 h84z";case"lparen":return"M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0,"+(I+84)+"c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-"+(I+92)+"c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";case"rparen":return"M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,"+(I+9)+"\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-"+(I+144)+"c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";default:throw new Error("Unknown stretchy delimiter.")}}(c,Math.round(1e3*X)),N=new yc(c,R),H=(d/1e3).toFixed(3)+"em",K=(Y/1e3).toFixed(3)+"em",f=new Bc([N],{width:H,height:K,viewBox:"0 0 "+d+" "+Y}),F=Wd.makeSvgSpan([],[f],A);F.height=Y/1e3,F.style.width=H,F.style.height=K,V.push({type:"elem",elem:F})}else{if(V.push(Ja(o,a,i)),V.push(Da),null===l){var M=W-r-b+.016;V.push(ka(s,M,A))}else{var S=(W-r-b-G)/2+.016;V.push(ka(s,S,A)),V.push(Da),V.push(Ja(l,a,i)),V.push(Da),V.push(ka(s,S,A))}V.push(Da),V.push(Ja(t,a,i))}var J=A.havingBaseStyle(Oo.TEXT),k=Wd.makeVList({positionType:"bottom",positionData:y,children:V},J);return Fa(Wd.makeSpan(["delimsizing","mult"],[k],J),Oo.TEXT,A,e)},Ta=.08,xa=function(g,I,C,A,i){var e=function(g,I,C){I*=1e3;var A="";switch(g){case"sqrtMain":A=function(g,I){return"M95,"+(622+g+I)+"\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl"+g/2.075+" -"+g+"\nc5.3,-9.3,12,-14,20,-14\nH400000v"+(40+g)+"H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM"+(834+g)+" "+I+"h400000v"+(40+g)+"h-400000z"}(I,qo);break;case"sqrtSize1":A=function(g,I){return"M263,"+(601+g+I)+"c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl"+g/2.084+" -"+g+"\nc4.7,-7.3,11,-11,19,-11\nH40000v"+(40+g)+"H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM"+(1001+g)+" "+I+"h400000v"+(40+g)+"h-400000z"}(I,qo);break;case"sqrtSize2":A=function(g,I){return"M983 "+(10+g+I)+"\nl"+g/3.13+" -"+g+"\nc4,-6.7,10,-10,18,-10 H400000v"+(40+g)+"\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM"+(1001+g)+" "+I+"h400000v"+(40+g)+"h-400000z"}(I,qo);break;case"sqrtSize3":A=function(g,I){return"M424,"+(2398+g+I)+"\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl"+g/4.223+" -"+g+"c4,-6.7,10,-10,18,-10 H400000\nv"+(40+g)+"H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M"+(1001+g)+" "+I+"\nh400000v"+(40+g)+"h-400000z"}(I,qo);break;case"sqrtSize4":A=function(g,I){return"M473,"+(2713+g+I)+"\nc339.3,-1799.3,509.3,-2700,510,-2702 l"+g/5.298+" -"+g+"\nc3.3,-7.3,9.3,-11,18,-11 H400000v"+(40+g)+"H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM"+(1001+g)+" "+I+"h400000v"+(40+g)+"H1017.7z"}(I,qo);break;case"sqrtTall":A=function(g,I,C){return"M702 "+(g+I)+"H400000"+(40+g)+"\nH742v"+(C-54-I-g)+"l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 "+I+"H400000v"+(40+g)+"H742z"}(I,qo,C)}return A}(g,A,C),t=new yc(g,e),l=new Bc([t],{width:"400em",height:rc(I),viewBox:"0 0 400000 "+C,preserveAspectRatio:"xMinYMin slice"});return Wd.makeSvgSpan(["hide-tail"],[l],i)},Ua=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","\\surd"],ja=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱"],Qa=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],Oa=[0,1.2,1.8,2.4,3],Ea=[{type:"small",style:Oo.SCRIPTSCRIPT},{type:"small",style:Oo.SCRIPT},{type:"small",style:Oo.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],Pa=[{type:"small",style:Oo.SCRIPTSCRIPT},{type:"small",style:Oo.SCRIPT},{type:"small",style:Oo.TEXT},{type:"stack"}],_a=[{type:"small",style:Oo.SCRIPTSCRIPT},{type:"small",style:Oo.SCRIPT},{type:"small",style:Oo.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],qa=function(g){if("small"===g.type)return"Main-Regular";if("large"===g.type)return"Size"+g.size+"-Regular";if("stack"===g.type)return"Size4-Regular";throw new Error("Add support for delim type '"+g.type+"' here.")},$a=function(g,I,C,A){for(var i=Math.min(2,3-A.style.size);iI)return C[i]}return C[C.length-1]},gn=function(g,I,C,A,i,e){var t;"<"===g||"\\lt"===g||"⟨"===g?g="\\langle":">"!==g&&"\\gt"!==g&&"⟩"!==g||(g="\\rangle"),t=So.contains(Qa,g)?Ea:So.contains(Ua,g)?_a:Pa;var l=$a(g,I,t,A);return"small"===l.type?function(g,I,C,A,i,e){var t=Wd.makeSymbol(g,"Main-Regular",i,A),l=Fa(t,I,A,e);return C&&Ma(l,A,I),l}(g,l.style,C,A,i,e):"large"===l.type?Sa(g,l.size,C,A,i,e):za(g,I,C,A,i,e)},In={sqrtImage:function(g,I){var C,A,i=I.havingBaseSizing(),e=$a("\\surd",g*i.sizeMultiplier,_a,i),t=i.sizeMultiplier,l=Math.max(0,I.minRuleThickness-I.fontMetrics().sqrtRuleThickness),s=0,o=0,c=0;return"small"===e.type?(g<1?t=1:g<1.4&&(t=.7),o=(1+l)/t,(C=xa("sqrtMain",s=(1+l+Ta)/t,c=1e3+1e3*l+80,l,I)).style.minWidth="0.853em",A=.833/t):"large"===e.type?(c=1080*Oa[e.size],o=(Oa[e.size]+l)/t,s=(Oa[e.size]+l+Ta)/t,(C=xa("sqrtSize"+e.size,s,c,l,I)).style.minWidth="1.02em",A=1/t):(s=g+l+Ta,o=g+l,c=Math.floor(1e3*g+l)+80,(C=xa("sqrtTall",s,c,l,I)).style.minWidth="0.742em",A=1.056),C.height=o,C.style.height=rc(s),{span:C,advanceWidth:A,ruleWidth:(I.fontMetrics().sqrtRuleThickness+l)*t}},sizedDelim:function(g,I,C,A,i){if("<"===g||"\\lt"===g||"⟨"===g?g="\\langle":">"!==g&&"\\gt"!==g&&"⟩"!==g||(g="\\rangle"),So.contains(Ua,g)||So.contains(Qa,g))return Sa(g,I,!1,C,A,i);if(So.contains(ja,g))return za(g,Oa[I],!1,C,A,i);throw new Ho("Illegal delimiter: '"+g+"'")},sizeToMaxHeight:Oa,customSizedDelim:gn,leftRightDelim:function(g,I,C,A,i,e){var t=A.fontMetrics().axisHeight*A.sizeMultiplier,l=5/A.fontMetrics().ptPerEm,s=Math.max(I-t,C+t),o=Math.max(s/500*901,2*s-l);return gn(g,o,!0,A,i,e)}},Cn={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},An=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];function en(g,I){var C=ha(g);if(C&&So.contains(An,C.text))return C;throw new Ho(C?"Invalid delimiter '"+C.text+"' after '"+I.funcName+"'":"Invalid delimiter type '"+g.type+"'",g)}function tn(g){if(!g.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}Kd({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(g,I)=>{var C=en(I[0],g);return{type:"delimsizing",mode:g.parser.mode,size:Cn[g.funcName].size,mclass:Cn[g.funcName].mclass,delim:C.text}},htmlBuilder:(g,I)=>"."===g.delim?Wd.makeSpan([g.mclass]):In.sizedDelim(g.delim,g.size,I,g.mode,[g.mclass]),mathmlBuilder:g=>{var I=[];"."!==g.delim&&I.push(ga(g.delim,g.mode));var C=new $d.MathNode("mo",I);"mopen"===g.mclass||"mclose"===g.mclass?C.setAttribute("fence","true"):C.setAttribute("fence","false"),C.setAttribute("stretchy","true");var A=rc(In.sizeToMaxHeight[g.size]);return C.setAttribute("minsize",A),C.setAttribute("maxsize",A),C}}),Kd({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(g,I)=>{var C=g.parser.gullet.macros.get("\\current@color");if(C&&"string"!=typeof C)throw new Ho("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:g.parser.mode,delim:en(I[0],g).text,color:C}}}),Kd({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(g,I)=>{var C=en(I[0],g),A=g.parser;++A.leftrightDepth;var i=A.parseExpression(!1);--A.leftrightDepth,A.expect("\\right",!1);var e=ra(A.parseFunction(),"leftright-right");return{type:"leftright",mode:A.mode,body:i,left:C.text,right:e.delim,rightColor:e.color}},htmlBuilder:(g,I)=>{tn(g);for(var C,A,i=Ld(g.body,I,!0,["mopen","mclose"]),e=0,t=0,l=!1,s=0;s{tn(g);var C=Aa(g.body,I);if("."!==g.left){var A=new $d.MathNode("mo",[ga(g.left,g.mode)]);A.setAttribute("fence","true"),C.unshift(A)}if("."!==g.right){var i=new $d.MathNode("mo",[ga(g.right,g.mode)]);i.setAttribute("fence","true"),g.rightColor&&i.setAttribute("mathcolor",g.rightColor),C.push(i)}return Ia(C)}}),Kd({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(g,I)=>{var C=en(I[0],g);if(!g.parser.leftrightDepth)throw new Ho("\\middle without preceding \\left",C);return{type:"middle",mode:g.parser.mode,delim:C.text}},htmlBuilder:(g,I)=>{var C;if("."===g.delim)C=jd(I,[]);else{C=In.sizedDelim(g.delim,1,I,g.mode,[]);var A={delim:g.delim,options:I};C.isMiddle=A}return C},mathmlBuilder:(g,I)=>{var C="\\vert"===g.delim||"|"===g.delim?ga("|","text"):ga(g.delim,g.mode),A=new $d.MathNode("mo",[C]);return A.setAttribute("fence","true"),A.setAttribute("lspace","0.05em"),A.setAttribute("rspace","0.05em"),A}});var ln=(g,I)=>{var C,A,i,e=Wd.wrapFragment(Qd(g.body,I),I),t=g.label.slice(1),l=I.sizeMultiplier,s=0,o=So.isCharacterBox(g.body);if("sout"===t)(C=Wd.makeSpan(["stretchy","sout"])).height=I.fontMetrics().defaultRuleThickness/l,s=-.5*I.fontMetrics().xHeight;else if("phase"===t){var c=nc({number:.6,unit:"pt"},I),d=nc({number:.35,unit:"ex"},I);l/=I.havingBaseSizing().sizeMultiplier;var a=e.height+e.depth+c+d;e.style.paddingLeft=rc(a/2+c);var n=Math.floor(1e3*a*l),r="M400000 "+(A=n)+" H0 L"+A/2+" 0 l65 45 L145 "+(A-80)+" H400000z",m=new Bc([new yc("phase",r)],{width:"400em",height:rc(n/1e3),viewBox:"0 0 400000 "+n,preserveAspectRatio:"xMinYMin slice"});(C=Wd.makeSvgSpan(["hide-tail"],[m],I)).style.height=rc(a),s=e.depth+c+d}else{/cancel/.test(t)?o||e.classes.push("cancel-pad"):"angl"===t?e.classes.push("anglpad"):e.classes.push("boxpad");var h=0,Z=0,b=0;/box/.test(t)?(b=Math.max(I.fontMetrics().fboxrule,I.minRuleThickness),Z=h=I.fontMetrics().fboxsep+("colorbox"===t?0:b)):"angl"===t?(h=4*(b=Math.max(I.fontMetrics().defaultRuleThickness,I.minRuleThickness)),Z=Math.max(0,.25-e.depth)):Z=h=o?.2:0,C=da(e,t,h,Z,I),/fbox|boxed|fcolorbox/.test(t)?(C.style.borderStyle="solid",C.style.borderWidth=rc(b)):"angl"===t&&.049!==b&&(C.style.borderTopWidth=rc(b),C.style.borderRightWidth=rc(b)),s=e.depth+Z,g.backgroundColor&&(C.style.backgroundColor=g.backgroundColor,g.borderColor&&(C.style.borderColor=g.borderColor))}if(g.backgroundColor)i=Wd.makeVList({positionType:"individualShift",children:[{type:"elem",elem:C,shift:s},{type:"elem",elem:e,shift:0}]},I);else{var G=/cancel|phase/.test(t)?["svg-align"]:[];i=Wd.makeVList({positionType:"individualShift",children:[{type:"elem",elem:e,shift:0},{type:"elem",elem:C,shift:s,wrapperClasses:G}]},I)}return/cancel/.test(t)&&(i.height=e.height,i.depth=e.depth),/cancel/.test(t)&&!o?Wd.makeSpan(["mord","cancel-lap"],[i],I):Wd.makeSpan(["mord"],[i],I)},sn=(g,I)=>{var C=0,A=new $d.MathNode(g.label.indexOf("colorbox")>-1?"mpadded":"menclose",[ea(g.body,I)]);switch(g.label){case"\\cancel":A.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":A.setAttribute("notation","downdiagonalstrike");break;case"\\phase":A.setAttribute("notation","phasorangle");break;case"\\sout":A.setAttribute("notation","horizontalstrike");break;case"\\fbox":A.setAttribute("notation","box");break;case"\\angl":A.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(C=I.fontMetrics().fboxsep*I.fontMetrics().ptPerEm,A.setAttribute("width","+"+2*C+"pt"),A.setAttribute("height","+"+2*C+"pt"),A.setAttribute("lspace",C+"pt"),A.setAttribute("voffset",C+"pt"),"\\fcolorbox"===g.label){var i=Math.max(I.fontMetrics().fboxrule,I.minRuleThickness);A.setAttribute("style","border: "+i+"em solid "+String(g.borderColor))}break;case"\\xcancel":A.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return g.backgroundColor&&A.setAttribute("mathbackground",g.backgroundColor),A};Kd({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(g,I,C){var{parser:A,funcName:i}=g,e=ra(I[0],"color-token").color,t=I[1];return{type:"enclose",mode:A.mode,label:i,backgroundColor:e,body:t}},htmlBuilder:ln,mathmlBuilder:sn}),Kd({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(g,I,C){var{parser:A,funcName:i}=g,e=ra(I[0],"color-token").color,t=ra(I[1],"color-token").color,l=I[2];return{type:"enclose",mode:A.mode,label:i,backgroundColor:t,borderColor:e,body:l}},htmlBuilder:ln,mathmlBuilder:sn}),Kd({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(g,I){var{parser:C}=g;return{type:"enclose",mode:C.mode,label:"\\fbox",body:I[0]}}}),Kd({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout","\\phase"],props:{numArgs:1},handler(g,I){var{parser:C,funcName:A}=g,i=I[0];return{type:"enclose",mode:C.mode,label:A,body:i}},htmlBuilder:ln,mathmlBuilder:sn}),Kd({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(g,I){var{parser:C}=g;return{type:"enclose",mode:C.mode,label:"\\angl",body:I[0]}}});var on={};function cn(g){for(var{type:I,names:C,props:A,handler:i,htmlBuilder:e,mathmlBuilder:t}=g,l={type:I,numArgs:A.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},s=0;s{if(!g.parser.settings.displayMode)throw new Ho("{"+g.envName+"} can be used only in display mode.")};function mn(g){if(-1===g.indexOf("ed"))return-1===g.indexOf("*")}function hn(g,I,C){var{hskipBeforeAndAfter:A,addJot:i,cols:e,arraystretch:t,colSeparationType:l,autoTag:s,singleRow:o,emptySingleRow:c,maxNumCols:d,leqno:a}=I;if(g.gullet.beginGroup(),o||g.gullet.macros.set("\\cr","\\\\\\relax"),!t){var n=g.gullet.expandMacroAsText("\\arraystretch");if(null==n)t=1;else if(!(t=parseFloat(n))||t<0)throw new Ho("Invalid \\arraystretch: "+n)}g.gullet.beginGroup();var r=[],m=[r],h=[],Z=[],b=null!=s?[]:void 0;function G(){s&&g.gullet.macros.set("\\@eqnsw","1",!0)}function u(){b&&(g.gullet.macros.get("\\df@tag")?(b.push(g.subparse([new No("\\df@tag")])),g.gullet.macros.set("\\df@tag",void 0,!0)):b.push(Boolean(s)&&"1"===g.gullet.macros.get("\\@eqnsw")))}for(G(),Z.push(nn(g));;){var p=g.parseExpression(!1,o?"\\end":"\\\\");g.gullet.endGroup(),g.gullet.beginGroup(),p={type:"ordgroup",mode:g.mode,body:p},C&&(p={type:"styling",mode:g.mode,style:C,body:[p]}),r.push(p);var w=g.fetch().text;if("&"===w){if(d&&r.length===d){if(o||l)throw new Ho("Too many tab characters: &",g.nextToken);g.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}g.consume()}else{if("\\end"===w){u(),1===r.length&&"styling"===p.type&&0===p.body[0].body.length&&(m.length>1||!c)&&m.pop(),Z.length0&&(Z+=.25),s.push({pos:Z,isDashed:g[I]})}for(b(e[0]),C=0;C0&&(p<(y+=h)&&(p=y),y=0),g.addJot&&(p+=n),w.height=u,w.depth=p,Z+=u,w.pos=Z,Z+=p+y,l[C]=w,b(e[C+1])}var V,X,Y=Z/2+I.fontMetrics().axisHeight,R=g.cols||[],N=[],H=[];if(g.tags&&g.tags.some((g=>g)))for(C=0;C=t)){var L=void 0;(A>0||g.hskipBeforeAndAfter)&&0!==(L=So.deflt(S.pregap,d))&&((V=Wd.makeSpan(["arraycolsep"],[])).style.width=rc(L),N.push(V));var z=[];for(C=0;C0){for(var j=Wd.makeLineSpan("hline",I,o),Q=Wd.makeLineSpan("hdashline",I,o),O=[{type:"elem",elem:l,shift:0}];s.length>0;){var E=s.pop(),P=E.pos-Y;E.isDashed?O.push({type:"elem",elem:Q,shift:P}):O.push({type:"elem",elem:j,shift:P})}l=Wd.makeVList({positionType:"individualShift",children:O},I)}if(0===H.length)return Wd.makeSpan(["mord"],[l],I);var _=Wd.makeVList({positionType:"individualShift",children:H},I);return _=Wd.makeSpan(["tag"],[_],I),Wd.makeFragment([l,_])},Gn={c:"center ",l:"left ",r:"right "},un=function(g,I){for(var C=[],A=new $d.MathNode("mtd",[],["mtr-glue"]),i=new $d.MathNode("mtd",[],["mml-eqn-num"]),e=0;e0){var n=g.cols,r="",m=!1,h=0,Z=n.length;"separator"===n[0].type&&(d+="top ",h=1),"separator"===n[n.length-1].type&&(d+="bottom ",Z-=1);for(var b=h;b0?"left ":"",d+=W[W.length-1].length>0?"right ":"";for(var B=1;B-1?"alignat":"align",e="split"===g.envName,t=hn(g.parser,{cols:A,addJot:!0,autoTag:e?void 0:mn(g.envName),emptySingleRow:!0,colSeparationType:i,maxNumCols:e?2:void 0,leqno:g.parser.settings.leqno},"display"),l=0,s={type:"ordgroup",mode:g.mode,body:[]};if(I[0]&&"ordgroup"===I[0].type){for(var o="",c=0;c0&&d&&(r=1),A[a]={type:"align",align:n,pregap:r,postgap:0}}return t.colSeparationType=d?"align":"alignat",t};cn({type:"array",names:["array","darray"],props:{numArgs:1},handler(g,I){var C=(ha(I[0])?[I[0]]:ra(I[0],"ordgroup").body).map((function(g){var I=ma(g).text;if(-1!=="lcr".indexOf(I))return{type:"align",align:I};if("|"===I)return{type:"separator",separator:"|"};if(":"===I)return{type:"separator",separator:":"};throw new Ho("Unknown column alignment: "+I,g)})),A={cols:C,hskipBeforeAndAfter:!0,maxNumCols:C.length};return hn(g.parser,A,Zn(g.envName))},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(g){var I={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[g.envName.replace("*","")],C="c",A={hskipBeforeAndAfter:!1,cols:[{type:"align",align:C}]};if("*"===g.envName.charAt(g.envName.length-1)){var i=g.parser;if(i.consumeSpaces(),"["===i.fetch().text){if(i.consume(),i.consumeSpaces(),C=i.fetch().text,-1==="lcr".indexOf(C))throw new Ho("Expected l or c or r",i.nextToken);i.consume(),i.consumeSpaces(),i.expect("]"),i.consume(),A.cols=[{type:"align",align:C}]}}var e=hn(g.parser,A,Zn(g.envName)),t=Math.max(0,...e.body.map((g=>g.length)));return e.cols=new Array(t).fill({type:"align",align:C}),I?{type:"leftright",mode:g.mode,body:[e],left:I[0],right:I[1],rightColor:void 0}:e},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(g){var I=hn(g.parser,{arraystretch:.5},"script");return I.colSeparationType="small",I},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["subarray"],props:{numArgs:1},handler(g,I){var C=(ha(I[0])?[I[0]]:ra(I[0],"ordgroup").body).map((function(g){var I=ma(g).text;if(-1!=="lc".indexOf(I))return{type:"align",align:I};throw new Ho("Unknown column alignment: "+I,g)}));if(C.length>1)throw new Ho("{subarray} can contain only one column");var A={cols:C,hskipBeforeAndAfter:!1,arraystretch:.5};if((A=hn(g.parser,A,"script")).body.length>0&&A.body[0].length>1)throw new Ho("{subarray} can contain only one column");return A},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(g){var I=hn(g.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},Zn(g.envName));return{type:"leftright",mode:g.mode,body:[I],left:g.envName.indexOf("r")>-1?".":"\\{",right:g.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:pn,htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(g){So.contains(["gather","gather*"],g.envName)&&rn(g);var I={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:mn(g.envName),emptySingleRow:!0,leqno:g.parser.settings.leqno};return hn(g.parser,I,"display")},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:pn,htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(g){rn(g);var I={autoTag:mn(g.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:g.parser.settings.leqno};return hn(g.parser,I,"display")},htmlBuilder:bn,mathmlBuilder:un}),cn({type:"array",names:["CD"],props:{numArgs:0},handler:g=>(rn(g),function(g){var I=[];for(g.gullet.beginGroup(),g.gullet.macros.set("\\cr","\\\\\\relax"),g.gullet.beginGroup();;){I.push(g.parseExpression(!1,"\\\\")),g.gullet.endGroup(),g.gullet.beginGroup();var C=g.fetch().text;if("&"!==C&&"\\\\"!==C){if("\\end"===C){0===I[I.length-1].length&&I.pop();break}throw new Ho("Expected \\\\ or \\cr or \\end",g.nextToken)}g.consume()}for(var A,i,e=[],t=[e],l=0;l-1);else{if(!("<>AV".indexOf(d)>-1))throw new Ho('Expected one of "<>AV=|." after @',s[c]);for(var n=0;n<2;n++){for(var r=!0,m=c+1;m{var C=g.font,A=I.withFont(C);return Qd(g.body,A)},Bn=(g,I)=>{var C=g.font,A=I.withFont(C);return ea(g.body,A)},yn={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};Kd({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(g,I)=>{var{parser:C,funcName:A}=g,i=Fd(I[0]),e=A;return e in yn&&(e=yn[e]),{type:"font",mode:C.mode,font:e.slice(1),body:i}},htmlBuilder:Wn,mathmlBuilder:Bn}),Kd({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(g,I)=>{var{parser:C}=g,A=I[0],i=So.isCharacterBox(A);return{type:"mclass",mode:C.mode,mclass:Ba(A),body:[{type:"font",mode:C.mode,font:"boldsymbol",body:A}],isCharacterBox:i}}}),Kd({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(g,I)=>{var{parser:C,funcName:A,breakOnTokenText:i}=g,{mode:e}=C,t=C.parseExpression(!0,i);return{type:"font",mode:e,font:"math"+A.slice(1),body:{type:"ordgroup",mode:C.mode,body:t}}},htmlBuilder:Wn,mathmlBuilder:Bn});var Vn=(g,I)=>{var C=I;return"display"===g?C=C.id>=Oo.SCRIPT.id?C.text():Oo.DISPLAY:"text"===g&&C.size===Oo.DISPLAY.size?C=Oo.TEXT:"script"===g?C=Oo.SCRIPT:"scriptscript"===g&&(C=Oo.SCRIPTSCRIPT),C},Xn=(g,I)=>{var C,A=Vn(g.size,I.style),i=A.fracNum(),e=A.fracDen();C=I.havingStyle(i);var t=Qd(g.numer,C,I);if(g.continued){var l=8.5/I.fontMetrics().ptPerEm,s=3.5/I.fontMetrics().ptPerEm;t.height=t.height0?3*d:7*d,r=I.fontMetrics().denom1):(c>0?(a=I.fontMetrics().num2,n=d):(a=I.fontMetrics().num3,n=3*d),r=I.fontMetrics().denom2),o){var u=I.fontMetrics().axisHeight;a-t.depth-(u+.5*c){var C=new $d.MathNode("mfrac",[ea(g.numer,I),ea(g.denom,I)]);if(g.hasBarLine){if(g.barSize){var A=nc(g.barSize,I);C.setAttribute("linethickness",rc(A))}}else C.setAttribute("linethickness","0px");var i=Vn(g.size,I.style);if(i.size!==I.style.size){C=new $d.MathNode("mstyle",[C]);var e=i.size===Oo.DISPLAY.size?"true":"false";C.setAttribute("displaystyle",e),C.setAttribute("scriptlevel","0")}if(null!=g.leftDelim||null!=g.rightDelim){var t=[];if(null!=g.leftDelim){var l=new $d.MathNode("mo",[new $d.TextNode(g.leftDelim.replace("\\",""))]);l.setAttribute("fence","true"),t.push(l)}if(t.push(C),null!=g.rightDelim){var s=new $d.MathNode("mo",[new $d.TextNode(g.rightDelim.replace("\\",""))]);s.setAttribute("fence","true"),t.push(s)}return Ia(t)}return C};Kd({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(g,I)=>{var C,{parser:A,funcName:i}=g,e=I[0],t=I[1],l=null,s=null,o="auto";switch(i){case"\\dfrac":case"\\frac":case"\\tfrac":C=!0;break;case"\\\\atopfrac":C=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":C=!1,l="(",s=")";break;case"\\\\bracefrac":C=!1,l="\\{",s="\\}";break;case"\\\\brackfrac":C=!1,l="[",s="]";break;default:throw new Error("Unrecognized genfrac command")}switch(i){case"\\dfrac":case"\\dbinom":o="display";break;case"\\tfrac":case"\\tbinom":o="text"}return{type:"genfrac",mode:A.mode,continued:!1,numer:e,denom:t,hasBarLine:C,leftDelim:l,rightDelim:s,size:o,barSize:null}},htmlBuilder:Xn,mathmlBuilder:Yn}),Kd({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:(g,I)=>{var{parser:C,funcName:A}=g,i=I[0],e=I[1];return{type:"genfrac",mode:C.mode,continued:!0,numer:i,denom:e,hasBarLine:!0,leftDelim:null,rightDelim:null,size:"display",barSize:null}}}),Kd({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(g){var I,{parser:C,funcName:A,token:i}=g;switch(A){case"\\over":I="\\frac";break;case"\\choose":I="\\binom";break;case"\\atop":I="\\\\atopfrac";break;case"\\brace":I="\\\\bracefrac";break;case"\\brack":I="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:C.mode,replaceWith:I,token:i}}});var Rn=["display","text","script","scriptscript"],Nn=function(g){var I=null;return g.length>0&&(I="."===(I=g)?null:I),I};Kd({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(g,I){var C,{parser:A}=g,i=I[4],e=I[5],t=Fd(I[0]),l="atom"===t.type&&"open"===t.family?Nn(t.text):null,s=Fd(I[1]),o="atom"===s.type&&"close"===s.family?Nn(s.text):null,c=ra(I[2],"size"),d=null;C=!!c.isBlank||(d=c.value).number>0;var a="auto",n=I[3];if("ordgroup"===n.type){if(n.body.length>0){var r=ra(n.body[0],"textord");a=Rn[Number(r.text)]}}else n=ra(n,"textord"),a=Rn[Number(n.text)];return{type:"genfrac",mode:A.mode,numer:i,denom:e,continued:!1,hasBarLine:C,barSize:d,leftDelim:l,rightDelim:o,size:a}},htmlBuilder:Xn,mathmlBuilder:Yn}),Kd({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(g,I){var{parser:C,funcName:A,token:i}=g;return{type:"infix",mode:C.mode,replaceWith:"\\\\abovefrac",size:ra(I[0],"size").value,token:i}}}),Kd({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(g,I)=>{var{parser:C,funcName:A}=g,i=I[0],e=function(g){if(!g)throw new Error("Expected non-null, but got "+String(g));return g}(ra(I[1],"infix").size),t=I[2],l=e.number>0;return{type:"genfrac",mode:C.mode,numer:i,denom:t,continued:!1,hasBarLine:l,barSize:e,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:Xn,mathmlBuilder:Yn});var Hn=(g,I)=>{var C,A,i=I.style;"supsub"===g.type?(C=g.sup?Qd(g.sup,I.havingStyle(i.sup()),I):Qd(g.sub,I.havingStyle(i.sub()),I),A=ra(g.base,"horizBrace")):A=ra(g,"horizBrace");var e,t=Qd(A.base,I.havingBaseStyle(Oo.DISPLAY)),l=na(A,I);if(A.isOver?(e=Wd.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:.1},{type:"elem",elem:l}]},I)).children[0].children[0].children[1].classes.push("svg-align"):(e=Wd.makeVList({positionType:"bottom",positionData:t.depth+.1+l.height,children:[{type:"elem",elem:l},{type:"kern",size:.1},{type:"elem",elem:t}]},I)).children[0].children[0].children[0].classes.push("svg-align"),C){var s=Wd.makeSpan(["mord",A.isOver?"mover":"munder"],[e],I);e=A.isOver?Wd.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.2},{type:"elem",elem:C}]},I):Wd.makeVList({positionType:"bottom",positionData:s.depth+.2+C.height+C.depth,children:[{type:"elem",elem:C},{type:"kern",size:.2},{type:"elem",elem:s}]},I)}return Wd.makeSpan(["mord",A.isOver?"mover":"munder"],[e],I)};Kd({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler(g,I){var{parser:C,funcName:A}=g;return{type:"horizBrace",mode:C.mode,label:A,isOver:/^\\over/.test(A),base:I[0]}},htmlBuilder:Hn,mathmlBuilder:(g,I)=>{var C=aa(g.label);return new $d.MathNode(g.isOver?"mover":"munder",[ea(g.base,I),C])}}),Kd({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(g,I)=>{var{parser:C}=g,A=I[1],i=ra(I[0],"url").url;return C.settings.isTrusted({command:"\\href",url:i})?{type:"href",mode:C.mode,href:i,body:Md(A)}:C.formatUnsupportedCmd("\\href")},htmlBuilder:(g,I)=>{var C=Ld(g.body,I,!1);return Wd.makeAnchor(g.href,[],C,I)},mathmlBuilder:(g,I)=>{var C=ia(g.body,I);return C instanceof _d||(C=new _d("mrow",[C])),C.setAttribute("href",g.href),C}}),Kd({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(g,I)=>{var{parser:C}=g,A=ra(I[0],"url").url;if(!C.settings.isTrusted({command:"\\url",url:A}))return C.formatUnsupportedCmd("\\url");for(var i=[],e=0;enew $d.MathNode("mrow",Aa(g.body,I))}),Kd({type:"html",names:["\\htmlClass","\\htmlId","\\htmlStyle","\\htmlData"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:(g,I)=>{var C,{parser:A,funcName:i,token:e}=g,t=ra(I[0],"raw").string,l=I[1];A.settings.strict&&A.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var s={};switch(i){case"\\htmlClass":s.class=t,C={command:"\\htmlClass",class:t};break;case"\\htmlId":s.id=t,C={command:"\\htmlId",id:t};break;case"\\htmlStyle":s.style=t,C={command:"\\htmlStyle",style:t};break;case"\\htmlData":for(var o=t.split(","),c=0;c{var C=Ld(g.body,I,!1),A=["enclosing"];g.attributes.class&&A.push(...g.attributes.class.trim().split(/\s+/));var i=Wd.makeSpan(A,C,I);for(var e in g.attributes)"class"!==e&&g.attributes.hasOwnProperty(e)&&i.setAttribute(e,g.attributes[e]);return i},mathmlBuilder:(g,I)=>ia(g.body,I)}),Kd({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(g,I)=>{var{parser:C}=g;return{type:"htmlmathml",mode:C.mode,html:Md(I[0]),mathml:Md(I[1])}},htmlBuilder:(g,I)=>{var C=Ld(g.html,I,!1);return Wd.makeFragment(C)},mathmlBuilder:(g,I)=>ia(g.mathml,I)});var Kn=function(g){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(g))return{number:+g,unit:"bp"};var I=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(g);if(!I)throw new Ho("Invalid size: '"+g+"' in \\includegraphics");var C={number:+(I[1]+I[2]),unit:I[3]};if(!ac(C))throw new Ho("Invalid unit: '"+C.unit+"' in \\includegraphics.");return C};Kd({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(g,I,C)=>{var{parser:A}=g,i={number:0,unit:"em"},e={number:.9,unit:"em"},t={number:0,unit:"em"},l="";if(C[0])for(var s=ra(C[0],"raw").string.split(","),o=0;o{var C=nc(g.height,I),A=0;g.totalheight.number>0&&(A=nc(g.totalheight,I)-C);var i=0;g.width.number>0&&(i=nc(g.width,I));var e={height:rc(C+A)};i>0&&(e.width=rc(i)),A>0&&(e.verticalAlign=rc(-A));var t=new pc(g.src,g.alt,e);return t.height=C,t.depth=A,t},mathmlBuilder:(g,I)=>{var C=new $d.MathNode("mglyph",[]);C.setAttribute("alt",g.alt);var A=nc(g.height,I),i=0;if(g.totalheight.number>0&&(i=nc(g.totalheight,I)-A,C.setAttribute("valign",rc(-i))),C.setAttribute("height",rc(A+i)),g.width.number>0){var e=nc(g.width,I);C.setAttribute("width",rc(e))}return C.setAttribute("src",g.src),C}}),Kd({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(g,I){var{parser:C,funcName:A}=g,i=ra(I[0],"size");if(C.settings.strict){var e="m"===A[1],t="mu"===i.value.unit;e?(t||C.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+A+" supports only mu units, not "+i.value.unit+" units"),"math"!==C.mode&&C.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+A+" works only in math mode")):t&&C.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+A+" doesn't support mu units")}return{type:"kern",mode:C.mode,dimension:i.value}},htmlBuilder:(g,I)=>Wd.makeGlue(g.dimension,I),mathmlBuilder(g,I){var C=nc(g.dimension,I);return new $d.SpaceNode(C)}}),Kd({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(g,I)=>{var{parser:C,funcName:A}=g,i=I[0];return{type:"lap",mode:C.mode,alignment:A.slice(5),body:i}},htmlBuilder:(g,I)=>{var C;"clap"===g.alignment?(C=Wd.makeSpan([],[Qd(g.body,I)]),C=Wd.makeSpan(["inner"],[C],I)):C=Wd.makeSpan(["inner"],[Qd(g.body,I)]);var A=Wd.makeSpan(["fix"],[]),i=Wd.makeSpan([g.alignment],[C,A],I),e=Wd.makeSpan(["strut"]);return e.style.height=rc(i.height+i.depth),i.depth&&(e.style.verticalAlign=rc(-i.depth)),i.children.unshift(e),i=Wd.makeSpan(["thinbox"],[i],I),Wd.makeSpan(["mord","vbox"],[i],I)},mathmlBuilder:(g,I)=>{var C=new $d.MathNode("mpadded",[ea(g.body,I)]);if("rlap"!==g.alignment){var A="llap"===g.alignment?"-1":"-0.5";C.setAttribute("lspace",A+"width")}return C.setAttribute("width","0px"),C}}),Kd({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(g,I){var{funcName:C,parser:A}=g,i=A.mode;A.switchMode("math");var e="\\("===C?"\\)":"$",t=A.parseExpression(!1,e);return A.expect(e),A.switchMode(i),{type:"styling",mode:A.mode,style:"text",body:t}}}),Kd({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(g,I){throw new Ho("Mismatched "+g.funcName)}});var fn=(g,I)=>{switch(I.style.size){case Oo.DISPLAY.size:return g.display;case Oo.TEXT.size:return g.text;case Oo.SCRIPT.size:return g.script;case Oo.SCRIPTSCRIPT.size:return g.scriptscript;default:return g.text}};Kd({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(g,I)=>{var{parser:C}=g;return{type:"mathchoice",mode:C.mode,display:Md(I[0]),text:Md(I[1]),script:Md(I[2]),scriptscript:Md(I[3])}},htmlBuilder:(g,I)=>{var C=fn(g,I),A=Ld(C,I,!1);return Wd.makeFragment(A)},mathmlBuilder:(g,I)=>{var C=fn(g,I);return ia(C,I)}});var Fn=(g,I,C,A,i,e,t)=>{g=Wd.makeSpan([],[g]);var l,s,o,c=C&&So.isCharacterBox(C);if(I){var d=Qd(I,A.havingStyle(i.sup()),A);s={elem:d,kern:Math.max(A.fontMetrics().bigOpSpacing1,A.fontMetrics().bigOpSpacing3-d.depth)}}if(C){var a=Qd(C,A.havingStyle(i.sub()),A);l={elem:a,kern:Math.max(A.fontMetrics().bigOpSpacing2,A.fontMetrics().bigOpSpacing4-a.height)}}if(s&&l){var n=A.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+g.depth+t;o=Wd.makeVList({positionType:"bottom",positionData:n,children:[{type:"kern",size:A.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:rc(-e)},{type:"kern",size:l.kern},{type:"elem",elem:g},{type:"kern",size:s.kern},{type:"elem",elem:s.elem,marginLeft:rc(e)},{type:"kern",size:A.fontMetrics().bigOpSpacing5}]},A)}else if(l){var r=g.height-t;o=Wd.makeVList({positionType:"top",positionData:r,children:[{type:"kern",size:A.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:rc(-e)},{type:"kern",size:l.kern},{type:"elem",elem:g}]},A)}else{if(!s)return g;var m=g.depth+t;o=Wd.makeVList({positionType:"bottom",positionData:m,children:[{type:"elem",elem:g},{type:"kern",size:s.kern},{type:"elem",elem:s.elem,marginLeft:rc(e)},{type:"kern",size:A.fontMetrics().bigOpSpacing5}]},A)}var h=[o];if(l&&0!==e&&!c){var Z=Wd.makeSpan(["mspace"],[],A);Z.style.marginRight=rc(e),h.unshift(Z)}return Wd.makeSpan(["mop","op-limits"],h,A)},Mn=["\\smallint"],Sn=(g,I)=>{var C,A,i,e=!1;"supsub"===g.type?(C=g.sup,A=g.sub,i=ra(g.base,"op"),e=!0):i=ra(g,"op");var t,l=I.style,s=!1;if(l.size===Oo.DISPLAY.size&&i.symbol&&!So.contains(Mn,i.name)&&(s=!0),i.symbol){var o=s?"Size2-Regular":"Size1-Regular",c="";if("\\oiint"!==i.name&&"\\oiiint"!==i.name||(c=i.name.slice(1),i.name="oiint"===c?"\\iint":"\\iiint"),t=Wd.makeSymbol(i.name,o,"math",I,["mop","op-symbol",s?"large-op":"small-op"]),c.length>0){var d=t.italic,a=Wd.staticSvg(c+"Size"+(s?"2":"1"),I);t=Wd.makeVList({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:a,shift:s?.08:0}]},I),i.name="\\"+c,t.classes.unshift("mop"),t.italic=d}}else if(i.body){var n=Ld(i.body,I,!0);1===n.length&&n[0]instanceof Wc?(t=n[0]).classes[0]="mop":t=Wd.makeSpan(["mop"],n,I)}else{for(var r=[],m=1;m{var C;if(g.symbol)C=new _d("mo",[ga(g.name,g.mode)]),So.contains(Mn,g.name)&&C.setAttribute("largeop","false");else if(g.body)C=new _d("mo",Aa(g.body,I));else{C=new _d("mi",[new qd(g.name.slice(1))]);var A=new _d("mo",[ga("⁡","text")]);C=g.parentIsSupSub?new _d("mrow",[C,A]):Pd([C,A])}return C},kn={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨆":"\\bigsqcup"};Kd({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],props:{numArgs:0},handler:(g,I)=>{var{parser:C,funcName:A}=g,i=A;return 1===i.length&&(i=kn[i]),{type:"op",mode:C.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:i}},htmlBuilder:Sn,mathmlBuilder:Jn}),Kd({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(g,I)=>{var{parser:C}=g,A=I[0];return{type:"op",mode:C.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:Md(A)}},htmlBuilder:Sn,mathmlBuilder:Jn});var Dn={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint"};Kd({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler(g){var{parser:I,funcName:C}=g;return{type:"op",mode:I.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:C}},htmlBuilder:Sn,mathmlBuilder:Jn}),Kd({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(g){var{parser:I,funcName:C}=g;return{type:"op",mode:I.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:C}},htmlBuilder:Sn,mathmlBuilder:Jn}),Kd({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","∫","∬","∭","∮","∯","∰"],props:{numArgs:0},handler(g){var{parser:I,funcName:C}=g,A=C;return 1===A.length&&(A=Dn[A]),{type:"op",mode:I.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:A}},htmlBuilder:Sn,mathmlBuilder:Jn});var vn=(g,I)=>{var C,A,i,e,t=!1;if("supsub"===g.type?(C=g.sup,A=g.sub,i=ra(g.base,"operatorname"),t=!0):i=ra(g,"operatorname"),i.body.length>0){for(var l=i.body.map((g=>{var I=g.text;return"string"==typeof I?{type:"textord",mode:g.mode,text:I}:g})),s=Ld(l,I.withFont("mathrm"),!0),o=0;o{var{parser:C,funcName:A}=g,i=I[0];return{type:"operatorname",mode:C.mode,body:Md(i),alwaysHandleSupSub:"\\operatornamewithlimits"===A,limits:!1,parentIsSupSub:!1}},htmlBuilder:vn,mathmlBuilder:(g,I)=>{for(var C=Aa(g.body,I.withFont("mathrm")),A=!0,i=0;ig.toText())).join("");C=[new $d.TextNode(l)]}var s=new $d.MathNode("mi",C);s.setAttribute("mathvariant","normal");var o=new $d.MathNode("mo",[ga("⁡","text")]);return g.parentIsSupSub?new $d.MathNode("mrow",[s,o]):$d.newDocumentFragment([s,o])}}),an("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),fd({type:"ordgroup",htmlBuilder:(g,I)=>g.semisimple?Wd.makeFragment(Ld(g.body,I,!1)):Wd.makeSpan(["mord"],Ld(g.body,I,!0),I),mathmlBuilder:(g,I)=>ia(g.body,I,!0)}),Kd({type:"overline",names:["\\overline"],props:{numArgs:1},handler(g,I){var{parser:C}=g,A=I[0];return{type:"overline",mode:C.mode,body:A}},htmlBuilder(g,I){var C=Qd(g.body,I.havingCrampedStyle()),A=Wd.makeLineSpan("overline-line",I),i=I.fontMetrics().defaultRuleThickness,e=Wd.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:C},{type:"kern",size:3*i},{type:"elem",elem:A},{type:"kern",size:i}]},I);return Wd.makeSpan(["mord","overline"],[e],I)},mathmlBuilder(g,I){var C=new $d.MathNode("mo",[new $d.TextNode("‾")]);C.setAttribute("stretchy","true");var A=new $d.MathNode("mover",[ea(g.body,I),C]);return A.setAttribute("accent","true"),A}}),Kd({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(g,I)=>{var{parser:C}=g,A=I[0];return{type:"phantom",mode:C.mode,body:Md(A)}},htmlBuilder:(g,I)=>{var C=Ld(g.body,I.withPhantom(),!1);return Wd.makeFragment(C)},mathmlBuilder:(g,I)=>{var C=Aa(g.body,I);return new $d.MathNode("mphantom",C)}}),Kd({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:(g,I)=>{var{parser:C}=g,A=I[0];return{type:"hphantom",mode:C.mode,body:A}},htmlBuilder:(g,I)=>{var C=Wd.makeSpan([],[Qd(g.body,I.withPhantom())]);if(C.height=0,C.depth=0,C.children)for(var A=0;A{var C=Aa(Md(g.body),I),A=new $d.MathNode("mphantom",C),i=new $d.MathNode("mpadded",[A]);return i.setAttribute("height","0px"),i.setAttribute("depth","0px"),i}}),Kd({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(g,I)=>{var{parser:C}=g,A=I[0];return{type:"vphantom",mode:C.mode,body:A}},htmlBuilder:(g,I)=>{var C=Wd.makeSpan(["inner"],[Qd(g.body,I.withPhantom())]),A=Wd.makeSpan(["fix"],[]);return Wd.makeSpan(["mord","rlap"],[C,A],I)},mathmlBuilder:(g,I)=>{var C=Aa(Md(g.body),I),A=new $d.MathNode("mphantom",C),i=new $d.MathNode("mpadded",[A]);return i.setAttribute("width","0px"),i}}),Kd({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(g,I){var{parser:C}=g,A=ra(I[0],"size").value,i=I[1];return{type:"raisebox",mode:C.mode,dy:A,body:i}},htmlBuilder(g,I){var C=Qd(g.body,I),A=nc(g.dy,I);return Wd.makeVList({positionType:"shift",positionData:-A,children:[{type:"elem",elem:C}]},I)},mathmlBuilder(g,I){var C=new $d.MathNode("mpadded",[ea(g.body,I)]),A=g.dy.number+g.dy.unit;return C.setAttribute("voffset",A),C}}),Kd({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler(g){var{parser:I}=g;return{type:"internal",mode:I.mode}}}),Kd({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"]},handler(g,I,C){var{parser:A}=g,i=C[0],e=ra(I[0],"size"),t=ra(I[1],"size");return{type:"rule",mode:A.mode,shift:i&&ra(i,"size").value,width:e.value,height:t.value}},htmlBuilder(g,I){var C=Wd.makeSpan(["mord","rule"],[],I),A=nc(g.width,I),i=nc(g.height,I),e=g.shift?nc(g.shift,I):0;return C.style.borderRightWidth=rc(A),C.style.borderTopWidth=rc(i),C.style.bottom=rc(e),C.width=A,C.height=i+e,C.depth=-e,C.maxFontSize=1.125*i*I.sizeMultiplier,C},mathmlBuilder(g,I){var C=nc(g.width,I),A=nc(g.height,I),i=g.shift?nc(g.shift,I):0,e=I.color&&I.getColor()||"black",t=new $d.MathNode("mspace");t.setAttribute("mathbackground",e),t.setAttribute("width",rc(C)),t.setAttribute("height",rc(A));var l=new $d.MathNode("mpadded",[t]);return i>=0?l.setAttribute("height",rc(i)):(l.setAttribute("height",rc(i)),l.setAttribute("depth",rc(-i))),l.setAttribute("voffset",rc(i)),l}});var zn=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];Kd({type:"sizing",names:zn,props:{numArgs:0,allowedInText:!0},handler:(g,I)=>{var{breakOnTokenText:C,funcName:A,parser:i}=g,e=i.parseExpression(!1,C);return{type:"sizing",mode:i.mode,size:zn.indexOf(A)+1,body:e}},htmlBuilder:(g,I)=>{var C=I.havingSize(g.size);return Ln(g.body,C,I)},mathmlBuilder:(g,I)=>{var C=I.havingSize(g.size),A=Aa(g.body,C),i=new $d.MathNode("mstyle",A);return i.setAttribute("mathsize",rc(C.sizeMultiplier)),i}}),Kd({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(g,I,C)=>{var{parser:A}=g,i=!1,e=!1,t=C[0]&&ra(C[0],"ordgroup");if(t)for(var l="",s=0;s{var C=Wd.makeSpan([],[Qd(g.body,I)]);if(!g.smashHeight&&!g.smashDepth)return C;if(g.smashHeight&&(C.height=0,C.children))for(var A=0;A{var C=new $d.MathNode("mpadded",[ea(g.body,I)]);return g.smashHeight&&C.setAttribute("height","0px"),g.smashDepth&&C.setAttribute("depth","0px"),C}}),Kd({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(g,I,C){var{parser:A}=g,i=C[0],e=I[0];return{type:"sqrt",mode:A.mode,body:e,index:i}},htmlBuilder(g,I){var C=Qd(g.body,I.havingCrampedStyle());0===C.height&&(C.height=I.fontMetrics().xHeight),C=Wd.wrapFragment(C,I);var A=I.fontMetrics().defaultRuleThickness,i=A;I.style.idC.height+C.depth+e&&(e=(e+c-C.height-C.depth)/2);var d=l.height-C.height-e-s;C.style.paddingLeft=rc(o);var a=Wd.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:C,wrapperClasses:["svg-align"]},{type:"kern",size:-(C.height+d)},{type:"elem",elem:l},{type:"kern",size:s}]},I);if(g.index){var n=I.havingStyle(Oo.SCRIPTSCRIPT),r=Qd(g.index,n,I),m=.6*(a.height-a.depth),h=Wd.makeVList({positionType:"shift",positionData:-m,children:[{type:"elem",elem:r}]},I),Z=Wd.makeSpan(["root"],[h]);return Wd.makeSpan(["mord","sqrt"],[Z,a],I)}return Wd.makeSpan(["mord","sqrt"],[a],I)},mathmlBuilder(g,I){var{body:C,index:A}=g;return A?new $d.MathNode("mroot",[ea(C,I),ea(A,I)]):new $d.MathNode("msqrt",[ea(C,I)])}});var Tn={display:Oo.DISPLAY,text:Oo.TEXT,script:Oo.SCRIPT,scriptscript:Oo.SCRIPTSCRIPT};Kd({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(g,I){var{breakOnTokenText:C,funcName:A,parser:i}=g,e=i.parseExpression(!0,C),t=A.slice(1,A.length-5);return{type:"styling",mode:i.mode,style:t,body:e}},htmlBuilder(g,I){var C=Tn[g.style],A=I.havingStyle(C).withFont("");return Ln(g.body,A,I)},mathmlBuilder(g,I){var C=Tn[g.style],A=I.havingStyle(C),i=Aa(g.body,A),e=new $d.MathNode("mstyle",i),t={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[g.style];return e.setAttribute("scriptlevel",t[0]),e.setAttribute("displaystyle",t[1]),e}});fd({type:"supsub",htmlBuilder(g,I){var C=function(g,I){var C=g.base;return C?"op"===C.type?C.limits&&(I.style.size===Oo.DISPLAY.size||C.alwaysHandleSupSub)?Sn:null:"operatorname"===C.type?C.alwaysHandleSupSub&&(I.style.size===Oo.DISPLAY.size||C.limits)?vn:null:"accent"===C.type?So.isCharacterBox(C.base)?Za:null:"horizBrace"===C.type&&!g.sub===C.isOver?Hn:null:null}(g,I);if(C)return C(g,I);var A,i,e,{base:t,sup:l,sub:s}=g,o=Qd(t,I),c=I.fontMetrics(),d=0,a=0,n=t&&So.isCharacterBox(t);if(l){var r=I.havingStyle(I.style.sup());A=Qd(l,r,I),n||(d=o.height-r.fontMetrics().supDrop*r.sizeMultiplier/I.sizeMultiplier)}if(s){var m=I.havingStyle(I.style.sub());i=Qd(s,m,I),n||(a=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/I.sizeMultiplier)}e=I.style===Oo.DISPLAY?c.sup1:I.style.cramped?c.sup3:c.sup2;var h,Z=I.sizeMultiplier,b=rc(.5/c.ptPerEm/Z),G=null;if(i){var u=g.base&&"op"===g.base.type&&g.base.name&&("\\oiint"===g.base.name||"\\oiiint"===g.base.name);(o instanceof Wc||u)&&(G=rc(-o.italic))}if(A&&i){d=Math.max(d,e,A.depth+.25*c.xHeight),a=Math.max(a,c.sub2);var p=4*c.defaultRuleThickness;if(d-A.depth-(i.height-a)0&&(d+=w,a-=w)}var W=[{type:"elem",elem:i,shift:a,marginRight:b,marginLeft:G},{type:"elem",elem:A,shift:-d,marginRight:b}];h=Wd.makeVList({positionType:"individualShift",children:W},I)}else if(i){a=Math.max(a,c.sub1,i.height-.8*c.xHeight);var B=[{type:"elem",elem:i,marginLeft:G,marginRight:b}];h=Wd.makeVList({positionType:"shift",positionData:a,children:B},I)}else{if(!A)throw new Error("supsub must have either sup or sub.");d=Math.max(d,e,A.depth+.25*c.xHeight),h=Wd.makeVList({positionType:"shift",positionData:-d,children:[{type:"elem",elem:A,marginRight:b}]},I)}var y=Ud(o,"right")||"mord";return Wd.makeSpan([y],[o,Wd.makeSpan(["msupsub"],[h])],I)},mathmlBuilder(g,I){var C,A=!1;g.base&&"horizBrace"===g.base.type&&!!g.sup===g.base.isOver&&(A=!0,C=g.base.isOver),!g.base||"op"!==g.base.type&&"operatorname"!==g.base.type||(g.base.parentIsSupSub=!0);var i,e=[ea(g.base,I)];if(g.sub&&e.push(ea(g.sub,I)),g.sup&&e.push(ea(g.sup,I)),A)i=C?"mover":"munder";else if(g.sub)if(g.sup){var t=g.base;i=t&&"op"===t.type&&t.limits&&I.style===Oo.DISPLAY||t&&"operatorname"===t.type&&t.alwaysHandleSupSub&&(I.style===Oo.DISPLAY||t.limits)?"munderover":"msubsup"}else{var l=g.base;i=l&&"op"===l.type&&l.limits&&(I.style===Oo.DISPLAY||l.alwaysHandleSupSub)||l&&"operatorname"===l.type&&l.alwaysHandleSupSub&&(l.limits||I.style===Oo.DISPLAY)?"munder":"msub"}else{var s=g.base;i=s&&"op"===s.type&&s.limits&&(I.style===Oo.DISPLAY||s.alwaysHandleSupSub)||s&&"operatorname"===s.type&&s.alwaysHandleSupSub&&(s.limits||I.style===Oo.DISPLAY)?"mover":"msup"}return new $d.MathNode(i,e)}}),fd({type:"atom",htmlBuilder:(g,I)=>Wd.mathsym(g.text,g.mode,I,["m"+g.family]),mathmlBuilder(g,I){var C=new $d.MathNode("mo",[ga(g.text,g.mode)]);if("bin"===g.family){var A=Ca(g,I);"bold-italic"===A&&C.setAttribute("mathvariant",A)}else"punct"===g.family?C.setAttribute("separator","true"):"open"!==g.family&&"close"!==g.family||C.setAttribute("stretchy","false");return C}});var xn={mi:"italic",mn:"normal",mtext:"normal"};fd({type:"mathord",htmlBuilder:(g,I)=>Wd.makeOrd(g,I,"mathord"),mathmlBuilder(g,I){var C=new $d.MathNode("mi",[ga(g.text,g.mode,I)]),A=Ca(g,I)||"italic";return A!==xn[C.type]&&C.setAttribute("mathvariant",A),C}}),fd({type:"textord",htmlBuilder:(g,I)=>Wd.makeOrd(g,I,"textord"),mathmlBuilder(g,I){var C,A=ga(g.text,g.mode,I),i=Ca(g,I)||"normal";return C="text"===g.mode?new $d.MathNode("mtext",[A]):/[0-9]/.test(g.text)?new $d.MathNode("mn",[A]):"\\prime"===g.text?new $d.MathNode("mo",[A]):new $d.MathNode("mi",[A]),i!==xn[C.type]&&C.setAttribute("mathvariant",i),C}});var Un={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},jn={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};fd({type:"spacing",htmlBuilder(g,I){if(jn.hasOwnProperty(g.text)){var C=jn[g.text].className||"";if("text"===g.mode){var A=Wd.makeOrd(g,I,"textord");return A.classes.push(C),A}return Wd.makeSpan(["mspace",C],[Wd.mathsym(g.text,g.mode,I)],I)}if(Un.hasOwnProperty(g.text))return Wd.makeSpan(["mspace",Un[g.text]],[],I);throw new Ho('Unknown type of space "'+g.text+'"')},mathmlBuilder(g,I){if(!jn.hasOwnProperty(g.text)){if(Un.hasOwnProperty(g.text))return new $d.MathNode("mspace");throw new Ho('Unknown type of space "'+g.text+'"')}return new $d.MathNode("mtext",[new $d.TextNode(" ")])}});var Qn=()=>{var g=new $d.MathNode("mtd",[]);return g.setAttribute("width","50%"),g};fd({type:"tag",mathmlBuilder(g,I){var C=new $d.MathNode("mtable",[new $d.MathNode("mtr",[Qn(),new $d.MathNode("mtd",[ia(g.body,I)]),Qn(),new $d.MathNode("mtd",[ia(g.tag,I)])])]);return C.setAttribute("width","100%"),C}});var On={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},En={"\\textbf":"textbf","\\textmd":"textmd"},Pn={"\\textit":"textit","\\textup":"textup"},_n=(g,I)=>{var C=g.font;return C?On[C]?I.withTextFontFamily(On[C]):En[C]?I.withTextFontWeight(En[C]):"\\emph"===C?"textit"===I.fontShape?I.withTextFontShape("textup"):I.withTextFontShape("textit"):I.withTextFontShape(Pn[C]):I};Kd({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(g,I){var{parser:C,funcName:A}=g,i=I[0];return{type:"text",mode:C.mode,body:Md(i),font:A}},htmlBuilder(g,I){var C=_n(g,I),A=Ld(g.body,C,!0);return Wd.makeSpan(["mord","text"],A,C)},mathmlBuilder(g,I){var C=_n(g,I);return ia(g.body,C)}}),Kd({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(g,I){var{parser:C}=g;return{type:"underline",mode:C.mode,body:I[0]}},htmlBuilder(g,I){var C=Qd(g.body,I),A=Wd.makeLineSpan("underline-line",I),i=I.fontMetrics().defaultRuleThickness,e=Wd.makeVList({positionType:"top",positionData:C.height,children:[{type:"kern",size:i},{type:"elem",elem:A},{type:"kern",size:3*i},{type:"elem",elem:C}]},I);return Wd.makeSpan(["mord","underline"],[e],I)},mathmlBuilder(g,I){var C=new $d.MathNode("mo",[new $d.TextNode("‾")]);C.setAttribute("stretchy","true");var A=new $d.MathNode("munder",[ea(g.body,I),C]);return A.setAttribute("accentunder","true"),A}}),Kd({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(g,I){var{parser:C}=g;return{type:"vcenter",mode:C.mode,body:I[0]}},htmlBuilder(g,I){var C=Qd(g.body,I),A=I.fontMetrics().axisHeight,i=.5*(C.height-A-(C.depth+A));return Wd.makeVList({positionType:"shift",positionData:i,children:[{type:"elem",elem:C}]},I)},mathmlBuilder:(g,I)=>new $d.MathNode("mpadded",[ea(g.body,I)],["vcenter"])}),Kd({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(g,I,C){throw new Ho("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(g,I){for(var C=qn(g),A=[],i=I.havingStyle(I.style.text()),e=0;eg.body.replace(/ /g,g.star?"␣":" "),$n=Rd,gr="[ \r\n\t]",Ir="(\\\\[a-zA-Z@]+)"+gr+"*",Cr="[̀-ͯ]",Ar=new RegExp(Cr+"+$"),ir="("+gr+"+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-‧‪-퟿豈-￿]"+Cr+"*|[\ud800-\udbff][\udc00-\udfff]"+Cr+"*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|"+Ir+"|\\\\[^\ud800-\udfff])";class er{constructor(g,I){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=g,this.settings=I,this.tokenRegex=new RegExp(ir,"g"),this.catcodes={"%":14,"~":13}}setCatcode(g,I){this.catcodes[g]=I}lex(){var g=this.input,I=this.tokenRegex.lastIndex;if(I===g.length)return new No("EOF",new Ro(this,I,I));var C=this.tokenRegex.exec(g);if(null===C||C.index!==I)throw new Ho("Unexpected character: '"+g[I]+"'",new No(g[I],new Ro(this,I,I+1)));var A=C[6]||C[3]||(C[2]?"\\ ":" ");if(14===this.catcodes[A]){var i=g.indexOf("\n",this.tokenRegex.lastIndex);return-1===i?(this.tokenRegex.lastIndex=g.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=i+1,this.lex()}return new No(A,new Ro(this,I,this.tokenRegex.lastIndex))}}class tr{constructor(g,I){void 0===g&&(g={}),void 0===I&&(I={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=I,this.builtins=g,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(0===this.undefStack.length)throw new Ho("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var g=this.undefStack.pop();for(var I in g)g.hasOwnProperty(I)&&(null==g[I]?delete this.current[I]:this.current[I]=g[I])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(g){return this.current.hasOwnProperty(g)||this.builtins.hasOwnProperty(g)}get(g){return this.current.hasOwnProperty(g)?this.current[g]:this.builtins[g]}set(g,I,C){if(void 0===C&&(C=!1),C){for(var A=0;A0&&(this.undefStack[this.undefStack.length-1][g]=I)}else{var i=this.undefStack[this.undefStack.length-1];i&&!i.hasOwnProperty(g)&&(i[g]=this.current[g])}null==I?delete this.current[g]:this.current[g]=I}}var lr=dn;an("\\noexpand",(function(g){var I=g.popToken();return g.isExpandable(I.text)&&(I.noexpand=!0,I.treatAsRelax=!0),{tokens:[I],numArgs:0}})),an("\\expandafter",(function(g){var I=g.popToken();return g.expandOnce(!0),{tokens:[I],numArgs:0}})),an("\\@firstoftwo",(function(g){return{tokens:g.consumeArgs(2)[0],numArgs:0}})),an("\\@secondoftwo",(function(g){return{tokens:g.consumeArgs(2)[1],numArgs:0}})),an("\\@ifnextchar",(function(g){var I=g.consumeArgs(3);g.consumeSpaces();var C=g.future();return 1===I[0].length&&I[0][0].text===C.text?{tokens:I[1],numArgs:0}:{tokens:I[2],numArgs:0}})),an("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),an("\\TextOrMath",(function(g){var I=g.consumeArgs(2);return"text"===g.mode?{tokens:I[0],numArgs:0}:{tokens:I[1],numArgs:0}}));var sr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};an("\\char",(function(g){var I,C=g.popToken(),A="";if("'"===C.text)I=8,C=g.popToken();else if('"'===C.text)I=16,C=g.popToken();else if("`"===C.text)if("\\"===(C=g.popToken()).text[0])A=C.text.charCodeAt(1);else{if("EOF"===C.text)throw new Ho("\\char` missing argument");A=C.text.charCodeAt(0)}else I=10;if(I){if(null==(A=sr[C.text])||A>=I)throw new Ho("Invalid base-"+I+" digit "+C.text);for(var i;null!=(i=sr[g.future().text])&&i{var A=g.consumeArg().tokens;if(1!==A.length)throw new Ho("\\newcommand's first argument must be a macro name");var i=A[0].text,e=g.isDefined(i);if(e&&!I)throw new Ho("\\newcommand{"+i+"} attempting to redefine "+i+"; use \\renewcommand");if(!e&&!C)throw new Ho("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");var t=0;if(1===(A=g.consumeArg().tokens).length&&"["===A[0].text){for(var l="",s=g.expandNextToken();"]"!==s.text&&"EOF"!==s.text;)l+=s.text,s=g.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new Ho("Invalid number of arguments: "+l);t=parseInt(l),A=g.consumeArg().tokens}return g.macros.set(i,{tokens:A,numArgs:t}),""};an("\\newcommand",(g=>or(g,!1,!0))),an("\\renewcommand",(g=>or(g,!0,!1))),an("\\providecommand",(g=>or(g,!0,!0))),an("\\message",(g=>{var I=g.consumeArgs(1)[0];return console.log(I.reverse().map((g=>g.text)).join("")),""})),an("\\errmessage",(g=>{var I=g.consumeArgs(1)[0];return console.error(I.reverse().map((g=>g.text)).join("")),""})),an("\\show",(g=>{var I=g.popToken(),C=I.text;return console.log(I,g.macros.get(C),$n[C],Nc.math[C],Nc.text[C]),""})),an("\\bgroup","{"),an("\\egroup","}"),an("~","\\nobreakspace"),an("\\lq","`"),an("\\rq","'"),an("\\aa","\\r a"),an("\\AA","\\r A"),an("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}"),an("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),an("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),an("ℬ","\\mathscr{B}"),an("ℰ","\\mathscr{E}"),an("ℱ","\\mathscr{F}"),an("ℋ","\\mathscr{H}"),an("ℐ","\\mathscr{I}"),an("ℒ","\\mathscr{L}"),an("ℳ","\\mathscr{M}"),an("ℛ","\\mathscr{R}"),an("ℭ","\\mathfrak{C}"),an("ℌ","\\mathfrak{H}"),an("ℨ","\\mathfrak{Z}"),an("\\Bbbk","\\Bbb{k}"),an("·","\\cdotp"),an("\\llap","\\mathllap{\\textrm{#1}}"),an("\\rlap","\\mathrlap{\\textrm{#1}}"),an("\\clap","\\mathclap{\\textrm{#1}}"),an("\\mathstrut","\\vphantom{(}"),an("\\underbar","\\underline{\\text{#1}}"),an("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'),an("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),an("\\ne","\\neq"),an("≠","\\neq"),an("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),an("∉","\\notin"),an("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),an("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),an("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),an("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),an("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),an("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),an("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),an("⟂","\\perp"),an("‼","\\mathclose{!\\mkern-0.8mu!}"),an("∌","\\notni"),an("⌜","\\ulcorner"),an("⌝","\\urcorner"),an("⌞","\\llcorner"),an("⌟","\\lrcorner"),an("©","\\copyright"),an("®","\\textregistered"),an("️","\\textregistered"),an("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),an("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),an("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),an("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),an("\\vdots","\\mathord{\\varvdots\\rule{0pt}{15pt}}"),an("⋮","\\vdots"),an("\\varGamma","\\mathit{\\Gamma}"),an("\\varDelta","\\mathit{\\Delta}"),an("\\varTheta","\\mathit{\\Theta}"),an("\\varLambda","\\mathit{\\Lambda}"),an("\\varXi","\\mathit{\\Xi}"),an("\\varPi","\\mathit{\\Pi}"),an("\\varSigma","\\mathit{\\Sigma}"),an("\\varUpsilon","\\mathit{\\Upsilon}"),an("\\varPhi","\\mathit{\\Phi}"),an("\\varPsi","\\mathit{\\Psi}"),an("\\varOmega","\\mathit{\\Omega}"),an("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),an("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),an("\\boxed","\\fbox{$\\displaystyle{#1}$}"),an("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),an("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),an("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");var cr={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};an("\\dots",(function(g){var I="\\dotso",C=g.expandAfterFuture().text;return C in cr?I=cr[C]:("\\not"===C.slice(0,4)||C in Nc.math&&So.contains(["bin","rel"],Nc.math[C].group))&&(I="\\dotsb"),I}));var dr={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};an("\\dotso",(function(g){return g.future().text in dr?"\\ldots\\,":"\\ldots"})),an("\\dotsc",(function(g){var I=g.future().text;return I in dr&&","!==I?"\\ldots\\,":"\\ldots"})),an("\\cdots",(function(g){return g.future().text in dr?"\\@cdots\\,":"\\@cdots"})),an("\\dotsb","\\cdots"),an("\\dotsm","\\cdots"),an("\\dotsi","\\!\\cdots"),an("\\dotsx","\\ldots\\,"),an("\\DOTSI","\\relax"),an("\\DOTSB","\\relax"),an("\\DOTSX","\\relax"),an("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),an("\\,","\\tmspace+{3mu}{.1667em}"),an("\\thinspace","\\,"),an("\\>","\\mskip{4mu}"),an("\\:","\\tmspace+{4mu}{.2222em}"),an("\\medspace","\\:"),an("\\;","\\tmspace+{5mu}{.2777em}"),an("\\thickspace","\\;"),an("\\!","\\tmspace-{3mu}{.1667em}"),an("\\negthinspace","\\!"),an("\\negmedspace","\\tmspace-{4mu}{.2222em}"),an("\\negthickspace","\\tmspace-{5mu}{.277em}"),an("\\enspace","\\kern.5em "),an("\\enskip","\\hskip.5em\\relax"),an("\\quad","\\hskip1em\\relax"),an("\\qquad","\\hskip2em\\relax"),an("\\tag","\\@ifstar\\tag@literal\\tag@paren"),an("\\tag@paren","\\tag@literal{({#1})}"),an("\\tag@literal",(g=>{if(g.macros.get("\\df@tag"))throw new Ho("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"})),an("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),an("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),an("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),an("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),an("\\newline","\\\\\\relax"),an("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var ar=rc(Ic["Main-Regular"]["T".charCodeAt(0)][1]-.7*Ic["Main-Regular"]["A".charCodeAt(0)][1]);an("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+ar+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),an("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+ar+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),an("\\hspace","\\@ifstar\\@hspacer\\@hspace"),an("\\@hspace","\\hskip #1\\relax"),an("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),an("\\ordinarycolon",":"),an("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),an("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),an("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),an("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),an("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),an("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),an("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),an("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),an("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),an("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),an("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),an("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),an("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),an("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),an("∷","\\dblcolon"),an("∹","\\eqcolon"),an("≔","\\coloneqq"),an("≕","\\eqqcolon"),an("⩴","\\Coloneqq"),an("\\ratio","\\vcentcolon"),an("\\coloncolon","\\dblcolon"),an("\\colonequals","\\coloneqq"),an("\\coloncolonequals","\\Coloneqq"),an("\\equalscolon","\\eqqcolon"),an("\\equalscoloncolon","\\Eqqcolon"),an("\\colonminus","\\coloneq"),an("\\coloncolonminus","\\Coloneq"),an("\\minuscolon","\\eqcolon"),an("\\minuscoloncolon","\\Eqcolon"),an("\\coloncolonapprox","\\Colonapprox"),an("\\coloncolonsim","\\Colonsim"),an("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),an("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),an("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),an("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),an("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),an("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),an("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),an("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),an("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),an("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),an("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),an("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),an("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),an("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}"),an("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}"),an("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}"),an("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}"),an("\\nleqq","\\html@mathml{\\@nleqq}{≰}"),an("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}"),an("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}"),an("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}"),an("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}"),an("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}"),an("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}"),an("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}"),an("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}"),an("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}"),an("\\imath","\\html@mathml{\\@imath}{ı}"),an("\\jmath","\\html@mathml{\\@jmath}{ȷ}"),an("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),an("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),an("⟦","\\llbracket"),an("⟧","\\rrbracket"),an("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),an("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),an("⦃","\\lBrace"),an("⦄","\\rBrace"),an("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),an("⦵","\\minuso"),an("\\darr","\\downarrow"),an("\\dArr","\\Downarrow"),an("\\Darr","\\Downarrow"),an("\\lang","\\langle"),an("\\rang","\\rangle"),an("\\uarr","\\uparrow"),an("\\uArr","\\Uparrow"),an("\\Uarr","\\Uparrow"),an("\\N","\\mathbb{N}"),an("\\R","\\mathbb{R}"),an("\\Z","\\mathbb{Z}"),an("\\alef","\\aleph"),an("\\alefsym","\\aleph"),an("\\Alpha","\\mathrm{A}"),an("\\Beta","\\mathrm{B}"),an("\\bull","\\bullet"),an("\\Chi","\\mathrm{X}"),an("\\clubs","\\clubsuit"),an("\\cnums","\\mathbb{C}"),an("\\Complex","\\mathbb{C}"),an("\\Dagger","\\ddagger"),an("\\diamonds","\\diamondsuit"),an("\\empty","\\emptyset"),an("\\Epsilon","\\mathrm{E}"),an("\\Eta","\\mathrm{H}"),an("\\exist","\\exists"),an("\\harr","\\leftrightarrow"),an("\\hArr","\\Leftrightarrow"),an("\\Harr","\\Leftrightarrow"),an("\\hearts","\\heartsuit"),an("\\image","\\Im"),an("\\infin","\\infty"),an("\\Iota","\\mathrm{I}"),an("\\isin","\\in"),an("\\Kappa","\\mathrm{K}"),an("\\larr","\\leftarrow"),an("\\lArr","\\Leftarrow"),an("\\Larr","\\Leftarrow"),an("\\lrarr","\\leftrightarrow"),an("\\lrArr","\\Leftrightarrow"),an("\\Lrarr","\\Leftrightarrow"),an("\\Mu","\\mathrm{M}"),an("\\natnums","\\mathbb{N}"),an("\\Nu","\\mathrm{N}"),an("\\Omicron","\\mathrm{O}"),an("\\plusmn","\\pm"),an("\\rarr","\\rightarrow"),an("\\rArr","\\Rightarrow"),an("\\Rarr","\\Rightarrow"),an("\\real","\\Re"),an("\\reals","\\mathbb{R}"),an("\\Reals","\\mathbb{R}"),an("\\Rho","\\mathrm{P}"),an("\\sdot","\\cdot"),an("\\sect","\\S"),an("\\spades","\\spadesuit"),an("\\sub","\\subset"),an("\\sube","\\subseteq"),an("\\supe","\\supseteq"),an("\\Tau","\\mathrm{T}"),an("\\thetasym","\\vartheta"),an("\\weierp","\\wp"),an("\\Zeta","\\mathrm{Z}"),an("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),an("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),an("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),an("\\bra","\\mathinner{\\langle{#1}|}"),an("\\ket","\\mathinner{|{#1}\\rangle}"),an("\\braket","\\mathinner{\\langle{#1}\\rangle}"),an("\\Bra","\\left\\langle#1\\right|"),an("\\Ket","\\left|#1\\right\\rangle");var nr=g=>I=>{var C=I.consumeArg().tokens,A=I.consumeArg().tokens,i=I.consumeArg().tokens,e=I.consumeArg().tokens,t=I.macros.get("|"),l=I.macros.get("\\|");I.macros.beginGroup();var s=I=>C=>{g&&(C.macros.set("|",t),i.length&&C.macros.set("\\|",l));var e=I;!I&&i.length&&("|"===C.future().text&&(C.popToken(),e=!0));return{tokens:e?i:A,numArgs:0}};I.macros.set("|",s(!1)),i.length&&I.macros.set("\\|",s(!0));var o=I.consumeArg().tokens,c=I.expandTokens([...e,...o,...C]);return I.macros.endGroup(),{tokens:c.reverse(),numArgs:0}};an("\\bra@ket",nr(!1)),an("\\bra@set",nr(!0)),an("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),an("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),an("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),an("\\angln","{\\angl n}"),an("\\blue","\\textcolor{##6495ed}{#1}"),an("\\orange","\\textcolor{##ffa500}{#1}"),an("\\pink","\\textcolor{##ff00af}{#1}"),an("\\red","\\textcolor{##df0030}{#1}"),an("\\green","\\textcolor{##28ae7b}{#1}"),an("\\gray","\\textcolor{gray}{#1}"),an("\\purple","\\textcolor{##9d38bd}{#1}"),an("\\blueA","\\textcolor{##ccfaff}{#1}"),an("\\blueB","\\textcolor{##80f6ff}{#1}"),an("\\blueC","\\textcolor{##63d9ea}{#1}"),an("\\blueD","\\textcolor{##11accd}{#1}"),an("\\blueE","\\textcolor{##0c7f99}{#1}"),an("\\tealA","\\textcolor{##94fff5}{#1}"),an("\\tealB","\\textcolor{##26edd5}{#1}"),an("\\tealC","\\textcolor{##01d1c1}{#1}"),an("\\tealD","\\textcolor{##01a995}{#1}"),an("\\tealE","\\textcolor{##208170}{#1}"),an("\\greenA","\\textcolor{##b6ffb0}{#1}"),an("\\greenB","\\textcolor{##8af281}{#1}"),an("\\greenC","\\textcolor{##74cf70}{#1}"),an("\\greenD","\\textcolor{##1fab54}{#1}"),an("\\greenE","\\textcolor{##0d923f}{#1}"),an("\\goldA","\\textcolor{##ffd0a9}{#1}"),an("\\goldB","\\textcolor{##ffbb71}{#1}"),an("\\goldC","\\textcolor{##ff9c39}{#1}"),an("\\goldD","\\textcolor{##e07d10}{#1}"),an("\\goldE","\\textcolor{##a75a05}{#1}"),an("\\redA","\\textcolor{##fca9a9}{#1}"),an("\\redB","\\textcolor{##ff8482}{#1}"),an("\\redC","\\textcolor{##f9685d}{#1}"),an("\\redD","\\textcolor{##e84d39}{#1}"),an("\\redE","\\textcolor{##bc2612}{#1}"),an("\\maroonA","\\textcolor{##ffbde0}{#1}"),an("\\maroonB","\\textcolor{##ff92c6}{#1}"),an("\\maroonC","\\textcolor{##ed5fa6}{#1}"),an("\\maroonD","\\textcolor{##ca337c}{#1}"),an("\\maroonE","\\textcolor{##9e034e}{#1}"),an("\\purpleA","\\textcolor{##ddd7ff}{#1}"),an("\\purpleB","\\textcolor{##c6b9fc}{#1}"),an("\\purpleC","\\textcolor{##aa87ff}{#1}"),an("\\purpleD","\\textcolor{##7854ab}{#1}"),an("\\purpleE","\\textcolor{##543b78}{#1}"),an("\\mintA","\\textcolor{##f5f9e8}{#1}"),an("\\mintB","\\textcolor{##edf2df}{#1}"),an("\\mintC","\\textcolor{##e0e5cc}{#1}"),an("\\grayA","\\textcolor{##f6f7f7}{#1}"),an("\\grayB","\\textcolor{##f0f1f2}{#1}"),an("\\grayC","\\textcolor{##e3e5e6}{#1}"),an("\\grayD","\\textcolor{##d6d8da}{#1}"),an("\\grayE","\\textcolor{##babec2}{#1}"),an("\\grayF","\\textcolor{##888d93}{#1}"),an("\\grayG","\\textcolor{##626569}{#1}"),an("\\grayH","\\textcolor{##3b3e40}{#1}"),an("\\grayI","\\textcolor{##21242c}{#1}"),an("\\kaBlue","\\textcolor{##314453}{#1}"),an("\\kaGreen","\\textcolor{##71B307}{#1}");var rr={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class mr{constructor(g,I,C){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=I,this.expansionCount=0,this.feed(g),this.macros=new tr(lr,I.macros),this.mode=C,this.stack=[]}feed(g){this.lexer=new er(g,this.settings)}switchMode(g){this.mode=g}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(g){this.stack.push(g)}pushTokens(g){this.stack.push(...g)}scanArgument(g){var I,C,A;if(g){if(this.consumeSpaces(),"["!==this.future().text)return null;I=this.popToken(),({tokens:A,end:C}=this.consumeArg(["]"]))}else({tokens:A,start:I,end:C}=this.consumeArg());return this.pushToken(new No("EOF",C.loc)),this.pushTokens(A),I.range(C,"")}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(g){var I=[],C=g&&g.length>0;C||this.consumeSpaces();var A,i=this.future(),e=0,t=0;do{if(A=this.popToken(),I.push(A),"{"===A.text)++e;else if("}"===A.text){if(-1===--e)throw new Ho("Extra }",A)}else if("EOF"===A.text)throw new Ho("Unexpected end of input in a macro argument, expected '"+(g&&C?g[t]:"}")+"'",A);if(g&&C)if((0===e||1===e&&"{"===g[t])&&A.text===g[t]){if(++t===g.length){I.splice(-t,t);break}}else t=0}while(0!==e||C);return"{"===i.text&&"}"===I[I.length-1].text&&(I.pop(),I.shift()),I.reverse(),{tokens:I,start:i,end:A}}consumeArgs(g,I){if(I){if(I.length!==g+1)throw new Ho("The length of delimiters doesn't match the number of args!");for(var C=I[0],A=0;Athis.settings.maxExpand)throw new Ho("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(g){var I=this.popToken(),C=I.text,A=I.noexpand?null:this._getExpansion(C);if(null==A||g&&A.unexpandable){if(g&&null==A&&"\\"===C[0]&&!this.isDefined(C))throw new Ho("Undefined control sequence: "+C);return this.pushToken(I),!1}this.countExpansion(1);var i=A.tokens,e=this.consumeArgs(A.numArgs,A.delimiters);if(A.numArgs)for(var t=(i=i.slice()).length-1;t>=0;--t){var l=i[t];if("#"===l.text){if(0===t)throw new Ho("Incomplete placeholder at end of macro body",l);if("#"===(l=i[--t]).text)i.splice(t+1,1);else{if(!/^[1-9]$/.test(l.text))throw new Ho("Not a valid argument number",l);i.splice(t,2,...e[+l.text-1])}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){var g=this.stack.pop();return g.treatAsRelax&&(g.text="\\relax"),g}throw new Error}expandMacro(g){return this.macros.has(g)?this.expandTokens([new No(g)]):void 0}expandTokens(g){var I=[],C=this.stack.length;for(this.pushTokens(g);this.stack.length>C;)if(!1===this.expandOnce(!0)){var A=this.stack.pop();A.treatAsRelax&&(A.noexpand=!1,A.treatAsRelax=!1),I.push(A)}return this.countExpansion(I.length),I}expandMacroAsText(g){var I=this.expandMacro(g);return I?I.map((g=>g.text)).join(""):I}_getExpansion(g){var I=this.macros.get(g);if(null==I)return I;if(1===g.length){var C=this.lexer.catcodes[g];if(null!=C&&13!==C)return}var A="function"==typeof I?I(this):I;if("string"==typeof A){var i=0;if(-1!==A.indexOf("#"))for(var e=A.replace(/##/g,"");-1!==e.indexOf("#"+(i+1));)++i;for(var t=new er(A,this.settings),l=[],s=t.lex();"EOF"!==s.text;)l.push(s),s=t.lex();return l.reverse(),{tokens:l,numArgs:i}}return A}isDefined(g){return this.macros.has(g)||$n.hasOwnProperty(g)||Nc.math.hasOwnProperty(g)||Nc.text.hasOwnProperty(g)||rr.hasOwnProperty(g)}isExpandable(g){var I=this.macros.get(g);return null!=I?"string"==typeof I||"function"==typeof I||!I.unexpandable:$n.hasOwnProperty(g)&&!$n[g].primitive}}var hr=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Zr=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g","ʰ":"h","ⁱ":"i","ʲ":"j","ᵏ":"k","ˡ":"l","ᵐ":"m","ⁿ":"n","ᵒ":"o","ᵖ":"p","ʳ":"r","ˢ":"s","ᵗ":"t","ᵘ":"u","ᵛ":"v","ʷ":"w","ˣ":"x","ʸ":"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),br={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},Gr={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","ḉ":"ḉ","č":"č","ĉ":"ĉ","ċ":"ċ","ç":"ç","ď":"ď","ḋ":"ḋ","ḑ":"ḑ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ḝ":"ḝ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ȩ":"ȩ","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ģ":"ģ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","ḩ":"ḩ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ķ":"ķ","ĺ":"ĺ","ľ":"ľ","ļ":"ļ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ņ":"ņ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ŗ":"ŗ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ş":"ş","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ţ":"ţ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Ḉ":"Ḉ","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ç":"Ç","Ď":"Ď","Ḋ":"Ḋ","Ḑ":"Ḑ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ḝ":"Ḝ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ȩ":"Ȩ","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ģ":"Ģ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Ḩ":"Ḩ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ķ":"Ķ","Ĺ":"Ĺ","Ľ":"Ľ","Ļ":"Ļ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ņ":"Ņ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"Ȯ","Ȱ":"Ȱ","Ő":"Ő","Ṕ":"Ṕ","Ṗ":"Ṗ","Ŕ":"Ŕ","Ř":"Ř","Ṙ":"Ṙ","Ŗ":"Ŗ","Ś":"Ś","Ṥ":"Ṥ","Š":"Š","Ṧ":"Ṧ","Ŝ":"Ŝ","Ṡ":"Ṡ","Ş":"Ş","Ť":"Ť","Ṫ":"Ṫ","Ţ":"Ţ","Ú":"Ú","Ù":"Ù","Ü":"Ü","Ǘ":"Ǘ","Ǜ":"Ǜ","Ǖ":"Ǖ","Ǚ":"Ǚ","Ũ":"Ũ","Ṹ":"Ṹ","Ū":"Ū","Ṻ":"Ṻ","Ŭ":"Ŭ","Ǔ":"Ǔ","Û":"Û","Ů":"Ů","Ű":"Ű","Ṽ":"Ṽ","Ẃ":"Ẃ","Ẁ":"Ẁ","Ẅ":"Ẅ","Ŵ":"Ŵ","Ẇ":"Ẇ","Ẍ":"Ẍ","Ẋ":"Ẋ","Ý":"Ý","Ỳ":"Ỳ","Ÿ":"Ÿ","Ỹ":"Ỹ","Ȳ":"Ȳ","Ŷ":"Ŷ","Ẏ":"Ẏ","Ź":"Ź","Ž":"Ž","Ẑ":"Ẑ","Ż":"Ż","ά":"ά","ὰ":"ὰ","ᾱ":"ᾱ","ᾰ":"ᾰ","έ":"έ","ὲ":"ὲ","ή":"ή","ὴ":"ὴ","ί":"ί","ὶ":"ὶ","ϊ":"ϊ","ΐ":"ΐ","ῒ":"ῒ","ῑ":"ῑ","ῐ":"ῐ","ό":"ό","ὸ":"ὸ","ύ":"ύ","ὺ":"ὺ","ϋ":"ϋ","ΰ":"ΰ","ῢ":"ῢ","ῡ":"ῡ","ῠ":"ῠ","ώ":"ώ","ὼ":"ὼ","Ύ":"Ύ","Ὺ":"Ὺ","Ϋ":"Ϋ","Ῡ":"Ῡ","Ῠ":"Ῠ","Ώ":"Ώ","Ὼ":"Ὼ"};class ur{constructor(g,I){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new mr(g,I,this.mode),this.settings=I,this.leftrightDepth=0}expect(g,I){if(void 0===I&&(I=!0),this.fetch().text!==g)throw new Ho("Expected '"+g+"', got '"+this.fetch().text+"'",this.fetch());I&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(g){this.mode=g,this.gullet.switchMode(g)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var g=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),g}finally{this.gullet.endGroups()}}subparse(g){var I=this.nextToken;this.consume(),this.gullet.pushToken(new No("}")),this.gullet.pushTokens(g);var C=this.parseExpression(!1);return this.expect("}"),this.nextToken=I,C}parseExpression(g,I){for(var C=[];;){"math"===this.mode&&this.consumeSpaces();var A=this.fetch();if(-1!==ur.endOfExpression.indexOf(A.text))break;if(I&&A.text===I)break;if(g&&$n[A.text]&&$n[A.text].infix)break;var i=this.parseAtom(I);if(!i)break;"internal"!==i.type&&C.push(i)}return"text"===this.mode&&this.formLigatures(C),this.handleInfixNodes(C)}handleInfixNodes(g){for(var I,C=-1,A=0;A=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+I[0]+'" used in math mode',g);var t,l=Nc[this.mode][I].group,s=Ro.range(g);if(Yc.hasOwnProperty(l)){var o=l;t={type:"atom",mode:this.mode,family:o,loc:s,text:I}}else t={type:l,mode:this.mode,loc:s,text:I};i=t}else{if(!(I.charCodeAt(0)>=128))return null;this.settings.strict&&(_o(I.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+I[0]+'" used in math mode',g):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+I[0]+'" ('+I.charCodeAt(0)+")",g)),i={type:"textord",mode:"text",loc:Ro.range(g),text:I}}if(this.consume(),e)for(var c=0;cg.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))).join("|")+")");-1!==(C=g.search(i));){C>0&&(A.push({type:"text",data:g.slice(0,C)}),g=g.slice(C));var e=I.findIndex((I=>g.startsWith(I.left)));if(-1===(C=Vr(I[e].right,g,I[e].left.length)))break;var t=g.slice(0,C+I[e].right.length),l=Xr.test(t)?t:g.slice(I[e].left.length,C);A.push({type:"math",data:l,rawData:t,display:I[e].display}),g=g.slice(C+I[e].right.length)}return""!==g&&A.push({type:"text",data:g}),A}(g,I.delimiters);if(1===C.length&&"text"===C[0].type)return null;for(var A=document.createDocumentFragment(),i=0;i-1===I.indexOf(" "+g+" ")))&&g(i,C)}()}},Nr=function(g,I){if(!g)throw new Error("No element provided to render");var C={};for(var A in I)I.hasOwnProperty(A)&&(C[A]=I[A]);C.delimiters=C.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],C.ignoredTags=C.ignoredTags||["script","noscript","style","textarea","pre","code","option"],C.ignoredClasses=C.ignoredClasses||[],C.errorCallback=C.errorCallback||console.error,C.macros=C.macros||{},Rr(g,C)};const Hr=Object.freeze(Object.defineProperty({__proto__:null,default:Nr,renderMathInElement:Nr},Symbol.toStringTag,{value:"Module"}));g.button=J,g.checkbox=kg,g.colorpicker=AI,g.icon=z,g.image=x,g.input=Q,g.loading=lI,g.math=cI,g.message=q,g.modal=Hg,g.player=Rg,g.popover=Eg,g.preview=ig,g.progress=Mg,g.radar=hg,g.select=Wg,g.skeleton=tg,g.tab=cg,g.tabpane=sg,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
"+g+""+g+""+g+"
"+g+"